@@ -188,21 +188,21 @@ nfp_net_dump_load_dumpspec(struct nfp_cpp *cpp, struct nfp_rtsym_table *rtbl)
188
188
const struct nfp_rtsym * specsym ;
189
189
struct nfp_dumpspec * dumpspec ;
190
190
int bytes_read ;
191
+ u64 sym_size ;
191
192
192
193
specsym = nfp_rtsym_lookup (rtbl , NFP_DUMP_SPEC_RTSYM );
193
194
if (!specsym )
194
195
return NULL ;
196
+ sym_size = nfp_rtsym_size (specsym );
195
197
196
198
/* 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 );
198
200
if (!dumpspec )
199
201
return NULL ;
202
+ dumpspec -> size = sym_size ;
200
203
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 ) {
206
206
vfree (dumpspec );
207
207
nfp_warn (cpp , "Debug dump specification read failed.\n" );
208
208
return NULL ;
@@ -262,7 +262,6 @@ nfp_calc_rtsym_dump_sz(struct nfp_pf *pf, struct nfp_dump_tl *spec)
262
262
struct nfp_dumpspec_rtsym * spec_rtsym ;
263
263
const struct nfp_rtsym * sym ;
264
264
u32 tl_len , key_len ;
265
- u32 size ;
266
265
267
266
spec_rtsym = (struct nfp_dumpspec_rtsym * )spec ;
268
267
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
273
if (!sym )
275
274
return nfp_dump_error_tlv_size (spec );
276
275
277
- if (sym -> type == NFP_RTSYM_TYPE_ABS )
278
- size = sizeof (sym -> addr );
279
- else
280
- size = sym -> size ;
281
-
282
276
return ALIGN8 (offsetof(struct nfp_dump_rtsym , rtsym ) + key_len + 1 ) +
283
- ALIGN8 (size );
277
+ ALIGN8 (nfp_rtsym_size ( sym ) );
284
278
}
285
279
286
280
static int
@@ -652,11 +646,7 @@ nfp_dump_single_rtsym(struct nfp_pf *pf, struct nfp_dumpspec_rtsym *spec,
652
646
if (!sym )
653
647
return nfp_dump_error_tlv (& spec -> tl , - ENOENT , dump );
654
648
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 );
660
650
header_size =
661
651
ALIGN8 (offsetof(struct nfp_dump_rtsym , rtsym ) + key_len + 1 );
662
652
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
661
memcpy (dump_header -> rtsym , spec -> rtsym , key_len + 1 );
672
662
dump_header -> cpp .dump_length = cpu_to_be32 (sym_size );
673
663
674
- if (sym -> type == NFP_RTSYM_TYPE_ABS ) {
675
- * (u64 * )dest = sym -> addr ;
676
- } else {
664
+ if (sym -> type != NFP_RTSYM_TYPE_ABS ) {
677
665
cpp_params .target = sym -> target ;
678
666
cpp_params .action = NFP_CPP_ACTION_RW ;
679
667
cpp_params .token = 0 ;
680
668
cpp_params .island = sym -> domain ;
681
669
dump_header -> cpp .cpp_id = cpp_params ;
682
670
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 );
689
678
}
690
679
691
680
return 0 ;
0 commit comments