Skip to content

Commit f788409

Browse files
Rakesh Babudavem330
authored andcommitted
octeontx2-af: Formatting debugfs entry rsrc_alloc.
With the existing rsrc_alloc's format, there is misalignment for the pcifunc entries whose VF's index is a double digit. This patch fixes this. pcifunc NPA NIX0 NIX1 SSO GROUP SSOWS TIM CPT0 CPT1 REE0 REE1 PF0:VF0 8 5 PF0:VF1 9 3 PF0:VF10 18 10 PF0:VF11 19 8 PF0:VF12 20 11 PF0:VF13 21 9 PF0:VF14 22 12 PF0:VF15 23 10 PF1 0 0 Fixes: 23205e6 ("octeontx2-af: Dump current resource provisioning status") Signed-off-by: Rakesh Babu <rsaladi2@marvell.com> Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f41b2d6 commit f788409

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

‎drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
234234
char __user *buffer,
235235
size_t count, loff_t *ppos)
236236
{
237-
int index, off = 0, flag = 0, go_back = 0, off_prev;
237+
int index, off = 0, flag = 0, go_back = 0, len = 0;
238238
struct rvu *rvu = filp->private_data;
239239
int lf, pf, vf, pcifunc;
240240
struct rvu_block block;
241241
int bytes_not_copied;
242+
int lf_str_size = 12;
242243
int buf_size = 2048;
244+
char *lfs;
243245
char *buf;
244246

245247
/* don't allow partial reads */
@@ -249,12 +251,18 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
249251
buf = kzalloc(buf_size, GFP_KERNEL);
250252
if (!buf)
251253
return -ENOSPC;
252-
off += scnprintf(&buf[off], buf_size - 1 - off, "\npcifunc\t\t");
254+
255+
lfs = kzalloc(lf_str_size, GFP_KERNEL);
256+
if (!lfs)
257+
return -ENOMEM;
258+
off += scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size,
259+
"pcifunc");
253260
for (index = 0; index < BLK_COUNT; index++)
254-
if (strlen(rvu->hw->block[index].name))
255-
off += scnprintf(&buf[off], buf_size - 1 - off,
256-
"%*s\t", (index - 1) * 2,
257-
rvu->hw->block[index].name);
261+
if (strlen(rvu->hw->block[index].name)) {
262+
off += scnprintf(&buf[off], buf_size - 1 - off,
263+
"%-*s", lf_str_size,
264+
rvu->hw->block[index].name);
265+
}
258266
off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
259267
for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
260268
for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
@@ -263,35 +271,38 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
263271
continue;
264272

265273
if (vf) {
274+
sprintf(lfs, "PF%d:VF%d", pf, vf - 1);
266275
go_back = scnprintf(&buf[off],
267276
buf_size - 1 - off,
268-
"PF%d:VF%d\t\t", pf,
269-
vf - 1);
277+
"%-*s", lf_str_size, lfs);
270278
} else {
279+
sprintf(lfs, "PF%d", pf);
271280
go_back = scnprintf(&buf[off],
272281
buf_size - 1 - off,
273-
"PF%d\t\t", pf);
282+
"%-*s", lf_str_size, lfs);
274283
}
275284

276285
off += go_back;
277286
for (index = 0; index < BLKTYPE_MAX; index++) {
278287
block = rvu->hw->block[index];
279288
if (!strlen(block.name))
280289
continue;
281-
off_prev = off;
290+
len = 0;
291+
lfs[len] = '\0';
282292
for (lf = 0; lf < block.lf.max; lf++) {
283293
if (block.fn_map[lf] != pcifunc)
284294
continue;
285295
flag = 1;
286-
off += scnprintf(&buf[off], buf_size - 1
287-
- off, "%3d,", lf);
296+
len += sprintf(&lfs[len], "%d,", lf);
288297
}
289-
if (flag && off_prev != off)
290-
off--;
291-
else
292-
go_back++;
298+
299+
if (flag)
300+
len--;
301+
lfs[len] = '\0';
293302
off += scnprintf(&buf[off], buf_size - 1 - off,
294-
"\t");
303+
"%-*s", lf_str_size, lfs);
304+
if (!strlen(lfs))
305+
go_back += lf_str_size;
295306
}
296307
if (!flag)
297308
off -= go_back;
@@ -303,6 +314,7 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
303314
}
304315

305316
bytes_not_copied = copy_to_user(buffer, buf, off);
317+
kfree(lfs);
306318
kfree(buf);
307319

308320
if (bytes_not_copied)

0 commit comments

Comments
 (0)