Commit 640917dd authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: support access to absolute RTsyms

Add support in nfpcore for reading the absolute RTsyms.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarFrancois H. Theron <francois.theron@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1240989c
...@@ -61,10 +61,12 @@ void nfp_mip_strtab(const struct nfp_mip *mip, u32 *addr, u32 *size); ...@@ -61,10 +61,12 @@ void nfp_mip_strtab(const struct nfp_mip *mip, u32 *addr, u32 *size);
/* Implemented in nfp_rtsym.c */ /* Implemented in nfp_rtsym.c */
#define NFP_RTSYM_TYPE_NONE 0 enum nfp_rtsym_type {
#define NFP_RTSYM_TYPE_OBJECT 1 NFP_RTSYM_TYPE_NONE = 0,
#define NFP_RTSYM_TYPE_FUNCTION 2 NFP_RTSYM_TYPE_OBJECT = 1,
#define NFP_RTSYM_TYPE_ABS 3 NFP_RTSYM_TYPE_FUNCTION = 2,
NFP_RTSYM_TYPE_ABS = 3,
};
#define NFP_RTSYM_TARGET_NONE 0 #define NFP_RTSYM_TARGET_NONE 0
#define NFP_RTSYM_TARGET_LMEM -1 #define NFP_RTSYM_TARGET_LMEM -1
...@@ -83,7 +85,7 @@ struct nfp_rtsym { ...@@ -83,7 +85,7 @@ struct nfp_rtsym {
const char *name; const char *name;
u64 addr; u64 addr;
u64 size; u64 size;
int type; enum nfp_rtsym_type type;
int target; int target;
int domain; int domain;
}; };
...@@ -98,6 +100,7 @@ const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx); ...@@ -98,6 +100,7 @@ const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
const struct nfp_rtsym * const struct nfp_rtsym *
nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name); 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, int __nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
u8 action, u8 token, u64 off, void *buf, size_t len); 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, int nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
......
...@@ -233,10 +233,32 @@ nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name) ...@@ -233,10 +233,32 @@ nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name)
return NULL; 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 static int
nfp_rtsym_to_dest(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, nfp_rtsym_to_dest(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
u8 action, u8 token, u64 off, u32 *cpp_id, u64 *addr) 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; *addr = sym->addr + off;
if (sym->target == NFP_RTSYM_TARGET_EMU_CACHE) { 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, ...@@ -266,6 +288,15 @@ int __nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
u64 addr; u64 addr;
int err; 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); err = nfp_rtsym_to_dest(cpp, sym, action, token, off, &cpp_id, &addr);
if (err) if (err)
return err; return err;
...@@ -306,6 +337,9 @@ int __nfp_rtsym_readq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, ...@@ -306,6 +337,9 @@ int __nfp_rtsym_readq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
u64 addr; u64 addr;
int err; 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); err = nfp_rtsym_to_dest(cpp, sym, action, token, off, &cpp_id, &addr);
if (err) if (err)
return err; return err;
...@@ -405,7 +439,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, ...@@ -405,7 +439,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
goto exit; goto exit;
} }
switch (sym->size) { switch (nfp_rtsym_size(sym)) {
case 4: case 4:
err = nfp_rtsym_readl(rtbl->cpp, sym, 0, &val32); err = nfp_rtsym_readl(rtbl->cpp, sym, 0, &val32);
val = val32; val = val32;
...@@ -416,7 +450,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, ...@@ -416,7 +450,7 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
default: default:
nfp_err(rtbl->cpp, nfp_err(rtbl->cpp,
"rtsym '%s' unsupported or non-scalar size: %lld\n", "rtsym '%s' unsupported or non-scalar size: %lld\n",
name, sym->size); name, nfp_rtsym_size(sym));
err = -EINVAL; err = -EINVAL;
break; break;
} }
...@@ -452,7 +486,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name, ...@@ -452,7 +486,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name,
if (!sym) if (!sym)
return -ENOENT; return -ENOENT;
switch (sym->size) { switch (nfp_rtsym_size(sym)) {
case 4: case 4:
err = nfp_rtsym_writel(rtbl->cpp, sym, 0, value); err = nfp_rtsym_writel(rtbl->cpp, sym, 0, value);
break; break;
...@@ -462,7 +496,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name, ...@@ -462,7 +496,7 @@ int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name,
default: default:
nfp_err(rtbl->cpp, nfp_err(rtbl->cpp,
"rtsym '%s' unsupported or non-scalar size: %lld\n", "rtsym '%s' unsupported or non-scalar size: %lld\n",
name, sym->size); name, nfp_rtsym_size(sym));
err = -EINVAL; err = -EINVAL;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment