From nobody Tue Nov 26 12:34:51 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 4XyMTl3Cyzz5fPl4; Tue, 26 Nov 2024 12:34:51 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XyMTl2hYyz47cM; Tue, 26 Nov 2024 12:34:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732624491; 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=aimjmHGR1bRg/v5BmX0DV5s63uLoW2XA7UtjLBNwLEM=; b=TkNu8Y6CIErPpE8o1p9uP6jFBNrdDpcf8SVkq7mjFw96d2KQ1CxSp0lGoseFzUImwKImqM MtXNcjVTet70gINB9XIUo7Kj9WqBkGgTtgUGfJFcTK7wtuXLCoMpBLo+D7EV2xFsSSmbmY TEHWkAr78jZLsyBeMJShZQ3iq6bLga6yneY7R0Vgp7FemCxh8A7NxYk1myAO0vy8k6iIEX FgGkOuhPNNrbK7hRxFQDLm87L4Wew9wC55rAo7frrvv37oN3qKM2YLRo8vJBY63rsXz7zM KNmQi0INp0+IHl2lZqsCU8laEI27M2BoDNkfRpHqkZG2YR2aNvcJ3iozRzcKZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732624491; 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=aimjmHGR1bRg/v5BmX0DV5s63uLoW2XA7UtjLBNwLEM=; b=uI9bcNpsymQus2XuSbrtm444Tq0gdp7iFqE8Ju3jLEc9PmSAzFq9VeWLdxI3q74P47HE6H vpnVM+CpY6Brl+CYi9hc9gcEI9nf1empP46vfIvfQxOPZcK0P/pfVlRjwBuZoppji3qDRu mjFstXQ4OBmhGCxaLySVHZ0vUtz1lKxPF84JHlZry8SHq/trrAXx1JdHTLIrdjNW6Pglnp rVtQ5YI+xNtb3TKvcwh1WHxiJVlj9wFQuX6mnM0AJiCInGJ3IephM3aSPhluL0aRa+houv dA8UZ6XOKLePn7j/iQZgp6DTxvvLmzIONduXJsvEvtFa74x7Z+qrgFA3HfUaUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732624491; a=rsa-sha256; cv=none; b=Sgf4yxQMP9lnub6dowdh+dmKO19TrwuzuYrbabZvRPm7qEaYK5ZYsmjR67SkOJ/srFGq/M IIaNB4qc1Wm+84D973fIMJspGAPfn9NZeJgQi4YQRMfSUw8b+KnLfddVDpGGgMx/4JgjEC /1DBCJLHiwaV2LDc7zeApuH+LQSzjb34VTohWzwFoeFm7v3y4s4veJvJkpg0v0aD5LZ2af CsGQTy7tv2Ess4pskUEmeXl9JKOsJolZBMvJudaYM2u3Pv6Ffooosa7BIZ2EkgUReMDhtj 5cXCsvVUosXKOfXWeYeYLgc/nBEDhLOVW4SHZjmgOa21cIhKixevjOplZYKj+g== 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 4XyMTl29WDzQ5Z; Tue, 26 Nov 2024 12:34:51 +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 4AQCYpBV038913; Tue, 26 Nov 2024 12:34:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AQCYp1k038910; Tue, 26 Nov 2024 12:34:51 GMT (envelope-from git) Date: Tue, 26 Nov 2024 12:34:51 GMT Message-Id: <202411261234.4AQCYp1k038910@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: cca0dc49e0ca - main - mlx5en: move runtime capabilities checks into helper functions 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: cca0dc49e0ca66f7696920266ea6340b05e3e455 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=cca0dc49e0ca66f7696920266ea6340b05e3e455 commit cca0dc49e0ca66f7696920266ea6340b05e3e455 Author: Konstantin Belousov AuthorDate: 2024-11-21 05:51:18 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-26 12:34:34 +0000 mlx5en: move runtime capabilities checks into helper functions For TLS TX/RX, ratelimit, and IPSEC offload caps. Reviewed by: Ariel Ehrenberg Sponsored by: NVidia networking MFC after: 1 week --- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 70 ++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index ec35d87af962..e3c075d4dd80 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -3404,6 +3404,51 @@ mlx5e_set_rx_mode(if_t ifp) queue_work(priv->wq, &priv->set_rx_mode_work); } +static bool +mlx5e_is_ipsec_capable(struct mlx5_core_dev *mdev) +{ +#ifdef IPSEC_OFFLOAD + if ((mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_PACKET_OFFLOAD) != 0) + return (true); +#endif + return (false); +} + +static bool +mlx5e_is_ratelimit_capable(struct mlx5_core_dev *mdev) +{ +#ifdef RATELIMIT + if (MLX5_CAP_GEN(mdev, qos) && + MLX5_CAP_QOS(mdev, packet_pacing)) + return (true); +#endif + return (false); +} + +static bool +mlx5e_is_tlstx_capable(struct mlx5_core_dev *mdev) +{ +#ifdef KERN_TLS + if (MLX5_CAP_GEN(mdev, tls_tx) != 0 && + MLX5_CAP_GEN(mdev, log_max_dek) != 0) + return (true); +#endif + return (false); +} + +static bool +mlx5e_is_tlsrx_capable(struct mlx5_core_dev *mdev) +{ +#ifdef KERN_TLS + if (MLX5_CAP_GEN(mdev, tls_rx) != 0 && + MLX5_CAP_GEN(mdev, log_max_dek) != 0 && + MLX5_CAP_FLOWTABLE_NIC_RX(mdev, + ft_field_support.outer_ip_version) != 0) + return (true); +#endif + return (false); +} + static int mlx5e_ioctl(if_t ifp, u_long command, caddr_t data) { @@ -4535,29 +4580,20 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) if_setcapabilitiesbit(ifp, IFCAP_TSO | IFCAP_VLAN_HWTSO, 0); if_setcapabilitiesbit(ifp, IFCAP_HWSTATS | IFCAP_HWRXTSTMP, 0); if_setcapabilitiesbit(ifp, IFCAP_MEXTPG, 0); -#ifdef KERN_TLS - if (MLX5_CAP_GEN(mdev, tls_tx) != 0 && - MLX5_CAP_GEN(mdev, log_max_dek) != 0) + if (mlx5e_is_tlstx_capable(mdev)) if_setcapabilitiesbit(ifp, IFCAP_TXTLS4 | IFCAP_TXTLS6, 0); - if (MLX5_CAP_GEN(mdev, tls_rx) != 0 && - MLX5_CAP_GEN(mdev, log_max_dek) != 0 && - MLX5_CAP_FLOWTABLE_NIC_RX(mdev, - ft_field_support.outer_ip_version) != 0) + if (mlx5e_is_tlsrx_capable(mdev)) if_setcapabilities2bit(ifp, IFCAP2_BIT(IFCAP2_RXTLS4) | IFCAP2_BIT(IFCAP2_RXTLS6), 0); -#endif -#ifdef RATELIMIT - if (MLX5_CAP_GEN(mdev, qos) && - MLX5_CAP_QOS(mdev, packet_pacing)) - if_setcapabilitiesbit(ifp, IFCAP_TXRTLMT | IFCAP_TXTLS_RTLMT, - 0); -#endif + if (mlx5e_is_ratelimit_capable(mdev)) { + if_setcapabilitiesbit(ifp, IFCAP_TXRTLMT, 0); + if (mlx5e_is_tlstx_capable(mdev)) + if_setcapabilitiesbit(ifp, IFCAP_TXTLS_RTLMT, 0); + } if_setcapabilitiesbit(ifp, IFCAP_VXLAN_HWCSUM | IFCAP_VXLAN_HWTSO, 0); -#ifdef IPSEC_OFFLOAD - if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_PACKET_OFFLOAD) + if (mlx5e_is_ipsec_capable(mdev)) if_setcapabilities2bit(ifp, IFCAP2_BIT(IFCAP2_IPSEC_OFFLOAD), 0); -#endif if_setsndtagallocfn(ifp, mlx5e_snd_tag_alloc); #ifdef RATELIMIT