[1/2] net/hns3: fix error code for repeatedly create counter

Message ID 20241107115645.22617-2-haijie1@huawei.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/hns3: bugfix for hns3 |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Jie Hai Nov. 7, 2024, 11:56 a.m. UTC
From: Dengdui Huang <huangdengdui@huawei.com>

Return EINVAL instead of ENOSPC when the same counter ID is
used for multiple times to create a counter.

Fixes: fcba820d9b9e ("net/hns3: support flow director")
Cc: stable@dpdk.org

Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
Signed-off-by: Jie Hai <haijie1@huawei.com>
---
 drivers/net/hns3/hns3_flow.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Stephen Hemminger Nov. 7, 2024, 4:21 p.m. UTC | #1
On Thu, 7 Nov 2024 19:56:44 +0800
Jie Hai <haijie1@huawei.com> wrote:

> From: Dengdui Huang <huangdengdui@huawei.com>
> 
> Return EINVAL instead of ENOSPC when the same counter ID is
> used for multiple times to create a counter.
> 
> Fixes: fcba820d9b9e ("net/hns3: support flow director")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Dengdui Huang <huangdengdui@huawei.com>
> Signed-off-by: Jie Hai <haijie1@huawei.com>

Not sure that actual error number matters that much, but
looks good to me.
Another alternative might be EEXIST which is the error code
used when creat() is called on an existing file.

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c
index 192ffc015e14..266934b45bce 100644
--- a/drivers/net/hns3/hns3_flow.c
+++ b/drivers/net/hns3/hns3_flow.c
@@ -286,7 +286,7 @@  hns3_counter_new(struct rte_eth_dev *dev, uint32_t indirect, uint32_t id,
 	cnt = hns3_counter_lookup(dev, id);
 	if (cnt) {
 		if (!cnt->indirect || cnt->indirect != indirect)
-			return rte_flow_error_set(error, ENOTSUP,
+			return rte_flow_error_set(error, EINVAL,
 				RTE_FLOW_ERROR_TYPE_ACTION_CONF,
 				cnt,
 				"Counter id is used, indirect flag not match");