diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-03-28 20:29:51 +0000 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-03-28 20:29:51 +0000 |
commit | ed40d0c472b136682b2fcba05f89762859c7374f (patch) | |
tree | 076b83a26bcd63d6158463735dd34c10bbc591dc /drivers/net/wimax | |
parent | 9e495834e59ca9b29f1a1f63b9f5533bb022ac49 (diff) | |
parent | 5d80f8e5a9dc9c9a94d4aeaa567e219a808b8a4a (diff) |
Merge branch 'origin' into devel
Conflicts:
sound/soc/pxa/pxa2xx-i2s.c
Diffstat (limited to 'drivers/net/wimax')
-rw-r--r-- | drivers/net/wimax/i2400m/Makefile | 1 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/control.c | 147 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/debug-levels.h | 1 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/driver.c | 28 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/fw.c | 65 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/i2400m.h | 91 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/netdev.c | 120 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/rx.c | 749 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/sdio.c | 27 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/sysfs.c | 80 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/usb-notif.c | 2 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/usb.c | 30 |
12 files changed, 1210 insertions, 131 deletions
diff --git a/drivers/net/wimax/i2400m/Makefile b/drivers/net/wimax/i2400m/Makefile index 1696e936cf5..5d9e018d31a 100644 --- a/drivers/net/wimax/i2400m/Makefile +++ b/drivers/net/wimax/i2400m/Makefile @@ -8,6 +8,7 @@ i2400m-y := \ driver.o \ fw.o \ op-rfkill.o \ + sysfs.o \ netdev.o \ tx.o \ rx.o diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c index 15d9f51b292..b3cadb626fe 100644 --- a/drivers/net/wimax/i2400m/control.c +++ b/drivers/net/wimax/i2400m/control.c @@ -52,7 +52,6 @@ * * i2400m_dev_initalize() Called by i2400m_dev_start() * i2400m_set_init_config() - * i2400m_firmware_check() * i2400m_cmd_get_state() * i2400m_dev_shutdown() Called by i2400m_dev_stop() * i2400m->bus_reset() @@ -942,8 +941,8 @@ error_cmd_failed: /* Firmware interface versions we support */ enum { I2400M_HDIv_MAJOR = 9, - I2400M_HDIv_MAJOR_2 = 8, I2400M_HDIv_MINOR = 1, + I2400M_HDIv_MINOR_2 = 2, }; @@ -959,6 +958,10 @@ enum { * Long function, but quite simple; first chunk launches the command * and double checks the reply for the right TLV. Then we process the * TLV (where the meat is). + * + * Once we process the TLV that gives us the firmware's interface + * version, we encode it and save it in i2400m->fw_version for future + * reference. */ int i2400m_firmware_check(struct i2400m *i2400m) { @@ -1009,22 +1012,20 @@ int i2400m_firmware_check(struct i2400m *i2400m) minor = le16_to_cpu(l4mv->minor); branch = le16_to_cpu(l4mv->branch); result = -EINVAL; - if (major != I2400M_HDIv_MAJOR - && major != I2400M_HDIv_MAJOR_2) { - dev_err(dev, "unsupported major fw interface version " + if (major != I2400M_HDIv_MAJOR) { + dev_err(dev, "unsupported major fw version " "%u.%u.%u\n", major, minor, branch); goto error_bad_major; } - if (major == I2400M_HDIv_MAJOR_2) - dev_err(dev, "deprecated major fw interface version " - "%u.%u.%u\n", major, minor, branch); result = 0; - if (minor != I2400M_HDIv_MINOR) - dev_warn(dev, "untested minor fw firmware version %u.%u.%u\n", + if (minor < I2400M_HDIv_MINOR_2 && minor > I2400M_HDIv_MINOR) + dev_warn(dev, "untested minor fw version %u.%u.%u\n", major, minor, branch); -error_bad_major: + /* Yes, we ignore the branch -- we don't have to track it */ + i2400m->fw_version = major << 16 | minor; dev_info(dev, "firmware interface version %u.%u.%u\n", major, minor, branch); +error_bad_major: error_no_tlv: error_cmd_failed: kfree_skb(ack_skb); @@ -1221,6 +1222,77 @@ EXPORT_SYMBOL_GPL(i2400m_set_init_config); /** + * i2400m_set_idle_timeout - Set the device's idle mode timeout + * + * @i2400m: i2400m device descriptor + * + * @msecs: milliseconds for the timeout to enter idle mode. Between + * 100 to 300000 (5m); 0 to disable. In increments of 100. + * + * After this @msecs of the link being idle (no data being sent or + * received), the device will negotiate with the basestation entering + * idle mode for saving power. The connection is maintained, but + * getting out of it (done in tx.c) will require some negotiation, + * possible crypto re-handshake and a possible DHCP re-lease. + * + * Only available if fw_version >= 0x00090002. + * + * Returns: 0 if ok, < 0 errno code on error. + */ +int i2400m_set_idle_timeout(struct i2400m *i2400m, unsigned msecs) +{ + int result; + struct device *dev = i2400m_dev(i2400m); + struct sk_buff *ack_skb; + struct { + struct i2400m_l3l4_hdr hdr; + struct i2400m_tlv_config_idle_timeout cit; + } *cmd; + const struct i2400m_l3l4_hdr *ack; + size_t ack_len; + char strerr[32]; + + result = -ENOSYS; + if (i2400m_le_v1_3(i2400m)) + goto error_alloc; + result = -ENOMEM; + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); + if (cmd == NULL) + goto error_alloc; + cmd->hdr.type = cpu_to_le16(I2400M_MT_GET_STATE); + cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr)); + cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION); + + cmd->cit.hdr.type = + cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT); + cmd->cit.hdr.length = cpu_to_le16(sizeof(cmd->cit.timeout)); + cmd->cit.timeout = cpu_to_le32(msecs); + + ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd)); + if (IS_ERR(ack_skb)) { + dev_err(dev, "Failed to issue 'set idle timeout' command: " + "%ld\n", PTR_ERR(ack_skb)); + result = PTR_ERR(ack_skb); + goto error_msg_to_dev; + } + ack = wimax_msg_data_len(ack_skb, &ack_len); + result = i2400m_msg_check_status(ack, strerr, sizeof(strerr)); + if (result < 0) { + dev_err(dev, "'set idle timeout' (0x%04x) command failed: " + "%d - %s\n", I2400M_MT_GET_STATE, result, strerr); + goto error_cmd_failed; + } + result = 0; + kfree_skb(ack_skb); +error_cmd_failed: +error_msg_to_dev: + kfree(cmd); +error_alloc: + return result; +} + + +/** * i2400m_dev_initialize - Initialize the device once communications are ready * * @i2400m: device descriptor @@ -1238,26 +1310,55 @@ int i2400m_dev_initialize(struct i2400m *i2400m) int result; struct device *dev = i2400m_dev(i2400m); struct i2400m_tlv_config_idle_parameters idle_params; + struct i2400m_tlv_config_idle_timeout idle_timeout; + struct i2400m_tlv_config_d2h_data_format df; + struct i2400m_tlv_config_dl_host_reorder dlhr; const struct i2400m_tlv_hdr *args[9]; unsigned argc = 0; d_fnstart(3, dev, "(i2400m %p)\n", i2400m); - /* Useless for now...might change */ + /* Disable idle mode? (enabled by default) */ if (i2400m_idle_mode_disabled) { - idle_params.hdr.type = - cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS); - idle_params.hdr.length = cpu_to_le16( - sizeof(idle_params) - sizeof(idle_params.hdr)); - idle_params.idle_timeout = 0; - idle_params.idle_paging_interval = 0; - args[argc++] = &idle_params.hdr; + if (i2400m_le_v1_3(i2400m)) { + idle_params.hdr.type = + cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS); + idle_params.hdr.length = cpu_to_le16( + sizeof(idle_params) - sizeof(idle_params.hdr)); + idle_params.idle_timeout = 0; + idle_params.idle_paging_interval = 0; + args[argc++] = &idle_params.hdr; + } else { + idle_timeout.hdr.type = + cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT); + idle_timeout.hdr.length = cpu_to_le16( + sizeof(idle_timeout) - sizeof(idle_timeout.hdr)); + idle_timeout.timeout = 0; + args[argc++] = &idle_timeout.hdr; + } + } + if (i2400m_ge_v1_4(i2400m)) { + /* Enable extended RX data format? */ + df.hdr.type = + cpu_to_le16(I2400M_TLV_CONFIG_D2H_DATA_FORMAT); + df.hdr.length = cpu_to_le16( + sizeof(df) - sizeof(df.hdr)); + df.format = 1; + args[argc++] = &df.hdr; + + /* Enable RX data reordering? + * (switch flipped in rx.c:i2400m_rx_setup() after fw upload) */ + if (i2400m->rx_reorder) { + dlhr.hdr.type = + cpu_to_le16(I2400M_TLV_CONFIG_DL_HOST_REORDER); + dlhr.hdr.length = cpu_to_le16( + sizeof(dlhr) - sizeof(dlhr.hdr)); + dlhr.reorder = 1; + args[argc++] = &dlhr.hdr; + } } result = i2400m_set_init_config(i2400m, args, argc); if (result < 0) goto error; - result = i2400m_firmware_check(i2400m); /* fw versions ok? */ - if (result < 0) - goto error; /* * Update state: Here it just calls a get state; parsing the * result (System State TLV and RF Status TLV [done in the rx @@ -1266,6 +1367,8 @@ int i2400m_dev_initialize(struct i2400m *i2400m) */ result = i2400m_cmd_get_state(i2400m); error: + if (result < 0) + dev_err(dev, "failed to initialize the device: %d\n", result); d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result); return result; } diff --git a/drivers/net/wimax/i2400m/debug-levels.h b/drivers/net/wimax/i2400m/debug-levels.h index 3183baa16a5..48fbfaa0d40 100644 --- a/drivers/net/wimax/i2400m/debug-levels.h +++ b/drivers/net/wimax/i2400m/debug-levels.h @@ -38,6 +38,7 @@ enum d_module { D_SUBMODULE_DECLARE(netdev), D_SUBMODULE_DECLARE(rfkill), D_SUBMODULE_DECLARE(rx), + D_SUBMODULE_DECLARE(sysfs), D_SUBMODULE_DECLARE(tx), }; diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c index e80a0b65a75..07a54bad237 100644 --- a/drivers/net/wimax/i2400m/driver.c +++ b/drivers/net/wimax/i2400m/driver.c @@ -48,6 +48,7 @@ * i2400m_dev_bootstrap() * i2400m_tx_setup() * i2400m->bus_dev_start() + * i2400m_firmware_check() * i2400m_check_mac_addr() * wimax_dev_add() * @@ -75,6 +76,11 @@ MODULE_PARM_DESC(idle_mode_disabled, "If true, the device will not enable idle mode negotiation " "with the base station (when connected) to save power."); +int i2400m_rx_reorder_disabled; /* 0 (rx reorder enabled) by default */ +module_param_named(rx_reorder_disabled, i2400m_rx_reorder_disabled, int, 0644); +MODULE_PARM_DESC(rx_reorder_disabled, + "If true, RX reordering will be disabled."); + /** * i2400m_queue_work - schedule work on a i2400m's queue * @@ -395,6 +401,9 @@ retry: result = i2400m_tx_setup(i2400m); if (result < 0) goto error_tx_setup; + result = i2400m_rx_setup(i2400m); + if (result < 0) + goto error_rx_setup; result = i2400m->bus_dev_start(i2400m); if (result < 0) goto error_bus_dev_start; @@ -404,6 +413,9 @@ retry: dev_err(dev, "cannot create workqueue\n"); goto error_create_workqueue; } + result = i2400m_firmware_check(i2400m); /* fw versions ok? */ + if (result < 0) + goto error_fw_check; /* At this point is ok to send commands to the device */ result = i2400m_check_mac_addr(i2400m); if (result < 0) @@ -421,10 +433,13 @@ retry: error_dev_initialize: error_check_mac_addr: +error_fw_check: destroy_workqueue(i2400m->work_queue); error_create_workqueue: i2400m->bus_dev_stop(i2400m); error_bus_dev_start: + i2400m_rx_release(i2400m); +error_rx_setup: i2400m_tx_release(i2400m); error_tx_setup: error_bootstrap: @@ -472,6 +487,7 @@ void __i2400m_dev_stop(struct i2400m *i2400m) i2400m->ready = 0; destroy_workqueue(i2400m->work_queue); i2400m->bus_dev_stop(i2400m); + i2400m_rx_release(i2400m); i2400m_tx_release(i2400m); wimax_state_change(wimax_dev, WIMAX_ST_DOWN); d_fnend(3, dev, "(i2400m %p) = 0\n", i2400m); @@ -613,7 +629,7 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) d_fnstart(3, dev, "(i2400m %p)\n", i2400m); snprintf(wimax_dev->name, sizeof(wimax_dev->name), - "i2400m-%s:%s", dev->bus->name, dev->bus_id); + "i2400m-%s:%s", dev->bus->name, dev_name(dev)); i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL); if (i2400m->bm_cmd_buf == NULL) { @@ -657,6 +673,11 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) wimax_state_change(wimax_dev, WIMAX_ST_UNINITIALIZED); /* Now setup all that requires a registered net and wimax device. */ + result = sysfs_create_group(&net_dev->dev.kobj, &i2400m_dev_attr_group); + if (result < 0) { + dev_err(dev, "cannot setup i2400m's sysfs: %d\n", result); + goto error_sysfs_setup; + } result = i2400m_debugfs_add(i2400m); if (result < 0) { dev_err(dev, "cannot setup i2400m's debugfs: %d\n", result); @@ -666,6 +687,9 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) return result; error_debugfs_setup: + sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj, + &i2400m_dev_attr_group); +error_sysfs_setup: wimax_dev_rm(&i2400m->wimax_dev); error_wimax_dev_add: i2400m_dev_stop(i2400m); @@ -697,6 +721,8 @@ void i2400m_release(struct i2400m *i2400m) netif_stop_queue(i2400m->wimax_dev.net_dev); i2400m_debugfs_rm(i2400m); + sysfs_remove_group(&i2400m->wimax_dev.net_dev->dev.kobj, + &i2400m_dev_attr_group); wimax_dev_rm(&i2400m->wimax_dev); i2400m_dev_stop(i2400m); unregister_netdev(i2400m->wimax_dev.net_dev); diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c index 1d8271f34c3..675c6ce810c 100644 --- a/drivers/net/wimax/i2400m/fw.c +++ b/drivers/net/wimax/i2400m/fw.c @@ -140,10 +140,10 @@ static const __le32 i2400m_ACK_BARKER[4] = { - __constant_cpu_to_le32(I2400M_ACK_BARKER), - __constant_cpu_to_le32(I2400M_ACK_BARKER), - __constant_cpu_to_le32(I2400M_ACK_BARKER), - __constant_cpu_to_le32(I2400M_ACK_BARKER) + cpu_to_le32(I2400M_ACK_BARKER), + cpu_to_le32(I2400M_ACK_BARKER), + cpu_to_le32(I2400M_ACK_BARKER), + cpu_to_le32(I2400M_ACK_BARKER) }; @@ -483,7 +483,7 @@ ssize_t i2400m_dnload_bcf(struct i2400m *i2400m, if (offset + section_size > bcf_len) { dev_err(dev, "fw %s: bad section #%zu, " "end (@%zu) beyond EOF (@%zu)\n", - i2400m->bus_fw_name, section, + i2400m->fw_name, section, offset + section_size, bcf_len); ret = -EINVAL; goto error_section_beyond_eof; @@ -493,7 +493,7 @@ ssize_t i2400m_dnload_bcf(struct i2400m *i2400m, &ack, sizeof(ack), I2400M_BM_CMD_RAW); if (ret < 0) { dev_err(dev, "fw %s: section #%zu (@%zu %zu B) " - "failed %d\n", i2400m->bus_fw_name, section, + "failed %d\n", i2400m->fw_name, section, offset, sizeof(*bh) + data_size, (int) ret); goto error_send; } @@ -771,8 +771,8 @@ static int i2400m_dnload_init_nonsigned(struct i2400m *i2400m) { #define POKE(a, d) { \ - .address = __constant_cpu_to_le32(a), \ - .data = __constant_cpu_to_le32(d) \ + .address = cpu_to_le32(a), \ + .data = cpu_to_le32(d) \ } static const struct { __le32 address; @@ -874,7 +874,7 @@ int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf) if (result < 0) dev_err(dev, "fw %s: non-signed download " "initialization failed: %d\n", - i2400m->bus_fw_name, result); + i2400m->fw_name, result); } else if (i2400m->sboot == 0 && (module_id & I2400M_BCF_MOD_ID_POKES)) { /* non-signed boot process with pokes, nothing to do */ @@ -886,7 +886,7 @@ int i2400m_dnload_init(struct i2400m *i2400m, const struct i2400m_bcf_hdr *bcf) if (result < 0) dev_err(dev, "fw %s: signed boot download " "initialization failed: %d\n", - i2400m->bus_fw_name, result); + i2400m->fw_name, result); } return result; } @@ -915,7 +915,7 @@ int i2400m_fw_check(struct i2400m *i2400m, if (bcf_size < sizeof(*bcf)) { /* big enough header? */ dev_err(dev, "firmware %s too short: " "%zu B vs %zu (at least) expected\n", - i2400m->bus_fw_name, bcf_size, sizeof(*bcf)); + i2400m->fw_name, bcf_size, sizeof(*bcf)); goto error; } @@ -931,7 +931,7 @@ int i2400m_fw_check(struct i2400m *i2400m, if (bcf_size != size) { /* annoyingly paranoid */ dev_err(dev, "firmware %s: bad size, got " "%zu B vs %u expected\n", - i2400m->bus_fw_name, bcf_size, size); + i2400m->fw_name, bcf_size, size); goto error; } @@ -943,7 +943,7 @@ int i2400m_fw_check(struct i2400m *i2400m, if (module_type != 6) { /* built for the right hardware? */ dev_err(dev, "bad fw %s: unexpected module type 0x%x; " - "aborting\n", i2400m->bus_fw_name, module_type); + "aborting\n", i2400m->fw_name, module_type); goto error; } @@ -951,10 +951,10 @@ int i2400m_fw_check(struct i2400m *i2400m, result = 0; if (module_vendor != 0x8086) dev_err(dev, "bad fw %s? unexpected vendor 0x%04x\n", - i2400m->bus_fw_name, module_vendor); + i2400m->fw_name, module_vendor); if (date < 0x20080300) dev_err(dev, "bad fw %s? build date too old %08x\n", - i2400m->bus_fw_name, date); + i2400m->fw_name, date); error: return result; } @@ -1016,7 +1016,7 @@ hw_reboot: goto error_dev_rebooted; if (ret < 0) { dev_err(dev, "fw %s: download failed: %d\n", - i2400m->bus_fw_name, ret); + i2400m->fw_name, ret); goto error_dnload_bcf; } @@ -1026,12 +1026,12 @@ hw_reboot: if (ret < 0) { dev_err(dev, "fw %s: " "download finalization failed: %d\n", - i2400m->bus_fw_name, ret); + i2400m->fw_name, ret); goto error_dnload_finalize; } d_printf(2, dev, "fw %s successfully uploaded\n", - i2400m->bus_fw_name); + i2400m->fw_name); i2400m->boot_mode = 0; error_dnload_finalize: error_dnload_bcf: @@ -1067,28 +1067,41 @@ error_dev_rebooted: */ int i2400m_dev_bootstrap(struct i2400m *i2400m, enum i2400m_bri flags) { - int ret = 0; + int ret = 0, itr = 0; struct device *dev = i2400m_dev(i2400m); const struct firmware *fw; const struct i2400m_bcf_hdr *bcf; /* Firmware data */ + const char *fw_name; d_fnstart(5, dev, "(i2400m %p)\n", i2400m); + /* Load firmware files to memory. */ - ret = request_firmware(&fw, i2400m->bus_fw_name, dev); - if (ret) { - dev_err(dev, "fw %s: request failed: %d\n", - i2400m->bus_fw_name, ret); - goto error_fw_req; + itr = 0; + while(1) { + fw_name = i2400m->bus_fw_names[itr]; + if (fw_name == NULL) { + dev_err(dev, "Could not find a usable firmware image\n"); + ret = -ENOENT; + goto error_no_fw; + } + ret = request_firmware(&fw, fw_name, dev); + if (ret == 0) + break; /* got it */ + if (ret < 0) + dev_err(dev, "fw %s: cannot load file: %d\n", + fw_name, ret); + itr++; } - bcf = (void *) fw->data; + bcf = (void *) fw->data; + i2400m->fw_name = fw_name; ret = i2400m_fw_check(i2400m, bcf, fw->size); if (ret < 0) goto error_fw_bad; ret = i2400m_fw_dnload(i2400m, bcf, fw->size, flags); error_fw_bad: release_firmware(fw); -error_fw_req: +error_no_fw: d_fnend(5, dev, "(i2400m %p) = %d\n", i2400m, ret); return ret; } diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h index 3b9d27ea295..3ae2df38b59 100644 --- a/drivers/net/wimax/i2400m/i2400m.h +++ b/drivers/net/wimax/i2400m/i2400m.h @@ -156,10 +156,6 @@ enum { }; -/* Firmware version we request when pulling the fw image file */ -#define I2400M_FW_VERSION "1.4" - - /** * i2400m_reset_type - methods to reset a device * @@ -178,6 +174,7 @@ enum i2400m_reset_type { }; struct i2400m_reset_ctx; +struct i2400m_roq; /** * struct i2400m - descriptor for an Intel 2400m @@ -242,10 +239,14 @@ struct i2400m_reset_ctx; * The caller to this function will check if the response is a * barker that indicates the device going into reset mode. * - * @bus_fw_name: [fill] name of the firmware image (in most cases, - * they are all the same for a single release, except that they - * have the type of the bus embedded in the name (eg: - * i2400m-fw-X-VERSION.sbcf, where X is the bus name). + * @bus_fw_names: [fill] a NULL-terminated array with the names of the + * firmware images to try loading. This is made a list so we can + * support backward compatibility of firmware releases (eg: if we + * can't find the default v1.4, we try v1.3). In general, the name + * should be i2400m-fw-X-VERSION.sbcf, where X is the bus name. + * The list is tried in order and the first one that loads is + * used. The fw loader will set i2400m->fw_name to point to the + * active firmware image. * * @bus_bm_mac_addr_impaired: [fill] Set to true if the device's MAC * address provided in boot mode is kind of broken and needs to @@ -257,6 +258,9 @@ struct i2400m_reset_ctx; * force this to be the first field so that we can get from * netdev_priv() the right pointer. * + * @rx_reorder: 1 if RX reordering is enabled; this can only be + * set at probe time. + * * @state: device's state (as reported by it) * * @state_wq: waitqueue that is woken up whenever the state changes @@ -313,6 +317,12 @@ struct i2400m_reset_ctx; * * @rx_size_max: buggest RX message received. * + * @rx_roq: RX ReOrder queues. (fw >= v1.4) When packets are received + * out of order, the device will ask the driver to hold certain + * packets until the ones that are received out of order can be + * delivered. Then the driver can release them to the host. See + * drivers/net/i2400m/rx.c for details. + * * @init_mutex: Mutex used for serializing the device bringup * sequence; this way if the device reboots in the middle, we * don't try to do a bringup again while we are tearing down the @@ -364,6 +374,11 @@ struct i2400m_reset_ctx; * These have to be in a separate directory, a child of * (wimax_dev->debugfs_dentry) so they can be removed when the * module unloads, as we don't keep each dentry. + * + * @fw_name: name of the firmware image that is currently being used. + * + * @fw_version: version of the firmware interface, Major.minor, + * encoded in the high word and low word (major << 16 | minor). */ struct i2400m { struct wimax_dev wimax_dev; /* FIRST! See doc */ @@ -372,6 +387,7 @@ struct i2400m { unsigned boot_mode:1; /* is the device in boot mode? */ unsigned sboot:1; /* signed or unsigned fw boot */ unsigned ready:1; /* all probing steps done */ + unsigned rx_reorder:1; /* RX reorder is enabled */ u8 trace_msg_from_user; /* echo rx msgs to 'trace' pipe */ /* typed u8 so debugfs/u8 can tweak */ enum i2400m_system_state state; @@ -388,7 +404,7 @@ struct i2400m { size_t, int flags); ssize_t (*bus_bm_wait_for_ack)(struct i2400m *, struct i2400m_bootrom_header *, size_t); - const char *bus_fw_name; + const char **bus_fw_names; unsigned bus_bm_mac_addr_impaired:1; spinlock_t tx_lock; /* protect TX state */ @@ -400,10 +416,11 @@ struct i2400m { unsigned tx_pl_num, tx_pl_max, tx_pl_min, tx_num, tx_size_acc, tx_size_min, tx_size_max; - /* RX stats */ + /* RX stuff */ spinlock_t rx_lock; /* protect RX state */ unsigned rx_pl_num, rx_pl_max, rx_pl_min, rx_num, rx_size_acc, rx_size_min, rx_size_max; + struct i2400m_roq *rx_roq; /* not under rx_lock! */ struct mutex msg_mutex; /* serialize command execution */ struct completion msg_completion; @@ -421,6 +438,8 @@ struct i2400m { struct sk_buff *wake_tx_skb; struct dentry *debugfs_dentry; + const char *fw_name; /* name of the current firmware image */ + unsigned long fw_version; /* version of the firmware interface */ }; @@ -435,6 +454,7 @@ void i2400m_init(struct i2400m *i2400m) wimax_dev_init(&i2400m->wimax_dev); i2400m->boot_mode = 1; + i2400m->rx_reorder = 1; init_waitqueue_head(&i2400m->state_wq); spin_lock_init(&i2400m->tx_lock); @@ -578,12 +598,19 @@ unsigned i2400m_brh_get_signature(const struct i2400m_bootrom_header *hdr) * Driver / device setup and internal functions */ extern void i2400m_netdev_setup(struct net_device *net_dev); +extern int i2400m_sysfs_setup(struct device_driver *); +extern void i2400m_sysfs_release(struct device_driver *); extern int i2400m_tx_setup(struct i2400m *); extern void i2400m_wake_tx_work(struct work_struct *); extern void i2400m_tx_release(struct i2400m *); +extern int i2400m_rx_setup(struct i2400m *); +extern void i2400m_rx_release(struct i2400m *); + extern void i2400m_net_rx(struct i2400m *, struct sk_buff *, unsigned, const void *, int); +extern void i2400m_net_erx(struct i2400m *, struct sk_buff *, + enum i2400m_cs); enum i2400m_pt; extern int i2400m_tx(struct i2400m *, const void *, size_t, enum i2400m_pt); @@ -664,17 +691,17 @@ extern struct i2400m_msg_hdr *i2400m_tx_msg_get(struct i2400m *, size_t *); extern void i2400m_tx_msg_sent(struct i2400m *); static const __le32 i2400m_NBOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_NBOOT_BARKER), - __constant_cpu_to_le32(I2400M_NBOOT_BARKER), - __constant_cpu_to_le32(I2400M_NBOOT_BARKER), - __constant_cpu_to_le32(I2400M_NBOOT_BARKER) + cpu_to_le32(I2400M_NBOOT_BARKER), + cpu_to_le32(I2400M_NBOOT_BARKER), + cpu_to_le32(I2400M_NBOOT_BARKER), + cpu_to_le32(I2400M_NBOOT_BARKER) }; static const __le32 i2400m_SBOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_SBOOT_BARKER), - __constant_cpu_to_le32(I2400M_SBOOT_BARKER), - __constant_cpu_to_le32(I2400M_SBOOT_BARKER), - __constant_cpu_to_le32(I2400M_SBOOT_BARKER) + cpu_to_le32(I2400M_SBOOT_BARKER), + cpu_to_le32(I2400M_SBOOT_BARKER), + cpu_to_le32(I2400M_SBOOT_BARKER), + cpu_to_le32(I2400M_SBOOT_BARKER) }; @@ -721,6 +748,7 @@ extern struct sk_buff *i2400m_get_device_info(struct i2400m *); extern int i2400m_firmware_check(struct i2400m *); extern int i2400m_set_init_config(struct i2400m *, const struct i2400m_tlv_hdr **, size_t); +extern int i2400m_set_idle_timeout(struct i2400m *, unsigned); static inline struct usb_endpoint_descriptor *usb_get_epd(struct usb_interface *iface, int ep) @@ -733,6 +761,32 @@ extern int i2400m_op_rfkill_sw_toggle(struct wimax_dev *, extern void i2400m_report_tlv_rf_switches_status( struct i2400m *, const struct i2400m_tlv_rf_switches_status *); +/* + * Helpers for firmware backwards compability + * + * As we aim to support at least the firmware version that was + * released with the previous kernel/driver release, some code will be + * conditionally executed depending on the firmware version. On each + * release, the code to support fw releases past the last two ones + * will be purged. + * + * By making it depend on this macros, it is easier to keep it a tab + * on what has to go and what not. + */ +static inline +unsigned i2400m_le_v1_3(struct i2400m *i2400m) +{ + /* running fw is lower or v1.3 */ + return i2400m->fw_version <= 0x00090001; +} + +static inline +unsigned i2400m_ge_v1_4(struct i2400m *i2400m) +{ + /* running fw is higher or v1.4 */ + return i2400m->fw_version >= 0x00090002; +} + /* * Do a millisecond-sleep for allowing wireshark to dump all the data @@ -750,6 +804,7 @@ void __i2400m_msleep(unsigned ms) /* Module parameters */ extern int i2400m_idle_mode_disabled; +extern int i2400m_rx_reorder_disabled; #endif /* #ifndef __I2400M_H__ */ diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c index 63fe708e8a3..6b1fe7a81f2 100644 --- a/drivers/net/wimax/i2400m/netdev.c +++ b/drivers/net/wimax/i2400m/netdev.c @@ -28,13 +28,12 @@ * space and from the other side. The world is (sadly) configured to * take in only Ethernet devices... * - * Because of this, currently there is an copy-each-rxed-packet - * overhead on the RX path. Each IP packet has to be reallocated to - * add an ethernet header (as there is no space in what we get from - * the device). This is a known drawback and coming versions of the - * device's firmware are being changed to add header space that can be - * used to insert the ethernet header without having to reallocate and - * copy. + * Because of this, when using firmwares <= v1.3, there is an + * copy-each-rxed-packet overhead on the RX path. Each IP packet has + * to be reallocated to add an ethernet header (as there is no space + * in what we get from the device). This is a known drawback and + * firmwares >= 1.4 add header space that can be used to insert the + * ethernet header without having to reallocate and copy. * * TX error handling is tricky; because we have to FIFO/queue the * buffers for transmission (as the hardware likes it aggregated), we @@ -67,7 +66,9 @@ * i2400m_tx_timeout Called when the device times out * * i2400m_net_rx Called by the RX code when a data frame is - * available. + * available (firmware <= 1.3) + * i2400m_net_erx Called by the RX code when a data frame is + * available (firmware >= 1.4). * i2400m_netdev_setup Called to setup all the netdev stuff from * alloc_netdev. */ @@ -396,30 +397,18 @@ void i2400m_tx_timeout(struct net_device *net_dev) * Create a fake ethernet header * * For emulating an ethernet device, every received IP header has to - * be prefixed with an ethernet header. - * - * What we receive has (potentially) many IP packets concatenated with - * no ETH_HLEN bytes prefixed. Thus there is no space for an eth - * header. - * - * We would have to reallocate or do ugly fragment tricks in order to - * add it. - * - * But what we do is use the header space of the RX transaction - * (*msg_hdr) as we don't need it anymore; then we'll point all the - * data skbs there, as they share the same backing store. - * - * We only support IPv4 for v3 firmware. + * be prefixed with an ethernet header. Fake it with the given + * protocol. */ static void i2400m_rx_fake_eth_header(struct net_device *net_dev, - void *_eth_hdr) + void *_eth_hdr, __be16 protocol) { struct ethhdr *eth_hdr = _eth_hdr; memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest)); memset(eth_hdr->h_source, 0, sizeof(eth_hdr->h_dest)); - eth_hdr->h_proto = __constant_cpu_to_be16(ETH_P_IP); + eth_hdr->h_proto = protocol; } @@ -432,6 +421,13 @@ void i2400m_rx_fake_eth_header(struct net_device *net_dev, * @buf: pointer to the buffer containing the data * @len: buffer's length * + * This is only used now for the v1.3 firmware. It will be deprecated + * in >= 2.6.31. + * + * Note that due to firmware limitations, we don't have space to add + * an ethernet header, so we need to copy each packet. Firmware + * versions >= v1.4 fix this [see i2400m_net_erx()]. + * * We just clone the skb and set it up so that it's skb->data pointer * points to "buf" and it's length. * @@ -478,7 +474,8 @@ void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx, memcpy(skb_put(skb, buf_len), buf, buf_len); } i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev, - skb->data - ETH_HLEN); + skb->data - ETH_HLEN, + cpu_to_be16(ETH_P_IP)); skb_set_mac_header(skb, -ETH_HLEN); skb->dev = i2400m->wimax_dev.net_dev; skb->protocol = htons(ETH_P_IP); @@ -494,6 +491,73 @@ error_skb_realloc: } +/* + * i2400m_net_erx - pass a network packet to the stack (extended version) + * + * @i2400m: device descriptor + * @skb: the skb where the packet is - the skb should be set to point + * at the IP packet; this function will add ethernet headers if + * needed. + * @cs: packet type + * + * This is only used now for firmware >= v1.4. Note it is quite + * similar to i2400m_net_rx() (used only for v1.3 firmware). + * + * This function is normally run from a thread context. However, we + * still use netif_rx() instead of netif_receive_skb() as was + * recommended in the mailing list. Reason is in some stress tests + * when sending/receiving a lot of data we seem to hit a softlock in + * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using + * netif_rx() took care of the issue. + * + * This is, of course, still open to do more research on why running + * with netif_receive_skb() hits this softlock. FIXME. + */ +void i2400m_net_erx(struct i2400m *i2400m, struct sk_buff *skb, + enum i2400m_cs cs) +{ + struct net_device *net_dev = i2400m->wimax_dev.net_dev; + struct device *dev = i2400m_dev(i2400m); + int protocol; + + d_fnstart(2, dev, "(i2400m %p skb %p [%u] cs %d)\n", + i2400m, skb, skb->len, cs); + switch(cs) { + case I2400M_CS_IPV4_0: + case I2400M_CS_IPV4: + protocol = ETH_P_IP; + i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev, + skb->data - ETH_HLEN, + cpu_to_be16(ETH_P_IP)); + skb_set_mac_header(skb, -ETH_HLEN); + skb->dev = i2400m->wimax_dev.net_dev; + skb->protocol = htons(ETH_P_IP); + net_dev->stats.rx_packets++; + net_dev->stats.rx_bytes += skb->len; + break; + default: + dev_err(dev, "ERX: BUG? CS type %u unsupported\n", cs); + goto error; + + } + d_printf(3, dev, "ERX: receiving %d bytes to the network stack\n", + skb->len); + d_dump(4, dev, skb->data, skb->len); + netif_rx_ni(skb); /* see notes in function header */ +error: + d_fnend(2, dev, "(i2400m %p skb %p [%u] cs %d) = void\n", + i2400m, skb, skb->len, cs); +} + +static const struct net_device_ops i2400m_netdev_ops = { + .ndo_open = i2400m_open, + .ndo_stop = i2400m_stop, + .ndo_start_xmit = i2400m_hard_start_xmit, + .ndo_tx_timeout = i2400m_tx_timeout, + .ndo_change_mtu = i2400m_change_mtu, +}; + + /** * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data * @@ -513,11 +577,7 @@ void i2400m_netdev_setup(struct net_device *net_dev) & (~IFF_BROADCAST /* i2400m is P2P */ & ~IFF_MULTICAST); net_dev->watchdog_timeo = I2400M_TX_TIMEOUT; - net_dev->open = i2400m_open; - net_dev->stop = i2400m_stop; - net_dev->hard_start_xmit = i2400m_hard_start_xmit; - net_dev->change_mtu = i2400m_change_mtu; - net_dev->tx_timeout = i2400m_tx_timeout; + net_dev->netdev_ops = &i2400m_netdev_ops; d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev); } EXPORT_SYMBOL_GPL(i2400m_netdev_setup); diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 6922022710a..02419bfd64b 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c @@ -39,7 +39,7 @@ * - Use skb_clone(), break up processing in chunks * - Split transport/device specific * - Make buffer size dynamic to exert less memory pressure - * + * - RX reorder support * * This handles the RX path. * @@ -69,6 +69,50 @@ * See tx.c for a deeper description on alignment requirements and * other fun facts of it. * + * DATA PACKETS + * + * In firmwares <= v1.3, data packets have no header for RX, but they + * do for TX (currently unused). + * + * In firmware >= 1.4, RX packets have an extended header (16 + * bytes). This header conveys information for management of host + * reordering of packets (the device offloads storage of the packets + * for reordering to the host). Read below for more information. + * + * The header is used as dummy space to emulate an ethernet header and + * thus be able to act as an ethernet device without having to reallocate. + * + * DATA RX REORDERING + * + * Starting in firmware v1.4, the device can deliver packets for + * delivery with special reordering information; this allows it to + * more effectively do packet management when some frames were lost in + * the radio traffic. + * + * Thus, for RX packets that come out of order, the device gives the + * driver enough information to queue them properly and then at some + * point, the signal to deliver the whole (or part) of the queued + * packets to the networking stack. There are 16 such queues. + * + * This only happens when a packet comes in with the "need reorder" + * flag set in the RX header. When such bit is set, the following + * operations might be indicated: + * + * - reset queue: send all queued packets to the OS + * + * - queue: queue a packet + * + * - update ws: update the queue's window start and deliver queued + * packets that meet the criteria + * + * - queue & update ws: queue a packet, update the window start and + * deliver queued packets that meet the criteria + * + * (delivery criteria: the packet's [normalized] sequence number is + * lower than the new [normalized] window start). + * + * See the i2400m_roq_*() functions for details. + * * ROADMAP * * i2400m_rx @@ -76,6 +120,19 @@ * i2400m_rx_pl_descr_check * i2400m_rx_payload * i2400m_net_rx + * i2400m_rx_edata + * i2400m_net_erx + * i2400m_roq_reset + * i2400m_net_erx + * i2400m_roq_queue + * __i2400m_roq_queue + * i2400m_roq_update_ws + * __i2400m_roq_update_ws + * i2400m_net_erx + * i2400m_roq_queue_update_ws + * __i2400m_roq_queue + * __i2400m_roq_update_ws + * i2400m_net_erx * i2400m_rx_ctl * i2400m_msg_size_check * i2400m_report_hook_work [in a workqueue] @@ -177,8 +234,7 @@ void i2400m_rx_ctl_ack(struct i2400m *i2400m, return; error_waiter_cancelled: - if (ack_skb) - kfree_skb(ack_skb); + kfree_skb(ack_skb); error_no_waiter: spin_unlock_irqrestore(&i2400m->rx_lock, flags); return; @@ -265,8 +321,6 @@ error_check: } - - /* * Receive and send up a trace * @@ -317,30 +371,628 @@ error_check: /* + * Reorder queue data stored on skb->cb while the skb is queued in the + * reorder queues. + */ +struct i2400m_roq_data { + unsigned sn; /* Serial number for the skb */ + enum i2400m_cs cs; /* packet type for the skb */ +}; + + +/* + * ReOrder Queue + * + * @ws: Window Start; sequence number where the current window start + * is for this queue + * @queue: the skb queue itself + * @log: circular ring buffer used to log information about the + * reorder process in this queue that can be displayed in case of + * error to help diagnose it. + * + * This is the head for a list of skbs. In the skb->cb member of the + * skb when queued here contains a 'struct i2400m_roq_data' were we + * store the sequence number (sn) and the cs (packet type) coming from + * the RX payload header from the device. + */ +struct i2400m_roq +{ + unsigned ws; + struct sk_buff_head queue; + struct i2400m_roq_log *log; +}; + + +static +void __i2400m_roq_init(struct i2400m_roq *roq) +{ + roq->ws = 0; + skb_queue_head_init(&roq->queue); +} + + +static +unsigned __i2400m_roq_index(struct i2400m *i2400m, struct i2400m_roq *roq) +{ + return ((unsigned long) roq - (unsigned long) i2400m->rx_roq) + / sizeof(*roq); +} + + +/* + * Normalize a sequence number based on the queue's window start + * + * nsn = (sn - ws) % 2048 + * + * Note that if @sn < @roq->ws, we still need a positive number; %'s + * sign is implementation specific, so we normalize it by adding 2048 + * to bring it to be positive. + */ +static +unsigned __i2400m_roq_nsn(struct i2400m_roq *roq, unsigned sn) +{ + int r; + r = ((int) sn - (int) roq->ws) % 2048; + if (r < 0) + r += 2048; + return r; +} + + +/* + * Circular buffer to keep the last N reorder operations + * + * In case something fails, dumb then to try to come up with what + * happened. + */ +enum { + I2400M_ROQ_LOG_LENGTH = 32, +}; + +struct i2400m_roq_log { + struct i2400m_roq_log_entry { + enum i2400m_ro_type type; + unsigned ws, count, sn, nsn, new_ws; + } entry[I2400M_ROQ_LOG_LENGTH]; + unsigned in, out; +}; + + +/* Print a log entry */ +static +void i2400m_roq_log_entry_print(struct i2400m *i2400m, unsigned index, + unsigned e_index, + struct i2400m_roq_log_entry *e) +{ + struct device *dev = i2400m_dev(i2400m); + + switch(e->type) { + case I2400M_RO_TYPE_RESET: + dev_err(dev, "q#%d reset ws %u cnt %u sn %u/%u" + " - new nws %u\n", + index, e->ws, e->count, e->sn, e->nsn, e->new_ws); + break; + case I2400M_RO_TYPE_PACKET: + dev_err(dev, "q#%d queue ws %u cnt %u sn %u/%u\n", + index, e->ws, e->count, e->sn, e->nsn); + break; + case I2400M_RO_TYPE_WS: + dev_err(dev, "q#%d update_ws ws %u cnt %u sn %u/%u" + " - new nws %u\n", + index, e->ws, e->count, e->sn, e->nsn, e->new_ws); + break; + case I2400M_RO_TYPE_PACKET_WS: + dev_err(dev, "q#%d queue_update_ws ws %u cnt %u sn %u/%u" + " - new nws %u\n", + index, e->ws, e->count, e->sn, e->nsn, e->new_ws); + break; + default: + dev_err(dev, "q#%d BUG? entry %u - unknown type %u\n", + index, e_index, e->type); + break; + } +} + + +static +void i2400m_roq_log_add(struct i2400m *i2400m, + struct i2400m_roq *roq, enum i2400m_ro_type type, + unsigned ws, unsigned count, unsigned sn, + unsigned nsn, unsigned new_ws) +{ + struct i2400m_roq_log_entry *e; + unsigned cnt_idx; + int index = __i2400m_roq_index(i2400m, roq); + + /* if we run out of space, we eat from the end */ + if (roq->log->in - roq->log->out == I2400M_ROQ_LOG_LENGTH) + roq->log->out++; + cnt_idx = roq->log->in++ % I2400M_ROQ_LOG_LENGTH; + e = &roq->log->entry[cnt_idx]; + + e->type = type; + e->ws = ws; + e->count = count; + e->sn = sn; + e->nsn = nsn; + e->new_ws = new_ws; + + if (d_test(1)) + i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e); +} + + +/* Dump all the entries in the FIFO and reinitialize it */ +static +void i2400m_roq_log_dump(struct i2400m *i2400m, struct i2400m_roq *roq) +{ + unsigned cnt, cnt_idx; + struct i2400m_roq_log_entry *e; + int index = __i2400m_roq_index(i2400m, roq); + + BUG_ON(roq->log->out > roq->log->in); + for (cnt = roq->log->out; cnt < roq->log->in; cnt++) { + cnt_idx = cnt % I2400M_ROQ_LOG_LENGTH; + e = &roq->log->entry[cnt_idx]; + i2400m_roq_log_entry_print(i2400m, index, cnt_idx, e); + memset(e, 0, sizeof(*e)); + } + roq->log->in = roq->log->out = 0; +} + + +/* + * Backbone for the queuing of an skb (by normalized sequence number) + * + * @i2400m: device descriptor + * @roq: reorder queue where to add + * @skb: the skb to add + * @sn: the sequence number of the skb + * @nsn: the normalized sequence number of the skb (pre-computed by the + * caller from the @sn and @roq->ws). + * + * We try first a couple of quick cases: + * + * - the queue is empty + * - the skb would be appended to the queue + * + * These will be the most common operations. + * + * If these fail, then we have to do a sorted insertion in the queue, + * which is the slowest path. + * + * We don't have to acquire a reference count as we are going to own it. + */ +static +void __i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq, + struct sk_buff *skb, unsigned sn, unsigned nsn) +{ + struct device *dev = i2400m_dev(i2400m); + struct sk_buff *skb_itr; + struct i2400m_roq_data *roq_data_itr, *roq_data; + unsigned nsn_itr; + + d_fnstart(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %u)\n", + i2400m, roq, skb, sn, nsn); + + roq_data = (struct i2400m_roq_data *) &skb->cb; + BUILD_BUG_ON(sizeof(*roq_data) > sizeof(skb->cb)); + roq_data->sn = sn; + d_printf(3, dev, "ERX: roq %p [ws %u] nsn %d sn %u\n", + roq, roq->ws, nsn, roq_data->sn); + + /* Queues will be empty on not-so-bad environments, so try + * that first */ + if (skb_queue_empty(&roq->queue)) { + d_printf(2, dev, "ERX: roq %p - first one\n", roq); + __skb_queue_head(&roq->queue, skb); + goto out; + } + /* Now try append, as most of the operations will be that */ + skb_itr = skb_peek_tail(&roq->queue); + roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb; + nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn); + /* NSN bounds assumed correct (checked when it was queued) */ + if (nsn >= nsn_itr) { + d_printf(2, dev, "ERX: roq %p - appended after %p (nsn %d sn %u)\n", + roq, skb_itr, nsn_itr, roq_data_itr->sn); + __skb_queue_tail(&roq->queue, skb); + goto out; + } + /* None of the fast paths option worked. Iterate to find the + * right spot where to insert the packet; we know the queue is + * not empty, so we are not the first ones; we also know we + * are not going to be the last ones. The list is sorted, so + * we have to insert before the the first guy with an nsn_itr + * greater that our nsn. */ + skb_queue_walk(&roq->queue, skb_itr) { + roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb; + nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn); + /* NSN bounds assumed correct (checked when it was queued) */ + if (nsn_itr > nsn) { + d_printf(2, dev, "ERX: roq %p - queued before %p " + "(nsn %d sn %u)\n", roq, skb_itr, nsn_itr, + roq_data_itr->sn); + __skb_queue_before(&roq->queue, skb_itr, skb); + goto out; + } + } + /* If we get here, that is VERY bad -- print info to help + * diagnose and crash it */ + dev_err(dev, "SW BUG? failed to insert packet\n"); + dev_err(dev, "ERX: roq %p [ws %u] skb %p nsn %d sn %u\n", + roq, roq->ws, skb, nsn, roq_data->sn); + skb_queue_walk(&roq->queue, skb_itr) { + roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb; + nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn); + /* NSN bounds assumed correct (checked when it was queued) */ + dev_err(dev, "ERX: roq %p skb_itr %p nsn %d sn %u\n", + roq, skb_itr, nsn_itr, roq_data_itr->sn); + } + BUG(); +out: + d_fnend(4, dev, "(i2400m %p roq %p skb %p sn %u nsn %d) = void\n", + i2400m, roq, skb, sn, nsn); + return; +} + + +/* + * Backbone for the update window start operation + * + * @i2400m: device descriptor + * @roq: Reorder queue + * @sn: New sequence number + * + * Updates the window start of a queue; when doing so, it must deliver + * to the networking stack all the queued skb's whose normalized + * sequence number is lower than the new normalized window start. + */ +static +unsigned __i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq, + unsigned sn) +{ + struct device *dev = i2400m_dev(i2400m); + struct sk_buff *skb_itr, *tmp_itr; + struct i2400m_roq_data *roq_data_itr; + unsigned new_nws, nsn_itr; + + new_nws = __i2400m_roq_nsn(roq, sn); + if (unlikely(new_nws >= 1024) && d_test(1)) { + dev_err(dev, "SW BUG? __update_ws new_nws %u (sn %u ws %u)\n", + new_nws, sn, roq->ws); + WARN_ON(1); + i2400m_roq_log_dump(i2400m, roq); + } + skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) { + roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb; + nsn_itr = __i2400m_roq_nsn(roq, roq_data_itr->sn); + /* NSN bounds assumed correct (checked when it was queued) */ + if (nsn_itr < new_nws) { + d_printf(2, dev, "ERX: roq %p - release skb %p " + "(nsn %u/%u new nws %u)\n", + roq, skb_itr, nsn_itr, roq_data_itr->sn, + new_nws); + __skb_unlink(skb_itr, &roq->queue); + i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs); + } + else + break; /* rest of packets all nsn_itr > nws */ + } + roq->ws = sn; + return new_nws; +} + + +/* + * Reset a queue + * + * @i2400m: device descriptor + * @cin: Queue Index + * + * Deliver all the packets and reset the window-start to zero. Name is + * kind of misleading. + */ +static +void i2400m_roq_reset(struct i2400m *i2400m, struct i2400m_roq *roq) +{ + struct device *dev = i2400m_dev(i2400m); + struct sk_buff *skb_itr, *tmp_itr; + struct i2400m_roq_data *roq_data_itr; + + d_fnstart(2, dev, "(i2400m %p roq %p)\n", i2400m, roq); + i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_RESET, + roq->ws, skb_queue_len(&roq->queue), + ~0, ~0, 0); + skb_queue_walk_safe(&roq->queue, skb_itr, tmp_itr) { + roq_data_itr = (struct i2400m_roq_data *) &skb_itr->cb; + d_printf(2, dev, "ERX: roq %p - release skb %p (sn %u)\n", + roq, skb_itr, roq_data_itr->sn); + __skb_unlink(skb_itr, &roq->queue); + i2400m_net_erx(i2400m, skb_itr, roq_data_itr->cs); + } + roq->ws = 0; + d_fnend(2, dev, "(i2400m %p roq %p) = void\n", i2400m, roq); + return; +} + + +/* + * Queue a packet + * + * @i2400m: device descriptor + * @cin: Queue Index + * @skb: containing the packet data + * @fbn: First block number of the packet in @skb + * @lbn: Last block number of the packet in @skb + * + * The hardware is asking the driver to queue a packet for later + * delivery to the networking stack. + */ +static +void i2400m_roq_queue(struct i2400m *i2400m, struct i2400m_roq *roq, + struct sk_buff * skb, unsigned lbn) +{ + struct device *dev = i2400m_dev(i2400m); + unsigned nsn, len; + + d_fnstart(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n", + i2400m, roq, skb, lbn); + len = skb_queue_len(&roq->queue); + nsn = __i2400m_roq_nsn(roq, lbn); + if (unlikely(nsn >= 1024)) { + dev_err(dev, "SW BUG? queue nsn %d (lbn %u ws %u)\n", + nsn, lbn, roq->ws); + i2400m_roq_log_dump(i2400m, roq); + i2400m->bus_reset(i2400m, I2400M_RT_WARM); + } else { + __i2400m_roq_queue(i2400m, roq, skb, lbn, nsn); + i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET, + roq->ws, len, lbn, nsn, ~0); + } + d_fnend(2, dev, "(i2400m %p roq %p skb %p lbn %u) = void\n", + i2400m, roq, skb, lbn); + return; +} + + +/* + * Update the window start in a reorder queue and deliver all skbs + * with a lower window start + * + * @i2400m: device descriptor + * @roq: Reorder queue + * @sn: New sequence number + */ +static +void i2400m_roq_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq, + unsigned sn) +{ + struct device *dev = i2400m_dev(i2400m); + unsigned old_ws, nsn, len; + + d_fnstart(2, dev, "(i2400m %p roq %p sn %u)\n", i2400m, roq, sn); + old_ws = roq->ws; + len = skb_queue_len(&roq->queue); + nsn = __i2400m_roq_update_ws(i2400m, roq, sn); + i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_WS, + old_ws, len, sn, nsn, roq->ws); + d_fnstart(2, dev, "(i2400m %p roq %p sn %u) = void\n", i2400m, roq, sn); + return; +} + + +/* + * Queue a packet and update the window start + * + * @i2400m: device descriptor + * @cin: Queue Index + * @skb: containing the packet data + * @fbn: First block number of the packet in @skb + * @sn: Last block number of the packet in @skb + * + * Note that unlike i2400m_roq_update_ws(), which sets the new window + * start to @sn, in here we'll set it to @sn + 1. + */ +static +void i2400m_roq_queue_update_ws(struct i2400m *i2400m, struct i2400m_roq *roq, + struct sk_buff * skb, unsigned sn) +{ + struct device *dev = i2400m_dev(i2400m); + unsigned nsn, old_ws, len; + + d_fnstart(2, dev, "(i2400m %p roq %p skb %p sn %u)\n", + i2400m, roq, skb, sn); + len = skb_queue_len(&roq->queue); + nsn = __i2400m_roq_nsn(roq, sn); + old_ws = roq->ws; + if (unlikely(nsn >= 1024)) { + dev_err(dev, "SW BUG? queue_update_ws nsn %u (sn %u ws %u)\n", + nsn, sn, roq->ws); + i2400m_roq_log_dump(i2400m, roq); + i2400m->bus_reset(i2400m, I2400M_RT_WARM); + } else { + /* if the queue is empty, don't bother as we'd queue + * it and inmediately unqueue it -- just deliver it */ + if (len == 0) { + struct i2400m_roq_data *roq_data; + roq_data = (struct i2400m_roq_data *) &skb->cb; + i2400m_net_erx(i2400m, skb, roq_data->cs); + } + else { + __i2400m_roq_queue(i2400m, roq, skb, sn, nsn); + __i2400m_roq_update_ws(i2400m, roq, sn + 1); + } + i2400m_roq_log_add(i2400m, roq, I2400M_RO_TYPE_PACKET_WS, + old_ws, len, sn, nsn, roq->ws); + } + d_fnend(2, dev, "(i2400m %p roq %p skb %p sn %u) = void\n", + i2400m, roq, skb, sn); + return; +} + + +/* + * Receive and send up an extended data packet + * + * @i2400m: device descriptor + * @skb_rx: skb that contains the extended data packet + * @single_last: 1 if the payload is the only one or the last one of + * the skb. + * @payload: pointer to the packet's data inside the skb + * @size: size of the payload + * + * Starting in v1.4 of the i2400m's firmware, the device can send data + * packets to the host in an extended format that; this incudes a 16 + * byte header (struct i2400m_pl_edata_hdr). Using this header's space + * we can fake ethernet headers for ethernet device emulation without + * having to copy packets around. + * + * This function handles said path. + * + * + * Receive and send up an extended data packet that requires no reordering + * + * @i2400m: device descriptor + * @skb_rx: skb that contains the extended data packet + * @single_last: 1 if the payload is the only one or the last one of + * the skb. + * @payload: pointer to the packet's data (past the actual extended + * data payload header). + * @size: size of the payload + * + * Pass over to the networking stack a data packet that might have + * reordering requirements. + * + * This needs to the decide if the skb in which the packet is + * contained can be reused or if it needs to be cloned. Then it has to + * be trimmed in the edges so that the beginning is the space for eth + * header and then pass it to i2400m_net_erx() for the stack + * + * Assumes the caller has verified the sanity of the payload (size, + * etc) already. + */ +static +void i2400m_rx_edata(struct i2400m *i2400m, struct sk_buff *skb_rx, + unsigned single_last, const void *payload, size_t size) +{ + struct device *dev = i2400m_dev(i2400m); + const struct i2400m_pl_edata_hdr *hdr = payload; + struct net_device *net_dev = i2400m->wimax_dev.net_dev; + struct sk_buff *skb; + enum i2400m_cs cs; + u32 reorder; + unsigned ro_needed, ro_type, ro_cin, ro_sn; + struct i2400m_roq *roq; + struct i2400m_roq_data *roq_data; + + BUILD_BUG_ON(ETH_HLEN > sizeof(*hdr)); + + d_fnstart(2, dev, "(i2400m %p skb_rx %p single %u payload %p " + "size %zu)\n", i2400m, skb_rx, single_last, payload, size); + if (size < sizeof(*hdr)) { + dev_err(dev, "ERX: HW BUG? message with short header (%zu " + "vs %zu bytes expected)\n", size, sizeof(*hdr)); + goto error; + } + + if (single_last) { + skb = skb_get(skb_rx); + d_printf(3, dev, "ERX: skb %p reusing\n", skb); + } else { + skb = skb_clone(skb_rx, GFP_KERNEL); + if (skb == NULL) { + dev_err(dev, "ERX: no memory to clone skb\n"); + net_dev->stats.rx_dropped++; + goto error_skb_clone; + } + d_printf(3, dev, "ERX: skb %p cloned from %p\n", skb, skb_rx); + } + /* now we have to pull and trim so that the skb points to the + * beginning of the IP packet; the netdev part will add the + * ethernet header as needed - we know there is enough space + * because we checked in i2400m_rx_edata(). */ + skb_pull(skb, payload + sizeof(*hdr) - (void *) skb->data); + skb_trim(skb, (void *) skb_end_pointer(skb) - payload - sizeof(*hdr)); + + reorder = le32_to_cpu(hdr->reorder); + ro_needed = reorder & I2400M_RO_NEEDED; + cs = hdr->cs; + if (ro_needed) { + ro_type = (reorder >> I2400M_RO_TYPE_SHIFT) & I2400M_RO_TYPE; + ro_cin = (reorder >> I2400M_RO_CIN_SHIFT) & I2400M_RO_CIN; + ro_sn = (reorder >> I2400M_RO_SN_SHIFT) & I2400M_RO_SN; + + roq = &i2400m->rx_roq[ro_cin]; + roq_data = (struct i2400m_roq_data *) &skb->cb; + roq_data->sn = ro_sn; + roq_data->cs = cs; + d_printf(2, dev, "ERX: reorder needed: " + "type %u cin %u [ws %u] sn %u/%u len %zuB\n", + ro_type, ro_cin, roq->ws, ro_sn, + __i2400m_roq_nsn(roq, ro_sn), size); + d_dump(2, dev, payload, size); + switch(ro_type) { + case I2400M_RO_TYPE_RESET: + i2400m_roq_reset(i2400m, roq); + kfree_skb(skb); /* no data here */ + break; + case I2400M_RO_TYPE_PACKET: + i2400m_roq_queue(i2400m, roq, skb, ro_sn); + break; + case I2400M_RO_TYPE_WS: + i2400m_roq_update_ws(i2400m, roq, ro_sn); + kfree_skb(skb); /* no data here */ + break; + case I2400M_RO_TYPE_PACKET_WS: + i2400m_roq_queue_update_ws(i2400m, roq, skb, ro_sn); + break; + default: + dev_err(dev, "HW BUG? unknown reorder type %u\n", ro_type); + } + } + else + i2400m_net_erx(i2400m, skb, cs); +error_skb_clone: +error: + d_fnend(2, dev, "(i2400m %p skb_rx %p single %u payload %p " + "size %zu) = void\n", i2400m, skb_rx, single_last, payload, size); + return; +} + + +/* * Act on a received payload * * @i2400m: device instance * @skb_rx: skb where the transaction was received - * @single: 1 if there is only one payload, 0 otherwise + * @single_last: 1 this is the only payload or the last one (so the + * skb can be reused instead of cloned). * @pld: payload descriptor * @payload: payload data * * Upon reception of a payload, look at its guts in the payload - * descriptor and decide what to do with it. + * descriptor and decide what to do with it. If it is a single payload + * skb or if the last skb is a data packet, the skb will be referenced + * and modified (so it doesn't have to be cloned). */ static void i2400m_rx_payload(struct i2400m *i2400m, struct sk_buff *skb_rx, - unsigned single, const struct i2400m_pld *pld, + unsigned single_last, const struct i2400m_pld *pld, const void *payload) { struct device *dev = i2400m_dev(i2400m); size_t pl_size = i2400m_pld_size(pld); enum i2400m_pt pl_type = i2400m_pld_type(pld); + d_printf(7, dev, "RX: received payload type %u, %zu bytes\n", + pl_type, pl_size); + d_dump(8, dev, payload, pl_size); + switch (pl_type) { case I2400M_PT_DATA: d_printf(3, dev, "RX: data payload %zu bytes\n", pl_size); - i2400m_net_rx(i2400m, skb_rx, single, payload, pl_size); + i2400m_net_rx(i2400m, skb_rx, single_last, payload, pl_size); break; case I2400M_PT_CTRL: i2400m_rx_ctl(i2400m, skb_rx, payload, pl_size); @@ -348,6 +1000,10 @@ void i2400m_rx_payload(struct i2400m *i2400m, struct sk_buff *skb_rx, case I2400M_PT_TRACE: i2400m_rx_trace(i2400m, payload, pl_size); break; + case I2400M_PT_EDATA: + d_printf(3, dev, "ERX: data payload %zu bytes\n", pl_size); + i2400m_rx_edata(i2400m, skb_rx, single_last, payload, pl_size); + break; default: /* Anything else shouldn't come to the host */ if (printk_ratelimit()) dev_err(dev, "RX: HW BUG? unexpected payload type %u\n", @@ -475,7 +1131,7 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) const struct i2400m_msg_hdr *msg_hdr; size_t pl_itr, pl_size, skb_len; unsigned long flags; - unsigned num_pls; + unsigned num_pls, single_last; skb_len = skb->len; d_fnstart(4, dev, "(i2400m %p skb %p [size %zu])\n", @@ -504,7 +1160,8 @@ int i2400m_rx(struct i2400m *i2400m, struct sk_buff *skb) pl_itr, skb->len); if (result < 0) goto error_pl_descr_check; - i2400m_rx_payload(i2400m, skb, num_pls == 1, &msg_hdr->pld[i], + single_last = num_pls == 1 || i == num_pls - 1; + i2400m_rx_payload(i2400m, skb, single_last, &msg_hdr->pld[i], skb->data + pl_itr); pl_itr += ALIGN(pl_size, I2400M_PL_PAD); cond_resched(); /* Don't monopolize */ @@ -532,3 +1189,73 @@ error_msg_hdr_check: return result; } EXPORT_SYMBOL_GPL(i2400m_rx); + + +/* + * Initialize the RX queue and infrastructure + * + * This sets up all the RX reordering infrastructures, which will not + * be used if reordering is not enabled or if the firmware does not + * support it. The device is told to do reordering in + * i2400m_dev_initialize(), where it also looks at the value of the + * i2400m->rx_reorder switch before taking a decission. + * + * Note we allocate the roq queues in one chunk and the actual logging + * support for it (logging) in another one and then we setup the + * pointers from the first to the last. + */ +int i2400m_rx_setup(struct i2400m *i2400m) +{ + int result = 0; + struct device *dev = i2400m_dev(i2400m); + + i2400m->rx_reorder = i2400m_rx_reorder_disabled? 0 : 1; + if (i2400m->rx_reorder) { + unsigned itr; + size_t size; + struct i2400m_roq_log *rd; + + result = -ENOMEM; + + size = sizeof(i2400m->rx_roq[0]) * (I2400M_RO_CIN + 1); + i2400m->rx_roq = kzalloc(size, GFP_KERNEL); + if (i2400m->rx_roq == NULL) { + dev_err(dev, "RX: cannot allocate %zu bytes for " + "reorder queues\n", size); + goto error_roq_alloc; + } + + size = sizeof(*i2400m->rx_roq[0].log) * (I2400M_RO_CIN + 1); + rd = kzalloc(size, GFP_KERNEL); + if (rd == NULL) { + dev_err(dev, "RX: cannot allocate %zu bytes for " + "reorder queues log areas\n", size); + result = -ENOMEM; + goto error_roq_log_alloc; + } + + for(itr = 0; itr < I2400M_RO_CIN + 1; itr++) { + __i2400m_roq_init(&i2400m->rx_roq[itr]); + i2400m->rx_roq[itr].log = &rd[itr]; + } + } + return 0; + +error_roq_log_alloc: + kfree(i2400m->rx_roq); +error_roq_alloc: + return result; +} + + +/* Tear down the RX queue and infrastructure */ +void i2400m_rx_release(struct i2400m *i2400m) +{ + if (i2400m->rx_reorder) { + unsigned itr; + for(itr = 0; itr < I2400M_RO_CIN + 1; itr++) + __skb_queue_purge(&i2400m->rx_roq[itr].queue); + kfree(i2400m->rx_roq[0].log); + kfree(i2400m->rx_roq); + } +} diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c index 1bfa283bbd8..5ac5e76701c 100644 --- a/drivers/net/wimax/i2400m/sdio.c +++ b/drivers/net/wimax/i2400m/sdio.c @@ -70,8 +70,13 @@ static int ioe_timeout = 2; module_param(ioe_timeout, int, 0); -/* Our firmware file name */ -#define I2400MS_FW_FILE_NAME "i2400m-fw-sdio-" I2400M_FW_VERSION ".sbcf" +/* Our firmware file name list */ +static const char *i2400ms_bus_fw_names[] = { +#define I2400MS_FW_FILE_NAME "i2400m-fw-sdio-1.3.sbcf" + I2400MS_FW_FILE_NAME, + NULL +}; + /* * Enable the SDIO function @@ -255,16 +260,16 @@ int i2400ms_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt) container_of(i2400m, struct i2400ms, i2400m); struct device *dev = i2400m_dev(i2400m); static const __le32 i2400m_WARM_BOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), }; static const __le32 i2400m_COLD_BOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), }; if (rt == I2400M_RT_WARM) @@ -401,7 +406,7 @@ int i2400ms_probe(struct sdio_func *func, i2400m->bus_reset = i2400ms_bus_reset; i2400m->bus_bm_cmd_send = i2400ms_bus_bm_cmd_send; i2400m->bus_bm_wait_for_ack = i2400ms_bus_bm_wait_for_ack; - i2400m->bus_fw_name = I2400MS_FW_FILE_NAME; + i2400m->bus_fw_names = i2400ms_bus_fw_names; i2400m->bus_bm_mac_addr_impaired = 1; result = i2400ms_enable_function(i2400ms->func); diff --git a/drivers/net/wimax/i2400m/sysfs.c b/drivers/net/wimax/i2400m/sysfs.c new file mode 100644 index 00000000000..1237109f251 --- /dev/null +++ b/drivers/net/wimax/i2400m/sysfs.c @@ -0,0 +1,80 @@ +/* + * Intel Wireless WiMAX Connection 2400m + * Sysfs interfaces to show driver and device information + * + * + * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com> + * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/spinlock.h> +#include <linux/device.h> +#include "i2400m.h" + + +#define D_SUBMODULE sysfs +#include "debug-levels.h" + + +/* + * Set the idle timeout (msecs) + * + * FIXME: eventually this should be a common WiMAX stack method, but + * would like to wait to see how other devices manage it. + */ +static +ssize_t i2400m_idle_timeout_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + ssize_t result; + struct i2400m *i2400m = net_dev_to_i2400m(to_net_dev(dev)); + unsigned val; + + result = -EINVAL; + if (sscanf(buf, "%u\n", &val) != 1) + goto error_no_unsigned; + if (val != 0 && (val < 100 || val > 300000 || val % 100 != 0)) { + dev_err(dev, "idle_timeout: %u: invalid msecs specification; " + "valid values are 0, 100-300000 in 100 increments\n", + val); + goto error_bad_value; + } + result = i2400m_set_idle_timeout(i2400m, val); + if (result >= 0) + result = size; +error_no_unsigned: +error_bad_value: + return result; +} + +static +DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR, + NULL, i2400m_idle_timeout_store); + +static +struct attribute *i2400m_dev_attrs[] = { + &dev_attr_i2400m_idle_timeout.attr, + NULL, +}; + +struct attribute_group i2400m_dev_attr_group = { + .name = NULL, /* we want them in the same directory */ + .attrs = i2400m_dev_attrs, +}; diff --git a/drivers/net/wimax/i2400m/usb-notif.c b/drivers/net/wimax/i2400m/usb-notif.c index 9702c22b249..6add27c3f35 100644 --- a/drivers/net/wimax/i2400m/usb-notif.c +++ b/drivers/net/wimax/i2400m/usb-notif.c @@ -102,7 +102,7 @@ int i2400mu_notification_grok(struct i2400mu *i2400mu, const void *buf, dev_err(dev, "HW BUG? Unknown/unexpected data in notification " "message (%zu bytes)\n", buf_len); snprintf(prefix, sizeof(prefix), "%s %s: ", - dev_driver_string(dev) , dev->bus_id); + dev_driver_string(dev), dev_name(dev)); if (buf_len > 64) { print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 8, 4, buf, 64, 0); diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c index c6d93465c7e..ca4151a9e22 100644 --- a/drivers/net/wimax/i2400m/usb.c +++ b/drivers/net/wimax/i2400m/usb.c @@ -73,7 +73,14 @@ /* Our firmware file name */ -#define I2400MU_FW_FILE_NAME "i2400m-fw-usb-" I2400M_FW_VERSION ".sbcf" +static const char *i2400mu_bus_fw_names[] = { +#define I2400MU_FW_FILE_NAME_v1_4 "i2400m-fw-usb-1.4.sbcf" + I2400MU_FW_FILE_NAME_v1_4, +#define I2400MU_FW_FILE_NAME_v1_3 "i2400m-fw-usb-1.3.sbcf" + I2400MU_FW_FILE_NAME_v1_3, + NULL, +}; + static int i2400mu_bus_dev_start(struct i2400m *i2400m) @@ -211,16 +218,16 @@ int i2400mu_bus_reset(struct i2400m *i2400m, enum i2400m_reset_type rt) container_of(i2400m, struct i2400mu, i2400m); struct device *dev = i2400m_dev(i2400m); static const __le32 i2400m_WARM_BOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), - __constant_cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), + cpu_to_le32(I2400M_WARM_RESET_BARKER), }; static const __le32 i2400m_COLD_BOOT_BARKER[4] = { - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), - __constant_cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), + cpu_to_le32(I2400M_COLD_RESET_BARKER), }; d_fnstart(3, dev, "(i2400m %p rt %u)\n", i2400m, rt); @@ -394,7 +401,7 @@ int i2400mu_probe(struct usb_interface *iface, i2400m->bus_reset = i2400mu_bus_reset; i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send; i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack; - i2400m->bus_fw_name = I2400MU_FW_FILE_NAME; + i2400m->bus_fw_names = i2400mu_bus_fw_names; i2400m->bus_bm_mac_addr_impaired = 0; #ifdef CONFIG_PM @@ -594,4 +601,5 @@ module_exit(i2400mu_driver_exit); MODULE_AUTHOR("Intel Corporation <linux-wimax@intel.com>"); MODULE_DESCRIPTION("Intel 2400M WiMAX networking for USB"); MODULE_LICENSE("GPL"); -MODULE_FIRMWARE(I2400MU_FW_FILE_NAME); +MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_4); +MODULE_FIRMWARE(I2400MU_FW_FILE_NAME_v1_3); |