From nobody Wed Sep 16 14:13:29 2026 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 4hlLTQ2MZmz6rXPX for ; Wed, 16 Sep 2026 14:13:30 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hlLTQ1DrTz3NYZ for ; Wed, 16 Sep 2026 14:13:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789568010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzLAozK+J9N/SvWzPED7hnqrHeoWw8sJcs+d1baUg04=; b=jAIz8Euzn48WK6NxMZZfvWKflPss9rDaikhbby4znxzSglQz3yk1l2WkGY6y+ZNZYWsgj4 F9VeLrsTsY2MyWW50tAiVXgzd0SM3haGTuPlTzWdJpCpt43zD6eWPPpJa4z04twY80PiDJ lmEGomPyTNRZ5n3eryV+mMhtmhyNNpDYvZ/K0F+LgPPlE/A4/k9oM3G6XZBllFFjO85m6X v7nSvsfxJ33GBntr02OTc7jFlohsJZJVp/xtEyPpnnCvqQJF8Mfz9QGIMUTRF4x2kzo1WS bCn0LCEbt8eUBar44YrJIGJNozVGhECBcpI3QWUcw1eLSG7Zo5Ztn6zz8utlxg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789568010; b=nxWVm+YMVrttTa39A7JtC/iCqR3Uf+8LhysKpz8Ck3kfY/NvpPsbO58Xp43zcmaNPuA/r4 xU5v4v43nS5IKj4FNOFNjM61+xy6Ouw6F0JlWrua3ANdAQeZDn+jGh6aMYHOSMPxKIjXua bwt2tzjOdvw3k2FK9L/Q7Z5UuBwwhjqEys70h1ci5BHuLgNxVHEP1v5FmV9YgsVra0qEid gXUD9Bt/v86CspIPn/v/f6EL3JYYPUFaOg9rLsQqcdvxeuYkvyiL66NKEoMP8w3MgaoT8F L+D8Xo/3Boy5n0igG8SypC8a7J36rAynRC2PzukN6LzOv50da1JF3Te/e84UCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789568010; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzLAozK+J9N/SvWzPED7hnqrHeoWw8sJcs+d1baUg04=; b=sIzaizdbDa9GZl2zXD4/wuC28xLwxajgH/4NK04lwp0od7bhvfjB/ODGG+yicLaDkGynDy FIidfwk5kSlhzI3NMavkWjTzgADihKSsYvw8EM0giP0CkX6UbnFqkgVFrI5iZkmhqGdjMK 3p7ZG+6n66KkvjqhieGMx0lcVVLNW87SjtJf6vLoCPzv6kChV+daKVdy7pDAe8Ziv0LTw5 UnY9qln6zh1F1dOig2zJi1sPywoN1Z+Be3vZ1SlmQ+hwIcsVdKOVydUDQ8YzpUBMS1M1zw yic+ORFe7hDE07HTJ7hsRl+Yz9dxShyfqGFfiIch9oeHzwmOphwIOAoU8I40xQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hlLTP74v3zr2l for ; Wed, 16 Sep 2026 14:13:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37340 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 16 Sep 2026 14:13:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Vag Singh From: Konstantin Belousov Subject: git: 644f8990e2c2 - main - verbs/mlx5: Add GRE and MPLS flow specification filter 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 List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 644f8990e2c2203de649b80c82a2a56bacbd98a9 Auto-Submitted: auto-generated Date: Wed, 16 Sep 2026 14:13:29 +0000 Message-Id: <6aaaa409.37340.15805341@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=644f8990e2c2203de649b80c82a2a56bacbd98a9 commit 644f8990e2c2203de649b80c82a2a56bacbd98a9 Author: Vag Singh AuthorDate: 2025-08-14 07:06:01 +0000 Commit: Konstantin Belousov CommitDate: 2026-09-16 14:12:10 +0000 verbs/mlx5: Add GRE and MPLS flow specification filter [PATCH 30/31] FreeBSD OFED support for DPDK MLX5 PMD a) Allow verbs applications packet steering of GRE tunneled traffic. Adding GRE flow specification based on RFC 2890. GRE consists of flags, protocol and key fields. IPv4 protocol 47 (IPPROTO_GRE) can be used when GRE packets are encapsulated in IPv4. b) verbs: Add MPLS flow specification filter Add MPLS flow specification based on RFC 3032. MPLS spec defined with label field which includes the label value and additional parameters such as: BoS, TC and TTL. MPLS allows stacking multiple labels in sequence. In addition, the MPLS header can be encapsulated on top of different layers, e.g.: ETH, IP (rfc4023), UDP (rfc7510), GRE (rfc4023). Therefore, when using the flow creation verb, the application should organize the spec filters list in the command in an ordered manner, such that reflects the actual protocol stack of the packet, to determine the exact position of the MPLS headers in the protocol stack. c) mlx5: Report MPLS tunnel offload capabilities through mlx5 direct verbs This patch exposes the mlx5 device's capability to offload MPLS based tunnel protocols via DV API. The possible protocols are: - Control word + MPLS over GRE. - Control word + MPLS over UDP. Differential revision: https://reviews.freebsd.org/D32205 MFC after: 1 month --- contrib/ofed/libibverbs/cmd.c | 14 +++++++++ contrib/ofed/libibverbs/kern-abi.h | 2 ++ contrib/ofed/libibverbs/man/ibv_create_flow.3 | 20 ++++++++++++- contrib/ofed/libibverbs/verbs.h | 42 +++++++++++++++++++++++++++ contrib/ofed/libmlx5/mlx5dv.h | 2 ++ 5 files changed, 79 insertions(+), 1 deletion(-) diff --git a/contrib/ofed/libibverbs/cmd.c b/contrib/ofed/libibverbs/cmd.c index 82ceb5fb9fe8..9c79757f0e60 100644 --- a/contrib/ofed/libibverbs/cmd.c +++ b/contrib/ofed/libibverbs/cmd.c @@ -1914,6 +1914,20 @@ static int ib_spec_to_kern_spec(struct ibv_flow_spec *ib_spec, memcpy(&kern_spec->tcp_udp.mask, &ib_spec->tcp_udp.mask, sizeof(struct ibv_flow_tcp_udp_filter)); break; + case IBV_FLOW_SPEC_GRE: + kern_spec->gre.size = sizeof(struct ib_uverbs_flow_spec_gre); + memcpy(&kern_spec->gre.val, &ib_spec->gre.val, + sizeof(struct ibv_flow_gre_filter)); + memcpy(&kern_spec->gre.mask, &ib_spec->gre.mask, + sizeof(struct ibv_flow_gre_filter)); + break; + case IBV_FLOW_SPEC_MPLS: + kern_spec->mpls.size = sizeof(struct ib_uverbs_flow_spec_mpls); + memcpy(&kern_spec->mpls.val, &ib_spec->mpls.val, + sizeof(struct ibv_flow_mpls_filter)); + memcpy(&kern_spec->mpls.mask, &ib_spec->mpls.mask, + sizeof(struct ibv_flow_mpls_filter)); + break; case IBV_FLOW_SPEC_VXLAN_TUNNEL: ret = get_filters_size(ib_spec, kern_spec, &ib_filter_size, &kern_filter_size, diff --git a/contrib/ofed/libibverbs/kern-abi.h b/contrib/ofed/libibverbs/kern-abi.h index d5ed405d08c7..fb3d545cecc4 100644 --- a/contrib/ofed/libibverbs/kern-abi.h +++ b/contrib/ofed/libibverbs/kern-abi.h @@ -1027,7 +1027,9 @@ struct ibv_kern_spec { struct ibv_kern_spec_ipv4_ext ipv4_ext; struct ibv_kern_spec_tcp_udp tcp_udp; struct ibv_kern_spec_ipv6 ipv6; + struct ib_uverbs_flow_spec_gre gre; struct ibv_kern_spec_tunnel tunnel; + struct ib_uverbs_flow_spec_mpls mpls; struct ibv_kern_spec_action_tag flow_tag; struct ibv_kern_spec_action_drop drop; }; diff --git a/contrib/ofed/libibverbs/man/ibv_create_flow.3 b/contrib/ofed/libibverbs/man/ibv_create_flow.3 index 48bbb14c9914..7c02695a93e3 100644 --- a/contrib/ofed/libibverbs/man/ibv_create_flow.3 +++ b/contrib/ofed/libibverbs/man/ibv_create_flow.3 @@ -67,6 +67,8 @@ IBV_FLOW_SPEC_IPV4_EXT = 0x32, /* Extended flow specification IBV_FLOW_SPEC_TCP = 0x40, /* Flow specification of TCP header */ IBV_FLOW_SPEC_UDP = 0x41, /* Flow specification of UDP header */ IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, /* Flow specification of VXLAN header */ +IBV_FLOW_SPEC_GRE = 0x51, /* Flow specification of GRE header */ +IBV_FLOW_SPEC_MPLS = 0x60, /* Flow specification of MPLS header */ IBV_FLOW_SPEC_INNER = 0x100, /* Flag making L2/L3/L4 specifications to be applied on the inner header */ IBV_FLOW_SPEC_ACTION_TAG = 0x1000, /* Action tagging matched packet */ IBV_FLOW_SPEC_ACTION_DROP = 0x1001, /* Action dropping matched packet */ @@ -103,7 +105,23 @@ In addition to the domain, there is priority within each of the domains. A lower priority numeric value (higher priority) takes precedence over matching rules with higher numeric priority value (lower priority). It is important to note that the priority value of a flow spec is used not only to establish the precedence of conflicting flow matches but also as a way to abstract the order on which flow specs are tested for matches. Flows with higher priorities will be tested before flows with lower priorities. -.PP + +.SS Rules definition ordering +An application can provide the ibv_flow_spec_xxx rules in an un-ordered scheme. In this case, each spec should be well +defined and match a specific network header layer. +In some cases, when certain flow spec types are present in the spec list, it is required to provide the list in an +ordered manner so that the position of that flow spec type in the protocol stack is strictly defined. +This is essential to represent many of the encapsulation tunnel protocols. +.br + +The flow spec types which require this sort of ordering are: +.br +.B 1. IBV_FLOW_SPEC_MPLS - +.br +Since MPLS header can appear at several locations in the protocol stack and can also be +encapsulated on top of different layers, it is required to place this spec according to its exact location in the +protocol stack. +.br .SS ibv_destroy_flow() destroys the flow .I flow_id\fR. diff --git a/contrib/ofed/libibverbs/verbs.h b/contrib/ofed/libibverbs/verbs.h index 54a8a2d39342..81c6a3b57bb6 100644 --- a/contrib/ofed/libibverbs/verbs.h +++ b/contrib/ofed/libibverbs/verbs.h @@ -1280,6 +1280,8 @@ enum ibv_flow_spec_type { IBV_FLOW_SPEC_TCP = 0x40, IBV_FLOW_SPEC_UDP = 0x41, IBV_FLOW_SPEC_VXLAN_TUNNEL = 0x50, + IBV_FLOW_SPEC_GRE = 0x51, + IBV_FLOW_SPEC_MPLS = 0x60, IBV_FLOW_SPEC_INNER = 0x100, IBV_FLOW_SPEC_ACTION_TAG = 0x1000, IBV_FLOW_SPEC_ACTION_DROP = 0x1001, @@ -1358,6 +1360,44 @@ struct ibv_flow_spec_tcp_udp { struct ibv_flow_tcp_udp_filter mask; }; +struct ibv_flow_gre_filter { + /* c_ks_res0_ver field is bits 0-15 in offset 0 of a standard GRE header: + * bit 0 - checksum present bit. + * bit 1 - reserved. set to 0. + * bit 2 - key present bit. + * bit 3 - sequence number present bit. + * bits 4:12 - reserved. set to 0. + * bits 13:15 - GRE version. + */ + uint16_t c_ks_res0_ver; + uint16_t protocol; + uint32_t key; +}; + +struct ibv_flow_spec_gre { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_gre_filter val; + struct ibv_flow_gre_filter mask; +}; + +struct ibv_flow_mpls_filter { + /* The field includes the entire MPLS label: + * bits 0:19 - label value field. + * bits 20:22 - traffic class field. + * bits 23 - bottom of stack bit. + * bits 24:31 - ttl field. + */ + uint32_t label; +}; + +struct ibv_flow_spec_mpls { + enum ibv_flow_spec_type type; + uint16_t size; + struct ibv_flow_mpls_filter val; + struct ibv_flow_mpls_filter mask; +}; + struct ibv_flow_tunnel_filter { uint32_t tunnel_id; }; @@ -1392,6 +1432,8 @@ struct ibv_flow_spec { struct ibv_flow_spec_ipv4_ext ipv4_ext; struct ibv_flow_spec_ipv6 ipv6; struct ibv_flow_spec_tunnel tunnel; + struct ibv_flow_spec_gre gre; + struct ibv_flow_spec_mpls mpls; struct ibv_flow_spec_action_tag flow_tag; struct ibv_flow_spec_action_drop drop; }; diff --git a/contrib/ofed/libmlx5/mlx5dv.h b/contrib/ofed/libmlx5/mlx5dv.h index fb6180b50104..f31d4964998d 100644 --- a/contrib/ofed/libmlx5/mlx5dv.h +++ b/contrib/ofed/libmlx5/mlx5dv.h @@ -86,6 +86,8 @@ enum mlx5dv_tunnel_offloads { MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_VXLAN = 1 << 0, MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GRE = 1 << 1, MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GENEVE = 1 << 2, + MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE = 1 << 3, + MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_UDP = 1 << 4, };