First, let me summarize the current status of the problem. Most problems
have been resolved by msaito. The remaining problem is that transmission
from interface if0 to interface if1 fails when any TX offload option is
enabled for if0 but disabled for if1.
We need handle TX offload in software in bridge_output() when some TX
offload option is enabled for a packet and it is not available for the
destination interface. The attached patches deal with this as follows.
For unicast:
(1) When the destination interface is the same as source interface, we
do not need to handle offload options; send a packet as is.
(2) When the destination is different from the source, check whether TX
offload options specified in a packet is supported by the
destination. If so, we can send it as is. Otherwise, handle these
options in software.
For multicast/broadcast:
(3) Send a packet as is if all the members of that bridge support given
TX offload options. Otherwise, handle these options in software.
For (3) we need calculate logical AND b/w capabilities of TX offload
options in member interface (ifp->if_csum_flags_tx). I've added
sc_csum_flags_tx flag to bridge softc for this purpose. This flag is
updated when a member is (i) added to or (ii) removed from a bridge, or
(iii) if_csum_flags_tx flag of a member interface is manipulated via
ifconfig(8).
Also, currently, if_csum_flags_tx do not contains M_CSUM_TSOv[46]. I've
added these flags when TSOv[46] is enabled for that interface. As far
as I can see, no one seems to depend on the old behavior.
I've separated the patch into four parts for readability.
(a) http://www.netbsd.org/~rin/bridge_20181204/ether_sw_offload_20181204.patch
This patch provides routines to handle TX/RX offload options in software
for ethernet. Since this breaks separation between L2 and L3/L4, I've
added new files (ether_sw_offload.[ch]) rather than adding the routines
to existing files.
(b) http://www.netbsd.org/~rin/bridge_20181204/bridge_sw_offload_20181204.patch
This is main patch to deal with the problem described above by using (a).
(c) http://www.netbsd.org/~rin/bridge_20181204/if_shmem_sw_offload_20181204.patch
This patch adds TX/RX offload support for shmemif(4) using (a). This may
be useful for testing offload related codes in the ATF framework. This
patch also contains a test code written by msaito; if_capabilities for
shmemif(4) can be specified by environmental variable
RUMP_SHMIF_CAPENABLE:
setenv RUMP_SHMIF_CAPENABLE 0x7ff80 (all offload)
setenv RUMP_SHMIF_CAPENABLE 0x6aa80 (all TX)
setenv RUMP_SHMIF_CAPENABLE 0x15500 (all RX)
for definition of flags, see sys/net/if.h:
https://nxr.netbsd.org/xref/src/sys/net/if.h#591
I've tested all tests in /usr/tests passed with all offload options
enabled (RUMP_SHMIF_CAPENABLE=0x7ff80).
(d) http://www.netbsd.org/~rin/bridge_20181204/simplify_ip_output_20181204.patch
This patch simplify logics in ip{,6}_output() by using M_CSUM_TSOv[46]
bits in ifp->if_csum_flags_tx.
Any comments and suggestions are welcomed. I thank msaito for fruitful
discussion!
rin