Skip to content

Commit 3aa7b74

Browse files
Filip SadowskiJeff Kirsher
authored andcommitted
i40e: removed unreachable code
Removed some of unnecessary if statements and unreachable code found by static code analysis tool. The return value of i40e_vsi_control_rings(..., false) is always 0. So, test for non-zero will never be true. The function has been split into "int i40e_vsi_start_rings()" and "void i40e_vsi_stop_rings()" for better understanding. Similarly, the function i40e_vsi_kill_vlan() never fails. So, checking for return value is also unnecessary. Function definition changed to void. The i40e_loopback_test() function is not implemented. The function and all references to loopback testing were removed. Change-ID: Id45cf66f6689ce2bc4e887de13f073e30e8431bd Signed-off-by: Filip Sadowski <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 81fa7c9 commit 3aa7b74

File tree

4 files changed

+33
-60
lines changed

4 files changed

+33
-60
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ void i40e_service_event_schedule(struct i40e_pf *pf);
773773
void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
774774
u8 *msg, u16 len);
775775

776-
int i40e_vsi_control_rings(struct i40e_vsi *vsi, bool enable);
776+
int i40e_vsi_start_rings(struct i40e_vsi *vsi);
777+
void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
777778
int i40e_reconfig_rss_queues(struct i40e_pf *pf, int queue_count);
778779
struct i40e_veb *i40e_veb_setup(struct i40e_pf *pf, u16 flags, u16 uplink_seid,
779780
u16 downlink_seid, u8 enabled_tc);
@@ -849,7 +850,7 @@ int i40e_close(struct net_device *netdev);
849850
int i40e_vsi_open(struct i40e_vsi *vsi);
850851
void i40e_vlan_stripping_disable(struct i40e_vsi *vsi);
851852
int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid);
852-
int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
853+
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid);
853854
struct i40e_mac_filter *i40e_put_mac_in_vlan(struct i40e_vsi *vsi,
854855
const u8 *macaddr);
855856
int i40e_del_mac_all_vlan(struct i40e_vsi *vsi, const u8 *macaddr);

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,13 @@ enum i40e_ethtool_test_id {
216216
I40E_ETH_TEST_REG = 0,
217217
I40E_ETH_TEST_EEPROM,
218218
I40E_ETH_TEST_INTR,
219-
I40E_ETH_TEST_LOOPBACK,
220219
I40E_ETH_TEST_LINK,
221220
};
222221

223222
static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = {
224223
"Register test (offline)",
225224
"Eeprom test (offline)",
226225
"Interrupt test (offline)",
227-
"Loopback test (offline)",
228226
"Link test (on/offline)"
229227
};
230228

@@ -1744,17 +1742,6 @@ static int i40e_intr_test(struct net_device *netdev, u64 *data)
17441742
return *data;
17451743
}
17461744

1747-
static int i40e_loopback_test(struct net_device *netdev, u64 *data)
1748-
{
1749-
struct i40e_netdev_priv *np = netdev_priv(netdev);
1750-
struct i40e_pf *pf = np->vsi->back;
1751-
1752-
netif_info(pf, hw, netdev, "loopback test not implemented\n");
1753-
*data = 0;
1754-
1755-
return *data;
1756-
}
1757-
17581745
static inline bool i40e_active_vfs(struct i40e_pf *pf)
17591746
{
17601747
struct i40e_vf *vfs = pf->vf;
@@ -1790,7 +1777,6 @@ static void i40e_diag_test(struct net_device *netdev,
17901777
data[I40E_ETH_TEST_REG] = 1;
17911778
data[I40E_ETH_TEST_EEPROM] = 1;
17921779
data[I40E_ETH_TEST_INTR] = 1;
1793-
data[I40E_ETH_TEST_LOOPBACK] = 1;
17941780
data[I40E_ETH_TEST_LINK] = 1;
17951781
eth_test->flags |= ETH_TEST_FL_FAILED;
17961782
clear_bit(__I40E_TESTING, &pf->state);
@@ -1818,9 +1804,6 @@ static void i40e_diag_test(struct net_device *netdev,
18181804
if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR]))
18191805
eth_test->flags |= ETH_TEST_FL_FAILED;
18201806

