vxge_main.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gpxe/io.h>
#include <errno.h>
#include <byteswap.h>
#include <gpxe/pci.h>
#include <gpxe/malloc.h>
#include <gpxe/if_ether.h>
#include <gpxe/ethernet.h>
#include <gpxe/iobuf.h>
#include <gpxe/netdevice.h>
#include <gpxe/timer.h>
#include <nic.h>
#include "vxge_main.h"
#include "vxge_reg.h"

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_ONLY)
static int is_vxge_card_up (struct vxgedev *vdev)
enum vxge_hw_status vxge_xmit_compl (struct __vxge_hw_fifo *fifo_hw, struct vxge_hw_fifo_txd *txdp, enum vxge_hw_fifo_tcode tcode)
enum vxge_hw_status vxge_reset_all_vpaths (struct vxgedev *vdev)
void vxge_close_vpaths (struct vxgedev *vdev)
int vxge_open_vpaths (struct vxgedev *vdev)
static int vxge_xmit (struct net_device *dev, struct io_buffer *iobuf)
 Functions that implement the gPXE driver API.
static void vxge_poll (struct net_device *ndev)
static void vxge_irq (struct net_device *netdev __unused, int action)
int vxge_open (struct net_device *dev)
 vxge_open : pointer to the device structure.
static void vxge_close (struct net_device *dev)
 vxge_close : device pointer.
int vxge_device_register (struct __vxge_hw_device *hldev, struct vxgedev **vdev_out)
void vxge_device_unregister (struct __vxge_hw_device *hldev)
static int vxge_probe (struct pci_device *pdev, const struct pci_device_id *id __unused)
 vxge_probe : structure containing the PCI related information of the device.
static void vxge_remove (struct pci_device *pdev)
 vxge_remove - Free the PCI device : structure containing the PCI related information of the device.

Variables

static char * vxge_func_mode_names []
static struct net_device_operations vxge_operations
static struct pci_device_id vxge_main_nics []
struct pci_driver vxge_driver __pci_driver


Function Documentation

FILE_LICENCE ( GPL2_ONLY   ) 

static int is_vxge_card_up ( struct vxgedev vdev  )  [inline, static]

Definition at line 50 of file vxge_main.c.

References __VXGE_STATE_CARD_UP, vxgedev::state, and test_bit.

Referenced by vxge_close(), vxge_poll(), vxge_reset_all_vpaths(), and vxge_xmit().

00051 {
00052         return test_bit(__VXGE_STATE_CARD_UP, vdev->state);
00053 }

enum vxge_hw_status vxge_xmit_compl ( struct __vxge_hw_fifo fifo_hw,
struct vxge_hw_fifo_txd txdp,
enum vxge_hw_fifo_tcode  tcode 
)

Definition at line 64 of file vxge_main.c.

References EINVAL, __vxge_hw_virtualpath::hldev, vxge_hw_fifo_txd::host_control, memset(), net_device::name, __vxge_hw_device::ndev, netdev, netdev_tx_complete(), netdev_tx_complete_err(), NULL, __vxge_hw_fifo::vpathh, vxge_debug, VXGE_ERR, VXGE_HW_FIFO_T_CODE_OK, VXGE_HW_OK, and vxge_trace.

Referenced by vxge_hw_vpath_poll_tx().

00066 {
00067         struct net_device *netdev;
00068         struct io_buffer *tx_iob = NULL;
00069 
00070         vxge_trace();
00071 
00072         netdev = fifo_hw->vpathh->hldev->ndev;
00073 
00074         tx_iob = (struct io_buffer *)(intptr_t)txdp->host_control;
00075 
00076         if (tcode == VXGE_HW_FIFO_T_CODE_OK) {
00077                 netdev_tx_complete(netdev, tx_iob);
00078         } else {
00079                 netdev_tx_complete_err(netdev, tx_iob, -EINVAL);
00080                 vxge_debug(VXGE_ERR, "%s: transmit failed, tcode %d\n",
00081                                 netdev->name, tcode);
00082         }
00083 
00084         memset(txdp, 0, sizeof(struct vxge_hw_fifo_txd));
00085 
00086         return VXGE_HW_OK;
00087 }

enum vxge_hw_status vxge_reset_all_vpaths ( struct vxgedev vdev  ) 

Definition at line 90 of file vxge_main.c.

References __vxge_hw_vpath_reset_check(), is_vxge_card_up(), vxgedev::vpath, vxge_vpath::vpathh, vxge_debug, VXGE_ERR, VXGE_HW_OK, vxge_hw_vpath_recover_from_reset(), vxge_hw_vpath_reset(), and vxge_trace.

Referenced by vxge_close().

