Skip to content

Commit 148c8cb

Browse files
dmertmananguy11
authored andcommitted
ice: Cleanup variable initialization in LAG code
In preparation for implementing SRIOV Active-Active LAG support, cleanup several unneeded variable initializations in declaration blocks. Also move a couple of variable initializations into declaration block that should be there. Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Dave Ertman <[email protected]> Tested-by: Sujai Buvaneswaran <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent b2e9715 commit 148c8cb

File tree

1 file changed

+17
-37
lines changed

1 file changed

+17
-37
lines changed

drivers/net/ethernet/intel/ice/ice_lag.c

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,12 @@ ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx,
234234
u8 direction, bool add)
235235
{
236236
struct ice_sw_rule_lkup_rx_tx *s_rule;
237+
struct ice_hw *hw = &lag->pf->hw;
237238
u16 s_rule_sz, vsi_num;
238-
struct ice_hw *hw;
239239
u8 *eth_hdr;
240240
u32 opc;
241241
int err;
242242

243-
hw = &lag->pf->hw;
244243
vsi_num = ice_get_hw_vsi_num(hw, 0);
245244

246245
s_rule_sz = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE(s_rule);
@@ -384,12 +383,10 @@ ice_lag_cfg_pf_fltrs(struct ice_lag *lag, void *ptr)
384383
static void
385384
ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
386385
{
387-
struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
388-
struct ice_vsi *vsi;
386+
struct ice_sw_rule_lkup_rx_tx *s_rule;
387+
struct ice_vsi *vsi = lag->pf->vsi[0];
389388
u16 buf_len, opc;
390389

391-
vsi = lag->pf->vsi[0];
392-
393390
buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
394391
s_rule = kzalloc(buf_len, GFP_KERNEL);
395392
if (!s_rule) {
@@ -477,12 +474,11 @@ static u16
477474
ice_lag_qbuf_recfg(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
478475
u16 vsi_num, u16 numq, u8 tc)
479476
{
477+
struct ice_pf *pf = hw->back;
480478
struct ice_q_ctx *q_ctx;
481479
u16 qid, count = 0;
482-
struct ice_pf *pf;
483480
int i;
484481

485-
pf = hw->back;
486482
for (i = 0; i < numq; i++) {
487483
q_ctx = ice_get_lan_q_ctx(hw, vsi_num, tc, i);
488484
if (!q_ctx) {
@@ -940,13 +936,12 @@ ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
940936
u16 numq, valq, num_moved, qbuf_size;
941937
u16 buf_size = __struct_size(buf);
942938
struct ice_aqc_cfg_txqs_buf *qbuf;
939+
struct ice_hw *hw = &lag->pf->hw;
943940
struct ice_sched_node *n_prt;
944941
__le32 teid, parent_teid;
945942
struct ice_vsi_ctx *ctx;
946-
struct ice_hw *hw;
947943
u32 tmp_teid;
948944

949-
hw = &lag->pf->hw;
950945
ctx = ice_get_vsi_ctx(hw, vsi_num);
951946
if (!ctx) {
952947
dev_warn(dev, "Unable to locate VSI context for LAG reclaim\n");
@@ -1221,11 +1216,8 @@ ice_lag_set_swid(u16 primary_swid, struct ice_lag *local_lag,
12211216
*/
12221217
static void ice_lag_primary_swid(struct ice_lag *lag, bool link)
12231218
{
1224-
struct ice_hw *hw;
1225-
u16 swid;
1226-
1227-
hw = &lag->pf->hw;
1228-
swid = hw->port_info->sw_id;
1219+
struct ice_hw *hw = &lag->pf->hw;
1220+
u16 swid = hw->port_info->sw_id;
12291221

12301222
if (ice_share_res(hw, ICE_AQC_RES_TYPE_SWID, link, swid))
12311223
dev_warn(ice_pf_to_dev(lag->pf), "Failure to set primary interface shared status\n");
@@ -1238,12 +1230,10 @@ static void ice_lag_primary_swid(struct ice_lag *lag, bool link)
12381230
*/
12391231
static void ice_lag_add_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
12401232
{
1241-
u16 num_vsi, rule_buf_sz, vsi_list_id, event_vsi_num, prim_vsi_idx;
1242-
struct ice_sw_rule_vsi_list *s_rule = NULL;
1233+
u16 rule_buf_sz, vsi_list_id, event_vsi_num, prim_vsi_idx, num_vsi = 1;
1234+
struct ice_sw_rule_vsi_list *s_rule;
12431235
struct device *dev;
12441236

1245-
num_vsi = 1;
1246-
12471237
dev = ice_pf_to_dev(lag->pf);
12481238
event_vsi_num = event_pf->vsi[0]->vsi_num;
12491239
prim_vsi_idx = lag->pf->vsi[0]->idx;
@@ -1279,12 +1269,10 @@ static void ice_lag_add_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
12791269
*/
12801270
static void ice_lag_del_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
12811271
{
1282-
u16 num_vsi, vsi_num, vsi_idx, rule_buf_sz, vsi_list_id;
1283-
struct ice_sw_rule_vsi_list *s_rule = NULL;
1272+
u16 vsi_num, vsi_idx, rule_buf_sz, vsi_list_id, num_vsi = 1;
1273+
struct ice_sw_rule_vsi_list *s_rule;
12841274
struct device *dev;
12851275

1286-
num_vsi = 1;
1287-
12881276
dev = ice_pf_to_dev(lag->pf);
12891277
vsi_num = event_pf->vsi[0]->vsi_num;
12901278
vsi_idx = lag->pf->vsi[0]->idx;
@@ -1707,11 +1695,9 @@ static void ice_lag_chk_disabled_bond(struct ice_lag *lag, void *ptr)
17071695
*/
17081696
static void ice_lag_disable_sriov_bond(struct ice_lag *lag)
17091697
{
1710-
struct ice_netdev_priv *np;
1711-
struct ice_pf *pf;
1698+
struct ice_netdev_priv *np = netdev_priv(lag->netdev);
1699+
struct ice_pf *pf = np->vsi->back;
17121700

1713-
np = netdev_priv(lag->netdev);
1714-
pf = np->vsi->back;
17151701
ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
17161702
}
17171703

@@ -1880,10 +1866,8 @@ ice_lag_event_handler(struct notifier_block *notif_blk, unsigned long event,
18801866
*/
18811867
static int ice_register_lag_handler(struct ice_lag *lag)
18821868
{
1869+
struct notifier_block *notif_blk = &lag->notif_block;
18831870
struct device *dev = ice_pf_to_dev(lag->pf);
1884-
struct notifier_block *notif_blk;
1885-
1886-
notif_blk = &lag->notif_block;
18871871

18881872
if (!notif_blk->notifier_call) {
18891873
notif_blk->notifier_call = ice_lag_event_handler;
@@ -1903,10 +1887,9 @@ static int ice_register_lag_handler(struct ice_lag *lag)
19031887
*/
19041888
static void ice_unregister_lag_handler(struct ice_lag *lag)
19051889
{
1890+
struct notifier_block *notif_blk = &lag->notif_block;
19061891
struct device *dev = ice_pf_to_dev(lag->pf);
1907-
struct notifier_block *notif_blk;
19081892

1909-
notif_blk = &lag->notif_block;
19101893
if (notif_blk->notifier_call) {
19111894
unregister_netdevice_notifier(notif_blk);
19121895
dev_dbg(dev, "LAG event handler unregistered\n");
@@ -1968,13 +1951,12 @@ ice_lag_move_vf_nodes_tc_sync(struct ice_lag *lag, struct ice_hw *dest_hw,
19681951
u16 numq, valq, num_moved, qbuf_size;
19691952
u16 buf_size = __struct_size(buf);
19701953
struct ice_aqc_cfg_txqs_buf *qbuf;
1954+
struct ice_hw *hw = &lag->pf->hw;
19711955
struct ice_sched_node *n_prt;
19721956
__le32 teid, parent_teid;
19731957
struct ice_vsi_ctx *ctx;
1974-
struct ice_hw *hw;
19751958
u32 tmp_teid;
19761959

1977-
hw = &lag->pf->hw;
19781960
ctx = ice_get_vsi_ctx(hw, vsi_num);
19791961
if (!ctx) {
19801962
dev_warn(dev, "LAG rebuild failed after reset due to VSI Context failure\n");
@@ -2165,9 +2147,7 @@ int ice_init_lag(struct ice_pf *pf)
21652147
*/
21662148
void ice_deinit_lag(struct ice_pf *pf)
21672149
{
2168-
struct ice_lag *lag;
2169-
2170-
lag = pf->lag;
2150+
struct ice_lag *lag = pf->lag;
21712151

21722152
if (!lag)
21732153
return;

0 commit comments

Comments
 (0)