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 13/20] net/ntnic: add support pattern matching on inner VLAN header
Date: Wed, 1 Oct 2025 17:09:55 +0200 [thread overview]
Message-ID: <20251001151018.250671-14-sil-plv@napatech.com> (raw)
In-Reply-To: <20251001151018.250671-1-sil-plv@napatech.com>
Implements support for match on single or multiple nested inner VLAN
headers.
Updates flow dump output to print both outer and inner VLAN 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 | 3 +-
.../profile_inline/flow_api_profile_inline.c | 31 +++++++++++++------
4 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ntnic/include/flow_api_engine.h b/drivers/net/ntnic/include/flow_api_engine.h
index 362e1666bd..c166243d4b 100644
--- a/drivers/net/ntnic/include/flow_api_engine.h
+++ b/drivers/net/ntnic/include/flow_api_engine.h
@@ -207,6 +207,7 @@ struct nic_flow_def {
int tunnel_l3_prot;
int tunnel_l4_prot;
int vlans;
+ int tunnel_vlans;
int fragmentation;
int ip_prot;
int tunnel_ip_prot;
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 5caf5b2768..17a0332a06 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
@@ -393,8 +393,9 @@ void nthw_db_inline_dump(struct flow_nic_dev *ndev, void *db_handle, const struc
case HW_DB_IDX_TYPE_CAT: {
const struct hw_db_inline_cat_data *data = &db->cat[idxs[i].ids].data;
fprintf(file, " CAT %" PRIu32 "\n", idxs[i].ids);
- fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x\n",
- (int)data->mac_port_mask, (int)data->vlan_mask);
+ fprintf(file, " Port msk 0x%02x, VLAN msk 0x%02x, VLAN tun msk 0x%02x\n",
+ (int)data->mac_port_mask, (int)data->vlan_mask,
+ (int)data->vlan_mask_tunnel);
fprintf(file,
" 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,
@@ -961,7 +962,8 @@ static int hw_db_inline_filter_apply(struct flow_nic_dev *ndev,
cat->ptc_mask_tunnel);
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_VLAN, cat_hw_id, 0,
+ cat->vlan_mask_tunnel);
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,
cat->ptc_mask_l3_tunnel);
@@ -2296,6 +2298,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->vlan_mask_tunnel == data2->vlan_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 &&
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 ec36678c12..3a4e39b713 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
@@ -212,12 +212,13 @@ struct hw_db_inline_cat_data {
uint32_t ptc_mask_l4 : 5;
uint32_t padding0 : 1;
+ uint32_t vlan_mask_tunnel : 4;
uint32_t ptc_mask_tunnel : 11;
uint32_t ptc_mask_l3_tunnel : 3;
uint32_t ptc_mask_l4_tunnel : 5;
uint32_t err_mask_ttl_tunnel : 2;
uint32_t err_mask_ttl : 2;
- uint32_t padding1 : 9;
+ uint32_t padding1 : 5;
uint8_t ptc_mask_l2_tunnel;
uint8_t ip_prot;
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 f8a4ab715c..19c552bcd4 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
@@ -907,6 +907,7 @@ static inline struct nic_flow_def *prepare_nic_flow_def(struct nic_flow_def *fd)
fd->l3_prot = -1;
fd->l4_prot = -1;
fd->vlans = 0;
+ fd->tunnel_vlans = 0;
fd->tunnel_prot = -1;
fd->tunnel_l2_prot = -1;
fd->tunnel_l3_prot = -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 &&
+ return fd && fd->vlans == 0 && fd->tunnel_vlans == 0 && fd->l2_prot < 0 &&
+ fd->l3_prot < 0 && fd->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;
@@ -1920,7 +1922,10 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
(const struct rte_vlan_hdr *)elem[eidx].mask;
if (vlan_spec == NULL || vlan_mask == NULL) {
- fd->vlans += 1;
+ if (any_count > 0)
+ fd->tunnel_vlans += 1;
+ else
+ fd->vlans += 1;
break;
}
@@ -1947,9 +1952,13 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
sw_data[0] &= sw_mask[0];
nthw_km_add_match_elem(&fd->km, &sw_data[0], &sw_mask[0], 1,
- DYN_FIRST_VLAN, 2 + 4 * fd->vlans);
- set_key_def_sw(key_def, sw_counter, DYN_FIRST_VLAN,
- 2 + 4 * fd->vlans);
+ any_count > 0 ? DYN_TUN_VLAN : DYN_FIRST_VLAN,
+ 2 + 4 * (any_count > 0 ? fd->tunnel_vlans :
+ fd->vlans));
+ set_key_def_sw(key_def, sw_counter,
+ any_count > 0 ? DYN_TUN_VLAN : DYN_FIRST_VLAN,
+ 2 + 4 * (any_count > 0 ? fd->tunnel_vlans :
+ fd->vlans));
sw_counter += 1;
} else if (qw_counter < 2 && qw_free > 0) {
@@ -1973,10 +1982,13 @@ static int interpret_flow_elements(const struct flow_eth_dev *dev,
qw_data[2] &= qw_mask[2];
qw_data[3] &= qw_mask[3];
- nthw_km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0], 4,
- DYN_FIRST_VLAN, 2 + 4 * fd->vlans);
- set_key_def_qw(key_def, qw_counter, DYN_FIRST_VLAN,
- 2 + 4 * fd->vlans);
+ nthw_km_add_match_elem(&fd->km, &qw_data[0], &qw_mask[0],
+ 4, any_count > 0 ? DYN_TUN_VLAN : DYN_FIRST_VLAN,
+ 2 + 4 * (any_count > 0 ? fd->tunnel_vlans :
+ fd->vlans));
+ set_key_def_qw(key_def, qw_counter,
+ any_count > 0 ? DYN_TUN_VLAN : DYN_FIRST_VLAN,
+ 2 + 4 * (any_count > 0 ? fd->tunnel_vlans : fd->vlans));
qw_counter += 1;
qw_free -= 1;
@@ -3699,6 +3711,7 @@ static struct flow_handle *create_flow_filter(struct flow_eth_dev *dev, struct n
.ptc_mask_l4 = fd->l4_prot != -1 ? (1 << fd->l4_prot) : -1,
.err_mask_ttl = (fd->ttl_sub_enable &&
fd->ttl_sub_outer) ? -1 : 0x1,
+ .vlan_mask_tunnel = (0xf << fd->tunnel_vlans) & 0xf,
.ptc_mask_tunnel = fd->tunnel_prot !=
-1 ? (1 << (fd->tunnel_prot > 10 ? 10 : fd->tunnel_prot)) : -1,
.ptc_mask_l2_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 ` [PATCH v1 12/20] net/ntnic: add support pattern matching on inner ETH headers Serhii Iliushyk
2025-10-01 15:09 ` Serhii Iliushyk [this message]
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-14-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).