00091 {
00092         enum vxge_hw_status status = VXGE_HW_OK;
00093         struct __vxge_hw_virtualpath *vpath;
00094 
00095         vxge_trace();
00096 
00097         vpath = vdev->vpath.vpathh;
00098 
00099         if (vpath) {
00100                 if ((status = vxge_hw_vpath_reset(vpath)) == VXGE_HW_OK) {
00101                         if (is_vxge_card_up(vdev) &&
00102                                 (status = vxge_hw_vpath_recover_from_reset(
00103                                         vpath)) != VXGE_HW_OK) {
00104                                 vxge_debug(VXGE_ERR, "vxge_hw_vpath_recover_"
00105                                         "from_reset failed\n");
00106                                 return status;
00107                         } else {
00108                                 status = __vxge_hw_vpath_reset_check(vpath);
00109                                 if (status != VXGE_HW_OK) {
00110                                         vxge_debug(VXGE_ERR,
00111                                         "__vxge_hw_vpath_reset_check error\n");
00112                                         return status;
00113                                 }
00114                         }
00115                 } else {
00116                         vxge_debug(VXGE_ERR, "vxge_hw_vpath_reset failed\n");
00117                         return status;
00118                 }
00119         }
00120         return status;
00121 }

void vxge_close_vpaths ( struct vxgedev vdev  ) 

Definition at line 124 of file vxge_main.c.

References vxge_vpath::is_open, NULL, vxgedev::vpath, vxge_vpath::vpathh, and vxge_hw_vpath_close().

Referenced by vxge_close(), vxge_open(), and vxge_open_vpaths().

00125 {
00126 
00127         if (vdev->vpath.vpathh && vdev->vpath.is_open)
00128                 vxge_hw_vpath_close(vdev->vpath.vpathh);
00129 
00130         vdev->vpath.is_open = 0;
00131         vdev->vpath.vpathh = NULL;
00132 }

int vxge_open_vpaths ( struct vxgedev vdev  ) 

Definition at line 135 of file vxge_main.c.

References vxgedev::devh, vxge_vpath::device_id, vxge_vpath::fifo, __vxge_hw_virtualpath::fifoh, vxge_fifo::fifoh, vxge_vpath::is_open, net_device::name, vxge_ring::ndev, vxgedev::ndev, vxge_fifo::ndev, pci_get_drvdata(), vxge_ring::pdev, vxge_fifo::pdev, vxgedev::pdev, vxge_vpath::ring, __vxge_hw_virtualpath::ringh, vxge_ring::ringh, __vxge_hw_device::virtual_path, __vxge_hw_virtualpath::vp_id, vxgedev::vpath, vxge_vpath::vpathh, __vxge_hw_device::vpaths_deployed, vxge_close_vpaths(), vxge_debug, VXGE_ERR, VXGE_HW_OK, vxge_hw_vpath_open(), and vxge_mBIT.

Referenced by vxge_open().

00136 {
00137         enum vxge_hw_status status;
00138         struct __vxge_hw_device *hldev;
00139 
00140         hldev = (struct __vxge_hw_device  *)pci_get_drvdata(vdev->pdev);
00141 
00142         vdev->vpath.vpathh = &hldev->virtual_path;
00143         vdev->vpath.fifo.ndev = vdev->ndev;
00144         vdev->vpath.fifo.pdev = vdev->pdev;
00145         vdev->vpath.fifo.fifoh = &hldev->virtual_path.fifoh;
00146         vdev->vpath.ring.ndev = vdev->ndev;
00147         vdev->vpath.ring.pdev = vdev->pdev;
00148         vdev->vpath.ring.ringh = &hldev->virtual_path.ringh;
00149 
00150         status = vxge_hw_vpath_open(vdev->devh, &vdev->vpath);
00151         if (status == VXGE_HW_OK) {
00152                 vdev->vpath.is_open = 1;
00153         } else {
00154                 vxge_debug(VXGE_ERR,
00155                         "%s: vpath: %d failed to open "
00156                         "with status: %d\n",
00157                         vdev->ndev->name, vdev->vpath.device_id,
00158                         status);
00159                 vxge_close_vpaths(vdev);
00160                 return status;
00161         }
00162 
00163         hldev->vpaths_deployed |= vxge_mBIT(vdev->vpath.vpathh->vp_id);
00164 
00165         return VXGE_HW_OK;
00166 }

static int vxge_xmit ( struct net_device dev,
struct io_buffer iobuf 
) [static]

Functions that implement the gPXE driver API.

vxge_xmit : the socket buffer containing the Tx data. : device pointer.

This function is the Tx entry point of the driver. Neterion NIC supports certain protocol assist features on Tx side, namely CSO, S/G, LSO.

Definition at line 179 of file vxge_main.c.

