53 #include <linux/device.h>
56 #include <linux/netdevice.h>
58 #include <linux/module.h>
62 #define D_SUBMODULE stack
65 static char wimax_debug_params[128];
69 "String of space-separated NAME:VALUE pairs, where NAMEs "
70 "are the different debug submodules and VALUE are the "
71 "initial debug value to set.");
101 struct sk_buff *wimax_gnl_re_state_change_alloc(
107 struct device *
dev = wimax_dev_to_dev(wimax_dev);
111 d_fnstart(3, dev,
"(wimax_dev %p new_state %u old_state %u)\n",
112 wimax_dev, new_state, old_state);
115 if (report_skb ==
NULL) {
116 dev_err(dev,
"RE_STCH: can't create message\n");
122 dev_err(dev,
"RE_STCH: can't put data into message\n");
129 dev_err(dev,
"RE_STCH: Error adding OLD attr: %d\n", result);
134 dev_err(dev,
"RE_STCH: Error adding NEW attr: %d\n", result);
140 dev_err(dev,
"RE_STCH: Error adding IFINDEX attribute\n");
143 d_fnend(3, dev,
"(wimax_dev %p new_state %u old_state %u) = %p\n",
144 wimax_dev, new_state, old_state, report_skb);
148 nlmsg_free(report_skb);
150 d_fnend(3, dev,
"(wimax_dev %p new_state %u old_state %u) = %d\n",
151 wimax_dev, new_state, old_state, result);
152 return ERR_PTR(result);
167 int wimax_gnl_re_state_change_send(
168 struct wimax_dev *wimax_dev,
struct sk_buff *report_skb,
172 struct device *dev = wimax_dev_to_dev(wimax_dev);
173 d_fnstart(3, dev,
"(wimax_dev %p report_skb %p)\n",
174 wimax_dev, report_skb);
175 if (report_skb ==
NULL) {
179 genlmsg_end(report_skb, header);
182 d_fnend(3, dev,
"(wimax_dev %p report_skb %p) = %d\n",
183 wimax_dev, report_skb, result);
190 unsigned int allowed_states_bm)
192 if (
WARN_ON(((1 << new_state) & allowed_states_bm) == 0)) {
194 old_state, new_state);
205 struct device *dev = wimax_dev_to_dev(wimax_dev);
210 d_fnstart(3, dev,
"(wimax_dev %p new_state %u [old %u])\n",
211 wimax_dev, new_state, old_state);
214 dev_err(dev,
"SW BUG: requesting invalid state %u\n",
218 if (old_state == new_state)
221 stch_skb = wimax_gnl_re_state_change_alloc(
222 wimax_dev, new_state, old_state, &header);
227 __check_new_state(old_state, new_state,
231 __check_new_state(old_state, new_state,
240 __check_new_state(old_state, new_state,
245 __check_new_state(old_state, new_state,
250 __check_new_state(old_state, new_state,
258 __check_new_state(old_state, new_state,
266 __check_new_state(old_state, new_state,
274 __check_new_state(old_state, new_state,
278 netif_tx_disable(wimax_dev->
net_dev);
283 dev_err(dev,
"SW BUG: wimax_dev %p is in unknown state %u\n",
284 wimax_dev, wimax_dev->
state);
292 dev_err(dev,
"SW BUG: wimax_dev %p entering NULL state "
293 "from %u\n", wimax_dev, wimax_dev->
state);
312 netif_wake_queue(wimax_dev->
net_dev);
318 __wimax_state_set(wimax_dev, new_state);
319 if (!IS_ERR(stch_skb))
320 wimax_gnl_re_state_change_send(wimax_dev, stch_skb, header);
322 d_fnend(3, dev,
"(wimax_dev %p new_state %u [old %u]) = void\n",
323 wimax_dev, new_state, old_state);
380 state = wimax_dev->
state;
416 struct genl_ops *wimax_gnl_ops[] = {
425 size_t wimax_addr_scnprint(
char *addr_str,
size_t addr_str_size,
426 unsigned char *
addr,
size_t addr_len)
428 unsigned int cnt, total;
430 for (total = cnt = 0; cnt < addr_len; cnt++)
431 total +=
scnprintf(addr_str + total, addr_str_size - total,
433 cnt == addr_len - 1 ?
'\0' :
':');
460 struct device *dev = net_dev->
dev.parent;
463 d_fnstart(3, dev,
"(wimax_dev %p net_dev %p)\n", wimax_dev, net_dev);
470 goto error_rfkill_add;
477 dev_err(dev,
"cannot initialize debugfs: %d\n",
479 goto error_debugfs_add;
485 wimax_addr_scnprint(addr_str,
sizeof(addr_str),
487 dev_err(dev,
"WiMAX interface %s (%s) ready\n",
488 net_dev->
name, addr_str);
489 d_fnend(3, dev,
"(wimax_dev %p net_dev %p) = 0\n", wimax_dev, net_dev);
497 d_fnend(3, dev,
"(wimax_dev %p net_dev %p) = %d\n",
498 wimax_dev, net_dev, result);
534 d_fnend(3,
NULL,
"(wimax_dev %p) = void\n", wimax_dev);
568 int __init wimax_subsys_init(
void)
573 d_parse_params(D_LEVEL, D_LEVEL_SIZE, wimax_debug_params,
582 goto error_register_family;
585 for (cnt = 0; cnt <
ARRAY_SIZE(wimax_gnl_ops); cnt++) {
588 d_printf(4,
NULL,
"registering generic netlink op code "
589 "%u: %d\n", wimax_gnl_ops[cnt]->
cmd, result);
593 wimax_gnl_ops[cnt]->
cmd, result);
594 goto error_register_ops;
606 for (cnt--; cnt >= 0; cnt--)
610 error_register_family:
620 void __exit wimax_subsys_exit(
void)
625 for (cnt =
ARRAY_SIZE(wimax_gnl_ops) - 1; cnt >= 0; cnt--)