Commit 4152e58c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: make RTsym users handle absolute symbols correctly

Make the RTsym users access the size via the helper, which
takes care of special handling of absolute symbols.
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 640917dd
...@@ -280,10 +280,10 @@ nfp_abm_ctrl_find_rtsym(struct nfp_pf *pf, const char *name, unsigned int size) ...@@ -280,10 +280,10 @@ nfp_abm_ctrl_find_rtsym(struct nfp_pf *pf, const char *name, unsigned int size)
nfp_err(pf->cpp, "Symbol '%s' not found\n", name); nfp_err(pf->cpp, "Symbol '%s' not found\n", name);
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
} }
if (sym->size != size) { if (nfp_rtsym_size(sym) != size) {
nfp_err(pf->cpp, nfp_err(pf->cpp,
"Symbol '%s' wrong size: expected %u got %llu\n", "Symbol '%s' wrong size: expected %u got %llu\n",
name, size, sym->size); name, size, nfp_rtsym_size(sym));
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
......
...@@ -124,7 +124,7 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, ...@@ -124,7 +124,7 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
if (!pf->mbox) if (!pf->mbox)
return -EOPNOTSUPP; return -EOPNOTSUPP;
max_data_sz = pf->mbox->size - NFP_MBOX_SYM_MIN_SIZE; max_data_sz = nfp_rtsym_size(pf->mbox) - NFP_MBOX_SYM_MIN_SIZE;
/* Check if cmd field is clear */ /* Check if cmd field is clear */
err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val); err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val);
...@@ -566,9 +566,9 @@ static int nfp_pf_find_rtsyms(struct nfp_pf *pf) ...@@ -566,9 +566,9 @@ static int nfp_pf_find_rtsyms(struct nfp_pf *pf)
/* Optional per-PCI PF mailbox */ /* Optional per-PCI PF mailbox */
snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id); snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id);
pf->mbox = nfp_rtsym_lookup(pf->rtbl, pf_symbol); pf->mbox = nfp_rtsym_lookup(pf->rtbl, pf_symbol);
if (pf->mbox && pf->mbox->size < NFP_MBOX_SYM_MIN_SIZE) { if (pf->mbox && nfp_rtsym_size(pf->mbox) < NFP_MBOX_SYM_MIN_SIZE) {
nfp_err(pf->cpp, "PF mailbox symbol too small: %llu < %d\n", nfp_err(pf->cpp, "PF mailbox symbol too small: %llu < %d\n",
pf->mbox->size, NFP_MBOX_SYM_MIN_SIZE); nfp_rtsym_size(pf->mbox), NFP_MBOX_SYM_MIN_SIZE);
return -EINVAL; return -EINVAL;
} }
......
...@@ -188,21 +188,21 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl) ...@@ -188,21 +188,21 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
const struct nfp_rtsym *specsym; const struct nfp_rtsym *specsym;
struct nfp_dumpspec *dumpspec; struct nfp_dumpspec *dumpspec;
int bytes_read; int bytes_read;
u64 sym_size;
specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM); specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM);
if (!specsym) if (!specsym)
return NULL; return NULL;
sym_size = nfp_rtsym_size(specsym);
/* expected size of this buffer is in the order of tens of kilobytes */ /* expected size of this buffer is in the order of tens of kilobytes */
dumpspec = vmalloc(sizeof(*dumpspec) + specsym->size); dumpspec = vmalloc(sizeof(*dumpspec) + sym_size);
if (!dumpspec) if (!dumpspec)
return NULL; return NULL;
dumpspec->size = sym_size;
dumpspec->size = specsym->size; bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data, sym_size);
if (bytes_read != sym_size) {
bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data,
specsym->size);
if (bytes_read != specsym->size) {
vfree(dumpspec); vfree(dumpspec);
nfp_warn(cpp, "Debug dump specification read failed.\n"); nfp_warn(cpp, "Debug dump specification read failed.\n");
return NULL; return NULL;
...@@ -262,7 +262,6 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec) ...@@ -262,7 +262,6 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec)
struct nfp_dumpspec_rtsym *spec_rtsym; struct nfp_dumpspec_rtsym *spec_rtsym;
const struct nfp_rtsym *sym; const struct nfp_rtsym *sym;
u32 tl_len, key_len; u32 tl_len, key_len;
u32 size;
spec_rtsym = (struct nfp_dumpspec_rtsym *)spec; spec_rtsym = (struct nfp_dumpspec_rtsym *)spec;
tl_len = be32_to_cpu(spec->length); tl_len = be32_to_cpu(spec->length);
...@@ -274,13 +273,8 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec) ...@@ -274,13 +273,8 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec)
if (!sym) if (!sym)
return nfp_dump_error_tlv_size(spec); return nfp_dump_error_tlv_size(spec);
if (sym->type == NFP_RTSYM_TYPE_ABS)
size = sizeof(sym->addr);
else
size = sym->size;
return ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1) + return ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1) +
ALIGN8(size); ALIGN8(nfp_rtsym_size(sym));
} }
static int static int
...@@ -652,11 +646,7 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec, ...@@ -652,11 +646,7 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
if (!sym) if (!sym)
return nfp_dump_error_tlv(&spec->tl, -ENOENT, dump); return nfp_dump_error_tlv(&spec->tl, -ENOENT, dump);
if (sym->type == NFP_RTSYM_TYPE_ABS) sym_size = nfp_rtsym_size(sym);
sym_size = sizeof(sym->addr);
else
sym_size = sym->size;
header_size = header_size =
ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1); ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1);
total_size = header_size + ALIGN8(sym_size); total_size = header_size + ALIGN8(sym_size);
...@@ -671,21 +661,20 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec, ...@@ -671,21 +661,20 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
memcpy(dump_header->rtsym, spec->rtsym, key_len + 1); memcpy(dump_header->rtsym, spec->rtsym, key_len + 1);
dump_header->cpp.dump_length = cpu_to_be32(sym_size); dump_header->cpp.dump_length = cpu_to_be32(sym_size);
if (sym->type == NFP_RTSYM_TYPE_ABS) { if (sym->type != NFP_RTSYM_TYPE_ABS) {
*(u64 *)dest = sym->addr;
} else {
cpp_params.target = sym->target; cpp_params.target = sym->target;
cpp_params.action = NFP_CPP_ACTION_RW; cpp_params.action = NFP_CPP_ACTION_RW;
cpp_params.token = 0; cpp_params.token = 0;
cpp_params.island = sym->domain; cpp_params.island = sym->domain;
dump_header->cpp.cpp_id = cpp_params; dump_header->cpp.cpp_id = cpp_params;
dump_header->cpp.offset = cpu_to_be32(sym->addr); dump_header->cpp.offset = cpu_to_be32(sym->addr);
bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size); }
if (bytes_read != sym_size) {
if (bytes_read >= 0) bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size);
bytes_read = -EIO; if (bytes_read != sym_size) {
dump_header->error = cpu_to_be32(bytes_read); if (bytes_read >= 0)
} bytes_read = -EIO;
dump_header->error = cpu_to_be32(bytes_read);
} }
return 0; return 0;
......
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