References EIO, ENETDOWN, ENOBUFS, vxge_vpath::fifo, vxge_fifo::fifoh, is_vxge_card_up(), net_device::name, netdev_link_ok(), netdev_priv(), NULL, pci_get_drvdata(), vxgedev::pdev, __vxge_hw_fifo::sw_offset, txdp, vxgedev::vpath, vxge_debug, VXGE_ERR, vxge_hw_fifo_free_txdl_get(), vxge_hw_fifo_txdl_buffer_set(), vxge_hw_fifo_txdl_post(), vxge_trace, and VXGE_XMIT.

00180 {
00181         struct vxge_fifo *fifo = NULL;
00182         struct vxgedev *vdev = NULL;
00183         struct __vxge_hw_fifo *fifoh;
00184         struct __vxge_hw_device  *hldev;
00185         struct vxge_hw_fifo_txd *txdp;
00186 
00187         vxge_trace();
00188 
00189         vdev = (struct vxgedev *)netdev_priv(dev);
00190         hldev = (struct __vxge_hw_device  *)pci_get_drvdata(vdev->pdev);
00191 
00192         if (!is_vxge_card_up(vdev)) {
00193                 vxge_debug(VXGE_ERR,
00194                         "%s: vdev not initialized\n", dev->name);
00195                 return -EIO;
00196         }
00197 
00198         if (!netdev_link_ok(dev)) {
00199                 vxge_debug(VXGE_ERR,
00200                         "%s: Link down, transmit failed\n", dev->name);
00201                 return -ENETDOWN;
00202         }
00203 
00204         fifo = &vdev->vpath.fifo;
00205         fifoh = fifo->fifoh;
00206 
00207         txdp = vxge_hw_fifo_free_txdl_get(fifoh);
00208         if (!txdp) {
00209                 vxge_debug(VXGE_ERR,
00210                         "%s: Out of tx descriptors\n", dev->name);
00211                 return -ENOBUFS;
00212         }
00213 
00214         vxge_debug(VXGE_XMIT, "%s: %s:%d fifoh offset= %d\n",
00215                 dev->name, __func__, __LINE__, fifoh->sw_offset);
00216 
00217         vxge_hw_fifo_txdl_buffer_set(fifoh, txdp, iobuf);
00218 
00219         vxge_hw_fifo_txdl_post(fifoh, txdp);
00220 
00221         return 0;
00222 }

static void vxge_poll ( struct net_device ndev  )  [static]

Definition at line 232 of file vxge_main.c.

References __vxge_hw_virtualpath::fifoh, is_vxge_card_up(), netdev_priv(), pci_get_drvdata(), vxgedev::pdev, __vxge_hw_virtualpath::ringh, __vxge_hw_device::virtual_path, vxge_debug, vxge_hw_device_begin_irq(), vxge_hw_vpath_poll_rx(), vxge_hw_vpath_poll_tx(), and VXGE_POLL.

00233 {
00234         struct __vxge_hw_device  *hldev;
00235         struct vxgedev *vdev;
00236 
00237         vxge_debug(VXGE_POLL, "%s:%d \n", __func__, __LINE__);
00238 
00239         vdev = (struct vxgedev *)netdev_priv(ndev);
00240         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
00241 
00242         if (!is_vxge_card_up(vdev))
00243                 return;
00244 
00245         /* process alarm and acknowledge the interrupts */
00246         vxge_hw_device_begin_irq(hldev);
00247 
00248         vxge_hw_vpath_poll_tx(&hldev->virtual_path.fifoh);
00249 
00250         vxge_hw_vpath_poll_rx(&hldev->virtual_path.ringh);
00251 }

static void vxge_irq ( struct net_device *netdev  __unused,
int  action 
) [static]

Definition at line 259 of file vxge_main.c.

References DISABLE, netdev, netdev_priv(), pci_get_drvdata(), vxgedev::pdev, vxge_debug, vxge_hw_device_mask_all(), vxge_hw_device_unmask_all(), and VXGE_INFO.

00260 {
00261         struct __vxge_hw_device  *hldev;
00262         struct vxgedev *vdev;
00263 
00264         vxge_debug(VXGE_INFO,
00265                 "%s:%d action(%d)\n", __func__, __LINE__, action);
00266 
00267         vdev = (struct vxgedev *)netdev_priv(netdev);
00268         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
00269 
00270         switch (action) {
00271         case DISABLE:
00272                 vxge_hw_device_mask_all(hldev);
00273                 break;
00274         default:
00275                 vxge_hw_device_unmask_all(hldev);
00276                 break;
00277         }
00278 }

int vxge_open ( struct net_device dev  ) 

vxge_open : pointer to the device structure.

This function is the open entry point of the driver. It mainly calls a function to allocate Rx buffers and inserts them into the buffer descriptors and then enables the Rx part of the NIC. Return value: '0' on success and an appropriate (-)ve integer as defined in errno.h file on failure.

