Index | Thread | Search

From:
Alexander Bluhm <bluhm@openbsd.org>
Subject:
Re: iavf: remove IAVF_MAX_VECTORS
To:
Jonathan Matthew <jonathan@d14n.org>
Cc:
tech@openbsd.org, jan@openbsd.org
Date:
Wed, 19 Nov 2025 14:38:45 +0100

Download raw body.

Thread
On Wed, Nov 19, 2025 at 08:49:19PM +1000, Jonathan Matthew wrote:
> The iavf spec says the VF is guaranteed at least 5 MSI-X vectors and
> 4 queue pairs; the size of the MSI-X table is accounted for already,
> and we get the actual number of queue pairs in response to the
> IAVF_VC_OP_GET_VF_RESOURCES message, so we can get rid of
> IAVF_MAX_VECTORS and we'll be able to make use of bigger VFs should
> they ever exist.
> 
> ok?

I cannot test this.  Maybe jan@ has a machine that he can configure
manually with a lot of effort.

Your explanation makes sense.  Actually that matches my idea.  We
have a global limit IF_MAX_VECTORS to tune performance and resource
allocation.  The driver limits itself to hardware capabilities.

Thanks.

OK bluhm@

> Index: if_iavf.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_iavf.c,v
> diff -u -p -r1.26 if_iavf.c
> --- if_iavf.c	11 Nov 2025 17:43:18 -0000	1.26
> +++ if_iavf.c	19 Nov 2025 10:46:29 -0000
> @@ -91,7 +91,6 @@
>  #define CACHE_LINE_SIZE 64
>  #endif
>  
> -#define IAVF_MAX_VECTORS		4
>  #define IAVF_MAX_DMA_SEG_SIZE		((16 * 1024) - 1)
>  
>  #define I40E_MASK(mask, shift)		((mask) << (shift))
> @@ -643,6 +642,7 @@ struct iavf_softc {
>  	uint32_t		 sc_vf_id;
>  	uint16_t		 sc_vsi_id;
>  	uint16_t		 sc_qset_handle;
> +	uint16_t		 sc_num_queue_pairs;
>  	unsigned int		 sc_base_queue;
>  	uint32_t		 sc_rss_key_size;
>  	uint32_t		 sc_rss_lut_size;
> @@ -1035,7 +1035,7 @@ iavf_attach(struct device *parent, struc
>  			nmsix--;
>  
>  			sc->sc_intrmap = intrmap_create(&sc->sc_dev, nmsix,
> -			    MIN(IAVF_MAX_VECTORS, IF_MAX_VECTORS),
> +			    MIN(sc->sc_num_queue_pairs, IF_MAX_VECTORS),
>  			    INTRMAP_POWEROF2);
>  			nqueues = intrmap_count(sc->sc_intrmap);
>  			KASSERT(nqueues > 0);
> @@ -2588,13 +2588,11 @@ iavf_process_vf_resources(struct iavf_so
>  	if (mtu != 0)
>  		ifp->if_hardmtu = MIN(IAVF_HARDMTU, mtu);
>  
> -	/* limit vectors to what we got here? */
> -
>  	/* just take the first vsi */
>  	vsi_res = &vf_res->vsi_res[0];
>  	sc->sc_vsi_id = letoh16(vsi_res->vsi_id);
>  	sc->sc_qset_handle = letoh16(vsi_res->qset_handle);
> -	/* limit number of queues to what we got here */
> +	sc->sc_num_queue_pairs = letoh16(vsi_res->num_queue_pairs);
>  	/* is vsi type interesting? */
>  
>  	sc->sc_vf_id = letoh32(desc->iaq_param[0]);