Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: ice(4): add SIOCGIFRXR support
To:
tech@openbsd.org
Date:
Tue, 7 Oct 2025 14:26:04 +0200

Download raw body.

Thread
On Tue, Oct 07, 2025 at 01:58:45PM +0200, Claudio Jeker wrote:
> While trying to figure out why ice(4) fails to receive any packets on
> sparc64 I stumbled over the fact that ice(4) is missing SIOCGIFRXR
> support and so systat mbuf does not show the queues.
> 
> This implements this by mostly stealing the code from ixl(4).

Reads fine when compared to ixl.  ok stsp@

> Index: if_ice.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_ice.c,v
> diff -u -p -r1.59 if_ice.c
> --- if_ice.c	17 Sep 2025 12:54:19 -0000	1.59
> +++ if_ice.c	7 Oct 2025 11:56:06 -0000
> @@ -338,6 +338,8 @@ struct ice_softc {
>  	int sw_intr[ICE_MAX_VECTORS];
>  };
>  
> +static int ice_rxrinfo(struct ice_softc *, struct if_rxrinfo *);
> +
>  /**
>   * ice_driver_is_detaching - Check if the driver is detaching/unloading
>   * @sc: device private softc
> @@ -13756,6 +13758,9 @@ ice_ioctl(struct ifnet *ifp, u_long cmd,
>  	case SIOCGIFMEDIA:
>  		error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd);
>  		break;
> +	case SIOCGIFRXR:
> +		error = ice_rxrinfo(sc, (struct if_rxrinfo *)ifr->ifr_data);
> +		break;
>  	case SIOCADDMULTI:
>  		error = ether_addmulti(ifr, &sc->sc_ac);
>  		if (error == ENETRESET) {
> @@ -29800,6 +29805,35 @@ ice_rxrefill(void *arg)
>  	struct ice_softc *sc = rxq->vsi->sc;
>  
>  	ice_rxfill(sc, rxq);
> +}
> +
> +static int
> +ice_rxrinfo(struct ice_softc *sc, struct if_rxrinfo *ifri)
> +{
> +	struct ifnet *ifp = &sc->sc_ac.ac_if;
> +	struct if_rxring_info *ifr;
> +	struct ice_rx_queue *rxq;
> +	int i, rv;
> +
> +	if (!ISSET(ifp->if_flags, IFF_RUNNING))
> +		return (ENOTTY);
> +
> +	ifr = mallocarray(sizeof(*ifr), sc->sc_nqueues, M_TEMP,
> +	    M_WAITOK|M_CANFAIL|M_ZERO);
> +	if (ifr == NULL)
> +		return (ENOMEM);
> +
> +	for (i = 0; i < sc->sc_nqueues; i++) {
> +		rxq = ifp->if_iqs[i]->ifiq_softc;
> +		ifr[i].ifr_size = MCLBYTES + ETHER_ALIGN;
> +		snprintf(ifr[i].ifr_name, sizeof(ifr[i].ifr_name), "%d", i);
> +		ifr[i].ifr_info = rxq->rxq_acct;
> +	}
> +
> +	rv = if_rxr_info_ioctl(ifri, sc->sc_nqueues, ifr);
> +	free(ifr, M_TEMP, sc->sc_nqueues * sizeof(*ifr));
> +
> +	return (rv);
>  }
>  
>  /* ice_rx_queues_alloc - Allocate Rx queue memory */
> 
>