Definition at line 291 of file vxge_main.c.

References __VXGE_STATE_CARD_UP, vxgedev::devh, EPERM, vxgedev::mtu, net_device::name, vxgedev::ndev, netdev_link_down(), netdev_link_up(), netdev_priv(), pci_get_drvdata(), vxgedev::pdev, set_bit, vxgedev::state, vxgedev::vpath, vxge_vpath::vpathh, vxge_close_vpaths(), vxge_debug, VXGE_DRIVER_NAME, VXGE_ERR, VXGE_HW_DEFAULT_MTU, vxge_hw_device_intr_enable(), vxge_hw_device_link_state_get(), VXGE_HW_LINK_UP, VXGE_HW_OK, vxge_hw_vpath_enable(), vxge_hw_vpath_mtu_set(), vxge_hw_vpath_rx_doorbell_init(), VXGE_INFO, vxge_open_vpaths(), and wmb.

00292 {
00293         enum vxge_hw_status status;
00294         struct vxgedev *vdev;
00295         struct __vxge_hw_device *hldev;
00296         int ret = 0;
00297 
00298         vxge_debug(VXGE_INFO, "%s: %s:%d\n",
00299                         VXGE_DRIVER_NAME, __func__, __LINE__);
00300 
00301         vdev = (struct vxgedev *)netdev_priv(dev);
00302         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
00303 
00304         /* make sure you have link off by default every time Nic is
00305          * initialized */
00306         netdev_link_down(dev);
00307 
00308         /* Open VPATHs */
00309         status = vxge_open_vpaths(vdev);
00310         if (status != VXGE_HW_OK) {
00311                 vxge_debug(VXGE_ERR, "%s: fatal: Vpath open failed\n",
00312                                 VXGE_DRIVER_NAME);
00313                 ret = -EPERM;
00314                 goto out0;
00315         }
00316 
00317         vdev->mtu = VXGE_HW_DEFAULT_MTU;
00318         /* set initial mtu before enabling the device */
00319         status = vxge_hw_vpath_mtu_set(vdev->vpath.vpathh, vdev->mtu);
00320         if (status != VXGE_HW_OK) {
00321                 vxge_debug(VXGE_ERR,
00322                         "%s: fatal: can not set new MTU\n", dev->name);
00323                 ret = -EPERM;
00324                 goto out2;
00325         }
00326         vxge_debug(VXGE_INFO,
00327                 "%s: MTU is %d\n", vdev->ndev->name, vdev->mtu);
00328 
00329         set_bit(__VXGE_STATE_CARD_UP, vdev->state);
00330 
00331         wmb();
00332 
00333         if (vxge_hw_device_link_state_get(vdev->devh) == VXGE_HW_LINK_UP) {
00334                 netdev_link_up(vdev->ndev);
00335                 vxge_debug(VXGE_INFO, "%s: Link Up\n", vdev->ndev->name);
00336         }
00337 
00338         vxge_hw_device_intr_enable(hldev);
00339 
00340         vxge_hw_vpath_enable(vdev->vpath.vpathh);
00341         wmb();
00342         vxge_hw_vpath_rx_doorbell_init(vdev->vpath.vpathh);
00343 
00344         goto out0;
00345 
00346 out2:
00347         vxge_close_vpaths(vdev);
00348 out0:
00349         vxge_debug(VXGE_INFO, "%s: %s:%d  Exiting...\n",
00350                                 dev->name, __func__, __LINE__);
00351         return ret;
00352 }

static void vxge_close ( struct net_device dev  )  [static]

vxge_close : device pointer.

This is the stop entry point of the driver. It needs to undo exactly whatever was done by the open entry point, thus it's usually referred to as the close function.Among other things this function mainly stops the Rx side of the NIC and frees all the Rx buffers in the Rx rings. Return value: '0' on success and an appropriate (-)ve integer as defined in errno.h file on failure.

Definition at line 365 of file vxge_main.c.

References __VXGE_STATE_CARD_UP, clear_bit, vxge_hw_device_hw_info::function_mode, __vxge_hw_device::hw_info, is_mf, is_vxge_card_up(), net_device::name, vxgedev::ndev, netdev_link_down(), netdev_priv(), pci_get_drvdata(), vxgedev::pdev, vxgedev::state, vxge_close_vpaths(), vxge_debug, vxge_hw_device_intr_disable(), vxge_hw_device_unmask_all(), vxge_hw_vpath_set_zero_rx_frm_len(), VXGE_INFO, and vxge_reset_all_vpaths().

