nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 #ifndef _CHANNELS_H_
2 #define _CHANNELS_H_
3  
4 typedef unsigned short chanspec_t;
5  
6 /* channel defines */
7 #define CH_UPPER_SB 0x01
8 #define CH_LOWER_SB 0x02
9 #define CH_EWA_VALID 0x04
10 #define CH_80MHZ_APART 16
11 #define CH_40MHZ_APART 8
12 #define CH_20MHZ_APART 4
13 #define CH_10MHZ_APART 2
14 #define CH_5MHZ_APART 1 /* 2G band channels are 5 Mhz apart */
15 #define CH_MAX_2G_CHANNEL 14 /* Max channel in 2G band */
16 #define MAXCHANNEL 224 /* max # supported channels. The max channel no is 216,
17 * this is that + 1 rounded up to a multiple of NBBY (8).
18 * DO NOT MAKE it > 255: channels are uint8's all over
19 */
20 #define CHSPEC_CTLOVLP(sp1, sp2, sep) (ABS(wf_chspec_ctlchan(sp1) - wf_chspec_ctlchan(sp2)) < \
21 (sep))
22  
23 #define WL_CHANSPEC_CHAN_MASK 0x00ff
24 #define WL_CHANSPEC_CHAN_SHIFT 0
25 #define WL_CHANSPEC_CHAN1_MASK 0x000f
26 #define WL_CHANSPEC_CHAN1_SHIFT 0
27 #define WL_CHANSPEC_CHAN2_MASK 0x00f0
28 #define WL_CHANSPEC_CHAN2_SHIFT 4
29  
30 #define WL_CHANSPEC_CTL_SB_MASK 0x0700
31 #define WL_CHANSPEC_CTL_SB_SHIFT 8
32 #define WL_CHANSPEC_CTL_SB_LLL 0x0000
33 #define WL_CHANSPEC_CTL_SB_LLU 0x0100
34 #define WL_CHANSPEC_CTL_SB_LUL 0x0200
35 #define WL_CHANSPEC_CTL_SB_LUU 0x0300
36 #define WL_CHANSPEC_CTL_SB_ULL 0x0400
37 #define WL_CHANSPEC_CTL_SB_ULU 0x0500
38 #define WL_CHANSPEC_CTL_SB_UUL 0x0600
39 #define WL_CHANSPEC_CTL_SB_UUU 0x0700
40 #define WL_CHANSPEC_CTL_SB_LL WL_CHANSPEC_CTL_SB_LLL
41 #define WL_CHANSPEC_CTL_SB_LU WL_CHANSPEC_CTL_SB_LLU
42 #define WL_CHANSPEC_CTL_SB_UL WL_CHANSPEC_CTL_SB_LUL
43 #define WL_CHANSPEC_CTL_SB_UU WL_CHANSPEC_CTL_SB_LUU
44 #define WL_CHANSPEC_CTL_SB_L WL_CHANSPEC_CTL_SB_LLL
45 #define WL_CHANSPEC_CTL_SB_U WL_CHANSPEC_CTL_SB_LLU
46 #define WL_CHANSPEC_CTL_SB_LOWER WL_CHANSPEC_CTL_SB_LLL
47 #define WL_CHANSPEC_CTL_SB_UPPER WL_CHANSPEC_CTL_SB_LLU
48  
49 #define WL_CHANSPEC_BW_MASK 0x3800
50 #define WL_CHANSPEC_BW_SHIFT 11
51 #define WL_CHANSPEC_BW_5 0x0000
52 #define WL_CHANSPEC_BW_10 0x0800
53 #define WL_CHANSPEC_BW_20 0x1000
54 #define WL_CHANSPEC_BW_40 0x1800
55 #define WL_CHANSPEC_BW_80 0x2000
56 #define WL_CHANSPEC_BW_160 0x2800
57 #define WL_CHANSPEC_BW_8080 0x3000
58  
59 #define WL_CHANSPEC_BAND_MASK 0xc000
60 #define WL_CHANSPEC_BAND_SHIFT 14
61 #define WL_CHANSPEC_BAND_2G 0x0000
62 #define WL_CHANSPEC_BAND_3G 0x4000
63 #define WL_CHANSPEC_BAND_4G 0x8000
64 #define WL_CHANSPEC_BAND_5G 0xc000
65 #define INVCHANSPEC 255
66  
67 /* channel defines */
68 #define LOWER_20_SB(channel) (((channel) > CH_10MHZ_APART) ? \
69 ((channel) - CH_10MHZ_APART) : 0)
70 #define UPPER_20_SB(channel) (((channel) < (MAXCHANNEL - CH_10MHZ_APART)) ? \
71 ((channel) + CH_10MHZ_APART) : 0)
72  
73 #define LL_20_SB(channel) (((channel) > 3 * CH_10MHZ_APART) ? ((channel) - 3 * CH_10MHZ_APART) : 0)
74 #define UU_20_SB(channel) (((channel) < (MAXCHANNEL - 3 * CH_10MHZ_APART)) ? \
75 ((channel) + 3 * CH_10MHZ_APART) : 0)
76 #define LU_20_SB(channel) LOWER_20_SB(channel)
77 #define UL_20_SB(channel) UPPER_20_SB(channel)
78  
79 #define LOWER_40_SB(channel) ((channel) - CH_20MHZ_APART)
80 #define UPPER_40_SB(channel) ((channel) + CH_20MHZ_APART)
81 #define CHSPEC_WLCBANDUNIT(chspec) (CHSPEC_IS5G(chspec) ? BAND_5G_INDEX : BAND_2G_INDEX)
82 #define CH20MHZ_CHSPEC(channel) (chanspec_t)((chanspec_t)(channel) | WL_CHANSPEC_BW_20 | \
83 (((channel) <= CH_MAX_2G_CHANNEL) ? \
84 WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G))
85 #define NEXT_20MHZ_CHAN(channel) (((channel) < (MAXCHANNEL - CH_20MHZ_APART)) ? \
86 ((channel) + CH_20MHZ_APART) : 0)
87 #define CH40MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
88 ((channel) | (ctlsb) | WL_CHANSPEC_BW_40 | \
89 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
90 WL_CHANSPEC_BAND_5G))
91 #define CH80MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
92 ((channel) | (ctlsb) | WL_CHANSPEC_BW_80 | \
93 ((channel) <= CH_MAX_2G_CHANNEL ? WL_CHANSPEC_BAND_2G : \
94 WL_CHANSPEC_BAND_5G))
95 #define CH160MHZ_CHSPEC(channel, ctlsb) (chanspec_t) \
96 ((channel) | (ctlsb) | \
97 WL_CHANSPEC_BW_160 | WL_CHANSPEC_BAND_5G)
98  
99 /* simple MACROs to get different fields of chanspec */
100 #define CHSPEC_CHANNEL(chspec) ((uint8)((chspec) & WL_CHANSPEC_CHAN_MASK))
101 #define CHSPEC_CHAN1(chspec) ((chspec) & WL_CHANSPEC_CHAN1_MASK)
102 #define CHSPEC_CHAN2(chspec) ((chspec) & WL_CHANSPEC_CHAN2_MASK)
103 #define CHSPEC_BAND(chspec) ((chspec) & WL_CHANSPEC_BAND_MASK)
104 #define CHSPEC_CTL_SB(chspec) ((chspec) & WL_CHANSPEC_CTL_SB_MASK)
105 #define CHSPEC_BW(chspec) ((chspec) & WL_CHANSPEC_BW_MASK)
106  
107 #define CHSPEC_IS10(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_10)
108 #define CHSPEC_IS20(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_20)
109 #ifndef CHSPEC_IS40
110 #define CHSPEC_IS40(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40)
111 #endif
112 #ifndef CHSPEC_IS80
113 #define CHSPEC_IS80(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_80)
114 #endif
115 #ifndef CHSPEC_IS160
116 #define CHSPEC_IS160(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_160)
117 #endif
118 #ifndef CHSPEC_IS8080
119 #define CHSPEC_IS8080(chspec) (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_8080)
120 #endif
121  
122 #define CHSPEC_IS5G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_5G)
123 #define CHSPEC_IS2G(chspec) (((chspec) & WL_CHANSPEC_BAND_MASK) == WL_CHANSPEC_BAND_2G)
124 #define CHSPEC_SB_UPPER(chspec) \
125 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_UPPER) && \
126 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
127 #define CHSPEC_SB_LOWER(chspec) \
128 ((((chspec) & WL_CHANSPEC_CTL_SB_MASK) == WL_CHANSPEC_CTL_SB_LOWER) && \
129 (((chspec) & WL_CHANSPEC_BW_MASK) == WL_CHANSPEC_BW_40))
130 #define CHSPEC2WLC_BAND(chspec) (CHSPEC_IS5G(chspec) ? WLC_BAND_5G : WLC_BAND_2G)
131  
132 #endif /* _CHANNELS_H_ */