netdev.c 18 KB

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