1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2012 Freescale Semiconductor Inc.
3 * Copyright 2017-2020 NXP
10 #include "dpaa_integration.h"
12 #define FM_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 1)
13 #define FMT_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 3)
15 #define MODULE_FM 0x00010000
16 #define __ERR_MODULE__ MODULE_FM
18 /* #define FM_LIB_DBG */
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", \
25 #define _fml_dbg(arg...)
28 /*#define FM_IOCTL_DBG*/
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", \
35 #define _fm_ioctl_dbg(arg...)
39 * @Group lnx_ioctl_ncsw_grp NetCommSw Linux User-Space (IOCTL) API
43 #define NCSW_IOC_TYPE_BASE 0xe0
44 /**< defines the IOCTL type for all the NCSW Linux module commands */
47 * @Group lnx_usr_FM_grp Frame Manager API
49 * @Description FM API functions, definitions and enums.
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
65 * @Description Enum for defining port types
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 */
79 * @Description Parse results memory layout
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
93 volatile uint8_t route_type;
94 /**< Routing type field of a IPv6 routing extension
97 volatile uint8_t rhp_ip_valid;
98 /**< Routing Extension Header Present; last bit is IP
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;
117 * @Collection FM Parser results
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 */
128 * @Collection FM Frame descriptor macros
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 */
137 #define FM_FD_ERR_UNSUPPORTED_FORMAT 0x04000000
138 /**< Not for Rx-Port! Unsupported Format
140 #define FM_FD_ERR_LENGTH 0x02000000
141 /**< Not for Rx-Port! Length Error */
142 #define FM_FD_ERR_DMA 0x01000000 /**< DMA Data error */
144 #define FM_FD_IPR 0x00000001 /**< IPR frame (not error) */
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 */
151 #ifdef FM_CAPWAP_SUPPORT
152 #define FM_FD_ERR_CRE 0x00200000
153 #define FM_FD_ERR_CHE 0x00100000
154 #endif /* FM_CAPWAP_SUPPORT */
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.
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 */
181 #define FM_FD_TX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
183 FM_FD_ERR_DMA) /**< TX Error FD bits */
185 #define FM_FD_RX_STATUS_ERR_MASK (FM_FD_ERR_UNSUPPORTED_FORMAT | \
190 FM_FD_ERR_IPR_NCSP | \
191 FM_FD_ERR_PHYSICAL | \
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 */
207 #define FM_FD_RX_STATUS_ERR_NON_FM 0x00400000
208 /**< non Frame-Manager error */
212 * @Description FM Exceptions
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)
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*/
243 * @Description Enum for defining port DMA cache attributes
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;
250 * @Group lnx_usr_FM_init_grp FM Initialization Unit
252 * @Description FM Initialization Unit
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
260 * - Calling the initialization routine.
265 t_handle fm_open(uint8_t id);
266 void fm_close(t_handle h_fm);
269 * @Description A structure for defining buffer prefix area content.
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.
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.
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.
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.
292 bool pass_all_other_pcdinfo;
293 /**< Add all other Internal-Context information: AD,
294 * hash-result, key, etc.
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.
301 uint8_t manip_ext_space;
302 /**< Maximum extra size needed (insertion-size minus
304 * Note that this field impacts the size of the buffer-prefix
305 * (i.e. it pushes the data offset);
307 } t_fm_buffer_prefix_content;
310 * @Description A structure of information about each of the external
311 * buffer pools used by a port or storage-profile.
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;
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
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 */
331 * @Description A structure for defining backup BM Pools.
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
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
345 } t_fm_backup_bm_pools;
347 /** @} */ /* end of lnx_usr_FM_init_grp group */
350 * @Group lnx_usr_FM_runtime_control_grp FM Runtime Control Unit
352 * @Description FM Runtime control unit API functions, definitions and enums.
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
366 * @Collection General FM defines.
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 */
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 */
381 * @Description FM Char device ioctls
385 * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API
387 * @Description FM Linux ioctls definitions and enums
393 * @Collection FM IOCTL device ('/dev') definitions
395 #define DEV_FM_NAME "fm" /**< Name of the FM chardev */
397 #define DEV_FM_MINOR_BASE 0
398 #define DEV_FM_PCD_MINOR_BASE (DEV_FM_MINOR_BASE + 1)
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)
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)
416 #define IOC_FM_MAX_NUM_OF_PORTS 64
419 * @Description Enum for defining port types
420 * (must match enum e_fm_port_type defined in fm_ext.h)
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
431 typedef struct ioc_fm_obj_t {
435 typedef union ioc_fm_api_version_t {
443 } ioc_fm_api_version_t;
446 * @Function FM_IOC_GET_API_VERSION
448 * @Description Reads the FMD IOCTL API version.
450 * @Param[in,out] ioc_fm_api_version_t The requested counter parameters
452 * @Return Version's value.
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
460 uint32_t fm_get_api_version(t_handle h_fm, ioc_fm_api_version_t *p_version);
463 #endif /* __FM_EXT_H */