Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmfmac/proto.h
178665 views
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
#if defined(__linux__)
33
u8 peer[ETH_ALEN]);
34
#elif defined(__FreeBSD__)
35
const u8 peer[ETH_ALEN]);
36
#endif
37
void (*add_tdls_peer)(struct brcmf_pub *drvr, int ifidx,
38
#if defined(__linux__)
39
u8 peer[ETH_ALEN]);
40
#elif defined(__FreeBSD__)
41
const u8 peer[ETH_ALEN]);
42
#endif
43
void (*rxreorder)(struct brcmf_if *ifp, struct sk_buff *skb);
44
void (*add_if)(struct brcmf_if *ifp);
45
void (*del_if)(struct brcmf_if *ifp);
46
void (*reset_if)(struct brcmf_if *ifp);
47
int (*init_done)(struct brcmf_pub *drvr);
48
void (*debugfs_create)(struct brcmf_pub *drvr);
49
void *pd;
50
};
51
52
53
int brcmf_proto_attach(struct brcmf_pub *drvr);
54
void brcmf_proto_detach(struct brcmf_pub *drvr);
55
56
static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
57
struct sk_buff *skb,
58
struct brcmf_if **ifp)
59
{
60
struct brcmf_if *tmp = NULL;
61
62
/* assure protocol is always called with
63
* non-null initialized pointer.
64
*/
65
if (ifp)
66
*ifp = NULL;
67
else
68
ifp = &tmp;
69
return drvr->proto->hdrpull(drvr, do_fws, skb, ifp);
70
}
71
static inline int brcmf_proto_query_dcmd(struct brcmf_pub *drvr, int ifidx,
72
uint cmd, void *buf, uint len,
73
int *fwerr)
74
{
75
return drvr->proto->query_dcmd(drvr, ifidx, cmd, buf, len,fwerr);
76
}
77
static inline int brcmf_proto_set_dcmd(struct brcmf_pub *drvr, int ifidx,
78
uint cmd, void *buf, uint len,
79
int *fwerr)
80
{
81
return drvr->proto->set_dcmd(drvr, ifidx, cmd, buf, len, fwerr);
82
}
83
84
static inline int brcmf_proto_tx_queue_data(struct brcmf_pub *drvr, int ifidx,
85
struct sk_buff *skb)
86
{
87
return drvr->proto->tx_queue_data(drvr, ifidx, skb);
88
}
89
90
static inline int brcmf_proto_txdata(struct brcmf_pub *drvr, int ifidx,
91
u8 offset, struct sk_buff *skb)
92
{
93
return drvr->proto->txdata(drvr, ifidx, offset, skb);
94
}
95
static inline void
96
brcmf_proto_configure_addr_mode(struct brcmf_pub *drvr, int ifidx,
97
enum proto_addr_mode addr_mode)
98
{
99
drvr->proto->configure_addr_mode(drvr, ifidx, addr_mode);
100
}
101
static inline void
102
#if defined(__linux__)
103
brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
104
#elif defined(__FreeBSD__)
105
brcmf_proto_delete_peer(struct brcmf_pub *drvr, int ifidx, const u8 peer[ETH_ALEN])
106
#endif
107
{
108
drvr->proto->delete_peer(drvr, ifidx, peer);
109
}
110
static inline void
111
#if defined(__linux__)
112
brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, u8 peer[ETH_ALEN])
113
#elif defined(__FreeBSD__)
114
brcmf_proto_add_tdls_peer(struct brcmf_pub *drvr, int ifidx, const u8 peer[ETH_ALEN])
115
#endif
116
{
117
drvr->proto->add_tdls_peer(drvr, ifidx, peer);
118
}
119
static inline bool brcmf_proto_is_reorder_skb(struct sk_buff *skb)
120
{
121
struct brcmf_skb_reorder_data *rd;
122
123
rd = (struct brcmf_skb_reorder_data *)skb->cb;
124
return !!rd->reorder;
125
}
126
127
static inline void
128
brcmf_proto_rxreorder(struct brcmf_if *ifp, struct sk_buff *skb)
129
{
130
ifp->drvr->proto->rxreorder(ifp, skb);
131
}
132
133
static inline void
134
brcmf_proto_add_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
135
{
136
if (!drvr->proto->add_if)
137
return;
138
drvr->proto->add_if(ifp);
139
}
140
141
static inline void
142
brcmf_proto_del_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
143
{
144
if (!drvr->proto->del_if)
145
return;
146
drvr->proto->del_if(ifp);
147
}
148
149
static inline void
150
brcmf_proto_reset_if(struct brcmf_pub *drvr, struct brcmf_if *ifp)
151
{
152
if (!drvr->proto->reset_if)
153
return;
154
drvr->proto->reset_if(ifp);
155
}
156
157
static inline int
158
brcmf_proto_init_done(struct brcmf_pub *drvr)
159
{
160
if (!drvr->proto->init_done)
161
return 0;
162
return drvr->proto->init_done(drvr);
163
}
164
165
static inline void
166
brcmf_proto_debugfs_create(struct brcmf_pub *drvr)
167
{
168
drvr->proto->debugfs_create(drvr);
169
}
170
171
#endif /* BRCMFMAC_PROTO_H */
172
173