[dpdk-stable] [dpdk-dev] [PATCH] net/af_xdp: fix support of secondary process

Loftus, Ciara ciara.loftus at intel.com
Mon Sep 20 15:23:57 CEST 2021



> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Stephen Hemminger
> Sent: Friday 3 September 2021 17:15
> To: dev at dpdk.org
> Cc: Stephen Hemminger <stephen at networkplumber.org>;
> stable at dpdk.org; xiaolong.ye at intel.com
> Subject: [dpdk-dev] [PATCH] net/af_xdp: fix support of secondary process
> 
> Doing basic operations like info_get or get_stats was broken
> in af_xdp PMD. The info_get would crash because dev->device
> was NULL in secondary process. Fix this by doing same initialization
> as af_packet and tap devices.
> 
> The get_stats would crash because the XDP socket is not open in
> primary process. As a workaround don't query kernel for dropped
> packets when called from secondary process.
> 
> Note: this does not address the other bug which is that transmitting
> in secondary process is broken because the send() in tx_kick
> will fail because XDP socket fd is not valid in secondary process.

Hi Stephen,

Apologies for the delayed reply, I was on vacation.

In the Bugzilla report you suggest we:
"mark AF_XDP as broken in with primary/secondary
and return an error in probe in secondary process".
I agree with this suggestion. However with this patch we still permit secondary, and just make sure it doesn't crash for get_stats. Did you change your mind?
Personally, I would prefer to have primary/secondary either working 100% or else not allowed at all by throwing an error during probe. What do you think? Do you have a reason/use case to permit secondary processes despite some features not being available eg. full stats, tx?

Thanks,
Ciara

> 
> Bugzilla ID: 805
> Fixes: f1debd77efaf ("net/af_xdp: introduce AF_XDP PMD")
> Cc: stable at dpdk.org
> Cc: xiaolong.ye at intel.com
> Ciara Loftus <ciara.loftus at intel.com>
> Qi Zhang <qi.z.zhang at intel.com>
> Anatoly Burakov <anatoly.burakov at intel.com>
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 74ffa4511284..70abc14fa753 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -860,7 +860,7 @@ eth_stats_get(struct rte_eth_dev *dev, struct
> rte_eth_stats *stats)
>  	struct pkt_rx_queue *rxq;
>  	struct pkt_tx_queue *txq;
>  	socklen_t optlen;
> -	int i, ret;
> +	int i;
> 
>  	for (i = 0; i < dev->data->nb_rx_queues; i++) {
>  		optlen = sizeof(struct xdp_statistics);
> @@ -876,13 +876,12 @@ eth_stats_get(struct rte_eth_dev *dev, struct
> rte_eth_stats *stats)
>  		stats->ibytes += stats->q_ibytes[i];
>  		stats->imissed += rxq->stats.rx_dropped;
>  		stats->oerrors += txq->stats.tx_dropped;
> -		ret = getsockopt(xsk_socket__fd(rxq->xsk), SOL_XDP,
> -				XDP_STATISTICS, &xdp_stats, &optlen);
> -		if (ret != 0) {
> -			AF_XDP_LOG(ERR, "getsockopt() failed for
> XDP_STATISTICS.\n");
> -			return -1;
> -		}
> -		stats->imissed += xdp_stats.rx_dropped;
> +
> +		/* The socket fd is not valid in secondary process */
> +		if (rte_eal_process_type() != RTE_PROC_SECONDARY &&
> +		    getsockopt(xsk_socket__fd(rxq->xsk), SOL_XDP,
> +			       XDP_STATISTICS, &xdp_stats, &optlen) == 0)
> +			stats->imissed += xdp_stats.rx_dropped;
> 
>  		stats->opackets += stats->q_opackets[i];
>  		stats->obytes += stats->q_obytes[i];
> @@ -1799,7 +1798,9 @@ rte_pmd_af_xdp_probe(struct rte_vdev_device
> *dev)
>  			AF_XDP_LOG(ERR, "Failed to probe %s\n", name);
>  			return -EINVAL;
>  		}
> +		/* TODO: reconnect socket from primary */
>  		eth_dev->dev_ops = &ops;
> +		eth_dev->device = &dev->device;
>  		rte_eth_dev_probing_finish(eth_dev);
>  		return 0;
>  	}
> --
> 2.30.2



More information about the stable mailing list