#ifndef __PPA_LPAL_API_H__ #define __PPA_LPAL_API_H__ /** * @file lpal_api.h * @brief This file contains the Puma Litepath API's. */ #include #if defined(CONFIG_LTQ_DATAPATH) #include #endif #define LOG_PRINT(msg, arg...) \ pr_crit("[%s:%d] "msg, __func__, __LINE__, ##arg) #define LOG_ERROR err #define LOG_INFO(msg, arg...) \ ppa_debug(DBG_ENABLE_MASK_DEBUG_PRINT, msg, ##arg) #define LOG_DEBUG(msg, arg...) \ ppa_debug(DBG_ENABLE_MASK_DEBUG_PRINT, msg, ##arg) #define LOG_TRACE(msg, arg...) \ ppa_debug(DBG_ENABLE_MASK_DEBUG_PRINT, msg, ##arg) enum { PPA_LPAL_F_REGISTER = 0x1, PPA_LPAL_F_DEREGISTER = 0x2, /* = 0x4 */ }; #define MAX_PID (32) #define MAX_VPID (50) #define DP_DATA_INDEX(__p) \ ((__p)->port_id * (MAX_VPID+1) + ((__p)->subif > 0 ? (__p)->subif : 0)) #define DP_PORT_ID(_idx) ((_idx) ? ((_idx) / (MAX_VPID+1)) : 0) #define DP_SUBIF(_idx) ((_idx) ? ((_idx) % (MAX_VPID+1)) : 0) #define PPA_SUCCESS 0 #define PPA_FAILURE -1 #define PPA_EPERM -2 #define PPA_INVALID -3 #define PPA_F_DIRECTPATH_REGISTER 0x00100000 /*!< Directpath register flag */ #define PPE_DIRECTPATH_DATA_ENTRY_VALID (1 << 31) /*!< define flag */ #define PPE_DIRECTPATH_DATA_RX_ENABLE (1 << 0) /*!< define flag */ struct ppa_lpal_ifstats { uint64_t rx_pkts; uint64_t tx_pkts; uint64_t rx_bytes; uint64_t tx_bytes; uint64_t droped_pkts; /* ... */ }; #define PPA_NETIF struct net_device #define PPA_BUF struct sk_buff struct ppa_subif_t { int32_t port_id; /*!< Datapath Port Id corresponds to PMAC Port Id */ int32_t subif:15; /*!< Sub-interface Id info. In GRX500, this is 15 bits, only 13 bits in PAE are handled [14, 11:0].\n DMA subif format is mc_flag[14:14] Res[13:12] VAP[11:8] GRP[7:7] Index/StationID[6:0] \n */ }; #ifndef CONFIG_LTQ_DATAPATH #define PPA_SUBIF struct ppa_subif_t #endif typedef int32_t(*PPA_FP_RX_FN) (PPA_NETIF *rxif, PPA_NETIF *txif, PPA_BUF *skb, int32_t len); typedef int32_t(*PPA_FP_RESTART_TX_FN) (PPA_NETIF *dev); typedef int32_t(*PPA_FP_STOP_TX_FN) (PPA_NETIF *dev); struct ppa_directpath_cb_t { PPA_FP_STOP_TX_FN stop_tx_fn; /*!< Pointer to the Driver Stop Tx function callback. Providing a NULL pointer disables the callback functionality. */ PPA_FP_RESTART_TX_FN start_tx_fn; /*!< Pointer to the Driver Restart Tx function callback. Providing a NULL pointer disables the callback functionality. */ PPA_FP_RX_FN rx_fn; /*!< Device Receive Function callback for packets. Setting a value of NULL pointer disables Receive callback for the device */ }; #define PPA_DIRECTPATH_CB struct ppa_directpath_cb_t struct ppe_directpath_data { PPA_DIRECTPATH_CB callback; /*!< Callback Pointer to PPA_DIRECTPATH_CB */ PPA_NETIF *netif; /*!< pointer to PPA_NETIF */ uint32_t ifid; /*!< directpath interface id */ uint32_t rx_fn_rxif_pkt; /*!< received packet counter */ uint32_t rx_fn_txif_pkt; /*!< transmitted packet coutner */ uint32_t tx_pkt; /*!< transmitted packet counter */ uint32_t tx_pkt_dropped; /*!< dropped packet counter */ uint32_t tx_pkt_queued; /*!< queued packet counter */ uint32_t flags; /*!< bit 0 - directpath send valid, 31 - entry valid */ }; typedef int32_t(*ppa_lpal_regsiter_cb) (PPA_SUBIF *psubif, PPA_NETIF *netif, PPA_DIRECTPATH_CB *cb, uint32_t *index, uint32_t flags); typedef int32_t(*ppa_lpal_send_cb) (PPA_SUBIF *p_subif, struct sk_buff *skb, int32_t len, uint32_t flags); typedef struct sk_buff *(*ppa_lpal_allocskb_cb) (PPA_SUBIF *p_subif, int32_t len, uint32_t flags); typedef int32_t(*ppa_lpal_recycleskb_cb) (PPA_SUBIF *p_subif, struct sk_buff *skb, uint32_t flags); typedef int32_t(*ppa_lpal_flowctrl_cb) (PPA_SUBIF *p_subif, uint32_t flags); typedef int32_t(*ppa_lpal_stats_cb) (PPA_SUBIF *p_subif, struct ppa_lpal_ifstats *stats); typedef int32_t(*ppa_lpal_wifi_pdsp_cb) (PPA_SUBIF *p_subif, uint32_t enable_pdsp); struct ppa_lpal_cb { ppa_lpal_regsiter_cb cb_register; ppa_lpal_send_cb cb_send; ppa_lpal_allocskb_cb cb_alloc_skb; ppa_lpal_recycleskb_cb cb_recycle_skb; ppa_lpal_flowctrl_cb cb_flowctrl; ppa_lpal_stats_cb cb_stats; ppa_lpal_wifi_pdsp_cb cb_wifi_pdsp; }; /** @defgroup PUMA_LITEPATH Puma Litepath API's */ /** @{ */ /** * @brief API for puma litepath to register/deregister lpal callback functions * * @param *lpcb litepath callback structure * * @param flags Puma Litepath register/deregister flag * * @return zero for success, non-zero for failure */ extern int32_t ppa_litepath_ll_register(struct ppa_lpal_cb *lpcb, int flags); /** * @brief API for WiFi Driver to register/deregister with Puma Litepath * * @param *subif Pointer to Network Device sub-interface * * @param *netif Pointer to Network Device * * @param *pDirectpathCb Pointer to Callback functions of the Network interface registered * * @param *index Pointer to index * * @param Flags associated with the network interface * * @return zero for success, non-zero for failure */ extern int32_t ppa_drv_lpal_directpath_register(PPA_SUBIF *subif, PPA_NETIF *netif, PPA_DIRECTPATH_CB * pDirectpathCb, int32_t *index, uint32_t flags); /** * @brief API for WiFI Driver to send skb * * @param *p_subif Pointer to Network Device sub-interface * * @param *skb Pointer to skb * * @param len Length of skb * * @param flags Flags associated with the interface * * @return zero for success, non-zero for failure */ extern int32_t ppa_drv_lpal_directpath_send(PPA_SUBIF *p_subif, struct sk_buff *skb, int32_t len, uint32_t flags); /** * @brief API for network interface flow control * * @param *psubif Pointer to Network Device sub-interface * * @param flags Flags associated with the interface * * @return zero for success, non-zero for failure */ extern int32_t ppa_drv_lpal_directpath_flowctrl(PPA_SUBIF *psubif, uint32_t flags); /** * @brief API for WiFI Driver to allocate skb * * @param *subif Pointer to Network Device sub-interface * * @param len Length of skb * * @param flags Flags associated with the interface * * @return zero for success, non-zero for failure */ extern PPA_BUF *ppa_drv_lpal_directpath_alloc_skb(PPA_SUBIF *subif, int32_t len, uint32_t flags); /** * @brief API to recycle skb * * @param *subif Pointer to Network Device sub-interface * * @param skb Pointer to skb * * @param flags Flags associated with the interface * * @return zero for success, non-zero for failure */ extern int32_t ppa_drv_lpal_directpath_recycle_skb(PPA_SUBIF *subif, PPA_BUF *skb, uint32_t flags); /** * @brief API for WiFi Driver to enable/disable with Puma Litepath * * @param *subif Pointer to Network Device sub-interface * * @param enable_pdsp Enable/Disable PDSP associated with the network interface * * @return zero for success, non-zero for failure */ extern int32_t ppa_drv_lpal_directpath_enable_wifi_pdsp(PPA_SUBIF *subif, uint32_t enable_pdsp); /** @} */ #if 0 /* Exposed API to get lpal callback reference */ extern ppa_lpal_regsiter_cb LPAL_REGISTER_CB(void); extern ppa_lpal_send_cb LPAL_SEND_CB(void); extern ppa_lpal_allocskb_cb LPAL_ALLOC_SKB_CB(void); extern ppa_lpal_recycleskb_cb LPAL_RECYCLE_SKB_CB(void); extern ppa_lpal_flowctrl_cb LPAL_FLOWCTRL_CB(void); extern ppa_lpal_stats_cb LPAL_STATS_CB(void); #endif #endif