All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: add drop transmit status feature
@ 2017-04-11 14:44 Joao Pinto
  2017-04-11 15:04 ` Andrew Lunn
  2017-04-11 18:53 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Joao Pinto @ 2017-04-11 14:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, Joao Pinto

When the Drop Transmit Status bit is set, the Tx packet status
received from the MAC is dropped in the MTL. When this bit is reset,
the Tx packet status received from the MAC is forwarded to the
application. This feature will cause a performance improvement.

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
---
 Documentation/devicetree/bindings/net/stmmac.txt      |  1 +
 drivers/net/ethernet/stmicro/stmmac/common.h          |  2 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h          |  1 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c     | 13 +++++++++++++
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     |  3 +++
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c |  2 ++
 include/linux/stmmac.h                                |  1 +
 7 files changed, 23 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/stmmac.txt b/Documentation/devicetree/bindings/net/stmmac.txt
index f652b0c..dbcb2cc 100644
--- a/Documentation/devicetree/bindings/net/stmmac.txt
+++ b/Documentation/devicetree/bindings/net/stmmac.txt
@@ -60,6 +60,7 @@ Optional properties:
 		 and MAC2MAC connection.
 - snps,tso: this enables the TSO feature otherwise it will be managed by
 		 MAC HW capability register. Only for GMAC4 and newer.
+- snps,drop-tx-status: this enables drop tx status
 - AXI BUS Mode parameters: below the list of all the parameters to program the
 			   AXI register inside the DMA module:
 	- snps,lpi_en: enable Low Power Interface
diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 90d28bc..312f9670 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -487,6 +487,8 @@ struct stmmac_ops {
 	/* RX Queues Routing */
 	void (*rx_queue_routing)(struct mac_device_info *hw, u8 packet,
 				 u32 queue);
+	/* Enable TX drop */
+	void (*enable_tx_drop)(struct mac_device_info *hw);
 	/* Program RX Algorithms */
 	void (*prog_mtl_rx_algorithms)(struct mac_device_info *hw, u32 rx_alg);
 	/* Program TX Algorithms */
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index d74cedf..56ba01a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -202,6 +202,7 @@ enum power_event {
 #define MTL_OPERATION_RAA		BIT(2)
 #define MTL_OPERATION_RAA_SP		(0x0 << 2)
 #define MTL_OPERATION_RAA_WSP		(0x1 << 2)
+#define MTL_OPERATION_DTXSTS		BIT(1)
 
 #define MTL_INT_STATUS			0x00000c20
 #define MTL_INT_QX(x)			BIT(x)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
index 48793f2..a71e9db 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
@@ -142,6 +142,17 @@ static void dwmac4_tx_queue_routing(struct mac_device_info *hw,
 	writel(value, ioaddr + GMAC_RXQ_CTRL1);
 }
 
+static void dwmac4_enable_tx_drop(struct mac_device_info *hw)
+{
+	void __iomem *ioaddr = hw->pcsr;
+	u32 value = readl(ioaddr + MTL_OPERATION_MODE);
+
+	value &= ~MTL_OPERATION_DTXSTS;
+	value |= MTL_OPERATION_DTXSTS;
+
+	writel(value, ioaddr + MTL_OPERATION_MODE);
+}
+
 static void dwmac4_prog_mtl_rx_algorithms(struct mac_device_info *hw,
 					  u32 rx_alg)
 {
@@ -675,6 +686,7 @@ static const struct stmmac_ops dwmac4_ops = {
 	.rx_queue_prio = dwmac4_rx_queue_priority,
 	.tx_queue_prio = dwmac4_tx_queue_priority,
 	.rx_queue_routing = dwmac4_tx_queue_routing,
+	.enable_tx_drop = dwmac4_enable_tx_drop,
 	.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
 	.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
 	.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
@@ -706,6 +718,7 @@ static const struct stmmac_ops dwmac410_ops = {
 	.rx_queue_prio = dwmac4_rx_queue_priority,
 	.tx_queue_prio = dwmac4_tx_queue_priority,
 	.rx_queue_routing = dwmac4_tx_queue_routing,
+	.enable_tx_drop = dwmac4_enable_tx_drop,
 	.prog_mtl_rx_algorithms = dwmac4_prog_mtl_rx_algorithms,
 	.prog_mtl_tx_algorithms = dwmac4_prog_mtl_tx_algorithms,
 	.set_mtl_tx_queue_weight = dwmac4_set_mtl_tx_queue_weight,
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index a89f76b..bbde5b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2368,6 +2368,9 @@ static void stmmac_mtl_configuration(struct stmmac_priv *priv)
 	u32 rx_queues_count = priv->plat->rx_queues_to_use;
 	u32 tx_queues_count = priv->plat->tx_queues_to_use;
 
+	if (priv->plat->drop_tx_status)
+		priv->hw->mac->enable_tx_drop(priv->hw);
+
 	if (tx_queues_count > 1 && priv->hw->mac->set_mtl_tx_queue_weight)
 		stmmac_set_tx_queue_weight(priv);
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 7fc3a1e..d15e650 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -451,6 +451,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		plat->has_gmac = 0;
 		plat->pmt = 1;
 		plat->tso_en = of_property_read_bool(np, "snps,tso");
+		plat->drop_tx_status =
+			of_property_read_bool(np, "snps,drop-tx-status");
 	}
 
 	if (of_device_is_compatible(np, "snps,dwmac-3.610") ||
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 3921cb9..fe7940c 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -186,6 +186,7 @@ struct plat_stmmacenet_data {
 	struct stmmac_axi *axi;
 	int has_gmac4;
 	bool tso_en;
+	bool drop_tx_status;
 	int mac_port_sel_speed;
 	bool en_tx_lpi_clockgating;
 };
-- 
2.9.3

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

* Re: [PATCH] net: stmmac: add drop transmit status feature
  2017-04-11 14:44 [PATCH] net: stmmac: add drop transmit status feature Joao Pinto
@ 2017-04-11 15:04 ` Andrew Lunn
  2017-04-11 15:10   ` Joao Pinto
  2017-04-11 18:53 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Lunn @ 2017-04-11 15:04 UTC (permalink / raw)
  To: Joao Pinto; +Cc: davem, netdev

On Tue, Apr 11, 2017 at 03:44:10PM +0100, Joao Pinto wrote:
> When the Drop Transmit Status bit is set, the Tx packet status
> received from the MAC is dropped in the MTL. When this bit is reset,
> the Tx packet status received from the MAC is forwarded to the
> application. This feature will cause a performance improvement.

Hi Joao

Is there a reason not to turn this on by default?

   Andrew

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

* Re: [PATCH] net: stmmac: add drop transmit status feature
  2017-04-11 15:04 ` Andrew Lunn
