1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright 2008-2012 Freescale Semiconductor Inc. 3 * Copyright 2017-2020 NXP 4 */ 5 6 #ifndef __FM_EXT_H 7 #define __FM_EXT_H 8 9 #include "ncsw_ext.h" 10 #include "dpaa_integration.h" 11 12 #define FM_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 1) 13 #define FMT_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 3) 14 15 #define MODULE_FM 0x00010000 16 #define __ERR_MODULE__ MODULE_FM 17 18 /* #define FM_LIB_DBG */ 19 20 #if defined(FM_LIB_DBG) 21 #define _fml_dbg(fmt, args...) \ 22 rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmlib:%s(): " fmt "\n", \ 23 __func__, ##args) 24 #else 25 #define _fml_dbg(arg...) 26 #endif 27 28 /*#define FM_IOCTL_DBG*/ 29 30 #if defined(FM_IOCTL_DBG) 31 #define _fm_ioctl_dbg(fmt, args...) \ 32 rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmioc:%s(): " fmt "\n", \ 33 __func__, ##args) 34 #else 35 #define _fm_ioctl_dbg(arg...) 36 #endif 37 38 /* 39 * @Group lnx_ioctl_ncsw_grp NetCommSw Linux User-Space (IOCTL) API 40 * @{ 41 */ 42 43 #define NCSW_IOC_TYPE_BASE 0xe0 44 /**< defines the IOCTL type for all the NCSW Linux module commands */ 45 46 /* 47 * @Group lnx_usr_FM_grp Frame Manager API 48 * 49 * @Description FM API functions, definitions and enums. 50 * 51 * The FM module is the main driver module and is a mandatory 52 * module for FM driver users. This module must be initialized 53 * first prior to any other drivers modules. 54 * The FM is a "singleton" module. It is responsible of the 55 * common HW modules: FPM, DMA, common QMI and common BMI 56 * initializations and run-time control routines. This module 57 * must be initialized always when working with any of the FM modules. 58 * NOTE - We assume that the FM library will be initialized only 59 * by core No. 0! 60 * 61 * @{ 62 */ 63 64 /* 65 * @Description Enum for defining port types 66 */ 67 typedef enum e_fm_port_type { 68 e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ 69 e_FM_PORT_TYPE_RX, /**< 1G Rx port */ 70 e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ 71 e_FM_PORT_TYPE_TX, /**< 1G Tx port */ 72 e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ 73 e_FM_PORT_TYPE_RX_2_5G, /**< 2.5G Rx port */ 74 e_FM_PORT_TYPE_TX_2_5G, /**< 2.5G Tx port */ 75 e_FM_PORT_TYPE_DUMMY 76 } e_fm_port_type; 77 78 /* 79 * @Description Parse results memory layout 80 */ 81 typedef struct t_fm_prs_result { 82 volatile uint8_t lpid; /**< Logical port id */ 83 volatile uint8_t shimr; /**< Shim header result */ 84 volatile uint16_t l2r; /**< Layer 2 result */ 85 volatile uint16_t l3r; /**< Layer 3 result */ 86 volatile uint8_t l4r; /**< Layer 4 result */ 87 volatile uint8_t cplan; /**< Classification plan id */ 88 volatile uint16_t nxthdr; /**< Next Header */ 89 volatile uint16_t cksum; /**< Running-sum */ 90 volatile uint16_t flags_frag_off; 91 /**<Flags & fragment-offset field of the last IP-header 92 */ 93 volatile uint8_t route_type; 94 /**< Routing type field of a IPv6 routing extension 95 * header 96 */ 97 volatile uint8_t rhp_ip_valid; 98 /**< Routing Extension Header Present; last bit is IP 99 * valid 100 */ 101 volatile uint8_t shim_off[2]; /**< Shim offset */ 102 volatile uint8_t ip_pid_off; 103 /**< IP PID (last IP-proto)offset */ 104 volatile uint8_t eth_off; /**< ETH offset */ 105 volatile uint8_t llc_snap_off; /**< LLC_SNAP offset */ 106 volatile uint8_t vlan_off[2]; /**< VLAN offset */ 107 volatile uint8_t etype_off; /**< ETYPE offset */ 108 volatile uint8_t pppoe_off; /**< PPP offset */ 109 volatile uint8_t mpls_off[2]; /**< MPLS offset */ 110 volatile uint8_t ip_off[2]; /**< IP offset */ 111 volatile uint8_t gre_off; /**< GRE offset */ 112 volatile uint8_t l4_off; /**< Layer 4 offset */ 113 volatile uint8_t nxthdr_off; /**< Parser end point */ 114 } __rte_packed t_fm_prs_result; 115 116 /* 117 * @Collection FM Parser results 118 */ 119 #define FM_PR_L2_VLAN_STACK 0x00000100 /**< Parse Result: VLAN stack */ 120 #define FM_PR_L2_ETHERNET 0x00008000 /**< Parse Result: Ethernet*/ 121 #define FM_PR_L2_VLAN 0x00004000 /**< Parse Result: VLAN */ 122 #define FM_PR_L2_LLC_SNAP 0x00002000 /**< Parse Result: LLC_SNAP */ 123 #define FM_PR_L2_MPLS 0x00001000 /**< Parse Result: MPLS */ 124 #define FM_PR_L2_PPPoE 0x00000800 /**< Parse Result: PPPoE */ 125 /* @} */ 126 127 /* 128 * @Collection FM Frame descriptor macros 129 */ 130 #define FM_FD_CMD_FCO 0x80000000 /**< Frame queue Context Override */ 131 #define FM_FD_CMD_RPD 0x40000000 /**< Read Prepended Data */ 132 #define FM_FD_CMD_UPD 0x20000000 /**< Update Prepended Data */ 133 #define FM_FD_CMD_DTC 0x10000000 /**< Do L4 Checksum */ 134 #define FM_FD_CMD_DCL4C 0x10000000 /**< Didn't calculate L4 Checksum */ 135 #define FM_FD_CMD_CFQ 0x00ffffff /**< Confirmation Frame Queue */ 136 137 #define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000 138 /**< Not for Rx-Port! Unsupported Format 139 */ 140 #define FM_FD_ERR_LENGTH 0x02000000 141 /**< Not for Rx-Port! Length Error */ 142 #define FM_FD_ERR_DMA 0x01000000 /**< DMA Data error */ 143 144 #define FM_FD_IPR 0x00000001 /**< IPR frame (not error) */ 145 146 #define FM_FD_ERR_IPR_NCSP (0x00100000 | FM_FD_IPR) 147 /**< IPR non-consistent-sp */ 148 #define FM_FD_ERR_IPR (0x00200000 | FM_FD_IPR) /**< IPR error */ 149 #define FM_FD_ERR_IPR_TO (0x00300000 | FM_FD_IPR) /**< IPR timeout */ 150 151 #ifdef FM_CAPWAP_SUPPORT 152 #define FM_FD_ERR_CRE 0x00200000 153 #define FM_FD_ERR_CHE 0x00100000 154 #endif /* FM_CAPWAP_SUPPORT */ 155 156 #define FM_FD_ERR_PHYSICAL 0x00080000 157 /**< Rx FIFO overflow, FCS error, code error, running 158 * disparity error (SGMII and TBI modes), FIFO parity 159 * error. PHY Sequence error, PHY error control 160 * character detected. 161 */ 162 #define FM_FD_ERR_SIZE 0x00040000 163 /**< Frame too long OR Frame size exceeds max_length_frame */ 164 #define FM_FD_ERR_CLS_DISCARD 0x00020000 /**< classification discard */ 165 #define FM_FD_ERR_EXTRACTION 0x00008000 /**< Extract Out of Frame */ 166 #define FM_FD_ERR_NO_SCHEME 0x00004000 /**< No Scheme Selected */ 167 #define FM_FD_ERR_KEYSIZE_OVERFLOW 0x00002000 /**< Keysize Overflow */ 168 #define FM_FD_ERR_COLOR_RED 0x00000800 /**< Frame color is red */ 169 #define FM_FD_ERR_COLOR_YELLOW 0x00000400 /**< Frame color is yellow */ 170 #define FM_FD_ERR_ILL_PLCR 0x00000200 171 /**< Illegal Policer Profile selected */ 172 #define FM_FD_ERR_PLCR_FRAME_LEN 0x00000100 /**< Policer frame length error */ 173 #define FM_FD_ERR_PRS_TIMEOUT 0x00000080 /**< Parser Time out Exceed */ 174 #define FM_FD_ERR_PRS_ILL_INSTRUCT 0x00000040 175 /**< Invalid Soft Parser instruction */ 176 #define FM_FD_ERR_PRS_HDR_ERR 0x00000020 177 /**< Header error was identified during parsing */ 178 #define FM_FD_ERR_BLOCK_LIMIT_EXCEEDED 0x00000008 179 /**< Frame parsed beyind 256 first bytes */ 180 181 #define FM_FD_TX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \ 182 FM_FD_ERR_LENGTH | \ 183 FM_FD_ERR_DMA) /**< TX Error FD bits */ 184 185 #define FM_FD_RX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \ 186 FM_FD_ERR_LENGTH | \ 187 FM_FD_ERR_DMA | \ 188 FM_FD_ERR_IPR | \ 189 FM_FD_ERR_IPR_TO | \ 190 FM_FD_ERR_IPR_NCSP | \ 191 FM_FD_ERR_PHYSICAL | \ 192 FM_FD_ERR_SIZE | \ 193 FM_FD_ERR_CLS_DISCARD | \ 194 FM_FD_ERR_COLOR_RED | \ 195 FM_FD_ERR_COLOR_YELLOW | \ 196 FM_FD_ERR_ILL_PLCR | \ 197 FM_FD_ERR_PLCR_FRAME_LEN | \ 198 FM_FD_ERR_EXTRACTION | \ 199 FM_FD_ERR_NO_SCHEME | \ 200 FM_FD_ERR_KEYSIZE_OVERFLOW | \ 201 FM_FD_ERR_PRS_TIMEOUT | \ 202 FM_FD_ERR_PRS_ILL_INSTRUCT | \ 203 FM_FD_ERR_PRS_HDR_ERR | \ 204 FM_FD_ERR_BLOCK_LIMIT_EXCEEDED) 205 /**< RX Error FD bits */ 206 207 #define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000 208 /**< non Frame-Manager error */ 209 /* @} */ 210 211 /* 212 * @Description FM Exceptions 213 */ 214 typedef enum e_fm_exceptions { 215 e_FM_EX_DMA_BUS_ERROR = 0, /**< DMA bus error. */ 216 e_FM_EX_DMA_READ_ECC, 217 /**< Read Buffer ECC error (Valid for FM rev < 6)*/ 218 e_FM_EX_DMA_SYSTEM_WRITE_ECC, 219 /**< Write Buffer ECC error on system side 220 * (Valid for FM rev < 6) 221 */ 222 e_FM_EX_DMA_FM_WRITE_ECC, 223 /**< Write Buffer ECC error on FM side (Valid for FM rev < 6)*/ 224 e_FM_EX_DMA_SINGLE_PORT_ECC, 225 /**< Single Port ECC error on FM side (Valid for FM rev > 6)*/ 226 e_FM_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */ 227 e_FM_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */ 228 e_FM_EX_FPM_DOUBLE_ECC, 229 /**< Double ECC error on FPM ram access */ 230 e_FM_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */ 231 e_FM_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */ 232 e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */ 233 e_FM_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */ 234 e_FM_EX_BMI_STORAGE_PROFILE_ECC,/**< Storage Profile ECC Error */ 235 e_FM_EX_BMI_STATISTICS_RAM_ECC, 236 /**< Statistics Count RAM ECC Error Enable */ 237 e_FM_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */ 238 e_FM_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/ 239 e_FM_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/ 240 } e_fm_exceptions; 241 242 /* 243 * @Description Enum for defining port DMA cache attributes 244 */ 245 typedef enum e_fm_dma_cache_option { 246 e_FM_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */ 247 e_FM_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */ 248 } e_fm_dma_cache_option; 249 /* 250 * @Group lnx_usr_FM_init_grp FM Initialization Unit 251 * 252 * @Description FM Initialization Unit 253 * 254 * Initialization Flow 255 * Initialization of the FM Module will be carried out by the 256 * application according to the following sequence: 257 * - Calling the configuration routine with basic parameters. 258 * - Calling the advance initialization routines to change 259 * driver's defaults. 260 * - Calling the initialization routine. 261 * 262 * @{ 263 */ 264 265 t_handle fm_open(uint8_t id); 266 void fm_close(t_handle h_fm); 267 268 /* 269 * @Description A structure for defining buffer prefix area content. 270 */ 271 typedef struct t_fm_buffer_prefix_content { 272 uint16_t priv_data_size; 273 /**< Number of bytes to be left at the beginning of the external 274 * buffer Note that the private-area will start from the base of 275 * the buffer address. 276 */ 277 bool pass_prs_result; 278 /**< TRUE to pass the parse result to/from the FM; User may use 279 * fm_port_get_buffer_prs_result() in order to get the 280 * parser-result from a buffer. 281 */ 282 bool pass_time_stamp; 283 /**< TRUE to pass the timeStamp to/from the FM User may use 284 * fm_port_get_buffer_time_stamp() in order to get the 285 * parser-result from a buffer. 286 */ 287 bool pass_hash_result; 288 /**< TRUE to pass the KG hash result to/from the FM User may use 289 * fm_port_get_buffer_hash_result() in order to get the 290 * parser-result from a buffer. 291 */ 292 bool pass_all_other_pcdinfo; 293 /**< Add all other Internal-Context information: AD, 294 * hash-result, key, etc. 295 */ 296 uint16_t data_align; 297 /**< 0 to use driver's default alignment [64], other value for 298 * selecting a data alignment (must be a power of 2); if write 299 * optimization is used, must be >= 16. 300 */ 301 uint8_t manip_ext_space; 302 /**< Maximum extra size needed (insertion-size minus 303 * removal-size); 304 * Note that this field impacts the size of the buffer-prefix 305 * (i.e. it pushes the data offset); 306 */ 307 } t_fm_buffer_prefix_content; 308 309 /* 310 * @Description A structure of information about each of the external 311 * buffer pools used by a port or storage-profile. 312 */ 313 typedef struct t_fm_ext_pool_params { 314 uint8_t id; /**< External buffer pool id */ 315 uint16_t size; /**< External buffer pool buffer size */ 316 } t_fm_ext_pool_params; 317 318 /* 319 * @Description A structure for informing the driver about the external 320 * buffer pools allocated in the BM and used by a port or a 321 * storage-profile. 322 */ 323 typedef struct t_fm_ext_pools { 324 uint8_t num_of_pools_used; 325 /**< Number of pools use by this port*/ 326 t_fm_ext_pool_params ext_buf_pool[FM_PORT_MAX_NUM_OF_EXT_POOLS]; 327 /**< Parameters for each port */ 328 } t_fm_ext_pools; 329 330 /* 331 * @Description A structure for defining backup BM Pools. 332 */ 333 typedef struct t_fm_backup_bm_pools { 334 uint8_t num_bkup_pools; 335 /**< Number of BM backup pools - must be smaller than 336 * the total number of pools defined for the specified 337 * port. 338 */ 339 uint8_t pool_ids[FM_PORT_MAX_NUM_OF_EXT_POOLS]; 340 /**< num_bkup_pools pool id's, specifying which pools 341 * should be used only as backup. Pool id's specified 342 * here must be a subset of the pools used by the 343 * specified port. 344 */ 345 } t_fm_backup_bm_pools; 346 347 /** @} */ /* end of lnx_usr_FM_init_grp group */ 348 349 /* 350 * @Group lnx_usr_FM_runtime_control_grp FM Runtime Control Unit 351 * 352 * @Description FM Runtime control unit API functions, definitions and enums. 353 * 354 * The FM driver provides a set of control routines. 355 * These routines may only be called after the module was fully 356 * initialized (both configuration and initialization routines 357 * were called). They are typically used to get information from 358 * hardware (status, counters/statistics, revision etc.), to 359 * modify a current state or to force/enable a required action. 360 * Run-time control may be called whenever necessary and as many 361 * times as needed. 362 * @{ 363 */ 364 365 /* 366 * @Collection General FM defines. 367 */ 368 #define FM_MAX_NUM_OF_VALID_PORTS (FM_MAX_NUM_OF_OH_PORTS + \ 369 FM_MAX_NUM_OF_1G_RX_PORTS + \ 370 FM_MAX_NUM_OF_10G_RX_PORTS + \ 371 FM_MAX_NUM_OF_1G_TX_PORTS + \ 372 FM_MAX_NUM_OF_10G_TX_PORTS) 373 /**< Number of available FM ports */ 374 /* @} */ 375 376 /** @} */ /* end of lnx_usr_FM_runtime_control_grp group */ 377 /** @} */ /* end of lnx_usr_FM_lib_grp group */ 378 /** @} */ /* end of lnx_usr_FM_grp group */ 379 380 /* 381 * @Description FM Char device ioctls 382 */ 383 384 /* 385 * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API 386 * 387 * @Description FM Linux ioctls definitions and enums 388 * 389 * @{ 390 */ 391 392 /* 393 * @Collection FM IOCTL device ('/dev') definitions 394 */ 395 #define DEV_FM_NAME "fm" /**< Name of the FM chardev */ 396 397 #define DEV_FM_MINOR_BASE 0 398 #define DEV_FM_PCD_MINOR_BASE (DEV_FM_MINOR_BASE + 1) 399 /*/dev/fmx-pcd */ 400 #define DEV_FM_OH_PORTS_MINOR_BASE (DEV_FM_PCD_MINOR_BASE + 1) 401 /*/dev/fmx-port-ohy */ 402 #define DEV_FM_RX_PORTS_MINOR_BASE \ 403 (DEV_FM_OH_PORTS_MINOR_BASE + FM_MAX_NUM_OF_OH_PORTS) 404 /*/dev/fmx-port-rxy */ 405 #define DEV_FM_TX_PORTS_MINOR_BASE \ 406 (DEV_FM_RX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_RX_PORTS) 407 /*/dev/fmx-port-txy */ 408 #define DEV_FM_MAX_MINORS \ 409 (DEV_FM_TX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_TX_PORTS) 410 411 #define FM_IOC_NUM(n) (n) 412 #define FM_PCD_IOC_NUM(n) ((n) + 20) 413 #define FM_PORT_IOC_NUM(n) ((n) + 70) 414 /* @} */ 415 416 #define IOC_FM_MAX_NUM_OF_PORTS 64 417 418 /* 419 * @Description Enum for defining port types 420 * (must match enum e_fm_port_type defined in fm_ext.h) 421 */ 422 typedef enum ioc_fm_port_type { 423 e_IOC_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ 424 e_IOC_FM_PORT_TYPE_RX, /**< 1G Rx port */ 425 e_IOC_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ 426 e_IOC_FM_PORT_TYPE_TX, /**< 1G Tx port */ 427 e_IOC_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ 428 e_IOC_FM_PORT_TYPE_DUMMY 429 } ioc_fm_port_type; 430 431 typedef struct ioc_fm_obj_t { 432 void *obj; 433 } ioc_fm_obj_t; 434 435 typedef union ioc_fm_api_version_t { 436 struct { 437 uint8_t major; 438 uint8_t minor; 439 uint8_t respin; 440 uint8_t reserved; 441 } version; 442 uint32_t ver; 443 } ioc_fm_api_version_t; 444 445 /* 446 * @Function FM_IOC_GET_API_VERSION 447 * 448 * @Description Reads the FMD IOCTL API version. 449 * 450 * @Param[in,out] ioc_fm_api_version_t The requested counter parameters 451 * 452 * @Return Version's value. 453 */ 454 #define FM_IOC_GET_API_VERSION \ 455 _IOR(FM_IOC_TYPE_BASE, FM_IOC_NUM(7), ioc_fm_api_version_t) 456 #define FMD_API_VERSION_MAJOR 21 457 #define FMD_API_VERSION_MINOR 1 458 #define FMD_API_VERSION_RESPIN 0 459 460 uint32_t fm_get_api_version(t_handle h_fm, ioc_fm_api_version_t *p_version); 461 462 463 #endif /* __FM_EXT_H */ 464