From nobody Wed Jan 26 12:42:10 2022 X-Original-To: dev-commits-src-all@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 940E2198AACC; Wed, 26 Jan 2022 12:42:13 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JkNdw5shkz4kTV; Wed, 26 Jan 2022 12:42:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643200933; 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=n1sKPGfNvqyVHDFo7FRhToAdLb7pC9MehjGNaqBkKpU=; b=DVN7IKJXhBbPVO7N2CcPRIFhNmyKq0RCbNOnnFCcvLTmutObbsBhp+A++LqjbTJAljtNkH Xh4eNADRIzrLWr7eEqfFwt+hCWEyVpiuQQPlMDtCFG1JRtlGHOGegBnsqpsi2fsrZBrAXv /elGua4FN3ZsykJl1ykaHKihq793Kihtu3c9lyeyO9fIq1LozEL5X2ygbJZrWgluM9oScx YCCa4+Ur42TD930uM1F60V0Ud8o4+sI9KOSC+TYMtxcAehRpoI8RZKfRn4ACMpTNTzLLNI G4S9gLh7vYaz0KP7GrrQTW5kAKPjhdDjWs8MOlsaRQSAX9kHIr5D2zeMQMeVDg== 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 C286D1D355; Wed, 26 Jan 2022 12:42:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20QCgAE8075028; Wed, 26 Jan 2022 12:42:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20QCgAkq075027; Wed, 26 Jan 2022 12:42:10 GMT (envelope-from git) Date: Wed, 26 Jan 2022 12:42:10 GMT Message-Id: <202201261242.20QCgAkq075027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 9e2cce7e6a87 - main - Implement a function to get the next TCP- and TLS- receive sequence number. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9e2cce7e6a87dd68af0f671f964cc7b3464ea76a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643200933; 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=n1sKPGfNvqyVHDFo7FRhToAdLb7pC9MehjGNaqBkKpU=; b=iNCSxfxKLdFEn/juXw5SFuYZ5tGHDxnEFaFFo4km8tiXiyMFi1QkXKzqi/nGU3z9RXczrL xJEUoQmuxrvJIYI27oqJDq0zCSbWrsVmE/43QSblhYRC1ItEzm+Mi90tchfbGXEa2AByJ+ /WRUm7z/FTznjebm6zrsHOr4ajcaVfOxBiUQu2i6rs16V3b7Gd3gYd0f83rsij2PCrkHeL b9ZfM3+dtc5XOavL0oJRh8LlZJ8voN/qvyPgjjUsimFUfZNdcoOb9Zb1Zo73nWijv7awYX COMJCx2ahIpLJbrxAqekKMQsgmZSsJnJMemdgAca7goEa4JiC2x/Rd3obIwwyw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643200933; a=rsa-sha256; cv=none; b=u3xdaBlgzwW3NmpbssrxpAE3Ksd+fQpm06tCsmpKo5JRREqlZBUfElnoA+rGGhHta+z+lQ YJhny9z5U2wEkmhRbNzl/lJzgk0d0xtHnoTU5PoLcgHc+24LFPwv4sF7JAalJ92mIFUOoX sZcNsoXP8UK9XrvSZJOc2fETI/zVZ1zT5xlSL/mj8Dpixi41Puvg+oMynIldZmwU0uFPfs xfBpzrK88DQ1tFjR5eictZhzt1FRjXURa3Rwxr33sxiAjXlKprGh2LyykWPz5qukglUfpw XeQ+ncwUviirnF7D4tOKZj2tWQzgpvgyHz2ttWiK3fjrPIS2BQvwD8Smbz0sEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=9e2cce7e6a87dd68af0f671f964cc7b3464ea76a commit 9e2cce7e6a87dd68af0f671f964cc7b3464ea76a Author: Hans Petter Selasky AuthorDate: 2022-01-26 11:53:13 +0000 Commit: Hans Petter Selasky CommitDate: 2022-01-26 11:55:00 +0000 Implement a function to get the next TCP- and TLS- receive sequence number. This function will be used by coming TLS hardware receive offload support. Differential Revision: https://reviews.freebsd.org/D32356 Discussed with: jhb@ MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/kern/uipc_ktls.c | 43 +++++++++++++++++++++++++++++++++++++++++++ sys/sys/ktls.h | 1 + 2 files changed, 44 insertions(+) diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c index 5912db865ef6..620536f28b34 100644 --- a/sys/kern/uipc_ktls.c +++ b/sys/kern/uipc_ktls.c @@ -1319,6 +1319,49 @@ ktls_get_rx_mode(struct socket *so, int *modep) return (0); } +/* + * ktls_get_rx_sequence - get the next TCP- and TLS- sequence number. + * + * This function gets information about the next TCP- and TLS- + * sequence number to be processed by the TLS receive worker + * thread. The information is extracted from the given "inpcb" + * structure. The values are stored in host endian format at the two + * given output pointer locations. The TCP sequence number points to + * the beginning of the TLS header. + * + * This function returns zero on success, else a non-zero error code + * is returned. + */ +int +ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq) +{ + struct socket *so; + struct tcpcb *tp; + + INP_RLOCK(inp); + so = inp->inp_socket; + if (__predict_false(so == NULL)) { + INP_RUNLOCK(inp); + return (EINVAL); + } + if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { + INP_RUNLOCK(inp); + return (ECONNRESET); + } + + tp = intotcpcb(inp); + MPASS(tp != NULL); + + SOCKBUF_LOCK(&so->so_rcv); + *tcpseq = tp->rcv_nxt - so->so_rcv.sb_tlscc; + *tlsseq = so->so_rcv.sb_tls_seqno; + SOCKBUF_UNLOCK(&so->so_rcv); + + INP_RUNLOCK(inp); + + return (0); +} + int ktls_get_tx_mode(struct socket *so, int *modep) { diff --git a/sys/sys/ktls.h b/sys/sys/ktls.h index a3eac69b5eeb..5cfca2d860a0 100644 --- a/sys/sys/ktls.h +++ b/sys/sys/ktls.h @@ -219,6 +219,7 @@ void ktls_enqueue_to_free(struct mbuf *m); int ktls_get_rx_mode(struct socket *so, int *modep); int ktls_set_tx_mode(struct socket *so, int mode); int ktls_get_tx_mode(struct socket *so, int *modep); +int ktls_get_rx_sequence(struct inpcb *inp, uint32_t *tcpseq, uint64_t *tlsseq); int ktls_output_eagain(struct inpcb *inp, struct ktls_session *tls); #ifdef RATELIMIT int ktls_modify_txrtlmt(struct ktls_session *tls, uint64_t max_pacing_rate);