1821-
if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK]))
1822-
eth_test->flags |= ETH_TEST_FL_FAILED;
1823-
18241807
/* run reg test last, a reset is required after it */
18251808
if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG]))
18261809
eth_test->flags |= ETH_TEST_FL_FAILED;
@@ -1841,7 +1824,6 @@ static void i40e_diag_test(struct net_device *netdev,
18411824
data[I40E_ETH_TEST_REG] = 0;
18421825
data[I40E_ETH_TEST_EEPROM] = 0;
18431826
data[I40E_ETH_TEST_INTR] = 0;
1844-
data[I40E_ETH_TEST_LOOPBACK] = 0;
18451827
}
18461828

18471829
skip_ol_tests:

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2503,10 +2503,8 @@ int i40e_vsi_add_vlan(struct i40e_vsi *vsi, s16 vid)
25032503
* i40e_vsi_kill_vlan - Remove vsi membership for given vlan
25042504
* @vsi: the vsi being configured
25052505
* @vid: vlan id to be removed (0 = untagged only , -1 = any)
2506-
*
2507-
* Return: 0 on success or negative otherwise
25082506
**/
2509-
int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
2507+
void i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
25102508
{
25112509
struct net_device *netdev = vsi->netdev;
25122510
struct i40e_mac_filter *f;
@@ -2530,7 +2528,6 @@ int i40e_vsi_kill_vlan(struct i40e_vsi *vsi, s16 vid)
25302528
* applying the new filter changes
25312529
*/
25322530
i40e_service_event_schedule(vsi->back);
2533-
return 0;
25342531
}
25352532

25362533
/**
@@ -4017,29 +4014,35 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
40174014
}
40184015

40194016
/**
4020-
* i40e_vsi_control_rings - Start or stop a VSI's rings
4017+
* i40e_vsi_start_rings - Start a VSI's rings
40214018
* @vsi: the VSI being configured
4022-
* @enable: start or stop the rings
40234019
**/
4024-
int i40e_vsi_control_rings(struct i40e_vsi *vsi, bool request)
4020+
int i40e_vsi_start_rings(struct i40e_vsi *vsi)
40254021
{
40264022
int ret = 0;
40274023

40284024
/* do rx first for enable and last for disable */
4029-
if (request) {
4030-
ret = i40e_vsi_control_rx(vsi, request);
4031-
if (ret)
4032-
return ret;
4033-
ret = i40e_vsi_control_tx(vsi, request);
4034-
} else {
4035-
/* Ignore return value, we need to shutdown whatever we can */
4036-
i40e_vsi_control_tx(vsi, request);
4037-
i40e_vsi_control_rx(vsi, request);
4038-
}
4025+
ret = i40e_vsi_control_rx(vsi, true);
4026+
if (ret)
4027+
return ret;
4028+
ret = i40e_vsi_control_tx(vsi, true);
40394029

40404030
return ret;
40414031
}
40424032

4033+
/**
4034+
* i40e_vsi_stop_rings - Stop a VSI's rings
4035+
* @vsi: the VSI being configured
4036+
**/
4037+
void i40e_vsi_stop_rings(struct i40e_vsi *vsi)
4038+
{
4039+
/* do rx first for enable and last for disable
4040+
* Ignore return value, we need to shutdown whatever we can
4041+
*/
4042+
i40e_vsi_control_tx(vsi, false);
4043+
i40e_vsi_control_rx(vsi, false);
4044+
}
4045+
40434046
/**
40444047
* i40e_vsi_free_irq - Free the irq association with the OS
40454048
* @vsi: the VSI being configured
@@ -5238,7 +5241,7 @@ static int i40e_up_complete(struct i40e_vsi *vsi)
52385241
i40e_configure_msi_and_legacy(vsi);
52395242

52405243
/* start rings */
5241-
err = i40e_vsi_control_rings(vsi, true);
5244+
err = i40e_vsi_start_rings(vsi);
52425245
if (err)
52435246
return err;
52445247

