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