75 #include <linux/if_arp.h>
76 #include <linux/slab.h>
77 #include <linux/netdevice.h>
78 #include <linux/ethtool.h>
79 #include <linux/export.h>
83 #define D_SUBMODULE netdev
107 d_fnstart(3, dev,
"(net_dev %p [i2400m %p])\n", net_dev, i2400m);
115 d_fnend(3, dev,
"(net_dev %p [i2400m %p]) = %d\n",
116 net_dev, i2400m, result);
127 d_fnstart(3, dev,
"(net_dev %p [i2400m %p])\n", net_dev, i2400m);
129 d_fnend(3, dev,
"(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
165 spin_unlock_irqrestore(&i2400m->
tx_lock, flags);
167 d_fnstart(3, dev,
"(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
170 dev_err(dev,
"WAKE&TX: skb disappeared!\n");
176 if (
unlikely(!netif_carrier_ok(net_dev)))
182 dev_err(dev,
"WAKE&TX: device didn't get out of idle: "
183 "%d - resetting\n", result);
193 dev_err(dev,
"WAKE&TX: error waiting for device to exit IDLE: "
194 "%d - resetting\n", result);
201 netif_wake_queue(net_dev);
206 d_fnend(3, dev,
"(ws %p i2400m %p skb %p) = void [%d]\n",
207 ws, i2400m, skb, result);
220 void i2400m_tx_prep_header(
struct sk_buff *
skb)
240 d_fnstart(3, dev,
"(i2400m %p)\n", i2400m);
252 spin_unlock_irqrestore(&i2400m->
tx_lock, flags);
256 d_fnend(3, dev,
"(i2400m %p) = void\n", i2400m);
279 d_fnstart(3, dev,
"(skb %p net_dev %p)\n", skb, net_dev);
282 "skb %p sending %d bytes to radio\n",
292 netif_stop_queue(net_dev);
295 i2400m_tx_prep_header(skb);
299 spin_unlock_irqrestore(&i2400m->
tx_lock, flags);
306 d_printf(1, dev,
"NETTX: device exiting idle, "
307 "dropping skb %p, queue running %d\n",
308 skb, netif_queue_stopped(net_dev));
311 d_fnend(3, dev,
"(skb %p net_dev %p) = %d\n", skb, net_dev, result);
325 int i2400m_net_tx(
struct i2400m *i2400m,
struct net_device *net_dev,
329 struct device *dev = i2400m_dev(i2400m);
331 d_fnstart(3, dev,
"(i2400m %p net_dev %p skb %p)\n",
332 i2400m, net_dev, skb);
335 i2400m_tx_prep_header(skb);
336 d_printf(3, dev,
"NETTX: skb %p sending %d bytes to radio\n",
340 d_fnend(3, dev,
"(i2400m %p net_dev %p skb %p) = %d\n",
341 i2400m, net_dev, skb, result);
368 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
369 struct device *dev = i2400m_dev(i2400m);
372 d_fnstart(3, dev,
"(skb %p net_dev %p)\n", skb, net_dev);
374 if (skb_header_cloned(skb) &&
379 result = i2400m_net_wake_tx(i2400m, net_dev, skb);
381 result = i2400m_net_tx(i2400m, net_dev, skb);
384 net_dev->
stats.tx_dropped++;
386 net_dev->
stats.tx_packets++;
387 net_dev->
stats.tx_bytes += skb->
len;
390 d_fnend(3, dev,
"(skb %p net_dev %p) = %d\n", skb, net_dev, result);
396 int i2400m_change_mtu(
struct net_device *net_dev,
int new_mtu)
399 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
400 struct device *dev = i2400m_dev(i2400m);
403 dev_err(dev,
"Cannot change MTU to %d (max is %d)\n",
407 net_dev->
mtu = new_mtu;
415 void i2400m_tx_timeout(
struct net_device *net_dev)
424 net_dev->
stats.tx_errors++;
436 void i2400m_rx_fake_eth_header(
struct net_device *net_dev,
439 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
440 struct ethhdr *eth_hdr = _eth_hdr;
486 unsigned i,
const void *
buf,
int buf_len)
489 struct device *dev = i2400m_dev(i2400m);
492 d_fnstart(2, dev,
"(i2400m %p buf %p buf_len %d)\n",
493 i2400m, buf, buf_len);
495 skb = skb_get(skb_rx);
496 d_printf(2, dev,
"RX: reusing first payload skb %p\n", skb);
498 skb_trim(skb, (
void *) skb_end_pointer(skb) - buf);
504 dev_err(dev,
"NETRX: no memory to realloc skb\n");
505 net_dev->
stats.rx_dropped++;
506 goto error_skb_realloc;
510 i2400m_rx_fake_eth_header(i2400m->
wimax_dev.net_dev,
516 net_dev->
stats.rx_packets++;
517 net_dev->
stats.rx_bytes += buf_len;
518 d_printf(3, dev,
"NETRX: receiving %d bytes to network stack\n",
520 d_dump(4, dev, buf, buf_len);
523 d_fnend(2, dev,
"(i2400m %p buf %p buf_len %d) = void\n",
524 i2400m, buf, buf_len);
554 struct device *dev = i2400m_dev(i2400m);
557 d_fnstart(2, dev,
"(i2400m %p skb %p [%u] cs %d)\n",
558 i2400m, skb, skb->
len, cs);
563 i2400m_rx_fake_eth_header(i2400m->
wimax_dev.net_dev,
569 net_dev->
stats.rx_packets++;
570 net_dev->
stats.rx_bytes += skb->
len;
573 dev_err(dev,
"ERX: BUG? CS type %u unsupported\n", cs);
577 d_printf(3, dev,
"ERX: receiving %d bytes to the network stack\n",
582 d_fnend(2, dev,
"(i2400m %p skb %p [%u] cs %d) = void\n",
583 i2400m, skb, skb->
len, cs);
587 .ndo_open = i2400m_open,
588 .ndo_stop = i2400m_stop,
589 .ndo_start_xmit = i2400m_hard_start_xmit,
590 .ndo_tx_timeout = i2400m_tx_timeout,
591 .ndo_change_mtu = i2400m_change_mtu,
594 static void i2400m_get_drvinfo(
struct net_device *net_dev,
597 struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
602 if (net_dev->
dev.parent)
607 static const struct ethtool_ops i2400m_ethtool_ops = {
608 .get_drvinfo = i2400m_get_drvinfo,
633 d_fnend(3,
NULL,
"(net_dev %p) = void\n", net_dev);