netdev.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Intel Wireless WiMAX Connection 2400m
  4. * Glue with the networking stack
  5. *
  6. * Copyright (C) 2007 Intel Corporation <linux-wimax@intel.com>
  7. * Yanir Lubetkin <yanirx.lubetkin@intel.com>
  8. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  9. *
  10. * This implements an ethernet device for the i2400m.
  11. *
  12. * We fake being an ethernet device to simplify the support from user
  13. * space and from the other side. The world is (sadly) configured to
  14. * take in only Ethernet devices...
  15. *
  16. * Because of this, when using firmwares <= v1.3, there is an
  17. * copy-each-rxed-packet overhead on the RX path. Each IP packet has
  18. * to be reallocated to add an ethernet header (as there is no space
  19. * in what we get from the device). This is a known drawback and
  20. * firmwares >= 1.4 add header space that can be used to insert the
  21. * ethernet header without having to reallocate and copy.
  22. *
  23. * TX error handling is tricky; because we have to FIFO/queue the
  24. * buffers for transmission (as the hardware likes it aggregated), we
  25. * just give the skb to the TX subsystem and by the time it is
  26. * transmitted, we have long forgotten about it. So we just don't care
  27. * too much about it.
  28. *
  29. * Note that when the device is in idle mode with the basestation, we
  30. * need to negotiate coming back up online. That involves negotiation
  31. * and possible user space interaction. Thus, we defer to a workqueue
  32. * to do all that. By default, we only queue a single packet and drop
  33. * the rest, as potentially the time to go back from idle to normal is
  34. * long.
  35. *
  36. * ROADMAP
  37. *
  38. * i2400m_open Called on ifconfig up
  39. * i2400m_stop Called on ifconfig down
  40. *
  41. * i2400m_hard_start_xmit Called by the network stack to send a packet
  42. * i2400m_net_wake_tx Wake up device from basestation-IDLE & TX
  43. * i2400m_wake_tx_work
  44. * i2400m_cmd_exit_idle
  45. * i2400m_tx
  46. * i2400m_net_tx TX a data frame
  47. * i2400m_tx
  48. *
  49. * i2400m_change_mtu Called on ifconfig mtu XXX
  50. *
  51. * i2400m_tx_timeout Called when the device times out
  52. *
  53. * i2400m_net_rx Called by the RX code when a data frame is
  54. * available (firmware <= 1.3)
  55. * i2400m_net_erx Called by the RX code when a data frame is
  56. * available (firmware >= 1.4).
  57. * i2400m_netdev_setup Called to setup all the netdev stuff from
  58. * alloc_netdev.
  59. */
  60. #include <linux/if_arp.h>
  61. #include <linux/slab.h>
  62. #include <linux/netdevice.h>
  63. #include <linux/ethtool.h>
  64. #include <linux/export.h>
  65. #include "i2400m.h"
  66. #define D_SUBMODULE netdev
  67. #include "debug-levels.h"
  68. enum {
  69. /* netdev interface */
  70. /* 20 secs? yep, this is the maximum timeout that the device
  71. * might take to get out of IDLE / negotiate it with the base
  72. * station. We add 1sec for good measure. */
  73. I2400M_TX_TIMEOUT = 21 * HZ,
  74. /*
  75. * Experimentation has determined that, 20 to be a good value
  76. * for minimizing the jitter in the throughput.
  77. */
  78. I2400M_TX_QLEN = 20,
  79. };
  80. static
  81. int i2400m_open(struct net_device *net_dev)
  82. {
  83. int result;
  84. struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
  85. struct device *dev = i2400m_dev(i2400m);
  86. d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
  87. /* Make sure we wait until init is complete... */
  88. mutex_lock(&i2400m->init_mutex);
  89. if (i2400m->updown)
  90. result = 0;
  91. else
  92. result = -EBUSY;
  93. mutex_unlock(&i2400m->init_mutex);
  94. d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
  95. net_dev, i2400m, result);
  96. return result;
  97. }
  98. static
  99. int i2400m_stop(struct net_device *net_dev)
  100. {
  101. struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
  102. struct device *dev = i2400m_dev(i2400m);
  103. d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
  104. i2400m_net_wake_stop(i2400m);
  105. d_fnend(3, dev, "(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
  106. return 0;
  107. }
  108. /*
  109. * Wake up the device and transmit a held SKB, then restart the net queue
  110. *
  111. * When the device goes into basestation-idle mode, we need to tell it
  112. * to exit that mode; it will negotiate with the base station, user
  113. * space may have to intervene to rehandshake crypto and then tell us
  114. * when it is ready to transmit the packet we have "queued". Still we
  115. * need to give it sometime after it reports being ok.
  116. *
  117. * On error, there is not much we can do. If the error was on TX, we
  118. * still wake the queue up to see if the next packet will be luckier.
  119. *
  120. * If _cmd_exit_idle() fails...well, it could be many things; most
  121. * commonly it is that something else took the device out of IDLE mode
  122. * (for example, the base station). In that case we get an -EILSEQ and
  123. * we are just going to ignore that one. If the device is back to
  124. * connected, then fine -- if it is someother state, the packet will
  125. * be dropped anyway.
  126. */
  127. void i2400m_wake_tx_work(struct work_struct *ws)
  128. {
  129. int result;
  130. struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
  131. struct net_device *net_dev = i2400m->wimax_dev.net_dev;
  132. struct device *dev = i2400m_dev(i2400m);
  133. struct sk_buff *skb;
  134. unsigned long flags;
  135. spin_lock_irqsave(&i2400m->tx_lock, flags);
  136. skb = i2400m->wake_tx_skb;
  137. i2400m->wake_tx_skb = NULL;
  138. spin_unlock_irqrestore(&i2400m->tx_lock, flags);
  139. d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
  140. result = -EINVAL;
  141. if (skb == NULL) {
  142. dev_err(dev, "WAKE&TX: skb disappeared!\n");
  143. goto out_put;
  144. }
  145. /* If we have, somehow, lost the connection after this was
  146. * queued, don't do anything; this might be the device got
  147. * reset or just disconnected. */
  148. if (unlikely(!netif_carrier_ok(net_dev)))
  149. goto out_kfree;
  150. result = i2400m_cmd_exit_idle(i2400m);
  151. if (result == -EILSEQ)
  152. result = 0;
  153. if (result < 0) {
  154. dev_err(dev, "WAKE&TX: device didn't get out of idle: "
  155. "%d - resetting\n", result);
  156. i2400m_reset(i2400m, I2400M_RT_BUS);
  157. goto error;
  158. }
  159. result = wait_event_timeout(i2400m->state_wq,
  160. i2400m->state != I2400M_SS_IDLE,
  161. net_dev->watchdog_timeo - HZ/2);
  162. if (result == 0)
  163. result = -ETIMEDOUT;
  164. if (result < 0) {
  165. dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: "
  166. "%d - resetting\n", result);
  167. i2400m_reset(i2400m, I2400M_RT_BUS);
  168. goto error;
  169. }
  170. msleep(20); /* device still needs some time or it drops it */
  171. result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
  172. error:
  173. netif_wake_queue(net_dev);
  174. out_kfree:
  175. kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */
  176. out_put:
  177. i2400m_put(i2400m);
  178. d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n",
  179. ws, i2400m, skb, result);
  180. }
  181. /*
  182. * Prepare the data payload TX header
  183. *
  184. * The i2400m expects a 4 byte header in front of a data packet.
  185. *
  186. * Because we pretend to be an ethernet device, this packet comes with
  187. * an ethernet header. Pull it and push our header.
  188. */
  189. static
  190. void i2400m_tx_prep_header(struct sk_buff *skb)
  191. {
  192. struct i2400m_pl_data_hdr *pl_hdr;
  193. skb_pull(skb, ETH_HLEN);
  194. pl_hdr = skb_push(skb, sizeof(*pl_hdr));
  195. pl_hdr->reserved = 0;
  196. }
  197. /*
  198. * Cleanup resources acquired during i2400m_net_wake_tx()
  199. *
  200. * This is called by __i2400m_dev_stop and means we have to make sure
  201. * the workqueue is flushed from any pending work.
  202. */
  203. void i2400m_net_wake_stop(struct i2400m *i2400m)
  204. {
  205. struct device *dev = i2400m_dev(i2400m);
  206. struct sk_buff *wake_tx_skb;
  207. unsigned long flags;
  208. d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
  209. /*
  210. * See i2400m_hard_start_xmit(), references are taken there and
  211. * here we release them if the packet was still pending.
  212. */
  213. cancel_work_sync(&i2400m->wake_tx_ws);
  214. spin_lock_irqsave(&i2400m->tx_lock, flags);
  215. wake_tx_skb = i2400m->wake_tx_skb;
  216. i2400m->wake_tx_skb = NULL;
  217. spin_unlock_irqrestore(&i2400m->tx_lock, flags);
  218. if (wake_tx_skb) {
  219. i2400m_put(i2400m);
  220. kfree_skb(wake_tx_skb);
  221. }
  222. d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
  223. }
  224. /*
  225. * TX an skb to an idle device
  226. *
  227. * When the device is in basestation-idle mode, we need to wake it up
  228. * and then TX. So we queue a work_struct for doing so.
  229. *
  230. * We need to get an extra ref for the skb (so it is not dropped), as
  231. * well as be careful not to queue more than one request (won't help
  232. * at all). If more than one request comes or there are errors, we
  233. * just drop the packets (see i2400m_hard_start_xmit()).
  234. */
  235. static
  236. int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
  237. struct sk_buff *skb)
  238. {
  239. int result;
  240. struct device *dev = i2400m_dev(i2400m);
  241. unsigned long flags;
  242. d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
  243. if (net_ratelimit()) {
  244. d_printf(3, dev, "WAKE&NETTX: "
  245. "skb %p sending %d bytes to radio\n",
  246. skb, skb->len);
  247. d_dump(4, dev, skb->data, skb->len);
  248. }
  249. /* We hold a ref count for i2400m and skb, so when
  250. * stopping() the device, we need to cancel that work
  251. * and if pending, release those resources. */
  252. result = 0;
  253. spin_lock_irqsave(&i2400m->tx_lock, flags);
  254. if (!i2400m->wake_tx_skb) {
  255. netif_stop_queue(net_dev);
  256. i2400m_get(i2400m);
  257. i2400m->wake_tx_skb = skb_get(skb); /* transfer ref count */
  258. i2400m_tx_prep_header(skb);
  259. result = schedule_work(&i2400m->wake_tx_ws);
  260. WARN_ON(result == 0);
  261. }
  262. spin_unlock_irqrestore(&i2400m->tx_lock, flags);
  263. if (result == 0) {
  264. /* Yes, this happens even if we stopped the
  265. * queue -- blame the queue disciplines that
  266. * queue without looking -- I guess there is a reason
  267. * for that. */
  268. if (net_ratelimit())
  269. d_printf(1, dev, "NETTX: device exiting idle, "
  270. "dropping skb %p, queue running %d\n",
  271. skb, netif_queue_stopped(net_dev));
  272. result = -EBUSY;
  273. }
  274. d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
  275. return result;
  276. }
  277. /*
  278. * Transmit a packet to the base station on behalf of the network stack.
  279. *
  280. * Returns: 0 if ok, < 0 errno code on error.
  281. *
  282. * We need to pull the ethernet header and add the hardware header,
  283. * which is currently set to all zeroes and reserved.
  284. */
  285. static
  286. int i2400m_net_tx(struct i2400m *i2400m, struct net_device *net_dev,
  287. struct sk_buff *skb)
  288. {
  289. int result;
  290. struct device *dev = i2400m_dev(i2400m);
  291. d_fnstart(3, dev, "(i2400m %p net_dev %p skb %p)\n",
  292. i2400m, net_dev, skb);
  293. /* FIXME: check eth hdr, only IPv4 is routed by the device as of now */
  294. netif_trans_update(net_dev);
  295. i2400m_tx_prep_header(skb);
  296. d_printf(3, dev, "NETTX: skb %p sending %d bytes to radio\n",
  297. skb, skb->len);
  298. d_dump(4, dev, skb->data, skb->len);
  299. result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
  300. d_fnend(3, dev, "(i2400m %p net_dev %p skb %p) = %d\n",
  301. i2400m, net_dev, skb, result);
  302. return result;
  303. }
  304. /*
  305. * Transmit a packet to the base station on behalf of the network stack
  306. *
  307. *
  308. * Returns: NETDEV_TX_OK (always, even in case of error)
  309. *
  310. * In case of error, we just drop it. Reasons:
  311. *
  312. * - we add a hw header to each skb, and if the network stack
  313. * retries, we have no way to know if that skb has it or not.
  314. *
  315. * - network protocols have their own drop-recovery mechanisms
  316. *
  317. * - there is not much else we can do
  318. *
  319. * If the device is idle, we need to wake it up; that is an operation
  320. * that will sleep. See i2400m_net_wake_tx() for details.
  321. */
  322. static
  323. netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,
  324. struct net_device *net_dev)
  325. {
  326. struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
  327. struct device *dev = i2400m_dev(i2400m);
  328. int result = -1;
  329. d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
  330. if (skb_cow_head(skb, 0))
  331. goto drop;
  332. if (i2400m->state == I2400M_SS_IDLE)
  333. result = i2400m_net_wake_tx(i2400m, net_dev, skb);
  334. else
  335. result = i2400m_net_tx(i2400m, net_dev, skb);
  336. if (result < 0) {
  337. drop:
  338. net_dev->stats.tx_dropped++;
  339. } else {
  340. net_dev->stats.tx_packets++;
  341. net_dev->stats.tx_bytes += skb->len;
  342. }
  343. dev_kfree_skb(skb);
  344. d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
  345. return NETDEV_TX_OK;
  346. }
  347. static
  348. void i2400m_tx_timeout(struct net_device *net_dev)
  349. {
  350. /*
  351. * We might want to kick the device
  352. *
  353. * There is not much we can do though, as the device requires
  354. * that we send the data aggregated. By the time we receive
  355. * this, there might be data pending to be sent or not...
  356. */
  357. net_dev->stats.tx_errors++;
  358. }
  359. /*
  360. * Create a fake ethernet header
  361. *
  362. * For emulating an ethernet device, every received IP header has to
  363. * be prefixed with an ethernet header. Fake it with the given
  364. * protocol.
  365. */
  366. static
  367. void i2400m_rx_fake_eth_header(struct net_device *net_dev,
  368. void *_eth_hdr, __be16 protocol)
  369. {
  370. struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
  371. struct ethhdr *eth_hdr = _eth_hdr;
  372. memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
  373. memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
  374. sizeof(eth_hdr->h_source));
  375. eth_hdr->h_proto = protocol;
  376. }
  377. /*
  378. * i2400m_net_rx - pass a network packet to the stack
  379. *
  380. * @i2400m: device instance
  381. * @skb_rx: the skb where the buffer pointed to by @buf is
  382. * @i: 1 if payload is the only one
  383. * @buf: pointer to the buffer containing the data
  384. * @len: buffer's length
  385. *
  386. * This is only used now for the v1.3 firmware. It will be deprecated
  387. * in >= 2.6.31.
  388. *
  389. * Note that due to firmware limitations, we don't have space to add
  390. * an ethernet header, so we need to copy each packet. Firmware
  391. * versions >= v1.4 fix this [see i2400m_net_erx()].
  392. *
  393. * We just clone the skb and set it up so that it's skb->data pointer
  394. * points to "buf" and it's length.
  395. *
  396. * Note that if the payload is the last (or the only one) in a
  397. * multi-payload message, we don't clone the SKB but just reuse it.
  398. *
  399. * This function is normally run from a thread context. However, we
  400. * still use netif_rx() instead of netif_receive_skb() as was
  401. * recommended in the mailing list. Reason is in some stress tests
  402. * when sending/receiving a lot of data we seem to hit a softlock in
  403. * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
  404. * netif_rx() took care of the issue.
  405. *
  406. * This is, of course, still open to do more research on why running
  407. * with netif_receive_skb() hits this softlock. FIXME.
  408. *
  409. * FIXME: currently we don't do any efforts at distinguishing if what
  410. * we got was an IPv4 or IPv6 header, to setup the protocol field
  411. * correctly.
  412. */
  413. void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx,
  414. unsigned i, const void *buf, int buf_len)
  415. {
  416. struct net_device *net_dev = i2400m->wimax_dev.net_dev;
  417. struct device *dev = i2400m_dev(i2400m);
  418. struct sk_buff *skb;
  419. d_fnstart(2, dev, "(i2400m %p buf %p buf_len %d)\n",
  420. i2400m, buf, buf_len);
  421. if (i) {
  422. skb = skb_get(skb_rx);
  423. d_printf(2, dev, "RX: reusing first payload skb %p\n", skb);
  424. skb_pull(skb, buf - (void *) skb->data);
  425. skb_trim(skb, (void *) skb_end_pointer(skb) - buf);
  426. } else {
  427. /* Yes, this is bad -- a lot of overhead -- see
  428. * comments at the top of the file */
  429. skb = __netdev_alloc_skb(net_dev, buf_len, GFP_KERNEL);
  430. if (skb == NULL) {
  431. dev_err(dev, "NETRX: no memory to realloc skb\n");
  432. net_dev->stats.rx_dropped++;
  433. goto error_skb_realloc;
  434. }
  435. skb_put_data(skb, buf, buf_len);
  436. }
  437. i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
  438. skb->data - ETH_HLEN,
  439. cpu_to_be16(ETH_P_IP));
  440. skb_set_mac_header(skb, -ETH_HLEN);
  441. skb->dev = i2400m->wimax_dev.net_dev;
  442. skb->protocol = htons(ETH_P_IP);
  443. net_dev->stats.rx_packets++;
  444. net_dev->stats.rx_bytes += buf_len;
  445. d_printf(3, dev, "NETRX: receiving %d bytes to network stack\n",
  446. buf_len);
  447. d_dump(4, dev, buf, buf_len);
  448. netif_rx_ni(skb); /* see notes in function header */
  449. error_skb_realloc:
  450. d_fnend(2, dev, "(i2400m %p buf %p buf_len %d) = void\n",
  451. i2400m, buf, buf_len);
  452. }
  453. /*
  454. * i2400m_net_erx - pass a network packet to the stack (extended version)
  455. *
  456. * @i2400m: device descriptor
  457. * @skb: the skb where the packet is - the skb should be set to point
  458. * at the IP packet; this function will add ethernet headers if
  459. * needed.
  460. * @cs: packet type
  461. *
  462. * This is only used now for firmware >= v1.4. Note it is quite
  463. * similar to i2400m_net_rx() (used only for v1.3 firmware).
  464. *
  465. * This function is normally run from a thread context. However, we
  466. * still use netif_rx() instead of netif_receive_skb() as was
  467. * recommended in the mailing list. Reason is in some stress tests
  468. * when sending/receiving a lot of data we seem to hit a softlock in
  469. * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
  470. * netif_rx() took care of the issue.
  471. *
  472. * This is, of course, still open to do more research on why running
  473. * with netif_receive_skb() hits this softlock. FIXME.
  474. */
  475. void i2400m_net_erx(struct i2400m *i2400m, struct sk_buff *skb,
  476. enum i2400m_cs cs)
  477. {
  478. struct net_device *net_dev = i2400m->wimax_dev.net_dev;
  479. struct device *dev = i2400m_dev(i2400m);
  480. d_fnstart(2, dev, "(i2400m %p skb %p [%u] cs %d)\n",
  481. i2400m, skb, skb->len, cs);
  482. switch(cs) {
  483. case I2400M_CS_IPV4_0:
  484. case I2400M_CS_IPV4:
  485. i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
  486. skb->data - ETH_HLEN,
  487. cpu_to_be16(ETH_P_IP));
  488. skb_set_mac_header(skb, -ETH_HLEN);
  489. skb->dev = i2400m->wimax_dev.net_dev;
  490. skb->protocol = htons(ETH_P_IP);
  491. net_dev->stats.rx_packets++;
  492. net_dev->stats.rx_bytes += skb->len;
  493. break;
  494. default:
  495. dev_err(dev, "ERX: BUG? CS type %u unsupported\n", cs);
  496. goto error;
  497. }
  498. d_printf(3, dev, "ERX: receiving %d bytes to the network stack\n",
  499. skb->len);
  500. d_dump(4, dev, skb->data, skb->len);
  501. netif_rx_ni(skb); /* see notes in function header */
  502. error:
  503. d_fnend(2, dev, "(i2400m %p skb %p [%u] cs %d) = void\n",
  504. i2400m, skb, skb->len, cs);
  505. }
  506. static const struct net_device_ops i2400m_netdev_ops = {
  507. .ndo_open = i2400m_open,
  508. .ndo_stop = i2400m_stop,
  509. .ndo_start_xmit = i2400m_hard_start_xmit,
  510. .ndo_tx_timeout = i2400m_tx_timeout,
  511. };
  512. static void i2400m_get_drvinfo(struct net_device *net_dev,
  513. struct ethtool_drvinfo *info)
  514. {
  515. struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
  516. strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
  517. strlcpy(info->fw_version, i2400m->fw_name ? : "",
  518. sizeof(info->fw_version));
  519. if (net_dev->dev.parent)
  520. strlcpy(info->bus_info, dev_name(net_dev->dev.parent),
  521. sizeof(info->bus_info));
  522. }
  523. static const struct ethtool_ops i2400m_ethtool_ops = {
  524. .get_drvinfo = i2400m_get_drvinfo,
  525. .get_link = ethtool_op_get_link,
  526. };
  527. /**
  528. * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
  529. *
  530. * Called by alloc_netdev()
  531. */
  532. void i2400m_netdev_setup(struct net_device *net_dev)
  533. {
  534. d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
  535. ether_setup(net_dev);
  536. net_dev->mtu = I2400M_MAX_MTU;
  537. net_dev->min_mtu = 0;
  538. net_dev->max_mtu = I2400M_MAX_MTU;
  539. net_dev->tx_queue_len = I2400M_TX_QLEN;
  540. net_dev->features =
  541. NETIF_F_VLAN_CHALLENGED
  542. | NETIF_F_HIGHDMA;
  543. net_dev->flags =
  544. IFF_NOARP /* i2400m is apure IP device */
  545. & (~IFF_BROADCAST /* i2400m is P2P */
  546. & ~IFF_MULTICAST);
  547. net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
  548. net_dev->netdev_ops = &i2400m_netdev_ops;
  549. net_dev->ethtool_ops = &i2400m_ethtool_ops;
  550. d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
  551. }
  552. EXPORT_SYMBOL_GPL(i2400m_netdev_setup);