diff options
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmutil')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmutil/Makefile | 9 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmutil/d11.c | 162 | ||||
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmutil/utils.c | 25 |
3 files changed, 189 insertions, 7 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmutil/Makefile b/drivers/net/wireless/brcm80211/brcmutil/Makefile index 6281c416289e..8a928184016a 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/Makefile +++ b/drivers/net/wireless/brcm80211/brcmutil/Makefile | |||
@@ -19,10 +19,5 @@ ccflags-y := \ | |||
19 | -Idrivers/net/wireless/brcm80211/brcmutil \ | 19 | -Idrivers/net/wireless/brcm80211/brcmutil \ |
20 | -Idrivers/net/wireless/brcm80211/include | 20 | -Idrivers/net/wireless/brcm80211/include |
21 | 21 | ||
22 | BRCMUTIL_OFILES := \ | 22 | obj-$(CONFIG_BRCMUTIL) += brcmutil.o |
23 | utils.o | 23 | brcmutil-objs = utils.o d11.o |
24 | |||
25 | MODULEPFX := brcmutil | ||
26 | |||
27 | obj-$(CONFIG_BRCMUTIL) += $(MODULEPFX).o | ||
28 | $(MODULEPFX)-objs = $(BRCMUTIL_OFILES) | ||
diff --git a/drivers/net/wireless/brcm80211/brcmutil/d11.c b/drivers/net/wireless/brcm80211/brcmutil/d11.c new file mode 100644 index 000000000000..30e54e2c6c9b --- /dev/null +++ b/drivers/net/wireless/brcm80211/brcmutil/d11.c | |||
@@ -0,0 +1,162 @@ | |||
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 | /*********************channel spec common functions*********************/ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | |||
20 | #include <brcmu_utils.h> | ||
21 | #include <brcmu_wifi.h> | ||
22 | #include <brcmu_d11.h> | ||
23 | |||
24 | static void brcmu_d11n_encchspec(struct brcmu_chan *ch) | ||
25 | { | ||
26 | ch->chspec = ch->chnum & BRCMU_CHSPEC_CH_MASK; | ||
27 | |||
28 | switch (ch->bw) { | ||
29 | case BRCMU_CHAN_BW_20: | ||
30 | ch->chspec |= BRCMU_CHSPEC_D11N_BW_20 | BRCMU_CHSPEC_D11N_SB_N; | ||
31 | break; | ||
32 | case BRCMU_CHAN_BW_40: | ||
33 | default: | ||
34 | WARN_ON_ONCE(1); | ||
35 | break; | ||
36 | } | ||
37 | |||
38 | if (ch->chnum <= CH_MAX_2G_CHANNEL) | ||
39 | ch->chspec |= BRCMU_CHSPEC_D11N_BND_2G; | ||
40 | else | ||
41 | ch->chspec |= BRCMU_CHSPEC_D11N_BND_5G; | ||
42 | } | ||
43 | |||
44 | static void brcmu_d11ac_encchspec(struct brcmu_chan *ch) | ||
45 | { | ||
46 | ch->chspec = ch->chnum & BRCMU_CHSPEC_CH_MASK; | ||
47 | |||
48 | switch (ch->bw) { | ||
49 | case BRCMU_CHAN_BW_20: | ||
50 | ch->chspec |= BRCMU_CHSPEC_D11AC_BW_20; | ||
51 | break; | ||
52 | case BRCMU_CHAN_BW_40: | ||
53 | case BRCMU_CHAN_BW_80: | ||
54 | case BRCMU_CHAN_BW_80P80: | ||
55 | case BRCMU_CHAN_BW_160: | ||
56 | default: | ||
57 | WARN_ON_ONCE(1); | ||
58 | break; | ||
59 | } | ||
60 | |||
61 | if (ch->chnum <= CH_MAX_2G_CHANNEL) | ||
62 | ch->chspec |= BRCMU_CHSPEC_D11AC_BND_2G; | ||
63 | else | ||
64 | ch->chspec |= BRCMU_CHSPEC_D11AC_BND_5G; | ||
65 | } | ||
66 | |||
67 | static void brcmu_d11n_decchspec(struct brcmu_chan *ch) | ||
68 | { | ||
69 | u16 val; | ||
70 | |||
71 | ch->chnum = (u8)(ch->chspec & BRCMU_CHSPEC_CH_MASK); | ||
72 | |||
73 | switch (ch->chspec & BRCMU_CHSPEC_D11N_BW_MASK) { | ||
74 | case BRCMU_CHSPEC_D11N_BW_20: | ||
75 | ch->bw = BRCMU_CHAN_BW_20; | ||
76 | break; | ||
77 | case BRCMU_CHSPEC_D11N_BW_40: | ||
78 | ch->bw = BRCMU_CHAN_BW_40; | ||
79 | val = ch->chspec & BRCMU_CHSPEC_D11N_SB_MASK; | ||
80 | if (val == BRCMU_CHSPEC_D11N_SB_L) { | ||
81 | ch->sb = BRCMU_CHAN_SB_L; | ||
82 | ch->chnum -= CH_10MHZ_APART; | ||
83 | } else { | ||
84 | ch->sb = BRCMU_CHAN_SB_U; | ||
85 | ch->chnum += CH_10MHZ_APART; | ||
86 | } | ||
87 | break; | ||
88 | default: | ||
89 | WARN_ON_ONCE(1); | ||
90 | break; | ||
91 | } | ||
92 | |||
93 | switch (ch->chspec & BRCMU_CHSPEC_D11N_BND_MASK) { | ||
94 | case BRCMU_CHSPEC_D11N_BND_5G: | ||
95 | ch->band = BRCMU_CHAN_BAND_5G; | ||
96 | break; | ||
97 | case BRCMU_CHSPEC_D11N_BND_2G: | ||
98 | ch->band = BRCMU_CHAN_BAND_2G; | ||
99 | break; | ||
100 | default: | ||
101 | WARN_ON_ONCE(1); | ||
102 | break; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | static void brcmu_d11ac_decchspec(struct brcmu_chan *ch) | ||
107 | { | ||
108 | u16 val; | ||
109 | |||
110 | ch->chnum = (u8)(ch->chspec & BRCMU_CHSPEC_CH_MASK); | ||
111 | |||
112 | switch (ch->chspec & BRCMU_CHSPEC_D11AC_BW_MASK) { | ||
113 | case BRCMU_CHSPEC_D11AC_BW_20: | ||
114 | ch->bw = BRCMU_CHAN_BW_20; | ||
115 | break; | ||
116 | case BRCMU_CHSPEC_D11AC_BW_40: | ||
117 | ch->bw = BRCMU_CHAN_BW_40; | ||
118 | val = ch->chspec & BRCMU_CHSPEC_D11AC_SB_MASK; | ||
119 | if (val == BRCMU_CHSPEC_D11AC_SB_L) { | ||
120 | ch->sb = BRCMU_CHAN_SB_L; | ||
121 | ch->chnum -= CH_10MHZ_APART; | ||
122 | } else if (val == BRCMU_CHSPEC_D11AC_SB_U) { | ||
123 | ch->sb = BRCMU_CHAN_SB_U; | ||
124 | ch->chnum += CH_10MHZ_APART; | ||
125 | } else { | ||
126 | WARN_ON_ONCE(1); | ||
127 | } | ||
128 | break; | ||
129 | case BRCMU_CHSPEC_D11AC_BW_80: | ||
130 | ch->bw = BRCMU_CHAN_BW_80; | ||
131 | break; | ||
132 | case BRCMU_CHSPEC_D11AC_BW_8080: | ||
133 | case BRCMU_CHSPEC_D11AC_BW_160: | ||
134 | default: | ||
135 | WARN_ON_ONCE(1); | ||
136 | break; | ||
137 | } | ||
138 | |||
139 | switch (ch->chspec & BRCMU_CHSPEC_D11AC_BND_MASK) { | ||
140 | case BRCMU_CHSPEC_D11AC_BND_5G: | ||
141 | ch->band = BRCMU_CHAN_BAND_5G; | ||
142 | break; | ||
143 | case BRCMU_CHSPEC_D11AC_BND_2G: | ||
144 | ch->band = BRCMU_CHAN_BAND_2G; | ||
145 | break; | ||
146 | default: | ||
147 | WARN_ON_ONCE(1); | ||
148 | break; | ||
149 | } | ||
150 | } | ||
151 | |||
152 | void brcmu_d11_attach(struct brcmu_d11inf *d11inf) | ||
153 | { | ||
154 | if (d11inf->io_type == BRCMU_D11N_IOTYPE) { | ||
155 | d11inf->encchspec = brcmu_d11n_encchspec; | ||
156 | d11inf->decchspec = brcmu_d11n_decchspec; | ||
157 | } else { | ||
158 | d11inf->encchspec = brcmu_d11ac_encchspec; | ||
159 | d11inf->decchspec = brcmu_d11ac_decchspec; | ||
160 | } | ||
161 | } | ||
162 | EXPORT_SYMBOL(brcmu_d11_attach); | ||
diff --git a/drivers/net/wireless/brcm80211/brcmutil/utils.c b/drivers/net/wireless/brcm80211/brcmutil/utils.c index 3e6405e06ac0..bf5e50fc21ba 100644 --- a/drivers/net/wireless/brcm80211/brcmutil/utils.c +++ b/drivers/net/wireless/brcm80211/brcmutil/utils.c | |||
@@ -116,6 +116,31 @@ struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) | |||
116 | } | 116 | } |
117 | EXPORT_SYMBOL(brcmu_pktq_pdeq); | 117 | EXPORT_SYMBOL(brcmu_pktq_pdeq); |
118 | 118 | ||
119 | /* | ||
120 | * precedence based dequeue with match function. Passing a NULL pointer | ||
121 | * for the match function parameter is considered to be a wildcard so | ||
122 | * any packet on the queue is returned. In that case it is no different | ||
123 | * from brcmu_pktq_pdeq() above. | ||
124 | */ | ||
125 | struct sk_buff *brcmu_pktq_pdeq_match(struct pktq *pq, int prec, | ||
126 | bool (*match_fn)(struct sk_buff *skb, | ||
127 | void *arg), void *arg) | ||
128 | { | ||
129 | struct sk_buff_head *q; | ||
130 | struct sk_buff *p, *next; | ||
131 | |||
132 | q = &pq->q[prec].skblist; | ||
133 | skb_queue_walk_safe(q, p, next) { | ||
134 | if (match_fn == NULL || match_fn(p, arg)) { | ||
135 | skb_unlink(p, q); | ||
136 | pq->len--; | ||
137 | return p; | ||
138 | } | ||
139 | } | ||
140 | return NULL; | ||
141 | } | ||
142 | EXPORT_SYMBOL(brcmu_pktq_pdeq_match); | ||
143 | |||
119 | struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) | 144 | struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) |
120 | { | 145 | { |
121 | struct sk_buff_head *q; | 146 | struct sk_buff_head *q; |