[vxge] Add stub vxge.c file so bin/vxge.usb can be built
[people/mcb30/gpxe.git] / src / drivers / net / vxge / vxge_main.c
1 /*
2  * vxge-main.c: gPXE driver for Neterion Inc's X3100 Series 10GbE
3  *              PCIe I/O Virtualized Server Adapter.
4  *
5  * Copyright(c) 2002-2010 Neterion Inc.
6  *
7  * This software may be used and distributed according to the terms of
8  * the GNU General Public License (GPL), incorporated herein by
9  * reference.  Drivers based on or derived from this code fall under
10  * the GPL and must retain the authorship, copyright and license
11  * notice.
12  *
13  */
14
15 FILE_LICENCE(GPL2_ONLY);
16
17 #include <stdlib.h>
18 #include <stdio.h>
19 #include <string.h>
20 #include <gpxe/io.h>
21 #include <errno.h>
22 #include <byteswap.h>
23 #include <gpxe/pci.h>
24 #include <gpxe/malloc.h>
25 #include <gpxe/if_ether.h>
26 #include <gpxe/ethernet.h>
27 #include <gpxe/iobuf.h>
28 #include <gpxe/netdevice.h>
29 #include <gpxe/timer.h>
30 #include <nic.h>
31
32 #include "vxge_main.h"
33 #include "vxge_reg.h"
34
35 /* function modes strings */
36 static char *vxge_func_mode_names[] = {
37         "Single Function - 1 func, 17 vpath",
38         "Multi Function 8 - 8 func, 2 vpath per func",
39         "SRIOV 17 - 17 VF, 1 vpath per VF",
40         "WLPEX/SharedIO 17 - 17 VH, 1 vpath/func/hierarchy",
41         "WLPEX/SharedIO 8 - 8 VH, 2 vpath/func/hierarchy",
42         "Multi Function 17 - 17 func, 1 vpath per func",
43         "SRIOV 8 - 1 PF, 7 VF, 2 vpath per VF",
44         "SRIOV 4 - 1 PF, 3 VF, 4 vpath per VF",
45         "Multi Function 2 - 2 func, 8 vpath per func",
46         "Multi Function 4 - 4 func, 4 vpath per func",
47         "WLPEX/SharedIO 4 - 17 func, 1 vpath per func (PCIe ARI)",
48 };
49
50 static inline int is_vxge_card_up(struct vxgedev *vdev)
51 {
52         return test_bit(__VXGE_STATE_CARD_UP, vdev->state);
53 }
54
55 /*
56  * vxge_xmit_compl
57  *
58  * If an interrupt was raised to indicate DMA complete of the Tx packet,
59  * this function is called. It identifies the last TxD whose buffer was
60  * freed and frees all skbs whose data have already DMA'ed into the NICs
61  * internal memory.
62  */
63 enum vxge_hw_status
64 vxge_xmit_compl(struct __vxge_hw_fifo *fifo_hw,
65                 struct vxge_hw_fifo_txd *txdp, enum vxge_hw_fifo_tcode tcode)
66 {
67         struct net_device *netdev;
68         struct io_buffer *tx_iob = NULL;
69
70         vxge_trace();
71
72         netdev = fifo_hw->vpathh->hldev->ndev;
73
74         tx_iob = (struct io_buffer *)(intptr_t)txdp->host_control;
75
76         if (tcode == VXGE_HW_FIFO_T_CODE_OK) {
77                 netdev_tx_complete(netdev, tx_iob);
78         } else {
79                 netdev_tx_complete_err(netdev, tx_iob, -EINVAL);
80                 vxge_debug(VXGE_ERR, "%s: transmit failed, tcode %d\n",
81                                 netdev->name, tcode);
82         }
83
84         memset(txdp, 0, sizeof(struct vxge_hw_fifo_txd));
85
86         return VXGE_HW_OK;
87 }
88
89 /* reset vpaths */
90 enum vxge_hw_status vxge_reset_all_vpaths(struct vxgedev *vdev)
91 {
92         enum vxge_hw_status status = VXGE_HW_OK;
93         struct __vxge_hw_virtualpath *vpath;
94
95         vxge_trace();
96
97         vpath = vdev->vpath.vpathh;
98
99         if (vpath) {
100                 if ((status = vxge_hw_vpath_reset(vpath)) == VXGE_HW_OK) {
101                         if (is_vxge_card_up(vdev) &&
102                                 (status = vxge_hw_vpath_recover_from_reset(
103                                         vpath)) != VXGE_HW_OK) {
104                                 vxge_debug(VXGE_ERR, "vxge_hw_vpath_recover_"
105                                         "from_reset failed\n");
106                                 return status;
107                         } else {
108                                 status = __vxge_hw_vpath_reset_check(vpath);
109                                 if (status != VXGE_HW_OK) {
110                                         vxge_debug(VXGE_ERR,
111                                         "__vxge_hw_vpath_reset_check error\n");
112                                         return status;
113                                 }
114                         }
115                 } else {
116                         vxge_debug(VXGE_ERR, "vxge_hw_vpath_reset failed\n");
117                         return status;
118                 }
119         }
120         return status;
121 }
122
123 /* close vpaths */
124 void vxge_close_vpaths(struct vxgedev *vdev)
125 {
126
127         if (vdev->vpath.vpathh && vdev->vpath.is_open)
128                 vxge_hw_vpath_close(vdev->vpath.vpathh);
129
130         vdev->vpath.is_open = 0;
131         vdev->vpath.vpathh = NULL;
132 }
133
134 /* open vpaths */
135 int vxge_open_vpaths(struct vxgedev *vdev)
136 {
137         enum vxge_hw_status status;
138         struct __vxge_hw_device *hldev;
139
140         hldev = (struct __vxge_hw_device  *)pci_get_drvdata(vdev->pdev);
141
142         vdev->vpath.vpathh = &hldev->virtual_path;
143         vdev->vpath.fifo.ndev = vdev->ndev;
144         vdev->vpath.fifo.pdev = vdev->pdev;
145         vdev->vpath.fifo.fifoh = &hldev->virtual_path.fifoh;
146         vdev->vpath.ring.ndev = vdev->ndev;
147         vdev->vpath.ring.pdev = vdev->pdev;
148         vdev->vpath.ring.ringh = &hldev->virtual_path.ringh;
149
150         status = vxge_hw_vpath_open(vdev->devh, &vdev->vpath);
151         if (status == VXGE_HW_OK) {
152                 vdev->vpath.is_open = 1;
153         } else {
154                 vxge_debug(VXGE_ERR,
155                         "%s: vpath: %d failed to open "
156                         "with status: %d\n",
157                         vdev->ndev->name, vdev->vpath.device_id,
158                         status);
159                 vxge_close_vpaths(vdev);
160                 return status;
161         }
162
163         hldev->vpaths_deployed |= vxge_mBIT(vdev->vpath.vpathh->vp_id);
164
165         return VXGE_HW_OK;
166 }
167
168 /** Functions that implement the gPXE driver API **/
169
170 /**
171  * vxge_xmit
172  * @skb : the socket buffer containing the Tx data.
173  * @dev : device pointer.
174  *
175  * This function is the Tx entry point of the driver. Neterion NIC supports
176  * certain protocol assist features on Tx side, namely  CSO, S/G, LSO.
177  */
178 static int
179 vxge_xmit(struct net_device *dev, struct io_buffer *iobuf)
180 {
181         struct vxge_fifo *fifo = NULL;
182         struct vxgedev *vdev = NULL;
183         struct __vxge_hw_fifo *fifoh;
184         struct __vxge_hw_device  *hldev;
185         struct vxge_hw_fifo_txd *txdp;
186
187         vxge_trace();
188
189         vdev = (struct vxgedev *)netdev_priv(dev);
190         hldev = (struct __vxge_hw_device  *)pci_get_drvdata(vdev->pdev);
191
192         if (!is_vxge_card_up(vdev)) {
193                 vxge_debug(VXGE_ERR,
194                         "%s: vdev not initialized\n", dev->name);
195                 return -EIO;
196         }
197
198         if (!netdev_link_ok(dev)) {
199                 vxge_debug(VXGE_ERR,
200                         "%s: Link down, transmit failed\n", dev->name);
201                 return -ENETDOWN;
202         }
203
204         fifo = &vdev->vpath.fifo;
205         fifoh = fifo->fifoh;
206
207         txdp = vxge_hw_fifo_free_txdl_get(fifoh);
208         if (!txdp) {
209                 vxge_debug(VXGE_ERR,
210                         "%s: Out of tx descriptors\n", dev->name);
211                 return -ENOBUFS;
212         }
213
214         vxge_debug(VXGE_XMIT, "%s: %s:%d fifoh offset= %d\n",
215                 dev->name, __func__, __LINE__, fifoh->sw_offset);
216
217         vxge_hw_fifo_txdl_buffer_set(fifoh, txdp, iobuf);
218
219         vxge_hw_fifo_txdl_post(fifoh, txdp);
220
221         return 0;
222 }
223
224 /*
225  *  vxge_poll
226  *  @ndev: net device pointer
227  *
228  *  This function acks the interrupt. It polls for rx packets
229  *  and send to upper layer. It also checks for tx completion
230  *  and frees iobs.
231  */
232 static void vxge_poll(struct net_device *ndev)
233 {
234         struct __vxge_hw_device  *hldev;
235         struct vxgedev *vdev;
236
237         vxge_debug(VXGE_POLL, "%s:%d \n", __func__, __LINE__);
238
239         vdev = (struct vxgedev *)netdev_priv(ndev);
240         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
241
242         if (!is_vxge_card_up(vdev))
243                 return;
244
245         /* process alarm and acknowledge the interrupts */
246         vxge_hw_device_begin_irq(hldev);
247
248         vxge_hw_vpath_poll_tx(&hldev->virtual_path.fifoh);
249
250         vxge_hw_vpath_poll_rx(&hldev->virtual_path.ringh);
251 }
252
253 /*
254  * vxge_irq - enable or Disable interrupts
255  *
256  * @netdev   netdevice sturcture reference
257  * @action   requested interrupt action
258  */
259 static void vxge_irq(struct net_device *netdev __unused, int action)
260 {
261         struct __vxge_hw_device  *hldev;
262         struct vxgedev *vdev;
263
264         vxge_debug(VXGE_INFO,
265                 "%s:%d action(%d)\n", __func__, __LINE__, action);
266
267         vdev = (struct vxgedev *)netdev_priv(netdev);
268         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
269
270         switch (action) {
271         case DISABLE:
272                 vxge_hw_device_mask_all(hldev);
273                 break;
274         default:
275                 vxge_hw_device_unmask_all(hldev);
276                 break;
277         }
278 }
279
280 /**
281  * vxge_open
282  * @dev: pointer to the device structure.
283  *
284  * This function is the open entry point of the driver. It mainly calls a
285  * function to allocate Rx buffers and inserts them into the buffer
286  * descriptors and then enables the Rx part of the NIC.
287  * Return value: '0' on success and an appropriate (-)ve integer as
288  * defined in errno.h file on failure.
289  */
290 int
291 vxge_open(struct net_device *dev)
292 {
293         enum vxge_hw_status status;
294         struct vxgedev *vdev;
295         struct __vxge_hw_device *hldev;
296         int ret = 0;
297
298         vxge_debug(VXGE_INFO, "%s: %s:%d\n",
299                         VXGE_DRIVER_NAME, __func__, __LINE__);
300
301         vdev = (struct vxgedev *)netdev_priv(dev);
302         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
303
304         /* make sure you have link off by default every time Nic is
305          * initialized */
306         netdev_link_down(dev);
307
308         /* Open VPATHs */
309         status = vxge_open_vpaths(vdev);
310         if (status != VXGE_HW_OK) {
311                 vxge_debug(VXGE_ERR, "%s: fatal: Vpath open failed\n",
312                                 VXGE_DRIVER_NAME);
313                 ret = -EPERM;
314                 goto out0;
315         }
316
317         vdev->mtu = VXGE_HW_DEFAULT_MTU;
318         /* set initial mtu before enabling the device */
319         status = vxge_hw_vpath_mtu_set(vdev->vpath.vpathh, vdev->mtu);
320         if (status != VXGE_HW_OK) {
321                 vxge_debug(VXGE_ERR,
322                         "%s: fatal: can not set new MTU\n", dev->name);
323                 ret = -EPERM;
324                 goto out2;
325         }
326         vxge_debug(VXGE_INFO,
327                 "%s: MTU is %d\n", vdev->ndev->name, vdev->mtu);
328
329         set_bit(__VXGE_STATE_CARD_UP, vdev->state);
330
331         wmb();
332
333         if (vxge_hw_device_link_state_get(vdev->devh) == VXGE_HW_LINK_UP) {
334                 netdev_link_up(vdev->ndev);
335                 vxge_debug(VXGE_INFO, "%s: Link Up\n", vdev->ndev->name);
336         }
337
338         vxge_hw_device_intr_enable(hldev);
339
340         vxge_hw_vpath_enable(vdev->vpath.vpathh);
341         wmb();
342         vxge_hw_vpath_rx_doorbell_init(vdev->vpath.vpathh);
343
344         goto out0;
345
346 out2:
347         vxge_close_vpaths(vdev);
348 out0:
349         vxge_debug(VXGE_INFO, "%s: %s:%d  Exiting...\n",
350                                 dev->name, __func__, __LINE__);
351         return ret;
352 }
353
354 /**
355  * vxge_close
356  * @dev: device pointer.
357  *
358  * This is the stop entry point of the driver. It needs to undo exactly
359  * whatever was done by the open entry point, thus it's usually referred to
360  * as the close function.Among other things this function mainly stops the
361  * Rx side of the NIC and frees all the Rx buffers in the Rx rings.
362  * Return value: '0' on success and an appropriate (-)ve integer as
363  * defined in errno.h file on failure.
364  */
365 static void vxge_close(struct net_device *dev)
366 {
367         struct vxgedev *vdev;
368         struct __vxge_hw_device *hldev;
369
370         vxge_debug(VXGE_INFO, "%s: %s:%d\n",
371                 dev->name, __func__, __LINE__);
372
373         vdev = (struct vxgedev *)netdev_priv(dev);
374         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
375
376         if (!is_vxge_card_up(vdev))
377                 return;
378
379         clear_bit(__VXGE_STATE_CARD_UP, vdev->state);
380
381         vxge_hw_vpath_set_zero_rx_frm_len(hldev);
382
383         netdev_link_down(vdev->ndev);
384         vxge_debug(VXGE_INFO, "%s: Link Down\n", vdev->ndev->name);
385
386         /* Note that at this point xmit() is stopped by upper layer */
387         vxge_hw_device_intr_disable(hldev);
388
389         /* Multi function shares INTA, hence we should
390          * leave it in enabled state
391          */
392         if (is_mf(hldev->hw_info.function_mode))
393                 vxge_hw_device_unmask_all(hldev);
394
395         vxge_reset_all_vpaths(vdev);
396
397         vxge_close_vpaths(vdev);
398
399         vxge_debug(VXGE_INFO,
400                 "%s: %s:%d  Exiting...\n", dev->name, __func__, __LINE__);
401 }
402
403 static struct net_device_operations vxge_operations;
404
405 int vxge_device_register(struct __vxge_hw_device *hldev,
406                                 struct vxgedev **vdev_out)
407 {
408         struct net_device *ndev;
409         struct vxgedev *vdev;
410         int ret = 0;
411
412         *vdev_out = NULL;
413
414         ndev = alloc_etherdev(sizeof(struct vxgedev));
415         if (ndev == NULL) {
416                 vxge_debug(VXGE_ERR, "%s : device allocation failed\n",
417                                 __func__);
418                 ret = -ENODEV;
419                 goto _out0;
420         }
421
422         vxge_debug(VXGE_INFO, "%s:%d  netdev registering\n",
423                 __func__, __LINE__);
424         vdev = netdev_priv(ndev);
425         memset(vdev, 0, sizeof(struct vxgedev));
426
427         vdev->ndev = ndev;
428         vdev->devh = hldev;
429         vdev->pdev = hldev->pdev;
430
431         ndev->dev = &vdev->pdev->dev;
432         /* Associate vxge-specific network operations operations with
433          * generic network device layer */
434         netdev_init(ndev, &vxge_operations);
435
436         memcpy(ndev->hw_addr,
437                 (u8 *)hldev->hw_info.mac_addrs[hldev->first_vp_id], ETH_ALEN);
438
439         if (register_netdev(ndev)) {
440                 vxge_debug(VXGE_ERR, "%s : device registration failed!\n",
441                         __func__);
442                 ret = -ENODEV;
443                 goto _out2;
444         }
445
446         /* Make Link state as off at this point, when the Link change
447          * interrupt comes the state will be automatically changed to
448          * the right state.
449          */
450         netdev_link_down(ndev);
451
452         vxge_debug(VXGE_INFO, "%s: Ethernet device registered\n",
453                 VXGE_DRIVER_NAME);
454
455         *vdev_out = vdev;
456
457         return ret;
458 _out2:
459         netdev_put(ndev);
460 _out0:
461         return ret;
462 }
463
464 /*
465  * vxge_device_unregister
466  *
467  * This function will unregister and free network device
468  */
469 void
470 vxge_device_unregister(struct __vxge_hw_device *hldev)
471 {
472         struct vxgedev *vdev;
473         struct net_device *ndev;
474
475         ndev = hldev->ndev;
476         vdev = netdev_priv(ndev);
477
478         unregister_netdev(ndev);
479         netdev_nullify(ndev);
480         netdev_put(ndev);
481
482         vxge_debug(VXGE_INFO, "%s: ethernet device unregistered\n",
483                                 VXGE_DRIVER_NAME);
484 }
485
486 /**
487  * vxge_probe
488  * @pdev : structure containing the PCI related information of the device.
489  * @id: List of PCI devices supported by the driver listed in vxge_id_table.
490  * Description:
491  * This function is called when a new PCI device gets detected and initializes
492  * it.
493  * Return value:
494  * returns 0 on success and negative on failure.
495  *
496  */
497 static int
498 vxge_probe(struct pci_device *pdev, const struct pci_device_id *id __unused)
499 {
500         struct __vxge_hw_device  *hldev;
501         enum vxge_hw_status status;
502         int ret = 0;
503         u64 vpath_mask = 0;
504         struct vxgedev *vdev;
505         int i;
506         u8 revision, titan1;
507         u32 host_type;
508         u32 function_mode;
509         unsigned long mmio_start, mmio_len;
510         void *bar0;
511         struct vxge_hw_device_hw_info hw_info;
512         struct vxge_hw_device_version *fw_version;
513
514         vxge_debug(VXGE_INFO, "vxge_probe for device %02X:%02X.%X\n",
515                         pdev->bus, PCI_SLOT(pdev->devfn),
516                         PCI_FUNC(pdev->devfn));
517
518         pci_read_config_byte(pdev, PCI_REVISION_ID, &revision);
519         titan1 = is_titan1(pdev->device, revision);
520
521         mmio_start = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
522         mmio_len   = pci_bar_size(pdev, PCI_BASE_ADDRESS_0);
523         vxge_debug(VXGE_INFO, "mmio_start: %#08lx, mmio_len: %#08lx\n",
524                         mmio_start, mmio_len);
525
526         /* sets the bus master */
527         adjust_pci_device(pdev);
528
529         bar0 = ioremap(mmio_start, mmio_len);
530         if (!bar0) {
531                 vxge_debug(VXGE_ERR,
532                         "%s : cannot remap io memory bar0\n", __func__);
533                 ret = -ENODEV;
534                 goto _exit0;
535         }
536
537         status = vxge_hw_device_hw_info_get(bar0, &hw_info);
538         if (status != VXGE_HW_OK) {
539                 vxge_debug(VXGE_ERR,
540                         "%s: Reading of hardware info failed.\n",
541                         VXGE_DRIVER_NAME);
542                 ret = -EINVAL;
543                 goto _exit1;
544         }
545
546         if (hw_info.func_id != 0) {
547                 /* Non zero function, So do not load the driver */
548                 iounmap(bar0);
549                 pci_set_drvdata(pdev, NULL);
550                 return -EINVAL;
551         }
552
553
554         vpath_mask = hw_info.vpath_mask;
555         if (vpath_mask == 0) {
556                 vxge_debug(VXGE_ERR,
557                         "%s: No vpaths available in device\n",
558                         VXGE_DRIVER_NAME);
559                 ret = -EINVAL;
560                 goto _exit1;
561         }
562         vxge_debug(VXGE_INFO,
563                 "%s:%d  Vpath mask = %llx\n", __func__, __LINE__,
564                 (unsigned long long)vpath_mask);
565
566         host_type = hw_info.host_type;
567         fw_version = &hw_info.fw_version;
568         /* fail the driver loading if firmware is incompatible */
569         if ((fw_version->major != VXGE_CERT_FW_VER_MAJOR) ||
570                 (fw_version->minor < VXGE_CERT_FW_VER_MINOR)) {
571                 printf("%s: Adapter's current firmware version: %d.%d.%d\n",
572                         VXGE_DRIVER_NAME, fw_version->major,
573                         fw_version->minor, fw_version->build);
574
575                 printf("%s: Upgrade firmware to version %d.%d.%d\n",
576                         VXGE_DRIVER_NAME, VXGE_CERT_FW_VER_MAJOR,
577                         VXGE_CERT_FW_VER_MINOR, VXGE_CERT_FW_VER_BUILD);
578
579                 ret = -EACCES;
580                 goto _exit1;
581         }
582
583         status = vxge_hw_device_initialize(&hldev, bar0, pdev, titan1);
584         if (status != VXGE_HW_OK) {
585                 vxge_debug(VXGE_ERR,
586                         "Failed to initialize device (%d)\n", status);
587                         ret = -EINVAL;
588                         goto _exit1;
589         }
590         memcpy(&hldev->hw_info, &hw_info,
591                 sizeof(struct vxge_hw_device_hw_info));
592
593         /* find the vpath id of the first available one */
594         for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++)
595                 if (vpath_mask & vxge_mBIT(i)) {
596                         hldev->first_vp_id = i;
597                         break;
598                 }
599         /* if FCS stripping is not disabled in MAC fail driver load */
600         if (vxge_hw_vpath_strip_fcs_check(hldev, vpath_mask) != VXGE_HW_OK) {
601                 vxge_debug(VXGE_ERR,
602                         "%s: FCS stripping is not disabled in MAC"
603                         " failing driver load\n", VXGE_DRIVER_NAME);
604                 ret = -EINVAL;
605                 goto _exit2;
606         }
607
608         /* Read function mode */
609         status = vxge_hw_get_func_mode(hldev, &function_mode);
610         if (status != VXGE_HW_OK)
611                 goto _exit2;
612
613         hldev->hw_info.function_mode = function_mode;
614
615         /* set private device info */
616         pci_set_drvdata(pdev, hldev);
617
618         if (vxge_device_register(hldev, &vdev)) {
619                 ret = -EINVAL;
620                 goto _exit2;
621         }
622
623         /* set private HW device info */
624         hldev->ndev = vdev->ndev;
625         hldev->vdev = vdev;
626         hldev->pdev = pdev;
627         vdev->mtu = VXGE_HW_DEFAULT_MTU;
628         vdev->bar0 = bar0;
629         vdev->titan1 = titan1;
630         /* Virtual Path count */
631         vdev->vpath.device_id = hldev->first_vp_id;
632         vdev->vpath.vdev = vdev;
633         memcpy((u8 *)vdev->vpath.macaddr,
634                         (u8 *)hldev->hw_info.mac_addrs[hldev->first_vp_id],
635                         ETH_ALEN);
636
637         hldev->hw_info.serial_number[VXGE_HW_INFO_LEN - 1] = '\0';
638         hldev->hw_info.product_desc[VXGE_HW_INFO_LEN - 1] = '\0';
639         hldev->hw_info.part_number[VXGE_HW_INFO_LEN - 1] = '\0';
640
641         vxge_debug(VXGE_INFO, "%s: Neterion %s Server Adapter\n",
642                 VXGE_DRIVER_NAME, hldev->hw_info.product_desc);
643         vxge_debug(VXGE_INFO, "%s: SERIAL NUMBER: %s\n",
644                 VXGE_DRIVER_NAME, hldev->hw_info.serial_number);
645         vxge_debug(VXGE_INFO, "%s: PART NUMBER: %s\n",
646                 VXGE_DRIVER_NAME, hldev->hw_info.part_number);
647         vxge_debug(VXGE_INFO, "%s: MAC ADDR: %s\n",
648                 VXGE_DRIVER_NAME, eth_ntoa(vdev->vpath.macaddr));
649         vxge_debug(VXGE_INFO,
650                 "%s: Firmware version : %s Date : %s\n", VXGE_DRIVER_NAME,
651                 hldev->hw_info.fw_version.version,
652                 hldev->hw_info.fw_date.date);
653         vxge_debug(VXGE_INFO, "%s: %s Enabled\n",
654                         VXGE_DRIVER_NAME, vxge_func_mode_names[function_mode]);
655
656         vxge_debug(VXGE_INFO, "%s: %s:%d  Probe Exiting...\n",
657                 VXGE_DRIVER_NAME, __func__, __LINE__);
658
659         return 0;
660
661 _exit2:
662         vxge_hw_device_terminate(hldev);
663 _exit1:
664         iounmap(bar0);
665 _exit0:
666         pci_set_drvdata(pdev, NULL);
667         printf("%s: WARNING!! Driver loading failed!!\n",
668                 VXGE_DRIVER_NAME);
669
670         return ret;
671 }
672
673 /**
674  * vxge_remove - Free the PCI device
675  * @pdev: structure containing the PCI related information of the device.
676  * Description: This function is called by the Pci subsystem to release a
677  * PCI device and free up all resource held up by the device.
678  */
679 static void
680 vxge_remove(struct pci_device *pdev)
681 {
682         struct __vxge_hw_device  *hldev;
683         struct vxgedev *vdev = NULL;
684         struct net_device *ndev;
685
686         vxge_debug(VXGE_INFO,
687                 "%s:%d\n", __func__, __LINE__);
688         hldev = (struct __vxge_hw_device  *) pci_get_drvdata(pdev);
689         if (hldev == NULL)
690                 return;
691
692         ndev = hldev->ndev;
693         vdev = netdev_priv(ndev);
694
695         iounmap(vdev->bar0);
696
697         vxge_device_unregister(hldev);
698
699         vxge_debug(VXGE_INFO,
700                 "%s:%d  Device unregistered\n", __func__, __LINE__);
701
702         vxge_hw_device_terminate(hldev);
703         pci_set_drvdata(pdev, NULL);
704 }
705
706 /* vxge net device operations */
707 static struct net_device_operations vxge_operations = {
708         .open           = vxge_open,
709         .close          = vxge_close,
710         .transmit       = vxge_xmit,
711         .poll           = vxge_poll,
712         .irq            = vxge_irq,
713 };
714
715 static struct pci_device_id vxge_main_nics[] = {
716         /* If you change this, also adjust vxge_nics[] in vxge.c */
717         PCI_ID(0x17d5, 0x5833, "vxge-x3100", "Neterion X3100 Series", 0),
718 };
719
720 struct pci_driver vxge_driver __pci_driver = {
721         .ids = vxge_main_nics,
722         .id_count = (sizeof(vxge_main_nics) / sizeof(vxge_main_nics[0])),
723         .probe = vxge_probe,
724         .remove = vxge_remove,
725 };