58cae6e6a59cb1e43b55a504849ca1949ef12ff8
[deliverable/linux.git] / drivers / net / enic / enic_main.c
1 /*
2 * Copyright 2008 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4 *
5 * This program is free software; you may redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
10 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
11 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
12 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
13 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
14 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
15 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16 * SOFTWARE.
17 *
18 */
19
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/string.h>
23 #include <linux/errno.h>
24 #include <linux/types.h>
25 #include <linux/init.h>
26 #include <linux/workqueue.h>
27 #include <linux/pci.h>
28 #include <linux/netdevice.h>
29 #include <linux/etherdevice.h>
30 #include <linux/if_ether.h>
31 #include <linux/if_vlan.h>
32 #include <linux/ethtool.h>
33 #include <linux/in.h>
34 #include <linux/ip.h>
35 #include <linux/ipv6.h>
36 #include <linux/tcp.h>
37 #include <net/ip6_checksum.h>
38
39 #include "cq_enet_desc.h"
40 #include "vnic_dev.h"
41 #include "vnic_intr.h"
42 #include "vnic_stats.h"
43 #include "enic_res.h"
44 #include "enic.h"
45
46 #define ENIC_NOTIFY_TIMER_PERIOD (2 * HZ)
47
48 /* Supported devices */
49 static struct pci_device_id enic_id_table[] = {
50 { PCI_VDEVICE(CISCO, 0x0043) },
51 { 0, } /* end of table */
52 };
53
54 MODULE_DESCRIPTION(DRV_DESCRIPTION);
55 MODULE_AUTHOR("Scott Feldman <scofeldm@cisco.com>");
56 MODULE_LICENSE("GPL");
57 MODULE_VERSION(DRV_VERSION);
58 MODULE_DEVICE_TABLE(pci, enic_id_table);
59
60 struct enic_stat {
61 char name[ETH_GSTRING_LEN];
62 unsigned int offset;
63 };
64
65 #define ENIC_TX_STAT(stat) \
66 { .name = #stat, .offset = offsetof(struct vnic_tx_stats, stat) / 8 }
67 #define ENIC_RX_STAT(stat) \
68 { .name = #stat, .offset = offsetof(struct vnic_rx_stats, stat) / 8 }
69
70 static const struct enic_stat enic_tx_stats[] = {
71 ENIC_TX_STAT(tx_frames_ok),
72 ENIC_TX_STAT(tx_unicast_frames_ok),
73 ENIC_TX_STAT(tx_multicast_frames_ok),
74 ENIC_TX_STAT(tx_broadcast_frames_ok),
75 ENIC_TX_STAT(tx_bytes_ok),
76 ENIC_TX_STAT(tx_unicast_bytes_ok),
77 ENIC_TX_STAT(tx_multicast_bytes_ok),
78 ENIC_TX_STAT(tx_broadcast_bytes_ok),
79 ENIC_TX_STAT(tx_drops),
80 ENIC_TX_STAT(tx_errors),
81 ENIC_TX_STAT(tx_tso),
82 };
83
84 static const struct enic_stat enic_rx_stats[] = {
85 ENIC_RX_STAT(rx_frames_ok),
86 ENIC_RX_STAT(rx_frames_total),
87 ENIC_RX_STAT(rx_unicast_frames_ok),
88 ENIC_RX_STAT(rx_multicast_frames_ok),
89 ENIC_RX_STAT(rx_broadcast_frames_ok),
90 ENIC_RX_STAT(rx_bytes_ok),
91 ENIC_RX_STAT(rx_unicast_bytes_ok),
92 ENIC_RX_STAT(rx_multicast_bytes_ok),
93 ENIC_RX_STAT(rx_broadcast_bytes_ok),
94 ENIC_RX_STAT(rx_drop),
95 ENIC_RX_STAT(rx_no_bufs),
96 ENIC_RX_STAT(rx_errors),
97 ENIC_RX_STAT(rx_rss),
98 ENIC_RX_STAT(rx_crc_errors),
99 ENIC_RX_STAT(rx_frames_64),
100 ENIC_RX_STAT(rx_frames_127),
101 ENIC_RX_STAT(rx_frames_255),
102 ENIC_RX_STAT(rx_frames_511),
103 ENIC_RX_STAT(rx_frames_1023),
104 ENIC_RX_STAT(rx_frames_1518),
105 ENIC_RX_STAT(rx_frames_to_max),
106 };
107
108 static const unsigned int enic_n_tx_stats = ARRAY_SIZE(enic_tx_stats);
109 static const unsigned int enic_n_rx_stats = ARRAY_SIZE(enic_rx_stats);
110
111 static int enic_get_settings(struct net_device *netdev,
112 struct ethtool_cmd *ecmd)
113 {
114 struct enic *enic = netdev_priv(netdev);
115
116 ecmd->supported = (SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE);
117 ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_FIBRE);
118 ecmd->port = PORT_FIBRE;
119 ecmd->transceiver = XCVR_EXTERNAL;
120
121 if (netif_carrier_ok(netdev)) {
122 ecmd->speed = vnic_dev_port_speed(enic->vdev);
123 ecmd->duplex = DUPLEX_FULL;
124 } else {
125 ecmd->speed = -1;
126 ecmd->duplex = -1;
127 }
128
129 ecmd->autoneg = AUTONEG_DISABLE;
130
131 return 0;
132 }
133
134 static void enic_get_drvinfo(struct net_device *netdev,
135 struct ethtool_drvinfo *drvinfo)
136 {
137 struct enic *enic = netdev_priv(netdev);
138 struct vnic_devcmd_fw_info *fw_info;
139
140 spin_lock(&enic->devcmd_lock);
141 vnic_dev_fw_info(enic->vdev, &fw_info);
142 spin_unlock(&enic->devcmd_lock);
143
144 strncpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver));
145 strncpy(drvinfo->version, DRV_VERSION, sizeof(drvinfo->version));
146 strncpy(drvinfo->fw_version, fw_info->fw_version,
147 sizeof(drvinfo->fw_version));
148 strncpy(drvinfo->bus_info, pci_name(enic->pdev),
149 sizeof(drvinfo->bus_info));
150 }
151
152 static void enic_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
153 {
154 unsigned int i;
155
156 switch (stringset) {
157 case ETH_SS_STATS:
158 for (i = 0; i < enic_n_tx_stats; i++) {
159 memcpy(data, enic_tx_stats[i].name, ETH_GSTRING_LEN);
160 data += ETH_GSTRING_LEN;
161 }
162 for (i = 0; i < enic_n_rx_stats; i++) {
163 memcpy(data, enic_rx_stats[i].name, ETH_GSTRING_LEN);
164 data += ETH_GSTRING_LEN;
165 }
166 break;
167 }
168 }
169
170 static int enic_get_sset_count(struct net_device *netdev, int sset)
171 {
172 switch (sset) {
173 case ETH_SS_STATS:
174 return enic_n_tx_stats + enic_n_rx_stats;
175 default:
176 return -EOPNOTSUPP;
177 }
178 }
179
180 static void enic_get_ethtool_stats(struct net_device *netdev,
181 struct ethtool_stats *stats, u64 *data)
182 {
183 struct enic *enic = netdev_priv(netdev);
184 struct vnic_stats *vstats;
185 unsigned int i;
186
187 spin_lock(&enic->devcmd_lock);
188 vnic_dev_stats_dump(enic->vdev, &vstats);
189 spin_unlock(&enic->devcmd_lock);
190
191 for (i = 0; i < enic_n_tx_stats; i++)
192 *(data++) = ((u64 *)&vstats->tx)[enic_tx_stats[i].offset];
193 for (i = 0; i < enic_n_rx_stats; i++)
194 *(data++) = ((u64 *)&vstats->rx)[enic_rx_stats[i].offset];
195 }
196
197 static u32 enic_get_rx_csum(struct net_device *netdev)
198 {
199 struct enic *enic = netdev_priv(netdev);
200 return enic->csum_rx_enabled;
201 }
202
203 static int enic_set_rx_csum(struct net_device *netdev, u32 data)
204 {
205 struct enic *enic = netdev_priv(netdev);
206
207 if (data && !ENIC_SETTING(enic, RXCSUM))
208 return -EINVAL;
209
210 enic->csum_rx_enabled = !!data;
211
212 return 0;
213 }
214
215 static int enic_set_tx_csum(struct net_device *netdev, u32 data)
216 {
217 struct enic *enic = netdev_priv(netdev);
218
219 if (data && !ENIC_SETTING(enic, TXCSUM))
220 return -EINVAL;
221
222 if (data)
223 netdev->features |= NETIF_F_HW_CSUM;
224 else
225 netdev->features &= ~NETIF_F_HW_CSUM;
226
227 return 0;
228 }
229
230 static int enic_set_tso(struct net_device *netdev, u32 data)
231 {
232 struct enic *enic = netdev_priv(netdev);
233
234 if (data && !ENIC_SETTING(enic, TSO))
235 return -EINVAL;
236
237 if (data)
238 netdev->features |=
239 NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN;
240 else
241 netdev->features &=
242 ~(NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN);
243
244 return 0;
245 }
246
247 static u32 enic_get_msglevel(struct net_device *netdev)
248 {
249 struct enic *enic = netdev_priv(netdev);
250 return enic->msg_enable;
251 }
252
253 static void enic_set_msglevel(struct net_device *netdev, u32 value)
254 {
255 struct enic *enic = netdev_priv(netdev);
256 enic->msg_enable = value;
257 }
258
259 static const struct ethtool_ops enic_ethtool_ops = {
260 .get_settings = enic_get_settings,
261 .get_drvinfo = enic_get_drvinfo,
262 .get_msglevel = enic_get_msglevel,
263 .set_msglevel = enic_set_msglevel,
264 .get_link = ethtool_op_get_link,
265 .get_strings = enic_get_strings,
266 .get_sset_count = enic_get_sset_count,
267 .get_ethtool_stats = enic_get_ethtool_stats,
268 .get_rx_csum = enic_get_rx_csum,
269 .set_rx_csum = enic_set_rx_csum,
270 .get_tx_csum = ethtool_op_get_tx_csum,
271 .set_tx_csum = enic_set_tx_csum,
272 .get_sg = ethtool_op_get_sg,
273 .set_sg = ethtool_op_set_sg,
274 .get_tso = ethtool_op_get_tso,
275 .set_tso = enic_set_tso,
276 .get_flags = ethtool_op_get_flags,
277 .set_flags = ethtool_op_set_flags,
278 };
279
280 static void enic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
281 {
282 struct enic *enic = vnic_dev_priv(wq->vdev);
283
284 if (buf->sop)
285 pci_unmap_single(enic->pdev, buf->dma_addr,
286 buf->len, PCI_DMA_TODEVICE);
287 else
288 pci_unmap_page(enic->pdev, buf->dma_addr,
289 buf->len, PCI_DMA_TODEVICE);
290
291 if (buf->os_buf)
292 dev_kfree_skb_any(buf->os_buf);
293 }
294
295 static void enic_wq_free_buf(struct vnic_wq *wq,
296 struct cq_desc *cq_desc, struct vnic_wq_buf *buf, void *opaque)
297 {
298 enic_free_wq_buf(wq, buf);
299 }
300
301 static int enic_wq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc,
302 u8 type, u16 q_number, u16 completed_index, void *opaque)
303 {
304 struct enic *enic = vnic_dev_priv(vdev);
305
306 spin_lock(&enic->wq_lock[q_number]);
307
308 vnic_wq_service(&enic->wq[q_number], cq_desc,
309 completed_index, enic_wq_free_buf,
310 opaque);
311
312 if (netif_queue_stopped(enic->netdev) &&
313 vnic_wq_desc_avail(&enic->wq[q_number]) >= MAX_SKB_FRAGS + 1)
314 netif_wake_queue(enic->netdev);
315
316 spin_unlock(&enic->wq_lock[q_number]);
317
318 return 0;
319 }
320
321 static void enic_log_q_error(struct enic *enic)
322 {
323 unsigned int i;
324 u32 error_status;
325
326 for (i = 0; i < enic->wq_count; i++) {
327 error_status = vnic_wq_error_status(&enic->wq[i]);
328 if (error_status)
329 printk(KERN_ERR PFX "%s: WQ[%d] error_status %d\n",
330 enic->netdev->name, i, error_status);
331 }
332
333 for (i = 0; i < enic->rq_count; i++) {
334 error_status = vnic_rq_error_status(&enic->rq[i]);
335 if (error_status)
336 printk(KERN_ERR PFX "%s: RQ[%d] error_status %d\n",
337 enic->netdev->name, i, error_status);
338 }
339 }
340
341 static void enic_link_check(struct enic *enic)
342 {
343 int link_status = vnic_dev_link_status(enic->vdev);
344 int carrier_ok = netif_carrier_ok(enic->netdev);
345
346 if (link_status && !carrier_ok) {
347 printk(KERN_INFO PFX "%s: Link UP\n", enic->netdev->name);
348 netif_carrier_on(enic->netdev);
349 } else if (!link_status && carrier_ok) {
350 printk(KERN_INFO PFX "%s: Link DOWN\n", enic->netdev->name);
351 netif_carrier_off(enic->netdev);
352 }
353 }
354
355 static void enic_mtu_check(struct enic *enic)
356 {
357 u32 mtu = vnic_dev_mtu(enic->vdev);
358
359 if (mtu != enic->port_mtu) {
360 if (mtu < enic->netdev->mtu)
361 printk(KERN_WARNING PFX
362 "%s: interface MTU (%d) set higher "
363 "than switch port MTU (%d)\n",
364 enic->netdev->name, enic->netdev->mtu, mtu);
365 enic->port_mtu = mtu;
366 }
367 }
368
369 static void enic_msglvl_check(struct enic *enic)
370 {
371 u32 msg_enable = vnic_dev_msg_lvl(enic->vdev);
372
373 if (msg_enable != enic->msg_enable) {
374 printk(KERN_INFO PFX "%s: msg lvl changed from 0x%x to 0x%x\n",
375 enic->netdev->name, enic->msg_enable, msg_enable);
376 enic->msg_enable = msg_enable;
377 }
378 }
379
380 static void enic_notify_check(struct enic *enic)
381 {
382 enic_msglvl_check(enic);
383 enic_mtu_check(enic);
384 enic_link_check(enic);
385 }
386
387 #define ENIC_TEST_INTR(pba, i) (pba & (1 << i))
388
389 static irqreturn_t enic_isr_legacy(int irq, void *data)
390 {
391 struct net_device *netdev = data;
392 struct enic *enic = netdev_priv(netdev);
393 u32 pba;
394
395 vnic_intr_mask(&enic->intr[ENIC_INTX_WQ_RQ]);
396
397 pba = vnic_intr_legacy_pba(enic->legacy_pba);
398 if (!pba) {
399 vnic_intr_unmask(&enic->intr[ENIC_INTX_WQ_RQ]);
400 return IRQ_NONE; /* not our interrupt */
401 }
402
403 if (ENIC_TEST_INTR(pba, ENIC_INTX_NOTIFY)) {
404 vnic_intr_return_all_credits(&enic->intr[ENIC_INTX_NOTIFY]);
405 enic_notify_check(enic);
406 }
407
408 if (ENIC_TEST_INTR(pba, ENIC_INTX_ERR)) {
409 vnic_intr_return_all_credits(&enic->intr[ENIC_INTX_ERR]);
410 enic_log_q_error(enic);
411 /* schedule recovery from WQ/RQ error */
412 schedule_work(&enic->reset);
413 return IRQ_HANDLED;
414 }
415
416 if (ENIC_TEST_INTR(pba, ENIC_INTX_WQ_RQ)) {
417 if (napi_schedule_prep(&enic->napi))
418 __napi_schedule(&enic->napi);
419 } else {
420 vnic_intr_unmask(&enic->intr[ENIC_INTX_WQ_RQ]);
421 }
422
423 return IRQ_HANDLED;
424 }
425
426 static irqreturn_t enic_isr_msi(int irq, void *data)
427 {
428 struct enic *enic = data;
429
430 /* With MSI, there is no sharing of interrupts, so this is
431 * our interrupt and there is no need to ack it. The device
432 * is not providing per-vector masking, so the OS will not
433 * write to PCI config space to mask/unmask the interrupt.
434 * We're using mask_on_assertion for MSI, so the device
435 * automatically masks the interrupt when the interrupt is
436 * generated. Later, when exiting polling, the interrupt
437 * will be unmasked (see enic_poll).
438 *
439 * Also, the device uses the same PCIe Traffic Class (TC)
440 * for Memory Write data and MSI, so there are no ordering
441 * issues; the MSI will always arrive at the Root Complex
442 * _after_ corresponding Memory Writes (i.e. descriptor
443 * writes).
444 */
445
446 napi_schedule(&enic->napi);
447
448 return IRQ_HANDLED;
449 }
450
451 static irqreturn_t enic_isr_msix_rq(int irq, void *data)
452 {
453 struct enic *enic = data;
454
455 /* schedule NAPI polling for RQ cleanup */
456 napi_schedule(&enic->napi);
457
458 return IRQ_HANDLED;
459 }
460
461 static irqreturn_t enic_isr_msix_wq(int irq, void *data)
462 {
463 struct enic *enic = data;
464 unsigned int wq_work_to_do = -1; /* no limit */
465 unsigned int wq_work_done;
466
467 wq_work_done = vnic_cq_service(&enic->cq[ENIC_CQ_WQ],
468 wq_work_to_do, enic_wq_service, NULL);
469
470 vnic_intr_return_credits(&enic->intr[ENIC_MSIX_WQ],
471 wq_work_done,
472 1 /* unmask intr */,
473 1 /* reset intr timer */);
474
475 return IRQ_HANDLED;
476 }
477
478 static irqreturn_t enic_isr_msix_err(int irq, void *data)
479 {
480 struct enic *enic = data;
481
482 vnic_intr_return_all_credits(&enic->intr[ENIC_MSIX_ERR]);
483
484 enic_log_q_error(enic);
485
486 /* schedule recovery from WQ/RQ error */
487 schedule_work(&enic->reset);
488
489 return IRQ_HANDLED;
490 }
491
492 static irqreturn_t enic_isr_msix_notify(int irq, void *data)
493 {
494 struct enic *enic = data;
495
496 vnic_intr_return_all_credits(&enic->intr[ENIC_MSIX_NOTIFY]);
497 enic_notify_check(enic);
498
499 return IRQ_HANDLED;
500 }
501
502 static inline void enic_queue_wq_skb_cont(struct enic *enic,
503 struct vnic_wq *wq, struct sk_buff *skb,
504 unsigned int len_left)
505 {
506 skb_frag_t *frag;
507
508 /* Queue additional data fragments */
509 for (frag = skb_shinfo(skb)->frags; len_left; frag++) {
510 len_left -= frag->size;
511 enic_queue_wq_desc_cont(wq, skb,
512 pci_map_page(enic->pdev, frag->page,
513 frag->page_offset, frag->size,
514 PCI_DMA_TODEVICE),
515 frag->size,
516 (len_left == 0)); /* EOP? */
517 }
518 }
519
520 static inline void enic_queue_wq_skb_vlan(struct enic *enic,
521 struct vnic_wq *wq, struct sk_buff *skb,
522 int vlan_tag_insert, unsigned int vlan_tag)
523 {
524 unsigned int head_len = skb_headlen(skb);
525 unsigned int len_left = skb->len - head_len;
526 int eop = (len_left == 0);
527
528 /* Queue the main skb fragment */
529 enic_queue_wq_desc(wq, skb,
530 pci_map_single(enic->pdev, skb->data,
531 head_len, PCI_DMA_TODEVICE),
532 head_len,
533 vlan_tag_insert, vlan_tag,
534 eop);
535
536 if (!eop)
537 enic_queue_wq_skb_cont(enic, wq, skb, len_left);
538 }
539
540 static inline void enic_queue_wq_skb_csum_l4(struct enic *enic,
541 struct vnic_wq *wq, struct sk_buff *skb,
542 int vlan_tag_insert, unsigned int vlan_tag)
543 {
544 unsigned int head_len = skb_headlen(skb);
545 unsigned int len_left = skb->len - head_len;
546 unsigned int hdr_len = skb_transport_offset(skb);
547 unsigned int csum_offset = hdr_len + skb->csum_offset;
548 int eop = (len_left == 0);
549
550 /* Queue the main skb fragment */
551 enic_queue_wq_desc_csum_l4(wq, skb,
552 pci_map_single(enic->pdev, skb->data,
553 head_len, PCI_DMA_TODEVICE),
554 head_len,
555 csum_offset,
556 hdr_len,
557 vlan_tag_insert, vlan_tag,
558 eop);
559
560 if (!eop)
561 enic_queue_wq_skb_cont(enic, wq, skb, len_left);
562 }
563
564 static inline void enic_queue_wq_skb_tso(struct enic *enic,
565 struct vnic_wq *wq, struct sk_buff *skb, unsigned int mss,
566 int vlan_tag_insert, unsigned int vlan_tag)
567 {
568 unsigned int head_len = skb_headlen(skb);
569 unsigned int len_left = skb->len - head_len;
570 unsigned int hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
571 int eop = (len_left == 0);
572
573 /* Preload TCP csum field with IP pseudo hdr calculated
574 * with IP length set to zero. HW will later add in length
575 * to each TCP segment resulting from the TSO.
576 */
577
578 if (skb->protocol == cpu_to_be16(ETH_P_IP)) {
579 ip_hdr(skb)->check = 0;
580 tcp_hdr(skb)->check = ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
581 ip_hdr(skb)->daddr, 0, IPPROTO_TCP, 0);
582 } else if (skb->protocol == cpu_to_be16(ETH_P_IPV6)) {
583 tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
584 &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0);
585 }
586
587 /* Queue the main skb fragment */
588 enic_queue_wq_desc_tso(wq, skb,
589 pci_map_single(enic->pdev, skb->data,
590 head_len, PCI_DMA_TODEVICE),
591 head_len,
592 mss, hdr_len,
593 vlan_tag_insert, vlan_tag,
594 eop);
595
596 if (!eop)
597 enic_queue_wq_skb_cont(enic, wq, skb, len_left);
598 }
599
600 static inline void enic_queue_wq_skb(struct enic *enic,
601 struct vnic_wq *wq, struct sk_buff *skb)
602 {
603 unsigned int mss = skb_shinfo(skb)->gso_size;
604 unsigned int vlan_tag = 0;
605 int vlan_tag_insert = 0;
606
607 if (enic->vlan_group && vlan_tx_tag_present(skb)) {
608 /* VLAN tag from trunking driver */
609 vlan_tag_insert = 1;
610 vlan_tag = vlan_tx_tag_get(skb);
611 }
612
613 if (mss)
614 enic_queue_wq_skb_tso(enic, wq, skb, mss,
615 vlan_tag_insert, vlan_tag);
616 else if (skb->ip_summed == CHECKSUM_PARTIAL)
617 enic_queue_wq_skb_csum_l4(enic, wq, skb,
618 vlan_tag_insert, vlan_tag);
619 else
620 enic_queue_wq_skb_vlan(enic, wq, skb,
621 vlan_tag_insert, vlan_tag);
622 }
623
624 /* netif_tx_lock held, process context with BHs disabled, or BH */
625 static netdev_tx_t enic_hard_start_xmit(struct sk_buff *skb,
626 struct net_device *netdev)
627 {
628 struct enic *enic = netdev_priv(netdev);
629 struct vnic_wq *wq = &enic->wq[0];
630 unsigned long flags;
631
632 if (skb->len <= 0) {
633 dev_kfree_skb(skb);
634 return NETDEV_TX_OK;
635 }
636
637 /* Non-TSO sends must fit within ENIC_NON_TSO_MAX_DESC descs,
638 * which is very likely. In the off chance it's going to take
639 * more than * ENIC_NON_TSO_MAX_DESC, linearize the skb.
640 */
641
642 if (skb_shinfo(skb)->gso_size == 0 &&
643 skb_shinfo(skb)->nr_frags + 1 > ENIC_NON_TSO_MAX_DESC &&
644 skb_linearize(skb)) {
645 dev_kfree_skb(skb);
646 return NETDEV_TX_OK;
647 }
648
649 spin_lock_irqsave(&enic->wq_lock[0], flags);
650
651 if (vnic_wq_desc_avail(wq) < skb_shinfo(skb)->nr_frags + 1) {
652 netif_stop_queue(netdev);
653 /* This is a hard error, log it */
654 printk(KERN_ERR PFX "%s: BUG! Tx ring full when "
655 "queue awake!\n", netdev->name);
656 spin_unlock_irqrestore(&enic->wq_lock[0], flags);
657 return NETDEV_TX_BUSY;
658 }
659
660 enic_queue_wq_skb(enic, wq, skb);
661
662 if (vnic_wq_desc_avail(wq) < MAX_SKB_FRAGS + 1)
663 netif_stop_queue(netdev);
664
665 spin_unlock_irqrestore(&enic->wq_lock[0], flags);
666
667 return NETDEV_TX_OK;
668 }
669
670 /* dev_base_lock rwlock held, nominally process context */
671 static struct net_device_stats *enic_get_stats(struct net_device *netdev)
672 {
673 struct enic *enic = netdev_priv(netdev);
674 struct net_device_stats *net_stats = &netdev->stats;
675 struct vnic_stats *stats;
676
677 spin_lock(&enic->devcmd_lock);
678 vnic_dev_stats_dump(enic->vdev, &stats);
679 spin_unlock(&enic->devcmd_lock);
680
681 net_stats->tx_packets = stats->tx.tx_frames_ok;
682 net_stats->tx_bytes = stats->tx.tx_bytes_ok;
683 net_stats->tx_errors = stats->tx.tx_errors;
684 net_stats->tx_dropped = stats->tx.tx_drops;
685
686 net_stats->rx_packets = stats->rx.rx_frames_ok;
687 net_stats->rx_bytes = stats->rx.rx_bytes_ok;
688 net_stats->rx_errors = stats->rx.rx_errors;
689 net_stats->multicast = stats->rx.rx_multicast_frames_ok;
690 net_stats->rx_crc_errors = enic->rq_bad_fcs;
691 net_stats->rx_dropped = stats->rx.rx_no_bufs;
692
693 return net_stats;
694 }
695
696 static void enic_reset_mcaddrs(struct enic *enic)
697 {
698 enic->mc_count = 0;
699 }
700
701 static int enic_set_mac_addr(struct net_device *netdev, char *addr)
702 {
703 if (!is_valid_ether_addr(addr))
704 return -EADDRNOTAVAIL;
705
706 memcpy(netdev->dev_addr, addr, netdev->addr_len);
707
708 return 0;
709 }
710
711 /* netif_tx_lock held, BHs disabled */
712 static void enic_set_multicast_list(struct net_device *netdev)
713 {
714 struct enic *enic = netdev_priv(netdev);
715 struct dev_mc_list *list = netdev->mc_list;
716 int directed = 1;
717 int multicast = (netdev->flags & IFF_MULTICAST) ? 1 : 0;
718 int broadcast = (netdev->flags & IFF_BROADCAST) ? 1 : 0;
719 int promisc = (netdev->flags & IFF_PROMISC) ? 1 : 0;
720 int allmulti = (netdev->flags & IFF_ALLMULTI) ||
721 (netdev->mc_count > ENIC_MULTICAST_PERFECT_FILTERS);
722 u8 mc_addr[ENIC_MULTICAST_PERFECT_FILTERS][ETH_ALEN];
723 unsigned int mc_count = netdev->mc_count;
724 unsigned int i, j;
725
726 if (mc_count > ENIC_MULTICAST_PERFECT_FILTERS)
727 mc_count = ENIC_MULTICAST_PERFECT_FILTERS;
728
729 spin_lock(&enic->devcmd_lock);
730
731 vnic_dev_packet_filter(enic->vdev, directed,
732 multicast, broadcast, promisc, allmulti);
733
734 /* Is there an easier way? Trying to minimize to
735 * calls to add/del multicast addrs. We keep the
736 * addrs from the last call in enic->mc_addr and
737 * look for changes to add/del.
738 */
739
740 for (i = 0; list && i < mc_count; i++) {
741 memcpy(mc_addr[i], list->dmi_addr, ETH_ALEN);
742 list = list->next;
743 }
744
745 for (i = 0; i < enic->mc_count; i++) {
746 for (j = 0; j < mc_count; j++)
747 if (compare_ether_addr(enic->mc_addr[i],
748 mc_addr[j]) == 0)
749 break;
750 if (j == mc_count)
751 enic_del_multicast_addr(enic, enic->mc_addr[i]);
752 }
753
754 for (i = 0; i < mc_count; i++) {
755 for (j = 0; j < enic->mc_count; j++)
756 if (compare_ether_addr(mc_addr[i],
757 enic->mc_addr[j]) == 0)
758 break;
759 if (j == enic->mc_count)
760 enic_add_multicast_addr(enic, mc_addr[i]);
761 }
762
763 /* Save the list to compare against next time
764 */
765
766 for (i = 0; i < mc_count; i++)
767 memcpy(enic->mc_addr[i], mc_addr[i], ETH_ALEN);
768
769 enic->mc_count = mc_count;
770
771 spin_unlock(&enic->devcmd_lock);
772 }
773
774 /* rtnl lock is held */
775 static void enic_vlan_rx_register(struct net_device *netdev,
776 struct vlan_group *vlan_group)
777 {
778 struct enic *enic = netdev_priv(netdev);
779 enic->vlan_group = vlan_group;
780 }
781
782 /* rtnl lock is held */
783 static void enic_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
784 {
785 struct enic *enic = netdev_priv(netdev);
786
787 spin_lock(&enic->devcmd_lock);
788 enic_add_vlan(enic, vid);
789 spin_unlock(&enic->devcmd_lock);
790 }
791
792 /* rtnl lock is held */
793 static void enic_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
794 {
795 struct enic *enic = netdev_priv(netdev);
796
797 spin_lock(&enic->devcmd_lock);
798 enic_del_vlan(enic, vid);
799 spin_unlock(&enic->devcmd_lock);
800 }
801
802 /* netif_tx_lock held, BHs disabled */
803 static void enic_tx_timeout(struct net_device *netdev)
804 {
805 struct enic *enic = netdev_priv(netdev);
806 schedule_work(&enic->reset);
807 }
808
809 static void enic_free_rq_buf(struct vnic_rq *rq, struct vnic_rq_buf *buf)
810 {
811 struct enic *enic = vnic_dev_priv(rq->vdev);
812
813 if (!buf->os_buf)
814 return;
815
816 pci_unmap_single(enic->pdev, buf->dma_addr,
817 buf->len, PCI_DMA_FROMDEVICE);
818 dev_kfree_skb_any(buf->os_buf);
819 }
820
821 static inline struct sk_buff *enic_rq_alloc_skb(unsigned int size)
822 {
823 struct sk_buff *skb;
824
825 skb = dev_alloc_skb(size + NET_IP_ALIGN);
826
827 if (skb)
828 skb_reserve(skb, NET_IP_ALIGN);
829
830 return skb;
831 }
832
833 static int enic_rq_alloc_buf(struct vnic_rq *rq)
834 {
835 struct enic *enic = vnic_dev_priv(rq->vdev);
836 struct sk_buff *skb;
837 unsigned int len = enic->netdev->mtu + ETH_HLEN;
838 unsigned int os_buf_index = 0;
839 dma_addr_t dma_addr;
840
841 skb = enic_rq_alloc_skb(len);
842 if (!skb)
843 return -ENOMEM;
844
845 dma_addr = pci_map_single(enic->pdev, skb->data,
846 len, PCI_DMA_FROMDEVICE);
847
848 enic_queue_rq_desc(rq, skb, os_buf_index,
849 dma_addr, len);
850
851 return 0;
852 }
853
854 static int enic_rq_alloc_buf_a1(struct vnic_rq *rq)
855 {
856 struct rq_enet_desc *desc = vnic_rq_next_desc(rq);
857
858 if (vnic_rq_posting_soon(rq)) {
859
860 /* SW workaround for A0 HW erratum: if we're just about
861 * to write posted_index, insert a dummy desc
862 * of type resvd
863 */
864
865 rq_enet_desc_enc(desc, 0, RQ_ENET_TYPE_RESV2, 0);
866 vnic_rq_post(rq, 0, 0, 0, 0);
867 } else {
868 return enic_rq_alloc_buf(rq);
869 }
870
871 return 0;
872 }
873
874 static int enic_set_rq_alloc_buf(struct enic *enic)
875 {
876 enum vnic_dev_hw_version hw_ver;
877 int err;
878
879 err = vnic_dev_hw_version(enic->vdev, &hw_ver);
880 if (err)
881 return err;
882
883 switch (hw_ver) {
884 case VNIC_DEV_HW_VER_A1:
885 enic->rq_alloc_buf = enic_rq_alloc_buf_a1;
886 break;
887 case VNIC_DEV_HW_VER_A2:
888 case VNIC_DEV_HW_VER_UNKNOWN:
889 enic->rq_alloc_buf = enic_rq_alloc_buf;
890 break;
891 default:
892 return -ENODEV;
893 }
894
895 return 0;
896 }
897
898 static int enic_get_skb_header(struct sk_buff *skb, void **iphdr,
899 void **tcph, u64 *hdr_flags, void *priv)
900 {
901 struct cq_enet_rq_desc *cq_desc = priv;
902 unsigned int ip_len;
903 struct iphdr *iph;
904
905 u8 type, color, eop, sop, ingress_port, vlan_stripped;
906 u8 fcoe, fcoe_sof, fcoe_fc_crc_ok, fcoe_enc_error, fcoe_eof;
907 u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok;
908 u8 ipv6, ipv4, ipv4_fragment, fcs_ok, rss_type, csum_not_calc;
909 u8 packet_error;
910 u16 q_number, completed_index, bytes_written, vlan, checksum;
911 u32 rss_hash;
912
913 cq_enet_rq_desc_dec(cq_desc,
914 &type, &color, &q_number, &completed_index,
915 &ingress_port, &fcoe, &eop, &sop, &rss_type,
916 &csum_not_calc, &rss_hash, &bytes_written,
917 &packet_error, &vlan_stripped, &vlan, &checksum,
918 &fcoe_sof, &fcoe_fc_crc_ok, &fcoe_enc_error,
919 &fcoe_eof, &tcp_udp_csum_ok, &udp, &tcp,
920 &ipv4_csum_ok, &ipv6, &ipv4, &ipv4_fragment,
921 &fcs_ok);
922
923 if (!(ipv4 && tcp && !ipv4_fragment))
924 return -1;
925
926 skb_reset_network_header(skb);
927 iph = ip_hdr(skb);
928
929 ip_len = ip_hdrlen(skb);
930 skb_set_transport_header(skb, ip_len);
931
932 /* check if ip header and tcp header are complete */
933 if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb))
934 return -1;
935
936 *hdr_flags = LRO_IPV4 | LRO_TCP;
937 *tcph = tcp_hdr(skb);
938 *iphdr = iph;
939
940 return 0;
941 }
942
943 static void enic_rq_indicate_buf(struct vnic_rq *rq,
944 struct cq_desc *cq_desc, struct vnic_rq_buf *buf,
945 int skipped, void *opaque)
946 {
947 struct enic *enic = vnic_dev_priv(rq->vdev);
948 struct net_device *netdev = enic->netdev;
949 struct sk_buff *skb;
950
951 u8 type, color, eop, sop, ingress_port, vlan_stripped;
952 u8 fcoe, fcoe_sof, fcoe_fc_crc_ok, fcoe_enc_error, fcoe_eof;
953 u8 tcp_udp_csum_ok, udp, tcp, ipv4_csum_ok;
954 u8 ipv6, ipv4, ipv4_fragment, fcs_ok, rss_type, csum_not_calc;
955 u8 packet_error;
956 u16 q_number, completed_index, bytes_written, vlan, checksum;
957 u32 rss_hash;
958
959 if (skipped)
960 return;
961
962 skb = buf->os_buf;
963 prefetch(skb->data - NET_IP_ALIGN);
964 pci_unmap_single(enic->pdev, buf->dma_addr,
965 buf->len, PCI_DMA_FROMDEVICE);
966
967 cq_enet_rq_desc_dec((struct cq_enet_rq_desc *)cq_desc,
968 &type, &color, &q_number, &completed_index,
969 &ingress_port, &fcoe, &eop, &sop, &rss_type,
970 &csum_not_calc, &rss_hash, &bytes_written,
971 &packet_error, &vlan_stripped, &vlan, &checksum,
972 &fcoe_sof, &fcoe_fc_crc_ok, &fcoe_enc_error,
973 &fcoe_eof, &tcp_udp_csum_ok, &udp, &tcp,
974 &ipv4_csum_ok, &ipv6, &ipv4, &ipv4_fragment,
975 &fcs_ok);
976
977 if (packet_error) {
978
979 if (bytes_written > 0 && !fcs_ok)
980 enic->rq_bad_fcs++;
981
982 dev_kfree_skb_any(skb);
983
984 return;
985 }
986
987 if (eop && bytes_written > 0) {
988
989 /* Good receive
990 */
991
992 skb_put(skb, bytes_written);
993 skb->protocol = eth_type_trans(skb, netdev);
994
995 if (enic->csum_rx_enabled && !csum_not_calc) {
996 skb->csum = htons(checksum);
997 skb->ip_summed = CHECKSUM_COMPLETE;
998 }
999
1000 skb->dev = netdev;
1001
1002 if (enic->vlan_group && vlan_stripped) {
1003
1004 if ((netdev->features & NETIF_F_LRO) && ipv4)
1005 lro_vlan_hwaccel_receive_skb(&enic->lro_mgr,
1006 skb, enic->vlan_group,
1007 vlan, cq_desc);
1008 else
1009 vlan_hwaccel_receive_skb(skb,
1010 enic->vlan_group, vlan);
1011
1012 } else {
1013
1014 if ((netdev->features & NETIF_F_LRO) && ipv4)
1015 lro_receive_skb(&enic->lro_mgr, skb, cq_desc);
1016 else
1017 netif_receive_skb(skb);
1018
1019 }
1020
1021 } else {
1022
1023 /* Buffer overflow
1024 */
1025
1026 dev_kfree_skb_any(skb);
1027 }
1028 }
1029
1030 static int enic_rq_service(struct vnic_dev *vdev, struct cq_desc *cq_desc,
1031 u8 type, u16 q_number, u16 completed_index, void *opaque)
1032 {
1033 struct enic *enic = vnic_dev_priv(vdev);
1034
1035 vnic_rq_service(&enic->rq[q_number], cq_desc,
1036 completed_index, VNIC_RQ_RETURN_DESC,
1037 enic_rq_indicate_buf, opaque);
1038
1039 return 0;
1040 }
1041
1042 static void enic_rq_drop_buf(struct vnic_rq *rq,
1043 struct cq_desc *cq_desc, struct vnic_rq_buf *buf,
1044 int skipped, void *opaque)
1045 {
1046 struct enic *enic = vnic_dev_priv(rq->vdev);
1047 struct sk_buff *skb = buf->os_buf;
1048
1049 if (skipped)
1050 return;
1051
1052 pci_unmap_single(enic->pdev, buf->dma_addr,
1053 buf->len, PCI_DMA_FROMDEVICE);
1054
1055 dev_kfree_skb_any(skb);
1056 }
1057
1058 static int enic_rq_service_drop(struct vnic_dev *vdev, struct cq_desc *cq_desc,
1059 u8 type, u16 q_number, u16 completed_index, void *opaque)
1060 {
1061 struct enic *enic = vnic_dev_priv(vdev);
1062
1063 vnic_rq_service(&enic->rq[q_number], cq_desc,
1064 completed_index, VNIC_RQ_RETURN_DESC,
1065 enic_rq_drop_buf, opaque);
1066
1067 return 0;
1068 }
1069
1070 static int enic_poll(struct napi_struct *napi, int budget)
1071 {
1072 struct enic *enic = container_of(napi, struct enic, napi);
1073 struct net_device *netdev = enic->netdev;
1074 unsigned int rq_work_to_do = budget;
1075 unsigned int wq_work_to_do = -1; /* no limit */
1076 unsigned int work_done, rq_work_done, wq_work_done;
1077
1078 /* Service RQ (first) and WQ
1079 */
1080
1081 rq_work_done = vnic_cq_service(&enic->cq[ENIC_CQ_RQ],
1082 rq_work_to_do, enic_rq_service, NULL);
1083
1084 wq_work_done = vnic_cq_service(&enic->cq[ENIC_CQ_WQ],
1085 wq_work_to_do, enic_wq_service, NULL);
1086
1087 /* Accumulate intr event credits for this polling
1088 * cycle. An intr event is the completion of a
1089 * a WQ or RQ packet.
1090 */
1091
1092 work_done = rq_work_done + wq_work_done;
1093
1094 if (work_done > 0)
1095 vnic_intr_return_credits(&enic->intr[ENIC_INTX_WQ_RQ],
1096 work_done,
1097 0 /* don't unmask intr */,
1098 0 /* don't reset intr timer */);
1099
1100 if (rq_work_done > 0) {
1101
1102 /* Replenish RQ
1103 */
1104
1105 vnic_rq_fill(&enic->rq[0], enic->rq_alloc_buf);
1106
1107 } else {
1108
1109 /* If no work done, flush all LROs and exit polling
1110 */
1111
1112 if (netdev->features & NETIF_F_LRO)
1113 lro_flush_all(&enic->lro_mgr);
1114
1115 napi_complete(napi);
1116 vnic_intr_unmask(&enic->intr[ENIC_INTX_WQ_RQ]);
1117 }
1118
1119 return rq_work_done;
1120 }
1121
1122 static int enic_poll_msix(struct napi_struct *napi, int budget)
1123 {
1124 struct enic *enic = container_of(napi, struct enic, napi);
1125 struct net_device *netdev = enic->netdev;
1126 unsigned int work_to_do = budget;
1127 unsigned int work_done;
1128
1129 /* Service RQ
1130 */
1131
1132 work_done = vnic_cq_service(&enic->cq[ENIC_CQ_RQ],
1133 work_to_do, enic_rq_service, NULL);
1134
1135 if (work_done > 0) {
1136
1137 /* Replenish RQ
1138 */
1139
1140 vnic_rq_fill(&enic->rq[0], enic->rq_alloc_buf);
1141
1142 /* Return intr event credits for this polling
1143 * cycle. An intr event is the completion of a
1144 * RQ packet.
1145 */
1146
1147 vnic_intr_return_credits(&enic->intr[ENIC_MSIX_RQ],
1148 work_done,
1149 0 /* don't unmask intr */,
1150 0 /* don't reset intr timer */);
1151 } else {
1152
1153 /* If no work done, flush all LROs and exit polling
1154 */
1155
1156 if (netdev->features & NETIF_F_LRO)
1157 lro_flush_all(&enic->lro_mgr);
1158
1159 napi_complete(napi);
1160 vnic_intr_unmask(&enic->intr[ENIC_MSIX_RQ]);
1161 }
1162
1163 return work_done;
1164 }
1165
1166 static void enic_notify_timer(unsigned long data)
1167 {
1168 struct enic *enic = (struct enic *)data;
1169
1170 enic_notify_check(enic);
1171
1172 mod_timer(&enic->notify_timer,
1173 round_jiffies(jiffies + ENIC_NOTIFY_TIMER_PERIOD));
1174 }
1175
1176 static void enic_free_intr(struct enic *enic)
1177 {
1178 struct net_device *netdev = enic->netdev;
1179 unsigned int i;
1180
1181 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1182 case VNIC_DEV_INTR_MODE_INTX:
1183 free_irq(enic->pdev->irq, netdev);
1184 break;
1185 case VNIC_DEV_INTR_MODE_MSI:
1186 free_irq(enic->pdev->irq, enic);
1187 break;
1188 case VNIC_DEV_INTR_MODE_MSIX:
1189 for (i = 0; i < ARRAY_SIZE(enic->msix); i++)
1190 if (enic->msix[i].requested)
1191 free_irq(enic->msix_entry[i].vector,
1192 enic->msix[i].devid);
1193 break;
1194 default:
1195 break;
1196 }
1197 }
1198
1199 static int enic_request_intr(struct enic *enic)
1200 {
1201 struct net_device *netdev = enic->netdev;
1202 unsigned int i;
1203 int err = 0;
1204
1205 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1206
1207 case VNIC_DEV_INTR_MODE_INTX:
1208
1209 err = request_irq(enic->pdev->irq, enic_isr_legacy,
1210 IRQF_SHARED, netdev->name, netdev);
1211 break;
1212
1213 case VNIC_DEV_INTR_MODE_MSI:
1214
1215 err = request_irq(enic->pdev->irq, enic_isr_msi,
1216 0, netdev->name, enic);
1217 break;
1218
1219 case VNIC_DEV_INTR_MODE_MSIX:
1220
1221 sprintf(enic->msix[ENIC_MSIX_RQ].devname,
1222 "%.11s-rx-0", netdev->name);
1223 enic->msix[ENIC_MSIX_RQ].isr = enic_isr_msix_rq;
1224 enic->msix[ENIC_MSIX_RQ].devid = enic;
1225
1226 sprintf(enic->msix[ENIC_MSIX_WQ].devname,
1227 "%.11s-tx-0", netdev->name);
1228 enic->msix[ENIC_MSIX_WQ].isr = enic_isr_msix_wq;
1229 enic->msix[ENIC_MSIX_WQ].devid = enic;
1230
1231 sprintf(enic->msix[ENIC_MSIX_ERR].devname,
1232 "%.11s-err", netdev->name);
1233 enic->msix[ENIC_MSIX_ERR].isr = enic_isr_msix_err;
1234 enic->msix[ENIC_MSIX_ERR].devid = enic;
1235
1236 sprintf(enic->msix[ENIC_MSIX_NOTIFY].devname,
1237 "%.11s-notify", netdev->name);
1238 enic->msix[ENIC_MSIX_NOTIFY].isr = enic_isr_msix_notify;
1239 enic->msix[ENIC_MSIX_NOTIFY].devid = enic;
1240
1241 for (i = 0; i < ARRAY_SIZE(enic->msix); i++) {
1242 err = request_irq(enic->msix_entry[i].vector,
1243 enic->msix[i].isr, 0,
1244 enic->msix[i].devname,
1245 enic->msix[i].devid);
1246 if (err) {
1247 enic_free_intr(enic);
1248 break;
1249 }
1250 enic->msix[i].requested = 1;
1251 }
1252
1253 break;
1254
1255 default:
1256 break;
1257 }
1258
1259 return err;
1260 }
1261
1262 static int enic_notify_set(struct enic *enic)
1263 {
1264 int err;
1265
1266 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1267 case VNIC_DEV_INTR_MODE_INTX:
1268 err = vnic_dev_notify_set(enic->vdev, ENIC_INTX_NOTIFY);
1269 break;
1270 case VNIC_DEV_INTR_MODE_MSIX:
1271 err = vnic_dev_notify_set(enic->vdev, ENIC_MSIX_NOTIFY);
1272 break;
1273 default:
1274 err = vnic_dev_notify_set(enic->vdev, -1 /* no intr */);
1275 break;
1276 }
1277
1278 return err;
1279 }
1280
1281 static void enic_notify_timer_start(struct enic *enic)
1282 {
1283 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1284 case VNIC_DEV_INTR_MODE_MSI:
1285 mod_timer(&enic->notify_timer, jiffies);
1286 break;
1287 default:
1288 /* Using intr for notification for INTx/MSI-X */
1289 break;
1290 };
1291 }
1292
1293 /* rtnl lock is held, process context */
1294 static int enic_open(struct net_device *netdev)
1295 {
1296 struct enic *enic = netdev_priv(netdev);
1297 unsigned int i;
1298 int err;
1299
1300 err = enic_request_intr(enic);
1301 if (err) {
1302 printk(KERN_ERR PFX "%s: Unable to request irq.\n",
1303 netdev->name);
1304 return err;
1305 }
1306
1307 err = enic_notify_set(enic);
1308 if (err) {
1309 printk(KERN_ERR PFX
1310 "%s: Failed to alloc notify buffer, aborting.\n",
1311 netdev->name);
1312 goto err_out_free_intr;
1313 }
1314
1315 for (i = 0; i < enic->rq_count; i++) {
1316 err = vnic_rq_fill(&enic->rq[i], enic->rq_alloc_buf);
1317 if (err) {
1318 printk(KERN_ERR PFX
1319 "%s: Unable to alloc receive buffers.\n",
1320 netdev->name);
1321 goto err_out_notify_unset;
1322 }
1323 }
1324
1325 for (i = 0; i < enic->wq_count; i++)
1326 vnic_wq_enable(&enic->wq[i]);
1327 for (i = 0; i < enic->rq_count; i++)
1328 vnic_rq_enable(&enic->rq[i]);
1329
1330 enic_add_station_addr(enic);
1331 enic_set_multicast_list(netdev);
1332
1333 netif_wake_queue(netdev);
1334 napi_enable(&enic->napi);
1335 vnic_dev_enable(enic->vdev);
1336
1337 for (i = 0; i < enic->intr_count; i++)
1338 vnic_intr_unmask(&enic->intr[i]);
1339
1340 enic_notify_timer_start(enic);
1341
1342 return 0;
1343
1344 err_out_notify_unset:
1345 vnic_dev_notify_unset(enic->vdev);
1346 err_out_free_intr:
1347 enic_free_intr(enic);
1348
1349 return err;
1350 }
1351
1352 /* rtnl lock is held, process context */
1353 static int enic_stop(struct net_device *netdev)
1354 {
1355 struct enic *enic = netdev_priv(netdev);
1356 unsigned int i;
1357 int err;
1358
1359 del_timer_sync(&enic->notify_timer);
1360
1361 vnic_dev_disable(enic->vdev);
1362 napi_disable(&enic->napi);
1363 netif_stop_queue(netdev);
1364
1365 for (i = 0; i < enic->intr_count; i++)
1366 vnic_intr_mask(&enic->intr[i]);
1367
1368 for (i = 0; i < enic->wq_count; i++) {
1369 err = vnic_wq_disable(&enic->wq[i]);
1370 if (err)
1371 return err;
1372 }
1373 for (i = 0; i < enic->rq_count; i++) {
1374 err = vnic_rq_disable(&enic->rq[i]);
1375 if (err)
1376 return err;
1377 }
1378
1379 vnic_dev_notify_unset(enic->vdev);
1380 enic_free_intr(enic);
1381
1382 (void)vnic_cq_service(&enic->cq[ENIC_CQ_RQ],
1383 -1, enic_rq_service_drop, NULL);
1384 (void)vnic_cq_service(&enic->cq[ENIC_CQ_WQ],
1385 -1, enic_wq_service, NULL);
1386
1387 for (i = 0; i < enic->wq_count; i++)
1388 vnic_wq_clean(&enic->wq[i], enic_free_wq_buf);
1389 for (i = 0; i < enic->rq_count; i++)
1390 vnic_rq_clean(&enic->rq[i], enic_free_rq_buf);
1391 for (i = 0; i < enic->cq_count; i++)
1392 vnic_cq_clean(&enic->cq[i]);
1393 for (i = 0; i < enic->intr_count; i++)
1394 vnic_intr_clean(&enic->intr[i]);
1395
1396 return 0;
1397 }
1398
1399 static int enic_change_mtu(struct net_device *netdev, int new_mtu)
1400 {
1401 struct enic *enic = netdev_priv(netdev);
1402 int running = netif_running(netdev);
1403
1404 if (new_mtu < ENIC_MIN_MTU || new_mtu > ENIC_MAX_MTU)
1405 return -EINVAL;
1406
1407 if (running)
1408 enic_stop(netdev);
1409
1410 netdev->mtu = new_mtu;
1411
1412 if (netdev->mtu > enic->port_mtu)
1413 printk(KERN_WARNING PFX
1414 "%s: interface MTU (%d) set higher "
1415 "than port MTU (%d)\n",
1416 netdev->name, netdev->mtu, enic->port_mtu);
1417
1418 if (running)
1419 enic_open(netdev);
1420
1421 return 0;
1422 }
1423
1424 #ifdef CONFIG_NET_POLL_CONTROLLER
1425 static void enic_poll_controller(struct net_device *netdev)
1426 {
1427 struct enic *enic = netdev_priv(netdev);
1428 struct vnic_dev *vdev = enic->vdev;
1429
1430 switch (vnic_dev_get_intr_mode(vdev)) {
1431 case VNIC_DEV_INTR_MODE_MSIX:
1432 enic_isr_msix_rq(enic->pdev->irq, enic);
1433 enic_isr_msix_wq(enic->pdev->irq, enic);
1434 break;
1435 case VNIC_DEV_INTR_MODE_MSI:
1436 enic_isr_msi(enic->pdev->irq, enic);
1437 break;
1438 case VNIC_DEV_INTR_MODE_INTX:
1439 enic_isr_legacy(enic->pdev->irq, netdev);
1440 break;
1441 default:
1442 break;
1443 }
1444 }
1445 #endif
1446
1447 static int enic_dev_wait(struct vnic_dev *vdev,
1448 int (*start)(struct vnic_dev *, int),
1449 int (*finished)(struct vnic_dev *, int *),
1450 int arg)
1451 {
1452 unsigned long time;
1453 int done;
1454 int err;
1455
1456 BUG_ON(in_interrupt());
1457
1458 err = start(vdev, arg);
1459 if (err)
1460 return err;
1461
1462 /* Wait for func to complete...2 seconds max
1463 */
1464
1465 time = jiffies + (HZ * 2);
1466 do {
1467
1468 err = finished(vdev, &done);
1469 if (err)
1470 return err;
1471
1472 if (done)
1473 return 0;
1474
1475 schedule_timeout_uninterruptible(HZ / 10);
1476
1477 } while (time_after(time, jiffies));
1478
1479 return -ETIMEDOUT;
1480 }
1481
1482 static int enic_dev_open(struct enic *enic)
1483 {
1484 int err;
1485
1486 err = enic_dev_wait(enic->vdev, vnic_dev_open,
1487 vnic_dev_open_done, 0);
1488 if (err)
1489 printk(KERN_ERR PFX
1490 "vNIC device open failed, err %d.\n", err);
1491
1492 return err;
1493 }
1494
1495 static int enic_dev_soft_reset(struct enic *enic)
1496 {
1497 int err;
1498
1499 err = enic_dev_wait(enic->vdev, vnic_dev_soft_reset,
1500 vnic_dev_soft_reset_done, 0);
1501 if (err)
1502 printk(KERN_ERR PFX
1503 "vNIC soft reset failed, err %d.\n", err);
1504
1505 return err;
1506 }
1507
1508 static int enic_set_niccfg(struct enic *enic)
1509 {
1510 const u8 rss_default_cpu = 0;
1511 const u8 rss_hash_type = 0;
1512 const u8 rss_hash_bits = 0;
1513 const u8 rss_base_cpu = 0;
1514 const u8 rss_enable = 0;
1515 const u8 tso_ipid_split_en = 0;
1516 const u8 ig_vlan_strip_en = 1;
1517
1518 /* Enable VLAN tag stripping. RSS not enabled (yet).
1519 */
1520
1521 return enic_set_nic_cfg(enic,
1522 rss_default_cpu, rss_hash_type,
1523 rss_hash_bits, rss_base_cpu,
1524 rss_enable, tso_ipid_split_en,
1525 ig_vlan_strip_en);
1526 }
1527
1528 static void enic_reset(struct work_struct *work)
1529 {
1530 struct enic *enic = container_of(work, struct enic, reset);
1531
1532 if (!netif_running(enic->netdev))
1533 return;
1534
1535 rtnl_lock();
1536
1537 spin_lock(&enic->devcmd_lock);
1538 vnic_dev_hang_notify(enic->vdev);
1539 spin_unlock(&enic->devcmd_lock);
1540
1541 enic_stop(enic->netdev);
1542 enic_dev_soft_reset(enic);
1543 vnic_dev_init(enic->vdev, 0);
1544 enic_reset_mcaddrs(enic);
1545 enic_init_vnic_resources(enic);
1546 enic_set_niccfg(enic);
1547 enic_open(enic->netdev);
1548
1549 rtnl_unlock();
1550 }
1551
1552 static int enic_set_intr_mode(struct enic *enic)
1553 {
1554 unsigned int n = ARRAY_SIZE(enic->rq);
1555 unsigned int m = ARRAY_SIZE(enic->wq);
1556 unsigned int i;
1557
1558 /* Set interrupt mode (INTx, MSI, MSI-X) depending
1559 * system capabilities.
1560 *
1561 * Try MSI-X first
1562 *
1563 * We need n RQs, m WQs, n+m CQs, and n+m+2 INTRs
1564 * (the second to last INTR is used for WQ/RQ errors)
1565 * (the last INTR is used for notifications)
1566 */
1567
1568 BUG_ON(ARRAY_SIZE(enic->msix_entry) < n + m + 2);
1569 for (i = 0; i < n + m + 2; i++)
1570 enic->msix_entry[i].entry = i;
1571
1572 if (enic->config.intr_mode < 1 &&
1573 enic->rq_count >= n &&
1574 enic->wq_count >= m &&
1575 enic->cq_count >= n + m &&
1576 enic->intr_count >= n + m + 2 &&
1577 !pci_enable_msix(enic->pdev, enic->msix_entry, n + m + 2)) {
1578
1579 enic->rq_count = n;
1580 enic->wq_count = m;
1581 enic->cq_count = n + m;
1582 enic->intr_count = n + m + 2;
1583
1584 vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_MSIX);
1585
1586 return 0;
1587 }
1588
1589 /* Next try MSI
1590 *
1591 * We need 1 RQ, 1 WQ, 2 CQs, and 1 INTR
1592 */
1593
1594 if (enic->config.intr_mode < 2 &&
1595 enic->rq_count >= 1 &&
1596 enic->wq_count >= 1 &&
1597 enic->cq_count >= 2 &&
1598 enic->intr_count >= 1 &&
1599 !pci_enable_msi(enic->pdev)) {
1600
1601 enic->rq_count = 1;
1602 enic->wq_count = 1;
1603 enic->cq_count = 2;
1604 enic->intr_count = 1;
1605
1606 vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_MSI);
1607
1608 return 0;
1609 }
1610
1611 /* Next try INTx
1612 *
1613 * We need 1 RQ, 1 WQ, 2 CQs, and 3 INTRs
1614 * (the first INTR is used for WQ/RQ)
1615 * (the second INTR is used for WQ/RQ errors)
1616 * (the last INTR is used for notifications)
1617 */
1618
1619 if (enic->config.intr_mode < 3 &&
1620 enic->rq_count >= 1 &&
1621 enic->wq_count >= 1 &&
1622 enic->cq_count >= 2 &&
1623 enic->intr_count >= 3) {
1624
1625 enic->rq_count = 1;
1626 enic->wq_count = 1;
1627 enic->cq_count = 2;
1628 enic->intr_count = 3;
1629
1630 vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_INTX);
1631
1632 return 0;
1633 }
1634
1635 vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
1636
1637 return -EINVAL;
1638 }
1639
1640 static void enic_clear_intr_mode(struct enic *enic)
1641 {
1642 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1643 case VNIC_DEV_INTR_MODE_MSIX:
1644 pci_disable_msix(enic->pdev);
1645 break;
1646 case VNIC_DEV_INTR_MODE_MSI:
1647 pci_disable_msi(enic->pdev);
1648 break;
1649 default:
1650 break;
1651 }
1652
1653 vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN);
1654 }
1655
1656 static const struct net_device_ops enic_netdev_ops = {
1657 .ndo_open = enic_open,
1658 .ndo_stop = enic_stop,
1659 .ndo_start_xmit = enic_hard_start_xmit,
1660 .ndo_get_stats = enic_get_stats,
1661 .ndo_validate_addr = eth_validate_addr,
1662 .ndo_set_mac_address = eth_mac_addr,
1663 .ndo_set_multicast_list = enic_set_multicast_list,
1664 .ndo_change_mtu = enic_change_mtu,
1665 .ndo_vlan_rx_register = enic_vlan_rx_register,
1666 .ndo_vlan_rx_add_vid = enic_vlan_rx_add_vid,
1667 .ndo_vlan_rx_kill_vid = enic_vlan_rx_kill_vid,
1668 .ndo_tx_timeout = enic_tx_timeout,
1669 #ifdef CONFIG_NET_POLL_CONTROLLER
1670 .ndo_poll_controller = enic_poll_controller,
1671 #endif
1672 };
1673
1674 static void enic_iounmap(struct enic *enic)
1675 {
1676 unsigned int i;
1677
1678 for (i = 0; i < ARRAY_SIZE(enic->bar); i++)
1679 if (enic->bar[i].vaddr)
1680 iounmap(enic->bar[i].vaddr);
1681 }
1682
1683 static int __devinit enic_probe(struct pci_dev *pdev,
1684 const struct pci_device_id *ent)
1685 {
1686 struct net_device *netdev;
1687 struct enic *enic;
1688 int using_dac = 0;
1689 unsigned int i;
1690 int err;
1691
1692 /* Allocate net device structure and initialize. Private
1693 * instance data is initialized to zero.
1694 */
1695
1696 netdev = alloc_etherdev(sizeof(struct enic));
1697 if (!netdev) {
1698 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n");
1699 return -ENOMEM;
1700 }
1701
1702 pci_set_drvdata(pdev, netdev);
1703
1704 SET_NETDEV_DEV(netdev, &pdev->dev);
1705
1706 enic = netdev_priv(netdev);
1707 enic->netdev = netdev;
1708 enic->pdev = pdev;
1709
1710 /* Setup PCI resources
1711 */
1712
1713 err = pci_enable_device(pdev);
1714 if (err) {
1715 printk(KERN_ERR PFX
1716 "Cannot enable PCI device, aborting.\n");
1717 goto err_out_free_netdev;
1718 }
1719
1720 err = pci_request_regions(pdev, DRV_NAME);
1721 if (err) {
1722 printk(KERN_ERR PFX
1723 "Cannot request PCI regions, aborting.\n");
1724 goto err_out_disable_device;
1725 }
1726
1727 pci_set_master(pdev);
1728
1729 /* Query PCI controller on system for DMA addressing
1730 * limitation for the device. Try 40-bit first, and
1731 * fail to 32-bit.
1732 */
1733
1734 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(40));
1735 if (err) {
1736 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1737 if (err) {
1738 printk(KERN_ERR PFX
1739 "No usable DMA configuration, aborting.\n");
1740 goto err_out_release_regions;
1741 }
1742 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
1743 if (err) {
1744 printk(KERN_ERR PFX
1745 "Unable to obtain 32-bit DMA "
1746 "for consistent allocations, aborting.\n");
1747 goto err_out_release_regions;
1748 }
1749 } else {
1750 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40));
1751 if (err) {
1752 printk(KERN_ERR PFX
1753 "Unable to obtain 40-bit DMA "
1754 "for consistent allocations, aborting.\n");
1755 goto err_out_release_regions;
1756 }
1757 using_dac = 1;
1758 }
1759
1760 /* Map vNIC resources from BAR0-5
1761 */
1762
1763 for (i = 0; i < ARRAY_SIZE(enic->bar); i++) {
1764 if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM))
1765 continue;
1766 enic->bar[i].len = pci_resource_len(pdev, i);
1767 enic->bar[i].vaddr = pci_iomap(pdev, i, enic->bar[i].len);
1768 if (!enic->bar[i].vaddr) {
1769 printk(KERN_ERR PFX
1770 "Cannot memory-map BAR %d, aborting.\n", i);
1771 err = -ENODEV;
1772 goto err_out_iounmap;
1773 }
1774 enic->bar[i].bus_addr = pci_resource_start(pdev, i);
1775 }
1776
1777 /* Register vNIC device
1778 */
1779
1780 enic->vdev = vnic_dev_register(NULL, enic, pdev, enic->bar,
1781 ARRAY_SIZE(enic->bar));
1782 if (!enic->vdev) {
1783 printk(KERN_ERR PFX
1784 "vNIC registration failed, aborting.\n");
1785 err = -ENODEV;
1786 goto err_out_iounmap;
1787 }
1788
1789 /* Issue device open to get device in known state
1790 */
1791
1792 err = enic_dev_open(enic);
1793 if (err) {
1794 printk(KERN_ERR PFX
1795 "vNIC dev open failed, aborting.\n");
1796 goto err_out_vnic_unregister;
1797 }
1798
1799 /* Issue device init to initialize the vnic-to-switch link.
1800 * We'll start with carrier off and wait for link UP
1801 * notification later to turn on carrier. We don't need
1802 * to wait here for the vnic-to-switch link initialization
1803 * to complete; link UP notification is the indication that
1804 * the process is complete.
1805 */
1806
1807 netif_carrier_off(netdev);
1808
1809 err = vnic_dev_init(enic->vdev, 0);
1810 if (err) {
1811 printk(KERN_ERR PFX
1812 "vNIC dev init failed, aborting.\n");
1813 goto err_out_dev_close;
1814 }
1815
1816 /* Get vNIC configuration
1817 */
1818
1819 err = enic_get_vnic_config(enic);
1820 if (err) {
1821 printk(KERN_ERR PFX
1822 "Get vNIC configuration failed, aborting.\n");
1823 goto err_out_dev_close;
1824 }
1825
1826 /* Get available resource counts
1827 */
1828
1829 enic_get_res_counts(enic);
1830
1831 /* Set interrupt mode based on resource counts and system
1832 * capabilities
1833 */
1834
1835 err = enic_set_intr_mode(enic);
1836 if (err) {
1837 printk(KERN_ERR PFX
1838 "Failed to set intr mode, aborting.\n");
1839 goto err_out_dev_close;
1840 }
1841
1842 /* Allocate and configure vNIC resources
1843 */
1844
1845 err = enic_alloc_vnic_resources(enic);
1846 if (err) {
1847 printk(KERN_ERR PFX
1848 "Failed to alloc vNIC resources, aborting.\n");
1849 goto err_out_free_vnic_resources;
1850 }
1851
1852 enic_init_vnic_resources(enic);
1853
1854 err = enic_set_niccfg(enic);
1855 if (err) {
1856 printk(KERN_ERR PFX
1857 "Failed to config nic, aborting.\n");
1858 goto err_out_free_vnic_resources;
1859 }
1860
1861 /* Setup notification timer, HW reset task, and locks
1862 */
1863
1864 init_timer(&enic->notify_timer);
1865 enic->notify_timer.function = enic_notify_timer;
1866 enic->notify_timer.data = (unsigned long)enic;
1867
1868 INIT_WORK(&enic->reset, enic_reset);
1869
1870 for (i = 0; i < enic->wq_count; i++)
1871 spin_lock_init(&enic->wq_lock[i]);
1872
1873 spin_lock_init(&enic->devcmd_lock);
1874
1875 /* Register net device
1876 */
1877
1878 enic->port_mtu = enic->config.mtu;
1879 (void)enic_change_mtu(netdev, enic->port_mtu);
1880
1881 err = enic_set_mac_addr(netdev, enic->mac_addr);
1882 if (err) {
1883 printk(KERN_ERR PFX
1884 "Invalid MAC address, aborting.\n");
1885 goto err_out_free_vnic_resources;
1886 }
1887
1888 netdev->netdev_ops = &enic_netdev_ops;
1889 netdev->watchdog_timeo = 2 * HZ;
1890 netdev->ethtool_ops = &enic_ethtool_ops;
1891
1892 switch (vnic_dev_get_intr_mode(enic->vdev)) {
1893 default:
1894 netif_napi_add(netdev, &enic->napi, enic_poll, 64);
1895 break;
1896 case VNIC_DEV_INTR_MODE_MSIX:
1897 netif_napi_add(netdev, &enic->napi, enic_poll_msix, 64);
1898 break;
1899 }
1900
1901 netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
1902 if (ENIC_SETTING(enic, TXCSUM))
1903 netdev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
1904 if (ENIC_SETTING(enic, TSO))
1905 netdev->features |= NETIF_F_TSO |
1906 NETIF_F_TSO6 | NETIF_F_TSO_ECN;
1907 if (ENIC_SETTING(enic, LRO))
1908 netdev->features |= NETIF_F_LRO;
1909 if (using_dac)
1910 netdev->features |= NETIF_F_HIGHDMA;
1911
1912 enic->csum_rx_enabled = ENIC_SETTING(enic, RXCSUM);
1913
1914 enic->lro_mgr.max_aggr = ENIC_LRO_MAX_AGGR;
1915 enic->lro_mgr.max_desc = ENIC_LRO_MAX_DESC;
1916 enic->lro_mgr.lro_arr = enic->lro_desc;
1917 enic->lro_mgr.get_skb_header = enic_get_skb_header;
1918 enic->lro_mgr.features = LRO_F_NAPI | LRO_F_EXTRACT_VLAN_ID;
1919 enic->lro_mgr.dev = netdev;
1920 enic->lro_mgr.ip_summed = CHECKSUM_COMPLETE;
1921 enic->lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
1922
1923 err = register_netdev(netdev);
1924 if (err) {
1925 printk(KERN_ERR PFX
1926 "Cannot register net device, aborting.\n");
1927 goto err_out_free_vnic_resources;
1928 }
1929
1930 return 0;
1931
1932 err_out_free_vnic_resources:
1933 enic_free_vnic_resources(enic);
1934 err_out_dev_close:
1935 vnic_dev_close(enic->vdev);
1936 err_out_vnic_unregister:
1937 enic_clear_intr_mode(enic);
1938 vnic_dev_unregister(enic->vdev);
1939 err_out_iounmap:
1940 enic_iounmap(enic);
1941 err_out_release_regions:
1942 pci_release_regions(pdev);
1943 err_out_disable_device:
1944 pci_disable_device(pdev);
1945 err_out_free_netdev:
1946 pci_set_drvdata(pdev, NULL);
1947 free_netdev(netdev);
1948
1949 return err;
1950 }
1951
1952 static void __devexit enic_remove(struct pci_dev *pdev)
1953 {
1954 struct net_device *netdev = pci_get_drvdata(pdev);
1955
1956 if (netdev) {
1957 struct enic *enic = netdev_priv(netdev);
1958
1959 flush_scheduled_work();
1960 unregister_netdev(netdev);
1961 enic_free_vnic_resources(enic);
1962 vnic_dev_close(enic->vdev);
1963 enic_clear_intr_mode(enic);
1964 vnic_dev_unregister(enic->vdev);
1965 enic_iounmap(enic);
1966 pci_release_regions(pdev);
1967 pci_disable_device(pdev);
1968 pci_set_drvdata(pdev, NULL);
1969 free_netdev(netdev);
1970 }
1971 }
1972
1973 static struct pci_driver enic_driver = {
1974 .name = DRV_NAME,
1975 .id_table = enic_id_table,
1976 .probe = enic_probe,
1977 .remove = __devexit_p(enic_remove),
1978 };
1979
1980 static int __init enic_init_module(void)
1981 {
1982 printk(KERN_INFO PFX "%s, ver %s\n", DRV_DESCRIPTION, DRV_VERSION);
1983
1984 return pci_register_driver(&enic_driver);
1985 }
1986
1987 static void __exit enic_cleanup_module(void)
1988 {
1989 pci_unregister_driver(&enic_driver);
1990 }
1991
1992 module_init(enic_init_module);
1993 module_exit(enic_cleanup_module);
This page took 0.164992 seconds and 4 git commands to generate.