All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part
@ 2020-03-16 20:47 Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
                   ` (9 more replies)
  0 siblings, 10 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

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/20200305051542.991898-1-kuba@kernel.org/
[2] https://lore.kernel.org/netdev/20200306010602.1620354-1-kuba@kernel.org/
[3] https://lore.kernel.org/netdev/20200310021512.1861626-1-kuba@kernel.org/
[4] https://lore.kernel.org/netdev/20200311223302.2171564-1-kuba@kernel.org/
[5] https://lore.kernel.org/netdev/20200313040803.2367590-1-kuba@kernel.org/

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(-)

-- 
2.24.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-17  1:29   ` Edward Cree
  2020-03-16 20:47 ` [PATCH net-next 2/9] net: socionext: " Jakub Kicinski
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/sfc/ethtool.c        | 6 +++---
 drivers/net/ethernet/sfc/falcon/ethtool.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 9a637cd67f43..04e88d05e8ff 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -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,
diff --git a/drivers/net/ethernet/sfc/falcon/ethtool.c b/drivers/net/ethernet/sfc/falcon/ethtool.c
index 08bd6a321918..db90d94e24c9 100644
--- a/drivers/net/ethernet/sfc/falcon/ethtool.c
+++ b/drivers/net/ethernet/sfc/falcon/ethtool.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 2/9] net: socionext: reject unsupported coalescing params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-17  7:51   ` Ilias Apalodimas
  2020-03-16 20:47 ` [PATCH net-next 3/9] net: dwc-xlgmac: let core reject the unsupported coalescing parameters Jakub Kicinski
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver did not previously reject unsupported parameters.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/socionext/netsec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index 58b9b7ce7195..a5a0fb60193a 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 3/9] net: dwc-xlgmac: let core reject the unsupported coalescing parameters
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 2/9] net: socionext: " Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 4/9] net: tehuti: reject unsupported coalescing params Jakub Kicinski
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set 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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/synopsys/dwc-xlgmac-ethtool.c  | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c b/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c
index fde722136869..bc198eadfcab 100644
--- a/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c
+++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-ethtool.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 4/9] net: tehuti: reject unsupported coalescing params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (2 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 3/9] net: dwc-xlgmac: let core reject the unsupported coalescing parameters Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 5/9] net: cpsw: " Jakub Kicinski
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver did not previously reject unsupported parameters.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/tehuti/tehuti.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 0f8a924fc60c..40a2ce0ca808 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 5/9] net: cpsw: reject unsupported coalescing params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (3 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 4/9] net: tehuti: reject unsupported coalescing params Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-17  6:38   ` Grygorii Strashko
  2020-03-16 20:47 ` [PATCH net-next 6/9] net: davinci_emac: " Jakub Kicinski
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver did not previously reject unsupported parameters.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/ti/cpsw.c     | 1 +
 drivers/net/ethernet/ti/cpsw_new.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 6ae4a72e6f43..c2c5bf87da01 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -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,
diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c
index 71215db7934b..9209e613257d 100644
--- a/drivers/net/ethernet/ti/cpsw_new.c
+++ b/drivers/net/ethernet/ti/cpsw_new.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 6/9] net: davinci_emac: reject unsupported coalescing params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (4 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 5/9] net: cpsw: " Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 7/9] net: ll_temac: let core reject the unsupported coalescing parameters Jakub Kicinski
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver did not previously reject unsupported parameters.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/ti/davinci_emac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 75d4e16c692b..de282531f68b 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 7/9] net: ll_temac: let core reject the unsupported coalescing parameters
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (5 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 6/9] net: davinci_emac: " Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 8/9] net: axienet: " Jakub Kicinski
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver already correctly rejected all unsupported
parameters. No functional changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index dc022cd5bc42..3e313e71ae36 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 8/9] net: axienet: let core reject the unsupported coalescing parameters
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (6 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 7/9] net: ll_temac: let core reject the unsupported coalescing parameters Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-16 20:47 ` [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params Jakub Kicinski
  2020-03-18  3:57 ` [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part David Miller
  9 siblings, 0 replies; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver already correctly rejected all unsupported
parameters. No functional changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 .../net/ethernet/xilinx/xilinx_axienet_main.c | 22 +------------------
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index c2f4c5ca2e80..e2f3e2b0cec7 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -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,
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (7 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 8/9] net: axienet: " Jakub Kicinski
@ 2020-03-16 20:47 ` Jakub Kicinski
  2020-03-17  8:45   ` Michal Kubecek
  2020-03-18  3:57 ` [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part David Miller
  9 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2020-03-16 20:47 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek, Jakub Kicinski

Now 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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 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(-)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index be355f37337d..c1d379bf6ee1 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -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];
diff --git a/net/core/dev.c b/net/core/dev.c
index d84541c24446..021e18251465 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -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);
 
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 0b22741b2f8f..dab047eec943 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -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;
+}
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 258840b19fb5..3852a58d7f95 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -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)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params
  2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