00366 {
00367         struct vxgedev *vdev;
00368         struct __vxge_hw_device *hldev;
00369 
00370         vxge_debug(VXGE_INFO, "%s: %s:%d\n",
00371                 dev->name, __func__, __LINE__);
00372 
00373         vdev = (struct vxgedev *)netdev_priv(dev);
00374         hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev);
00375 
00376         if (!is_vxge_card_up(vdev))
00377                 return;
00378 
00379         clear_bit(__VXGE_STATE_CARD_UP, vdev->state);
00380 
00381         vxge_hw_vpath_set_zero_rx_frm_len(hldev);
00382 
00383         netdev_link_down(vdev->ndev);
00384         vxge_debug(VXGE_INFO, "%s: Link Down\n", vdev->ndev->name);
00385 
00386         /* Note that at this point xmit() is stopped by upper layer */
00387         vxge_hw_device_intr_disable(hldev);
00388 
00389         /* Multi function shares INTA, hence we should
00390          * leave it in enabled state
00391          */
00392         if (is_mf(hldev->hw_info.function_mode))
00393                 vxge_hw_device_unmask_all(hldev);
00394 
00395         vxge_reset_all_vpaths(vdev);
00396 
00397         vxge_close_vpaths(vdev);
00398 
00399         vxge_debug(VXGE_INFO,
00400                 "%s: %s:%d  Exiting...\n", dev->name, __func__, __LINE__);
00401 }

int vxge_device_register ( struct __vxge_hw_device hldev,
struct vxgedev **  vdev_out 
)

Definition at line 405 of file vxge_main.c.

References alloc_etherdev(), pci_device::dev, net_device::dev, vxgedev::devh, ENODEV, ETH_ALEN, __vxge_hw_device::first_vp_id, net_device::hw_addr, __vxge_hw_device::hw_info, memcpy, memset(), vxgedev::ndev, netdev_init(), netdev_link_down(), netdev_priv(), netdev_put(), NULL, __vxge_hw_device::pdev, vxgedev::pdev, register_netdev(), u8, vxge_debug, VXGE_DRIVER_NAME, VXGE_ERR, VXGE_INFO, and vxge_operations.

Referenced by vxge_probe().

00407 {
00408         struct net_device *ndev;
00409         struct vxgedev *vdev;
00410         int ret = 0;
00411 
00412         *vdev_out = NULL;
00413 
00414         ndev = alloc_etherdev(sizeof(struct vxgedev));
00415         if (ndev == NULL) {
00416                 vxge_debug(VXGE_ERR, "%s : device allocation failed\n",
00417                                 __func__);
00418                 ret = -ENODEV;
00419                 goto _out0;
00420         }
00421 
00422         vxge_debug(VXGE_INFO, "%s:%d  netdev registering\n",
00423                 __func__, __LINE__);
00424         vdev = netdev_priv(ndev);
00425         memset(vdev, 0, sizeof(struct vxgedev));
00426 
00427         vdev->ndev = ndev;
00428         vdev->devh = hldev;
00429         vdev->pdev = hldev->pdev;
00430 
00431         ndev->dev = &vdev->pdev->dev;
00432         /* Associate vxge-specific network operations operations with
00433          * generic network device layer */
00434         netdev_init(ndev, &vxge_operations);
00435 
00436         memcpy(ndev->hw_addr,
00437                 (u8 *)hldev->hw_info.mac_addrs[hldev->first_vp_id], ETH_ALEN);
00438 
00439         if (register_netdev(ndev)) {
00440                 vxge_debug(VXGE_ERR, "%s : device registration failed!\n",
00441                         __func__);
00442                 ret = -ENODEV;
00443                 goto _out2;
00444         }
00445 
00446         /* Make Link state as off at this point, when the Link change
00447          * interrupt comes the state will be automatically changed to
00448          * the right state.
00449          */
00450         netdev_link_down(ndev);
00451 
00452         vxge_debug(VXGE_INFO, "%s: Ethernet device registered\n",
00453                 VXGE_DRIVER_NAME);
00454 
00455         *vdev_out = vdev;
00456 
00457         return ret;
00458 _out2:
00459         netdev_put(ndev);
00460 _out0:
00461         return ret;
00462 }

void vxge_device_unregister ( struct __vxge_hw_device hldev  ) 

Definition at line 470 of file vxge_main.c.

References __vxge_hw_device::ndev, netdev_nullify(), netdev_priv(), netdev_put(), unregister_netdev(), vxge_debug, VXGE_DRIVER_NAME, and VXGE_INFO.

Referenced by vxge_remove().

00471 {
00472         struct vxgedev *vdev;
00473         struct net_device *ndev;
00474 
00475         ndev = hldev->ndev;
00476         vdev = netdev_priv(ndev);
00477 
00478         unregister_netdev(ndev);
00479         netdev_nullify(ndev);
00480         netdev_put(ndev);
00481 
00482         vxge_debug(VXGE_INFO, "%s: ethernet device unregistered\n",
00483                                 VXGE_DRIVER_NAME);
00484 }

