netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 14/15] nfp: support access to absolute RTsyms
Date: Tue, 28 Aug 2018 13:20:46 -0700	[thread overview]
Message-ID: <20180828202047.1305-15-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180828202047.1305-1-jakub.kicinski@netronome.com>

Add support in nfpcore for reading the absolute RTsyms.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Francois H. Theron <francois.theron@netronome.com>
---
 .../ethernet/netronome/nfp/nfpcore/nfp_nffw.h | 13 +++---
 .../netronome/nfp/nfpcore/nfp_rtsym.c         | 42 +++++++++++++++++--
 2 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h
index 04700278d00d..8d2cbdf4d517 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h
@@ -61,10 +61,12 @@ void nfp_mip_strtab(const struct nfp_mip *mip, u32 *addr, u32 *size);
 
 /* Implemented in nfp_rtsym.c */
 
-#define NFP_RTSYM_TYPE_NONE		0
-#define NFP_RTSYM_TYPE_OBJECT		1
-#define NFP_RTSYM_TYPE_FUNCTION		2
-#define NFP_RTSYM_TYPE_ABS		3
+enum nfp_rtsym_type {
+	NFP_RTSYM_TYPE_NONE	= 0,
+	NFP_RTSYM_TYPE_OBJECT	= 1,
+	NFP_RTSYM_TYPE_FUNCTION	= 2,
+	NFP_RTSYM_TYPE_ABS	= 3,
+};
 
 #define NFP_RTSYM_TARGET_NONE		0
 #define NFP_RTSYM_TARGET_LMEM		-1
@@ -83,7 +85,7 @@ struct nfp_rtsym {
 	const char *name;
 	u64 addr;
 	u64 size;
-	int type;
+	enum nfp_rtsym_type type;
 	int target;
 	int domain;
 };
@@ -98,6 +100,7 @@ const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
 const struct nfp_rtsym *
 nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);
 
+u64 nfp_rtsym_size(const struct nfp_rtsym *rtsym);
 int __nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
 		     u8 action, u8 token, u64 off, void *buf, size_t len);
 int nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c
index 28e5ed0bb31d..108ce8c5e68e 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_rtsym.c
@@ -233,10 +233,32 @@ nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name)
 	return NULL;
 }
 
+u64 nfp_rtsym_size(const struct nfp_rtsym *sym)
+{
+	switch (sym->type) {
+	case NFP_RTSYM_TYPE_NONE:
+		pr_err("rtsym type NONE\n");
+		return 0;
+	default:
+		pr_warn("Unknown rtsym type: %d\n", sym->type);
+		/* fall through */
+	case NFP_RTSYM_TYPE_OBJECT:
+	case NFP_RTSYM_TYPE_FUNCTION:
+		return sym->size;
+	case NFP_RTSYM_TYPE_ABS:
+		return sizeof(u64);
+	}
+}
+
 static int
 nfp_rtsym_to_dest(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
 		  u8 action, u8 token, u64 off, u32 *cpp_id, u64 *addr)
 {
+	if (sym->type != NFP_RTSYM_TYPE_OBJECT) {
+		nfp_err(cpp, "Direct access attempt to non-object rtsym\n");
+		return -EINVAL;
+	}
+
 	*addr = sym->addr + off;
 
 	if (sym->target == NFP_RTSYM_TARGET_EMU_CACHE) {
@@ -266,6 +288,15 @@ int __nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
 	u64 addr;
 	int err;
 
+	if (sym->type == NFP_RTSYM_TYPE_ABS) {
+		__le64 tmp = cpu_to_le64(sym->addr);
+
+		len = min(len, sizeof(tmp));
+		memcpy(buf, &tmp, len);
+
+		return len;
+	}
+
 	err = nfp_rtsym_to_dest(cpp, sym, action, token, off, &cpp_id, &addr);
 	if (err)
 		return err;
@@ -306,6 +337,9 @@ int __nfp_rtsym_readq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
 	u64 addr;
 	int err;
 
+	if (sym->type == NFP_RTSYM_TYPE_ABS)
+		return sym->addr;
+
 	err = nfp_rtsym_to_dest(cpp, sym, action, token, off, &cpp_id, &addr);
 	if (err)
 		return err;
@@ -405,7 +439,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
 		goto exit;
 	}
 
-	switch (sym->size) {
+	switch (nfp_rtsym_size(sym)) {
 	case 4:
 		err = nfp_rtsym_readl(rtbl->cpp, sym, 0, &val32);
 		val = val32;
@@ -416,7 +450,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
 	default:
 		nfp_err(rtbl->cpp,
 			"rtsym '%s' unsupported or non-scalar size: %lld\n",
-			name, sym->size);
+			name, nfp_rtsym_size(sym));
 		err = -EINVAL;
 		break;
 	}
@@ -452,7 +486,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name,
 	if (!sym)
 		return -ENOENT;
 
-	switch (sym->size) {
+	switch (nfp_rtsym_size(sym)) {
 	case 4:
 		err = nfp_rtsym_writel(rtbl->cpp, sym, 0, value);
 		break;
@@ -462,7 +496,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name,
 	default:
 		nfp_err(rtbl->cpp,
 			"rtsym '%s' unsupported or non-scalar size: %lld\n",
-			name, sym->size);
+			name, nfp_rtsym_size(sym));
 		err = -EINVAL;
 		break;
 	}
-- 
2.17.1

  parent reply	other threads:[~2018-08-29  0:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 20:20 [PATCH net-next 00/15] nfp: add NFP5000 support Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 01/15] nfp: encapsulate NSP command arguments into structs Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 02/15] nfp: attempt FW load from flash Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 03/15] nfp: interpret extended FW load result codes Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 04/15] nfp: add support for indirect HWinfo lookup Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 05/15] nfp: abm: look up MAC addresses via management FW Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 06/15] nfp: add support for NFP5000 Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 07/15] nfp: refactor the per-chip PCIe config Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 08/15] nfp: save the MU locality field offset Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 09/15] nfp: add basic errors messages to target logic Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 10/15] nfp: add RTsym access helpers Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 11/15] nfp: pass cpp_id to nfp_cpp_map_area() Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 12/15] nfp: convert existing RTsym helpers to full target decoding Jakub Kicinski
2018-08-28 20:20 ` [PATCH net-next 13/15] nfp: convert all RTsym users to use new read/write helpers Jakub Kicinski
2018-08-28 20:20 ` Jakub Kicinski [this message]
2018-08-28 20:20 ` [PATCH net-next 15/15] nfp: make RTsym users handle absolute symbols correctly Jakub Kicinski
2018-08-29  0:01 ` [PATCH net-next 00/15] nfp: add NFP5000 support David Miller

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=20180828202047.1305-15-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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
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).