]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nfp: load debug dump spec
authorCarl Heymann <carl.heymann@netronome.com>
Mon, 4 Dec 2017 22:34:13 +0000 (23:34 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Dec 2017 20:01:01 +0000 (15:01 -0500)
Load the TLV-based binary specification of what needs to be included in
a dump, from the "_abi_dump_spec" rtsymbol. If the symbol is not defined,
then dumps for levels >= 1 are not supported.

Signed-off-by: Carl Heymann <carl.heymann@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net_debugdump.c

index a7061b6c609d35c288d5fa64c8aba4c9073b8bec..15b6623ef0b24c824af78488bad525bb3c09ee5f 100644 (file)
  */
 
 #include <linux/ethtool.h>
+#include <linux/vmalloc.h>
 
 #include "nfp_main.h"
+#include "nfpcore/nfp.h"
+#include "nfpcore/nfp_nffw.h"
+
+#define NFP_DUMP_SPEC_RTSYM    "_abi_dump_spec"
 
 struct nfp_dumpspec *
 nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
 {
-       return NULL;
+       const struct nfp_rtsym *specsym;
+       struct nfp_dumpspec *dumpspec;
+       int bytes_read;
+       u32 cpp_id;
+
+       specsym = nfp_rtsym_lookup(rtbl, NFP_DUMP_SPEC_RTSYM);
+       if (!specsym)
+               return NULL;
+
+       /* expected size of this buffer is in the order of tens of kilobytes */
+       dumpspec = vmalloc(sizeof(*dumpspec) + specsym->size);
+       if (!dumpspec)
+               return NULL;
+
+       dumpspec->size = specsym->size;
+
+       cpp_id = NFP_CPP_ISLAND_ID(specsym->target, NFP_CPP_ACTION_RW, 0,
+                                  specsym->domain);
+
+       bytes_read = nfp_cpp_read(cpp, cpp_id, specsym->addr, dumpspec->data,
+                                 specsym->size);
+       if (bytes_read != specsym->size) {
+               vfree(dumpspec);
+               nfp_warn(cpp, "Debug dump specification read failed.\n");
+               return NULL;
+       }
+
+       return dumpspec;
 }
 
 s64 nfp_net_dump_calculate_size(struct nfp_pf *pf, struct nfp_dumpspec *spec,