From nobody Tue Aug 20 12:43:52 2024 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 4Wp8KP3xLZz5T487; Tue, 20 Aug 2024 12:43:53 +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 4Wp8KN4mmNz4TXm; Tue, 20 Aug 2024 12:43:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724157832; 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=5HDtnAhqkiPcPjx4mOEFE5GOOzjEKHcx0pV5XQhB6m0=; b=vs73LkXZIAzPP7Fzc/icFx1vJzAIhtE/wrVBM1f3eBg6KQeErhFAzdz0UJ8meHG+Cm0j91 UySI3680o6Zq90nvOoUkPaZIVwKdr5gcweWCldi4WIof60amXaKyfm9b67JtiT1QuxeWr6 Om+AQyBe8RHP7oKgaQOVk2Tzce219JS8hoSOZabKyZhKQWxWhmZrEGTOpHJ/4VMlC/ahEh SYSXFt+7syS2EwwBhFIHL+Rp03EoT28x/pkuOlLo3m426ZHHv4Kpx6oXCY7O17MkkFg/d4 cmxWC8DJcB5iJ96UUbBPVxOovR6W2JaEywtGA66ox1ns91XFyhwUfgTzVzzsjg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724157832; a=rsa-sha256; cv=none; b=GRqKZLyHNFHR5EdH6U9cvI6L0DtwJ1BHRWxoWtLId1k8Yxt758SBPj5Kt2cJJ05gXJYHFR t6fRKCKabR7ibgYc9kOoez6lt0NdbyHQo1RLdkO4SfHmIyBxvoP+Q5dunvXyttDn3quyVx atc58SrmqS+q/eEU8of1k4kqgiWzWJup4QONvWohjiQ5iDKR10VdjohDrcJilSj2hd6Fe6 wdHCH9NtFpG75kEL/PmLCyWfCpsM2BgCxir5soIWChPrDC4MV7TliKPpnvOXXNhv/l6IiQ yGC07mXiynxc8qMR9uXARgtSVAZi2O/PExvJloRTGCRB2qeQjES5C/GmEsWoag== 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=1724157832; 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=5HDtnAhqkiPcPjx4mOEFE5GOOzjEKHcx0pV5XQhB6m0=; b=CQa+wbIoCfx9ZgHpI+BaClGSLenHYa5pndqUOpTBgGTqbyCdy5WqmIMqPZb7zbsdFt4s70 soqwJXKr0Q9uGst1BMZZQ7k2AM6TQokpa4pduIU6fK2SSol8FWlmkjR8AB+ST/S1RvSbsU e5Ro+2qyPDnv9OD3+7laK7SH1zAP89ZN8T5mmWTDXBLmftQh+L3b3cND6r+bdeMppgiBHE jkTGCIhOBNMZSpzmssSQXuFZfqd/Hv2g0HmCH2yNhYSqQPRNn1/QYdt0l5/DvOEbTdwDHE 4x0rKJDghYhInzRICSFx/q9STymuXIsqbEiEMZAhAi6Zq1hKlFcBX2EosvhhkQ== 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 4Wp8KN43FVz11KX; Tue, 20 Aug 2024 12:43:52 +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 47KChqub054542; Tue, 20 Aug 2024 12:43:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47KChqcb054539; Tue, 20 Aug 2024 12:43:52 GMT (envelope-from git) Date: Tue, 20 Aug 2024 12:43:52 GMT Message-Id: <202408201243.47KChqcb054539@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: 66f0e2017f7c - main - ipsec_offload: add ipsec_accel_drv_sa_lifetime_fetch() 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 66f0e2017f7cd804f31ae4fc2ad38607d85a08d3 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=66f0e2017f7cd804f31ae4fc2ad38607d85a08d3 commit 66f0e2017f7cd804f31ae4fc2ad38607d85a08d3 Author: Konstantin Belousov AuthorDate: 2024-08-18 13:22:28 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-20 12:42:13 +0000 ipsec_offload: add ipsec_accel_drv_sa_lifetime_fetch() A function to fetch hardware counters for offloaded SA on specific interface. Sponsored by: NVidia networking --- sys/netipsec/ipsec_offload.c | 29 +++++++++++++++++++++++++++++ sys/netipsec/ipsec_offload.h | 4 ++++ sys/netipsec/key.c | 15 +++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/sys/netipsec/ipsec_offload.c b/sys/netipsec/ipsec_offload.c index 4d81803f4be7..bbf98ac7a676 100644 --- a/sys/netipsec/ipsec_offload.c +++ b/sys/netipsec/ipsec_offload.c @@ -157,6 +157,8 @@ static struct mbuf *ipsec_accel_key_setaccelif_impl(struct secasvar *sav); static void ipsec_accel_on_ifdown_impl(struct ifnet *ifp); static void ipsec_accel_drv_sa_lifetime_update_impl(struct secasvar *sav, if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +static int ipsec_accel_drv_sa_lifetime_fetch_impl(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs); static void ipsec_accel_ifdetach_event(void *arg, struct ifnet *ifp); static void @@ -177,6 +179,8 @@ ipsec_accel_init(void *arg) ipsec_accel_on_ifdown_p = ipsec_accel_on_ifdown_impl; ipsec_accel_drv_sa_lifetime_update_p = ipsec_accel_drv_sa_lifetime_update_impl; + ipsec_accel_drv_sa_lifetime_fetch_p = + ipsec_accel_drv_sa_lifetime_fetch_impl; pctrie_init(&drv_spi_pctrie); ipsec_accel_ifdetach_event_tag = EVENTHANDLER_REGISTER( ifnet_departure_event, ipsec_accel_ifdetach_event, NULL, @@ -200,6 +204,7 @@ ipsec_accel_fini(void *arg) ipsec_accel_key_setaccelif_p = NULL; ipsec_accel_on_ifdown_p = NULL; ipsec_accel_drv_sa_lifetime_update_p = NULL; + ipsec_accel_drv_sa_lifetime_fetch_p = NULL; ipsec_accel_sync_imp(); clean_unrhdr(drv_spi_unr); /* avoid panic, should go later */ clear_unrhdr(drv_spi_unr); @@ -1017,6 +1022,30 @@ out: NET_EPOCH_EXIT(et); } +static int +ipsec_accel_drv_sa_lifetime_fetch_impl(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs) +{ + struct ifp_handle_sav *i; + int error; + + NET_EPOCH_ASSERT(); + error = 0; + + mtx_lock(&ipsec_accel_cnt_lock); + CK_LIST_FOREACH(i, &sav->accel_ifps, sav_link) { + if (i->ifp == ifp && i->drv_spi == drv_spi) { + *octets = i->cnt_octets; + *allocs = i->cnt_allocs; + break; + } + } + if (i == NULL) + error = ENOENT; + mtx_unlock(&ipsec_accel_cnt_lock); + return (error); +} + static void ipsec_accel_sa_lifetime_hw(struct secasvar *sav, if_t ifp, struct seclifetime *lft) diff --git a/sys/netipsec/ipsec_offload.h b/sys/netipsec/ipsec_offload.h index 72055a110951..904fe6252396 100644 --- a/sys/netipsec/ipsec_offload.h +++ b/sys/netipsec/ipsec_offload.h @@ -64,6 +64,8 @@ extern struct mbuf *(*ipsec_accel_key_setaccelif_p)(struct secasvar *sav); extern void (*ipsec_accel_on_ifdown_p)(struct ifnet *ifp); extern void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav, if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +extern int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs); #ifdef IPSEC_OFFLOAD /* @@ -191,6 +193,8 @@ struct ipsec_accel_in_tag *ipsec_accel_input_tag_lookup(const struct mbuf *); void ipsec_accel_on_ifdown(struct ifnet *ifp); void ipsec_accel_drv_sa_lifetime_update(struct secasvar *sav, if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +int ipsec_accel_drv_sa_lifetime_fetch(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs); #endif /* _KERNEL */ diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 149173e0b5f6..5a3e5727bc2e 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -112,6 +112,8 @@ struct mbuf *(*ipsec_accel_key_setaccelif_p)(struct secasvar *sav); void (*ipsec_accel_on_ifdown_p)(struct ifnet *ifp); void (*ipsec_accel_drv_sa_lifetime_update_p)(struct secasvar *sav, if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +int (*ipsec_accel_drv_sa_lifetime_fetch_p)(struct secasvar *sav, if_t ifp, + u_int drv_spi, uint64_t *octets, uint64_t *allocs); #endif #define FULLMASK 0xff @@ -8990,4 +8992,17 @@ ipsec_accel_drv_sa_lifetime_update(struct secasvar *sav, if_t ifp, if (p != NULL) p(sav, ifp, drv_spi, octets, allocs); } + +int +ipsec_accel_drv_sa_lifetime_fetch(struct secasvar *sav, + if_t ifp, u_int drv_spi, uint64_t *octets, uint64_t *allocs) +{ + int (*p)(struct secasvar *sav, if_t ifp, u_int drv_spi, + uint64_t *octets, uint64_t *allocs); + + p = atomic_load_ptr(&ipsec_accel_drv_sa_lifetime_fetch_p); + if (p == NULL) + return (EOPNOTSUPP); + return (p(sav, ifp, drv_spi, octets, allocs)); +} #endif