diff mbox series

[v2,24/58] net/bnxt: add support for WC TCAM shared session

Message ID 20210613000652.28191-25-ajit.khaparde@broadcom.com (mailing list archive)
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series enhancements to host based flow table management | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde June 13, 2021, 12:06 a.m. UTC
From: Jay Ding <jay.ding@broadcom.com>

If the session shares WC TCAM entries with others,
specify it in the session name by attach "-wc_tcam".
Firmware will flush the shared WC TCAM entries if
the last shared session using them is closed.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_msg.c     | 46 +++++++++++++++++++++++----
 drivers/net/bnxt/tf_core/tf_session.c |  5 +++
 2 files changed, 44 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/tf_core/tf_msg.c b/drivers/net/bnxt/tf_core/tf_msg.c
index fbd4b1d910..6717710dbd 100644
--- a/drivers/net/bnxt/tf_core/tf_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_msg.c
@@ -58,6 +58,16 @@  static_assert(sizeof(struct hwrm_tf_tbl_type_set_input) ==
  */
 #define TF_PCI_BUF_SIZE_MAX 88
 
+/**
+ * This is the length of shared session name "tf_share"
+ */
+#define TF_SHARED_SESSION_NAME_LEN 8
+
+/**
+ * This is the length of tcam shared session name "tf_shared-wc_tcam"
+ */
+#define TF_TCAM_SHARED_SESSION_NAME_LEN 17
+
 /**
  * If data bigger than TF_PCI_BUF_SIZE_MAX then use DMA method
  */
@@ -126,13 +136,17 @@  tf_msg_session_open(struct bnxt *bp,
 	struct hwrm_tf_session_open_output resp = { 0 };
 	struct tfp_send_msg_parms parms = { 0 };
 	int name_len;
-	char *name;
+	char *session_name;
+	char *tcam_session_name;
 
 	/* Populate the request */
 	name_len = strnlen(ctrl_chan_name, TF_SESSION_NAME_MAX);
-	name = &ctrl_chan_name[name_len - strlen("tf_shared")];
-	if (!strncmp(name, "tf_shared", strlen("tf_shared")))
-		tfp_memcpy(&req.session_name, name, strlen("tf_share"));
+	session_name = &ctrl_chan_name[name_len - strlen("tf_shared")];
+	tcam_session_name = &ctrl_chan_name[name_len - strlen("tf_shared-wc_tcam")];
+	if (!strncmp(tcam_session_name, "tf_shared-wc_tcam", strlen("tf_shared-wc_tcam")))
+		tfp_memcpy(&req.session_name, tcam_session_name, TF_TCAM_SHARED_SESSION_NAME_LEN);
+	else if (!strncmp(session_name, "tf_shared", strlen("tf_shared")))
+		tfp_memcpy(&req.session_name, session_name, TF_SHARED_SESSION_NAME_LEN);
 	else
 		tfp_memcpy(&req.session_name, ctrl_chan_name, TF_SESSION_NAME_MAX);
 
@@ -177,6 +191,9 @@  tf_msg_session_client_register(struct tf *tfp,
 	struct tfp_send_msg_parms parms = { 0 };
 	uint8_t fw_session_id;
 	struct tf_dev_info *dev;
+	int name_len;
+	char *session_name;
+	char *tcam_session_name;
 
 	/* Retrieve the device information */
 	rc = tf_session_get_device(tfs, &dev);
@@ -197,9 +214,24 @@  tf_msg_session_client_register(struct tf *tfp,
 
 	/* Populate the request */
 	req.fw_session_id = tfp_cpu_to_le_32(fw_session_id);
-	tfp_memcpy(&req.session_client_name,
-		   ctrl_channel_name,
-		   TF_SESSION_NAME_MAX);
+	name_len = strnlen(ctrl_channel_name, TF_SESSION_NAME_MAX);
+	session_name = &ctrl_channel_name[name_len - strlen("tf_shared")];
+	tcam_session_name = &ctrl_channel_name[name_len -
+		strlen("tf_shared-wc_tcam")];
+	if (!strncmp(tcam_session_name,
+				"tf_shared-wc_tcam",
+				strlen("tf_shared-wc_tcam")))
+		tfp_memcpy(&req.session_client_name,
+				tcam_session_name,
+				TF_TCAM_SHARED_SESSION_NAME_LEN);
+	else if (!strncmp(session_name, "tf_shared", strlen("tf_shared")))
+		tfp_memcpy(&req.session_client_name,
+				session_name,
+				TF_SHARED_SESSION_NAME_LEN);
+	else
+		tfp_memcpy(&req.session_client_name,
+				ctrl_channel_name,
+				TF_SESSION_NAME_MAX);
 
 	parms.tf_type = HWRM_TF_SESSION_REGISTER;
 	parms.req_data = (uint32_t *)&req;
diff --git a/drivers/net/bnxt/tf_core/tf_session.c b/drivers/net/bnxt/tf_core/tf_session.c
index 71ccb2e3e7..90b65c59e6 100644
--- a/drivers/net/bnxt/tf_core/tf_session.c
+++ b/drivers/net/bnxt/tf_core/tf_session.c
@@ -188,6 +188,11 @@  tf_session_create(struct tf *tfp,
 	if (!strncmp(name, "tf_shared", strlen("tf_shared")))
 		session->shared_session = true;
 
+	name = &parms->open_cfg->ctrl_chan_name[name_len -
+		strlen("tf_shared-wc_tcam")];
+	if (!strncmp(name, "tf_shared-wc_tcam", strlen("tf_shared-wc_tcam")))
+		session->shared_session = true;
+
 	if (session->shared_session && shared_session_creator) {
 		session->shared_session_creator = true;
 		parms->open_cfg->shared_session_creator = true;