Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ice: Implement ethtool reset support

Enable ethtool reset support. Ethtool reset flags are mapped to the
E810 reset type:
PF reset:
$ ethtool --reset <ethX> irq dma filter offload
CORE reset:
$ ethtool --reset <ethX> irq-shared dma-shared filter-shared \
offload-shared ram-shared
GLOBAL reset:
$ ethtool --reset <ethX> irq-shared dma-shared filter-shared \
offload-shared mac-shared phy-shared ram-shared

Calling the same set of flags as in PF reset case on port representor
triggers VF reset.

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>

authored by

Wojciech Drewek and committed by
Tony Nguyen
b699c81a 42b23310

+108
+31
Documentation/networking/device_drivers/ethernet/intel/ice.rst
··· 101 101 rx_bytes as "X", then ethtool (hardware statistics) will display rx_bytes as 102 102 "X+40" (4 bytes CRC x 10 packets). 103 103 104 + ethtool reset 105 + ------------- 106 + The driver supports 3 types of resets: 107 + 108 + - PF reset - resets only components associated with the given PF, does not 109 + impact other PFs 110 + 111 + - CORE reset - whole adapter is affected, reset all PFs 112 + 113 + - GLOBAL reset - same as CORE but mac and phy components are also reinitialized 114 + 115 + These are mapped to ethtool reset flags as follow: 116 + 117 + - PF reset: 118 + 119 + # ethtool --reset <ethX> irq dma filter offload 120 + 121 + - CORE reset: 122 + 123 + # ethtool --reset <ethX> irq-shared dma-shared filter-shared offload-shared \ 124 + ram-shared 125 + 126 + - GLOBAL reset: 127 + 128 + # ethtool --reset <ethX> irq-shared dma-shared filter-shared offload-shared \ 129 + mac-shared phy-shared ram-shared 130 + 131 + In switchdev mode you can reset a VF using port representor: 132 + 133 + # ethtool --reset <repr> irq dma filter offload 134 + 104 135 105 136 Viewing Link Messages 106 137 ---------------------
+77
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 4716 4716 pi->lport, err); 4717 4717 } 4718 4718 4719 + #define ICE_ETHTOOL_PFR (ETH_RESET_IRQ | ETH_RESET_DMA | \ 4720 + ETH_RESET_FILTER | ETH_RESET_OFFLOAD) 4721 + 4722 + #define ICE_ETHTOOL_CORER ((ICE_ETHTOOL_PFR | ETH_RESET_RAM) << \ 4723 + ETH_RESET_SHARED_SHIFT) 4724 + 4725 + #define ICE_ETHTOOL_GLOBR (ICE_ETHTOOL_CORER | \ 4726 + (ETH_RESET_MAC << ETH_RESET_SHARED_SHIFT) | \ 4727 + (ETH_RESET_PHY << ETH_RESET_SHARED_SHIFT)) 4728 + 4729 + #define ICE_ETHTOOL_VFR ICE_ETHTOOL_PFR 4730 + 4731 + /** 4732 + * ice_ethtool_reset - triggers a given type of reset 4733 + * @dev: network interface device structure 4734 + * @flags: set of reset flags 4735 + * 4736 + * Return: 0 on success, -EOPNOTSUPP when using unsupported set of flags. 4737 + */ 4738 + static int ice_ethtool_reset(struct net_device *dev, u32 *flags) 4739 + { 4740 + struct ice_netdev_priv *np = netdev_priv(dev); 4741 + struct ice_pf *pf = np->vsi->back; 4742 + enum ice_reset_req reset; 4743 + 4744 + switch (*flags) { 4745 + case ICE_ETHTOOL_CORER: 4746 + reset = ICE_RESET_CORER; 4747 + break; 4748 + case ICE_ETHTOOL_GLOBR: 4749 + reset = ICE_RESET_GLOBR; 4750 + break; 4751 + case ICE_ETHTOOL_PFR: 4752 + reset = ICE_RESET_PFR; 4753 + break; 4754 + default: 4755 + netdev_info(dev, "Unsupported set of ethtool flags"); 4756 + return -EOPNOTSUPP; 4757 + } 4758 + 4759 + ice_schedule_reset(pf, reset); 4760 + 4761 + *flags = 0; 4762 + 4763 + return 0; 4764 + } 4765 + 4766 + /** 4767 + * ice_repr_ethtool_reset - triggers a VF reset 4768 + * @dev: network interface device structure 4769 + * @flags: set of reset flags 4770 + * 4771 + * Return: 0 on success, 4772 + * -EOPNOTSUPP when using unsupported set of flags 4773 + * -EBUSY when VF is not ready for reset. 4774 + */ 4775 + static int ice_repr_ethtool_reset(struct net_device *dev, u32 *flags) 4776 + { 4777 + struct ice_repr *repr = ice_netdev_to_repr(dev); 4778 + struct ice_vf *vf; 4779 + 4780 + if (repr->type != ICE_REPR_TYPE_VF || 4781 + *flags != ICE_ETHTOOL_VFR) 4782 + return -EOPNOTSUPP; 4783 + 4784 + vf = repr->vf; 4785 + 4786 + if (ice_check_vf_ready_for_cfg(vf)) 4787 + return -EBUSY; 4788 + 4789 + *flags = 0; 4790 + 4791 + return ice_reset_vf(vf, ICE_VF_RESET_VFLR | ICE_VF_RESET_LOCK); 4792 + } 4793 + 4719 4794 static const struct ethtool_ops ice_ethtool_ops = { 4720 4795 .cap_rss_ctx_supported = true, 4721 4796 .supported_coalesce_params = ETHTOOL_COALESCE_USECS | ··· 4827 4752 .nway_reset = ice_nway_reset, 4828 4753 .get_pauseparam = ice_get_pauseparam, 4829 4754 .set_pauseparam = ice_set_pauseparam, 4755 + .reset = ice_ethtool_reset, 4830 4756 .get_rxfh_key_size = ice_get_rxfh_key_size, 4831 4757 .get_rxfh_indir_size = ice_get_rxfh_indir_size, 4832 4758 .get_rxfh = ice_get_rxfh, ··· 4880 4804 .get_strings = ice_repr_get_strings, 4881 4805 .get_ethtool_stats = ice_repr_get_ethtool_stats, 4882 4806 .get_sset_count = ice_repr_get_sset_count, 4807 + .reset = ice_repr_ethtool_reset, 4883 4808 }; 4884 4809 4885 4810 /**