69 #include <linux/module.h>
72 #include <linux/slab.h>
74 #define D_SUBMODULE driver
78 static char i2400m_debug_params[128];
82 "String of space-separated NAME:VALUE pairs, where NAMEs "
83 "are the different debug submodules and VALUE are the "
84 "initial debug value to set.");
86 static char i2400m_barkers_params[128];
88 sizeof(i2400m_barkers_params), 0644);
90 "String of comma-separated 32-bit values; each is "
91 "recognized as the value the device sends as a reboot "
92 "signal; values are appended to a list--setting one value "
93 "as zero cleans the existing list and starts a new one.");
136 d_fnstart(4, dev,
"(wimax_dev %p [i2400m %p] msg_buf %p "
137 "msg_len %zu genl_info %p)\n", wimax_dev, i2400m,
138 msg_buf, msg_len, genl_info);
140 result = PTR_ERR(ack_skb);
142 goto error_msg_to_dev;
145 d_fnend(4, dev,
"(wimax_dev %p [i2400m %p] msg_buf %p msg_len %zu "
146 "genl_info %p) = %d\n", wimax_dev, i2400m, msg_buf, msg_len,
178 int i2400m_op_reset(
struct wimax_dev *wimax_dev)
181 struct i2400m *i2400m = wimax_dev_to_i2400m(wimax_dev);
182 struct device *dev = i2400m_dev(i2400m);
188 d_fnstart(4, dev,
"(wimax_dev %p)\n", wimax_dev);
205 d_fnend(4, dev,
"(wimax_dev %p) = %d\n", wimax_dev, result);
218 int i2400m_check_mac_addr(
struct i2400m *i2400m)
221 struct device *dev = i2400m_dev(i2400m);
226 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
229 result = PTR_ERR(skb);
230 dev_err(dev,
"Cannot verify MAC address, error reading: %d\n",
235 ddi = (
void *) skb->
data;
237 d_printf(2, dev,
"GET DEVICE INFO: mac addr %pM\n",
242 dev_warn(dev,
"warning: device reports a different MAC address "
243 "to that of boot mode's\n");
247 dev_err(dev,
"device reports an invalid MAC address, "
250 dev_warn(dev,
"updating MAC address\n");
259 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
287 struct wimax_dev *wimax_dev = &i2400m->
wimax_dev;
289 struct device *dev = i2400m_dev(i2400m);
292 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
296 dev_err(dev,
"cannot bootstrap device: %d\n", result);
297 goto error_bootstrap;
308 dev_err(dev,
"cannot create workqueue\n");
309 goto error_create_workqueue;
314 goto error_bus_dev_start;
324 result = i2400m_check_mac_addr(i2400m);
326 goto error_check_mac_addr;
329 goto error_dev_initialize;
342 d_fnend(3, dev,
"(net_dev %p [i2400m %p]) = %d\n",
343 net_dev, i2400m, result);
346 error_dev_initialize:
347 error_check_mac_addr:
356 error_create_workqueue:
362 if (result == -
EL3RST && times-- > 0) {
366 d_fnend(3, dev,
"(net_dev %p [i2400m %p]) = %d\n",
367 net_dev, i2400m, result);
373 int i2400m_dev_start(
struct i2400m *i2400m,
enum i2400m_bri bm_flags)
377 if (i2400m->
updown == 0) {
378 result = __i2400m_dev_start(i2400m, bm_flags);
402 void __i2400m_dev_stop(
struct i2400m *i2400m)
404 struct wimax_dev *wimax_dev = &i2400m->
wimax_dev;
405 struct device *dev = i2400m_dev(i2400m);
407 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
427 d_fnend(3, dev,
"(i2400m %p) = 0\n", i2400m);
437 void i2400m_dev_stop(
struct i2400m *i2400m)
441 __i2400m_dev_stop(i2400m);
465 unsigned long pm_event,
468 struct i2400m *i2400m =
470 struct device *dev = i2400m_dev(i2400m);
472 d_fnstart(3, dev,
"(i2400m %p pm_event %lx)\n", i2400m, pm_event);
490 d_fnend(3, dev,
"(i2400m %p pm_event %lx) = void\n", i2400m, pm_event);
504 struct device *dev = i2400m_dev(i2400m);
506 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
507 d_printf(1, dev,
"pre-reset shut down\n");
512 netif_tx_disable(i2400m->
wimax_dev.net_dev);
513 __i2400m_dev_stop(i2400m);
521 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
538 struct device *dev = i2400m_dev(i2400m);
540 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
541 d_printf(1, dev,
"post-reset start\n");
545 dev_err(dev,
"bus-specific setup failed: %d\n",
547 goto error_bus_setup;
552 result = __i2400m_dev_start(
555 goto error_dev_start;
558 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
570 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
604 struct device *dev = i2400m_dev(i2400m);
608 d_fnstart(3, dev,
"(ws %p i2400m %p reason %s)\n", ws, i2400m, reason);
618 dev_err(dev,
"device rebooted somewhere else?\n");
624 dev_err(dev,
"%s: reinitializing driver\n", reason);
627 __i2400m_dev_stop(i2400m);
633 result = __i2400m_dev_start(i2400m,
636 dev_err(dev,
"%s: cannot start the device: %d\n",
642 dev_err(dev,
"tried too many times to "
643 "reset the device, giving up\n");
681 d_fnend(3, dev,
"(ws %p i2400m %p reason %s) = void\n",
712 void __i2400m_error_recovery(
struct work_struct *ws)
759 int i2400m_bm_buf_alloc(
struct i2400m *i2400m)
766 goto error_bm_cmd_kzalloc;
769 goto error_bm_ack_buf_kzalloc;
772 error_bm_ack_buf_kzalloc:
774 error_bm_cmd_kzalloc:
783 void i2400m_bm_buf_free(
struct i2400m *i2400m)
843 netif_tx_disable(net_dev);
865 struct device *dev = i2400m_dev(i2400m);
866 struct wimax_dev *wimax_dev = &i2400m->
wimax_dev;
869 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
872 "i2400m-%s:%s", dev->
bus->name, dev_name(dev));
874 result = i2400m_bm_buf_alloc(i2400m);
876 dev_err(dev,
"cannot allocate bootmode scratch buffers\n");
877 goto error_bm_buf_alloc;
883 dev_err(dev,
"bus-specific setup failed: %d\n",
885 goto error_bus_setup;
891 dev_err(dev,
"read mac addr: bootrom init "
892 "failed: %d\n", result);
893 goto error_bootrom_init;
897 goto error_read_mac_addr;
900 i2400m->
pm_notifier.notifier_call = i2400m_pm_notifier;
905 dev_err(dev,
"cannot register i2400m network device: %d\n",
907 goto error_register_netdev;
911 i2400m->
wimax_dev.op_msg_from_user = i2400m_op_msg_from_user;
913 i2400m->
wimax_dev.op_reset = i2400m_op_reset;
917 goto error_wimax_dev_add;
922 dev_err(dev,
"cannot setup i2400m's sysfs: %d\n", result);
923 goto error_sysfs_setup;
928 dev_err(dev,
"cannot setup i2400m's debugfs: %d\n", result);
929 goto error_debugfs_setup;
932 result = i2400m_dev_start(i2400m, bm_flags);
934 goto error_dev_start;
935 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
947 error_register_netdev:
954 i2400m_bm_buf_free(i2400m);
956 d_fnend(3, dev,
"(i2400m %p) = %d\n", i2400m, result);
969 struct device *dev = i2400m_dev(i2400m);
971 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
972 netif_stop_queue(i2400m->
wimax_dev.net_dev);
974 i2400m_dev_stop(i2400m);
987 i2400m_bm_buf_free(i2400m);
988 d_fnend(3, dev,
"(i2400m %p) = void\n", i2400m);
1011 int __init i2400m_driver_init(
void)
1013 d_parse_params(D_LEVEL, D_LEVEL_SIZE, i2400m_debug_params,
1020 void __exit i2400m_driver_exit(
void)