X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fnet%2Fbnxt%2Fbnxt_ethdev.c;h=58a4f98c9f9a963d745773305d0e2658f7ad420e;hb=4b701523742e3753d58949846ac4eeebc6d5a78f;hp=b58a875c7ddebeeee088f5e797dc16ffecb4e789;hpb=9924dfd601fadeacb6c9968437cad8c6f853f77f;p=dpdk.git diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index b58a875c7d..58a4f98c9f 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -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) @@ -627,6 +635,9 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) * resource reservation. This will ensure the resource counts * are calculated correctly. */ + + pthread_mutex_lock(&bp->def_cp_lock); + if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) { bnxt_disable_int(bp); bnxt_free_cp_ring(bp, bp->async_cp_ring); @@ -635,15 +646,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev) rc = bnxt_hwrm_func_reserve_vf_resc(bp, false); if (rc) { PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc); + pthread_mutex_unlock(&bp->def_cp_lock); return -ENOSPC; } if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) { rc = bnxt_alloc_async_cp_ring(bp); - if (rc) + if (rc) { + pthread_mutex_unlock(&bp->def_cp_lock); return rc; + } bnxt_enable_int(bp); } + + pthread_mutex_unlock(&bp->def_cp_lock); } else { /* legacy driver needs to get updated values */ rc = bnxt_hwrm_func_qcaps(bp); @@ -823,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", @@ -861,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: @@ -1015,7 +1038,7 @@ static int bnxt_add_mac_filter(struct bnxt *bp, struct bnxt_vnic_info *vnic, * hw-vlan-filter is turned OFF from ON, default * MAC filter should be restored */ - if (filter->dflt) + if (index == 0 && filter->dflt) return 0; filter = bnxt_alloc_filter(bp); @@ -1314,9 +1337,6 @@ static int bnxt_reta_update_op(struct rte_eth_dev *eth_dev, vnic->rss_table[i] = vnic->fw_grp_ids[reta_conf[idx].reta[sft]]; } - - vnic->rss_table[i] = - vnic->fw_grp_ids[reta_conf[idx].reta[sft]]; } bnxt_hwrm_vnic_rss_cfg(bp, vnic); @@ -2119,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; @@ -2130,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; @@ -2160,14 +2184,15 @@ 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]; uint16_t size = 0; - vnic->mru = new_mtu + RTE_ETHER_HDR_LEN + - RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE * 2; + vnic->mru = BNXT_VNIC_MRU(new_mtu); rc = bnxt_hwrm_vnic_cfg(bp, vnic); if (rc) break; @@ -2182,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; @@ -2588,9 +2616,6 @@ parse_ntuple_filter(struct bnxt *bp, return -EINVAL; } - //TODO Priority - //nfilter->priority = (uint8_t)filter->priority; - bfilter->enables = en; return 0; } @@ -4049,6 +4074,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; @@ -4585,8 +4628,14 @@ bnxt_init_locks(struct bnxt *bp) int err; err = pthread_mutex_init(&bp->flow_lock, NULL); - if (err) + if (err) { PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n"); + return err; + } + + err = pthread_mutex_init(&bp->def_cp_lock, NULL); + if (err) + PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n"); return err; } @@ -4685,11 +4734,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 || @@ -4735,6 +4780,7 @@ static void bnxt_uninit_locks(struct bnxt *bp) { pthread_mutex_destroy(&bp->flow_lock); + pthread_mutex_destroy(&bp->def_cp_lock); } static int @@ -4757,6 +4803,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; @@ -4775,11 +4822,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; @@ -4798,8 +4840,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; }