ethdev: change device info get callback to return int
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 5e8bdff..b521a72 100644 (file)
@@ -74,7 +74,8 @@ int bnxt_logtype_driver;
 #define BROADCOM_DEV_ID_57508 0x1750
 #define BROADCOM_DEV_ID_57504 0x1751
 #define BROADCOM_DEV_ID_57502 0x1752
-#define BROADCOM_DEV_ID_57500_VF 0x1807
+#define BROADCOM_DEV_ID_57500_VF1 0x1806
+#define BROADCOM_DEV_ID_57500_VF2 0x1807
 #define BROADCOM_DEV_ID_58802 0xd802
 #define BROADCOM_DEV_ID_58804 0xd804
 #define BROADCOM_DEV_ID_58808 0x16f0
@@ -126,7 +127,8 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57508) },
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57504) },
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57502) },
-       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57500_VF) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57500_VF1) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57500_VF2) },
        { .vendor_id = 0, /* sentinel */ },
 };
 
@@ -198,12 +200,17 @@ static void bnxt_free_mem(struct bnxt *bp)
        bnxt_free_stats(bp);
        bnxt_free_tx_rings(bp);
        bnxt_free_rx_rings(bp);
+       bnxt_free_async_cp_ring(bp);
 }
 
 static int bnxt_alloc_mem(struct bnxt *bp)
 {
        int rc;
 
+       rc = bnxt_alloc_async_ring_struct(bp);
+       if (rc)
+               goto alloc_mem_err;
+
        rc = bnxt_alloc_vnic_mem(bp);
        if (rc)
                goto alloc_mem_err;
@@ -216,6 +223,10 @@ static int bnxt_alloc_mem(struct bnxt *bp)
        if (rc)
                goto alloc_mem_err;
 
+       rc = bnxt_alloc_async_cp_ring(bp);
+       if (rc)
+               goto alloc_mem_err;
+
        return 0;
 
 alloc_mem_err:
@@ -237,9 +248,6 @@ static int bnxt_init_chip(struct bnxt *bp)
        unsigned int i, j;
        int rc;
 
-       /* disable uio/vfio intr/eventfd mapping */
-       rte_intr_disable(intr_handle);
-
        if (bp->eth_dev->data->mtu > RTE_ETHER_MTU) {
                bp->eth_dev->data->dev_conf.rxmode.offloads |=
                        DEV_RX_OFFLOAD_JUMBO_FRAME;
@@ -416,7 +424,8 @@ static int bnxt_init_chip(struct bnxt *bp)
                        intr_handle->max_intr);
                for (queue_id = 0; queue_id < bp->eth_dev->data->nb_rx_queues;
                     queue_id++) {
-                       intr_handle->intr_vec[queue_id] = vec;
+                       intr_handle->intr_vec[queue_id] =
+                                                       vec + BNXT_RX_VEC_START;
                        if (vec < base + intr_handle->nb_efd - 1)
                                vec++;
                }
@@ -485,8 +494,8 @@ static int bnxt_init_nic(struct bnxt *bp)
  * Device configuration and status function
  */
 
-static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
-                                 struct rte_eth_dev_info *dev_info)
+static int bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
+                               struct rte_eth_dev_info *dev_info)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
        uint16_t max_vnics, i, j, vpool, vrxq;
@@ -579,6 +588,8 @@ found:
 
        dev_info->vmdq_pool_base = 0;
        dev_info->vmdq_queue_base = 0;
+
+       return 0;
 }
 
 /* Configure the device based on the configuration provided */
@@ -617,8 +628,8 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
        /* Inherit new configurations */
        if (eth_dev->data->nb_rx_queues > bp->max_rx_rings ||
            eth_dev->data->nb_tx_queues > bp->max_tx_rings ||
-           eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
-           bp->max_cp_rings ||
+           eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues
+               + BNXT_NUM_ASYNC_CPR(bp) > bp->max_cp_rings ||
            eth_dev->data->nb_rx_queues + eth_dev->data->nb_tx_queues >
            bp->max_stat_ctx)
                goto resource_error;
