forked from mirrors/linux
		
	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: 23205e6d06 ("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>
			
			
This commit is contained in:
		
							parent
							
								
									f41b2d67d7
								
							
						
					
					
						commit
						f788409714
					
				
					 1 changed files with 29 additions and 17 deletions
				
			
		|  | @ -234,12 +234,14 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | ||||||
| 					  char __user *buffer, | 					  char __user *buffer, | ||||||
| 					  size_t count, loff_t *ppos) | 					  size_t count, loff_t *ppos) | ||||||
| { | { | ||||||
| 	int index, off = 0, flag = 0, go_back = 0, off_prev; | 	int index, off = 0, flag = 0, go_back = 0, len = 0; | ||||||
| 	struct rvu *rvu = filp->private_data; | 	struct rvu *rvu = filp->private_data; | ||||||
| 	int lf, pf, vf, pcifunc; | 	int lf, pf, vf, pcifunc; | ||||||
| 	struct rvu_block block; | 	struct rvu_block block; | ||||||
| 	int bytes_not_copied; | 	int bytes_not_copied; | ||||||
|  | 	int lf_str_size = 12; | ||||||
| 	int buf_size = 2048; | 	int buf_size = 2048; | ||||||
|  | 	char *lfs; | ||||||
| 	char *buf; | 	char *buf; | ||||||
| 
 | 
 | ||||||
| 	/* don't allow partial reads */ | 	/* don't allow partial reads */ | ||||||
|  | @ -249,12 +251,18 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | ||||||
| 	buf = kzalloc(buf_size, GFP_KERNEL); | 	buf = kzalloc(buf_size, GFP_KERNEL); | ||||||
| 	if (!buf) | 	if (!buf) | ||||||
| 		return -ENOSPC; | 		return -ENOSPC; | ||||||
| 	off +=	scnprintf(&buf[off], buf_size - 1 - off, "\npcifunc\t\t"); | 
 | ||||||
|  | 	lfs = kzalloc(lf_str_size, GFP_KERNEL); | ||||||
|  | 	if (!lfs) | ||||||
|  | 		return -ENOMEM; | ||||||
|  | 	off +=	scnprintf(&buf[off], buf_size - 1 - off, "%-*s", lf_str_size, | ||||||
|  | 			  "pcifunc"); | ||||||
| 	for (index = 0; index < BLK_COUNT; index++) | 	for (index = 0; index < BLK_COUNT; index++) | ||||||
| 		if (strlen(rvu->hw->block[index].name)) | 		if (strlen(rvu->hw->block[index].name)) { | ||||||
| 			off += scnprintf(&buf[off], buf_size - 1 - off, | 			off += scnprintf(&buf[off], buf_size - 1 - off, | ||||||
| 					  "%*s\t", (index - 1) * 2, | 					 "%-*s", lf_str_size, | ||||||
| 					 rvu->hw->block[index].name); | 					 rvu->hw->block[index].name); | ||||||
|  | 		} | ||||||
| 	off += scnprintf(&buf[off], buf_size - 1 - off, "\n"); | 	off += scnprintf(&buf[off], buf_size - 1 - off, "\n"); | ||||||
| 	for (pf = 0; pf < rvu->hw->total_pfs; pf++) { | 	for (pf = 0; pf < rvu->hw->total_pfs; pf++) { | ||||||
| 		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) { | 		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) { | ||||||
|  | @ -263,14 +271,15 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | ||||||
| 				continue; | 				continue; | ||||||
| 
 | 
 | ||||||
| 			if (vf) { | 			if (vf) { | ||||||
|  | 				sprintf(lfs, "PF%d:VF%d", pf, vf - 1); | ||||||
| 				go_back = scnprintf(&buf[off], | 				go_back = scnprintf(&buf[off], | ||||||
| 						    buf_size - 1 - off, | 						    buf_size - 1 - off, | ||||||
| 						    "PF%d:VF%d\t\t", pf, | 						    "%-*s", lf_str_size, lfs); | ||||||
| 						    vf - 1); |  | ||||||
| 			} else { | 			} else { | ||||||
|  | 				sprintf(lfs, "PF%d", pf); | ||||||
| 				go_back = scnprintf(&buf[off], | 				go_back = scnprintf(&buf[off], | ||||||
| 						    buf_size - 1 - off, | 						    buf_size - 1 - off, | ||||||
| 						    "PF%d\t\t", pf); | 						    "%-*s", lf_str_size, lfs); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			off += go_back; | 			off += go_back; | ||||||
|  | @ -278,20 +287,22 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | ||||||
| 				block = rvu->hw->block[index]; | 				block = rvu->hw->block[index]; | ||||||
| 				if (!strlen(block.name)) | 				if (!strlen(block.name)) | ||||||
| 					continue; | 					continue; | ||||||
| 				off_prev = off; | 				len = 0; | ||||||
|  | 				lfs[len] = '\0'; | ||||||
| 				for (lf = 0; lf < block.lf.max; lf++) { | 				for (lf = 0; lf < block.lf.max; lf++) { | ||||||
| 					if (block.fn_map[lf] != pcifunc) | 					if (block.fn_map[lf] != pcifunc) | ||||||
| 						continue; | 						continue; | ||||||
| 					flag = 1; | 					flag = 1; | ||||||
| 					off += scnprintf(&buf[off], buf_size - 1 | 					len += sprintf(&lfs[len], "%d,", lf); | ||||||
| 							- off, "%3d,", lf); |  | ||||||
| 				} | 				} | ||||||
| 				if (flag && off_prev != off) | 
 | ||||||
| 					off--; | 				if (flag) | ||||||
| 				else | 					len--; | ||||||
| 					go_back++; | 				lfs[len] = '\0'; | ||||||
| 				off += scnprintf(&buf[off], buf_size - 1 - off, | 				off += scnprintf(&buf[off], buf_size - 1 - off, | ||||||
| 						"\t"); | 						 "%-*s", lf_str_size, lfs); | ||||||
|  | 				if (!strlen(lfs)) | ||||||
|  | 					go_back += lf_str_size; | ||||||
| 			} | 			} | ||||||
| 			if (!flag) | 			if (!flag) | ||||||
| 				off -= go_back; | 				off -= go_back; | ||||||
|  | @ -303,6 +314,7 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	bytes_not_copied = copy_to_user(buffer, buf, off); | 	bytes_not_copied = copy_to_user(buffer, buf, off); | ||||||
|  | 	kfree(lfs); | ||||||
| 	kfree(buf); | 	kfree(buf); | ||||||
| 
 | 
 | ||||||
| 	if (bytes_not_copied) | 	if (bytes_not_copied) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Rakesh Babu
						Rakesh Babu