lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 17 Mar 2020 20:47:26 +0530
From:   Vasundhara Volam <vasundhara-v.volam@...adcom.com>
To:     davem@...emloft.net
Cc:     netdev@...r.kernel.org, Pavan Chebbi <pavan.chebbi@...adcom.com>,
        Vasundhara Volam <vasundhara-v.volam@...adcom.com>,
        Michael Chan <michael.chan@...adcom.com>
Subject: [PATCH net-next 11/11] bnxt_en: Use "enable_ecn" devlink param

From: Pavan Chebbi <pavan.chebbi@...adcom.com>

Add support for "enable_ecn" devlink parameter with configuration
mode as permanent and runtime. Also update bnxt.rst documentation
file.

Signed-off-by: Pavan Chebbi <pavan.chebbi@...adcom.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@...adcom.com>
Signed-off-by: Michael Chan <michael.chan@...adcom.com>
---
 Documentation/networking/devlink/bnxt.rst         |  2 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 81 ++++++++++++++++++++---
 drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h |  1 +
 3 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/Documentation/networking/devlink/bnxt.rst b/Documentation/networking/devlink/bnxt.rst
index 17b6522..5541826 100644
--- a/Documentation/networking/devlink/bnxt.rst
+++ b/Documentation/networking/devlink/bnxt.rst
@@ -22,6 +22,8 @@ Parameters
      - Permanent
    * - ``msix_vec_per_pf_min``
      - Permanent
+   * - ``enable_ecn``
+     - Permanent, runtime
 
 The ``bnxt`` driver also implements the following driver-specific
 parameters.
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
index 6065602..53274be 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
@@ -312,6 +312,8 @@ enum bnxt_dl_param_id {
 	 NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10, 4},
 	{DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
 	 NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7, 4},
+	{DEVLINK_PARAM_GENERIC_ID_ENABLE_ECN, NVM_OFF_ENABLE_ECN,
+	 BNXT_NVM_SHARED_CFG, 1, 1},
 	{BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK,
 	 BNXT_NVM_SHARED_CFG, 1, 1},
 };
@@ -626,15 +628,42 @@ static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
 static int bnxt_dl_nvm_param_get(struct devlink *dl, u32 id,
 				 struct devlink_param_gset_ctx *ctx)
 {
-	struct hwrm_nvm_get_variable_input req = {0};
 	struct bnxt *bp = bnxt_get_bp_from_dl(dl);
 	int rc;
 
-	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
-	rc = bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
-	if (!rc)
-		if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
-			ctx->val.vbool = !ctx->val.vbool;
+	if (ctx->cmode == DEVLINK_PARAM_CMODE_PERMANENT) {
+		struct hwrm_nvm_get_variable_input req = {0};
+
+		bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
+		rc = bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
+		if (!rc)
+			if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
+				ctx->val.vbool = !ctx->val.vbool;
+	} else if (ctx->cmode == DEVLINK_PARAM_CMODE_RUNTIME) {
+		switch (id) {
+		case DEVLINK_PARAM_GENERIC_ID_ENABLE_ECN:
+		{
+			struct hwrm_fw_ecn_qcfg_input req = {0};
+			struct hwrm_fw_ecn_qcfg_output *resp =
+				bp->hwrm_cmd_resp_addr;
+
+			bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_ECN_QCFG,
+					       -1, -1);
+			rc = hwrm_send_message(bp, &req, sizeof(req),
+					       HWRM_CMD_TIMEOUT);
+			if (!rc) {
+				if (resp->flags &
+				    FW_ECN_QCFG_RESP_FLAGS_ENABLE_ECN)
+					ctx->val.vbool = true;
+			}
+			break;
+		}
+		default:
+			netdev_err(bp->dev, "Unsupported devlink parameter\n");
+			rc = -EOPNOTSUPP;
+			break;
+		}
+	}
 
 	return rc;
 }
@@ -642,15 +671,40 @@ static int bnxt_dl_nvm_param_get(struct devlink *dl, u32 id,
 static int bnxt_dl_nvm_param_set(struct devlink *dl, u32 id,
 				 struct devlink_param_gset_ctx *ctx)
 {
-	struct hwrm_nvm_set_variable_input req = {0};
 	struct bnxt *bp = bnxt_get_bp_from_dl(dl);
+	int rc;
 
-	bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_SET_VARIABLE, -1, -1);
+	if (ctx->cmode == DEVLINK_PARAM_CMODE_PERMANENT) {
+		struct hwrm_nvm_set_variable_input req = {0};
 
-	if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
-		ctx->val.vbool = !ctx->val.vbool;
+		if (id == BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK)
+			ctx->val.vbool = !ctx->val.vbool;
 
-	return bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
+		bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_SET_VARIABLE, -1, -1);
+		rc = bnxt_hwrm_nvm_req(bp, id, &req, sizeof(req), &ctx->val);
+	} else if (ctx->cmode == DEVLINK_PARAM_CMODE_RUNTIME) {
+		switch (id) {
+		case DEVLINK_PARAM_GENERIC_ID_ENABLE_ECN:
+		{
+			struct hwrm_fw_ecn_cfg_input req = {0};
+
+			bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_ECN_CFG,
+					       -1, -1);
+			if (ctx->val.vbool)
+				req.flags =
+				cpu_to_le32(FW_ECN_CFG_REQ_FLAGS_ENABLE_ECN);
+			rc = hwrm_send_message(bp, &req, sizeof(req),
+					       HWRM_CMD_TIMEOUT);
+			break;
+		}
+		default:
+			netdev_err(bp->dev, "Unsupported devlink parameter\n");
+			rc = -EOPNOTSUPP;
+			break;
+		}
+	}
+
+	return rc;
 }
 
 static int bnxt_dl_msix_validate(struct devlink *dl, u32 id,
@@ -690,6 +744,11 @@ static int bnxt_dl_msix_validate(struct devlink *dl, u32 id,
 			      BIT(DEVLINK_PARAM_CMODE_PERMANENT),
 			      bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
 			      bnxt_dl_msix_validate),
+	DEVLINK_PARAM_GENERIC(ENABLE_ECN,
+			      BIT(DEVLINK_PARAM_CMODE_PERMANENT) |
+			      BIT(DEVLINK_PARAM_CMODE_RUNTIME),
+			      bnxt_dl_nvm_param_get, bnxt_dl_nvm_param_set,
+			      NULL),
 	DEVLINK_PARAM_DRIVER(BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK,
 			     "gre_ver_check", DEVLINK_PARAM_TYPE_BOOL,
 			     BIT(DEVLINK_PARAM_CMODE_PERMANENT),
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
index e720b1d..71ba65a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
@@ -38,6 +38,7 @@ static inline void bnxt_link_bp_to_dl(struct bnxt *bp, struct devlink *dl)
 #define NVM_OFF_MSIX_VEC_PER_PF_MIN	114
 #define NVM_OFF_IGNORE_ARI		164
 #define NVM_OFF_DIS_GRE_VER_CHECK	171
+#define NVM_OFF_ENABLE_ECN		173
 #define NVM_OFF_ENABLE_SRIOV		401
 #define NVM_OFF_NVM_CFG_VER		602
 
-- 
1.8.3.1

Powered by blists - more mailing lists