Re: [PATCH v1 4/5] net/zxdh: add support primary/secondary process

Stephen Hemminger
2025-12-21T17:00:27Z

On Sat, 20 Dec 2025 14:15:20 +0800
Junlong Wang <wang.junlong1@zte.com.cn> wrote:

> diff --git a/drivers/net/zxdh/zxdh_ethdev_ops.c b/drivers/net/zxdh/zxdh_ethdev_ops.c
> index 8fb315eeac..068dd21876 100644
> --- a/drivers/net/zxdh/zxdh_ethdev_ops.c
> +++ b/drivers/net/zxdh/zxdh_ethdev_ops.c
> @@ -1802,22 +1802,26 @@ zxdh_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
> struct zxdh_hw_mac_bytes mac_bytes = {0};
> uint32_t i = 0;
>
> - zxdh_hw_vqm_stats_get(dev, ZXDH_VQM_DEV_STATS_GET, &vqm_stats);
> - if (hw->is_pf)
> - zxdh_hw_mac_stats_get(dev, &mac_stats, &mac_bytes);
> + if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> + zxdh_hw_vqm_stats_get(dev, ZXDH_VQM_DEV_STATS_GET, &vqm_stats);
> + if (hw->is_pf)
> + zxdh_hw_mac_stats_get(dev, &mac_stats, &mac_bytes);
>
> - zxdh_hw_np_stats_get(dev, &np_stats);
> + zxdh_hw_np_stats_get(dev, &np_stats);
>
> - stats->ipackets = vqm_stats.rx_total;
> - stats->opackets = vqm_stats.tx_total;
> - stats->ibytes = vqm_stats.rx_bytes;
> - stats->obytes = vqm_stats.tx_bytes;
> - stats->imissed = vqm_stats.rx_drop + mac_stats.rx_drop;
> - stats->ierrors = vqm_stats.rx_error + mac_stats.rx_error + np_stats.rx_mtu_drop_pkts;
> - stats->oerrors = vqm_stats.tx_error + mac_stats.tx_error + np_stats.tx_mtu_drop_pkts;
> + stats->ipackets = vqm_stats.rx_total;
> + stats->opackets = vqm_stats.tx_total;
> + stats->ibytes = vqm_stats.rx_bytes;
> + stats->obytes = vqm_stats.tx_bytes;
> + stats->imissed = vqm_stats.rx_drop + mac_stats.rx_drop;
> + stats->ierrors = vqm_stats.rx_error +
> + mac_stats.rx_error + np_stats.rx_mtu_drop_pkts;
> + stats->oerrors = vqm_stats.tx_error +
> + mac_stats.tx_error + np_stats.tx_mtu_drop_pkts;
>
> - if (hw->i_mtr_en || hw->e_mtr_en)
> - stats->imissed += np_stats.rx_mtr_drop_pkts;
> + if (hw->i_mtr_en || hw->e_mtr_en)
> + stats->imissed += np_stats.rx_mtr_drop_pkts;
> + }
>

Does this driver support getting stats in the secondary process?
There are some Network Virtual Appliance products that run with all the
work being done by secondary process and only use the primary as a watchdog for restart.