105491d2cSKalle Valo /* 205491d2cSKalle Valo * Copyright (c) 2013 Broadcom Corporation 305491d2cSKalle Valo * 405491d2cSKalle Valo * Permission to use, copy, modify, and/or distribute this software for any 505491d2cSKalle Valo * purpose with or without fee is hereby granted, provided that the above 605491d2cSKalle Valo * copyright notice and this permission notice appear in all copies. 705491d2cSKalle Valo * 805491d2cSKalle Valo * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 905491d2cSKalle Valo * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1005491d2cSKalle Valo * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 1105491d2cSKalle Valo * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1205491d2cSKalle Valo * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 1305491d2cSKalle Valo * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 1405491d2cSKalle Valo * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1505491d2cSKalle Valo */ 1605491d2cSKalle Valo #ifndef BRCMFMAC_PROTO_H 1705491d2cSKalle Valo #define BRCMFMAC_PROTO_H 1805491d2cSKalle Valo 1905491d2cSKalle Valo 2005491d2cSKalle Valo enum proto_addr_mode { 2105491d2cSKalle Valo ADDR_INDIRECT = 0, 2205491d2cSKalle Valo ADDR_DIRECT 2305491d2cSKalle Valo }; 2405491d2cSKalle Valo 25bbd1f932SArend van Spriel struct brcmf_skb_reorder_data { 26bbd1f932SArend van Spriel u8 *reorder; 27bbd1f932SArend van Spriel }; 2805491d2cSKalle Valo 2905491d2cSKalle Valo struct brcmf_proto { 3005491d2cSKalle Valo int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws, 3105491d2cSKalle Valo struct sk_buff *skb, struct brcmf_if **ifp); 3205491d2cSKalle Valo int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, 3305491d2cSKalle Valo void *buf, uint len); 3405491d2cSKalle Valo int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, 3505491d2cSKalle Valo uint len); 36b073ac1fSRafał Miłecki int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx, 37b073ac1fSRafał Miłecki struct sk_buff *skb); 3805491d2cSKalle Valo int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset, 3905491d2cSKalle Valo struct sk_buff *skb); 4005491d2cSKalle Valo void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx, 4105491d2cSKalle Valo enum proto_addr_mode addr_mode); 4205491d2cSKalle Valo void (*delete_peer)(struct brcmf_pub *drvr, int ifidx, 4305491d2cSKalle Valo u8 peer[ETH_ALEN]); 4405491d2cSKalle Valo void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx, 4505491d2cSKalle Valo u8 peer[ETH_ALEN]); 46bbd1f932SArend van Spriel void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb); 479fdc64bbSFranky Lin void (*add_if)(struct brcmf_if *ifp); 48*c02a5eb8SFranky Lin void (*del_if)(struct brcmf_if *ifp); 4905491d2cSKalle Valo void *pd; 5005491d2cSKalle Valo }; 5105491d2cSKalle Valo 5205491d2cSKalle Valo 5305491d2cSKalle Valo int brcmf_proto_attach(struct brcmf_pub *drvr); 5405491d2cSKalle Valo void brcmf_proto_detach(struct brcmf_pub *drvr); 5505491d2cSKalle Valo 5605491d2cSKalle Valo static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws, 5705491d2cSKalle Valo struct sk_buff *skb, 5805491d2cSKalle Valo struct brcmf_if **ifp) 5905491d2cSKalle Valo { 6005491d2cSKalle Valo struct brcmf_if *tmp = NULL; 6105491d2cSKalle Valo 6205491d2cSKalle Valo /* assure protocol is always called with 6305491d2cSKalle Valo * non-null initialized pointer. 6405491d2cSKalle Valo */ 6505491d2cSKalle Valo if (ifp) 6605491d2cSKalle Valo *ifp = NULL; 6705491d2cSKalle Valo else 6805491d2cSKalle Valo ifp = &tmp; 6905491d2cSKalle Valo return drvr->proto->hdrpull(drvr, do_fws, skb, ifp); 7005491d2cSKalle Valo } 7105491d2cSKalle Valo static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx, 7205491d2cSKalle Valo uint cmd, void *buf, uint len) 7305491d2cSKalle Valo { 7405491d2cSKalle Valo return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len); 7505491d2cSKalle Valo } 7605491d2cSKalle Valo static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx, 7705491d2cSKalle Valo uint cmd, void *buf, uint len) 7805491d2cSKalle Valo { 7905491d2cSKalle Valo return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len); 8005491d2cSKalle Valo } 81b073ac1fSRafał Miłecki 82b073ac1fSRafał Miłecki static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx, 83b073ac1fSRafał Miłecki struct sk_buff *skb) 84b073ac1fSRafał Miłecki { 85b073ac1fSRafał Miłecki return drvr->proto->tx_queue_data(drvr, ifidx, skb); 86b073ac1fSRafał Miłecki } 87b073ac1fSRafał Miłecki 8805491d2cSKalle Valo static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx, 8905491d2cSKalle Valo u8 offset, struct sk_buff *skb) 9005491d2cSKalle Valo { 9105491d2cSKalle Valo return drvr->proto->txdata(drvr, ifidx, offset, skb); 9205491d2cSKalle Valo } 9305491d2cSKalle Valo static inline void 9405491d2cSKalle Valo brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx, 9505491d2cSKalle Valo enum proto_addr_mode addr_mode) 9605491d2cSKalle Valo { 9705491d2cSKalle Valo drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode); 9805491d2cSKalle Valo } 9905491d2cSKalle Valo static inline void 10005491d2cSKalle Valo brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 10105491d2cSKalle Valo { 10205491d2cSKalle Valo drvr->proto->delete_peer(drvr, ifidx, peer); 10305491d2cSKalle Valo } 10405491d2cSKalle Valo static inline void 10505491d2cSKalle Valo brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 10605491d2cSKalle Valo { 10705491d2cSKalle Valo drvr->proto->add_tdls_peer(drvr, ifidx, peer); 10805491d2cSKalle Valo } 109bbd1f932SArend van Spriel static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb) 110bbd1f932SArend van Spriel { 111bbd1f932SArend van Spriel struct brcmf_skb_reorder_data *rd; 11205491d2cSKalle Valo 113bbd1f932SArend van Spriel rd = (struct brcmf_skb_reorder_data *)skb->cb; 114bbd1f932SArend van Spriel return !!rd->reorder; 115bbd1f932SArend van Spriel } 116bbd1f932SArend van Spriel 117bbd1f932SArend van Spriel static inline void 118bbd1f932SArend van Spriel brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb) 119bbd1f932SArend van Spriel { 120bbd1f932SArend van Spriel ifp->drvr->proto->rxreorder(ifp, skb); 121bbd1f932SArend van Spriel } 12205491d2cSKalle Valo 1239fdc64bbSFranky Lin static inline void 1249fdc64bbSFranky Lin brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 1259fdc64bbSFranky Lin { 1269fdc64bbSFranky Lin if (!drvr->proto->add_if) 1279fdc64bbSFranky Lin return; 1289fdc64bbSFranky Lin drvr->proto->add_if(ifp); 1299fdc64bbSFranky Lin } 1309fdc64bbSFranky Lin 131*c02a5eb8SFranky Lin static inline void 132*c02a5eb8SFranky Lin brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 133*c02a5eb8SFranky Lin { 134*c02a5eb8SFranky Lin if (!drvr->proto->del_if) 135*c02a5eb8SFranky Lin return; 136*c02a5eb8SFranky Lin drvr->proto->del_if(ifp); 137*c02a5eb8SFranky Lin } 138*c02a5eb8SFranky Lin 13905491d2cSKalle Valo #endif /* BRCMFMAC_PROTO_H */ 140