@ 2017-04-11 15:10   ` Joao Pinto
  0 siblings, 0 replies; 4+ messages in thread
From: Joao Pinto @ 2017-04-11 15:10 UTC (permalink / raw)
  To: Andrew Lunn, Joao Pinto, Niklas Cassel, Thierry Reding; +Cc: davem, netdev

Hi Andrew,

Às 4:04 PM de 4/11/2017, Andrew Lunn escreveu:
> On Tue, Apr 11, 2017 at 03:44:10PM +0100, Joao Pinto wrote:
>> When the Drop Transmit Status bit is set, the Tx packet status
>> received from the MAC is dropped in the MTL. When this bit is reset,
>> the Tx packet status received from the MAC is forwarded to the
>> application. This feature will cause a performance improvement.
> 
> Hi Joao
> 
> Is there a reason not to turn this on by default?

The only reason is not to cause problems for other people setup by introducing a
new variable. In my setup is set by default.

@Niklas and Thierry: Could you please test this feature in order to see if it
boosts your perfomance? If it works fine in your setup we can follow Andrew idea
to turn it on by default.

> 
>    Andrew
> 

Thanks.

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

* Re: [PATCH] net: stmmac: add drop transmit status feature
  2017-04-11 14:44 [PATCH] net: stmmac: add drop transmit status feature Joao Pinto
  2017-04-11 15:04 ` Andrew Lunn
@ 2017-04-11 18:53 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-04-11 18:53 UTC (permalink / raw)
  To: Joao.Pinto; +Cc: netdev

From: Joao Pinto <Joao.Pinto@synopsys.com>
Date: Tue, 11 Apr 2017 15:44:10 +0100

> +static void dwmac4_enable_tx_drop(struct mac_device_info *hw)
> +{
> +	void __iomem *ioaddr = hw->pcsr;
> +	u32 value = readl(ioaddr + MTL_OPERATION_MODE);
> +
> +	value &= ~MTL_OPERATION_DTXSTS;
> +	value |= MTL_OPERATION_DTXSTS;

I think the mask is unnecessary, just simply set the bit.

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

end of thread, other threads:[~2017-04-11 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 14:44 [PATCH] net: stmmac: add drop transmit status feature Joao Pinto
2017-04-11 15:04 ` Andrew Lunn
2017-04-11 15:10   ` Joao Pinto
2017-04-11 18:53 ` 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.