DPDK patches and discussions
 help / color / mirror / Atom feed
From: Somnath Kotur <somnath.kotur@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com
Subject: [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping
Date: Mon, 13 Jul 2020 11:58:19 +0530
Message-ID: <20200713062828.19626-2-somnath.kotur@broadcom.com> (raw)
In-Reply-To: <20200713062828.19626-1-somnath.kotur@broadcom.com>

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

- The mapping of kernel pages for EEM sysmem operation takes
  a significant amount of time. This change give the build option
  to delay the sysmem mapping until the first write to EEM

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c        | 17 +++++++++++--
 drivers/net/bnxt/tf_core/tf_em.h          | 11 +++++++++
 drivers/net/bnxt/tf_core/tf_em_common.c   | 41 +++++++++++++++++++++++++++++++
 drivers/net/bnxt/tf_core/tf_em_internal.c |  2 +-
 drivers/net/bnxt/tf_core/tf_em_system.c   |  6 +++--
 5 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 00b2775..a404cb8 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -49,9 +49,22 @@ tf_open_session(struct tf *tfp,
 		    &slot,
 		    &device);
 	if (rc != 4) {
-		TFP_DRV_LOG(ERR,
+		/* PCI Domain not provided (optional in DPDK), thus we
+		 * force domain to 0 and recheck.
+		 */
+		domain = 0;
+
+		/* Check parsing of bus/slot/device */
+		rc = sscanf(parms->ctrl_chan_name,
+			    "%x:%x.%d",
+			    &bus,
+			    &slot,
+			    &device);
+		if (rc != 3) {
+			TFP_DRV_LOG(ERR,
 			    "Failed to scan device ctrl_chan_name\n");
-		return -EINVAL;
+			return -EINVAL;
+		}
 	}
 
 	parms->session_id.internal.domain = domain;
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 0890261..ae2e64d 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -9,6 +9,16 @@
 #include "tf_core.h"
 #include "tf_session.h"
 
+#ifdef TF_USE_SYSTEM_MEM
+/**
+ * Select EEM sysmem mmap export to be done at init
+ * or on the first write to EEM.
+ */
+#define TF_EM_SYSMEM_DELAY_EXPORT 1
+#else
+#define TF_EM_SYSMEM_DELAY_EXPORT 0
+#endif
+
 #define SUPPORT_CFA_HW_P4 1
 #define SUPPORT_CFA_HW_P58 0
 #define SUPPORT_CFA_HW_P59 0
@@ -482,4 +492,5 @@ int
 tf_em_ext_system_bind(struct tf *tfp,
 		      struct tf_em_cfg_parms *parms);
 
+int offload_system_mmap(struct tf_tbl_scope_cb *tbl_scope_cb);
 #endif /* _TF_EM_H_ */
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index 8b02b8b..65b9abf 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -700,6 +700,26 @@ tf_insert_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
 	uint64_t big_hash;
 	int rc;
 
+#if (TF_EM_SYSMEM_DELAY_EXPORT == 1)
+	if (!tbl_scope_cb->valid) {
+		rc = offload_system_mmap(tbl_scope_cb);
+
+		if (rc) {
+			struct tf_rm_free_parms fparms = { 0 };
+
+			TFP_DRV_LOG(ERR,
+				    "System alloc mmap failed\n");
+			/* Free Table control block */
+			fparms.rm_db = eem_db[TF_DIR_RX];
+			fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+			fparms.index = parms->tbl_scope_id;
+			tf_rm_free(&fparms);
+			return -EINVAL;
+		}
+
+		tbl_scope_cb->valid = true;
+	}
+#endif
 	/* Get mask to use on hash */
 	mask = tf_em_get_key_mask(tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_KEY0_TABLE].num_entries);
 
@@ -1017,6 +1037,27 @@ int tf_tbl_ext_common_set(struct tf *tfp,
 		return -EINVAL;
 	}
 
+#if (TF_EM_SYSMEM_DELAY_EXPORT == 1)
+	if (!tbl_scope_cb->valid) {
+		rc = offload_system_mmap(tbl_scope_cb);
+
+		if (rc) {
+			struct tf_rm_free_parms fparms = { 0 };
+
+			TFP_DRV_LOG(ERR,
+				    "System alloc mmap failed\n");
+			/* Free Table control block */
+			fparms.rm_db = eem_db[TF_DIR_RX];
+			fparms.db_index = TF_EM_TBL_TYPE_TBL_SCOPE;
+			fparms.index = parms->tbl_scope_id;
+			tf_rm_free(&fparms);
+			return -EINVAL;
+		}
+
+		tbl_scope_cb->valid = true;
+	}
+#endif
+
 	op.opcode = HCAPI_CFA_HWOPS_PUT;
 	key_tbl.base0 =
 		(uint8_t *)&tbl_scope_cb->em_ctx_info[parms->dir].em_tables[TF_RECORD_TABLE];
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 3129fbe..462d0fa 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -179,7 +179,7 @@ tf_em_insert_int_entry(struct tf *tfp,
 		return -1;
 
 	PMD_DRV_LOG
-		  (ERR,
+		  (DEBUG,
 		   "%s, Internal entry @ Index:%d rptr_index:0x%x rptr_entry:0x%x num_of_entries:%d\n",
 		   tf_dir_2_str(parms->dir),
 		   index,
diff --git a/drivers/net/bnxt/tf_core/tf_em_system.c b/drivers/net/bnxt/tf_core/tf_em_system.c
index 339392c..1c3c702 100644
--- a/drivers/net/bnxt/tf_core/tf_em_system.c
+++ b/drivers/net/bnxt/tf_core/tf_em_system.c
@@ -272,8 +272,7 @@ tf_prepare_dmabuf_bnxt_lfc_device(struct tf_tbl_scope_cb *tbl_scope_cb)
 	return 0;
 }
 
-static int
-offload_system_mmap(struct tf_tbl_scope_cb *tbl_scope_cb)
+int offload_system_mmap(struct tf_tbl_scope_cb *tbl_scope_cb)
 {
 	int rc;
 	int dmabuf_fd;
@@ -455,6 +454,7 @@ tf_em_ext_alloc(struct tf *tfp,
 		}
 	}
 
+#if (TF_EM_SYSMEM_DELAY_EXPORT == 0)
 	rc = offload_system_mmap(tbl_scope_cb);
 
 	if (rc) {
@@ -462,6 +462,7 @@ tf_em_ext_alloc(struct tf *tfp,
 			    "System alloc mmap failed\n");
 		goto cleanup_full;
 	}
+#endif
 
 	return rc;
 
@@ -527,6 +528,7 @@ tf_em_ext_free(struct tf *tfp,
 	}
 
 	tf_dmabuf_free(tfp, tbl_scope_cb);
+	tbl_scope_cb->valid = false;
 
 	return rc;
 }
-- 
2.7.4


  reply	other threads:[~2020-07-13  6:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13  6:28 [dpdk-dev] [v2 PATCH 00/10] bnxt patches Somnath Kotur
2020-07-13  6:28 ` Somnath Kotur [this message]
2020-07-13  6:28 ` [dpdk-dev] [PATCH 02/10] net/bnxt: implement TF Identifier search Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 03/10] net/bnxt: check index range in bulk get Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 04/10] net/bnxt: add changes to support 2 table scopes Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 05/10] net/bnxt: add support to extract data from the ulp blob Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 06/10] net/bnxt: ignore ipv4 tos mask Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 07/10] net/bnxt: add support for identifier search and ref count Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 08/10] net/bnxt: consider vlan fields for the template match criteria Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 09/10] net/bnxt: increase the number of egress flow entries Somnath Kotur
2020-07-13  6:28 ` [dpdk-dev] [PATCH 10/10] net/bnxt: add support for decrement ttl action Somnath Kotur
2020-07-13  7:56 ` [dpdk-dev] [v2 PATCH 00/10] bnxt patches Thomas Monjalon
  -- strict thread matches above, loose matches on Subject: below --
2020-07-13  6:15 [dpdk-dev] [PATCH " Somnath Kotur
2020-07-13  6:15 ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-13  9:42 ` [dpdk-dev] [PATCH v3 00/10] bnxt patches Somnath Kotur
2020-07-13  9:42   ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur
2020-07-15 13:50 ` [dpdk-dev] [PATCH v4 00/10] bnxt patches Somnath Kotur
2020-07-15 13:50   ` [dpdk-dev] [PATCH 01/10] net/bnxt: add option to delay EEM sysmem mapping Somnath Kotur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200713062828.19626-2-somnath.kotur@broadcom.com \
    --to=somnath.kotur@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git