drivers: update registration macro usage
[dpdk.git] / drivers / net / bnx2x / bnx2x_ethdev.c
index 09b5920..65b99a0 100644 (file)
@@ -1,7 +1,11 @@
 /*
  * Copyright (c) 2013-2015 Brocade Communications Systems, Inc.
  *
+ * Copyright (c) 2015 QLogic Corporation.
  * All rights reserved.
+ * www.qlogic.com
+ *
+ * See LICENSE.bnx2x_pmd for copyright and licensing details.
  */
 
 #include "bnx2x.h"
@@ -40,9 +44,9 @@ bnx2x_link_update(struct rte_eth_dev *dev)
                case DUPLEX_HALF:
                        dev->data->dev_link.link_duplex = ETH_LINK_HALF_DUPLEX;
                        break;
-               default:
-                       dev->data->dev_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX;
        }
+       dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
+                       ETH_LINK_SPEED_FIXED);
        dev->data->dev_link.link_status = sc->link_vars.link_up;
 }
 
@@ -52,7 +56,7 @@ bnx2x_interrupt_action(struct rte_eth_dev *dev)
        struct bnx2x_softc *sc = dev->data->dev_private;
        uint32_t link_status;
 
-       PMD_DRV_LOG(INFO, "Interrupt handled");
+       PMD_DEBUG_PERIODIC_LOG(INFO, "Interrupt handled");
 
        if (bnx2x_intr_legacy(sc, 0))
                DELAY_MS(250);
@@ -83,7 +87,6 @@ bnx2x_dev_configure(struct rte_eth_dev *dev)
 {
        struct bnx2x_softc *sc = dev->data->dev_private;
        int mp_ncpus = sysconf(_SC_NPROCESSORS_CONF);
-       int ret;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -117,25 +120,6 @@ bnx2x_dev_configure(struct rte_eth_dev *dev)
                return -ENXIO;
        }
 
-       if (IS_VF(sc)) {
-               if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
-                                 &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
-                                 RTE_CACHE_LINE_SIZE) != 0)
-                       return -ENOMEM;
-
-               sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)sc->vf2pf_mbox_mapping.vaddr;
-               if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
-                                 &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
-                                 RTE_CACHE_LINE_SIZE) != 0)
-                       return -ENOMEM;
-
-               sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)sc->pf2vf_bulletin_mapping.vaddr;
-
-               ret = bnx2x_vf_get_resources(sc, sc->num_queues, sc->num_queues);
-               if (ret)
-                       return ret;
-       }
-
        return 0;
 }
 
@@ -282,7 +266,7 @@ bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_comple
        if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) {
                PMD_DRV_LOG(ERR, "PF indicated channel is down."
                                "VF device is no longer operational");
-               dev->data->dev_link.link_status = 0;
+               dev->data->dev_link.link_status = ETH_LINK_DOWN;
        }
 
        return old_link_status == dev->data->dev_link.link_status ? -1 : 0;
@@ -292,6 +276,9 @@ static void
 bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
        struct bnx2x_softc *sc = dev->data->dev_private;
+       uint32_t brb_truncate_discard;
+       uint64_t brb_drops;
+       uint64_t brb_truncates;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -332,6 +319,19 @@ bnx2x_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
        stats->rx_nombuf =
                HILO_U64(sc->eth_stats.no_buff_discard_hi,
                                sc->eth_stats.no_buff_discard_lo);
+
+       brb_drops =
+               HILO_U64(sc->eth_stats.brb_drop_hi,
+                        sc->eth_stats.brb_drop_lo);
+
+       brb_truncates =
+               HILO_U64(sc->eth_stats.brb_truncate_hi,
+                        sc->eth_stats.brb_truncate_lo);
+
+       brb_truncate_discard = sc->eth_stats.brb_truncate_discard;
+
+       stats->imissed = brb_drops + brb_truncates +
+                        brb_truncate_discard + stats->rx_nombuf;
 }
 
 static void
@@ -343,6 +343,7 @@ bnx2x_dev_infos_get(struct rte_eth_dev *dev, __rte_unused struct rte_eth_dev_inf
        dev_info->min_rx_bufsize = BNX2X_MIN_RX_BUF_SIZE;
        dev_info->max_rx_pktlen  = BNX2X_MAX_RX_PKT_LEN;
        dev_info->max_mac_addrs  = BNX2X_MAX_MAC_ADDRS;
+       dev_info->speed_capa = ETH_LINK_SPEED_10G | ETH_LINK_SPEED_20G;
 }
 
 static void
