git: 219a6ca91957 - main - tcp: uninline tcp_account_for_send()

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 21 Nov 2023 17:23:25 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=219a6ca919576c4f7e783720f66a458d51476f3d

commit 219a6ca919576c4f7e783720f66a458d51476f3d
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-11-21 17:21:41 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-11-21 17:21:41 +0000

    tcp: uninline tcp_account_for_send()
    
    This allows to clear inclusion of "opt_kern_tls.h" from a system header.
    
    Reviewed by:            rscheff, tuexen
    Differential Revision:  https://reviews.freebsd.org/D42696
---
 sys/netinet/tcp_subr.c | 27 +++++++++++++++++++++++++++
 sys/netinet/tcp_var.h  | 26 +-------------------------
 2 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 27b0eae83837..083a8b1ea384 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -4678,3 +4678,30 @@ tcp_get_srtt(struct tcpcb *tp, int granularity)
 
 	return (srtt);
 }
+
+void
+tcp_account_for_send(struct tcpcb *tp, uint32_t len, uint8_t is_rxt,
+    uint8_t is_tlp, bool hw_tls)
+{
+
+	if (is_tlp) {
+		tp->t_sndtlppack++;
+		tp->t_sndtlpbyte += len;
+	}
+	/* To get total bytes sent you must add t_snd_rxt_bytes to t_sndbytes */
+	if (is_rxt)
+		tp->t_snd_rxt_bytes += len;
+	else
+		tp->t_sndbytes += len;
+
+#ifdef KERN_TLS
+	if (hw_tls && is_rxt && len != 0) {
+		uint64_t rexmit_percent;
+
+		rexmit_percent = (1000ULL * tp->t_snd_rxt_bytes) /
+		    (10ULL * (tp->t_snd_rxt_bytes + tp->t_sndbytes));
+		if (rexmit_percent > ktls_ifnet_max_rexmit_pct)
+			ktls_disable_ifnet(tp);
+	}
+#endif
+}
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 2236a1385b44..2119c9dbe58f 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -38,7 +38,6 @@
 #include <netinet/tcp_fsm.h>
 
 #ifdef _KERNEL
-#include "opt_kern_tls.h"
 #include <net/vnet.h>
 #include <sys/mbuf.h>
 #include <sys/ktls.h>
@@ -1358,6 +1357,7 @@ VNET_DECLARE(struct hhook_head *, tcp_hhh[HHOOK_TCP_LAST + 1]);
 #define	V_tcp_hhh		VNET(tcp_hhh)
 #endif
 
+void	tcp_account_for_send(struct tcpcb *, uint32_t, uint8_t, uint8_t, bool);
 int	 tcp_addoptions(struct tcpopt *, u_char *);
 struct tcpcb *
 	 tcp_close(struct tcpcb *);
@@ -1591,30 +1591,6 @@ tcp_set_flags(struct tcphdr *th, uint16_t flags)
         th->th_x2    = (flags >> 8) & 0x0f;
         th->th_flags = flags & 0xff;
 }
-
-static inline void
-tcp_account_for_send(struct tcpcb *tp, uint32_t len, uint8_t is_rxt,
-    uint8_t is_tlp, bool hw_tls)
-{
-	if (is_tlp) {
-		tp->t_sndtlppack++;
-		tp->t_sndtlpbyte += len;
-	}
-	/* To get total bytes sent you must add t_snd_rxt_bytes to t_sndbytes */
-	if (is_rxt)
-		tp->t_snd_rxt_bytes += len;
-	else
-		tp->t_sndbytes += len;
-
-#ifdef KERN_TLS
-	if (hw_tls && is_rxt && len != 0) {
-		uint64_t rexmit_percent = (1000ULL * tp->t_snd_rxt_bytes) / (10ULL * (tp->t_snd_rxt_bytes + tp->t_sndbytes));
-		if (rexmit_percent > ktls_ifnet_max_rexmit_pct)
-			ktls_disable_ifnet(tp);
-	}
-#endif
-
-}
 #endif /* _KERNEL */
 
 #endif /* _NETINET_TCP_VAR_H_ */