/* * Wake up the device and transmit a held SKB, then restart the net queue * * When the device goes into basestation-idle mode, we need to tell it * to exit that mode; it will negotiate with the base station, user * space may have to intervene to rehandshake crypto and then tell us * when it is ready to transmit the packet we have "queued". Still we * need to give it sometime after it reports being ok. * * On error, there is not much we can do. If the error was on TX, we * still wake the queue up to see if the next packet will be luckier. * * If _cmd_exit_idle() fails...well, it could be many things; most * commonly it is that something else took the device out of IDLE mode * (for example, the base station). In that case we get an -EILSEQ and * we are just going to ignore that one. If the device is back to * connected, then fine -- if it is someother state, the packet will * be dropped anyway. */ void i2400m_wake_tx_work(struct work_struct *ws) { int result; struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws); struct net_device *net_dev = i2400m->wimax_dev.net_dev; struct device *dev = i2400m_dev(i2400m); struct sk_buff *skb; unsigned long flags; spin_lock_irqsave(&i2400m->tx_lock, flags); skb = i2400m->wake_tx_skb; i2400m->wake_tx_skb = NULL; spin_unlock_irqrestore(&i2400m->tx_lock, flags); d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb); result = -EINVAL; if (skb == NULL) { dev_err(dev, "WAKE&TX: skb disappeared!\n"); goto out_put; } /* If we have, somehow, lost the connection after this was * queued, don't do anything; this might be the device got * reset or just disconnected. */ if (unlikely(!netif_carrier_ok(net_dev))) goto out_kfree; result = i2400m_cmd_exit_idle(i2400m); if (result == -EILSEQ) result = 0; if (result < 0) { dev_err(dev, "WAKE&TX: device didn't get out of idle: " "%d - resetting\n", result); i2400m_reset(i2400m, I2400M_RT_BUS); goto error; } result = wait_event_timeout(i2400m->state_wq, i2400m->state != I2400M_SS_IDLE, net_dev->watchdog_timeo - HZ/2); if (result == 0) result = -ETIMEDOUT; if (result < 0) { dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: " "%d - resetting\n", result); i2400m_reset(i2400m, I2400M_RT_BUS); goto error; } msleep(20); /* device still needs some time or it drops it */ result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA); error: netif_wake_queue(net_dev); out_kfree: kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */ out_put: i2400m_put(i2400m); d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n", ws, i2400m, skb, result); }
/* * Wake up the device and transmit a held SKB, then restart the net queue * * When the device goes into basestation-idle mode, we need to tell it * to exit that mode; it will negotiate with the base station, user * space may have to intervene to rehandshake crypto and then tell us * when it is ready to transmit the packet we have "queued". Still we * need to give it sometime after it reports being ok. * * On error, there is not much we can do. If the error was on TX, we * still wake the queue up to see if the next packet will be luckier. * * If _cmd_exit_idle() fails...well, it could be many things; most * commonly it is that something else took the device out of IDLE mode * (for example, the base station). In that case we get an -EILSEQ and * we are just going to ignore that one. If the device is back to * connected, then fine -- if it is someother state, the packet will * be dropped anyway. */ void i2400m_wake_tx_work(struct work_struct *ws) { int result; struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws); struct device *dev = i2400m_dev(i2400m); struct sk_buff *skb = i2400m->wake_tx_skb; unsigned long flags; spin_lock_irqsave(&i2400m->tx_lock, flags); skb = i2400m->wake_tx_skb; i2400m->wake_tx_skb = NULL; spin_unlock_irqrestore(&i2400m->tx_lock, flags); d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb); result = -EINVAL; if (skb == NULL) { dev_err(dev, "WAKE&TX: skb dissapeared!\n"); goto out_put; } result = i2400m_cmd_exit_idle(i2400m); if (result == -EILSEQ) result = 0; if (result < 0) { dev_err(dev, "WAKE&TX: device didn't get out of idle: " "%d\n", result); goto error; } result = wait_event_timeout(i2400m->state_wq, i2400m->state != I2400M_SS_IDLE, 5 * HZ); if (result == 0) result = -ETIMEDOUT; if (result < 0) { dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: " "%d\n", result); goto error; } msleep(20); /* device still needs some time or it drops it */ result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA); netif_wake_queue(i2400m->wimax_dev.net_dev); error: kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */ out_put: i2400m_put(i2400m); d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n", ws, i2400m, skb, result); }