aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wimax/i2400m/control.c
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky@linux.intel.com>2009-02-28 18:42:50 -0500
committerDavid S. Miller <davem@davemloft.net>2009-03-02 06:10:25 -0500
commit8987691a4aa6622a1b58bb12c56abaf3d2098fad (patch)
tree92da0abdf6a29aa60ec5aff6250b1937d4c264d6 /drivers/net/wimax/i2400m/control.c
parent6a0f7ab8305cb60a43a6c4a548f57adab784e6cd (diff)
wimax/i2400m: allow control of the base-station idle mode timeout
For power saving reasons, WiMAX links can be put in idle mode while connected after a certain time of the link not being used for tx or rx. In this mode, the device pages the base-station regularly and when data is ready to be transmitted, the link is revived. This patch allows the user to control the time the device has to be idle before it decides to go to idle mode from a sysfs interace. It also updates the initialization code to acknowledge the module variable 'idle_mode_disabled' when the firmware is a newer version (upcoming 1.4 vs 2.6.29's v1.3). The method for setting the idle mode timeout in the older firmwares is much more limited and can be only done at initialization time. Thus, the sysfs file will return -ENOSYS on older ones. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wimax/i2400m/control.c')
-rw-r--r--drivers/net/wimax/i2400m/control.c98
1 files changed, 90 insertions, 8 deletions
diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
index c8b3a68b72b8..c3968b240d69 100644
--- a/drivers/net/wimax/i2400m/control.c
+++ b/drivers/net/wimax/i2400m/control.c
@@ -1222,6 +1222,77 @@ EXPORT_SYMBOL_GPL(i2400m_set_init_config);
1222 1222
1223 1223
1224/** 1224/**
1225 * i2400m_set_idle_timeout - Set the device's idle mode timeout
1226 *
1227 * @i2400m: i2400m device descriptor
1228 *
1229 * @msecs: milliseconds for the timeout to enter idle mode. Between
1230 * 100 to 300000 (5m); 0 to disable. In increments of 100.
1231 *
1232 * After this @msecs of the link being idle (no data being sent or
1233 * received), the device will negotiate with the basestation entering
1234 * idle mode for saving power. The connection is maintained, but
1235 * getting out of it (done in tx.c) will require some negotiation,
1236 * possible crypto re-handshake and a possible DHCP re-lease.
1237 *
1238 * Only available if fw_version >= 0x00090002.
1239 *
1240 * Returns: 0 if ok, < 0 errno code on error.
1241 */
1242int i2400m_set_idle_timeout(struct i2400m *i2400m, unsigned msecs)
1243{
1244 int result;
1245 struct device *dev = i2400m_dev(i2400m);
1246 struct sk_buff *ack_skb;
1247 struct {
1248 struct i2400m_l3l4_hdr hdr;
1249 struct i2400m_tlv_config_idle_timeout cit;
1250 } *cmd;
1251 const struct i2400m_l3l4_hdr *ack;
1252 size_t ack_len;
1253 char strerr[32];
1254
1255 result = -ENOSYS;
1256 if (i2400m_le_v1_3(i2400m))
1257 goto error_alloc;
1258 result = -ENOMEM;
1259 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
1260 if (cmd == NULL)
1261 goto error_alloc;
1262 cmd->hdr.type = cpu_to_le16(I2400M_MT_GET_STATE);
1263 cmd->hdr.length = cpu_to_le16(sizeof(*cmd) - sizeof(cmd->hdr));
1264 cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
1265
1266 cmd->cit.hdr.type =
1267 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
1268 cmd->cit.hdr.length = cpu_to_le16(sizeof(cmd->cit.timeout));
1269 cmd->cit.timeout = cpu_to_le32(msecs);
1270
1271 ack_skb = i2400m_msg_to_dev(i2400m, cmd, sizeof(*cmd));
1272 if (IS_ERR(ack_skb)) {
1273 dev_err(dev, "Failed to issue 'set idle timeout' command: "
1274 "%ld\n", PTR_ERR(ack_skb));
1275 result = PTR_ERR(ack_skb);
1276 goto error_msg_to_dev;
1277 }
1278 ack = wimax_msg_data_len(ack_skb, &ack_len);
1279 result = i2400m_msg_check_status(ack, strerr, sizeof(strerr));
1280 if (result < 0) {
1281 dev_err(dev, "'set idle timeout' (0x%04x) command failed: "
1282 "%d - %s\n", I2400M_MT_GET_STATE, result, strerr);
1283 goto error_cmd_failed;
1284 }
1285 result = 0;
1286 kfree_skb(ack_skb);
1287error_cmd_failed:
1288error_msg_to_dev:
1289 kfree(cmd);
1290error_alloc:
1291 return result;
1292}
1293
1294
1295/**
1225 * i2400m_dev_initialize - Initialize the device once communications are ready 1296 * i2400m_dev_initialize - Initialize the device once communications are ready
1226 * 1297 *
1227 * @i2400m: device descriptor 1298 * @i2400m: device descriptor
@@ -1239,19 +1310,28 @@ int i2400m_dev_initialize(struct i2400m *i2400m)
1239 int result; 1310 int result;
1240 struct device *dev = i2400m_dev(i2400m); 1311 struct device *dev = i2400m_dev(i2400m);
1241 struct i2400m_tlv_config_idle_parameters idle_params; 1312 struct i2400m_tlv_config_idle_parameters idle_params;
1313 struct i2400m_tlv_config_idle_timeout idle_timeout;
1242 const struct i2400m_tlv_hdr *args[9]; 1314 const struct i2400m_tlv_hdr *args[9];
1243 unsigned argc = 0; 1315 unsigned argc = 0;
1244 1316
1245 d_fnstart(3, dev, "(i2400m %p)\n", i2400m); 1317 d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
1246 /* Useless for now...might change */
1247 if (i2400m_idle_mode_disabled) { 1318 if (i2400m_idle_mode_disabled) {
1248 idle_params.hdr.type = 1319 if (i2400m_le_v1_3(i2400m)) {
1249 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS); 1320 idle_params.hdr.type =
1250 idle_params.hdr.length = cpu_to_le16( 1321 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_PARAMETERS);
1251 sizeof(idle_params) - sizeof(idle_params.hdr)); 1322 idle_params.hdr.length = cpu_to_le16(
1252 idle_params.idle_timeout = 0; 1323 sizeof(idle_params) - sizeof(idle_params.hdr));
1253 idle_params.idle_paging_interval = 0; 1324 idle_params.idle_timeout = 0;
1254 args[argc++] = &idle_params.hdr; 1325 idle_params.idle_paging_interval = 0;
1326 args[argc++] = &idle_params.hdr;
1327 } else {
1328 idle_timeout.hdr.type =
1329 cpu_to_le16(I2400M_TLV_CONFIG_IDLE_TIMEOUT);
1330 idle_timeout.hdr.length = cpu_to_le16(
1331 sizeof(idle_timeout) - sizeof(idle_timeout.hdr));
1332 idle_timeout.timeout = 0;
1333 args[argc++] = &idle_timeout.hdr;
1334 }
1255 } 1335 }
1256 result = i2400m_set_init_config(i2400m, args, argc); 1336 result = i2400m_set_init_config(i2400m, args, argc);
1257 if (result < 0) 1337 if (result < 0)
@@ -1264,6 +1344,8 @@ int i2400m_dev_initialize(struct i2400m *i2400m)
1264 */ 1344 */
1265 result = i2400m_cmd_get_state(i2400m); 1345 result = i2400m_cmd_get_state(i2400m);
1266error: 1346error:
1347 if (result < 0)
1348 dev_err(dev, "failed to initialize the device: %d\n", result);
1267 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result); 1349 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
1268 return result; 1350 return result;
1269} 1351}