]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ice: Cleanup variable initialization in LAG code
authorDave Ertman <david.m.ertman@intel.com>
Mon, 16 Jun 2025 11:03:20 +0000 (13:03 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Thu, 14 Aug 2025 15:57:28 +0000 (08:57 -0700)
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 <przemyslaw.kitszel@intel.com>
Signed-off-by: Dave Ertman <david.m.ertman@intel.com>
Tested-by: Sujai Buvaneswaran <sujai.buvaneswaran@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_lag.c

index 1f76536e61767fd8f52b77749e6754efee44ec03..72284555b98a048bbb30cc25a8303bdec5572b29 100644 (file)
@@ -234,13 +234,12 @@ ice_lag_cfg_fltr(struct ice_lag *lag, u32 act, u16 recipe_id, u16 *rule_idx,
                 u8 direction, bool add)
 {
        struct ice_sw_rule_lkup_rx_tx *s_rule;
+       struct ice_hw *hw = &lag->pf->hw;
        u16 s_rule_sz, vsi_num;
-       struct ice_hw *hw;
        u8 *eth_hdr;
        u32 opc;
        int err;
 
-       hw = &lag->pf->hw;
        vsi_num = ice_get_hw_vsi_num(hw, 0);
 
        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)
 static void
 ice_lag_cfg_cp_fltr(struct ice_lag *lag, bool add)
 {
-       struct ice_sw_rule_lkup_rx_tx *s_rule = NULL;
-       struct ice_vsi *vsi;
+       struct ice_sw_rule_lkup_rx_tx *s_rule;
+       struct ice_vsi *vsi = lag->pf->vsi[0];
        u16 buf_len, opc;
 
-       vsi = lag->pf->vsi[0];
-
        buf_len = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, ICE_TRAIN_PKT_LEN);
        s_rule = kzalloc(buf_len, GFP_KERNEL);
        if (!s_rule) {
@@ -477,12 +474,11 @@ static u16
 ice_lag_qbuf_recfg(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
                   u16 vsi_num, u16 numq, u8 tc)
 {
+       struct ice_pf *pf = hw->back;
        struct ice_q_ctx *q_ctx;
        u16 qid, count = 0;
-       struct ice_pf *pf;
        int i;
 
-       pf = hw->back;
        for (i = 0; i < numq; i++) {
                q_ctx = ice_get_lan_q_ctx(hw, vsi_num, tc, i);
                if (!q_ctx) {
@@ -940,13 +936,12 @@ ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
        u16 numq, valq, num_moved, qbuf_size;
        u16 buf_size = __struct_size(buf);
        struct ice_aqc_cfg_txqs_buf *qbuf;
+       struct ice_hw *hw = &lag->pf->hw;
        struct ice_sched_node *n_prt;
        __le32 teid, parent_teid;
        struct ice_vsi_ctx *ctx;
-       struct ice_hw *hw;
        u32 tmp_teid;
 
-       hw = &lag->pf->hw;
        ctx = ice_get_vsi_ctx(hw, vsi_num);
        if (!ctx) {
                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,
  */
 static void ice_lag_primary_swid(struct ice_lag *lag, bool link)
 {
-       struct ice_hw *hw;
-       u16 swid;
-
-       hw = &lag->pf->hw;
-       swid = hw->port_info->sw_id;
+       struct ice_hw *hw = &lag->pf->hw;
+       u16 swid = hw->port_info->sw_id;
 
        if (ice_share_res(hw, ICE_AQC_RES_TYPE_SWID, link, swid))
                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)
  */
 static void ice_lag_add_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
 {
-       u16 num_vsi, rule_buf_sz, vsi_list_id, event_vsi_num, prim_vsi_idx;
-       struct ice_sw_rule_vsi_list *s_rule = NULL;
+       u16 rule_buf_sz, vsi_list_id, event_vsi_num, prim_vsi_idx, num_vsi = 1;
+       struct ice_sw_rule_vsi_list *s_rule;
        struct device *dev;
 
-       num_vsi = 1;
-
        dev = ice_pf_to_dev(lag->pf);
        event_vsi_num = event_pf->vsi[0]->vsi_num;
        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)
  */
 static void ice_lag_del_prune_list(struct ice_lag *lag, struct ice_pf *event_pf)
 {
-       u16 num_vsi, vsi_num, vsi_idx, rule_buf_sz, vsi_list_id;
-       struct ice_sw_rule_vsi_list *s_rule = NULL;
+       u16 vsi_num, vsi_idx, rule_buf_sz, vsi_list_id, num_vsi = 1;
+       struct ice_sw_rule_vsi_list *s_rule;
        struct device *dev;
 
-       num_vsi = 1;
-
        dev = ice_pf_to_dev(lag->pf);
        vsi_num = event_pf->vsi[0]->vsi_num;
        vsi_idx = lag->pf->vsi[0]->idx;
@@ -1707,11 +1695,9 @@ static void ice_lag_chk_disabled_bond(struct ice_lag *lag, void *ptr)
  */
 static void ice_lag_disable_sriov_bond(struct ice_lag *lag)
 {
-       struct ice_netdev_priv *np;
-       struct ice_pf *pf;
+       struct ice_netdev_priv *np = netdev_priv(lag->netdev);
+       struct ice_pf *pf = np->vsi->back;
 
-       np = netdev_priv(lag->netdev);
-       pf = np->vsi->back;
        ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
 }
 
@@ -1880,10 +1866,8 @@ ice_lag_event_handler(struct notifier_block *notif_blk, unsigned long event,
  */
 static int ice_register_lag_handler(struct ice_lag *lag)
 {
+       struct notifier_block *notif_blk = &lag->notif_block;
        struct device *dev = ice_pf_to_dev(lag->pf);
-       struct notifier_block *notif_blk;
-
-       notif_blk = &lag->notif_block;
 
        if (!notif_blk->notifier_call) {
                notif_blk->notifier_call = ice_lag_event_handler;
@@ -1903,10 +1887,9 @@ static int ice_register_lag_handler(struct ice_lag *lag)
  */
 static void ice_unregister_lag_handler(struct ice_lag *lag)
 {
+       struct notifier_block *notif_blk = &lag->notif_block;
        struct device *dev = ice_pf_to_dev(lag->pf);
-       struct notifier_block *notif_blk;
 
-       notif_blk = &lag->notif_block;
        if (notif_blk->notifier_call) {
                unregister_netdevice_notifier(notif_blk);
                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,
        u16 numq, valq, num_moved, qbuf_size;
        u16 buf_size = __struct_size(buf);
        struct ice_aqc_cfg_txqs_buf *qbuf;
+       struct ice_hw *hw = &lag->pf->hw;
        struct ice_sched_node *n_prt;
        __le32 teid, parent_teid;
        struct ice_vsi_ctx *ctx;
-       struct ice_hw *hw;
        u32 tmp_teid;
 
-       hw = &lag->pf->hw;
        ctx = ice_get_vsi_ctx(hw, vsi_num);
        if (!ctx) {
                dev_warn(dev, "LAG rebuild failed after reset due to VSI Context failure\n");
@@ -2165,9 +2147,7 @@ lag_error:
  */
 void ice_deinit_lag(struct ice_pf *pf)
 {
-       struct ice_lag *lag;
-
-       lag = pf->lag;
+       struct ice_lag *lag = pf->lag;
 
        if (!lag)
                return;