1 /* 2 * Copyright (c) 2013 Broadcom Corporation 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 #ifndef BRCMFMAC_PROTO_H 17 #define BRCMFMAC_PROTO_H 18 19 20 enum proto_addr_mode { 21 ADDR_INDIRECT = 0, 22 ADDR_DIRECT 23 }; 24 25 struct brcmf_skb_reorder_data { 26 u8 *reorder; 27 }; 28 29 struct brcmf_proto { 30 int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws, 31 struct sk_buff *skb, struct brcmf_if **ifp); 32 int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, 33 void *buf, uint len, int *fwerr); 34 int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf, 35 uint len, int *fwerr); 36 int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx, 37 struct sk_buff *skb); 38 int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset, 39 struct sk_buff *skb); 40 void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx, 41 enum proto_addr_mode addr_mode); 42 void (*delete_peer)(struct brcmf_pub *drvr, int ifidx, 43 u8 peer[ETH_ALEN]); 44 void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx, 45 u8 peer[ETH_ALEN]); 46 void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb); 47 void (*add_if)(struct brcmf_if *ifp); 48 void (*del_if)(struct brcmf_if *ifp); 49 void (*reset_if)(struct brcmf_if *ifp); 50 int (*init_done)(struct brcmf_pub *drvr); 51 void (*debugfs_create)(struct brcmf_pub *drvr); 52 void *pd; 53 }; 54 55 56 int brcmf_proto_attach(struct brcmf_pub *drvr); 57 void brcmf_proto_detach(struct brcmf_pub *drvr); 58 59 static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws, 60 struct sk_buff *skb, 61 struct brcmf_if **ifp) 62 { 63 struct brcmf_if *tmp = NULL; 64 65 /* assure protocol is always called with 66 * non-null initialized pointer. 67 */ 68 if (ifp) 69 *ifp = NULL; 70 else 71 ifp = &tmp; 72 return drvr->proto->hdrpull(drvr, do_fws, skb, ifp); 73 } 74 static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx, 75 uint cmd, void *buf, uint len, 76 int *fwerr) 77 { 78 return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr); 79 } 80 static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx, 81 uint cmd, void *buf, uint len, 82 int *fwerr) 83 { 84 return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr); 85 } 86 87 static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx, 88 struct sk_buff *skb) 89 { 90 return drvr->proto->tx_queue_data(drvr, ifidx, skb); 91 } 92 93 static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx, 94 u8 offset, struct sk_buff *skb) 95 { 96 return drvr->proto->txdata(drvr, ifidx, offset, skb); 97 } 98 static inline void 99 brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx, 100 enum proto_addr_mode addr_mode) 101 { 102 drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode); 103 } 104 static inline void 105 brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 106 { 107 drvr->proto->delete_peer(drvr, ifidx, peer); 108 } 109 static inline void 110 brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN]) 111 { 112 drvr->proto->add_tdls_peer(drvr, ifidx, peer); 113 } 114 static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb) 115 { 116 struct brcmf_skb_reorder_data *rd; 117 118 rd = (struct brcmf_skb_reorder_data *)skb->cb; 119 return !!rd->reorder; 120 } 121 122 static inline void 123 brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb) 124 { 125 ifp->drvr->proto->rxreorder(ifp, skb); 126 } 127 128 static inline void 129 brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 130 { 131 if (!drvr->proto->add_if) 132 return; 133 drvr->proto->add_if(ifp); 134 } 135 136 static inline void 137 brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 138 { 139 if (!drvr->proto->del_if) 140 return; 141 drvr->proto->del_if(ifp); 142 } 143 144 static inline void 145 brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp) 146 { 147 if (!drvr->proto->reset_if) 148 return; 149 drvr->proto->reset_if(ifp); 150 } 151 152 static inline int 153 brcmf_proto_init_done(struct brcmf_pub *drvr) 154 { 155 if (!drvr->proto->init_done) 156 return 0; 157 return drvr->proto->init_done(drvr); 158 } 159 160 static inline void 161 brcmf_proto_debugfs_create(struct brcmf_pub *drvr) 162 { 163 drvr->proto->debugfs_create(drvr); 164 } 165 166 #endif /* BRCMFMAC_PROTO_H */ 167