1daeccac2SArend van Spriel // SPDX-License-Identifier: ISC
205491d2cSKalle Valo /*
305491d2cSKalle Valo * Copyright (c) 2013 Broadcom Corporation
405491d2cSKalle Valo */
505491d2cSKalle Valo #ifndef BRCMFMAC_PROTO_H
605491d2cSKalle Valo #define BRCMFMAC_PROTO_H
705491d2cSKalle Valo
805491d2cSKalle Valo
905491d2cSKalle Valo enum proto_addr_mode {
1005491d2cSKalle Valo ADDR_INDIRECT = 0,
1105491d2cSKalle Valo ADDR_DIRECT
1205491d2cSKalle Valo };
1305491d2cSKalle Valo
14bbd1f932SArend van Spriel struct brcmf_skb_reorder_data {
15bbd1f932SArend van Spriel u8 *reorder;
16bbd1f932SArend van Spriel };
1705491d2cSKalle Valo
1805491d2cSKalle Valo struct brcmf_proto {
1905491d2cSKalle Valo int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
2005491d2cSKalle Valo struct sk_buff *skb, struct brcmf_if **ifp);
2105491d2cSKalle Valo int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
22b69c1df4SArend Van Spriel void *buf, uint len, int *fwerr);
2305491d2cSKalle Valo int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
24b69c1df4SArend Van Spriel uint len, int *fwerr);
25b073ac1fSRafał Miłecki int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx,
26b073ac1fSRafał Miłecki struct sk_buff *skb);
2705491d2cSKalle Valo int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,
2805491d2cSKalle Valo struct sk_buff *skb);
2905491d2cSKalle Valo void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx,
3005491d2cSKalle Valo enum proto_addr_mode addr_mode);
3105491d2cSKalle Valo void (*delete_peer)(struct brcmf_pub *drvr, int ifidx,
3205491d2cSKalle Valo u8 peer[ETH_ALEN]);
3305491d2cSKalle Valo void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,
3405491d2cSKalle Valo u8 peer[ETH_ALEN]);
35*b381728eSSebastian Andrzej Siewior void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb);
369fdc64bbSFranky Lin void (*add_if)(struct brcmf_if *ifp);
37c02a5eb8SFranky Lin void (*del_if)(struct brcmf_if *ifp);
3866ded1f8SFranky Lin void (*reset_if)(struct brcmf_if *ifp);
3962c50a34SFranky Lin int (*init_done)(struct brcmf_pub *drvr);
4034789d0cSArend Van Spriel void (*debugfs_create)(struct brcmf_pub *drvr);
4105491d2cSKalle Valo void *pd;
4205491d2cSKalle Valo };
4305491d2cSKalle Valo
4405491d2cSKalle Valo
4505491d2cSKalle Valo int brcmf_proto_attach(struct brcmf_pub *drvr);
46a84a60ccSArend van Spriel void brcmf_proto_detach(struct brcmf_pub *drvr);
4705491d2cSKalle Valo
brcmf_proto_hdrpull(struct brcmf_pub * drvr,bool do_fws,struct sk_buff * skb,struct brcmf_if ** ifp)4805491d2cSKalle Valo static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
4905491d2cSKalle Valo struct sk_buff *skb,
5005491d2cSKalle Valo struct brcmf_if **ifp)
5105491d2cSKalle Valo {
5205491d2cSKalle Valo struct brcmf_if *tmp = NULL;
5305491d2cSKalle Valo
5405491d2cSKalle Valo /* assure protocol is always called with
5505491d2cSKalle Valo * non-null initialized pointer.
5605491d2cSKalle Valo */
5705491d2cSKalle Valo if (ifp)
5805491d2cSKalle Valo *ifp = NULL;
5905491d2cSKalle Valo else
6005491d2cSKalle Valo ifp = &tmp;
6105491d2cSKalle Valo return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
6205491d2cSKalle Valo }
brcmf_proto_query_dcmd(struct brcmf_pub * drvr,int ifidx,uint cmd,void * buf,uint len,int * fwerr)6305491d2cSKalle Valo static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
64b69c1df4SArend Van Spriel uint cmd, void *buf, uint len,
65b69c1df4SArend Van Spriel int *fwerr)
6605491d2cSKalle Valo {
67b69c1df4SArend Van Spriel return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr);
6805491d2cSKalle Valo }
brcmf_proto_set_dcmd(struct brcmf_pub * drvr,int ifidx,uint cmd,void * buf,uint len,int * fwerr)6905491d2cSKalle Valo static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
70b69c1df4SArend Van Spriel uint cmd, void *buf, uint len,
71b69c1df4SArend Van Spriel int *fwerr)
7205491d2cSKalle Valo {
73b69c1df4SArend Van Spriel return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr);
7405491d2cSKalle Valo }
75b073ac1fSRafał Miłecki
brcmf_proto_tx_queue_data(struct brcmf_pub * drvr,int ifidx,struct sk_buff * skb)76b073ac1fSRafał Miłecki static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,
77b073ac1fSRafał Miłecki struct sk_buff *skb)
78b073ac1fSRafał Miłecki {
79b073ac1fSRafał Miłecki return drvr->proto->tx_queue_data(drvr, ifidx, skb);
80b073ac1fSRafał Miłecki }
81b073ac1fSRafał Miłecki
brcmf_proto_txdata(struct brcmf_pub * drvr,int ifidx,u8 offset,struct sk_buff * skb)8205491d2cSKalle Valo static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
8305491d2cSKalle Valo u8 offset, struct sk_buff *skb)
8405491d2cSKalle Valo {
8505491d2cSKalle Valo return drvr->proto->txdata(drvr, ifidx, offset, skb);
8605491d2cSKalle Valo }
8705491d2cSKalle Valo static inline void
brcmf_proto_configure_addr_mode(struct brcmf_pub * drvr,int ifidx,enum proto_addr_mode addr_mode)8805491d2cSKalle Valo brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
8905491d2cSKalle Valo enum proto_addr_mode addr_mode)
9005491d2cSKalle Valo {
9105491d2cSKalle Valo drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
9205491d2cSKalle Valo }
9305491d2cSKalle Valo static inline void
brcmf_proto_delete_peer(struct brcmf_pub * drvr,int ifidx,u8 peer[ETH_ALEN])9405491d2cSKalle Valo brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
9505491d2cSKalle Valo {
9605491d2cSKalle Valo drvr->proto->delete_peer(drvr, ifidx, peer);
9705491d2cSKalle Valo }
9805491d2cSKalle Valo static inline void
brcmf_proto_add_tdls_peer(struct brcmf_pub * drvr,int ifidx,u8 peer[ETH_ALEN])9905491d2cSKalle Valo brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
10005491d2cSKalle Valo {
10105491d2cSKalle Valo drvr->proto->add_tdls_peer(drvr, ifidx, peer);
10205491d2cSKalle Valo }
brcmf_proto_is_reorder_skb(struct sk_buff * skb)103bbd1f932SArend van Spriel static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)
104bbd1f932SArend van Spriel {
105bbd1f932SArend van Spriel struct brcmf_skb_reorder_data *rd;
10605491d2cSKalle Valo
107bbd1f932SArend van Spriel rd = (struct brcmf_skb_reorder_data *)skb->cb;
108bbd1f932SArend van Spriel return !!rd->reorder;
109bbd1f932SArend van Spriel }
110bbd1f932SArend van Spriel
111bbd1f932SArend van Spriel static inline void
brcmf_proto_rxreorder(struct brcmf_if * ifp,struct sk_buff * skb)112*b381728eSSebastian Andrzej Siewior brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)
113bbd1f932SArend van Spriel {
114*b381728eSSebastian Andrzej Siewior ifp->drvr->proto->rxreorder(ifp, skb);
115bbd1f932SArend van Spriel }
11605491d2cSKalle Valo
1179fdc64bbSFranky Lin static inline void
brcmf_proto_add_if(struct brcmf_pub * drvr,struct brcmf_if * ifp)1189fdc64bbSFranky Lin brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
1199fdc64bbSFranky Lin {
1209fdc64bbSFranky Lin if (!drvr->proto->add_if)
1219fdc64bbSFranky Lin return;
1229fdc64bbSFranky Lin drvr->proto->add_if(ifp);
1239fdc64bbSFranky Lin }
1249fdc64bbSFranky Lin
125c02a5eb8SFranky Lin static inline void
brcmf_proto_del_if(struct brcmf_pub * drvr,struct brcmf_if * ifp)126c02a5eb8SFranky Lin brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
127c02a5eb8SFranky Lin {
128c02a5eb8SFranky Lin if (!drvr->proto->del_if)
129c02a5eb8SFranky Lin return;
130c02a5eb8SFranky Lin drvr->proto->del_if(ifp);
131c02a5eb8SFranky Lin }
132c02a5eb8SFranky Lin
13366ded1f8SFranky Lin static inline void
brcmf_proto_reset_if(struct brcmf_pub * drvr,struct brcmf_if * ifp)13466ded1f8SFranky Lin brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
13566ded1f8SFranky Lin {
13666ded1f8SFranky Lin if (!drvr->proto->reset_if)
13766ded1f8SFranky Lin return;
13866ded1f8SFranky Lin drvr->proto->reset_if(ifp);
13966ded1f8SFranky Lin }
14066ded1f8SFranky Lin
14162c50a34SFranky Lin static inline int
brcmf_proto_init_done(struct brcmf_pub * drvr)14262c50a34SFranky Lin brcmf_proto_init_done(struct brcmf_pub *drvr)
14362c50a34SFranky Lin {
14462c50a34SFranky Lin if (!drvr->proto->init_done)
14562c50a34SFranky Lin return 0;
14662c50a34SFranky Lin return drvr->proto->init_done(drvr);
14762c50a34SFranky Lin }
14862c50a34SFranky Lin
14934789d0cSArend Van Spriel static inline void
brcmf_proto_debugfs_create(struct brcmf_pub * drvr)15034789d0cSArend Van Spriel brcmf_proto_debugfs_create(struct brcmf_pub *drvr)
15134789d0cSArend Van Spriel {
15234789d0cSArend Van Spriel drvr->proto->debugfs_create(drvr);
15334789d0cSArend Van Spriel }
15434789d0cSArend Van Spriel
15505491d2cSKalle Valo #endif /* BRCMFMAC_PROTO_H */
156