Hi,
I would like to commit the TCP/IP layer for TCP segmentation offload.
The driver is not part of this diff, it should be reviewed separately.
Also the ifconfig flags and pseudo interfaces capabilities discussion
is excluded.
I kept the wrong names IFXF_TSO and IFCAP_TSO as jan@'s diff will
make them consistent. The numbers for the defines are not changed,
so my commit should not break anything.
This diff has no effect, as drivers do not set TSO capabilites yet.
I would like to commit it anyway to see that nothing else breaks.
Note that hardware might support IPv4 only, so add two separate
capabilities.
ok?
bluhm
Index: net/if.h
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/if.h,v
retrieving revision 1.211
diff -u -p -r1.211 if.h
--- net/if.h7 Mar 2023 20:09:48 - 1.211
+++ net/if.h14 May 2023 19:56:02 -
@@ -231,7 +231,7 @@ struct if_status_description {
#define IFXF_INET6_NOSOII 0x40/* [N] don't do RFC 7217 */
#defineIFXF_AUTOCONF4 0x80/* [N] v4 autoconf (aka dhcp)
enabled */
#defineIFXF_MONITOR0x100 /* [N] only used for bpf */
-#defineIFXF_TSO0x200 /* [N] TCP segment offloading */
+#defineIFXF_TSO0x200 /* [N] XXX missnamed, should be
LRO */
#defineIFXF_CANTCHANGE \
(IFXF_MPSAFE|IFXF_CLONED)
@@ -251,7 +251,9 @@ struct if_status_description {
#defineIFCAP_VLAN_HWTAGGING0x0020 /* hardware VLAN tag
support */
#defineIFCAP_CSUM_TCPv60x0080 /* can do IPv6/TCP
checksums */
#defineIFCAP_CSUM_UDPv60x0100 /* can do IPv6/UDP
checksums */
-#defineIFCAP_TSO 0x4000 /* TCP segment
offloading */
+#defineIFCAP_TSOv4 0x1000 /* IPv4/TCP segment
offload */
+#defineIFCAP_TSOv6 0x2000 /* IPv6/TCP segment
offload */
+#defineIFCAP_TSO 0x4000 /* XXX should be LRO */
#defineIFCAP_WOL 0x8000 /* can do wake on lan */
#define IFCAP_CSUM_MASK(IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | \
Index: net/pf.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/net/pf.c,v
retrieving revision 1.1179
diff -u -p -r1.1179 pf.c
--- net/pf.c13 May 2023 13:35:17 - 1.1179
+++ net/pf.c14 May 2023 19:56:02 -
@@ -6555,15 +6555,9 @@ pf_route(struct pf_pdesc *pd, struct pf_
goto done;
}
- if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) &&
- m0->m_pkthdr.ph_mss <= ifp->if_mtu) {
- if (tcp_chopper(m0, , ifp, m0->m_pkthdr.ph_mss) ||
- if_output_ml(ifp, , sintosa(dst), rt))
- goto done;
- tcpstat_inc(tcps_outswtso);
+ if (tcp_if_output_tso(ifp, , sintosa(dst), rt,
+ IFCAP_TSOv4, ifp->if_mtu) || m0 == NULL)
goto done;
- }
- CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO);
/*
* Too large for interface; fragment if possible.
@@ -6598,7 +6592,6 @@ void
pf_route6(struct pf_pdesc *pd, struct pf_state *st)
{
struct mbuf *m0;
- struct mbuf_list ml;
struct sockaddr_in6 *dst, sin6;
struct rtentry *rt = NULL;
struct ip6_hdr *ip6;
@@ -6696,15 +6689,9 @@ pf_route6(struct pf_pdesc *pd, struct pf
goto done;
}
- if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) &&
- m0->m_pkthdr.ph_mss <= ifp->if_mtu) {
- if (tcp_chopper(m0, , ifp, m0->m_pkthdr.ph_mss) ||
- if_output_ml(ifp, , sin6tosa(dst), rt))
- goto done;
- tcpstat_inc(tcps_outswtso);
+ if (tcp_if_output_tso(ifp, , sin6tosa(dst), rt,
+ IFCAP_TSOv6, ifp->if_mtu) || m0 == NULL)
goto done;
- }
- CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO);
ip6stat_inc(ip6s_cantfrag);
if (st->rt != PF_DUPTO)
Index: netinet/ip_output.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.386
diff -u -p -r1.386 ip_output.c
--- netinet/ip_output.c 13 May 2023 13:35:17 - 1.386
+++ netinet/ip_output.c 14 May 2023 19:56:02 -
@@ -460,15 +460,10 @@ sendit:
goto done;
}
- if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO) &&
- m->m_pkthdr.ph_mss <= mtu) {
- if ((error = tcp_chopper(m, , ifp, m->m_pkthdr.ph_mss)) ||
- (error = if_output_ml(ifp, , sintosa(dst), ro->ro_rt)))
- goto done;
- tcpstat_inc(tcps_outswtso);
+ error = tcp_if_output_tso(ifp, , sintosa(dst), ro->ro_rt,
+