xref: /linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h (revision b073ac1fcf42376018f6db6acc885dfd2cc9ff02)
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);
36*b073ac1fSRafał Miłecki 	int (*tx_queue_data)(struct brcmf_pub *drvr, int ifidx,
37*b073ac1fSRafał 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);
4705491d2cSKalle Valo 	void *pd;
4805491d2cSKalle Valo };
4905491d2cSKalle Valo 
5005491d2cSKalle Valo 
5105491d2cSKalle Valo int brcmf_proto_attach(struct brcmf_pub *drvr);
5205491d2cSKalle Valo void brcmf_proto_detach(struct brcmf_pub *drvr);
5305491d2cSKalle Valo 
5405491d2cSKalle Valo static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
5505491d2cSKalle Valo 				      struct sk_buff *skb,
5605491d2cSKalle Valo 				      struct brcmf_if **ifp)
5705491d2cSKalle Valo {
5805491d2cSKalle Valo 	struct brcmf_if *tmp = NULL;
5905491d2cSKalle Valo 
6005491d2cSKalle Valo 	/* assure protocol is always called with
6105491d2cSKalle Valo 	 * non-null initialized pointer.
6205491d2cSKalle Valo 	 */
6305491d2cSKalle Valo 	if (ifp)
6405491d2cSKalle Valo 		*ifp = NULL;
6505491d2cSKalle Valo 	else
6605491d2cSKalle Valo 		ifp = &tmp;
6705491d2cSKalle Valo 	return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
6805491d2cSKalle Valo }
6905491d2cSKalle Valo static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
7005491d2cSKalle Valo 					 uint cmd, void *buf, uint len)
7105491d2cSKalle Valo {
7205491d2cSKalle Valo 	return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len);
7305491d2cSKalle Valo }
7405491d2cSKalle Valo static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
7505491d2cSKalle Valo 				       uint cmd, void *buf, uint len)
7605491d2cSKalle Valo {
7705491d2cSKalle Valo 	return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len);
7805491d2cSKalle Valo }
79*b073ac1fSRafał Miłecki 
80*b073ac1fSRafał Miłecki static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,
81*b073ac1fSRafał Miłecki 					    struct sk_buff *skb)
82*b073ac1fSRafał Miłecki {
83*b073ac1fSRafał Miłecki 	return drvr->proto->tx_queue_data(drvr, ifidx, skb);
84*b073ac1fSRafał Miłecki }
85*b073ac1fSRafał Miłecki 
8605491d2cSKalle Valo static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
8705491d2cSKalle Valo 				     u8 offset, struct sk_buff *skb)
8805491d2cSKalle Valo {
8905491d2cSKalle Valo 	return drvr->proto->txdata(drvr, ifidx, offset, skb);
9005491d2cSKalle Valo }
9105491d2cSKalle Valo static inline void
9205491d2cSKalle Valo brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
9305491d2cSKalle Valo 				enum proto_addr_mode addr_mode)
9405491d2cSKalle Valo {
9505491d2cSKalle Valo 	drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
9605491d2cSKalle Valo }
9705491d2cSKalle Valo static inline void
9805491d2cSKalle Valo brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
9905491d2cSKalle Valo {
10005491d2cSKalle Valo 	drvr->proto->delete_peer(drvr, ifidx, peer);
10105491d2cSKalle Valo }
10205491d2cSKalle Valo static inline void
10305491d2cSKalle Valo brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
10405491d2cSKalle Valo {
10505491d2cSKalle Valo 	drvr->proto->add_tdls_peer(drvr, ifidx, peer);
10605491d2cSKalle Valo }
107bbd1f932SArend van Spriel static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)
108bbd1f932SArend van Spriel {
109bbd1f932SArend van Spriel 	struct brcmf_skb_reorder_data *rd;
11005491d2cSKalle Valo 
111bbd1f932SArend van Spriel 	rd = (struct brcmf_skb_reorder_data *)skb->cb;
112bbd1f932SArend van Spriel 	return !!rd->reorder;
113bbd1f932SArend van Spriel }
114bbd1f932SArend van Spriel 
115bbd1f932SArend van Spriel static inline void
116bbd1f932SArend van Spriel brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)
117bbd1f932SArend van Spriel {
118bbd1f932SArend van Spriel 	ifp->drvr->proto->rxreorder(ifp, skb);
119bbd1f932SArend van Spriel }
12005491d2cSKalle Valo 
12105491d2cSKalle Valo #endif /* BRCMFMAC_PROTO_H */
122