[1/3] common/sfc_efx/base: support unprivileged MAE clients

Message ID 20211015064903.3302489-2-andrew.rybchenko@oktetlabs.ru (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: support transfer rule proxy |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing warning apply patch failure

Commit Message

Andrew Rybchenko Oct. 15, 2021, 6:49 a.m. UTC
  From: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>

In order to differentiate between privileged and unprivileged MAE clients,
add a separate boolean flag to represent a NIC's MAE privilege level.

Allow initializing unprivileged MAE clients by avoiding calls to functions
that can only be called by the admin NIC.

Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 12 +++++++++---
 drivers/common/sfc_efx/base/efx.h       |  7 +++++++
 drivers/common/sfc_efx/base/siena_nic.c |  1 +
 3 files changed, 17 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index 3cd9ff89d0..bbc59811ec 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1442,13 +1442,19 @@  ef10_get_datapath_caps(
 	 * MAE support requires the privilege is granted initially,
 	 * and ignore later dynamic changes.
 	 */
-	if (CAP_FLAGS3(req, MAE_SUPPORTED) &&
-	    EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, MAE))
+	if (CAP_FLAGS3(req, MAE_SUPPORTED)) {
 		encp->enc_mae_supported = B_TRUE;
-	else
+		if (EFX_MCDI_HAVE_PRIVILEGE(encp->enc_privilege_mask, MAE))
+			encp->enc_mae_admin = B_TRUE;
+		else
+			encp->enc_mae_admin = B_FALSE;
+	} else {
 		encp->enc_mae_supported = B_FALSE;
+		encp->enc_mae_admin = B_FALSE;
+	}
 #else
 	encp->enc_mae_supported = B_FALSE;
+	encp->enc_mae_admin = B_FALSE;
 #endif /* EFSYS_OPT_MAE */
 
 #undef CAP_FLAGS1
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 8975c6e747..60533881c2 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1618,6 +1618,13 @@  typedef struct efx_nic_cfg_s {
 	boolean_t		enc_hlb_counters;
 	/* NIC support for Match-Action Engine (MAE). */
 	boolean_t		enc_mae_supported;
+	/*
+	 * NIC is privileged, i.e. it is the MAE admin.
+	 * Only privileged MAE clients can manage MAE flow rules,
+	 * for example, modify, count and route traffic to selected
+	 * destination (a MAE client or network port).
+	 */
+	boolean_t		enc_mae_admin;
 	/* Firmware support for "FLAG" and "MARK" filter actions */
 	boolean_t		enc_filter_action_flag_supported;
 	boolean_t		enc_filter_action_mark_supported;
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 29283eac72..8b810d3ae3 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -197,6 +197,7 @@  siena_board_cfg(
 	encp->enc_filter_action_mark_max = 0;
 
 	encp->enc_mae_supported = B_FALSE;
+	encp->enc_mae_admin = B_FALSE;
 
 	return (0);