[v4,23/34] common/sfc_efx/base: match on conntrack mark in action rules

Message ID 20230607130245.8048-24-ivan.malov@arknetworks.am (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: support HW conntrack assistance |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Ivan Malov June 7, 2023, 1:02 p.m. UTC
  EF100 match-action engine (MAE) has conntrack assistance
table. A hit in this table can provide a mark value for
the following lookup stage, which is action rule lookup.

Provide support for setting match on conntrack mark.

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/efx.h     |  7 +++++++
 drivers/common/sfc_efx/base/efx_mae.c | 28 +++++++++++++++++++++++++++
 drivers/common/sfc_efx/version.map    |  1 +
 3 files changed, 36 insertions(+)
  

Comments

Thomas Monjalon June 26, 2023, 1:07 p.m. UTC | #1
07/06/2023 15:02, Ivan Malov:
> EF100 match-action engine (MAE) has conntrack assistance
> table. A hit in this table can provide a mark value for
> the following lookup stage, which is action rule lookup.
> 
> Provide support for setting match on conntrack mark.

What happened Ivan? This commit message is not right aligned!
We could accept you drop a space before parentheses if it helps :)
  

Patch

diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index bc5117653f..f8c5d7a3bc 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -4276,6 +4276,7 @@  typedef enum efx_mae_field_id_e {
 	 * or by using dedicated field-specific helper APIs.
 	 */
 	EFX_MAE_FIELD_RECIRC_ID,
+	EFX_MAE_FIELD_CT_MARK,
 	EFX_MAE_FIELD_NIDS
 } efx_mae_field_id_t;
 
@@ -4462,6 +4463,12 @@  efx_mae_match_spec_recirc_id_set(
 	__in				efx_mae_match_spec_t *spec,
 	__in				uint8_t recirc_id);
 
+LIBEFX_API
+extern	__checkReturn			efx_rc_t
+efx_mae_match_spec_ct_mark_set(
+	__in				efx_mae_match_spec_t *spec,
+	__in				uint32_t ct_mark);
+
 LIBEFX_API
 extern	__checkReturn			efx_rc_t
 efx_mae_match_spec_clone(
diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c
index 011f38d298..b00ed2ec7a 100644
--- a/drivers/common/sfc_efx/base/efx_mae.c
+++ b/drivers/common/sfc_efx/base/efx_mae.c
@@ -474,6 +474,7 @@  typedef enum efx_mae_field_cap_id_e {
 	EFX_MAE_FIELD_ID_ENC_HAS_OVLAN = MAE_FIELD_ENC_HAS_OVLAN,
 	EFX_MAE_FIELD_ID_ENC_HAS_IVLAN = MAE_FIELD_ENC_HAS_IVLAN,
 	EFX_MAE_FIELD_ID_RECIRC_ID = MAE_FIELD_RECIRC_ID,
+	EFX_MAE_FIELD_ID_CT_MARK = MAE_FIELD_CT_MARK,
 
 	EFX_MAE_FIELD_CAP_NIDS
 } efx_mae_field_cap_id_t;
@@ -549,6 +550,7 @@  static const efx_mae_mv_desc_t __efx_mae_action_rule_mv_desc_set[] = {
 	EFX_MAE_MV_DESC(ENC_VNET_ID_BE, EFX_MAE_FIELD_BE),
 	EFX_MAE_MV_DESC(OUTER_RULE_ID, EFX_MAE_FIELD_LE),
 	EFX_MAE_MV_DESC(RECIRC_ID, EFX_MAE_FIELD_LE),
+	EFX_MAE_MV_DESC(CT_MARK, EFX_MAE_FIELD_LE),
 
 #undef EFX_MAE_MV_DESC
 };
@@ -910,6 +912,32 @@  efx_mae_match_spec_recirc_id_set(
 
 	return (0);
 
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+	return (rc);
+}
+
+	__checkReturn			efx_rc_t
+efx_mae_match_spec_ct_mark_set(
+	__in				efx_mae_match_spec_t *spec,
+	__in				uint32_t ct_mark)
+{
+	uint32_t full_mask = UINT32_MAX;
+	const uint8_t *vp;
+	const uint8_t *mp;
+	efx_rc_t rc;
+
+	mp = (const uint8_t *)&full_mask;
+	vp = (const uint8_t *)&ct_mark;
+
+	rc = efx_mae_match_spec_field_set(spec, EFX_MAE_FIELD_CT_MARK,
+					  sizeof (ct_mark), vp,
+					  sizeof (full_mask), mp);
+	if (rc != 0)
+		goto fail1;
+
+	return (0);
+
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 	return (rc);
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index b1ca8e1215..d972896210 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -125,6 +125,7 @@  INTERNAL {
 	efx_mae_mac_addr_free;
 	efx_mae_match_spec_bit_set;
 	efx_mae_match_spec_clone;
+	efx_mae_match_spec_ct_mark_set;
 	efx_mae_match_spec_field_get;
 	efx_mae_match_spec_field_set;
 	efx_mae_match_spec_fini;