fwil.c (4f2c0a4acffbec01079c28f839422e64ddeff004) fwil.c (31343230abb1683e8afb254e6b13a7a7fd01fcac)
1// SPDX-License-Identifier: ISC
2/*
3 * Copyright (c) 2012 Broadcom Corporation
4 */
5
6/* FWIL is the Firmware Interface Layer. In this module the support functions
7 * are located to set and get variables to and from the firmware.
8 */

--- 128 unchanged lines hidden (view full) ---

137 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
138 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
139
140 err = brcmf_fil_cmd_data(ifp, cmd, data, len, true);
141 mutex_unlock(&ifp->drvr->proto_block);
142
143 return err;
144}
1// SPDX-License-Identifier: ISC
2/*
3 * Copyright (c) 2012 Broadcom Corporation
4 */
5
6/* FWIL is the Firmware Interface Layer. In this module the support functions
7 * are located to set and get variables to and from the firmware.
8 */

--- 128 unchanged lines hidden (view full) ---

137 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
138 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
139
140 err = brcmf_fil_cmd_data(ifp, cmd, data, len, true);
141 mutex_unlock(&ifp->drvr->proto_block);
142
143 return err;
144}
145BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_cmd_data_set);
145
146s32
147brcmf_fil_cmd_data_get(struct brcmf_if *ifp, u32 cmd, void *data, u32 len)
148{
149 s32 err;
150
151 mutex_lock(&ifp->drvr->proto_block);
152 err = brcmf_fil_cmd_data(ifp, cmd, data, len, false);
153
154 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, len=%d, err=%d\n", ifp->ifidx, cmd,
155 len, err);
156 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
157 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
158
159 mutex_unlock(&ifp->drvr->proto_block);
160
161 return err;
162}
146
147s32
148brcmf_fil_cmd_data_get(struct brcmf_if *ifp, u32 cmd, void *data, u32 len)
149{
150 s32 err;
151
152 mutex_lock(&ifp->drvr->proto_block);
153 err = brcmf_fil_cmd_data(ifp, cmd, data, len, false);
154
155 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, len=%d, err=%d\n", ifp->ifidx, cmd,
156 len, err);
157 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
158 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
159
160 mutex_unlock(&ifp->drvr->proto_block);
161
162 return err;
163}
164BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_cmd_data_get);
163
165
164
165s32
166brcmf_fil_cmd_int_set(struct brcmf_if *ifp, u32 cmd, u32 data)
167{
168 s32 err;
169 __le32 data_le = cpu_to_le32(data);
170
171 mutex_lock(&ifp->drvr->proto_block);
172 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, value=%d\n", ifp->ifidx, cmd, data);
173 err = brcmf_fil_cmd_data(ifp, cmd, &data_le, sizeof(data_le), true);
174 mutex_unlock(&ifp->drvr->proto_block);
175
176 return err;
177}
178
179s32
180brcmf_fil_cmd_int_get(struct brcmf_if *ifp, u32 cmd, u32 *data)
181{
182 s32 err;
183 __le32 data_le = cpu_to_le32(*data);
184
185 mutex_lock(&ifp->drvr->proto_block);
186 err = brcmf_fil_cmd_data(ifp, cmd, &data_le, sizeof(data_le), false);
187 mutex_unlock(&ifp->drvr->proto_block);
188 *data = le32_to_cpu(data_le);
189 brcmf_dbg(FIL, "ifidx=%d, cmd=%d, value=%d\n", ifp->ifidx, cmd, *data);
190
191 return err;
192}
193
194static u32
195brcmf_create_iovar(const char *name, const char *data, u32 datalen,
196 char *buf, u32 buflen)
197{
198 u32 len;
199
200 len = strlen(name) + 1;
201

--- 63 unchanged lines hidden (view full) ---

265 brcmf_dbg(FIL, "ifidx=%d, name=%s, len=%d, err=%d\n", ifp->ifidx, name,
266 len, err);
267 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
268 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
269
270 mutex_unlock(&drvr->proto_block);
271 return err;
272}
166static u32
167brcmf_create_iovar(const char *name, const char *data, u32 datalen,
168 char *buf, u32 buflen)
169{
170 u32 len;
171
172 len = strlen(name) + 1;
173

--- 63 unchanged lines hidden (view full) ---

237 brcmf_dbg(FIL, "ifidx=%d, name=%s, len=%d, err=%d\n", ifp->ifidx, name,
238 len, err);
239 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
240 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
241
242 mutex_unlock(&drvr->proto_block);
243 return err;
244}
245BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_iovar_data_get);
273
246
274s32
275brcmf_fil_iovar_int_set(struct brcmf_if *ifp, const char *name, u32 data)
276{
277 __le32 data_le = cpu_to_le32(data);
278
279 return brcmf_fil_iovar_data_set(ifp, name, &data_le, sizeof(data_le));
280}
281
282s32
283brcmf_fil_iovar_int_get(struct brcmf_if *ifp, const char *name, u32 *data)
284{
285 __le32 data_le = cpu_to_le32(*data);
286 s32 err;
287
288 err = brcmf_fil_iovar_data_get(ifp, name, &data_le, sizeof(data_le));
289 if (err == 0)
290 *data = le32_to_cpu(data_le);
291 return err;
292}
293
294static u32
295brcmf_create_bsscfg(s32 bsscfgidx, const char *name, char *data, u32 datalen,
296 char *buf, u32 buflen)
297{
298 const s8 *prefix = "bsscfg:";
299 s8 *p;
300 u32 prefixlen;
301 u32 namelen;

--- 57 unchanged lines hidden (view full) ---

359 } else {
360 err = -EPERM;
361 bphy_err(drvr, "Creating bsscfg failed\n");
362 }
363
364 mutex_unlock(&drvr->proto_block);
365 return err;
366}
247static u32
248brcmf_create_bsscfg(s32 bsscfgidx, const char *name, char *data, u32 datalen,
249 char *buf, u32 buflen)
250{
251 const s8 *prefix = "bsscfg:";
252 s8 *p;
253 u32 prefixlen;
254 u32 namelen;

--- 57 unchanged lines hidden (view full) ---

312 } else {
313 err = -EPERM;
314 bphy_err(drvr, "Creating bsscfg failed\n");
315 }
316
317 mutex_unlock(&drvr->proto_block);
318 return err;
319}
320BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_bsscfg_data_set);
367
368s32
369brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, const char *name,
370 void *data, u32 len)
371{
372 struct brcmf_pub *drvr = ifp->drvr;
373 s32 err;
374 u32 buflen;

--- 14 unchanged lines hidden (view full) ---

389 brcmf_dbg(FIL, "ifidx=%d, bsscfgidx=%d, name=%s, len=%d, err=%d\n",
390 ifp->ifidx, ifp->bsscfgidx, name, len, err);
391 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
392 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
393
394 mutex_unlock(&drvr->proto_block);
395 return err;
396}
321
322s32
323brcmf_fil_bsscfg_data_get(struct brcmf_if *ifp, const char *name,
324 void *data, u32 len)
325{
326 struct brcmf_pub *drvr = ifp->drvr;
327 s32 err;
328 u32 buflen;

--- 14 unchanged lines hidden (view full) ---

343 brcmf_dbg(FIL, "ifidx=%d, bsscfgidx=%d, name=%s, len=%d, err=%d\n",
344 ifp->ifidx, ifp->bsscfgidx, name, len, err);
345 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
346 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
347
348 mutex_unlock(&drvr->proto_block);
349 return err;
350}
351BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_bsscfg_data_get);
397
352
398s32
399brcmf_fil_bsscfg_int_set(struct brcmf_if *ifp, const char *name, u32 data)
400{
401 __le32 data_le = cpu_to_le32(data);
402
403 return brcmf_fil_bsscfg_data_set(ifp, name, &data_le,
404 sizeof(data_le));
405}
406
407s32
408brcmf_fil_bsscfg_int_get(struct brcmf_if *ifp, const char *name, u32 *data)
409{
410 __le32 data_le = cpu_to_le32(*data);
411 s32 err;
412
413 err = brcmf_fil_bsscfg_data_get(ifp, name, &data_le,
414 sizeof(data_le));
415 if (err == 0)
416 *data = le32_to_cpu(data_le);
417 return err;
418}
419
420static u32 brcmf_create_xtlv(const char *name, u16 id, char *data, u32 len,
421 char *buf, u32 buflen)
422{
423 u32 iolen;
424 u32 nmlen;
425
426 nmlen = strlen(name) + 1;
427 iolen = nmlen + brcmf_xtlv_data_size(len, BRCMF_XTLV_OPTION_ALIGN32);

--- 32 unchanged lines hidden (view full) ---

460 } else {
461 err = -EPERM;
462 bphy_err(drvr, "Creating xtlv failed\n");
463 }
464
465 mutex_unlock(&drvr->proto_block);
466 return err;
467}
353static u32 brcmf_create_xtlv(const char *name, u16 id, char *data, u32 len,
354 char *buf, u32 buflen)
355{
356 u32 iolen;
357 u32 nmlen;
358
359 nmlen = strlen(name) + 1;
360 iolen = nmlen + brcmf_xtlv_data_size(len, BRCMF_XTLV_OPTION_ALIGN32);

--- 32 unchanged lines hidden (view full) ---

393 } else {
394 err = -EPERM;
395 bphy_err(drvr, "Creating xtlv failed\n");
396 }
397
398 mutex_unlock(&drvr->proto_block);
399 return err;
400}
401BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_xtlv_data_set);
468
469s32 brcmf_fil_xtlv_data_get(struct brcmf_if *ifp, const char *name, u16 id,
470 void *data, u32 len)
471{
472 struct brcmf_pub *drvr = ifp->drvr;
473 s32 err;
474 u32 buflen;
475

--- 13 unchanged lines hidden (view full) ---

489 brcmf_dbg(FIL, "ifidx=%d, name=%s, id=%u, len=%u, err=%d\n",
490 ifp->ifidx, name, id, len, err);
491 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
492 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
493
494 mutex_unlock(&drvr->proto_block);
495 return err;
496}
402
403s32 brcmf_fil_xtlv_data_get(struct brcmf_if *ifp, const char *name, u16 id,
404 void *data, u32 len)
405{
406 struct brcmf_pub *drvr = ifp->drvr;
407 s32 err;
408 u32 buflen;
409

--- 13 unchanged lines hidden (view full) ---

423 brcmf_dbg(FIL, "ifidx=%d, name=%s, id=%u, len=%u, err=%d\n",
424 ifp->ifidx, name, id, len, err);
425 brcmf_dbg_hex_dump(BRCMF_FIL_ON(), data,
426 min_t(uint, len, MAX_HEX_DUMP_LEN), "data\n");
427
428 mutex_unlock(&drvr->proto_block);
429 return err;
430}
497
498s32 brcmf_fil_xtlv_int_set(struct brcmf_if *ifp, const char *name, u16 id, u32 data)
499{
500 __le32 data_le = cpu_to_le32(data);
501
502 return brcmf_fil_xtlv_data_set(ifp, name, id, &data_le,
503 sizeof(data_le));
504}
505
506s32 brcmf_fil_xtlv_int_get(struct brcmf_if *ifp, const char *name, u16 id, u32 *data)
507{
508 __le32 data_le = cpu_to_le32(*data);
509 s32 err;
510
511 err = brcmf_fil_xtlv_data_get(ifp, name, id, &data_le, sizeof(data_le));
512 if (err == 0)
513 *data = le32_to_cpu(data_le);
514 return err;
515}
516
517s32 brcmf_fil_xtlv_int8_get(struct brcmf_if *ifp, const char *name, u16 id, u8 *data)
518{
519 return brcmf_fil_xtlv_data_get(ifp, name, id, data, sizeof(*data));
520}
521
522s32 brcmf_fil_xtlv_int16_get(struct brcmf_if *ifp, const char *name, u16 id, u16 *data)
523{
524 __le16 data_le = cpu_to_le16(*data);
525 s32 err;
526
527 err = brcmf_fil_xtlv_data_get(ifp, name, id, &data_le, sizeof(data_le));
528 if (err == 0)
529 *data = le16_to_cpu(data_le);
530 return err;
531}
532
431BRCMF_EXPORT_SYMBOL_GPL(brcmf_fil_xtlv_data_get);