static int vxge_probe ( struct pci_device pdev,
const struct pci_device_id *id  __unused 
) [static]

vxge_probe : structure containing the PCI related information of the device.

: List of PCI devices supported by the driver listed in vxge_id_table. Description: This function is called when a new PCI device gets detected and initializes it. Return value: returns 0 on success and negative on failure.

Definition at line 498 of file vxge_main.c.

References adjust_pci_device(), vxgedev::bar0, vxge_hw_device_version::build, pci_device::bus, vxge_hw_device_date::date, pci_device::devfn, pci_device::device, vxge_vpath::device_id, EACCES, EINVAL, ENODEV, ETH_ALEN, eth_ntoa(), __vxge_hw_device::first_vp_id, vxge_hw_device_hw_info::func_id, vxge_hw_device_hw_info::function_mode, vxge_hw_device_hw_info::fw_date, vxge_hw_device_hw_info::fw_version, vxge_hw_device_hw_info::host_type, __vxge_hw_device::hw_info, ioremap(), iounmap(), is_titan1, vxge_hw_device_version::major, memcpy, vxge_hw_device_version::minor, vxgedev::mtu, vxgedev::ndev, __vxge_hw_device::ndev, NULL, vxge_hw_device_hw_info::part_number, pci_bar_size(), pci_bar_start(), PCI_BASE_ADDRESS_0, PCI_FUNC, pci_read_config_byte(), PCI_REVISION_ID, pci_set_drvdata(), PCI_SLOT, __vxge_hw_device::pdev, printf(), vxge_hw_device_hw_info::product_desc, vxge_hw_device_hw_info::serial_number, vxgedev::titan1, u32, u8, vxge_vpath::vdev, __vxge_hw_device::vdev, vxge_hw_device_version::version, vxgedev::vpath, vxge_hw_device_hw_info::vpath_mask, VXGE_CERT_FW_VER_BUILD, VXGE_CERT_FW_VER_MAJOR, VXGE_CERT_FW_VER_MINOR, vxge_debug, vxge_device_register(), VXGE_DRIVER_NAME, VXGE_ERR, vxge_func_mode_names, VXGE_HW_DEFAULT_MTU, vxge_hw_device_hw_info_get(), vxge_hw_device_initialize(), vxge_hw_device_terminate(), vxge_hw_get_func_mode(), VXGE_HW_INFO_LEN, VXGE_HW_MAX_VIRTUAL_PATHS, VXGE_HW_OK, vxge_hw_vpath_strip_fcs_check(), VXGE_INFO, and vxge_mBIT.

