1 // SPDX-License-Identifier: ISC 2 /* 3 * Copyright (c) 2013 Broadcom Corporation 4 */ 5 #ifndef BRCMFMAC_PROTO_H 6 #define BRCMFMAC_PROTO_H 7 8 9 enum proto_addr_mode { 10 ADDR_INDIRECT = 0, 11 ADDR_DIRECT 12 }; 13 14 struct brcmf_skb_reorder_data { 15 u8 *reorder; 16 }; 17 18 struct brcmf_proto { 19 int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws, 20 struct sk_buff *skb, struct brcmf_if **ifp); 21 int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, 22 void *buf, uint len, int *fwerr); 23 int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, 24 uint len, int *fwerr); 25 int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx, 26 struct sk_buff *skb); 27 int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset, 28 struct sk_buff *skb); 29 void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx, 30 enum proto_addr_mode addr_mode); 31 void (*delete_peer)(struct brcmf_pub *drvr, int ifidx, 32 u8 peer[ETH_ALEN]); 33 void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx, 34 u8 peer[ETH_ALEN]); 35 void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb); 36 void (*add_if)(struct brcmf_if *ifp); 37 void (*del_if)(struct brcmf_if *ifp); 38 void (*reset_if)(struct brcmf_if *ifp); 39 int (*init_done)(struct brcmf_pub *drvr); 40 void (*debugfs_create)(struct brcmf_pub *drvr); 41 void *pd; 42 }; 43 44 45 int brcmf_proto_attach(struct brcmf_pub *drvr); 46 void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr); 47 void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr); 48 49 static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws, 50 struct sk_buff *skb, 51 struct brcmf_if **ifp) 52 { 53 struct brcmf_if *tmp = NULL; 54 55 /* assure protocol is always called with 56 * non-null initialized pointer. 57 */ 58 if (ifp) 59 *ifp = NULL; 60 else 61 ifp = &tmp; 62 return drvr->proto->hdrpull(drvr, do_fws, skb, ifp); 63 } 64 static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx, 65 uint cmd, void *buf, uint len, 66 int *fwerr) 67 { 68 return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr); 69 } 70 static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx, 71 uint cmd, void *buf, uint len, 72 int *fwerr) 73 { 74 return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr); 75 } 76 77 static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx, 78 struct sk_buff *skb) 79 { 80 return drvr->proto->tx_queue_data(drvr, ifidx, skb); 81 } 82 83 static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx, 84 u8 offset, struct sk_buff *skb) 85 { 86 return drvr->proto->txdata(drvr, ifidx, offset, skb); 87 } 88 static inline void 89 brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx, 90 enum proto_addr_mode addr_mode) 91 { 92 drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode); 93 } 94 static inline void 95 brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 96 { 97 drvr->proto->delete_peer(drvr, ifidx, peer); 98 } 99 static inline void 100 brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 101 { 102 drvr->proto->add_tdls_peer(drvr, ifidx, peer); 103 } 104 static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb) 105 { 106 struct brcmf_skb_reorder_data *rd; 107 108 rd = (struct brcmf_skb_reorder_data *)skb->cb; 109 return !!rd->reorder; 110 } 111 112 static inline void 113 brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb) 114 { 115 ifp->drvr->proto->rxreorder(ifp, skb); 116 } 117 118 static inline void 119 brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 120 { 121 if (!drvr->proto->add_if) 122 return; 123 drvr->proto->add_if(ifp); 124 } 125 126 static inline void 127 brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 128 { 129 if (!drvr->proto->del_if) 130 return; 131 drvr->proto->del_if(ifp); 132 } 133 134 static inline void 135 brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 136 { 137 if (!drvr->proto->reset_if) 138 return; 139 drvr->proto->reset_if(ifp); 140 } 141 142 static inline int 143 brcmf_proto_init_done(struct brcmf_pub *drvr) 144 { 145 if (!drvr->proto->init_done) 146 return 0; 147 return drvr->proto->init_done(drvr); 148 } 149 150 static inline void 151 brcmf_proto_debugfs_create(struct brcmf_pub *drvr) 152 { 153 drvr->proto->debugfs_create(drvr); 154 } 155 156 #endif /* BRCMFMAC_PROTO_H */ 157