Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmfmac/proto.h
178665 views
// SPDX-License-Identifier: ISC1/*2* Copyright (c) 2013 Broadcom Corporation3*/4#ifndef BRCMFMAC_PROTO_H5#define BRCMFMAC_PROTO_H678enum proto_addr_mode {9ADDR_INDIRECT = 0,10ADDR_DIRECT11};1213struct brcmf_skb_reorder_data {14u8 *reorder;15};1617struct brcmf_proto {18int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,19struct sk_buff *skb, struct brcmf_if **ifp);20int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,21void *buf, uint len, int *fwerr);22int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,23uint len, int *fwerr);24int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx,25struct sk_buff *skb);26int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,27struct sk_buff *skb);28void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx,29enum proto_addr_mode addr_mode);30void (*delete_peer)(struct brcmf_pub *drvr, int ifidx,31#if defined(__linux__)32u8 peer[ETH_ALEN]);33#elif defined(__FreeBSD__)34const u8 peer[ETH_ALEN]);35#endif36void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,37#if defined(__linux__)38u8 peer[ETH_ALEN]);39#elif defined(__FreeBSD__)40const u8 peer[ETH_ALEN]);41#endif42void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb);43void (*add_if)(struct brcmf_if *ifp);44void (*del_if)(struct brcmf_if *ifp);45void (*reset_if)(struct brcmf_if *ifp);46int (*init_done)(struct brcmf_pub *drvr);47void (*debugfs_create)(struct brcmf_pub *drvr);48void *pd;49};505152int brcmf_proto_attach(struct brcmf_pub *drvr);53void brcmf_proto_detach(struct brcmf_pub *drvr);5455static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,56struct sk_buff *skb,57struct brcmf_if **ifp)58{59struct brcmf_if *tmp = NULL;6061/* assure protocol is always called with62* non-null initialized pointer.63*/64if (ifp)65*ifp = NULL;66else67ifp = &tmp;68return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);69}70static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,71uint cmd, void *buf, uint len,72int *fwerr)73{74return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr);75}76static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,77uint cmd, void *buf, uint len,78int *fwerr)79{80return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr);81}8283static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,84struct sk_buff *skb)85{86return drvr->proto->tx_queue_data(drvr, ifidx, skb);87}8889static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,90u8 offset, struct sk_buff *skb)91{92return drvr->proto->txdata(drvr, ifidx, offset, skb);93}94static inline void95brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,96enum proto_addr_mode addr_mode)97{98drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);99}100static inline void101#if defined(__linux__)102brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])103#elif defined(__FreeBSD__)104brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, const u8 peer[ETH_ALEN])105#endif106{107drvr->proto->delete_peer(drvr, ifidx, peer);108}109static inline void110#if defined(__linux__)111brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])112#elif defined(__FreeBSD__)113brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, const u8 peer[ETH_ALEN])114#endif115{116drvr->proto->add_tdls_peer(drvr, ifidx, peer);117}118static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)119{120struct brcmf_skb_reorder_data *rd;121122rd = (struct brcmf_skb_reorder_data *)skb->cb;123return !!rd->reorder;124}125126static inline void127brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)128{129ifp->drvr->proto->rxreorder(ifp, skb);130}131132static inline void133brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)134{135if (!drvr->proto->add_if)136return;137drvr->proto->add_if(ifp);138}139140static inline void141brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)142{143if (!drvr->proto->del_if)144return;145drvr->proto->del_if(ifp);146}147148static inline void149brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)150{151if (!drvr->proto->reset_if)152return;153drvr->proto->reset_if(ifp);154}155156static inline int157brcmf_proto_init_done(struct brcmf_pub *drvr)158{159if (!drvr->proto->init_done)160return 0;161return drvr->proto->init_done(drvr);162}163164static inline void165brcmf_proto_debugfs_create(struct brcmf_pub *drvr)166{167drvr->proto->debugfs_create(drvr);168}169170#endif /* BRCMFMAC_PROTO_H */171172173