@ 2020-03-17  1:29   ` Edward Cree
  0 siblings, 0 replies; 15+ messages in thread
From: Edward Cree @ 2020-03-17  1:29 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, linux-net-drivers, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek

On 16/03/2020 20:47, Jakub Kicinski wrote:
> 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.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Edward Cree <ecree@solarflare.com>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 5/9] net: cpsw: reject unsupported coalescing params
  2020-03-16 20:47 ` [PATCH net-next 5/9] net: cpsw: " Jakub Kicinski
@ 2020-03-17  6:38   ` Grygorii Strashko
  0 siblings, 0 replies; 15+ messages in thread
From: Grygorii Strashko @ 2020-03-17  6:38 UTC (permalink / raw)
  To: Jakub Kicinski, davem
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, andrew, michal.simek,
	radhey.shyam.pandey, mkubecek



On 16/03/2020 22:47, Jakub Kicinski wrote:
> Set ethtool_ops->supported_coalesce_params to let
> the core reject unsupported coalescing parameters.
> 
> This driver did not previously reject unsupported parameters.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

-- 
Best regards,
grygorii

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 2/9] net: socionext: reject unsupported coalescing params
  2020-03-16 20:47 ` [PATCH net-next 2/9] net: socionext: " Jakub Kicinski
@ 2020-03-17  7:51   ` Ilias Apalodimas
  0 siblings, 0 replies; 15+ messages in thread
From: Ilias Apalodimas @ 2020-03-17  7:51 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: davem, netdev, linux-net-drivers, ecree, mhabets,
	jaswinder.singh, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek

Hi Jakub, 

Thanks for the cleanup

On Mon, Mar 16, 2020 at 01:47:05PM -0700, Jakub Kicinski wrote:
> Set ethtool_ops->supported_coalesce_params to let
> the core reject unsupported coalescing parameters.
> 
> This driver did not previously reject unsupported parameters.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  drivers/net/ethernet/socionext/netsec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
> index 58b9b7ce7195..a5a0fb60193a 100644
> --- a/drivers/net/ethernet/socionext/netsec.c
> +++ b/drivers/net/ethernet/socionext/netsec.c
> @@ -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,
> -- 
> 2.24.1
> 

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params
  2020-03-16 20:47 ` [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params Jakub Kicinski
@ 2020-03-17  8:45   ` Michal Kubecek
  0 siblings, 0 replies; 15+ messages in thread
From: Michal Kubecek @ 2020-03-17  8:45 UTC (permalink / raw)
  To: netdev
  Cc: Jakub Kicinski, davem, linux-net-drivers, ecree, mhabets,
	jaswinder.singh, ilias.apalodimas, Jose.Abreu, andy,
	grygorii.strashko, andrew, michal.simek, radhey.shyam.pandey

On Mon, Mar 16, 2020 at 01:47:12PM -0700, Jakub Kicinski wrote:
> Now 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.
> 
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---

Reviewed-by: Michal Kubecek <mkubecek@suse.cz>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part
  2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
                   ` (8 preceding siblings ...)
  2020-03-16 20:47 ` [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params Jakub Kicinski
@ 2020-03-18  3:57 ` David Miller
  9 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2020-03-18  3:57 UTC (permalink / raw)
  To: kuba
  Cc: netdev, linux-net-drivers, ecree, mhabets, jaswinder.singh,
	ilias.apalodimas, Jose.Abreu, andy, grygorii.strashko, andrew,
	michal.simek, radhey.shyam.pandey, mkubecek

From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 16 Mar 2020 13:47:03 -0700

> 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/20200305051542.991898-1-kuba@kernel.org/
> [2] https://lore.kernel.org/netdev/20200306010602.1620354-1-kuba@kernel.org/
> [3] https://lore.kernel.org/netdev/20200310021512.1861626-1-kuba@kernel.org/
> [4] https://lore.kernel.org/netdev/20200311223302.2171564-1-kuba@kernel.org/
> [5] https://lore.kernel.org/netdev/20200313040803.2367590-1-kuba@kernel.org/

Series applied and build testing, thanks Jakub.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-03-18  3:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16 20:47 [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 1/9] net: sfc: reject unsupported coalescing params Jakub Kicinski
2020-03-17  1:29   ` Edward Cree
2020-03-16 20:47 ` [PATCH net-next 2/9] net: socionext: " Jakub Kicinski
2020-03-17  7:51   ` Ilias Apalodimas
2020-03-16 20:47 ` [PATCH net-next 3/9] net: dwc-xlgmac: let core reject the unsupported coalescing parameters Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 4/9] net: tehuti: reject unsupported coalescing params Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 5/9] net: cpsw: " Jakub Kicinski
2020-03-17  6:38   ` Grygorii Strashko
2020-03-16 20:47 ` [PATCH net-next 6/9] net: davinci_emac: " Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 7/9] net: ll_temac: let core reject the unsupported coalescing parameters Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 8/9] net: axienet: " Jakub Kicinski
2020-03-16 20:47 ` [PATCH net-next 9/9] net: ethtool: require drivers to set supported_coalesce_params Jakub Kicinski
2020-03-17  8:45   ` Michal Kubecek
2020-03-18  3:57 ` [PATCH net-next 0/9] ethtool: consolidate irq coalescing - last part David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.