Skip to content

Commit b699c81

Browse files
WojDrewanguy11
authored andcommitted
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 <[email protected]> Reviewed-by: Marcin Szycik <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: Wojciech Drewek <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent 42b2331 commit b699c81

File tree

2 files changed

+108
-0
lines changed
  • Documentation/networking/device_drivers/ethernet/intel
  • drivers/net/ethernet/intel/ice

2 files changed

+108
-0
lines changed

Documentation/networking/device_drivers/ethernet/intel/ice.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,37 @@ example, if Rx packets are 10 and Netdev (software statistics) displays
101101
rx_bytes as "X", then ethtool (hardware statistics) will display rx_bytes as
102102
"X+40" (4 bytes CRC x 10 packets).
103103

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+
104135

105136
Viewing Link Messages
106137
---------------------

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4716,6 +4716,81 @@ static void ice_get_fec_stats(struct net_device *netdev,
47164716
pi->lport, err);
47174717
}
47184718

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+
47194794
static const struct ethtool_ops ice_ethtool_ops = {
47204795
.cap_rss_ctx_supported = true,
47214796
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
@@ -4752,6 +4827,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
47524827
.nway_reset = ice_nway_reset,
47534828
.get_pauseparam = ice_get_pauseparam,
47544829
.set_pauseparam = ice_set_pauseparam,
4830+
.reset = ice_ethtool_reset,
47554831
.get_rxfh_key_size = ice_get_rxfh_key_size,
47564832
.get_rxfh_indir_size = ice_get_rxfh_indir_size,
47574833
.get_rxfh = ice_get_rxfh,
@@ -4804,6 +4880,7 @@ static const struct ethtool_ops ice_ethtool_repr_ops = {
48044880
.get_strings = ice_repr_get_strings,
48054881
.get_ethtool_stats = ice_repr_get_ethtool_stats,
48064882
.get_sset_count = ice_repr_get_sset_count,
4883+
.reset = ice_repr_ethtool_reset,
48074884
};
48084885

48094886
/**

0 commit comments

Comments
 (0)