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
20enum proto_addr_mode {
21	ADDR_INDIRECT	= 0,
22	ADDR_DIRECT
23};
24
25
26struct brcmf_proto {
27	int (*hdrpull)(struct brcmf_pub *drvr, bool do_fws,
28		       struct sk_buff *skb, struct brcmf_if **ifp);
29	int (*query_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd,
30			  void *buf, uint len);
31	int (*set_dcmd)(struct brcmf_pub *drvr, int ifidx, uint cmd, void *buf,
32			uint len);
33	int (*txdata)(struct brcmf_pub *drvr, int ifidx, u8 offset,
34		      struct sk_buff *skb);
35	void (*configure_addr_mode)(struct brcmf_pub *drvr, int ifidx,
36				    enum proto_addr_mode addr_mode);
37	void (*delete_peer)(struct brcmf_pub *drvr, int ifidx,
38			    u8 peer[ETH_ALEN]);
39	void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,
40			      u8 peer[ETH_ALEN]);
41	void *pd;
42};
43
44
45int brcmf_proto_attach(struct brcmf_pub *drvr);
46void brcmf_proto_detach(struct brcmf_pub *drvr);
47
48static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
49				      struct sk_buff *skb,
50				      struct brcmf_if **ifp)
51{
52	struct brcmf_if *tmp = NULL;
53
54	/* assure protocol is always called with
55	 * non-null initialized pointer.
56	 */
57	if (ifp)
58		*ifp = NULL;
59	else
60		ifp = &tmp;
61	return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
62}
63static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
64					 uint cmd, void *buf, uint len)
65{
66	return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len);
67}
68static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
69				       uint cmd, void *buf, uint len)
70{
71	return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len);
72}
73static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
74				     u8 offset, struct sk_buff *skb)
75{
76	return drvr->proto->txdata(drvr, ifidx, offset, skb);
77}
78static inline void
79brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
80				enum proto_addr_mode addr_mode)
81{
82	drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
83}
84static inline void
85brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
86{
87	drvr->proto->delete_peer(drvr, ifidx, peer);
88}
89static inline void
90brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
91{
92	drvr->proto->add_tdls_peer(drvr, ifidx, peer);
93}
94
95
96#endif /* BRCMFMAC_PROTO_H */
97