From: Serhii Iliushyk <sil-plv@napatech.com>
To: dev@dpdk.org
Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com,
stephen@networkplumber.org
Subject: [PATCH v1 12/20] net/ntnic: add support pattern matching on inner ETH headers
Date: Wed, 1 Oct 2025 17:09:54 +0200 [thread overview]
Message-ID: <20251001151018.250671-13-sil-plv@napatech.com> (raw)
In-Reply-To: <20251001151018.250671-1-sil-plv@napatech.com>
Implements support for match on inner ETH header.
Updates flow dump output to print both outer and
inner l2 masks.
Signed-off-by: Serhii Iliushyk <sil-plv@napatech.com>
---
drivers/net/ntnic/include/flow_api_engine.h | 1 +
.../profile_inline/flow_api_hw_db_inline.c | 9 ++++--
.../profile_inline/flow_api_hw_db_inline.h | 1 +
.../profile_inline/flow_api_profile_inline.c | 30 +++++++++++--------
4 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h
index 6a27ba8e12..362e1666bd 100644
--- a/drivers/net/ntnic/include/flow_api_engine.h
+++ b/drivers/net/ntnic/include/flow_api_engine.h
@@ -203,6 +203,7 @@ struct nic_flow_def {
int l3_prot;
int l4_prot;
int tunnel_prot;
+ int tunnel_l2_prot;
int tunnel_l3_prot;
int tunnel_l4_prot;
int vlans;
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
index 5de4f6bae7..5caf5b2768 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.c
@@ -396,10 +396,11 @@ void nthw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struc
fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x\n",
(int)data->mac_port_mask, (int)data->vlan_mask);
fprintf(file,
- " Proto msks: Frag 0x%02x, l2 0x%02x, l3 0x%02x, l4 0x%02x, l3t 0x%02x, l4t 0x%02x\n",
+ " Proto msks: Frag 0x%02x, l2 0x%02x, l3 0x%02x, l4 0x%02x, l2t 0x%02x, l3t 0x%02x, l4t 0x%02x\n",
(int)data->ptc_mask_frag, (int)data->ptc_mask_l2,
(int)data->ptc_mask_l3, (int)data->ptc_mask_l4,
- (int)data->ptc_mask_l3_tunnel, (int)data->ptc_mask_l4_tunnel);
+ (int)data->ptc_mask_l2_tunnel, (int)data->ptc_mask_l3_tunnel,
+ (int)data->ptc_mask_l4_tunnel);
fprintf(file, " IP protocol: pn %u pnt %u\n", data->ip_prot,
data->ip_prot_tunnel);
break;
@@ -958,7 +959,8 @@ static int hw_db_inline_filter_apply(struct flow_nic_dev *ndev,
nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_L4, cat_hw_id, 0, cat->ptc_mask_l4);
nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TUNNEL, cat_hw_id, 0,
cat->ptc_mask_tunnel);
- nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L2, cat_hw_id, 0, -1);
+ nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L2, cat_hw_id, 0,
+ cat->ptc_mask_l2_tunnel);
nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_VLAN, cat_hw_id, 0, -1);
nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_MPLS, cat_hw_id, 0, -1);
nthw_mod_cat_cfn_set(&ndev->be, HW_CAT_CFN_PTC_TNL_L3, cat_hw_id, 0,
@@ -2294,6 +2296,7 @@ static int hw_db_inline_cat_compare(const struct hw_db_inline_cat_data *data1,
data1->ptc_mask_l3 == data2->ptc_mask_l3 &&
data1->ptc_mask_l4 == data2->ptc_mask_l4 &&
data1->ptc_mask_tunnel == data2->ptc_mask_tunnel &&
+ data1->ptc_mask_l2_tunnel == data2->ptc_mask_l2_tunnel &&
data1->ptc_mask_l3_tunnel == data2->ptc_mask_l3_tunnel &&
data1->ptc_mask_l4_tunnel == data2->ptc_mask_l4_tunnel &&
data1->err_mask_ttl_tunnel == data2->err_mask_ttl_tunnel &&
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h
index b2bd2f6d2d..ec36678c12 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_hw_db_inline.h
@@ -219,6 +219,7 @@ struct hw_db_inline_cat_data {
uint32_t err_mask_ttl : 2;
uint32_t padding1 : 9;
+ uint8_t ptc_mask_l2_tunnel;
uint8_t ip_prot;
uint8_t ip_prot_tunnel;
};
diff --git a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
index d9c10a8eab..f8a4ab715c 100644
--- a/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
+++ b/drivers/net/ntnic/nthw/flow_api/profile_inline/flow_api_profile_inline.c
@@ -908,6 +908,7 @@ static inline struct nic_flow_def *prepare_nic_flow_def(struct nic_flow_def *fd)
fd->l4_prot = -1;
fd->vlans = 0;
fd->tunnel_prot = -1;
+ fd->tunnel_l2_prot = -1;
fd->tunnel_l3_prot = -1;
fd->tunnel_l4_prot = -1;
fd->fragmentation = -1;
@@ -928,7 +929,8 @@ static inline struct nic_flow_def *allocate_nic_flow_def(void)
static bool fd_has_empty_pattern(const struct nic_flow_def *fd)
{
return fd && fd->vlans == 0 && fd->l2_prot < 0 && fd->l3_prot < 0 && fd->l4_prot < 0 &&
- fd->tunnel_prot < 0 && fd->tunnel_l3_prot < 0 && fd->tunnel_l4_prot < 0 &&
+ fd->tunnel_prot < 0 && fd->tunnel_l2_prot < 0 &&
+ fd->tunnel_l3_prot < 0 && fd->tunnel_l4_prot < 0 &&
fd->ip_prot < 0 && fd->tunnel_ip_prot < 0 && fd->non_empty < 0;
}
@@ -1798,15 +1800,11 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
const struct rte_ether_hdr *eth_mask =
(const struct rte_ether_hdr *)elem[eidx].mask;
- if (any_count > 0) {
- NT_LOG(ERR, FILTER,
- "Tunneled L2 ethernet not supported");
- nthw_flow_nic_set_error(ERR_FAILED, error);
- return -1;
- }
-
if (eth_spec == NULL || eth_mask == NULL) {
- fd->l2_prot = PROT_L2_ETH2;
+ if (any_count > 0 || fd->l2_prot != -1)
+ fd->tunnel_l2_prot = PROT_L2_ETH2;
+ else
+ fd->l2_prot = PROT_L2_ETH2;
break;
}
@@ -1876,8 +1874,10 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
nthw_km_add_match_elem(&fd->km,
&qw_data[(size_t)(qw_counter * 4)],
- &qw_mask[(size_t)(qw_counter * 4)], 4, DYN_L2, 0);
- set_key_def_qw(key_def, qw_counter, DYN_L2, 0);
+ &qw_mask[(size_t)(qw_counter * 4)], 4,
+ any_count > 0 ? DYN_TUN_L2 : DYN_L2, 0);
+ set_key_def_qw(key_def, qw_counter,
+ any_count > 0 ? DYN_TUN_L2 : DYN_L2, 0);
qw_counter += 1;
if (!non_zero)
@@ -1898,8 +1898,10 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
sw_data[0] = ntohs(eth_spec->ether_type) << 16 & sw_mask[0];
nthw_km_add_match_elem(&fd->km, &sw_data[0],
- &sw_mask[0], 1, DYN_L2, 12);
- set_key_def_sw(key_def, sw_counter, DYN_L2, 12);
+ &sw_mask[0], 1,
+ any_count > 0 ? DYN_TUN_L2 : DYN_L2, 12);
+ set_key_def_sw(key_def, sw_counter,
+ any_count > 0 ? DYN_TUN_L2 : DYN_L2, 12);
sw_counter += 1;
}
@@ -3699,6 +3701,8 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
fd->ttl_sub_outer) ? -1 : 0x1,
.ptc_mask_tunnel = fd->tunnel_prot !=
-1 ? (1 << (fd->tunnel_prot > 10 ? 10 : fd->tunnel_prot)) : -1,
+ .ptc_mask_l2_tunnel =
+ fd->tunnel_l2_prot != -1 ? (1 << fd->tunnel_l2_prot) : -1,
.ptc_mask_l3_tunnel =
fd->tunnel_l3_prot != -1 ? (1 << fd->tunnel_l3_prot) : -1,
.ptc_mask_l4_tunnel =
--
2.45.0
next prev parent reply other threads:[~2025-10-01 15:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-01 15:09 [PATCH v1 00/20] Add NT400D11 support and new features Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 01/20] net/ntnic: add stubs for init NT400D11 Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 02/20] net/ntnic: add reset setup for NT400D11 Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 03/20] net/ntnic: add reset init stage 0 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 04/20] net/ntnic: add reset init stage 1 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 05/20] net/ntnic: add reset init stage 2 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 06/20] net/ntnic: add reset init stage 3 and 4 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 07/20] net/ntnic: add reset init stage 5 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 08/20] net/ntnic: add reset init stage 6 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 09/20] net/ntnic: add reset init stage 7 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 10/20] net/ntnic: add reset init stage 8 " Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 11/20] net/ntnic: add fpga registers " Serhii Iliushyk
2025-10-01 15:09 ` Serhii Iliushyk [this message]
2025-10-01 15:09 ` [PATCH v1 13/20] net/ntnic: add support pattern matching on inner VLAN header Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 14/20] net/ntnic: add handling exception path option Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 15/20] net/ntnic: add flow query with count action Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 16/20] net/ntnic: add flow pull Serhii Iliushyk
2025-10-01 15:09 ` [PATCH v1 17/20] net/ntnic: extend flow dump with MBR configuration Serhii Iliushyk
2025-10-01 15:10 ` [PATCH v1 18/20] net/ntnic: make flow lock local Serhii Iliushyk
2025-10-01 15:10 ` [PATCH v1 19/20] net/ntnic: rename hwlock Serhii Iliushyk
2025-10-01 15:10 ` [PATCH v1 20/20] net/ntnic: rename nt log types Serhii Iliushyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251001151018.250671-13-sil-plv@napatech.com \
--to=sil-plv@napatech.com \
--cc=ckm@napatech.com \
--cc=dev@dpdk.org \
--cc=mko-plv@napatech.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).