@@ -731,13 +742,11 @@ bnxt_transmit_function(__rte_unused struct rte_eth_dev *eth_dev)
 {
 #ifdef RTE_ARCH_X86
        /*
-        * Vector mode receive can be enabled only if scatter tx is not
-        * in use and tx offloads other than VLAN insertion are not
-        * in use.
+        * Vector mode transmit can be enabled only if not using scatter rx
+        * or tx offloads.
         */
        if (!eth_dev->data->scattered_rx &&
-           !(eth_dev->data->dev_conf.txmode.offloads &
-             ~DEV_TX_OFFLOAD_VLAN_INSERT)) {
+           !eth_dev->data->dev_conf.txmode.offloads) {
                PMD_DRV_LOG(INFO, "Using vector mode transmit for port %d\n",
                            eth_dev->data->port_id);
                return bnxt_xmit_pkts_vec;
@@ -1780,7 +1789,11 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
        new_pkt_size = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
                       VLAN_TAG_SIZE * BNXT_NUM_VLANS;
 
-       bnxt_dev_info_get_op(eth_dev, &dev_info);
+       rc = bnxt_dev_info_get_op(eth_dev, &dev_info);
+       if (rc != 0) {
+               PMD_DRV_LOG(ERR, "Error during getting ethernet device info\n");
+               return rc;
+       }
 
        if (new_mtu < RTE_ETHER_MIN_MTU || new_mtu > BNXT_MAX_MTU) {
                PMD_DRV_LOG(ERR, "MTU requested must be within (%d, %d)\n",
@@ -3329,7 +3342,8 @@ static bool bnxt_vf_pciid(uint16_t id)
            id == BROADCOM_DEV_ID_STRATUS_NIC_VF1 ||
            id == BROADCOM_DEV_ID_STRATUS_NIC_VF2 ||
            id == BROADCOM_DEV_ID_58802_VF ||
-           id == BROADCOM_DEV_ID_57500_VF)
+           id == BROADCOM_DEV_ID_57500_VF1 ||
+           id == BROADCOM_DEV_ID_57500_VF2)
                return true;
        return false;
 }
@@ -3391,8 +3405,9 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
        valid_bits = PTU_PTE_VALID;
 
        if (rmem->nr_pages > 1) {
-               snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_pg_tbl%s_%x",
-                        suffix, idx);
+               snprintf(mz_name, RTE_MEMZONE_NAMESIZE,
+                        "bnxt_ctx_pg_tbl%s_%x_%d",
+                        suffix, idx, bp->eth_dev->data->port_id);
                mz_name[RTE_MEMZONE_NAMESIZE - 1] = 0;
                mz = rte_memzone_lookup(mz_name);
                if (!mz) {
@@ -3428,7 +3443,8 @@ static int bnxt_alloc_ctx_mem_blk(__rte_unused struct bnxt *bp,
                rmem->pg_tbl_mz = mz;
        }
 
-       snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x", suffix, idx);
+       snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "bnxt_ctx_%s_%x_%d",
+                suffix, idx, bp->eth_dev->data->port_id);
        mz = rte_memzone_lookup(mz_name);
        if (!mz) {
                mz = rte_memzone_reserve_aligned(mz_name,
@@ -3799,9 +3815,16 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        if (pci_dev->id.device_id == BROADCOM_DEV_ID_57508 ||
            pci_dev->id.device_id == BROADCOM_DEV_ID_57504 ||
            pci_dev->id.device_id == BROADCOM_DEV_ID_57502 ||
-           pci_dev->id.device_id == BROADCOM_DEV_ID_57500_VF)
+           pci_dev->id.device_id == BROADCOM_DEV_ID_57500_VF1 ||
+           pci_dev->id.device_id == BROADCOM_DEV_ID_57500_VF2)
                bp->flags |= BNXT_FLAG_THOR_CHIP;
 
+       if (pci_dev->id.device_id == BROADCOM_DEV_ID_58802 ||
+           pci_dev->id.device_id == BROADCOM_DEV_ID_58804 ||
+           pci_dev->id.device_id == BROADCOM_DEV_ID_58808 ||
+           pci_dev->id.device_id == BROADCOM_DEV_ID_58802_VF)
+               bp->flags |= BNXT_FLAG_STINGRAY;
+
        rc = bnxt_init_board(eth_dev);
        if (rc) {
                PMD_DRV_LOG(ERR,