From nobody Fri Jul 12 11:25:10 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WL8Qb23Vkz5QBrv; Fri, 12 Jul 2024 11:25:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WL8QZ6yRpz4jLJ; Fri, 12 Jul 2024 11:25:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720783511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dzv89xfN42GjyR51m39QnTBX2yu8DJAePAsW3p6E8mI=; b=j9z0v9yZXdknx9dfVr15Vs4DBAQp7RxkXOgAB/quSbXcIc2YDqZm3xcwNWleCdcbVhIgpC byRPPsUGK09NJ5mh+f2Z5GS/3XWa8MJkcWl9cSkzay5BXZ0P6HN3NqIf4xAapdokwWYvLY +Pgxd1vNgSB5EJHbxFb4XzAMMvcPIPsGvR5pS7DxucO6+cIu0C6LBq0ebYAfgI021+SnPv /hXQZFQ24sNdnVdie6gyJuMbda17efFLJp2+3gas76Q6M7BpaoDsgoLLhHBlKF2V2dMlar SRaG4jrWBFiIQbPyn1bgr7O3Z/dTjZPehsEO73tpQPJZlIAcV1/xryr9jiooGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1720783511; a=rsa-sha256; cv=none; b=b+2QnRTOSfGZICRY7sNQY7nXjVGhu0VIyPJ1Td8c8qiKbU/mbmDnY8e69LlOb3Tces1o6g slKnhAVAf1KlHJqHWwkeWpxRrtV43574ueERemvm5Ocv1aKUwkDOpAPzljNPQZ3sfp1yAF eW44ILm1s+tiBU2T/4tToJ99dvDGipJGwLNeNdHAjcCKD0IfP28U6lHt7lHeG0hEWaVIs9 s1UvUxlBWaiMJABtm4SbSEvteJK977PiYHxwYZnkiyCcIiit23+UPp1uHGYVqVa42t+CAD ECmFDf0FQNd9J2LesXk3nJaPp6lPeG/ERYWzpVMePI8h9M2Jd3xSU3R9tRJZ4A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1720783511; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Dzv89xfN42GjyR51m39QnTBX2yu8DJAePAsW3p6E8mI=; b=bvSyYr19qpWr6wHp8U5Oc/BxLx1iCLeCLJY+QRh62iPN4w7aYthtK0yJMRWm52Ez1C2It/ d/Gm5yCeJ32HhngeRllhpGECCJO+KMSJtgPlfK/eh+1Ctzze9ceAy4G5fAmWR6/FEOxEn/ 5IT/Gt4xv9AJN0ddDQ2N0Gvp2sur8danwxDFgWlpEm+V7vI9RWcBv6Ug5RxmWgCLq7A1Ep A6Qd0XPYeXnwP1mciO7trVURopcFKAInchzQG+LCl0DI9JfM7PZgU9ybkkdWjJdo5ZUdOr 5dS9wk56+3y/kIRZ4m8PiXQlekMXqps9MtrJzL4fga58hXwLoZ2K+WwOH/+qcw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WL8QZ6Z5Gzh7y; Fri, 12 Jul 2024 11:25:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46CBPA3f093223; Fri, 12 Jul 2024 11:25:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46CBPAWb093220; Fri, 12 Jul 2024 11:25:10 GMT (envelope-from git) Date: Fri, 12 Jul 2024 11:25:10 GMT Message-Id: <202407121125.46CBPAWb093220@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e6e2c0a5ef5d - main - ipsec_offload: switch TF2_IPSEC_TSO on/off as appropriate on output List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e6e2c0a5ef5d0454b19d2f89357b431eaeb1dd76 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e6e2c0a5ef5d0454b19d2f89357b431eaeb1dd76 commit e6e2c0a5ef5d0454b19d2f89357b431eaeb1dd76 Author: Konstantin Belousov AuthorDate: 2024-03-06 15:53:10 +0000 Commit: Konstantin Belousov CommitDate: 2024-07-12 04:27:59 +0000 ipsec_offload: switch TF2_IPSEC_TSO on/off as appropriate on output after the interface ipsec_accel method if_hwassist() is consulted. Sponsored by: NVIDIA networking --- sys/netipsec/ipsec_offload.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/sys/netipsec/ipsec_offload.c b/sys/netipsec/ipsec_offload.c index 7f63a5e0ccb6..48082830b88b 100644 --- a/sys/netipsec/ipsec_offload.c +++ b/sys/netipsec/ipsec_offload.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -803,26 +804,31 @@ ipsec_accel_output(struct ifnet *ifp, struct mbuf *m, struct inpcb *inp, { struct ifp_handle_sav *i; struct ip *ip; + struct tcpcb *tp; u_long ip_len, skip; + bool res; *hwassist = 0; + res = false; if (ifp == NULL) - return (false); + return (res); M_ASSERTPKTHDR(m); NET_EPOCH_ASSERT(); - if (sav == NULL) - return (ipsec_accel_output_tag(m, IPSEC_ACCEL_DRV_SPI_BYPASS)); + if (sav == NULL) { + res = ipsec_accel_output_tag(m, IPSEC_ACCEL_DRV_SPI_BYPASS); + goto out; + } i = ipsec_accel_is_accel_sav_ptr(sav, ifp); if (i == NULL) - return (false); + goto out; if ((m->m_pkthdr.csum_flags & CSUM_TSO) == 0) { ip_len = m->m_pkthdr.len; if (ip_len + i->hdr_ext_size > mtu) - return (false); + goto out; switch (af) { case AF_INET: ip = mtod(m, struct ip *); @@ -835,11 +841,11 @@ ipsec_accel_output(struct ifnet *ifp, struct mbuf *m, struct inpcb *inp, __unreachable(); } if (!ipsec_accel_output_pad(m, sav, skip, mtu)) - return (false); + goto out; } if (!ipsec_accel_output_tag(m, i->drv_spi)) - return (false); + goto out; ipsec_accel_sa_recordxfer(sav, m); key_freesav(&sav); @@ -848,7 +854,18 @@ ipsec_accel_output(struct ifnet *ifp, struct mbuf *m, struct inpcb *inp, *hwassist = ifp->if_ipsec_accel_m->if_hwassist(ifp, sav, i->drv_spi, i->ifdata); - return (true); + res = true; +out: + if (inp != NULL && inp->inp_pcbinfo == &V_tcbinfo) { + INP_WLOCK_ASSERT(inp); + tp = (struct tcpcb *)inp; + if (res && (*hwassist & (CSUM_TSO | CSUM_IP6_TSO)) != 0) { + tp->t_flags2 |= TF2_IPSEC_TSO; + } else { + tp->t_flags2 &= ~TF2_IPSEC_TSO; + } + } + return (res); } struct ipsec_accel_in_tag *