00499 {
00500         struct __vxge_hw_device  *hldev;
00501         enum vxge_hw_status status;
00502         int ret = 0;
00503         u64 vpath_mask = 0;
00504         struct vxgedev *vdev;
00505         int i;
00506         u8 revision, titan1;
00507         u32 host_type;
00508         u32 function_mode;
00509         unsigned long mmio_start, mmio_len;
00510         void *bar0;
00511         struct vxge_hw_device_hw_info hw_info;
00512         struct vxge_hw_device_version *fw_version;
00513 
00514         vxge_debug(VXGE_INFO, "vxge_probe for device %02X:%02X.%X\n",
00515                         pdev->bus, PCI_SLOT(pdev->devfn),
00516                         PCI_FUNC(pdev->devfn));
00517 
00518         pci_read_config_byte(pdev, PCI_REVISION_ID, &revision);
00519         titan1 = is_titan1(pdev->device, revision);
00520 
00521         mmio_start = pci_bar_start(pdev, PCI_BASE_ADDRESS_0);
00522         mmio_len   = pci_bar_size(pdev, PCI_BASE_ADDRESS_0);
00523         vxge_debug(VXGE_INFO, "mmio_start: %#08lx, mmio_len: %#08lx\n",
00524                         mmio_start, mmio_len);
00525 
00526         /* sets the bus master */
00527         adjust_pci_device(pdev);
00528 
00529         bar0 = ioremap(mmio_start, mmio_len);
00530         if (!bar0) {
00531                 vxge_debug(VXGE_ERR,
00532                         "%s : cannot remap io memory bar0\n", __func__);
00533                 ret = -ENODEV;
00534                 goto _exit0;
00535         }
00536 
00537         status = vxge_hw_device_hw_info_get(bar0, &hw_info);
00538         if (status != VXGE_HW_OK) {
00539                 vxge_debug(VXGE_ERR,
00540                         "%s: Reading of hardware info failed.\n",
00541                         VXGE_DRIVER_NAME);
00542                 ret = -EINVAL;
00543                 goto _exit1;
00544         }
00545 
00546         if (hw_info.func_id != 0) {
00547                 /* Non zero function, So do not load the driver */
00548                 iounmap(bar0);
00549                 pci_set_drvdata(pdev, NULL);
00550                 return -EINVAL;
00551         }
00552 
00553 
00554         vpath_mask = hw_info.vpath_mask;
00555         if (vpath_mask == 0) {
00556                 vxge_debug(VXGE_ERR,
00557                         "%s: No vpaths available in device\n",
00558                         VXGE_DRIVER_NAME);
00559                 ret = -EINVAL;
00560                 goto _exit1;
00561         }
00562         vxge_debug(VXGE_INFO,
00563                 "%s:%d  Vpath mask = %llx\n", __func__, __LINE__,
00564                 (unsigned long long)vpath_mask);
00565 
00566         host_type = hw_info.host_type;
00567         fw_version = &hw_info.fw_version;
00568         /* fail the driver loading if firmware is incompatible */
00569         if ((fw_version->major != VXGE_CERT_FW_VER_MAJOR) ||
00570                 (fw_version->minor < VXGE_CERT_FW_VER_MINOR)) {
00571                 printf("%s: Adapter's current firmware version: %d.%d.%d\n",
00572                         VXGE_DRIVER_NAME, fw_version->major,
00573                         fw_version->minor, fw_version->build);
00574 
00575                 printf("%s: Upgrade firmware to version %d.%d.%d\n",
00576                         VXGE_DRIVER_NAME, VXGE_CERT_FW_VER_MAJOR,
00577                         VXGE_CERT_FW_VER_MINOR, VXGE_CERT_FW_VER_BUILD);
00578 
00579                 ret = -EACCES;
00580                 goto _exit1;
00581         }
00582 
00583         status = vxge_hw_device_initialize(&hldev, bar0, pdev, titan1);
00584         if (status != VXGE_HW_OK) {
00585                 vxge_debug(VXGE_ERR,
00586                         "Failed to initialize device (%d)\n", status);
00587                         ret = -EINVAL;
00588                         goto _exit1;
00589         }
00590         memcpy(&hldev->hw_info, &hw_info,
00591                 sizeof(struct vxge_hw_device_hw_info));
00592 
00593         /* find the vpath id of the first available one */
00594         for (i = 0; i < VXGE_HW_MAX_VIRTUAL_PATHS; i++)
00595                 if (vpath_mask & vxge_mBIT(i)) {
00596                         hldev->first_vp_id = i;
00597                         break;
00598                 }
00599         /* if FCS stripping is not disabled in MAC fail driver load */
00600         if (vxge_hw_vpath_strip_fcs_check(hldev, vpath_mask) != VXGE_HW_OK) {
00601                 vxge_debug(VXGE_ERR,
00602                         "%s: FCS stripping is not disabled in MAC"
00603                         " failing driver load\n", VXGE_DRIVER_NAME);
00604                 ret = -EINVAL;
00605                 goto _exit2;
00606         }
00607 
00608         /* Read function mode */
00609         status = vxge_hw_get_func_mode(hldev, &function_mode);
00610         if (status != VXGE_HW_OK)
00611                 goto _exit2;
00612 
00613         hldev->hw_info.function_mode = function_mode;
00614 
00615         /* set private device info */
00616         pci_set_drvdata(pdev, hldev);
00617 
00618         if (vxge_device_register(hldev, &vdev)) {
00619                 ret = -EINVAL;
00620                 goto _exit2;
00621         }
00622 
00623         /* set private HW device info */
00624         hldev->ndev = vdev->ndev;
00625         hldev->vdev = vdev;
00626         hldev->pdev = pdev;
00627         vdev->mtu = VXGE_HW_DEFAULT_MTU;
00628         vdev->bar0 = bar0;
00629         vdev->titan1 = titan1;
00630         /* Virtual Path count */
00631         vdev->vpath.device_id = hldev->first_vp_id;
00632         vdev->vpath.vdev = vdev;
00633         memcpy((u8 *)vdev->vpath.macaddr,
00634                         (u8 *)hldev->hw_info.mac_addrs[hldev->first_vp_id],
00635                         ETH_ALEN);
00636 
00637         hldev->hw_info.serial_number[VXGE_HW_INFO_LEN - 1] = '\0';
00638         hldev->hw_info.product_desc[VXGE_HW_INFO_LEN - 1] = '\0';
00639         hldev->hw_info.part_number[VXGE_HW_INFO_LEN - 1] = '\0';
00640 
00641         vxge_debug(VXGE_INFO, "%s: Neterion %s Server Adapter\n",
00642                 VXGE_DRIVER_NAME, hldev->hw_info.product_desc);
00643         vxge_debug(VXGE_INFO, "%s: SERIAL NUMBER: %s\n",
00644                 VXGE_DRIVER_NAME, hldev->hw_info.serial_number);
00645         vxge_debug(VXGE_INFO, "%s: PART NUMBER: %s\n",
00646                 VXGE_DRIVER_NAME, hldev->hw_info.part_number);
00647         vxge_debug(VXGE_INFO, "%s: MAC ADDR: %s\n",
00648                 VXGE_DRIVER_NAME, eth_ntoa(vdev->vpath.macaddr));
00649         vxge_debug(VXGE_INFO,
00650                 "%s: Firmware version : %s Date : %s\n", VXGE_DRIVER_NAME,
00651                 hldev->hw_info.fw_version.version,
00652                 hldev->hw_info.fw_date.date);
00653         vxge_debug(VXGE_INFO, "%s: %s Enabled\n",
00654                         VXGE_DRIVER_NAME, vxge_func_mode_names[function_mode]);
00655 
00656         vxge_debug(VXGE_INFO, "%s: %s:%d  Probe Exiting...\n",
00657                 VXGE_DRIVER_NAME, __func__, __LINE__);
00658 
00659         return 0;
00660 
00661 _exit2:
00662         vxge_hw_device_terminate(hldev);
00663 _exit1:
00664         iounmap(bar0);
00665 _exit0:
00666         pci_set_drvdata(pdev, NULL);
00667         printf("%s: WARNING!! Driver loading failed!!\n",
00668                 VXGE_DRIVER_NAME);
00669 
00670         return ret;
00671 }

