#ifndef __CBM_API_H /* [ */ #define __CBM_API_H #include /*! \file cbm_api.h \brief This file contains all the Central Buffer Manager (CBM) API */ /** \defgroup CBM_Driver CBM Driver \brief All API and defines exported by CBM Driver. Look at the constants chapter below. */ /* @{ */ /** \defgroup CBM_Driver_Defines CBM Driver Defines \brief Defines used in the CBM Driver. Look at the constants chapter below. */ /** \defgroup CBM_Driver_Global_Defines CBM Driver Global Defines \brief Global Defines used in the CBM Driver. Look at the constants chapter below. */ /** \defgroup CBM_Driver_Port_Allocation_Defines CBM Driver Port Allocation Defines \brief CBM Port Allocate Defines. Look at the constants chapter below. */ /** \defgroup CBM_Driver_Port_Defines CBM Driver Port Defines \brief CBM Port Initialization Defines. Look at the constants chapter below. */ /** \defgroup CBM_Driver_CPU_Defines CBM Driver CPU Defines \brief CBM Driver CPU Related Defines. Look at the constants chapter below. */ /** \defgroup CBM_Driver_QMAP_Defines CBM Driver QMAP Defines \brief CBM Queue Map Table Field defines. Look at the constants chapter below. */ /** \defgroup CBM_Driver_Port_Structures CBM Driver Port Structures \brief CBM Port Configuration Structures */ /** \defgroup CBM_Control_API CBM Control API \brief CBM Control API allows to configure Interrupt, Enqueue and Dequeue manager - CBM Enqueue Manager - CBM Dequeue Manager */ /** \defgroup CBM_Port_Allocation_API CBM Port Allocation API \brief CBM Port Allocation API allows to allocate and de-allocate - CBM Enqeuue and Dequeue Ports - Datapath (PMAC) Ports */ /** \defgroup CBM_Port_OPS_API CBM Port Operations API \brief CBM Port Operations API - Initialize/Uninitialize, Enable/Disable, Configure CBM port - CBM Enqeuue and Dequeue Ports */ /** \defgroup CBM_Stats_API CBM Statistics API \brief CBM Statistics API - CBM Enqeuue and Dequeue Ports */ /** \defgroup CBM_CPU_Port_API CBM CPU Port API \brief CBM CPU Port API - CBM Enqeuue and Dequeue Ports */ /** \defgroup CBM_CPU_IRQ_API CBM CPU IRQ API \brief CBM CPU IRQ Control and Enable API - CBM Enqeuue and Dequeue Ports */ /** \defgroup CBM_CPU_API CBM CPU API \brief CBM CPU API */ /** \defgroup CBM_CPU_LOAD_SPREADER_API CBM CPU LOAD SPREADER API \brief CBM CPU Rx side Load Spreader API. - Load Spreader module distributes incoming packet load to multiple Cores/VPEs in GRX500 for maximising SMP Rx Packet performance */ /* @} */ #include "datapath_api.h" #define SINGLE_RX_CH0_ONLY 1 /** \addtogroup CBM_Driver_Global_Defines */ /* @{ */ /*! \brief OK return value */ #define CBM_OK 0 /*! \brief Error return value */ #define CBM_ERROR -1 /* @} */ /** \addtogroup CBM_Driver_Port_Allocation_Defines */ /* @{ */ /*! \brief Module Flag VRX318 SmartPHY */ #define CBM_MOD_F_VRX318 0x1 /*! \brief Module Flag TSO Engine */ #define CBM_MOD_F_TSO 0x2 /*! \brief Module Flag LRO Engine */ #define CBM_MOD_F_LRO 0x4 /*! \brief Module Flag WAVE500 WLAN */ #define CBM_MOD_F_WAVE500 0x8 /*! \brief Flag Legacy 2-DWORD DMA descriptor */ #define CBM_MOD_F_LEGACY 0x10 /*! \brief Flag Legacy Desc to 4 DW Invert */ #define CBM_MOD_F_DESC_ORDER_INVERT 0x20 /*! \brief Flag CBM Port Type is CPU port */ #define CBM_MOD_F_PORT_TYPE_CPU 0x40 /* @} */ /** \addtogroup CBM_Driver_Port_Defines */ /* @{ */ /*! \brief Use Standard Size buffer pool */ #define CBM_PORT_F_STANDARD_BUF 0x1 /*! \brief Use Jumbo size Buffer pool */ #define CBM_PORT_F_JUMBO_BUF 0x2 /*! \brief CBM Dequeue port */ #define CBM_PORT_F_DEQUEUE_PORT 0x4 /*! \brief Disable the CBM port */ #define CBM_PORT_F_DISABLE 0x8 /*! \brief CPU CBM port */ #define CBM_PORT_F_CPU_PORT 0x10 /*! \brief WAVE500 WLAN special CPU port */ #define CBM_PORT_F_WAVE500_PORT 0x20 /* @} */ /** \addtogroup CBM_Driver_CPU_Defines */ /* @{ */ /*! \brief Stop Rx i.e. assert backpressure */ #define CBM_CPU_F_RX_STOP 0x1 /*! \brief Start Rx i.e. remove backpressure */ #define CBM_CPU_F_RX_START 0x2 /*! \brief RCNT Decrement flag */ #define CBM_CPU_BUF_DEC_RCNT 0x4 /*! \brief RCNT Increment flag */ #define CBM_CPU_BUF_INC_RCNT 0x8 /* @} */ /** \addtogroup CBM_Driver_QMAP_Defines */ /* @{ */ /*! \brief FlowId bits are don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_FLOWID_L_DONTCARE 0x1 #define CBM_QUEUE_MAP_F_FLOWID_H_DONTCARE 0x80 #define CBM_QUEUE_MAP_F_SUBIF_DONTCARE 0x100 #define CBM_QUEUE_MAP_F_SUBIF_LSB_DONTCARE 0x200 /*! \brief VPN Encrypt bit is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_EN_DONTCARE 0x2 /*! \brief VPN Decrypt bit is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_DE_DONTCARE 0x4 /*! \brief MPE1 bit is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_MPE1_DONTCARE 0x8 /*! \brief MPE2 bit is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_MPE2_DONTCARE 0x10 /*! \brief EP/Egress Port field is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_EP_DONTCARE 0x20 /*! \brief TC/Class field is don't care for map to QueueId */ #define CBM_QUEUE_MAP_F_TC_DONTCARE 0x40 /* @} */ /*Special input flag to get the Enqueue port resources*/ #define DP_F_ENQ_CPU_0 0x2 #define DP_F_ENQ_CPU_1 0x3 #define DP_F_ENQ_CPU_2 0x4 #define DP_F_ENQ_CPU_3 0x5 #define DP_F_ENQ_WAVE 0x6 #define DP_F_ENQ_GSWIPL 0x7 #define DP_F_ENQ_PAE 0x8 #define DP_F_ENQ_TSO 0x9 #define DP_F_ENQ_VRX318 0xa #define DP_F_ENQ_DL 0xb #define DP_F_DEQ_CPU 0x2 #define DP_F_DEQ_CPU1 0x3 #define DP_F_DEQ_MPE 0x4 #define DP_F_DEQ_DL 0x5 /*Special input flag to enable/disable datapath queues*/ #define CBM_Q_F_DISABLE 0x10000000 #define CBM_Q_F_NODEQUEUE 0x20000000 #define CBM_Q_F_CKSUM 0x40000000 #define CBM_Q_F_FLUSH 0x80000000 #define CBM_Q_F_FORCE_FLUSH 0x00000001 #define CBM_Q_F_RESTORE_ONLY 0x00000002 #define CQM_MAX_CPU 4 #define CBM_PORT_DP_SET BIT(0) #define CBM_PORT_DQ_SET BIT(1) #define CBM_PORT_DMA_CHAN_SET BIT(2) #define CBM_PORT_PKT_CRDT_SET BIT(3) #define CBM_PORT_BYTE_CRDT_SET BIT(4) #define CBM_PORT_RING_ADDR_SET BIT(5) #define CBM_PORT_RING_SIZE_SET BIT(6) #define CBM_PORT_RING_OFFSET_SET BIT(7) #define CBM_STD_BUF_SIZE 2048 /** \addtogroup CBM_Driver_Port_Structures */ /* @{ */ /*! \brief Datapath Driver Rx callback fn \param[in] skb Packet Buffer, skb \param[in] flags : Reserved \return CBM_OK / CBM_ERROR \note */ typedef int32_t (*rx_fn)(struct sk_buff *skb, uint32_t flags); /*! \brief Stop Tx flow control callback fn \param[in] pmac_port_id Datapath/PMAC Port Id to apply backpressure on \param[in] subif : Sub-interface Id, not used currently \param[in] flags : Reserved \return CBM_OK / CBM_ERROR \note */ typedef int32_t (*stop_tx_fn)( int32_t pmac_port_id, uint32_t subif, uint32_t flags); /*! \brief Start Tx flow control callback fn \param[in] pmac_port_id Datapath/PMAC Port Id to apply backpressure on \param[in] subif : Sub-interface Id, not used currently \param[in] flags : Reserved \return CBM_OK / CBM_ERROR \note */ typedef int32_t (*start_tx_fn)(int32_t pmac_port_id, uint32_t subif, uint32_t flags); /*! \brief CBM Datapath Registration Callback */ typedef struct { rx_fn rxfn; /*!< Rx function callback */ stop_tx_fn stoptxfn; /*!< Stop Tx function callback */ start_tx_fn starttxfn; /*!< Start Tx function callback */ } cbm_dp_callback_t; /*! \brief CBM Enqueue Manager Control data structure */ typedef union cbm_eqm_ctrl { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_eqm_ctrl_t; /*! \brief CBM Dequeue Manager Control data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dqm_ctrl_t; /*! \brief CBM DMA Dequeue Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_dma_port_config_t; /*! \brief CBM DMA Enqueue Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_dma_port_config_t; /*! \brief CBM DMA Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_dma_port_config_t enq_cfg; /*!< CBM Enqueue DMA port config */ cbm_dequeue_dma_port_config_t deq_cfg; /*!< CBM Dequeue DMA port config */ } cbm_dma_port_config_t; /*! \brief CBM Enqueue Port Watermark/Threshold Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ /* Low Watermark & High Watermark */ uint32_t regval; /*!< 32-bit register value */ } cbm_port_thresh_t; /*! \brief CBM CPU Dequeue Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_cpu_port_config_t; /*! \brief CBM CPU Enqueue Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_cpu_port_config_t; /*! \brief CBM CPU Port Configuration data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_cpu_port_config_t enq_cfg; /*!< CBM Enqueue CPU port config */ cbm_dequeue_cpu_port_config_t deq_cfg; /*!< CBM Dequeue CPU port config */ } cbm_cpu_port_config_t; /*! \brief CBM Dequeue CPU Port Interrupt Control data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_cpu_port_irq_ctrl_t; /*! \brief CBM Enqueue CPU Port Interrupt Control data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_cpu_port_irq_ctrl_t; /*! \brief CBM CPU Port Interrupt Control */ typedef union cbm_enqueue_cpu_port_irq_ctrl { uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_cpu_port_irq_ctrl_t enq_irq_ctrl; /*!< CBM Enqueue CPU port IRQ Ctrl */ cbm_dequeue_cpu_port_irq_ctrl_t deq_irq_ctrl; /*!< CBM Dequeue CPU port IRQ Ctrl */ } cbm_cpu_port_irq_ctrl_t; /*! \brief CBM Dequeue DMA Port Interrupt Control data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_dma_port_irq_ctrl_t; /*! \brief CBM Enqueue DMA Port Interrupt Control data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_dma_port_irq_ctrl_t; /*! \brief CBM DMA Port Interrupt Control */ typedef union { uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_dma_port_irq_ctrl_t enq_irq_ctrl; /*!< CBM Enqueue DMA port IRQ Ctrl */ cbm_dequeue_dma_port_irq_ctrl_t deq_irq_ctrl; /*!< CBM Dequeue DMA port IRQ Ctrl */ } cbm_dma_port_irq_ctrl_t; /*! \brief CBM Dequeue CPU Port Interrupt Enable data structure */ typedef union cbm_dequeue_cpu_port_irq_enable { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_cpu_port_irq_enable_t; /*! \brief CBM Enqueue CPU Port Interrupt Enable data structure */ typedef union cbm_enqueue_cpu_port_irq_enable { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_cpu_port_irq_enable_t; /*! \brief CBM CPU Port Interrupt Enable */ typedef union { uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_cpu_port_irq_enable_t enq_irq_enable; /*!< CBM Enqueue CPU port IRQ Enable */ cbm_dequeue_cpu_port_irq_enable_t deq_irq_enable; /*!< CBM Dequeue CPU port IRQ Enable */ } cbm_cpu_port_irq_enable_t; /*! \brief CBM Dequeue DMA Port Interrupt Enable data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_dequeue_dma_port_irq_enable_t; /*! \brief CBM Enqueue DMA Port Interrupt Enable data structure */ typedef union { /* Should be auto-generated by LSD tool */ uint32_t regval; /*!< 32-bit register value */ } cbm_enqueue_dma_port_irq_enable_t; /*! \brief CBM DMA Port Interrupt Enable */ typedef union { uint32_t regval; /*!< 32-bit register value */ cbm_enqueue_dma_port_irq_enable_t enq_irq_enable; /*!< CBM Enqueue DMA port IRQ Enable */ cbm_dequeue_dma_port_irq_enable_t deq_irq_enable; /*!< CBM Dequeue DMA port IRQ Enable */ } cbm_dma_port_irq_enable_t; /*! \brief CBM Queue Map table Entry */ typedef union { uint32_t regval; /*!< 32-bit register value */ struct { uint32_t flowid : 2; /*!< FlowId (Bits 7:6) */ uint32_t dec : 1; /*!< VPN Decrypt flag */ uint32_t enc : 1; /*!< VPN Encrypt flag */ uint32_t mpe1 : 1; /*!< MPE1 Flag */ uint32_t mpe2 : 1; /*!< MPE2 Flag */ uint32_t ep : 4; /*!< PMAC Egress Port number */ uint32_t tc : 4; /*!< Traffic Class */ uint32_t sub_if_id : 12; /*sub if id*/ uint32_t resv : 6; /*resv*/ }; uint32_t flags; /*!< Flags stored in DDR CBM Queue map table. Currently, only flag defined is CBM_F_QUEUE_DROP */ } cbm_queue_map_entry_t; /*! \brief CBM Load Spreader Config */ typedef struct { uint32_t enable : 1; /*!< Whether Load Spreader is enabled */ uint32_t clk_div : 2; /*!< Divide CBM clock by 2^clk_div for Overflow counter */ uint32_t flowid_mode : 1; /*!< 1-FlowId mode; 0-WRR mode */ uint32_t wp0 : 2; /*!< Weight of Port 0*/ uint32_t wp1 : 2; /*!< Weight of Port 1*/ uint32_t wp2 : 2; /*!< Weight of Port 2*/ uint32_t wp3 : 2; /*!< Weight of Port 3*/ uint32_t wp4 : 2; /*!< Weight of Port 4*/ uint32_t wp5 : 2; /*!< Weight of Port 5*/ uint32_t wp6 : 2; /*!< Weight of Port 6*/ uint32_t wp7 : 2; /*!< Weight of Port 7*/ uint32_t res1 : 20; /*!< Reserved*/ } cbm_load_spreader_cfg_t; /*! \brief CBM Port Load Spreader Config */ typedef struct { uint32_t enable : 1; /*!< Whether port is enabled on Load Spreader */ uint32_t spreading_enable : 1; /*!< 1-Port will participate in load spreading; 0-direct connect to corresponding VPE number */ uint32_t irq_en : 1; /*!< Rx Interrupt enabled for Port */ uint32_t counter_en : 1; /*!< Counter enabled for Port */ uint32_t queue_thresh : 3; /*!< Queue threshold to raise an interrupt */ uint32_t counter_thresh : 16; /*!< FIXME: Queue threshold to raise an interrupt */ uint32_t res1 : 9; /*!< REserved */ } cbm_port_load_spreader_cfg_t; /*! \brief TMU resource structure for a TMU port */ typedef struct cbm_tmu_res { uint32_t tmu_port; /*!< TMU port number, -1 if no TMU port allocated */ uint32_t cbm_deq_port; /*!< CBM Dequeue port number, -1 if no CBM port allocated */ int32_t tmu_sched; /*!< TMU scheduler Id attached to TMU port, -1 if unassigned */ int32_t tmu_q; /*!< TMU Queue Id attached to TMU scheduler on this TMU port, -1 if unassigned */ } cbm_tmu_res_t; /*! \brief CBM Dequeue Resource Info for configuring other HW peripherals to access the CBM */ typedef struct cbm_dq_info { uint32_t port_no; /*! < CBM Dequeue Port No */ void *cbm_dq_port_base; /*!< CBM Dequeue Port Base Address */ int32_t dma_tx_chan; /*! PMAC DMA Tx Channel */ uint32_t num_desc; /*!< Number of Descriptors at port base */ u32 num_free_burst; /*!< Number of free burst size */ u32 *pkt_base; /*!