Commit 1cde7f68 authored by David Vrabel's avatar David Vrabel

uwb: order IEs by element ID

ECMA-368 requires that IEs in a beacon must be sorted by element ID.  Most
hardware uses the ordering in the Set IE URC command so get the ordering
right on the host.

Also refactor the IE management code:
  - use uwb_ie_next() instead of uwb_ie_for_each().
  - remove unnecessary functions.
  - API is now only uwb_rc_ie_add() and uwb_rc_ie_rm().
Signed-off-by: default avatarDavid Vrabel <david.vrabel@csr.com>
parent 4d2bea4c
......@@ -349,22 +349,22 @@ ssize_t uwb_bce_print_IEs(struct uwb_dev *uwb_dev, struct uwb_beca_e *bce,
ssize_t result = 0;
struct uwb_rc_evt_beacon *be;
struct uwb_beacon_frame *bf;
struct uwb_buf_ctx ctx = {
.buf = buf,
.bytes = 0,
.size = size
};
int ies_len;
struct uwb_ie_hdr *ies;
mutex_lock(&bce->mutex);
be = bce->be;
if (be == NULL)
goto out;
bf = (void *) be->BeaconInfo;
uwb_ie_for_each(uwb_dev, uwb_ie_dump_hex, &ctx,
bf->IEData, be->wBeaconInfoLength - sizeof(*bf));
result = ctx.bytes;
out:
if (be) {
bf = (struct uwb_beacon_frame *)bce->be->BeaconInfo;
ies_len = be->wBeaconInfoLength - sizeof(struct uwb_beacon_frame);
ies = (struct uwb_ie_hdr *)bf->IEData;
result = uwb_ie_dump_hex(ies, ies_len, buf, size);
}
mutex_unlock(&bce->mutex);
return result;
}
......
This diff is collapsed.
......@@ -468,28 +468,3 @@ void uwb_rc_put(struct uwb_rc *rc)
__uwb_rc_put(rc);
}
EXPORT_SYMBOL_GPL(uwb_rc_put);
/*
*
*
*/
ssize_t uwb_rc_print_IEs(struct uwb_rc *uwb_rc, char *buf, size_t size)
{
ssize_t result;
struct uwb_rc_evt_get_ie *ie_info;
struct uwb_buf_ctx ctx;
result = uwb_rc_get_ie(uwb_rc, &ie_info);
if (result < 0)
goto error_get_ie;
ctx.buf = buf;
ctx.size = size;
ctx.bytes = 0;
uwb_ie_for_each(&uwb_rc->uwb_dev, uwb_ie_dump_hex, &ctx,
ie_info->IEData, result - sizeof(*ie_info));
result = ctx.bytes;
kfree(ie_info);
error_get_ie:
return result;
}
......@@ -66,14 +66,14 @@ extern int uwb_rc_scan(struct uwb_rc *rc,
unsigned channel, enum uwb_scan_type type,
unsigned bpst_offset);
extern int uwb_rc_send_all_drp_ie(struct uwb_rc *rc);
extern ssize_t uwb_rc_print_IEs(struct uwb_rc *rc, char *, size_t);
extern void uwb_rc_ie_init(struct uwb_rc *);
extern void uwb_rc_ie_init(struct uwb_rc *);
extern ssize_t uwb_rc_ie_setup(struct uwb_rc *);
extern void uwb_rc_ie_release(struct uwb_rc *);
extern int uwb_rc_ie_add(struct uwb_rc *,
const struct uwb_ie_hdr *, size_t);
extern int uwb_rc_ie_rm(struct uwb_rc *, enum uwb_ie);
void uwb_rc_ie_init(struct uwb_rc *);
int uwb_rc_ie_setup(struct uwb_rc *);
void uwb_rc_ie_release(struct uwb_rc *);
int uwb_ie_dump_hex(const struct uwb_ie_hdr *ies, size_t len,
char *buf, size_t size);
int uwb_rc_set_ie(struct uwb_rc *, struct uwb_rc_cmd_set_ie *);
extern const char *uwb_rc_strerror(unsigned code);
......
......@@ -42,10 +42,6 @@ enum wlp_wss_connect {
extern struct kobj_type wss_ktype;
extern struct attribute_group wss_attr_group;
extern int uwb_rc_ie_add(struct uwb_rc *, const struct uwb_ie_hdr *, size_t);
extern int uwb_rc_ie_rm(struct uwb_rc *, enum uwb_ie);
/* This should be changed to a dynamic array where entries are sorted
* by eth_addr and search is done in a binary form
*
......
......@@ -444,7 +444,6 @@ ssize_t uwb_rc_vcmd(struct uwb_rc *rc, const char *cmd_name,
struct uwb_rccb *cmd, size_t cmd_size,
u8 expected_type, u16 expected_event,
struct uwb_rceb **preply);
ssize_t uwb_rc_get_ie(struct uwb_rc *, struct uwb_rc_evt_get_ie **);
int uwb_bg_joined(struct uwb_rc *rc);
size_t __uwb_addr_print(char *, size_t, const unsigned char *, int);
......@@ -653,22 +652,9 @@ static inline int edc_inc(struct edc *err_hist, u16 max_err, u16 timeframe)
/* Information Element handling */
/* For representing the state of writing to a buffer when iterating */
struct uwb_buf_ctx {
char *buf;
size_t bytes, size;
};
typedef int (*uwb_ie_f)(struct uwb_dev *, const struct uwb_ie_hdr *,
size_t, void *);
struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len);
ssize_t uwb_ie_for_each(struct uwb_dev *uwb_dev, uwb_ie_f fn, void *data,
const void *buf, size_t size);
int uwb_ie_dump_hex(struct uwb_dev *, const struct uwb_ie_hdr *,
size_t, void *);
int uwb_rc_set_ie(struct uwb_rc *, struct uwb_rc_cmd_set_ie *);
struct uwb_ie_hdr *uwb_ie_next(void **ptr, size_t *len);
int uwb_rc_ie_add(struct uwb_rc *uwb_rc, const struct uwb_ie_hdr *ies, size_t size);
int uwb_rc_ie_rm(struct uwb_rc *uwb_rc, enum uwb_ie element_id);
/*
* Transmission statistics
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment