Skip to content

Commit 4152e58

Browse files
Jakub Kicinskidavem330
authored andcommitted
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: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Francois H. Theron <francois.theron@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 640917d commit 4152e58

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

drivers/net/ethernet/netronome/nfp/abm/ctrl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ nfp_abm_ctrl_find_rtsym(struct nfp_pf *pf, const char *name, unsigned int size)
280280
nfp_err(pf->cpp, "Symbol '%s' not found\n", name);
281281
return ERR_PTR(-ENOENT);
282282
}
283-
if (sym->size != size) {
283+
if (nfp_rtsym_size(sym) != size) {
284284
nfp_err(pf->cpp,
285285
"Symbol '%s' wrong size: expected %u got %llu\n",
286-
name, size, sym->size);
286+
name, size, nfp_rtsym_size(sym));
287287
return ERR_PTR(-EINVAL);
288288
}
289289

drivers/net/ethernet/netronome/nfp/nfp_main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
124124
if (!pf->mbox)
125125
return -EOPNOTSUPP;
126126

127-
max_data_sz = pf->mbox->size - NFP_MBOX_SYM_MIN_SIZE;
127+
max_data_sz = nfp_rtsym_size(pf->mbox) - NFP_MBOX_SYM_MIN_SIZE;
128128

129129
/* Check if cmd field is clear */
130130
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)
566566
/* Optional per-PCI PF mailbox */
567567
snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id);
568568
pf->mbox = nfp_rtsym_lookup(pf->rtbl, pf_symbol);
569-
if (pf->mbox && pf->mbox->size < NFP_MBOX_SYM_MIN_SIZE) {
569+
if (pf->mbox && nfp_rtsym_size(pf->mbox) < NFP_MBOX_SYM_MIN_SIZE) {
570570
nfp_err(pf->cpp, "PF mailbox symbol too small: %llu < %d\n",
571-
pf->mbox->size, NFP_MBOX_SYM_MIN_SIZE);
571+
nfp_rtsym_size(pf->mbox), NFP_MBOX_SYM_MIN_SIZE);
572572
return -EINVAL;
573573
}
574574

drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,21 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
188188
const struct nfp_rtsym *specsym;
189189
struct nfp_dumpspec *dumpspec;
190190
int bytes_read;
191+
u64 sym_size;
191192

192193
specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM);
193194
if (!specsym)
194195
return NULL;
196+
sym_size = nfp_rtsym_size(specsym);
195197

196198
/* expected size of this buffer is in the order of tens of kilobytes */
197-
dumpspec = vmalloc(sizeof(*dumpspec) + specsym->size);
199+
dumpspec = vmalloc(sizeof(*dumpspec) + sym_size);
198200
if (!dumpspec)
199201
return NULL;
202+
dumpspec->size = sym_size;
200203

201-
dumpspec->size = specsym->size;
202-
203-
bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data,
204-
specsym->size);
205-
if (bytes_read != specsym->size) {
204+
bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data, sym_size);
205+
if (bytes_read != sym_size) {
206206
vfree(dumpspec);
207207
nfp_warn(cpp, "Debug dump specification read failed.\n");
208208
return NULL;
@@ -262,7 +262,6 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec)
262262
struct nfp_dumpspec_rtsym *spec_rtsym;
263263
const struct nfp_rtsym *sym;
264264
u32 tl_len, key_len;
265-
u32 size;
266265

267266
spec_rtsym = (struct nfp_dumpspec_rtsym *)spec;
268267
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)
274273
if (!sym)
275274
return nfp_dump_error_tlv_size(spec);
276275

277-
if (sym->type == NFP_RTSYM_TYPE_ABS)
278-
size = sizeof(sym->addr);
279-
else
280-
size = sym->size;
281-
282276
return ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1) +
283-
ALIGN8(size);
277+
ALIGN8(nfp_rtsym_size(sym));
284278
}
285279

286280
static int
@@ -652,11 +646,7 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
652646
if (!sym)
653647
return nfp_dump_error_tlv(&spec->tl, -ENOENT, dump);
654648

655-
if (sym->type == NFP_RTSYM_TYPE_ABS)
656-
sym_size = sizeof(sym->addr);
657-
else
658-
sym_size = sym->size;
659-
649+
sym_size = nfp_rtsym_size(sym);
660650
header_size =
661651
ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1);
662652
total_size = header_size + ALIGN8(sym_size);
@@ -671,21 +661,20 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
671661
memcpy(dump_header->rtsym, spec->rtsym, key_len + 1);
672662
dump_header->cpp.dump_length = cpu_to_be32(sym_size);
673663

674-
if (sym->type == NFP_RTSYM_TYPE_ABS) {
675-
*(u64 *)dest = sym->addr;
676-
} else {
664+
if (sym->type != NFP_RTSYM_TYPE_ABS) {
677665
cpp_params.target = sym->target;
678666
cpp_params.action = NFP_CPP_ACTION_RW;
679667
cpp_params.token = 0;
680668
cpp_params.island = sym->domain;
681669
dump_header->cpp.cpp_id = cpp_params;
682670
dump_header->cpp.offset = cpu_to_be32(sym->addr);
683-
bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size);
684-
if (bytes_read != sym_size) {
685-
if (bytes_read >= 0)
686-
bytes_read = -EIO;
687-
dump_header->error = cpu_to_be32(bytes_read);
688-
}
671+
}
672+
673+
bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size);
674+
if (bytes_read != sym_size) {
675+
if (bytes_read >= 0)
676+
bytes_read = -EIO;
677+
dump_header->error = cpu_to_be32(bytes_read);
689678
}
690679

691680
return 0;

0 commit comments

Comments
 (0)