[v4,6/6] net/mlx5: add error message

Message ID 20230223124858.1042097-7-rongweil@nvidia.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series add flex item implementation |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Rongwei Liu Feb. 23, 2023, 12:48 p.m. UTC
  When pattern/action template creation fails the testpmd expects error
details.
The driver did not set the error structure and testpmd failed with a
segmentation fault.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 907aab8bf3..b43661674f 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -4570,8 +4570,12 @@  flow_hw_actions_template_create(struct rte_eth_dev *dev,
 						       &at->flex_item)) ||
 			     (info->src.field == RTE_FLOW_FIELD_FLEX_ITEM &&
 			      flow_hw_flex_item_acquire(dev, info->src.flex_handle,
-							&at->flex_item)))
+							&at->flex_item))) {
+				rte_flow_error_set(error, rte_errno,
+						   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+						   "Failed to acquire flex item");
 				goto error;
+			}
 		}
 	}
 	at->tmpl = flow_hw_dr_actions_template_create(at);
@@ -4587,6 +4591,9 @@  flow_hw_actions_template_create(struct rte_eth_dev *dev,
 			mlx5dr_action_template_destroy(at->tmpl);
 		mlx5_free(at);
 	}
+	rte_flow_error_set(error, rte_errno,
+			   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+			   "Failed to create action template");
 	return NULL;
 }
 
@@ -4936,6 +4943,9 @@  flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 		    (mlx5_alloc_srh_flex_parser(dev))) {
 			claim_zero(mlx5dr_match_template_destroy(it->mt));
 			mlx5_free(it);
+			rte_flow_error_set(error, rte_errno,
+					   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+					   "cannot create IPv6 routing extension support");
 			return NULL;
 		}
 	}
@@ -4948,6 +4958,9 @@  flow_hw_pattern_template_create(struct rte_eth_dev *dev,
 			if (flow_hw_flex_item_acquire(dev, handle, &it->flex_item)) {
 				claim_zero(mlx5dr_match_template_destroy(it->mt));
 				mlx5_free(it);
+				rte_flow_error_set(error, rte_errno,
+						   RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
+						   "Failed to acquire flex item");
 				return NULL;
 			}
 		}