[7/8] net/mlx5: add NAT64 action support in rule creation

Message ID 20231227090731.2569427-8-bingz@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series support NAT64 action |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bing Zhao Dec. 27, 2023, 9:07 a.m. UTC
  The action will handle the IPv4 and IPv6 headers translation. It will
add / remove IPv6 address prefix by default.

To use the user specific address, another rule to modify the
addresses of the IP header is needed.

Signed-off-by: Bing Zhao <bingz@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 9b9ad8de2d..9b60233549 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -2479,6 +2479,19 @@  __flow_hw_actions_translate(struct rte_eth_dev *dev,
 			}
 			acts->rule_acts[dr_pos].action = priv->hw_def_miss;
 			break;
+		case RTE_FLOW_ACTION_TYPE_NAT64:
+			if (masks->conf &&
+			    ((const struct rte_flow_action_nat64 *)masks->conf)->type) {
+				const struct rte_flow_action_nat64 *nat64_c =
+					(const struct rte_flow_action_nat64 *)actions->conf;
+
+				acts->rule_acts[dr_pos].action =
+					priv->action_nat64[type][nat64_c->type];
+			} else if (__flow_hw_act_data_general_append(priv, acts,
+								     actions->type,
+								     src_pos, dr_pos))
+				goto err;
+			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
 			break;
@@ -2912,6 +2925,7 @@  flow_hw_actions_construct(struct rte_eth_dev *dev,
 	const struct rte_flow_action_ethdev *port_action = NULL;
 	const struct rte_flow_action_meter *meter = NULL;
 	const struct rte_flow_action_age *age = NULL;
+	const struct rte_flow_action_nat64 *nat64_c = NULL;
 	uint8_t *buf = job->encap_data;
 	uint8_t *push_buf = job->push_data;
 	struct rte_flow_attr attr = {
@@ -3179,6 +3193,13 @@  flow_hw_actions_construct(struct rte_eth_dev *dev,
 			if (ret != 0)
 				return ret;
 			break;
+		case RTE_FLOW_ACTION_TYPE_NAT64:
+			nat64_c = action->conf;
+			if (!priv->action_nat64[table->type][nat64_c->type])
+				return -1;
+			rule_acts[act_data->action_dst].action =
+				priv->action_nat64[table->type][nat64_c->type];
+			break;
 		default:
 			break;
 		}
@@ -5872,6 +5893,7 @@  static enum mlx5dr_action_type mlx5_hw_dr_action_types[] = {
 	[RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL] = MLX5DR_ACTION_TYP_DEST_ROOT,
 	[RTE_FLOW_ACTION_TYPE_IPV6_EXT_PUSH] = MLX5DR_ACTION_TYP_PUSH_IPV6_ROUTE_EXT,
 	[RTE_FLOW_ACTION_TYPE_IPV6_EXT_REMOVE] = MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT,
+	[RTE_FLOW_ACTION_TYPE_NAT64] = MLX5DR_ACTION_TYP_NAT64,
 };
 
 static inline void