Currently, when querying the stats for IAVF, we pass a pointer-to-pointer and then use it as an input for another function. It does not really need to be a pointer because it is populated from virtchnl command response anyway. Replace it with passing in a stack-allocated struct, and pass it into the stats query function.
Signed-off-by: Anatoly Burakov <[email protected]> --- drivers/net/intel/iavf/iavf.h | 2 +- drivers/net/intel/iavf/iavf_ethdev.c | 34 ++++++++++++++-------------- drivers/net/intel/iavf/iavf_vchnl.c | 5 ++-- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h index 403c61e2e8..b2389e0bbd 100644 --- a/drivers/net/intel/iavf/iavf.h +++ b/drivers/net/intel/iavf/iavf.h @@ -518,7 +518,7 @@ int iavf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete); void iavf_dev_alarm_handler(void *param); int iavf_query_stats(struct iavf_adapter *adapter, - struct virtchnl_eth_stats **pstats); + struct virtchnl_eth_stats *pstats); int iavf_config_promisc(struct iavf_adapter *adapter, bool enable_unicast, bool enable_multicast); int iavf_add_del_eth_addr(struct iavf_adapter *adapter, diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c index 1eca20bc9a..e3690cce11 100644 --- a/drivers/net/intel/iavf/iavf_ethdev.c +++ b/drivers/net/intel/iavf/iavf_ethdev.c @@ -1793,7 +1793,7 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); struct iavf_vsi *vsi = &vf->vsi; - struct virtchnl_eth_stats *pstats = NULL; + struct virtchnl_eth_stats pstats; int ret; ret = iavf_query_stats(adapter, &pstats); @@ -1801,16 +1801,16 @@ iavf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats, uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 : RTE_ETHER_CRC_LEN; - iavf_update_stats(vsi, pstats); - stats->ipackets = pstats->rx_unicast + pstats->rx_multicast + - pstats->rx_broadcast - pstats->rx_discards; - stats->opackets = pstats->tx_broadcast + pstats->tx_multicast + - pstats->tx_unicast; - stats->imissed = pstats->rx_discards; - stats->oerrors = pstats->tx_errors + pstats->tx_discards; - stats->ibytes = pstats->rx_bytes; + iavf_update_stats(vsi, &pstats); + stats->ipackets = pstats.rx_unicast + pstats.rx_multicast + + pstats.rx_broadcast - pstats.rx_discards; + stats->opackets = pstats.tx_broadcast + pstats.tx_multicast + + pstats.tx_unicast; + stats->imissed = pstats.rx_discards; + stats->oerrors = pstats.tx_errors + pstats.tx_discards; + stats->ibytes = pstats.rx_bytes; stats->ibytes -= stats->ipackets * crc_stats_len; - stats->obytes = pstats->tx_bytes; + stats->obytes = pstats.tx_bytes; } else { PMD_DRV_LOG(ERR, "Get statistics failed"); } @@ -1825,15 +1825,15 @@ iavf_dev_stats_reset(struct rte_eth_dev *dev) IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); struct iavf_vsi *vsi = &vf->vsi; - struct virtchnl_eth_stats *pstats = NULL; + struct virtchnl_eth_stats stats; /* read stat values to clear hardware registers */ - ret = iavf_query_stats(adapter, &pstats); + ret = iavf_query_stats(adapter, &stats); if (ret != 0) return ret; /* set stats offset base on current values */ - vsi->eth_stats_offset.eth_stats = *pstats; + vsi->eth_stats_offset.eth_stats = stats; return 0; } @@ -1909,21 +1909,21 @@ static int iavf_dev_xstats_get(struct rte_eth_dev *dev, IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); struct iavf_vsi *vsi = &vf->vsi; - struct virtchnl_eth_stats *pstats = NULL; + struct virtchnl_eth_stats stats; struct iavf_eth_xstats iavf_xtats = {{0}}; if (n < IAVF_NB_XSTATS) return IAVF_NB_XSTATS; - ret = iavf_query_stats(adapter, &pstats); + ret = iavf_query_stats(adapter, &stats); if (ret != 0) return 0; if (!xstats) return 0; - iavf_update_stats(vsi, pstats); - iavf_xtats.eth_stats = *pstats; + iavf_update_stats(vsi, &stats); + iavf_xtats.eth_stats = stats; if (iavf_ipsec_crypto_supported(adapter)) iavf_dev_update_ipsec_xstats(dev, &iavf_xtats.ips_stats); diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c index 08dd6f2d7f..a1dc573841 100644 --- a/drivers/net/intel/iavf/iavf_vchnl.c +++ b/drivers/net/intel/iavf/iavf_vchnl.c @@ -1483,7 +1483,7 @@ iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add) int iavf_query_stats(struct iavf_adapter *adapter, - struct virtchnl_eth_stats **pstats) + struct virtchnl_eth_stats *pstats) { struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); struct virtchnl_queue_select q_stats; @@ -1504,10 +1504,9 @@ iavf_query_stats(struct iavf_adapter *adapter, err = iavf_execute_vf_cmd_safe(adapter, &args, 0); if (err) { PMD_DRV_LOG(ERR, "fail to execute command OP_GET_STATS"); - *pstats = NULL; return err; } - *pstats = (struct virtchnl_eth_stats *)args.out_buffer; + *pstats = *(struct virtchnl_eth_stats *)args.out_buffer; return 0; } -- 2.47.3

