DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alejandro Lucero <alejandro.lucero@netronome.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 06/18] net/nfp: add NSP symbol resolution command
Date: Fri,  1 Sep 2017 15:12:09 +0100	[thread overview]
Message-ID: <1504275141-35448-7-git-send-email-alejandro.lucero@netronome.com> (raw)
In-Reply-To: <1504275141-35448-1-git-send-email-alejandro.lucero@netronome.com>

Firmware has symbols helping to configure things like number of
PF ports, vNIC BARs addresses inside NFP memories, or ethernet
link state. Different firmware apps have different things to map
and likely different internal NFP addresses to use.

Host drivers can use the NSPU interface for getting symbol data
regarding different hardware configurations. Once the driver has
the information about a specific object, a mapping is required
configuring an NFP expansion bar creating a device PCI bar window.

Signed-off-by: Alejandro Lucero <alejandro.lucero@netronome.com>
---
 drivers/net/nfp/nfp_nspu.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/nfp/nfp_nspu.h |  3 ++
 2 files changed, 89 insertions(+)

diff --git a/drivers/net/nfp/nfp_nspu.c b/drivers/net/nfp/nfp_nspu.c
index 57ee45f..d80da80 100644
--- a/drivers/net/nfp/nfp_nspu.c
+++ b/drivers/net/nfp/nfp_nspu.c
@@ -43,6 +43,7 @@
 /* NSP commands */
 #define NSP_CMD_RESET          1
 #define NSP_CMD_FW_LOAD        6
+#define NSP_CMD_GET_SYMBOL     14
 
 #define NSP_BUFFER_CFG_SIZE_MASK	(0xff)
 
@@ -368,3 +369,88 @@
 
 	return ret;
 }
