]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
nfp: make RTsym users handle absolute symbols correctly
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 28 Aug 2018 20:20:47 +0000 (13:20 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 28 Aug 2018 23:01:47 +0000 (16:01 -0700)
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>
drivers/net/ethernet/netronome/nfp/abm/ctrl.c
drivers/net/ethernet/netronome/nfp/nfp_main.c
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c

index 53fb40aa83db15a304924db22284864b296963c0..5b06f07c78cd42b3d50ba357b643e9c784a93203 100644 (file)
@@ -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);
                return ERR_PTR(-ENOENT);
        }
-       if (sym->size != size) {
+       if (nfp_rtsym_size(sym) != size) {
                nfp_err(pf->cpp,
                        "Symbol '%s' wrong size: expected %u got %llu\n",
-                       name, size, sym->size);
+                       name, size, nfp_rtsym_size(sym));
                return ERR_PTR(-EINVAL);
        }
 
index 61b4b2055784b2899d6dcff927f7f9274ef659d3..9474a4eed8ce5f710c002c99e500fc246949687e 100644 (file)
@@ -124,7 +124,7 @@ int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length,
        if (!pf->mbox)
                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 */
        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)
        /* Optional per-PCI PF mailbox */
        snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id);
        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",
-                       pf->mbox->size, NFP_MBOX_SYM_MIN_SIZE);
+                       nfp_rtsym_size(pf->mbox), NFP_MBOX_SYM_MIN_SIZE);
                return -EINVAL;
        }
 
index 242c9363e9e8751c767cce7a1d1e7d33bbc66bb7..b6b897840ac56d50ea5e289f58be9e4016f1e0e1 100644 (file)
@@ -188,21 +188,21 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
        const struct nfp_rtsym *specsym;
        struct nfp_dumpspec *dumpspec;
        int bytes_read;
+       u64 sym_size;
 
        specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM);
        if (!specsym)
                return NULL;
+       sym_size = nfp_rtsym_size(specsym);
 
        /* 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)
                return NULL;
+       dumpspec->size = sym_size;
 
-       dumpspec->size = specsym->size;
-
-       bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data,
-                                   specsym->size);
-       if (bytes_read != specsym->size) {
+       bytes_read = nfp_rtsym_read(cpp, specsym, 0, dumpspec->data, sym_size);
+       if (bytes_read != sym_size) {
                vfree(dumpspec);
                nfp_warn(cpp, "Debug dump specification read failed.\n");
                return NULL;
@@ -262,7 +262,6 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec)
        struct nfp_dumpspec_rtsym *spec_rtsym;
        const struct nfp_rtsym *sym;
        u32 tl_len, key_len;
-       u32 size;
 
        spec_rtsym = (struct nfp_dumpspec_rtsym *)spec;
        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)
        if (!sym)
                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) +
-              ALIGN8(size);
+              ALIGN8(nfp_rtsym_size(sym));
 }
 
 static int
@@ -652,11 +646,7 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
        if (!sym)
                return nfp_dump_error_tlv(&spec->tl, -ENOENT, dump);
 
-       if (sym->type == NFP_RTSYM_TYPE_ABS)
-               sym_size = sizeof(sym->addr);
-       else
-               sym_size = sym->size;
-
+       sym_size = nfp_rtsym_size(sym);
        header_size =
                ALIGN8(offsetof(struct nfp_dump_rtsym, rtsym) + key_len + 1);
        total_size = header_size + ALIGN8(sym_size);
@@ -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);
        dump_header->cpp.dump_length = cpu_to_be32(sym_size);
 
-       if (sym->type == NFP_RTSYM_TYPE_ABS) {
-               *(u64 *)dest = sym->addr;
-       } else {
+       if (sym->type != NFP_RTSYM_TYPE_ABS) {
                cpp_params.target = sym->target;
                cpp_params.action = NFP_CPP_ACTION_RW;
                cpp_params.token  = 0;
                cpp_params.island = sym->domain;
                dump_header->cpp.cpp_id = cpp_params;
                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 = -EIO;
-                       dump_header->error = cpu_to_be32(bytes_read);
-               }
+       }
+
+       bytes_read = nfp_rtsym_read(pf->cpp, sym, 0, dest, sym_size);
+       if (bytes_read != sym_size) {
+               if (bytes_read >= 0)
+                       bytes_read = -EIO;
+               dump_header->error = cpu_to_be32(bytes_read);
        }
 
        return 0;