@@ -364,7 +365,7 @@ bnx2x_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
                sc->mac_ops.mac_addr_remove(dev, index);
 }
 
-static struct eth_dev_ops bnx2x_eth_dev_ops = {
+static const struct eth_dev_ops bnx2x_eth_dev_ops = {
        .dev_configure                = bnx2x_dev_configure,
        .dev_start                    = bnx2x_dev_start,
        .dev_stop                     = bnx2x_dev_stop,
@@ -387,7 +388,7 @@ static struct eth_dev_ops bnx2x_eth_dev_ops = {
 /*
  * dev_ops for virtual function
  */
-static struct eth_dev_ops bnx2xvf_eth_dev_ops = {
+static const struct eth_dev_ops bnx2xvf_eth_dev_ops = {
        .dev_configure                = bnx2x_dev_configure,
        .dev_start                    = bnx2x_dev_start,
        .dev_stop                     = bnx2x_dev_stop,
@@ -419,6 +420,9 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
 
        eth_dev->dev_ops = is_vf ? &bnx2xvf_eth_dev_ops : &bnx2x_eth_dev_ops;
        pci_dev = eth_dev->pci_dev;
+
+       rte_eth_copy_pci_info(eth_dev, pci_dev);
+
        sc = eth_dev->data->dev_private;
        sc->pcie_bus    = pci_dev->addr.bus;
        sc->pcie_device = pci_dev->addr.devid;
@@ -435,7 +439,7 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
        sc->bar[BAR0].base_addr = (void *)pci_dev->mem_resource[0].addr;
        if (is_vf)
                sc->bar[BAR1].base_addr = (void *)
-                       ((uint64_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
+                       ((uintptr_t)pci_dev->mem_resource[0].addr + PXP_VF_ADDR_DB_START);
        else
                sc->bar[BAR1].base_addr = pci_dev->mem_resource[2].addr;
 
@@ -459,6 +463,7 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
        ret = bnx2x_attach(sc);
        if (ret) {
                PMD_DRV_LOG(ERR, "bnx2x_attach failed (%d)", ret);
+               return ret;
        }
 
        eth_dev->data->mac_addrs = (struct ether_addr *)sc->link_params.mac_addr;
@@ -472,7 +477,30 @@ bnx2x_common_dev_init(struct rte_eth_dev *eth_dev, int is_vf)
        PMD_DRV_LOG(INFO, "portID=%d vendorID=0x%x deviceID=0x%x",
                        eth_dev->data->port_id, pci_dev->id.vendor_id, pci_dev->id.device_id);
 
-       return ret;
+       if (IS_VF(sc)) {
+               if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_mbx_msg),
+                                   &sc->vf2pf_mbox_mapping, "vf2pf_mbox",
+                                   RTE_CACHE_LINE_SIZE) != 0)
+                       return -ENOMEM;
+
+               sc->vf2pf_mbox = (struct bnx2x_vf_mbx_msg *)
+                                        sc->vf2pf_mbox_mapping.vaddr;
+
+               if (bnx2x_dma_alloc(sc, sizeof(struct bnx2x_vf_bulletin),
+                                   &sc->pf2vf_bulletin_mapping, "vf2pf_bull",
+                                   RTE_CACHE_LINE_SIZE) != 0)
+                       return -ENOMEM;
+
+               sc->pf2vf_bulletin = (struct bnx2x_vf_bulletin *)
+                                            sc->pf2vf_bulletin_mapping.vaddr;
+
+               ret = bnx2x_vf_get_resources(sc, sc->max_tx_queues,
+                                            sc->max_rx_queues);
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
 }
 
 static int
@@ -538,5 +566,7 @@ static struct rte_driver rte_bnx2xvf_driver = {
        .init = rte_bnx2xvf_pmd_init,
 };
 
-PMD_REGISTER_DRIVER(rte_bnx2x_driver);
-PMD_REGISTER_DRIVER(rte_bnx2xvf_driver);
+PMD_REGISTER_DRIVER(rte_bnx2x_driver, bnx2x);
+DRIVER_REGISTER_PCI_TABLE(bnx2x, pci_id_bnx2x_map);
+PMD_REGISTER_DRIVER(rte_bnx2xvf_driver, bnx2xvf);
+DRIVER_REGISTER_PCI_TABLE(bnx2xvf, pci_id_bnx2xvf_map);