@@ -5335,7 +5338,7 @@ void i40e_down(struct i40e_vsi *vsi)
53355338
netif_tx_disable(vsi->netdev);
53365339
}
53375340
i40e_vsi_disable_irq(vsi);
5338-
i40e_vsi_control_rings(vsi, false);
5341+
i40e_vsi_stop_rings(vsi);
53395342
i40e_napi_disable_all(vsi);
53405343

53415344
for (i = 0; i < vsi->num_queue_pairs; i++) {

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ void i40e_reset_vf(struct i40e_vf *vf, bool flr)
991991
if (vf->lan_vsi_idx == 0)
992992
goto complete_reset;
993993

994-
i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], false);
994+
i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]);
995995
complete_reset:
996996
/* reallocate VF resources to reset the VSI state */
997997
i40e_free_vf_res(vf);
@@ -1032,8 +1032,7 @@ void i40e_free_vfs(struct i40e_pf *pf)
10321032
i40e_notify_client_of_vf_enable(pf, 0);
10331033
for (i = 0; i < pf->num_alloc_vfs; i++)
10341034
if (test_bit(I40E_VF_STAT_INIT, &pf->vf[i].vf_states))
1035-
i40e_vsi_control_rings(pf->vsi[pf->vf[i].lan_vsi_idx],
1036-
false);
1035+
i40e_vsi_stop_rings(pf->vsi[pf->vf[i].lan_vsi_idx]);
10371036

10381037
/* Disable IOV before freeing resources. This lets any VF drivers
10391038
* running in the host get themselves cleaned up before we yank
@@ -1759,7 +1758,7 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
17591758
goto error_param;
17601759
}
17611760

1762-
if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], true))
1761+
if (i40e_vsi_start_rings(pf->vsi[vf->lan_vsi_idx]))
17631762
aq_ret = I40E_ERR_TIMEOUT;
17641763
error_param:
17651764
/* send the response to the VF */
@@ -1798,8 +1797,7 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
17981797
goto error_param;
17991798
}
18001799

1801-
if (i40e_vsi_control_rings(pf->vsi[vf->lan_vsi_idx], false))
1802-
aq_ret = I40E_ERR_TIMEOUT;
1800+
i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]);
18031801

18041802
error_param:
18051803
/* send the response to the VF */
@@ -2139,9 +2137,8 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
21392137
}
21402138

21412139
for (i = 0; i < vfl->num_elements; i++) {
2142-
int ret = i40e_vsi_kill_vlan(vsi, vfl->vlan_id[i]);
2143-
if (!ret)
2144-
vf->num_vlan--;
2140+
i40e_vsi_kill_vlan(vsi, vfl->vlan_id[i]);
2141+
vf->num_vlan--;
21452142

21462143
if (test_bit(I40E_VF_STAT_UC_PROMISC, &vf->vf_states))
21472144
i40e_aq_set_vsi_uc_promisc_on_vlan(&pf->hw, vsi->seid,
@@ -2153,11 +2150,6 @@ static int i40e_vc_remove_vlan_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
21532150
false,
21542151
vfl->vlan_id[i],
21552152
NULL);
2156-
2157-
if (ret)
2158-
dev_err(&pf->pdev->dev,
2159-
"Unable to delete VLAN filter %d for VF %d, error %d\n",
2160-
vfl->vlan_id[i], vf->vf_id, ret);
21612153
}
21622154

21632155
error_param:
@@ -2835,13 +2827,8 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,
28352827

28362828
if (vsi->info.pvid) {
28372829
/* kill old VLAN */
2838-
ret = i40e_vsi_kill_vlan(vsi, (le16_to_cpu(vsi->info.pvid) &
2839-
VLAN_VID_MASK));
2840-
if (ret) {
2841-
dev_info(&vsi->back->pdev->dev,
2842-
"remove VLAN failed, ret=%d, aq_err=%d\n",
2843-
ret, pf->hw.aq.asq_last_status);
2844-
}
2830+
i40e_vsi_kill_vlan(vsi, (le16_to_cpu(vsi->info.pvid) &
2831+
VLAN_VID_MASK));
28452832
}
28462833
if (vlan_id || qos)
28472834
ret = i40e_vsi_add_pvid(vsi, vlanprio);

0 commit comments

Comments
 (0)