+
+/* Firmware symbol descriptor size */
+#define NFP_SYM_DESC_LEN 40
+
+#define SYMBOL_DATA(b, off)     (*(int64_t *)((b) + (off)))
+#define SYMBOL_UDATA(b, off)     (*(uint64_t *)((b) + (off)))
+
+/* Firmware symbols contain information about how to access what they
+ * represent. It can be as simple as an numeric variable declared at a
+ * specific NFP memory, but it can also be more complex structures and
+ * related to specific hardware functionalities or components. Target,
+ * domain and address allow to create the BAR window for accessing such
+ * hw object and size defines the length to map.
+ *
+ * A vNIC is a network interface implemented inside the NFP and using a
+ * subset of device PCI BARs. Specific firmware symbols allow to map those
+ * vNIC bars by host drivers like the NFP PMD.
+ *
+ * Accessing what the symbol represents implies to map the access through
+ * a PCI BAR window. NFP expansion BARs are used in this regard through
+ * the NSPU interface.
+ */
+int
+nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
+			    uint32_t expbar, uint64_t *pcie_offset,
+			    ssize_t *size)
+{
+	int64_t type;
+	int64_t target;
+	int64_t domain;
+	uint64_t addr;
+	char *sym_buf;
+	int ret = 0;
+
+	sym_buf = malloc(desc->buf_size);
+	strncpy(sym_buf, symbl, strlen(symbl));
+	ret = nspu_command(desc, NSP_CMD_GET_SYMBOL, 1, 1, sym_buf,
+			   NFP_SYM_DESC_LEN, strlen(symbl));
+	if (ret) {
+		RTE_LOG(DEBUG, PMD, "symbol resolution (%s) failed\n", symbl);
+		goto clean;
+	}
+
+	/* Reading symbol information */
+	type = SYMBOL_DATA(sym_buf, 0);
+	target = SYMBOL_DATA(sym_buf, 8);
+	domain =  SYMBOL_DATA(sym_buf, 16);
+	addr = SYMBOL_UDATA(sym_buf, 24);
+	*size = (ssize_t)SYMBOL_UDATA(sym_buf, 32);
+
+	if (type != 1) {
+		RTE_LOG(INFO, PMD, "wrong symbol type\n");
+		ret = -EINVAL;
+		goto clean;
+	}
+	if (!(target == 7 || target == -7)) {
+		RTE_LOG(INFO, PMD, "wrong symbol target\n");
+		ret = -EINVAL;
+		goto clean;
+	}
+	if (domain == 8 || domain == 9) {
+		RTE_LOG(INFO, PMD, "wrong symbol domain\n");
+		ret = -EINVAL;
+		goto clean;
+	}
+
+	/* Adjusting address based on symbol location */
+	if ((domain >= 24) && (domain < 28) && (target == 7)) {
+		addr = 1ULL << 37 | addr | ((uint64_t)domain & 0x3) << 35;
+	} else {
+		addr = 1ULL << 39 | addr | ((uint64_t)domain & 0x3f) << 32;
+		if (target == -7)
+			target = 7;
+	}
+
+	/* Configuring NFP expansion bar for mapping specific PCI BAR window */
+	nfp_nspu_mem_bar_cfg(desc, expbar, target, addr, pcie_offset);
+
+	/* This is the PCI BAR offset to use by the host */
+	*pcie_offset |= ((expbar & 0x7) << (desc->barsz - 3));
+
+clean:
+	free(sym_buf);
+	return ret;
+}
diff --git a/drivers/net/nfp/nfp_nspu.h b/drivers/net/nfp/nfp_nspu.h
index 6e1c25f..7734b4f 100644
--- a/drivers/net/nfp/nfp_nspu.h
+++ b/drivers/net/nfp/nfp_nspu.h
@@ -74,3 +74,6 @@ int nfp_nspu_init(nspu_desc_t *desc, int nfp, int pcie_bar, size_t pcie_barsz,
 int nfp_nsp_get_abi_version(nspu_desc_t *desc, int *major, int *minor);
 int nfp_fw_reset(nspu_desc_t *nspu_desc);
 int nfp_fw_upload(nspu_desc_t *nspu_desc);
+int nfp_nspu_set_bar_from_symbl(nspu_desc_t *desc, const char *symbl,
+				uint32_t expbar, uint64_t *pcie_offset,
+				ssize_t *size);
-- 
1.9.1

  parent reply	other threads:[~2017-09-01 14:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01 14:12 [dpdk-dev] [PATCH v2 00/18] net/nfp: add PF support Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 01/18] net/nfp: add NSP user space interface Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 02/18] net/nfp: add specific PF probe function Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 03/18] net/nfp: add support for new PCI id Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 04/18] net/nfp: add NSP support for commands Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 05/18] net/nfp: add NSP FW upload command Alejandro Lucero
2017-09-01 14:12 ` Alejandro Lucero [this message]
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 07/18] net/nfp: add FW upload logic Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 08/18] net/nfp: add support for vnic config bar mapping Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 09/18] net/nfp: add support for vNIC Rx/Tx bar mappings Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 10/18] net/nfp: support PF devices inside PMD initialization Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 11/18] net/nfp: allocate ethernet device from PF probe function Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 12/18] net/nfp: support PF multiport Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 13/18] net/nfp: add NSP support for HW link configuration Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 14/18] net/nfp: add support for HW port " Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 15/18] net/nfp: read PF port MAC addr using NSP Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 16/18] doc: update NFP with PF support information Alejandro Lucero
2017-09-04 14:20   ` Mcnamara, John
2017-09-04 16:03     ` Alejandro Lucero
2017-09-06  9:53       ` Ferruh Yigit
2017-09-06 10:43         ` Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 17/18] doc: update release notes with NFP PF support Alejandro Lucero
2017-09-04 16:12   ` Mcnamara, John
2017-09-19  9:53   ` Ferruh Yigit
2017-09-19 10:49     ` Alejandro Lucero
2017-09-01 14:12 ` [dpdk-dev] [PATCH v2 18/18] doc: create different features files for NFP drivers Alejandro Lucero
2017-09-04 16:29   ` Mcnamara, John
2017-09-06 16:15 ` [dpdk-dev] [PATCH v2 00/18] net/nfp: add PF support Ferruh Yigit

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=1504275141-35448-7-git-send-email-alejandro.lucero@netronome.com \
    --to=alejandro.lucero@netronome.com \
    --cc=dev@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).