[1/4] net/nfp: support MARK flow action

Message ID 20240210104214.1248772-2-chaoyong.he@corigine.com (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers
Series add support of partial offload |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Chaoyong He Feb. 10, 2024, 10:42 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Add the corresponding logics to support the offload of MARK action.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 16 ++++++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.c | 27 ++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
  

Patch

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 8fb55f44a2..c94ea706bb 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -959,6 +959,22 @@  struct nfp_fl_act_meter {
 	rte_be32_t profile_id;
 };
 
+/*
+ * Mark
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | res |  opcode |  res  | len_lw|            reserved           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |                         Mark                                  |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct nfp_fl_act_mark {
+	struct nfp_fl_act_head head;
+	rte_be16_t reserved;
+	rte_be32_t mark;
+};
+
 int nfp_flower_cmsg_mac_repr(struct nfp_app_fw_flower *app_fw_flower);
 int nfp_flower_cmsg_repr_reify(struct nfp_app_fw_flower *app_fw_flower,
 		struct nfp_flower_representor *repr);
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index e26be30d18..8667f8e901 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -83,6 +83,7 @@ 
 #define NFP_FL_ACTION_OPCODE_METER              24
 #define NFP_FL_ACTION_OPCODE_CT_NAT_EXT         25
 #define NFP_FL_ACTION_OPCODE_PUSH_GENEVE        26
+#define NFP_FL_ACTION_OPCODE_SET_MARK           27
 #define NFP_FL_ACTION_OPCODE_NUM                32
 
 #define NFP_FL_OUT_FLAGS_LAST            RTE_BIT32(15)
@@ -1138,6 +1139,10 @@  nfp_flow_key_layers_calculate_actions(const struct rte_flow_action actions[],
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_CONNTRACK detected");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			key_ls->act_size += sizeof(struct nfp_fl_act_mark);
+			PMD_DRV_LOG(DEBUG, "RTE_FLOW_ACTION_TYPE_MARK detected");
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Action type %d not supported.", action->type);
 			return -ENOTSUP;
@@ -3487,6 +3492,23 @@  nfp_flow_action_meter(struct nfp_flower_representor *representor,
 	return 0;
 }
 
+static void
+nfp_flow_action_mark(char *act_data,
+		const struct rte_flow_action *action)
+{
+	struct nfp_fl_act_mark *fl_mark;
+	const struct rte_flow_action_mark *mark;
+	size_t act_size = sizeof(struct nfp_fl_act_mark);
+
+	mark = action->conf;
+
+	fl_mark = (struct nfp_fl_act_mark *)act_data;
+	fl_mark->head.jump_id = NFP_FL_ACTION_OPCODE_SET_MARK;
+	fl_mark->head.len_lw  = act_size >> NFP_FL_LW_SIZ;
+	fl_mark->reserved     = 0;
+	fl_mark->mark         = rte_cpu_to_be_32(mark->id);
+}
+
 static uint32_t
 nfp_flow_count_output(const struct rte_flow_action actions[])
 {
@@ -3734,6 +3756,11 @@  nfp_flow_compile_action(struct nfp_flower_representor *representor,
 		case RTE_FLOW_ACTION_TYPE_CONNTRACK:
 			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_CONNTRACK");
 			break;
+		case RTE_FLOW_ACTION_TYPE_MARK:
+			PMD_DRV_LOG(DEBUG, "Process RTE_FLOW_ACTION_TYPE_MARK");
+			nfp_flow_action_mark(position, action);
+			position += sizeof(struct nfp_fl_act_mark);
+			break;
 		default:
 			PMD_DRV_LOG(ERR, "Unsupported action type: %d", action->type);
 			return -ENOTSUP;