1 // SPDX-License-Identifier: ISC
2 /*
3 * Copyright (c) 2012 Broadcom Corporation
4 */
5
6 #ifndef _fwil_h_
7 #define _fwil_h_
8
9 /*******************************************************************************
10 * Dongle command codes that are interpreted by firmware
11 ******************************************************************************/
12 #define BRCMF_C_GET_VERSION 1
13 #define BRCMF_C_UP 2
14 #define BRCMF_C_DOWN 3
15 #define BRCMF_C_SET_PROMISC 10
16 #define BRCMF_C_GET_RATE 12
17 #define BRCMF_C_GET_INFRA 19
18 #define BRCMF_C_SET_INFRA 20
19 #define BRCMF_C_GET_AUTH 21
20 #define BRCMF_C_SET_AUTH 22
21 #define BRCMF_C_GET_BSSID 23
22 #define BRCMF_C_GET_SSID 25
23 #define BRCMF_C_SET_SSID 26
24 #define BRCMF_C_TERMINATED 28
25 #define BRCMF_C_GET_CHANNEL 29
26 #define BRCMF_C_SET_CHANNEL 30
27 #define BRCMF_C_GET_SRL 31
28 #define BRCMF_C_SET_SRL 32
29 #define BRCMF_C_GET_LRL 33
30 #define BRCMF_C_SET_LRL 34
31 #define BRCMF_C_GET_RADIO 37
32 #define BRCMF_C_SET_RADIO 38
33 #define BRCMF_C_GET_PHYTYPE 39
34 #define BRCMF_C_SET_KEY 45
35 #define BRCMF_C_GET_REGULATORY 46
36 #define BRCMF_C_SET_REGULATORY 47
37 #define BRCMF_C_SET_PASSIVE_SCAN 49
38 #define BRCMF_C_SCAN 50
39 #define BRCMF_C_SCAN_RESULTS 51
40 #define BRCMF_C_DISASSOC 52
41 #define BRCMF_C_REASSOC 53
42 #define BRCMF_C_SET_ROAM_TRIGGER 55
43 #define BRCMF_C_SET_ROAM_DELTA 57
44 #define BRCMF_C_GET_BCNPRD 75
45 #define BRCMF_C_SET_BCNPRD 76
46 #define BRCMF_C_GET_DTIMPRD 77
47 #define BRCMF_C_SET_DTIMPRD 78
48 #define BRCMF_C_SET_COUNTRY 84
49 #define BRCMF_C_GET_PM 85
50 #define BRCMF_C_SET_PM 86
51 #define BRCMF_C_GET_REVINFO 98
52 #define BRCMF_C_GET_MONITOR 107
53 #define BRCMF_C_SET_MONITOR 108
54 #define BRCMF_C_GET_CURR_RATESET 114
55 #define BRCMF_C_GET_AP 117
56 #define BRCMF_C_SET_AP 118
57 #define BRCMF_C_SET_SCB_AUTHORIZE 121
58 #define BRCMF_C_SET_SCB_DEAUTHORIZE 122
59 #define BRCMF_C_GET_RSSI 127
60 #define BRCMF_C_GET_WSEC 133
61 #define BRCMF_C_SET_WSEC 134
62 #define BRCMF_C_GET_PHY_NOISE 135
63 #define BRCMF_C_GET_BSS_INFO 136
64 #define BRCMF_C_GET_GET_PKTCNTS 137
65 #define BRCMF_C_GET_BANDLIST 140
66 #define BRCMF_C_SET_SCB_TIMEOUT 158
67 #define BRCMF_C_GET_ASSOCLIST 159
68 #define BRCMF_C_GET_PHYLIST 180
69 #define BRCMF_C_SET_SCAN_CHANNEL_TIME 185
70 #define BRCMF_C_SET_SCAN_UNASSOC_TIME 187
71 #define BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON 201
72 #define BRCMF_C_SET_ASSOC_PREFER 205
73 #define BRCMF_C_GET_VALID_CHANNELS 217
74 #define BRCMF_C_SET_FAKEFRAG 219
75 #define BRCMF_C_GET_KEY_PRIMARY 235
76 #define BRCMF_C_SET_KEY_PRIMARY 236
77 #define BRCMF_C_SET_SCAN_PASSIVE_TIME 258
78 #define BRCMF_C_GET_VAR 262
79 #define BRCMF_C_SET_VAR 263
80 #define BRCMF_C_SET_WSEC_PMK 268
81
82 s32 brcmf_fil_cmd_data_set(struct brcmf_if *ifp, u32 cmd, void *data, u32 len);
83 s32 brcmf_fil_cmd_data_get(struct brcmf_if *ifp, u32 cmd, void *data, u32 len);
84 static inline
brcmf_fil_cmd_int_set(struct brcmf_if * ifp,u32 cmd,u32 data)85 s32 brcmf_fil_cmd_int_set(struct brcmf_if *ifp, u32 cmd, u32 data)
86 {
87 s32 err;
88 __le32 data_le = cpu_to_le32(data);
89
90 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, value=%d\n", ifp->ifidx, cmd, data);
91 err = brcmf_fil_cmd_data_set(ifp, cmd, &data_le, sizeof(data_le));
92
93 return err;
94 }
95 static inline
brcmf_fil_cmd_int_get(struct brcmf_if * ifp,u32 cmd,u32 * data)96 s32 brcmf_fil_cmd_int_get(struct brcmf_if *ifp, u32 cmd, u32 *data)
97 {
98 s32 err;
99
100 err = brcmf_fil_cmd_data_get(ifp, cmd, data, sizeof(*data));
101 if (err == 0)
102 *data = le32_to_cpu(*(__le32 *)data);
103 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, value=%d\n", ifp->ifidx, cmd, *data);
104
105 return err;
106 }
107 static inline
brcmf_fil_cmd_int_query(struct brcmf_if * ifp,u32 cmd,u32 * data)108 s32 brcmf_fil_cmd_int_query(struct brcmf_if *ifp, u32 cmd, u32 *data)
109 {
110 __le32 *data_le = (__le32 *)data;
111
112 *data_le = cpu_to_le32(*data);
113 return brcmf_fil_cmd_int_get(ifp, cmd, data);
114 }
115
116 s32 brcmf_fil_iovar_data_set(struct brcmf_if *ifp, const char *name,
117 const void *data, u32 len);
118 s32 brcmf_fil_iovar_data_get(struct brcmf_if *ifp, const char *name, void *data,
119 u32 len);
120 static inline
brcmf_fil_iovar_int_set(struct brcmf_if * ifp,const char * name,u32 data)121 s32 brcmf_fil_iovar_int_set(struct brcmf_if *ifp, const char *name, u32 data)
122 {
123 __le32 data_le = cpu_to_le32(data);
124
125 return brcmf_fil_iovar_data_set(ifp, name, &data_le, sizeof(data_le));
126 }
127 static inline
brcmf_fil_iovar_int_get(struct brcmf_if * ifp,const char * name,u32 * data)128 s32 brcmf_fil_iovar_int_get(struct brcmf_if *ifp, const char *name, u32 *data)
129 {
130 s32 err;
131
132 err = brcmf_fil_iovar_data_get(ifp, name, data, sizeof(*data));
133 if (err == 0)
134 *data = le32_to_cpu(*(__le32 *)data);
135 return err;
136 }
137 static inline
brcmf_fil_iovar_int_query(struct brcmf_if * ifp,const char * name,u32 * data)138 s32 brcmf_fil_iovar_int_query(struct brcmf_if *ifp, const char *name, u32 *data)
139 {
140 __le32 *data_le = (__le32 *)data;
141
142 *data_le = cpu_to_le32(*data);
143 return brcmf_fil_iovar_int_get(ifp, name, data);
144 }
145
146
147 s32 brcmf_fil_bsscfg_data_set(struct brcmf_if *ifp, const char *name,
148 void *data, u32 len);
149 s32 brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, const char *name,
150 void *data, u32 len);
151 static inline
brcmf_fil_bsscfg_int_set(struct brcmf_if * ifp,const char * name,u32 data)152 s32 brcmf_fil_bsscfg_int_set(struct brcmf_if *ifp, const char *name, u32 data)
153 {
154 __le32 data_le = cpu_to_le32(data);
155
156 return brcmf_fil_bsscfg_data_set(ifp, name, &data_le,
157 sizeof(data_le));
158 }
159 static inline
brcmf_fil_bsscfg_int_get(struct brcmf_if * ifp,const char * name,u32 * data)160 s32 brcmf_fil_bsscfg_int_get(struct brcmf_if *ifp, const char *name, u32 *data)
161 {
162 s32 err;
163
164 err = brcmf_fil_bsscfg_data_get(ifp, name, data, sizeof(*data));
165 if (err == 0)
166 *data = le32_to_cpu(*(__le32 *)data);
167 return err;
168 }
169 static inline
brcmf_fil_bsscfg_int_query(struct brcmf_if * ifp,const char * name,u32 * data)170 s32 brcmf_fil_bsscfg_int_query(struct brcmf_if *ifp, const char *name, u32 *data)
171 {
172 __le32 *data_le = (__le32 *)data;
173
174 *data_le = cpu_to_le32(*data);
175 return brcmf_fil_bsscfg_int_get(ifp, name, data);
176 }
177
178 s32 brcmf_fil_xtlv_data_set(struct brcmf_if *ifp, const char *name, u16 id,
179 void *data, u32 len);
180 s32 brcmf_fil_xtlv_data_get(struct brcmf_if *ifp, const char *name, u16 id,
181 void *data, u32 len);
182 static inline
brcmf_fil_xtlv_int_set(struct brcmf_if * ifp,const char * name,u16 id,u32 data)183 s32 brcmf_fil_xtlv_int_set(struct brcmf_if *ifp, const char *name, u16 id,
184 u32 data)
185 {
186 __le32 data_le = cpu_to_le32(data);
187
188 return brcmf_fil_xtlv_data_set(ifp, name, id, &data_le,
189 sizeof(data_le));
190 }
191 static inline
brcmf_fil_xtlv_int_get(struct brcmf_if * ifp,const char * name,u16 id,u32 * data)192 s32 brcmf_fil_xtlv_int_get(struct brcmf_if *ifp, const char *name, u16 id,
193 u32 *data)
194 {
195 __le32 data_le = cpu_to_le32(*data);
196 s32 err;
197
198 err = brcmf_fil_xtlv_data_get(ifp, name, id, &data_le, sizeof(data_le));
199 if (err == 0)
200 *data = le32_to_cpu(data_le);
201 return err;
202 }
203 static inline
brcmf_fil_xtlv_int8_get(struct brcmf_if * ifp,const char * name,u16 id,u8 * data)204 s32 brcmf_fil_xtlv_int8_get(struct brcmf_if *ifp, const char *name, u16 id,
205 u8 *data)
206 {
207 return brcmf_fil_xtlv_data_get(ifp, name, id, data, sizeof(*data));
208 }
209 static inline
brcmf_fil_xtlv_int16_get(struct brcmf_if * ifp,const char * name,u16 id,u16 * data)210 s32 brcmf_fil_xtlv_int16_get(struct brcmf_if *ifp, const char *name, u16 id,
211 u16 *data)
212 {
213 __le16 data_le = cpu_to_le16(*data);
214 s32 err;
215
216 err = brcmf_fil_xtlv_data_get(ifp, name, id, &data_le, sizeof(data_le));
217 if (err == 0)
218 *data = le16_to_cpu(data_le);
219 return err;
220 }
221
222 #endif /* _fwil_h_ */
223