]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ice: refactor to use helpers
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Fri, 17 Oct 2025 06:08:41 +0000 (23:08 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Oct 2025 01:31:26 +0000 (18:31 -0700)
Use the ice_netdev_to_pf() helper in more places and remove a bunch of
boilerplate code. Not every instance could be replaced due to use of the
netdev_priv() output or the vsi variable within a bunch of functions.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Rinitha S <sx.rinitha@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20251016-jk-iwl-next-2025-10-15-v2-12-ff3a390d9fc6@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_flex_pipe.c
drivers/net/ethernet/intel/ice/ice_lag.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_ptp.c
drivers/net/ethernet/intel/ice/ice_sriov.c

index 75492a720c68cea31c6e70904f22a08ed9f66501..cb34d4675a78858b54ff9e8cd800cf4437aa88c1 100644 (file)
@@ -794,8 +794,7 @@ static int ice_get_extended_regs(struct net_device *netdev, void *p)
 static void
 ice_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        struct ice_hw *hw = &pf->hw;
        u32 *regs_buf = (u32 *)p;
        unsigned int i;
@@ -810,8 +809,7 @@ ice_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *p)
 
 static u32 ice_get_msglevel(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
 #ifndef CONFIG_DYNAMIC_DEBUG
        if (pf->hw.debug_mask)
@@ -824,8 +822,7 @@ static u32 ice_get_msglevel(struct net_device *netdev)
 
 static void ice_set_msglevel(struct net_device *netdev, u32 data)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
 #ifndef CONFIG_DYNAMIC_DEBUG
        if (ICE_DBG_USER & data)
@@ -840,16 +837,14 @@ static void ice_set_msglevel(struct net_device *netdev, u32 data)
 static void ice_get_link_ext_stats(struct net_device *netdev,
                                   struct ethtool_link_ext_stats *stats)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
        stats->link_down_events = pf->link_down_events;
 }
 
 static int ice_get_eeprom_len(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
        return (int)pf->hw.flash.flash_size;
 }
@@ -858,9 +853,7 @@ static int
 ice_get_eeprom(struct net_device *netdev, struct ethtool_eeprom *eeprom,
               u8 *bytes)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        struct ice_hw *hw = &pf->hw;
        struct device *dev;
        int ret;
