X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fatlantic%2Fatl_ethdev.c;h=b2b3bd36c188a8b600bc17f72c3dae3a6cb2f59f;hb=6f0a54b74bce90fca6264773db1b0bf13871874f;hp=19742c20d190e3238066fbdba58c6a727d2fdfa2;hpb=9970a9ad07db7745ca6bc441819b287940ae86ea;p=dpdk.git diff --git a/drivers/net/atlantic/atl_ethdev.c b/drivers/net/atlantic/atl_ethdev.c index 19742c20d1..b2b3bd36c1 100644 --- a/drivers/net/atlantic/atl_ethdev.c +++ b/drivers/net/atlantic/atl_ethdev.c @@ -26,8 +26,8 @@ static void atl_dev_close(struct rte_eth_dev *dev); static int atl_dev_reset(struct rte_eth_dev *dev); static int atl_dev_promiscuous_enable(struct rte_eth_dev *dev); static int atl_dev_promiscuous_disable(struct rte_eth_dev *dev); -static void atl_dev_allmulticast_enable(struct rte_eth_dev *dev); -static void atl_dev_allmulticast_disable(struct rte_eth_dev *dev); +static int atl_dev_allmulticast_enable(struct rte_eth_dev *dev); +static int atl_dev_allmulticast_disable(struct rte_eth_dev *dev); static int atl_dev_link_update(struct rte_eth_dev *dev, int wait); static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, @@ -407,6 +407,8 @@ eth_atl_dev_init(struct rte_eth_dev *eth_dev) hw->aq_nic_cfg = &adapter->hw_cfg; + pthread_mutex_init(&hw->mbox_mutex, NULL); + /* disable interrupt */ atl_disable_intr(hw); @@ -471,6 +473,8 @@ eth_atl_dev_uninit(struct rte_eth_dev *eth_dev) rte_free(eth_dev->data->mac_addrs); eth_dev->data->mac_addrs = NULL; + pthread_mutex_destroy(&hw->mbox_mutex); + return 0; } @@ -991,21 +995,43 @@ atl_dev_stats_reset(struct rte_eth_dev *dev) return 0; } +static int +atl_dev_xstats_get_count(struct rte_eth_dev *dev) +{ + struct atl_adapter *adapter = + (struct atl_adapter *)dev->data->dev_private; + + struct aq_hw_s *hw = &adapter->hw; + unsigned int i, count = 0; + + for (i = 0; i < RTE_DIM(atl_xstats_tbl); i++) { + if (atl_xstats_tbl[i].type == XSTATS_TYPE_MACSEC && + ((hw->caps_lo & BIT(CAPS_LO_MACSEC)) == 0)) + continue; + + count++; + } + + return count; +} + static int atl_dev_xstats_get_names(struct rte_eth_dev *dev __rte_unused, struct rte_eth_xstat_name *xstats_names, unsigned int size) { unsigned int i; + unsigned int count = atl_dev_xstats_get_count(dev); - if (!xstats_names) - return RTE_DIM(atl_xstats_tbl); - - for (i = 0; i < size && i < RTE_DIM(atl_xstats_tbl); i++) - strlcpy(xstats_names[i].name, atl_xstats_tbl[i].name, - RTE_ETH_XSTATS_NAME_SIZE); + if (xstats_names) { + for (i = 0; i < size && i < count; i++) { + snprintf(xstats_names[i].name, + RTE_ETH_XSTATS_NAME_SIZE, "%s", + atl_xstats_tbl[i].name); + } + } - return i; + return count; } static int @@ -1019,9 +1045,10 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, struct macsec_msg_fw_response resp = { 0 }; int err = -1; unsigned int i; + unsigned int count = atl_dev_xstats_get_count(dev); if (!stats) - return 0; + return count; if (hw->aq_fw_ops->send_macsec_req != NULL) { req.ingress_sa_index = 0xff; @@ -1034,7 +1061,7 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, err = hw->aq_fw_ops->send_macsec_req(hw, &msg, &resp); } - for (i = 0; i < n && i < RTE_DIM(atl_xstats_tbl); i++) { + for (i = 0; i < n && i < count; i++) { stats[i].id = i; switch (atl_xstats_tbl[i].type) { @@ -1043,14 +1070,15 @@ atl_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, atl_xstats_tbl[i].offset); break; case XSTATS_TYPE_MACSEC: - if (err) - goto done; - stats[i].value = *(u64 *)((uint8_t *)&resp.stats + - atl_xstats_tbl[i].offset); + if (!err) { + stats[i].value = + *(u64 *)((uint8_t *)&resp.stats + + atl_xstats_tbl[i].offset); + } break; } } -done: + return i; } @@ -1229,23 +1257,27 @@ atl_dev_promiscuous_disable(struct rte_eth_dev *dev) return 0; } -static void +static int atl_dev_allmulticast_enable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); hw_atl_rpfl2_accept_all_mc_packets_set(hw, true); + + return 0; } -static void +static int atl_dev_allmulticast_disable(struct rte_eth_dev *dev) { struct aq_hw_s *hw = ATL_DEV_PRIVATE_TO_HW(dev->data->dev_private); if (dev->data->promiscuous == 1) - return; /* must remain in all_multicast mode */ + return 0; /* must remain in all_multicast mode */ hw_atl_rpfl2_accept_all_mc_packets_set(hw, false); + + return 0; } /** @@ -1516,11 +1548,11 @@ atl_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) if (fc == AQ_NIC_FC_OFF) fc_conf->mode = RTE_FC_NONE; - else if (fc & (AQ_NIC_FC_RX | AQ_NIC_FC_TX)) + else if ((fc & AQ_NIC_FC_RX) && (fc & AQ_NIC_FC_TX)) fc_conf->mode = RTE_FC_FULL; else if (fc & AQ_NIC_FC_RX) fc_conf->mode = RTE_FC_RX_PAUSE; - else if (fc & AQ_NIC_FC_RX) + else if (fc & AQ_NIC_FC_TX) fc_conf->mode = RTE_FC_TX_PAUSE; return 0;