/* lpal_api.c * Description: LitePath Callback Wrapper implementation * * * GPL LICENSE SUMMARY * * Copyright(c) 2016 Intel Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. * The full GNU General Public License is included in this distribution * in the file called LICENSE.GPL. * * Contact Information: * Intel Corporation * 2200 Mission College Blvd. * Santa Clara, CA 97052 */ #include static struct ppa_lpal_cb g_lpal_cb; int32_t ppa_litepath_ll_register(struct ppa_lpal_cb *lpcb, int flags) { if (!lpcb) { /* LOG_ERROR("lpcb NULL !!\n"); */ return PPA_FAILURE; } else if (flags == PPA_LPAL_F_REGISTER) { memcpy(&g_lpal_cb, lpcb, sizeof(g_lpal_cb)); } else if (flags == PPA_LPAL_F_DEREGISTER) { memset(&g_lpal_cb, 0, sizeof(g_lpal_cb)); } else { /*( LOG_ERROR("Invalid flags: 0x%X\n", flags); */ return PPA_FAILURE; } return PPA_SUCCESS; } EXPORT_SYMBOL_GPL(ppa_litepath_ll_register); /** * API for WiFi Driver to register/deregister with Puma Litepath * * @param Network Device sub-interface * * @param Network Device * * @param Pointer to Callback functions of the Network interface registered * * @param Flags associated with the network interface * * @return zero for success, non-zero for failure */ int32_t ppa_drv_lpal_directpath_register(PPA_SUBIF *subif, PPA_NETIF *netif, PPA_DIRECTPATH_CB *pDirectpathCb, int32_t *index, uint32_t flags) { if (!subif || !netif) return PPA_INVALID; if (g_lpal_cb.cb_register == NULL) return PPA_INVALID; return g_lpal_cb.cb_register(subif, netif, pDirectpathCb, index, flags); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_register); /** * API for WiFI Driver to send skb * * @param Network Device sub-interface * * @param Pointer to skb * * @param Length of skb * * @param Flags associated with the interface * * @return zero for success, non-zero for failure */ int32_t ppa_drv_lpal_directpath_send(PPA_SUBIF *subif, struct sk_buff *skb, int32_t len, uint32_t flags) { if (!subif || !skb) return PPA_INVALID; if (g_lpal_cb.cb_send == NULL) return PPA_INVALID; return g_lpal_cb.cb_send(subif, skb, len, flags); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_send); /** * API for network interface flow control * * @param Network Device sub-interface * * @param Flags associated with the interface * * @return zero for success, non-zero for failure */ int32_t ppa_drv_lpal_directpath_flowctrl(PPA_SUBIF *subif, uint32_t flags) { if (g_lpal_cb.cb_flowctrl == NULL) return PPA_INVALID; return g_lpal_cb.cb_flowctrl(subif, flags); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_flowctrl); /** * API for WiFI Driver to send skb * * @param Network Device sub-interface * * @param Length of skb * * @param Flags associated with the interface * * @return zero for success, non-zero for failure */ PPA_BUF *ppa_drv_lpal_directpath_alloc_skb(PPA_SUBIF *subif, int32_t len, uint32_t flags) { if (!subif) return (PPA_BUF *) PPA_INVALID; if (g_lpal_cb.cb_alloc_skb == NULL) return (PPA_BUF *) PPA_INVALID; return g_lpal_cb.cb_alloc_skb(subif, len, flags); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_alloc_skb); /** * API to recycle skb * * @param Network Device sub-interface * * @param Pointer to skb * * @param Flags associated with the interface * * @return zero for success, non-zero for failure */ int32_t ppa_drv_lpal_directpath_recycle_skb(PPA_SUBIF *subif, PPA_BUF *skb, uint32_t flags) { if (g_lpal_cb.cb_recycle_skb == NULL) return PPA_INVALID; return g_lpal_cb.cb_recycle_skb(subif, skb, flags); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_recycle_skb); /** * API for WiFi Driver to enable/disable with Puma Litepath * * @param Network Device sub-interface * * @param enable_pdsp associated with the network interface * * @return zero for success, non-zero for failure */ int32_t ppa_drv_lpal_directpath_enable_wifi_pdsp(PPA_SUBIF *subif, uint32_t enable_pdsp) { if (!subif) return PPA_INVALID; if (g_lpal_cb.cb_wifi_pdsp == NULL){ return PPA_INVALID; } return g_lpal_cb.cb_wifi_pdsp(subif, enable_pdsp); } EXPORT_SYMBOL_GPL(ppa_drv_lpal_directpath_enable_wifi_pdsp);