fc3754acc73fbbeee4a92db955209431b4a14f8c
[safe/jmp/linux-2.6] / drivers / net / wimax / i2400m / netdev.c
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/slab.h>
77 #include <linux/netdevice.h>
78 #include <linux/ethtool.h>
79 #include "i2400m.h"
80
81
82 #define D_SUBMODULE netdev
83 #include "debug-levels.h"
84
85 enum {
86 /* netdev interface */
87         /* 20 secs? yep, this is the maximum timeout that the device
88          * might take to get out of IDLE / negotiate it with the base
89          * station. We add 1sec for good measure. */
90         I2400M_TX_TIMEOUT = 21 * HZ,
91         I2400M_TX_QLEN = 5,
92 };
93
94
95 static
96 int i2400m_open(struct net_device *net_dev)
97 {
98         int result;
99         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
100         struct device *dev = i2400m_dev(i2400m);
101
102         d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
103         /* Make sure we wait until init is complete... */
104         mutex_lock(&i2400m->init_mutex);
105         if (i2400m->updown)
106                 result = 0;
107         else
108                 result = -EBUSY;
109         mutex_unlock(&i2400m->init_mutex);
110         d_fnend(3, dev, "(net_dev %p [i2400m %p]) = %d\n",
111                 net_dev, i2400m, result);
112         return result;
113 }
114
115
116 static
117 int i2400m_stop(struct net_device *net_dev)
118 {
119         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
120         struct device *dev = i2400m_dev(i2400m);
121
122         d_fnstart(3, dev, "(net_dev %p [i2400m %p])\n", net_dev, i2400m);
123         i2400m_net_wake_stop(i2400m);
124         d_fnend(3, dev, "(net_dev %p [i2400m %p]) = 0\n", net_dev, i2400m);
125         return 0;
126 }
127
128
129 /*
130  * Wake up the device and transmit a held SKB, then restart the net queue
131  *
132  * When the device goes into basestation-idle mode, we need to tell it
133  * to exit that mode; it will negotiate with the base station, user
134  * space may have to intervene to rehandshake crypto and then tell us
135  * when it is ready to transmit the packet we have "queued". Still we
136  * need to give it sometime after it reports being ok.
137  *
138  * On error, there is not much we can do. If the error was on TX, we
139  * still wake the queue up to see if the next packet will be luckier.
140  *
141  * If _cmd_exit_idle() fails...well, it could be many things; most
142  * commonly it is that something else took the device out of IDLE mode
143  * (for example, the base station). In that case we get an -EILSEQ and
144  * we are just going to ignore that one. If the device is back to
145  * connected, then fine -- if it is someother state, the packet will
146  * be dropped anyway.
147  */
148 void i2400m_wake_tx_work(struct work_struct *ws)
149 {
150         int result;
151         struct i2400m *i2400m = container_of(ws, struct i2400m, wake_tx_ws);
152         struct net_device *net_dev = i2400m->wimax_dev.net_dev;
153         struct device *dev = i2400m_dev(i2400m);
154         struct sk_buff *skb = i2400m->wake_tx_skb;
155         unsigned long flags;
156
157         spin_lock_irqsave(&i2400m->tx_lock, flags);
158         skb = i2400m->wake_tx_skb;
159         i2400m->wake_tx_skb = NULL;
160         spin_unlock_irqrestore(&i2400m->tx_lock, flags);
161
162         d_fnstart(3, dev, "(ws %p i2400m %p skb %p)\n", ws, i2400m, skb);
163         result = -EINVAL;
164         if (skb == NULL) {
165                 dev_err(dev, "WAKE&TX: skb dissapeared!\n");
166                 goto out_put;
167         }
168         /* If we have, somehow, lost the connection after this was
169          * queued, don't do anything; this might be the device got
170          * reset or just disconnected. */
171         if (unlikely(!netif_carrier_ok(net_dev)))
172                 goto out_kfree;
173         result = i2400m_cmd_exit_idle(i2400m);
174         if (result == -EILSEQ)
175                 result = 0;
176         if (result < 0) {
177                 dev_err(dev, "WAKE&TX: device didn't get out of idle: "
178                         "%d - resetting\n", result);
179                 i2400m_reset(i2400m, I2400M_RT_BUS);
180                 goto error;
181         }
182         result = wait_event_timeout(i2400m->state_wq,
183                                     i2400m->state != I2400M_SS_IDLE,
184                                     net_dev->watchdog_timeo - HZ/2);
185         if (result == 0)
186                 result = -ETIMEDOUT;
187         if (result < 0) {
188                 dev_err(dev, "WAKE&TX: error waiting for device to exit IDLE: "
189                         "%d - resetting\n", result);
190                 i2400m_reset(i2400m, I2400M_RT_BUS);
191                 goto error;
192         }
193         msleep(20);     /* device still needs some time or it drops it */
194         result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
195 error:
196         netif_wake_queue(net_dev);
197 out_kfree:
198         kfree_skb(skb); /* refcount transferred by _hard_start_xmit() */
199 out_put:
200         i2400m_put(i2400m);
201         d_fnend(3, dev, "(ws %p i2400m %p skb %p) = void [%d]\n",
202                 ws, i2400m, skb, result);
203 }
204
205
206 /*
207  * Prepare the data payload TX header
208  *
209  * The i2400m expects a 4 byte header in front of a data packet.
210  *
211  * Because we pretend to be an ethernet device, this packet comes with
212  * an ethernet header. Pull it and push our header.
213  */
214 static
215 void i2400m_tx_prep_header(struct sk_buff *skb)
216 {
217         struct i2400m_pl_data_hdr *pl_hdr;
218         skb_pull(skb, ETH_HLEN);
219         pl_hdr = (struct i2400m_pl_data_hdr *) skb_push(skb, sizeof(*pl_hdr));
220         pl_hdr->reserved = 0;
221 }
222
223
224
225 /*
226  * Cleanup resources acquired during i2400m_net_wake_tx()
227  *
228  * This is called by __i2400m_dev_stop and means we have to make sure
229  * the workqueue is flushed from any pending work.
230  */
231 void i2400m_net_wake_stop(struct i2400m *i2400m)
232 {
233         struct device *dev = i2400m_dev(i2400m);
234
235         d_fnstart(3, dev, "(i2400m %p)\n", i2400m);
236         /* See i2400m_hard_start_xmit(), references are taken there
237          * and here we release them if the work was still
238          * pending. Note we can't differentiate work not pending vs
239          * never scheduled, so the NULL check does that. */
240         if (cancel_work_sync(&i2400m->wake_tx_ws) == 0
241             && i2400m->wake_tx_skb != NULL) {
242                 unsigned long flags;
243                 struct sk_buff *wake_tx_skb;
244                 spin_lock_irqsave(&i2400m->tx_lock, flags);
245                 wake_tx_skb = i2400m->wake_tx_skb;      /* compat help */
246                 i2400m->wake_tx_skb = NULL;     /* compat help */
247                 spin_unlock_irqrestore(&i2400m->tx_lock, flags);
248                 i2400m_put(i2400m);
249                 kfree_skb(wake_tx_skb);
250         }
251         d_fnend(3, dev, "(i2400m %p) = void\n", i2400m);
252         return;
253 }
254
255
256 /*
257  * TX an skb to an idle device
258  *
259  * When the device is in basestation-idle mode, we need to wake it up
260  * and then TX. So we queue a work_struct for doing so.
261  *
262  * We need to get an extra ref for the skb (so it is not dropped), as
263  * well as be careful not to queue more than one request (won't help
264  * at all). If more than one request comes or there are errors, we
265  * just drop the packets (see i2400m_hard_start_xmit()).
266  */
267 static
268 int i2400m_net_wake_tx(struct i2400m *i2400m, struct net_device *net_dev,
269                        struct sk_buff *skb)
270 {
271         int result;
272         struct device *dev = i2400m_dev(i2400m);
273         unsigned long flags;
274
275         d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
276         if (net_ratelimit()) {
277                 d_printf(3, dev, "WAKE&NETTX: "
278                          "skb %p sending %d bytes to radio\n",
279                          skb, skb->len);
280                 d_dump(4, dev, skb->data, skb->len);
281         }
282         /* We hold a ref count for i2400m and skb, so when
283          * stopping() the device, we need to cancel that work
284          * and if pending, release those resources. */
285         result = 0;
286         spin_lock_irqsave(&i2400m->tx_lock, flags);
287         if (!work_pending(&i2400m->wake_tx_ws)) {
288                 netif_stop_queue(net_dev);
289                 i2400m_get(i2400m);
290                 i2400m->wake_tx_skb = skb_get(skb);     /* transfer ref count */
291                 i2400m_tx_prep_header(skb);
292                 result = schedule_work(&i2400m->wake_tx_ws);
293                 WARN_ON(result == 0);
294         }
295         spin_unlock_irqrestore(&i2400m->tx_lock, flags);
296         if (result == 0) {
297                 /* Yes, this happens even if we stopped the
298                  * queue -- blame the queue disciplines that
299                  * queue without looking -- I guess there is a reason
300                  * for that. */
301                 if (net_ratelimit())
302                         d_printf(1, dev, "NETTX: device exiting idle, "
303                                  "dropping skb %p, queue running %d\n",
304                                  skb, netif_queue_stopped(net_dev));
305                 result = -EBUSY;
306         }
307         d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
308         return result;
309 }
310
311
312 /*
313  * Transmit a packet to the base station on behalf of the network stack.
314  *
315  * Returns: 0 if ok, < 0 errno code on error.
316  *
317  * We need to pull the ethernet header and add the hardware header,
318  * which is currently set to all zeroes and reserved.
319  */
320 static
321 int i2400m_net_tx(struct i2400m *i2400m, struct net_device *net_dev,
322                   struct sk_buff *skb)
323 {
324         int result;
325         struct device *dev = i2400m_dev(i2400m);
326
327         d_fnstart(3, dev, "(i2400m %p net_dev %p skb %p)\n",
328                   i2400m, net_dev, skb);
329         /* FIXME: check eth hdr, only IPv4 is routed by the device as of now */
330         net_dev->trans_start = jiffies;
331         i2400m_tx_prep_header(skb);
332         d_printf(3, dev, "NETTX: skb %p sending %d bytes to radio\n",
333                  skb, skb->len);
334         d_dump(4, dev, skb->data, skb->len);
335         result = i2400m_tx(i2400m, skb->data, skb->len, I2400M_PT_DATA);
336         d_fnend(3, dev, "(i2400m %p net_dev %p skb %p) = %d\n",
337                 i2400m, net_dev, skb, result);
338         return result;
339 }
340
341
342 /*
343  * Transmit a packet to the base station on behalf of the network stack
344  *
345  *
346  * Returns: NETDEV_TX_OK (always, even in case of error)
347  *
348  * In case of error, we just drop it. Reasons:
349  *
350  *  - we add a hw header to each skb, and if the network stack
351  *    retries, we have no way to know if that skb has it or not.
352  *
353  *  - network protocols have their own drop-recovery mechanisms
354  *
355  *  - there is not much else we can do
356  *
357  * If the device is idle, we need to wake it up; that is an operation
358  * that will sleep. See i2400m_net_wake_tx() for details.
359  */
360 static
361 netdev_tx_t i2400m_hard_start_xmit(struct sk_buff *skb,
362                                          struct net_device *net_dev)
363 {
364         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
365         struct device *dev = i2400m_dev(i2400m);
366         int result;
367
368         d_fnstart(3, dev, "(skb %p net_dev %p)\n", skb, net_dev);
369         if (skb_header_cloned(skb)) {
370                 /*
371                  * Make tcpdump/wireshark happy -- if they are
372                  * running, the skb is cloned and we will overwrite
373                  * the mac fields in i2400m_tx_prep_header. Expand
374                  * seems to fix this...
375                  */
376                 result = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
377                 if (result) {
378                         result = NETDEV_TX_BUSY;
379                         goto error_expand;
380                 }
381         }
382
383         if (i2400m->state == I2400M_SS_IDLE)
384                 result = i2400m_net_wake_tx(i2400m, net_dev, skb);
385         else
386                 result = i2400m_net_tx(i2400m, net_dev, skb);
387         if (result <  0)
388                 net_dev->stats.tx_dropped++;
389         else {
390                 net_dev->stats.tx_packets++;
391                 net_dev->stats.tx_bytes += skb->len;
392         }
393         result = NETDEV_TX_OK;
394 error_expand:
395         kfree_skb(skb);
396         d_fnend(3, dev, "(skb %p net_dev %p) = %d\n", skb, net_dev, result);
397         return result;
398 }
399
400
401 static
402 int i2400m_change_mtu(struct net_device *net_dev, int new_mtu)
403 {
404         int result;
405         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
406         struct device *dev = i2400m_dev(i2400m);
407
408         if (new_mtu >= I2400M_MAX_MTU) {
409                 dev_err(dev, "Cannot change MTU to %d (max is %d)\n",
410                         new_mtu, I2400M_MAX_MTU);
411                 result = -EINVAL;
412         } else {
413                 net_dev->mtu = new_mtu;
414                 result = 0;
415         }
416         return result;
417 }
418
419
420 static
421 void i2400m_tx_timeout(struct net_device *net_dev)
422 {
423         /*
424          * We might want to kick the device
425          *
426          * There is not much we can do though, as the device requires
427          * that we send the data aggregated. By the time we receive
428          * this, there might be data pending to be sent or not...
429          */
430         net_dev->stats.tx_errors++;
431         return;
432 }
433
434
435 /*
436  * Create a fake ethernet header
437  *
438  * For emulating an ethernet device, every received IP header has to
439  * be prefixed with an ethernet header. Fake it with the given
440  * protocol.
441  */
442 static
443 void i2400m_rx_fake_eth_header(struct net_device *net_dev,
444                                void *_eth_hdr, __be16 protocol)
445 {
446         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
447         struct ethhdr *eth_hdr = _eth_hdr;
448
449         memcpy(eth_hdr->h_dest, net_dev->dev_addr, sizeof(eth_hdr->h_dest));
450         memcpy(eth_hdr->h_source, i2400m->src_mac_addr,
451                sizeof(eth_hdr->h_source));
452         eth_hdr->h_proto = protocol;
453 }
454
455
456 /*
457  * i2400m_net_rx - pass a network packet to the stack
458  *
459  * @i2400m: device instance
460  * @skb_rx: the skb where the buffer pointed to by @buf is
461  * @i: 1 if payload is the only one
462  * @buf: pointer to the buffer containing the data
463  * @len: buffer's length
464  *
465  * This is only used now for the v1.3 firmware. It will be deprecated
466  * in >= 2.6.31.
467  *
468  * Note that due to firmware limitations, we don't have space to add
469  * an ethernet header, so we need to copy each packet. Firmware
470  * versions >= v1.4 fix this [see i2400m_net_erx()].
471  *
472  * We just clone the skb and set it up so that it's skb->data pointer
473  * points to "buf" and it's length.
474  *
475  * Note that if the payload is the last (or the only one) in a
476  * multi-payload message, we don't clone the SKB but just reuse it.
477  *
478  * This function is normally run from a thread context. However, we
479  * still use netif_rx() instead of netif_receive_skb() as was
480  * recommended in the mailing list. Reason is in some stress tests
481  * when sending/receiving a lot of data we seem to hit a softlock in
482  * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
483  * netif_rx() took care of the issue.
484  *
485  * This is, of course, still open to do more research on why running
486  * with netif_receive_skb() hits this softlock. FIXME.
487  *
488  * FIXME: currently we don't do any efforts at distinguishing if what
489  * we got was an IPv4 or IPv6 header, to setup the protocol field
490  * correctly.
491  */
492 void i2400m_net_rx(struct i2400m *i2400m, struct sk_buff *skb_rx,
493                    unsigned i, const void *buf, int buf_len)
494 {
495         struct net_device *net_dev = i2400m->wimax_dev.net_dev;
496         struct device *dev = i2400m_dev(i2400m);
497         struct sk_buff *skb;
498
499         d_fnstart(2, dev, "(i2400m %p buf %p buf_len %d)\n",
500                   i2400m, buf, buf_len);
501         if (i) {
502                 skb = skb_get(skb_rx);
503                 d_printf(2, dev, "RX: reusing first payload skb %p\n", skb);
504                 skb_pull(skb, buf - (void *) skb->data);
505                 skb_trim(skb, (void *) skb_end_pointer(skb) - buf);
506         } else {
507                 /* Yes, this is bad -- a lot of overhead -- see
508                  * comments at the top of the file */
509                 skb = __netdev_alloc_skb(net_dev, buf_len, GFP_KERNEL);
510                 if (skb == NULL) {
511                         dev_err(dev, "NETRX: no memory to realloc skb\n");
512                         net_dev->stats.rx_dropped++;
513                         goto error_skb_realloc;
514                 }
515                 memcpy(skb_put(skb, buf_len), buf, buf_len);
516         }
517         i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
518                                   skb->data - ETH_HLEN,
519                                   cpu_to_be16(ETH_P_IP));
520         skb_set_mac_header(skb, -ETH_HLEN);
521         skb->dev = i2400m->wimax_dev.net_dev;
522         skb->protocol = htons(ETH_P_IP);
523         net_dev->stats.rx_packets++;
524         net_dev->stats.rx_bytes += buf_len;
525         d_printf(3, dev, "NETRX: receiving %d bytes to network stack\n",
526                 buf_len);
527         d_dump(4, dev, buf, buf_len);
528         netif_rx_ni(skb);       /* see notes in function header */
529 error_skb_realloc:
530         d_fnend(2, dev, "(i2400m %p buf %p buf_len %d) = void\n",
531                 i2400m, buf, buf_len);
532 }
533
534
535 /*
536  * i2400m_net_erx - pass a network packet to the stack (extended version)
537  *
538  * @i2400m: device descriptor
539  * @skb: the skb where the packet is - the skb should be set to point
540  *     at the IP packet; this function will add ethernet headers if
541  *     needed.
542  * @cs: packet type
543  *
544  * This is only used now for firmware >= v1.4. Note it is quite
545  * similar to i2400m_net_rx() (used only for v1.3 firmware).
546  *
547  * This function is normally run from a thread context. However, we
548  * still use netif_rx() instead of netif_receive_skb() as was
549  * recommended in the mailing list. Reason is in some stress tests
550  * when sending/receiving a lot of data we seem to hit a softlock in
551  * the kernel's TCP implementation [aroudn tcp_delay_timer()]. Using
552  * netif_rx() took care of the issue.
553  *
554  * This is, of course, still open to do more research on why running
555  * with netif_receive_skb() hits this softlock. FIXME.
556  */
557 void i2400m_net_erx(struct i2400m *i2400m, struct sk_buff *skb,
558                     enum i2400m_cs cs)
559 {
560         struct net_device *net_dev = i2400m->wimax_dev.net_dev;
561         struct device *dev = i2400m_dev(i2400m);
562         int protocol;
563
564         d_fnstart(2, dev, "(i2400m %p skb %p [%u] cs %d)\n",
565                   i2400m, skb, skb->len, cs);
566         switch(cs) {
567         case I2400M_CS_IPV4_0:
568         case I2400M_CS_IPV4:
569                 protocol = ETH_P_IP;
570                 i2400m_rx_fake_eth_header(i2400m->wimax_dev.net_dev,
571                                           skb->data - ETH_HLEN,
572                                           cpu_to_be16(ETH_P_IP));
573                 skb_set_mac_header(skb, -ETH_HLEN);
574                 skb->dev = i2400m->wimax_dev.net_dev;
575                 skb->protocol = htons(ETH_P_IP);
576                 net_dev->stats.rx_packets++;
577                 net_dev->stats.rx_bytes += skb->len;
578                 break;
579         default:
580                 dev_err(dev, "ERX: BUG? CS type %u unsupported\n", cs);
581                 goto error;
582
583         }
584         d_printf(3, dev, "ERX: receiving %d bytes to the network stack\n",
585                  skb->len);
586         d_dump(4, dev, skb->data, skb->len);
587         netif_rx_ni(skb);       /* see notes in function header */
588 error:
589         d_fnend(2, dev, "(i2400m %p skb %p [%u] cs %d) = void\n",
590                 i2400m, skb, skb->len, cs);
591 }
592
593 static const struct net_device_ops i2400m_netdev_ops = {
594         .ndo_open = i2400m_open,
595         .ndo_stop = i2400m_stop,
596         .ndo_start_xmit = i2400m_hard_start_xmit,
597         .ndo_tx_timeout = i2400m_tx_timeout,
598         .ndo_change_mtu = i2400m_change_mtu,
599 };
600
601 static void i2400m_get_drvinfo(struct net_device *net_dev,
602                                struct ethtool_drvinfo *info)
603 {
604         struct i2400m *i2400m = net_dev_to_i2400m(net_dev);
605
606         strncpy(info->driver, KBUILD_MODNAME, sizeof(info->driver) - 1);
607         strncpy(info->fw_version, i2400m->fw_name, sizeof(info->fw_version) - 1);
608         if (net_dev->dev.parent)
609                 strncpy(info->bus_info, dev_name(net_dev->dev.parent),
610                         sizeof(info->bus_info) - 1);
611 }
612
613 static const struct ethtool_ops i2400m_ethtool_ops = {
614         .get_drvinfo = i2400m_get_drvinfo,
615         .get_link = ethtool_op_get_link,
616 };
617
618 /**
619  * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data
620  *
621  * Called by alloc_netdev()
622  */
623 void i2400m_netdev_setup(struct net_device *net_dev)
624 {
625         d_fnstart(3, NULL, "(net_dev %p)\n", net_dev);
626         ether_setup(net_dev);
627         net_dev->mtu = I2400M_MAX_MTU;
628         net_dev->tx_queue_len = I2400M_TX_QLEN;
629         net_dev->features =
630                   NETIF_F_VLAN_CHALLENGED
631                 | NETIF_F_HIGHDMA;
632         net_dev->flags =
633                 IFF_NOARP               /* i2400m is apure IP device */
634                 & (~IFF_BROADCAST       /* i2400m is P2P */
635                    & ~IFF_MULTICAST);
636         net_dev->watchdog_timeo = I2400M_TX_TIMEOUT;
637         net_dev->netdev_ops = &i2400m_netdev_ops;
638         net_dev->ethtool_ops = &i2400m_ethtool_ops;
639         d_fnend(3, NULL, "(net_dev %p) = void\n", net_dev);
640 }
641 EXPORT_SYMBOL_GPL(i2400m_netdev_setup);
642