net/virtio: fix Tx checksum offloads
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 820005c..7d9459f 100644 (file)
@@ -83,6 +83,12 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57502) },
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57500_VF1) },
        { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57500_VF2) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57508_MF1) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57504_MF1) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57502_MF1) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57508_MF2) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57504_MF2) },
+       { RTE_PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BROADCOM_DEV_ID_57502_MF2) },
        { .vendor_id = 0, /* sentinel */ },
 };
 
@@ -121,7 +127,6 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
 
 static int bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask);
 static void bnxt_print_link_info(struct rte_eth_dev *eth_dev);
-static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu);
 static int bnxt_dev_uninit(struct rte_eth_dev *eth_dev);
 static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev);
 static int bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev);
@@ -178,6 +183,9 @@ static void bnxt_free_mem(struct bnxt *bp, bool reconfig)
        }
        bnxt_free_async_cp_ring(bp);
        bnxt_free_rxtx_nq_ring(bp);
+
+       rte_free(bp->grp_info);
+       bp->grp_info = NULL;
 }
 
 static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig)
@@ -831,6 +839,11 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
        int vlan_mask = 0;
        int rc;
 
+       if (!eth_dev->data->nb_tx_queues || !eth_dev->data->nb_rx_queues) {
+               PMD_DRV_LOG(ERR, "Queues are not configured yet!\n");
+               return -EINVAL;
+       }
+
        if (bp->rx_cp_nr_rings > RTE_ETHDEV_QUEUE_STAT_CNTRS) {
                PMD_DRV_LOG(ERR,
                        "RxQ cnt %d > CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS %d\n",
@@ -869,7 +882,9 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
        bp->flags |= BNXT_FLAG_INIT_DONE;
        eth_dev->data->dev_started = 1;
        bp->dev_stopped = 0;
+       pthread_mutex_lock(&bp->def_cp_lock);
        bnxt_schedule_fw_health_check(bp);
+       pthread_mutex_unlock(&bp->def_cp_lock);
        return 0;
 
 error:
@@ -2124,7 +2139,7 @@ bnxt_txq_info_get_op(struct rte_eth_dev *dev, uint16_t queue_id,
        qinfo->conf.tx_deferred_start = txq->tx_deferred_start;
 }
 
-static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
+int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
 {
        struct bnxt *bp = eth_dev->data->dev_private;
        uint32_t new_pkt_size;
@@ -2135,6 +2150,10 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
        if (rc)
                return rc;
 
+       /* Exit if receive queues are not configured yet */
+       if (!eth_dev->data->nb_rx_queues)
+               return rc;
+
        new_pkt_size = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN +
                       VLAN_TAG_SIZE * BNXT_NUM_VLANS;
 
@@ -2165,7 +2184,9 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
                bp->flags &= ~BNXT_FLAG_JUMBO;
        }
 
-       eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_pkt_size;
+       /* Is there a change in mtu setting? */
+       if (eth_dev->data->dev_conf.rxmode.max_rx_pkt_len == new_pkt_size)
+               return rc;
 
        for (i = 0; i < bp->nr_vnics; i++) {
                struct bnxt_vnic_info *vnic = &bp->vnic_info[i];
@@ -2186,6 +2207,9 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu)
                }
        }
 
+       if (!rc)
+               eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_pkt_size;
+
        PMD_DRV_LOG(INFO, "New MTU is %d\n", new_mtu);
 
        return rc;
@@ -4053,6 +4077,24 @@ static bool bnxt_vf_pciid(uint16_t id)
        return false;
 }
 
+static bool bnxt_thor_device(uint16_t id)
+{
+       if (id == BROADCOM_DEV_ID_57508 ||
+           id == BROADCOM_DEV_ID_57504 ||
+           id == BROADCOM_DEV_ID_57502 ||
+           id == BROADCOM_DEV_ID_57508_MF1 ||
+           id == BROADCOM_DEV_ID_57504_MF1 ||
+           id == BROADCOM_DEV_ID_57502_MF1 ||
+           id == BROADCOM_DEV_ID_57508_MF2 ||
+           id == BROADCOM_DEV_ID_57504_MF2 ||
+           id == BROADCOM_DEV_ID_57502_MF2 ||
+           id == BROADCOM_DEV_ID_57500_VF1 ||
+           id == BROADCOM_DEV_ID_57500_VF2)
+               return true;
+
+       return false;
+}
+
 bool bnxt_stratus_device(struct bnxt *bp)
 {
        uint16_t id = bp->pdev->id.device_id;
@@ -4695,11 +4737,7 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        if (bnxt_vf_pciid(pci_dev->id.device_id))
                bp->flags |= BNXT_FLAG_VF;
 
-       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_VF1 ||
-           pci_dev->id.device_id == BROADCOM_DEV_ID_57500_VF2)
+       if (bnxt_thor_device(pci_dev->id.device_id))
                bp->flags |= BNXT_FLAG_THOR_CHIP;
 
        if (pci_dev->id.device_id == BROADCOM_DEV_ID_58802 ||
@@ -4768,6 +4806,7 @@ bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev)
                }
        }
 
+       bnxt_uninit_locks(bp);
        rte_free(bp->ptp_cfg);
        bp->ptp_cfg = NULL;
        return rc;
@@ -4786,11 +4825,6 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
 
        rc = bnxt_uninit_resources(bp, false);
 
-       if (bp->grp_info != NULL) {
-               rte_free(bp->grp_info);
-               bp->grp_info = NULL;
-       }
-
        if (bp->tx_mem_zone) {
                rte_memzone_free((const struct rte_memzone *)bp->tx_mem_zone);
                bp->tx_mem_zone = NULL;
@@ -4809,8 +4843,6 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev)
        eth_dev->rx_pkt_burst = NULL;
        eth_dev->tx_pkt_burst = NULL;
 
-       bnxt_uninit_locks(bp);
-
        return rc;
 }