25 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/device.h>
30 #include <linux/kdev_t.h>
31 #include <linux/slab.h>
58 result =
uwb_rc_cmd(rc,
"START-BEACON", &cmd->rccb,
sizeof(*cmd),
59 &reply.
rceb,
sizeof(reply));
64 "START-BEACON: command execution failed: %s (%d)\n",
73 static int uwb_rc_stop_beacon(
struct uwb_rc *
rc)
86 result =
uwb_rc_cmd(rc,
"STOP-BEACON", cmd,
sizeof(*cmd),
87 &reply.rceb,
sizeof(reply));
92 "STOP-BEACON: command execution failed: %s (%d)\n",
123 result = uwb_rc_stop_beacon(rc);
126 result = uwb_rc_start_beacon(rc, bpst_offset, channel);
132 dev_err(dev,
"Cannot set new IE on device: "
134 result = uwb_rc_stop_beacon(rc);
216 bce = __uwb_beca_find_bydev(rc, devaddr);
236 bce = __uwb_beca_find_bymac(rc, macaddr);
245 static void uwb_beca_e_init(
struct uwb_beca_e *bce)
249 stats_init(&bce->lqe_stats);
271 uwb_beca_e_init(bce);
286 unsigned long expires;
319 uwb_dev_addr_print(devbuf,
sizeof(devbuf), &bf->
hdr.SrcAddr);
320 uwb_dev_addr_print(dstbuf,
sizeof(dstbuf), &bf->
hdr.DestAddr);
322 "BEACON from %s to %s (ch%u offset %u slot %u MAC %s)\n",
366 if (evt->
notif.size <
sizeof(*be) +
sizeof(*bf)) {
367 dev_err(dev,
"BEACON event: Not enough data to decode "
368 "(%zu vs %zu bytes needed)\n", evt->
notif.size,
369 sizeof(*be) +
sizeof(*bf));
397 unsigned long last_ts;
401 result = uwb_verify_beacon(rc, evt, be);
428 uwb_beacon_print(evt->
rc, be, bf);
429 bce = __uwb_beca_add(rc, be, bf, evt->
ts_jiffies);
450 stats_add_sample(&bce->lqe_stats, be->
bLQI - 7);
472 struct device *dev = &evt->
rc->uwb_dev.dev;
476 if (evt->
notif.size <
sizeof(*bs)) {
477 dev_err(dev,
"BEACON SIZE notification: Not enough data to "
478 "decode (%zu vs %zu bytes needed)\n",
479 evt->
notif.size,
sizeof(*bs));
484 dev_info(dev,
"Beacon size changed to %u bytes "
488 static unsigned count;
489 if (++count % 1000 == 0)
490 dev_info(dev,
"Beacon size changed %u times "
491 "(FIXME: action?)\n", count);
512 if (evt->
notif.size <
sizeof(*bpsc)) {
513 dev_err(dev,
"BP SLOT CHANGE event: Not enough data\n");
519 if (uwb_rc_evt_bp_slot_change_no_slot(bpsc)) {
520 dev_info(dev,
"stopped beaconing: No free slots in BP\n");
523 rc->
uwb_dev.beacon_slot = uwb_rc_evt_bp_slot_change_slot_num(bpsc);
543 struct device *dev = &evt->
rc->uwb_dev.dev;
546 static unsigned count;
550 if (evt->
notif.size <
sizeof(*bpoiec)) {
551 dev_err(dev,
"BPOIEC notification: Not enough data to "
552 "decode (%zu vs %zu bytes needed)\n",
553 evt->
notif.size,
sizeof(*bpoiec));
558 if (iesize <
sizeof(*bpoie)) {
559 dev_err(dev,
"BPOIEC notification: Not enough IE data to "
560 "decode (%zu vs %zu bytes needed)\n",
561 iesize,
sizeof(*bpoie));
564 if (++count % 1000 == 0)
565 dev_info(dev,
"BPOIE: %u changes received\n", count);
603 result =
sscanf(buf,
"%d", &channel);
607 return result < 0 ? result :
size;