From: Prashant Gupta <prashant.gupta_3@nxp.com>
To: dev@dpdk.org, stephen@networkplumber.org, david.marchand@redhat.com
Cc: stable@dpdk.org, Jun Yang <jun.yang@nxp.com>
Subject: [PATCH 06/15] net/dpaa2: fix flow rule's resizing issue
Date: Tue, 14 Oct 2025 12:10:26 +0530 [thread overview]
Message-ID: <20251014064035.1312896-7-prashant.gupta_3@nxp.com> (raw)
In-Reply-To: <20251014064035.1312896-1-prashant.gupta_3@nxp.com>
From: Jun Yang <jun.yang@nxp.com>
Appending new extract need resize the flow's rule.
The rule's size should start from new extract's position plus
it's size unless the position is less than rule's original size.
Fixes: 56c1817d532e ("net/dpaa2: refactor flow engine")
Cc: stable@dpdk.org
Signed-off-by: Jun Yang <jun.yang@nxp.com>
---
drivers/net/dpaa2/dpaa2_flow.c | 123 ++++++++++++++++++++++++++-------
1 file changed, 97 insertions(+), 26 deletions(-)
diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
index 299c50dcdf..2e44bff766 100644
--- a/drivers/net/dpaa2/dpaa2_flow.c
+++ b/drivers/net/dpaa2/dpaa2_flow.c
@@ -630,42 +630,42 @@ dpaa2_flow_rule_insert_hole(struct dpaa2_dev_flow *flow,
int offset, int size,
enum dpaa2_flow_dist_type dist_type)
{
- int end;
-
if (dist_type & DPAA2_FLOW_QOS_TYPE) {
- end = flow->qos_rule_size;
- if (end > offset) {
+ if (offset < flow->qos_rule_size) {
memmove(flow->qos_key_addr + offset + size,
flow->qos_key_addr + offset,
- end - offset);
+ flow->qos_rule_size - offset);
memset(flow->qos_key_addr + offset,
0, size);
memmove(flow->qos_mask_addr + offset + size,
flow->qos_mask_addr + offset,
- end - offset);
+ flow->qos_rule_size - offset);
memset(flow->qos_mask_addr + offset,
0, size);
+ flow->qos_rule_size += size;
+ } else {
+ flow->qos_rule_size = offset + size;
}
- flow->qos_rule_size += size;
}
if (dist_type & DPAA2_FLOW_FS_TYPE) {
- end = flow->fs_rule_size;
- if (end > offset) {
+ if (offset < flow->fs_rule_size) {
memmove(flow->fs_key_addr + offset + size,
flow->fs_key_addr + offset,
- end - offset);
+ flow->fs_rule_size - offset);
memset(flow->fs_key_addr + offset,
0, size);
memmove(flow->fs_mask_addr + offset + size,
flow->fs_mask_addr + offset,
- end - offset);
+ flow->fs_rule_size - offset);
memset(flow->fs_mask_addr + offset,
0, size);
+ flow->fs_rule_size += size;
+ } else {
+ flow->fs_rule_size = offset + size;
}
- flow->fs_rule_size += size;
}
return 0;
@@ -1485,8 +1485,9 @@ dpaa2_flow_faf_add_rule(struct dpaa2_dev_priv *priv,
mask_addr = flow->qos_mask_addr + offset;
if (!(*key_addr) &&
- key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->qos_rule_size++;
+ key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT &&
+ offset >= flow->qos_rule_size)
+ flow->qos_rule_size = offset + sizeof(uint8_t);
*key_addr |= (1 << faf_bit_in_byte);
*mask_addr |= (1 << faf_bit_in_byte);
@@ -1507,8 +1508,9 @@ dpaa2_flow_faf_add_rule(struct dpaa2_dev_priv *priv,
mask_addr = flow->fs_mask_addr + offset;
if (!(*key_addr) &&
- key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->fs_rule_size++;
+ key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT &&
+ offset >= flow->fs_rule_size)
+ flow->fs_rule_size = offset + sizeof(uint8_t);
*key_addr |= (1 << faf_bit_in_byte);
*mask_addr |= (1 << faf_bit_in_byte);
@@ -1526,6 +1528,7 @@ dpaa2_flow_pr_rule_data_set(struct dpaa2_dev_flow *flow,
{
int offset;
uint32_t pr_field = pr_offset << 16 | pr_size;
+ char offset_info[64], size_info[64], rule_size_info[64];
offset = dpaa2_flow_extract_key_offset(key_profile,
DPAA2_PR_KEY, NET_PROT_NONE, pr_field);
@@ -1534,19 +1537,43 @@ dpaa2_flow_pr_rule_data_set(struct dpaa2_dev_flow *flow,
pr_offset, pr_size);
return -EINVAL;
}
+ sprintf(offset_info, "offset(%d)", offset);
+ sprintf(size_info, "size(%d)", pr_size);
if (dist_type & DPAA2_FLOW_QOS_TYPE) {
+ sprintf(rule_size_info, "qos rule size(%d)",
+ flow->qos_rule_size);
memcpy((flow->qos_key_addr + offset), key, pr_size);
memcpy((flow->qos_mask_addr + offset), mask, pr_size);
- if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->qos_rule_size = offset + pr_size;
+ if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT) {
+ if (offset >= flow->qos_rule_size) {
+ flow->qos_rule_size = offset + pr_size;
+ } else if ((offset + pr_size) > flow->qos_rule_size) {
+ DPAA2_PMD_ERR("%s < %s, but %s + %s > %s",
+ offset_info, rule_size_info,
+ offset_info, size_info,
+ rule_size_info);
+ return -EINVAL;
+ }
+ }
}
if (dist_type & DPAA2_FLOW_FS_TYPE) {
+ sprintf(rule_size_info, "fs rule size(%d)",
+ flow->fs_rule_size);
memcpy((flow->fs_key_addr + offset), key, pr_size);
memcpy((flow->fs_mask_addr + offset), mask, pr_size);
- if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->fs_rule_size = offset + pr_size;
+ if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT) {
+ if (offset >= flow->fs_rule_size) {
+ flow->fs_rule_size = offset + pr_size;
+ } else if ((offset + pr_size) > flow->fs_rule_size) {
+ DPAA2_PMD_ERR("%s < %s, but %s + %s > %s",
+ offset_info, rule_size_info,
+ offset_info, size_info,
+ rule_size_info);
+ return -EINVAL;
+ }
+ }
}
return 0;
@@ -1560,6 +1587,7 @@ dpaa2_flow_hdr_rule_data_set(struct dpaa2_dev_flow *flow,
enum dpaa2_flow_dist_type dist_type)
{
int offset;
+ char offset_info[64], size_info[64], rule_size_info[64];
if (dpaa2_flow_ip_address_extract(prot, field)) {
DPAA2_PMD_ERR("%s only for none IP address extract",
@@ -1574,19 +1602,41 @@ dpaa2_flow_hdr_rule_data_set(struct dpaa2_dev_flow *flow,
prot, field);
return -EINVAL;
}
+ sprintf(offset_info, "offset(%d)", offset);
+ sprintf(size_info, "size(%d)", size);
if (dist_type & DPAA2_FLOW_QOS_TYPE) {
+ sprintf(rule_size_info, "qos rule size(%d)",
+ flow->qos_rule_size);
memcpy((flow->qos_key_addr + offset), key, size);
memcpy((flow->qos_mask_addr + offset), mask, size);
- if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->qos_rule_size = offset + size;
+ if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT) {
+ if (offset >= flow->qos_rule_size) {
+ flow->qos_rule_size = offset + size;
+ } else if ((offset + size) > flow->qos_rule_size) {
+ DPAA2_PMD_ERR("%s: %s < %s, but %s + %s > %s",
+ __func__, offset_info, rule_size_info,
+ offset_info, size_info, rule_size_info);
+ return -EINVAL;
+ }
+ }
}
if (dist_type & DPAA2_FLOW_FS_TYPE) {
+ sprintf(rule_size_info, "fs rule size(%d)",
+ flow->fs_rule_size);
memcpy((flow->fs_key_addr + offset), key, size);
memcpy((flow->fs_mask_addr + offset), mask, size);
- if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT)
- flow->fs_rule_size = offset + size;
+ if (key_profile->ip_addr_type == IP_NONE_ADDR_EXTRACT) {
+ if (offset >= flow->fs_rule_size) {
+ flow->fs_rule_size = offset + size;
+ } else if ((offset + size) > flow->fs_rule_size) {
+ DPAA2_PMD_ERR("%s: %s < %s, but %s + %s > %s",
+ __func__, offset_info, rule_size_info,
+ offset_info, size_info, rule_size_info);
+ return -EINVAL;
+ }
+ }
}
return 0;
@@ -1602,6 +1652,7 @@ dpaa2_flow_raw_rule_data_set(struct dpaa2_dev_flow *flow,
int extract_size = size > DPAA2_FLOW_MAX_KEY_SIZE ?
DPAA2_FLOW_MAX_KEY_SIZE : size;
int offset, field;
+ char offset_info[64], size_info[64], rule_size_info[64];
field = extract_offset << DPAA2_FLOW_RAW_OFFSET_FIELD_SHIFT;
field |= extract_size;
@@ -1612,17 +1663,37 @@ dpaa2_flow_raw_rule_data_set(struct dpaa2_dev_flow *flow,
extract_offset, size);
return -EINVAL;
}
+ sprintf(offset_info, "offset(%d)", offset);
+ sprintf(size_info, "size(%d)", size);
if (dist_type & DPAA2_FLOW_QOS_TYPE) {
+ sprintf(rule_size_info, "qos rule size(%d)",
+ flow->qos_rule_size);
memcpy((flow->qos_key_addr + offset), key, size);
memcpy((flow->qos_mask_addr + offset), mask, size);
- flow->qos_rule_size = offset + size;
+ if (offset >= flow->qos_rule_size) {
+ flow->qos_rule_size = offset + size;
+ } else if ((offset + size) > flow->qos_rule_size) {
+ DPAA2_PMD_ERR("%s: %s < %s, but %s + %s > %s",
+ __func__, offset_info, rule_size_info,
+ offset_info, size_info, rule_size_info);
+ return -EINVAL;
+ }
}
if (dist_type & DPAA2_FLOW_FS_TYPE) {
+ sprintf(rule_size_info, "fs rule size(%d)",
+ flow->fs_rule_size);
memcpy((flow->fs_key_addr + offset), key, size);
memcpy((flow->fs_mask_addr + offset), mask, size);
- flow->fs_rule_size = offset + size;
+ if (offset >= flow->fs_rule_size) {
+ flow->fs_rule_size = offset + size;
+ } else if ((offset + size) > flow->fs_rule_size) {
+ DPAA2_PMD_ERR("%s: %s < %s, but %s + %s > %s",
+ __func__, offset_info, rule_size_info,
+ offset_info, size_info, rule_size_info);
+ return -EINVAL;
+ }
}
return 0;
--
2.43.0
next prev parent reply other threads:[~2025-10-14 7:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 6:40 [PATCH 00/15] dpaa2: Fixes and enhancements for DPMAC, stats, and parser Prashant Gupta
2025-10-14 6:40 ` [PATCH 01/15] net/dpaa2: fix uninitialized variable issue Prashant Gupta
2025-10-14 6:40 ` [PATCH 02/15] net/dpaa2: fix to free buffers from error queue Prashant Gupta
2025-10-14 6:40 ` [PATCH 03/15] net/dpaa2: fix L3/L4 csum results in packet parse Prashant Gupta
2025-10-14 6:40 ` [PATCH 04/15] net/dpaa2: fix to recv packets with additional parse errors Prashant Gupta
2025-10-14 6:40 ` [PATCH 05/15] net/dpaa2: fix error frame dump issue Prashant Gupta
2025-10-14 6:40 ` Prashant Gupta [this message]
2025-10-14 6:40 ` [PATCH 07/15] net/dpaa2: add dpmac MC header file Prashant Gupta
2025-10-14 6:40 ` [PATCH 08/15] net/dpaa2: support dpmac counters in stats Prashant Gupta
2025-10-14 6:40 ` [PATCH 09/15] net/dpaa2: setup the speed cap based on the actual MAC Prashant Gupta
2025-10-14 6:40 ` [PATCH 10/15] drivers: dpaa2 upgrade fslmc base FW to 10.39.0 Prashant Gupta
2025-10-14 6:40 ` [PATCH 11/15] net/dpaa2: replace global variable to driver flag Prashant Gupta
2025-10-14 6:40 ` [PATCH 12/15] net/dpaa2: add devargs to drop parse packets in HW Prashant Gupta
2025-10-14 6:40 ` [PATCH 13/15] net/dpaa2: optimize to prefetch next parser result Prashant Gupta
2025-10-14 6:40 ` [PATCH 14/15] net/dpaa2: add eCPRI header and message dump Prashant Gupta
2025-10-14 6:40 ` [PATCH 15/15] net/dpaa2: add Policer stats for each TC Prashant Gupta
-- strict thread matches above, loose matches on Subject: below --
2025-10-14 6:00 [PATCH 00/15] dpaa2: Fixes and enhancements for DPMAC, stats, and parser Prashant Gupta
2025-10-14 6:00 ` [PATCH 06/15] net/dpaa2: fix flow rule's resizing issue Prashant Gupta
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=20251014064035.1312896-7-prashant.gupta_3@nxp.com \
--to=prashant.gupta_3@nxp.com \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=jun.yang@nxp.com \
--cc=stable@dpdk.org \
--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).