@@ -959,8 +952,7 @@ static u64 ice_link_test(struct net_device *netdev)
  */
 static u64 ice_eeprom_test(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
        netdev_info(netdev, "EEPROM test\n");
        return !!(ice_nvm_validate_checksum(&pf->hw));
@@ -1274,9 +1266,8 @@ static int ice_lbtest_receive_frames(struct ice_rx_ring *rx_ring)
  */
 static u64 ice_loopback_test(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *orig_vsi = np->vsi, *test_vsi;
-       struct ice_pf *pf = orig_vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
+       struct ice_vsi *test_vsi;
        u8 *tx_frame __free(kfree) = NULL;
        u8 broadcast[ETH_ALEN], ret = 0;
        int num_frames, valid_frames;
@@ -1365,8 +1356,7 @@ lbtest_vsi_close:
  */
 static u64 ice_intr_test(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        u16 swic_old = pf->sw_int_count;
 
        netdev_info(netdev, "interrupt test\n");
@@ -1394,9 +1384,8 @@ static void
 ice_self_test(struct net_device *netdev, struct ethtool_test *eth_test,
              u64 *data)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        bool if_running = netif_running(netdev);
-       struct ice_pf *pf = np->vsi->back;
        struct device *dev;
 
        dev = ice_pf_to_dev(pf);
@@ -1720,9 +1709,7 @@ static int ice_nway_reset(struct net_device *netdev)
  */
 static u32 ice_get_priv_flags(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        u32 i, ret_flags = 0;
 
        for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) {
@@ -4417,9 +4404,7 @@ static int
 ice_get_module_info(struct net_device *netdev,
                    struct ethtool_modinfo *modinfo)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        struct ice_hw *hw = &pf->hw;
        u8 sff8472_comp = 0;
        u8 sff8472_swap = 0;
@@ -4491,12 +4476,10 @@ static int
 ice_get_module_eeprom(struct net_device *netdev,
                      struct ethtool_eeprom *ee, u8 *data)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 #define SFF_READ_BLOCK_SIZE 8
        u8 value[SFF_READ_BLOCK_SIZE] = { 0 };
        u8 addr = ICE_I2C_EEPROM_DEV_ADDR;
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
        struct ice_hw *hw = &pf->hw;
        bool is_sfp = false;
        unsigned int i, j;
@@ -4774,8 +4757,7 @@ static void ice_get_ts_stats(struct net_device *netdev,
  */
 static int ice_ethtool_reset(struct net_device *dev, u32 *flags)
 {
-       struct ice_netdev_priv *np = netdev_priv(dev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(dev);
        enum ice_reset_req reset;
 
        switch (*flags) {
index 363ae79a3620cdf8126a9a431208eee93ac7dda6..06b8786ae3abdba1c237d0f361b534e56dbc3ceb 100644 (file)
@@ -574,9 +574,7 @@ ice_destroy_tunnel_end:
 int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table,
                            unsigned int idx, struct udp_tunnel_info *ti)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        enum ice_tunnel_type tnl_type;
        int status;
        u16 index;
@@ -598,9 +596,7 @@ int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table,
 int ice_udp_tunnel_unset_port(struct net_device *netdev, unsigned int table,
                              unsigned int idx, struct udp_tunnel_info *ti)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        enum ice_tunnel_type tnl_type;
        int status;
 
index aebf8e08a297be3a43a255107a2f4bc67f3a6dc2..d2576d606e10e22e3b87bdd8a81fe0fa219c108d 100644 (file)
@@ -2177,8 +2177,7 @@ 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 = netdev_priv(lag->netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(lag->netdev);
 
        ice_clear_feature_support(pf, ICE_F_SRIOV_LAG);
        ice_clear_feature_support(pf, ICE_F_SRIOV_AA_LAG);
index 3d5615caf6d160cfc449f1b8f8beccc61f8befa6..ca95b8800bb3bad3f36badbeeddaf0a1119cfcff 100644 (file)
@@ -8074,9 +8074,7 @@ static int
 ice_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
                   struct net_device *dev, u32 filter_mask, int nlflags)
 {
-       struct ice_netdev_priv *np = netdev_priv(dev);
-       struct ice_vsi *vsi = np->vsi;
-       struct ice_pf *pf = vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(dev);
        u16 bmode;
 
        bmode = pf->first_sw->bridge_mode;
@@ -8146,8 +8144,7 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
                   u16 __always_unused flags,
                   struct netlink_ext_ack __always_unused *extack)
 {
-       struct ice_netdev_priv *np = netdev_priv(dev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(dev);
        struct nlattr *attr, *br_spec;
        struct ice_hw *hw = &pf->hw;
        struct ice_sw *pf_sw;
@@ -9581,8 +9578,7 @@ ice_indr_setup_tc_cb(struct net_device *netdev, struct Qdisc *sch,
  */
 int ice_open(struct net_device *netdev)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
        if (ice_is_reset_in_progress(pf->state)) {
                netdev_err(netdev, "can't open net device while reset is in progress");
index 4f50e952bfb57f756ca63a78ab1aca7792b80905..985b3e79b312660ba2879955e67c1b4fa98c958d 100644 (file)
@@ -2215,8 +2215,7 @@ static int ice_ptp_getcrosststamp(struct ptp_clock_info *info,
 int ice_ptp_hwtstamp_get(struct net_device *netdev,
                         struct kernel_hwtstamp_config *config)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
 
        if (pf->ptp.state != ICE_PTP_READY)
                return -EIO;
@@ -2287,8 +2286,7 @@ int ice_ptp_hwtstamp_set(struct net_device *netdev,
                         struct kernel_hwtstamp_config *config,
                         struct netlink_ext_ack *extack)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        int err;
 
        if (pf->ptp.state != ICE_PTP_READY)
index 843e82fd3bf936106fcf1f63508d00402ccd5dfa..6b1126ddb5616acf4b7c7a8472ac455f11e4ef29 100644 (file)
@@ -1190,8 +1190,7 @@ ice_vf_lan_overflow_event(struct ice_pf *pf, struct ice_rq_event_info *event)
  */
 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena)
 {
-       struct ice_netdev_priv *np = netdev_priv(netdev);
-       struct ice_pf *pf = np->vsi->back;
+       struct ice_pf *pf = ice_netdev_to_pf(netdev);
        struct ice_vsi *vf_vsi;
        struct device *dev;
        struct ice_vf *vf;