ethtool: consolidate irq coalescing - last part
Subsystems (11)
Jakub Kicinski
maintainercover ethtool: consolidate irq coalescing - last part
Hi!
Convert remaining drivers following the groundwork laid in a recent patch set [1] and continued in [2], [3], [4], [5]. The aim of the effort is to consolidate irq coalescing parameter validation in the core.
This set is the sixth and last installment. It converts the remaining 8 drivers in drivers/net/ethernet. The last patch makes declaring supported IRQ coalescing parameters a requirement.
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
[4] https://lore.kernel.org/netdev/[email protected]/
[5] https://lore.kernel.org/netdev/[email protected]/
Jakub Kicinski (9):
net: sfc: reject unsupported coalescing params
net: socionext: reject unsupported coalescing params
net: dwc-xlgmac: let core reject the unsupported coalescing parameters
net: tehuti: reject unsupported coalescing params
net: cpsw: reject unsupported coalescing params
net: davinci_emac: reject unsupported coalescing params
net: ll_temac: let core reject the unsupported coalescing parameters
net: axienet: let core reject the unsupported coalescing parameters
net: ethtool: require drivers to set supported_coalesce_params
drivers/net/ethernet/sfc/ethtool.c | 6 ++--- drivers/net/ethernet/sfc/falcon/ethtool.c | 6 ++--- drivers/net/ethernet/socionext/netsec.c | 2 ++ .../ethernet/synopsys/dwc-xlgmac-ethtool.c | 17 ++------------ drivers/net/ethernet/tehuti/tehuti.c | 2 ++ drivers/net/ethernet/ti/cpsw.c | 1 + drivers/net/ethernet/ti/cpsw_new.c | 1 + drivers/net/ethernet/ti/davinci_emac.c | 1 + drivers/net/ethernet/xilinx/ll_temac_main.c | 21 ++---------------- .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 +------------------ include/linux/ethtool.h | 2 ++ net/core/dev.c | 4 ++++ net/ethtool/common.c | 11 ++++++++++ net/ethtool/ioctl.c | 3 --- 14 files changed, 35 insertions(+), 64 deletions(-)
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 1/9 net: sfc: reject unsupported coalescing params
Set ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver did not previously reject unsupported parameters. The check for use_adaptive_tx_coalesce will now be done by the core.
--- drivers/net/ethernet/sfc/ethtool.c | 6 +++--- drivers/net/ethernet/sfc/falcon/ethtool.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/sfc/ethtool.c +3 -3
@@ -232,9 +232,6 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev,bool adaptive, rx_may_override_tx;int rc; -if (coalesce->use_adaptive_tx_coalesce) -return -EINVAL ; -efx_get_irq_moderation (efx, &tx_usecs, &rx_usecs, &adaptive);if (coalesce->rx_coalesce_usecs != rx_usecs)
@@ -1138,6 +1135,9 @@ static int efx_ethtool_set_fecparam(struct net_device *net_dev, }const struct ethtool_ops efx_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_USECS_IRQ | +ETHTOOL_COALESCE_USE_ADAPTIVE_RX , .get_drvinfo = efx_ethtool_get_drvinfo, .get_regs_len = efx_ethtool_get_regs_len, .get_regs = efx_ethtool_get_regs,
drivers/net/ethernet/sfc/falcon/ethtool.c +3 -3
@@ -603,9 +603,6 @@ static int ef4_ethtool_set_coalesce(struct net_device *net_dev,bool adaptive, rx_may_override_tx;int rc; -if (coalesce->use_adaptive_tx_coalesce) -return -EINVAL ; -ef4_get_irq_moderation (efx, &tx_usecs, &rx_usecs, &adaptive);if (coalesce->rx_coalesce_usecs != rx_usecs)
@@ -1311,6 +1308,9 @@ static int ef4_ethtool_get_module_info(struct net_device *net_dev, }const struct ethtool_ops ef4_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_USECS_IRQ | +ETHTOOL_COALESCE_USE_ADAPTIVE_RX , .get_drvinfo = ef4_ethtool_get_drvinfo, .get_regs_len = ef4_ethtool_get_regs_len, .get_regs = ef4_ethtool_get_regs,
Signature · 1 line
2.24.1
Re: [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params
Quoted 8 lines · Jakub Kicinski
Set
ethtool_ops->supported_coalesce_paramsto let the core reject unsupported coalescing parameters.This driver did not previously reject unsupported parameters. The check for
use_adaptive_tx_coalescewill now be done by the core.Signed-off-by Jakub Kicinski <[email protected]>
Jakub Kicinski
maintainerPATCH 2/9 net: socionext: reject unsupported coalescing params
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver did not previously reject unsupported parameters.
--- drivers/net/ethernet/socionext/netsec.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/socionext/netsec.c +2 -0
@@ -589,6 +589,8 @@ static void netsec_et_set_msglevel(struct net_device *dev, u32 datum) }static const struct ethtool_ops netsec_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = netsec_et_get_drvinfo, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,
Signature · 1 line
2.24.1
Re: [PATCH net-next 2/9] net: socionext: reject unsupported coalescing params
Hi Jakub,
Thanks for the cleanup
Quoted 26 lines · Jakub Kicinski
Set
ethtool_ops->supported_coalesce_paramsto let the core reject unsupported coalescing parameters.This driver did not previously reject unsupported parameters.
Signed-off-by Jakub Kicinski <[email protected]>--- drivers/net/ethernet/socionext/netsec.c | 2 ++ 1 file changed, 2 insertions(+)drivers/net/ethernet/socionext/netsec.c +2
-0@@ -589,6 +589,8 @@ static void netsec_et_set_msglevel(struct net_device *dev, u32 datum) }static const struct ethtool_ops netsec_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = netsec_et_get_drvinfo, .get_link_ksettings = phy_ethtool_get_link_ksettings, .set_link_ksettings = phy_ethtool_set_link_ksettings,Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 3/9 net: dwc-xlgmac: let core reject the unsupported coalescing parameters
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver already correctly rejected all unsupported parameters.
While at it remove unnecessary zeroing on get.
No functional changes.
--- .../net/ethernet/synopsys/dwc-xlgmac-ethtool.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c +2 -15
@@ -151,7 +151,6 @@ static int xlgmac_ethtool_get_coalesce(struct net_device *netdev, {struct xlgmac_pdata *pdata =netdev_priv (netdev); -memset (ec,0 ,sizeof (struct ethtool_coalesce )); ec->rx_coalesce_usecs = pdata->rx_usecs; ec->rx_max_coalesced_frames = pdata->rx_frames; ec->tx_max_coalesced_frames = pdata->tx_frames;
@@ -167,20 +166,6 @@ static int xlgmac_ethtool_set_coalesce(struct net_device *netdev,unsigned int rx_frames, rx_riwt, rx_usecs;unsigned int tx_frames; -/* Check for not supported parameters */ -if ((ec->rx_coalesce_usecs_irq) || (ec->rx_max_coalesced_frames_irq) || - (ec->tx_coalesce_usecs) || (ec->tx_coalesce_usecs_high) || - (ec->tx_max_coalesced_frames_irq) || (ec->tx_coalesce_usecs_irq) || - (ec->stats_block_coalesce_usecs) || (ec->pkt_rate_low) || - (ec->use_adaptive_rx_coalesce) || (ec->use_adaptive_tx_coalesce) || - (ec->rx_max_coalesced_frames_low) || (ec->rx_coalesce_usecs_low) || - (ec->tx_coalesce_usecs_low) || (ec->tx_max_coalesced_frames_low) || - (ec->pkt_rate_high) || (ec->rx_coalesce_usecs_high) || - (ec->rx_max_coalesced_frames_high) || - (ec->tx_max_coalesced_frames_high) || - (ec->rate_sample_interval)) -return -EOPNOTSUPP ; - rx_usecs = ec->rx_coalesce_usecs; rx_riwt = hw_ops->usec_to_riwt (pdata, rx_usecs); rx_frames = ec->rx_max_coalesced_frames;
@@ -257,6 +242,8 @@ static void xlgmac_ethtool_get_ethtool_stats(struct net_device *netdev, }static const struct ethtool_ops xlgmac_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS | +ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = xlgmac_ethtool_get_drvinfo, .get_link = ethtool_op_get_link, .get_msglevel = xlgmac_ethtool_get_msglevel,
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 4/9 net: tehuti: reject unsupported coalescing params
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver did not previously reject unsupported parameters.
--- drivers/net/ethernet/tehuti/tehuti.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/tehuti/tehuti.c +2 -0
@@ -2373,6 +2373,8 @@ static void bdx_get_ethtool_stats(struct net_device *netdev,static void bdx_set_ethtool_ops (struct net_device *netdev) {static const struct ethtool_ops bdx_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = bdx_get_drvinfo, .get_link = ethtool_op_get_link, .get_coalesce = bdx_get_coalesce,
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 5/9 net: cpsw: reject unsupported coalescing params
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver did not previously reject unsupported parameters.
--- drivers/net/ethernet/ti/cpsw.c | 1 + drivers/net/ethernet/ti/cpsw_new.c | 1 + 2 files changed, 2 insertions(+)
drivers/net/ethernet/ti/cpsw.c +1 -0
@@ -1211,6 +1211,7 @@ static int cpsw_set_channels(struct net_device *ndev, }static const struct ethtool_ops cpsw_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS , .get_drvinfo = cpsw_get_drvinfo, .get_msglevel = cpsw_get_msglevel, .set_msglevel = cpsw_set_msglevel,
drivers/net/ethernet/ti/cpsw_new.c +1 -0
@@ -1175,6 +1175,7 @@ static int cpsw_set_channels(struct net_device *ndev, }static const struct ethtool_ops cpsw_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS , .get_drvinfo = cpsw_get_drvinfo, .get_msglevel = cpsw_get_msglevel, .set_msglevel = cpsw_set_msglevel,
Signature · 1 line
2.24.1
Re: [PATCH net-next 5/9] net: cpsw: reject unsupported coalescing params
Quoted 7 lines · Jakub Kicinski
Set
ethtool_ops->supported_coalesce_paramsto let the core reject unsupported coalescing parameters.This driver did not previously reject unsupported parameters.
Signed-off-by Jakub Kicinski <[email protected]>---
Signature · 2 lines
Best regards, grygorii
Jakub Kicinski
maintainerPATCH 6/9 net: davinci_emac: reject unsupported coalescing params
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver did not previously reject unsupported parameters.
--- drivers/net/ethernet/ti/davinci_emac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/davinci_emac.c +1 -0
@@ -481,6 +481,7 @@ static int emac_set_coalesce(struct net_device *ndev,* Ethtool support for EMAC adapter */ static const struct ethtool_ops ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_RX_USECS , .get_drvinfo = emac_get_drvinfo, .get_link = ethtool_op_get_link, .get_coalesce = emac_get_coalesce,
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 7/9 net: ll_temac: let core reject the unsupported coalescing parameters
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver already correctly rejected all unsupported parameters. No functional changes.
--- drivers/net/ethernet/xilinx/ll_temac_main.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
drivers/net/ethernet/xilinx/ll_temac_main.c +2 -19
@@ -1314,25 +1314,6 @@ static int ll_temac_ethtools_set_coalesce(struct net_device *ndev,return -EFAULT ; } -if (ec->rx_coalesce_usecs_irq || - ec->rx_max_coalesced_frames_irq || - ec->tx_coalesce_usecs_irq || - ec->tx_max_coalesced_frames_irq || - ec->stats_block_coalesce_usecs || - ec->use_adaptive_rx_coalesce || - ec->use_adaptive_tx_coalesce || - ec->pkt_rate_low || - ec->rx_coalesce_usecs_low || - ec->rx_max_coalesced_frames_low || - ec->tx_coalesce_usecs_low || - ec->tx_max_coalesced_frames_low || - ec->pkt_rate_high || - ec->rx_coalesce_usecs_high || - ec->rx_max_coalesced_frames_high || - ec->tx_coalesce_usecs_high || - ec->tx_max_coalesced_frames_high || - ec->rate_sample_interval) -return -EOPNOTSUPP ;if (ec->rx_max_coalesced_frames) lp->coalesce_count_rx = ec->rx_max_coalesced_frames;if (ec->tx_max_coalesced_frames)
@@ -1351,6 +1332,8 @@ static int ll_temac_ethtools_set_coalesce(struct net_device *ndev, }static const struct ethtool_ops temac_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_USECS | +ETHTOOL_COALESCE_MAX_FRAMES , .nway_reset = phy_ethtool_nway_reset, .get_link = ethtool_op_get_link, .get_ts_info = ethtool_op_get_ts_info,
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 8/9 net: axienet: let core reject the unsupported coalescing parameters
In reply to Jakub KicinskiSet ethtool_ops->supported_coalesce_params to let the core reject unsupported coalescing parameters.
This driver already correctly rejected all unsupported parameters. No functional changes.
--- .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/net/ethernet/xilinx/xilinx_axienet_main.c +1 -21
@@ -1309,27 +1309,6 @@ static int axienet_ethtools_set_coalesce(struct net_device *ndev,return -EFAULT ; } -if ((ecoalesce->rx_coalesce_usecs) || - (ecoalesce->rx_coalesce_usecs_irq) || - (ecoalesce->rx_max_coalesced_frames_irq) || - (ecoalesce->tx_coalesce_usecs) || - (ecoalesce->tx_coalesce_usecs_irq) || - (ecoalesce->tx_max_coalesced_frames_irq) || - (ecoalesce->stats_block_coalesce_usecs) || - (ecoalesce->use_adaptive_rx_coalesce) || - (ecoalesce->use_adaptive_tx_coalesce) || - (ecoalesce->pkt_rate_low) || - (ecoalesce->rx_coalesce_usecs_low) || - (ecoalesce->rx_max_coalesced_frames_low) || - (ecoalesce->tx_coalesce_usecs_low) || - (ecoalesce->tx_max_coalesced_frames_low) || - (ecoalesce->pkt_rate_high) || - (ecoalesce->rx_coalesce_usecs_high) || - (ecoalesce->rx_max_coalesced_frames_high) || - (ecoalesce->tx_coalesce_usecs_high) || - (ecoalesce->tx_max_coalesced_frames_high) || - (ecoalesce->rate_sample_interval)) -return -EOPNOTSUPP ;if (ecoalesce->rx_max_coalesced_frames) lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames;if (ecoalesce->tx_max_coalesced_frames)
@@ -1357,6 +1336,7 @@ axienet_ethtools_set_link_ksettings(struct net_device *ndev, }static const struct ethtool_ops axienet_ethtool_ops = { + .supported_coalesce_params =ETHTOOL_COALESCE_MAX_FRAMES , .get_drvinfo = axienet_ethtools_get_drvinfo, .get_regs_len = axienet_ethtools_get_regs_len, .get_regs = axienet_ethtools_get_regs,
Signature · 1 line
2.24.1
Jakub Kicinski
maintainerPATCH 9/9 net: ethtool: require drivers to set supported_coalesce_params
In reply to Jakub KicinskiNow that all in-tree drivers have been updated we can make the supported_coalesce_params mandatory.
To save debugging time in case some driver was missed (or is out of tree) add a warning when netdev is registered with set_coalesce but without supported_coalesce_params.
--- include/linux/ethtool.h | 2 ++ net/core/dev.c | 4 ++++ net/ethtool/common.c | 11 +++++++++++ net/ethtool/ioctl.c | 3 --- 4 files changed, 17 insertions(+), 3 deletions(-)
include/linux/ethtool.h +2 -0
@@ -458,6 +458,8 @@ struct ethtool_ops { struct ethtool_stats *, u64 *); }; +int ethtool_check_ops (const struct ethtool_ops *ops); +struct ethtool_rx_flow_rule {struct flow_rule *rule;unsigned long priv[0 ];
net/core/dev.c +4 -0
@@ -9283,6 +9283,10 @@ int register_netdevice(struct net_device *dev)BUG_ON (dev->reg_state !=NETREG_UNINITIALIZED );BUG_ON (!net); + ret =ethtool_check_ops (dev->ethtool_ops); +if (ret) +return ret; +spin_lock_init (&dev->addr_list_lock);lockdep_set_class (&dev->addr_list_lock, &dev->addr_list_lock_key);
net/ethtool/common.c +11 -0
@@ -289,3 +289,14 @@ int ethtool_get_max_rxfh_channel(struct net_device *dev, u32 *max)kfree (indir);return ret; } + +int ethtool_check_ops (const struct ethtool_ops *ops) +{ +if (WARN_ON (ops->set_coalesce && !ops->supported_coalesce_params)) +return -EINVAL ; +/* NOTE: sufficiently insane drivers may swap ethtool_ops at runtime, +* the fact that ops are checked at registration time does not +* mean the ops attached to a netdev later on are sane. +*/ +return 0 ; +}
net/ethtool/ioctl.c +0 -3
@@ -1519,9 +1519,6 @@ ethtool_set_coalesce_supported(struct net_device *dev,u32 supported_params = dev->ethtool_ops->supported_coalesce_params;u32 nonzero_params =0 ; -if (!supported_params) -return true; -if (coalesce->rx_coalesce_usecs) nonzero_params |=ETHTOOL_COALESCE_RX_USECS ;if (coalesce->rx_max_coalesced_frames)
Signature · 1 line
2.24.1
Re: [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params
Quoted 9 lines · Jakub Kicinski
Now that all in-tree drivers have been updated we can make the
supported_coalesce_paramsmandatory.To save debugging time in case some driver was missed (or is out of tree) add a warning when netdev is registered with
set_coalescebut withoutsupported_coalesce_params.Signed-off-by Jakub Kicinski <[email protected]>---
David Miller
maintainerFrom: Jakub Kicinski <[email protected]>
Date: Mon, 16 Mar 2020 13:47:03 -0700
Quoted 9 lines
Convert remaining drivers following the groundwork laid in a recent patch set [1] and continued in [2], [3], [4], [5]. The aim of the effort is to consolidate irq coalescing parameter validation in the core.
This set is the sixth and last installment. It converts the remaining 8 drivers in
drivers/net/ethernet. The last patch makes declaring supported IRQ coalescing parameters a requirement.
Quoted 5 lines
[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/
[3] https://lore.kernel.org/netdev/[email protected]/
[4] https://lore.kernel.org/netdev/[email protected]/
[5] https://lore.kernel.org/netdev/[email protected]/
Series applied and build testing, thanks Jakub.