17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19 #include <linux/kernel.h>
20 #include <linux/string.h>
21 #include <linux/sched.h>
22 #include <linux/netdevice.h>
23 #include <asm/unaligned.h>
32 #define BRCM_OUI "\x00\x10\x18"
33 #define DOT11_OUI_LEN 3
34 #define BCMILCP_BCM_SUBTYPE_EVENT 1
35 #define PKTFILTER_BUF_SIZE 2048
36 #define BRCMF_ARPOL_MODE 0xb
38 #define MSGTRACE_VERSION 1
40 #define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter_le, u)
41 #define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \
42 offsetof(struct brcmf_pkt_filter_pattern_le, mask_and_pattern)
45 static const char brcmf_version[] =
47 __DATE__
" at " __TIME__;
49 static const char brcmf_version[] =
77 if ((len + datalen) > buflen)
83 if (data && datalen) {
84 memcpy(&buf[len], data, datalen);
107 iolen = prefixlen + namelen +
sizeof(bssidx_le) + datalen;
117 memcpy(p, prefix, prefixlen);
126 memcpy(p, &bssidx_le,
sizeof(bssidx_le));
127 p +=
sizeof(bssidx_le);
149 if (!pktq_pfull(q, prec) && !pktq_full(q)) {
155 if (pktq_pfull(q, prec))
157 else if (pktq_full(q)) {
166 discard_oldest = ac_bitmap_tst(drvr->
wme_dp, eprec);
167 if (eprec == prec && !discard_oldest)
192 bool group =
false, flush_txq =
false,
link =
false;
193 char *auth_str, *event_name;
260 static u32 seqnum_prev;
274 event_name =
"UNKNOWN";
275 for (i = 0; i <
ARRAY_SIZE(event_names); i++) {
276 if (event_names[i].event == event_type)
277 event_name = event_names[
i].event_name;
280 brcmf_dbg(
EVENT,
"EVENT: %s, event ID = %d\n", event_name, event_type);
281 brcmf_dbg(
EVENT,
"flags 0x%04x, status %d, reason %d, auth_type %d MAC %s\n",
282 flags, status, reason, auth_type, eabuf);
291 switch (event_type) {
313 event_name, eabuf, (
int)reason);
316 event_name, eabuf, (
int)status);
322 event_name, eabuf, (
int)reason);
328 auth_str =
"Open System";
330 auth_str =
"Shared Key";
332 sprintf(err_msg,
"AUTH unknown: %d", (
int)auth_type);
337 event_name, eabuf, auth_str);
340 event_name, eabuf, auth_str);
343 event_name, eabuf, auth_str);
345 brcmf_dbg(
EVENT,
"MACEVENT: %s, MAC %s, %s, FAILURE, reason %d\n",
346 event_name, eabuf, auth_str, (
int)reason);
364 event_name, (
int)status);
379 event_name,
link ?
"UP" :
"DOWN");
384 event_name, eabuf, group, flush_txq);
416 event_name, (
int)status, (
int)reason);
420 buf = (
unsigned char *) event_data;
425 "MACEVENT: %s [unsupported version --> brcmf"
426 " version:%d dongle version:%d]\n",
440 "WLC_E_TRACE: [Discarded traces in dongle -->"
441 " discarded_bytes %d discarded_printf %d]\n",
475 "MACEVENT: %s %d, MAC %s, status %d, reason %d, "
476 "auth %d\n", event_name, event_type, eabuf,
477 (
int)status, (
int)reason, (
int)auth_type);
504 if (get_unaligned_be16(&pvt_data->
hdr.usr_subtype) !=
510 *data_ptr = &pvt_data[1];
511 event_data = *data_ptr;
517 flags = get_unaligned_be16(&event->
flags);
531 pvt_data->
eth.h_dest);
554 type, flags, status);
566 memcpy((
void *)(&pvt_data->
msg.event_type), &temp2,
567 sizeof(pvt_data->
msg.event_type));
574 brcmf_c_show_host_event(event, event_data);
581 static int brcmf_c_pattern_atoh(
char *
src,
char *
dst)
585 brcmf_dbg(
ERROR,
"Mask invalid format. Needs to start with 0x\n");
589 if (
strlen(src) % 2 != 0) {
593 for (i = 0; *src !=
'\0'; i++) {
598 if (kstrtoul(num, 16, &res))
616 char *arg_save =
NULL, *arg_org =
NULL;
630 argv[
i] =
strsep(&arg_save,
" ");
633 if (
NULL == argv[i]) {
638 str =
"pkt_filter_enable";
642 buf_len = str_len + 1;
648 if (!kstrtoul(argv[i], 0, &res))
654 buf_len +=
sizeof(enable_parm);
655 memcpy((
char *)pkt_filterp, &enable_parm,
sizeof(enable_parm));
659 rc = rc >= 0 ? 0 :
rc;
672 rc = rc >= 0 ? 0 :
rc;
692 char *argv[8], *buf =
NULL;
694 char *arg_save =
NULL, *arg_org =
NULL;
706 argv[
i] =
strsep(&arg_save,
" ");
708 argv[
i] =
strsep(&arg_save,
" ");
711 if (
NULL == argv[i]) {
716 str =
"pkt_filter_add";
719 buf_len = str_len + 1;
725 if (!kstrtoul(argv[i], 0, &res))
728 if (
NULL == argv[++i]) {
735 if (!kstrtoul(argv[i], 0, &res))
738 if (
NULL == argv[++i]) {
745 if (!kstrtoul(argv[i], 0, &res))
748 if (
NULL == argv[++i]) {
755 if (!kstrtoul(argv[i], 0, &res))
758 if (
NULL == argv[++i]) {
766 (argv[i], (
char *)pkt_filterp->
u.
pattern.mask_and_pattern);
768 if (
NULL == argv[++i]) {
775 brcmf_c_pattern_atoh(argv[i],
777 mask_and_pattern[mask_size]);
779 if (mask_size != pattern_size) {
793 memcpy((
char *)pkt_filterp,
798 rc = rc >= 0 ? 0 :
rc;
812 static void brcmf_c_arp_offload_set(
struct brcmf_pub *drvr,
int arp_mode)
822 iovbuf,
sizeof(iovbuf));
823 retcode = retcode >= 0 ? 0 :
retcode;
825 brcmf_dbg(
TRACE,
"failed to set ARP offload mode to 0x%x, retcode = %d\n",
832 static void brcmf_c_arp_offload_enable(
struct brcmf_pub *drvr,
int arp_enable)
841 iovbuf,
sizeof(iovbuf));
843 iovbuf,
sizeof(iovbuf));
844 retcode = retcode >= 0 ? 0 :
retcode;
846 brcmf_dbg(
TRACE,
"failed to enable ARP offload to %d, retcode = %d\n",
847 arp_enable, retcode);
877 memset(buf, 0,
sizeof(buf));
895 iovbuf,
sizeof(iovbuf));
901 iovbuf,
sizeof(iovbuf));
906 (
char *)&scan_assoc_time_le,
sizeof(scan_assoc_time_le));
908 (
char *)&scan_unassoc_time_le,
sizeof(scan_unassoc_time_le));
912 brcmf_c_arp_offload_enable(drvr,
true);
929 iovbuf,
sizeof(iovbuf));