/* SPDX-License-Identifier: BSD-3-Clause * Copyright 2008-2012 Freescale Semiconductor Inc. * Copyright 2017-2020 NXP */ #ifndef __FM_EXT_H #define __FM_EXT_H #include "ncsw_ext.h" #include "dpaa_integration.h" #define FM_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 1) #define FMT_IOC_TYPE_BASE (NCSW_IOC_TYPE_BASE + 3) #define MODULE_FM 0x00010000 #define __ERR_MODULE__ MODULE_FM /* #define FM_LIB_DBG */ #if defined(FM_LIB_DBG) #define _fml_dbg(fmt, args...) \ rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmlib:%s(): " fmt "\n", \ __func__, ##args) #else #define _fml_dbg(arg...) #endif /*#define FM_IOCTL_DBG*/ #if defined(FM_IOCTL_DBG) #define _fm_ioctl_dbg(fmt, args...) \ rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "fmioc:%s(): " fmt "\n", \ __func__, ##args) #else #define _fm_ioctl_dbg(arg...) #endif /* * @Group lnx_ioctl_ncsw_grp NetCommSw Linux User-Space (IOCTL) API * @{ */ #define NCSW_IOC_TYPE_BASE 0xe0 /**< defines the IOCTL type for all the NCSW Linux module commands */ /* * @Group lnx_usr_FM_grp Frame Manager API * * @Description FM API functions, definitions and enums. * * The FM module is the main driver module and is a mandatory * module for FM driver users. This module must be initialized * first prior to any other drivers modules. * The FM is a "singleton" module. It is responsible of the * common HW modules: FPM, DMA, common QMI and common BMI * initializations and run-time control routines. This module * must be initialized always when working with any of the FM modules. * NOTE - We assume that the FM library will be initialized only * by core No. 0! * * @{ */ /* * @Description Enum for defining port types */ typedef enum e_fm_port_type { e_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ e_FM_PORT_TYPE_RX, /**< 1G Rx port */ e_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ e_FM_PORT_TYPE_TX, /**< 1G Tx port */ e_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ e_FM_PORT_TYPE_RX_2_5G, /**< 2.5G Rx port */ e_FM_PORT_TYPE_TX_2_5G, /**< 2.5G Tx port */ e_FM_PORT_TYPE_DUMMY } e_fm_port_type; /* * @Description Parse results memory layout */ typedef struct t_fm_prs_result { volatile uint8_t lpid; /**< Logical port id */ volatile uint8_t shimr; /**< Shim header result */ volatile uint16_t l2r; /**< Layer 2 result */ volatile uint16_t l3r; /**< Layer 3 result */ volatile uint8_t l4r; /**< Layer 4 result */ volatile uint8_t cplan; /**< Classification plan id */ volatile uint16_t nxthdr; /**< Next Header */ volatile uint16_t cksum; /**< Running-sum */ volatile uint16_t flags_frag_off; /** 6)*/ e_FM_EX_FPM_STALL_ON_TASKS, /**< Stall of tasks on FPM */ e_FM_EX_FPM_SINGLE_ECC, /**< Single ECC on FPM. */ e_FM_EX_FPM_DOUBLE_ECC, /**< Double ECC error on FPM ram access */ e_FM_EX_QMI_SINGLE_ECC, /**< Single ECC on QMI. */ e_FM_EX_QMI_DOUBLE_ECC, /**< Double bit ECC occurred on QMI */ e_FM_EX_QMI_DEQ_FROM_UNKNOWN_PORTID,/**< Dequeue from unknown port id */ e_FM_EX_BMI_LIST_RAM_ECC, /**< Linked List RAM ECC error */ e_FM_EX_BMI_STORAGE_PROFILE_ECC,/**< Storage Profile ECC Error */ e_FM_EX_BMI_STATISTICS_RAM_ECC, /**< Statistics Count RAM ECC Error Enable */ e_FM_EX_BMI_DISPATCH_RAM_ECC, /**< Dispatch RAM ECC Error Enable */ e_FM_EX_IRAM_ECC, /**< Double bit ECC occurred on IRAM*/ e_FM_EX_MURAM_ECC /**< Double bit ECC occurred on MURAM*/ } e_fm_exceptions; /* * @Description Enum for defining port DMA cache attributes */ typedef enum e_fm_dma_cache_option { e_FM_DMA_NO_STASH = 0, /**< Cacheable, no Allocate (No Stashing) */ e_FM_DMA_STASH = 1 /**< Cacheable and Allocate (Stashing on) */ } e_fm_dma_cache_option; /* * @Group lnx_usr_FM_init_grp FM Initialization Unit * * @Description FM Initialization Unit * * Initialization Flow * Initialization of the FM Module will be carried out by the * application according to the following sequence: * - Calling the configuration routine with basic parameters. * - Calling the advance initialization routines to change * driver's defaults. * - Calling the initialization routine. * * @{ */ t_handle fm_open(uint8_t id); void fm_close(t_handle h_fm); /* * @Description A structure for defining buffer prefix area content. */ typedef struct t_fm_buffer_prefix_content { uint16_t priv_data_size; /**< Number of bytes to be left at the beginning of the external * buffer Note that the private-area will start from the base of * the buffer address. */ bool pass_prs_result; /**< TRUE to pass the parse result to/from the FM; User may use * fm_port_get_buffer_prs_result() in order to get the * parser-result from a buffer. */ bool pass_time_stamp; /**< TRUE to pass the timeStamp to/from the FM User may use * fm_port_get_buffer_time_stamp() in order to get the * parser-result from a buffer. */ bool pass_hash_result; /**< TRUE to pass the KG hash result to/from the FM User may use * fm_port_get_buffer_hash_result() in order to get the * parser-result from a buffer. */ bool pass_all_other_pcdinfo; /**< Add all other Internal-Context information: AD, * hash-result, key, etc. */ uint16_t data_align; /**< 0 to use driver's default alignment [64], other value for * selecting a data alignment (must be a power of 2); if write * optimization is used, must be >= 16. */ uint8_t manip_ext_space; /**< Maximum extra size needed (insertion-size minus * removal-size); * Note that this field impacts the size of the buffer-prefix * (i.e. it pushes the data offset); */ } t_fm_buffer_prefix_content; /* * @Description A structure of information about each of the external * buffer pools used by a port or storage-profile. */ typedef struct t_fm_ext_pool_params { uint8_t id; /**< External buffer pool id */ uint16_t size; /**< External buffer pool buffer size */ } t_fm_ext_pool_params; /* * @Description A structure for informing the driver about the external * buffer pools allocated in the BM and used by a port or a * storage-profile. */ typedef struct t_fm_ext_pools { uint8_t num_of_pools_used; /**< Number of pools use by this port*/ t_fm_ext_pool_params ext_buf_pool[FM_PORT_MAX_NUM_OF_EXT_POOLS]; /**< Parameters for each port */ } t_fm_ext_pools; /* * @Description A structure for defining backup BM Pools. */ typedef struct t_fm_backup_bm_pools { uint8_t num_bkup_pools; /**< Number of BM backup pools - must be smaller than * the total number of pools defined for the specified * port. */ uint8_t pool_ids[FM_PORT_MAX_NUM_OF_EXT_POOLS]; /**< num_bkup_pools pool id's, specifying which pools * should be used only as backup. Pool id's specified * here must be a subset of the pools used by the * specified port. */ } t_fm_backup_bm_pools; /** @} */ /* end of lnx_usr_FM_init_grp group */ /* * @Group lnx_usr_FM_runtime_control_grp FM Runtime Control Unit * * @Description FM Runtime control unit API functions, definitions and enums. * * The FM driver provides a set of control routines. * These routines may only be called after the module was fully * initialized (both configuration and initialization routines * were called). They are typically used to get information from * hardware (status, counters/statistics, revision etc.), to * modify a current state or to force/enable a required action. * Run-time control may be called whenever necessary and as many * times as needed. * @{ */ /* * @Collection General FM defines. */ #define FM_MAX_NUM_OF_VALID_PORTS (FM_MAX_NUM_OF_OH_PORTS + \ FM_MAX_NUM_OF_1G_RX_PORTS + \ FM_MAX_NUM_OF_10G_RX_PORTS + \ FM_MAX_NUM_OF_1G_TX_PORTS + \ FM_MAX_NUM_OF_10G_TX_PORTS) /**< Number of available FM ports */ /* @} */ /** @} */ /* end of lnx_usr_FM_runtime_control_grp group */ /** @} */ /* end of lnx_usr_FM_lib_grp group */ /** @} */ /* end of lnx_usr_FM_grp group */ /* * @Description FM Char device ioctls */ /* * @Group lnx_ioctl_FM_grp Frame Manager Linux IOCTL API * * @Description FM Linux ioctls definitions and enums * * @{ */ /* * @Collection FM IOCTL device ('/dev') definitions */ #define DEV_FM_NAME "fm" /**< Name of the FM chardev */ #define DEV_FM_MINOR_BASE 0 #define DEV_FM_PCD_MINOR_BASE (DEV_FM_MINOR_BASE + 1) /*/dev/fmx-pcd */ #define DEV_FM_OH_PORTS_MINOR_BASE (DEV_FM_PCD_MINOR_BASE + 1) /*/dev/fmx-port-ohy */ #define DEV_FM_RX_PORTS_MINOR_BASE \ (DEV_FM_OH_PORTS_MINOR_BASE + FM_MAX_NUM_OF_OH_PORTS) /*/dev/fmx-port-rxy */ #define DEV_FM_TX_PORTS_MINOR_BASE \ (DEV_FM_RX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_RX_PORTS) /*/dev/fmx-port-txy */ #define DEV_FM_MAX_MINORS \ (DEV_FM_TX_PORTS_MINOR_BASE + FM_MAX_NUM_OF_TX_PORTS) #define FM_IOC_NUM(n) (n) #define FM_PCD_IOC_NUM(n) ((n) + 20) #define FM_PORT_IOC_NUM(n) ((n) + 70) /* @} */ #define IOC_FM_MAX_NUM_OF_PORTS 64 /* * @Description Enum for defining port types * (must match enum e_fm_port_type defined in fm_ext.h) */ typedef enum ioc_fm_port_type { e_IOC_FM_PORT_TYPE_OH_OFFLINE_PARSING = 0, /**< Offline parsing port */ e_IOC_FM_PORT_TYPE_RX, /**< 1G Rx port */ e_IOC_FM_PORT_TYPE_RX_10G, /**< 10G Rx port */ e_IOC_FM_PORT_TYPE_TX, /**< 1G Tx port */ e_IOC_FM_PORT_TYPE_TX_10G, /**< 10G Tx port */ e_IOC_FM_PORT_TYPE_DUMMY } ioc_fm_port_type; typedef struct ioc_fm_obj_t { void *obj; } ioc_fm_obj_t; typedef union ioc_fm_api_version_t { struct { uint8_t major; uint8_t minor; uint8_t respin; uint8_t reserved; } version; uint32_t ver; } ioc_fm_api_version_t; /* * @Function FM_IOC_GET_API_VERSION * * @Description Reads the FMD IOCTL API version. * * @Param[in,out] ioc_fm_api_version_t The requested counter parameters * * @Return Version's value. */ #define FM_IOC_GET_API_VERSION \ _IOR(FM_IOC_TYPE_BASE, FM_IOC_NUM(7), ioc_fm_api_version_t) #define FMD_API_VERSION_MAJOR 21 #define FMD_API_VERSION_MINOR 1 #define FMD_API_VERSION_RESPIN 0 uint32_t fm_get_api_version(t_handle h_fm, ioc_fm_api_version_t *p_version); #endif /* __FM_EXT_H */