Index | Thread | Search

From:
Jan Klemkow <jan@openbsd.org>
Subject:
Re: SoftLRO diff for cnmac/octeon
To:
icepic.dz@gmail.com, tech@openbsd.org, visa@openbsd.org
Date:
Thu, 29 Jan 2026 22:39:46 +0100

Download raw body.

Thread
On Thu, Jan 29, 2026 at 09:51:44PM +0100, Kirill A. Korinsky wrote:
> On Thu, 29 Jan 2026 21:45:33 +0100,
> Jan Klemkow <jan@openbsd.org> wrote:
> > 
> > On Thu, Jan 29, 2026 at 04:00:48PM +0100, Janne Johansson wrote:
> > > This is an update for the diff I sent when Jan Klemkow first sent out
> > > the proposal for SoftLRO last year for certain interfaces.
> > > It still gives me large speedups (*)  for incoming TCP and I have been
> > > running it for a long while.
> > > 
> > > In case gmail as usual mangles the whitespaces, the diff is also available here:
> > > 
> > > https://s3.sto3.safedc.net/jj-public-files/cnmac.softlro.diff
> > 
> > Thanks for the diff, but...
> > 
> > Patching file dev/if_cnmac.c using Plan A...
> > Hunk #1 succeeded at 55.
> > Hunk #2 failed at 109.
> > Hunk #3 failed at 310.
> > Hunk #4 failed at 318.
> > Hunk #5 failed at 1251.
> > 4 out of 5 hunks failed--saving rejects to dev/if_cnmac.c.rej
> > Hmm...  Ignoring the trailing garbage.
> > done
> > 
> > Even the downloaded version does not apply to cvs HEAD because of
> > missing tabs.
> > 
> 
> Hm, it applies as:

Sorry, my mistake.  I applied the mail version twice.

Thanks Kirill for testing.  I don't have this NIC in my octeon machine.

Comments inline:

> Index: dev/if_cnmac.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/octeon/dev/if_cnmac.c,v
> diff -u -p -u -r1.86 if_cnmac.c
> --- dev/if_cnmac.c	20 May 2024 23:13:33 -0000	1.86
> +++ dev/if_cnmac.c	29 Jan 2026 14:35:19 -0000
> @@ -55,6 +55,9 @@
>  #include <net/if_media.h>
>  #include <netinet/in.h>
>  #include <netinet/if_ether.h>
> +#include <netinet/tcp.h>
> +#include <netinet/tcp_timer.h>
> +#include <netinet/tcp_var.h>
>  
>  #if NBPFILTER > 0
>  #include <net/bpf.h>
> @@ -106,6 +109,7 @@
>  
>  CTASSERT(MCLBYTES >= OCTEON_POOL_SIZE_PKT + CACHELINESIZE);
>  
> +
>  void	cnmac_buf_init(struct cnmac_softc *);
>  
>  int	cnmac_match(struct device *, void *, void *);
> @@ -306,7 +310,7 @@ cnmac_attach(struct device *parent, stru
>  	strncpy(ifp->if_xname, sc->sc_dev.dv_xname, sizeof(ifp->if_xname));
>  	ifp->if_softc = sc;
>  	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
> -	ifp->if_xflags = IFXF_MPSAFE;
> +	ifp->if_xflags = IFXF_MPSAFE|IFXF_LRO;
>  	ifp->if_ioctl = cnmac_ioctl;
>  	ifp->if_qstart = cnmac_start;
>  	ifp->if_watchdog = cnmac_watchdog;
> @@ -314,7 +318,8 @@ cnmac_attach(struct device *parent, stru
>  	ifq_init_maxlen(&ifp->if_snd, max(GATHER_QUEUE_SIZE, IFQ_MAXLEN));
>  
>  	ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_TCPv4 |
> -	    IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6;
> +	    IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6 |
> +	    IFCAP_LRO;
>  
>  	cn30xxgmx_set_filter(sc->sc_gmx_port);
>  
> @@ -1246,7 +1251,10 @@ cnmac_recv(struct cnmac_softc *sc, uint6
>  			    M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK;
>  	}
>  

The following macro is needed, or your diff breaks SMALL_KERNELs like
the bsd.rd.

#ifndef SMALL_KERNEL

> -	ml_enqueue(ml, m);
> +	if (ISSET(ifp->if_xflags, IFXF_LRO))

It there a way do differentiate between TCP and over packets?
So, you could use the same pattern, as in the other drivers?
Is there a programmers guide for this chip, which might help?

> +	  tcp_softlro_glue(ml, m, ifp);

The indentation it wrong here.

> +	else

#endif

> +	  ml_enqueue(ml, m);

The indentation it wrong here, too.

>  
>  	return nmbuf;
>