brcm80211: add endian annotation to packet filter structures
The packet filter structures were byte copied and transferred over the host bus to the device. As such they are little endian and have been annotated accordingly. Reported-by: Johannes Berg <johannes@sipsolutions.net> Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com> Reviewed-by: Roland Vossen <rvossen@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Родитель
df4492f894
Коммит
f7264adb9a
|
@ -330,14 +330,14 @@ enum brcmf_bus_state {
|
||||||
* start matching, the pattern to match, the size of the pattern, and a bitmask
|
* start matching, the pattern to match, the size of the pattern, and a bitmask
|
||||||
* that indicates which bits within the pattern should be matched.
|
* that indicates which bits within the pattern should be matched.
|
||||||
*/
|
*/
|
||||||
struct brcmf_pkt_filter_pattern {
|
struct brcmf_pkt_filter_pattern_le {
|
||||||
/*
|
/*
|
||||||
* Offset within received packet to start pattern matching.
|
* Offset within received packet to start pattern matching.
|
||||||
* Offset '0' is the first byte of the ethernet header.
|
* Offset '0' is the first byte of the ethernet header.
|
||||||
*/
|
*/
|
||||||
u32 offset;
|
__le32 offset;
|
||||||
/* Size of the pattern. Bitmask must be the same size.*/
|
/* Size of the pattern. Bitmask must be the same size.*/
|
||||||
u32 size_bytes;
|
__le32 size_bytes;
|
||||||
/*
|
/*
|
||||||
* Variable length mask and pattern data. mask starts at offset 0.
|
* Variable length mask and pattern data. mask starts at offset 0.
|
||||||
* Pattern immediately follows mask.
|
* Pattern immediately follows mask.
|
||||||
|
@ -346,19 +346,19 @@ struct brcmf_pkt_filter_pattern {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
|
/* IOVAR "pkt_filter_add" parameter. Used to install packet filters. */
|
||||||
struct brcmf_pkt_filter {
|
struct brcmf_pkt_filter_le {
|
||||||
u32 id; /* Unique filter id, specified by app. */
|
__le32 id; /* Unique filter id, specified by app. */
|
||||||
u32 type; /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
|
__le32 type; /* Filter type (WL_PKT_FILTER_TYPE_xxx). */
|
||||||
u32 negate_match; /* Negate the result of filter matches */
|
__le32 negate_match; /* Negate the result of filter matches */
|
||||||
union { /* Filter definitions */
|
union { /* Filter definitions */
|
||||||
struct brcmf_pkt_filter_pattern pattern; /* Filter pattern */
|
struct brcmf_pkt_filter_pattern_le pattern; /* Filter pattern */
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* IOVAR "pkt_filter_enable" parameter. */
|
/* IOVAR "pkt_filter_enable" parameter. */
|
||||||
struct brcmf_pkt_filter_enable {
|
struct brcmf_pkt_filter_enable_le {
|
||||||
u32 id; /* Unique filter id */
|
__le32 id; /* Unique filter id */
|
||||||
u32 enable; /* Enable/disable bool */
|
__le32 enable; /* Enable/disable bool */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* BSS info structure
|
/* BSS info structure
|
||||||
|
|
|
@ -36,9 +36,9 @@ int brcmf_msg_level;
|
||||||
|
|
||||||
#define MSGTRACE_VERSION 1
|
#define MSGTRACE_VERSION 1
|
||||||
|
|
||||||
#define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter, u)
|
#define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter_le, u)
|
||||||
#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \
|
#define BRCMF_PKT_FILTER_PATTERN_FIXED_LEN \
|
||||||
offsetof(struct brcmf_pkt_filter_pattern, mask_and_pattern)
|
offsetof(struct brcmf_pkt_filter_pattern_le, mask_and_pattern)
|
||||||
|
|
||||||
#ifdef BCMDBG
|
#ifdef BCMDBG
|
||||||
static const char brcmf_version[] =
|
static const char brcmf_version[] =
|
||||||
|
@ -558,8 +558,9 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable,
|
||||||
char *arg_save = NULL, *arg_org = NULL;
|
char *arg_save = NULL, *arg_org = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
struct brcmf_pkt_filter_enable enable_parm;
|
struct brcmf_pkt_filter_enable_le enable_parm;
|
||||||
struct brcmf_pkt_filter_enable *pkt_filterp;
|
struct brcmf_pkt_filter_enable_le *pkt_filterp;
|
||||||
|
__le32 mmode_le;
|
||||||
|
|
||||||
arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
|
arg_save = kmalloc(strlen(arg) + 1, GFP_ATOMIC);
|
||||||
if (!arg_save)
|
if (!arg_save)
|
||||||
|
@ -582,15 +583,15 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable,
|
||||||
buf[str_len] = '\0';
|
buf[str_len] = '\0';
|
||||||
buf_len = str_len + 1;
|
buf_len = str_len + 1;
|
||||||
|
|
||||||
pkt_filterp = (struct brcmf_pkt_filter_enable *) (buf + str_len + 1);
|
pkt_filterp = (struct brcmf_pkt_filter_enable_le *) (buf + str_len + 1);
|
||||||
|
|
||||||
/* Parse packet filter id. */
|
/* Parse packet filter id. */
|
||||||
enable_parm.id = 0;
|
enable_parm.id = 0;
|
||||||
if (!kstrtoul(argv[i], 0, &res))
|
if (!kstrtoul(argv[i], 0, &res))
|
||||||
enable_parm.id = (u32)res;
|
enable_parm.id = cpu_to_le32((u32)res);
|
||||||
|
|
||||||
/* Parse enable/disable value. */
|
/* Parse enable/disable value. */
|
||||||
enable_parm.enable = enable;
|
enable_parm.enable = cpu_to_le32(enable);
|
||||||
|
|
||||||
buf_len += sizeof(enable_parm);
|
buf_len += sizeof(enable_parm);
|
||||||
memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm));
|
memcpy((char *)pkt_filterp, &enable_parm, sizeof(enable_parm));
|
||||||
|
@ -605,7 +606,8 @@ brcmf_c_pktfilter_offload_enable(struct brcmf_pub *drvr, char *arg, int enable,
|
||||||
brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg);
|
brcmf_dbg(TRACE, "successfully added pktfilter %s\n", arg);
|
||||||
|
|
||||||
/* Contorl the master mode */
|
/* Contorl the master mode */
|
||||||
brcmu_mkiovar("pkt_filter_mode", (char *)&master_mode, 4, buf,
|
mmode_le = cpu_to_le32(master_mode);
|
||||||
|
brcmu_mkiovar("pkt_filter_mode", (char *)&mmode_le, 4, buf,
|
||||||
sizeof(buf));
|
sizeof(buf));
|
||||||
rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf,
|
rc = brcmf_proto_cdc_set_dcmd(drvr, 0, BRCMF_C_SET_VAR, buf,
|
||||||
sizeof(buf));
|
sizeof(buf));
|
||||||
|
@ -621,8 +623,8 @@ fail:
|
||||||
void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
struct brcmf_pkt_filter pkt_filter;
|
struct brcmf_pkt_filter_le pkt_filter;
|
||||||
struct brcmf_pkt_filter *pkt_filterp;
|
struct brcmf_pkt_filter_le *pkt_filterp;
|
||||||
unsigned long res;
|
unsigned long res;
|
||||||
int buf_len;
|
int buf_len;
|
||||||
int str_len;
|
int str_len;
|
||||||
|
@ -658,12 +660,12 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
str_len = strlen(str);
|
str_len = strlen(str);
|
||||||
buf_len = str_len + 1;
|
buf_len = str_len + 1;
|
||||||
|
|
||||||
pkt_filterp = (struct brcmf_pkt_filter *) (buf + str_len + 1);
|
pkt_filterp = (struct brcmf_pkt_filter_le *) (buf + str_len + 1);
|
||||||
|
|
||||||
/* Parse packet filter id. */
|
/* Parse packet filter id. */
|
||||||
pkt_filter.id = 0;
|
pkt_filter.id = 0;
|
||||||
if (!kstrtoul(argv[i], 0, &res))
|
if (!kstrtoul(argv[i], 0, &res))
|
||||||
pkt_filter.id = (u32)res;
|
pkt_filter.id = cpu_to_le32((u32)res);
|
||||||
|
|
||||||
if (NULL == argv[++i]) {
|
if (NULL == argv[++i]) {
|
||||||
brcmf_dbg(ERROR, "Polarity not provided\n");
|
brcmf_dbg(ERROR, "Polarity not provided\n");
|
||||||
|
@ -673,7 +675,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
/* Parse filter polarity. */
|
/* Parse filter polarity. */
|
||||||
pkt_filter.negate_match = 0;
|
pkt_filter.negate_match = 0;
|
||||||
if (!kstrtoul(argv[i], 0, &res))
|
if (!kstrtoul(argv[i], 0, &res))
|
||||||
pkt_filter.negate_match = (u32)res;
|
pkt_filter.negate_match = cpu_to_le32((u32)res);
|
||||||
|
|
||||||
if (NULL == argv[++i]) {
|
if (NULL == argv[++i]) {
|
||||||
brcmf_dbg(ERROR, "Filter type not provided\n");
|
brcmf_dbg(ERROR, "Filter type not provided\n");
|
||||||
|
@ -683,7 +685,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
/* Parse filter type. */
|
/* Parse filter type. */
|
||||||
pkt_filter.type = 0;
|
pkt_filter.type = 0;
|
||||||
if (!kstrtoul(argv[i], 0, &res))
|
if (!kstrtoul(argv[i], 0, &res))
|
||||||
pkt_filter.type = (u32)res;
|
pkt_filter.type = cpu_to_le32((u32)res);
|
||||||
|
|
||||||
if (NULL == argv[++i]) {
|
if (NULL == argv[++i]) {
|
||||||
brcmf_dbg(ERROR, "Offset not provided\n");
|
brcmf_dbg(ERROR, "Offset not provided\n");
|
||||||
|
@ -693,7 +695,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
/* Parse pattern filter offset. */
|
/* Parse pattern filter offset. */
|
||||||
pkt_filter.u.pattern.offset = 0;
|
pkt_filter.u.pattern.offset = 0;
|
||||||
if (!kstrtoul(argv[i], 0, &res))
|
if (!kstrtoul(argv[i], 0, &res))
|
||||||
pkt_filter.u.pattern.offset = (u32)res;
|
pkt_filter.u.pattern.offset = cpu_to_le32((u32)res);
|
||||||
|
|
||||||
if (NULL == argv[++i]) {
|
if (NULL == argv[++i]) {
|
||||||
brcmf_dbg(ERROR, "Bitmask not provided\n");
|
brcmf_dbg(ERROR, "Bitmask not provided\n");
|
||||||
|
@ -721,7 +723,7 @@ void brcmf_c_pktfilter_offload_set(struct brcmf_pub *drvr, char *arg)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt_filter.u.pattern.size_bytes = mask_size;
|
pkt_filter.u.pattern.size_bytes = cpu_to_le32(mask_size);
|
||||||
buf_len += BRCMF_PKT_FILTER_FIXED_LEN;
|
buf_len += BRCMF_PKT_FILTER_FIXED_LEN;
|
||||||
buf_len += (BRCMF_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size);
|
buf_len += (BRCMF_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче