aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
diff options
context:
space:
mode:
authorIvan Vecera <[email protected]>2023-11-24 15:03:41 +0000
committerTony Nguyen <[email protected]>2024-02-16 17:28:14 +0000
commitb7fac08db5e32a7de8c53e50dc7c841d123dda05 (patch)
tree989f4a5fd40e0d4e5e19b333b1540b4ba73b6ed7 /drivers/net/ethernet/intel/i40e/i40e_debugfs.c
parenti40e: Introduce and use macros for iterating VSIs and VEBs (diff)
downloadkernel-b7fac08db5e32a7de8c53e50dc7c841d123dda05.tar.gz
kernel-b7fac08db5e32a7de8c53e50dc7c841d123dda05.zip
i40e: Add helpers to find VSI and VEB by SEID and use them
Add two helpers i40e_(veb|vsi)_get_by_seid() to find corresponding VEB or VSI by their SEID value and use these helpers to replace existing open-coded loops. Reviewed-by: Wojciech Drewek <[email protected]> Signed-off-by: Ivan Vecera <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_debugfs.c')
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_debugfs.c38
1 files changed, 5 insertions, 33 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index b236b0f93202..990a60889eef 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -24,37 +24,13 @@ enum ring_type {
**/
static struct i40e_vsi *i40e_dbg_find_vsi(struct i40e_pf *pf, int seid)
{
- struct i40e_vsi *vsi;
- int i;
-
if (seid < 0) {
dev_info(&pf->pdev->dev, "%d: bad seid\n", seid);
return NULL;
}
- i40e_pf_for_each_vsi(pf, i, vsi)
- if (vsi->seid == seid)
- return vsi;
-
- return NULL;
-}
-
-/**
- * i40e_dbg_find_veb - searches for the veb with the given seid
- * @pf: the PF structure to search for the veb
- * @seid: seid of the veb it is searching for
- **/
-static struct i40e_veb *i40e_dbg_find_veb(struct i40e_pf *pf, int seid)
-{
- struct i40e_veb *veb;
- int i;
-
- i40e_pf_for_each_veb(pf, i, veb)
- if (veb->seid == seid)
- return veb;
-
- return NULL;
+ return i40e_pf_get_vsi_by_seid(pf, seid);
}
/**************************************************************
@@ -701,7 +677,7 @@ static void i40e_dbg_dump_veb_seid(struct i40e_pf *pf, int seid)
{
struct i40e_veb *veb;
- veb = i40e_dbg_find_veb(pf, seid);
+ veb = i40e_pf_get_veb_by_seid(pf, seid);
if (!veb) {
dev_info(&pf->pdev->dev, "can't find veb %d\n", seid);
return;
@@ -853,7 +829,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
} else if (strncmp(cmd_buf, "add relay", 9) == 0) {
struct i40e_veb *veb;
- int uplink_seid, i;
+ int uplink_seid;
cnt = sscanf(&cmd_buf[9], "%i %i", &uplink_seid, &vsi_seid);
if (cnt != 2) {
@@ -875,12 +851,8 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
goto command_write_done;
}
- i40e_pf_for_each_veb(pf, i, veb)
- if (veb->seid == uplink_seid)
- break;
-
- if (i >= I40E_MAX_VEB && uplink_seid != 0 &&
- uplink_seid != pf->mac_seid) {
+ veb = i40e_pf_get_veb_by_seid(pf, uplink_seid);
+ if (!veb && uplink_seid != 0 && uplink_seid != pf->mac_seid) {
dev_info(&pf->pdev->dev,
"add relay: relay uplink %d not found\n",
uplink_seid);