static void vxge_remove ( struct pci_device pdev  )  [static]

vxge_remove - Free the PCI device : structure containing the PCI related information of the device.

Description: This function is called by the Pci subsystem to release a PCI device and free up all resource held up by the device.

Definition at line 680 of file vxge_main.c.

References vxgedev::bar0, iounmap(), __vxge_hw_device::ndev, netdev_priv(), NULL, pci_get_drvdata(), pci_set_drvdata(), vxge_debug, vxge_device_unregister(), vxge_hw_device_terminate(), and VXGE_INFO.

00681 {
00682         struct __vxge_hw_device  *hldev;
00683         struct vxgedev *vdev = NULL;
00684         struct net_device *ndev;
00685 
00686         vxge_debug(VXGE_INFO,
00687                 "%s:%d\n", __func__, __LINE__);
00688         hldev = (struct __vxge_hw_device  *) pci_get_drvdata(pdev);
00689         if (hldev == NULL)
00690                 return;
00691 
00692         ndev = hldev->ndev;
00693         vdev = netdev_priv(ndev);
00694 
00695         iounmap(vdev->bar0);
00696 
00697         vxge_device_unregister(hldev);
00698 
00699         vxge_debug(VXGE_INFO,
00700                 "%s:%d  Device unregistered\n", __func__, __LINE__);
00701 
00702         vxge_hw_device_terminate(hldev);
00703         pci_set_drvdata(pdev, NULL);
00704 }


Variable Documentation

char* vxge_func_mode_names[] [static]

Initial value:

 {
        "Single Function - 1 func, 17 vpath",
        "Multi Function 8 - 8 func, 2 vpath per func",
        "SRIOV 17 - 17 VF, 1 vpath per VF",
        "WLPEX/SharedIO 17 - 17 VH, 1 vpath/func/hierarchy",
        "WLPEX/SharedIO 8 - 8 VH, 2 vpath/func/hierarchy",
        "Multi Function 17 - 17 func, 1 vpath per func",
        "SRIOV 8 - 1 PF, 7 VF, 2 vpath per VF",
        "SRIOV 4 - 1 PF, 3 VF, 4 vpath per VF",
        "Multi Function 2 - 2 func, 8 vpath per func",
        "Multi Function 4 - 4 func, 4 vpath per func",
        "WLPEX/SharedIO 4 - 17 func, 1 vpath per func (PCIe ARI)",
}

Definition at line 36 of file vxge_main.c.

Referenced by vxge_probe().

static struct net_device_operations vxge_operations [static, read]

Initial value:

 {
        .open           = vxge_open,
        .close          = vxge_close,
        .transmit       = vxge_xmit,
        .poll           = vxge_poll,
        .irq            = vxge_irq,
}

Definition at line 403 of file vxge_main.c.

Referenced by vxge_device_register().

struct pci_device_id vxge_main_nics[] [static]

Initial value:

 {
        
        PCI_ID(0x17d5, 0x5833, "vxge-x3100", "Neterion X3100 Series", 0),
}

Definition at line 715 of file vxge_main.c.

struct pci_driver vxge_driver __pci_driver

Initial value:

 {
        .ids = vxge_main_nics,
        .id_count = (sizeof(vxge_main_nics) / sizeof(vxge_main_nics[0])),
        .probe = vxge_probe,
        .remove = vxge_remove,
}

Definition at line 720 of file vxge_main.c.


Generated on Tue Apr 6 20:01:44 2010 for gPXE by  doxygen 1.5.7.1