netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: stmmac: Minor fixes for stmmac EST implementation
@ 2025-09-11  8:22 Rohan G Thomas via B4 Relay
  2025-09-11  8:22 ` [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
  2025-09-11  8:23 ` [PATCH net 2/2] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay
  0 siblings, 2 replies; 7+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-09-11  8:22 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	Rohan G Thomas, Matthew Gerlach

This patchset includes following minor fixes for stmmac EST
implementation:
   1. Fix GCL bounds checks
   2. Consider Tx VLAN offload tag length for maxSDU

Signed-off-by: Rohan G Thomas <rohan.g.thomas@altera.com>
---
Rohan G Thomas (2):
      net: stmmac: est: Fix GCL bounds checks
      net: stmmac: Consider Tx VLAN offload tag length for maxSDU

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++++++++++++-------
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c   |  4 ++--
 2 files changed, 20 insertions(+), 9 deletions(-)
---
base-commit: 1f24a240974589ce42f70502ccb3ff3f5189d69a
change-id: 20250911-qbv-fixes-4ae64de86ee7

Best regards,
-- 
Rohan G Thomas <rohan.g.thomas@altera.com>



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

* [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks
  2025-09-11  8:22 [PATCH net 0/2] net: stmmac: Minor fixes for stmmac EST implementation Rohan G Thomas via B4 Relay
@ 2025-09-11  8:22 ` Rohan G Thomas via B4 Relay
  2025-09-11 11:24   ` Russell King (Oracle)
  2025-09-11  8:23 ` [PATCH net 2/2] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay
  1 sibling, 1 reply; 7+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-09-11  8:22 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	Rohan G Thomas, Matthew Gerlach

From: Rohan G Thomas <rohan.g.thomas@intel.com>

Fix the bounds checks for the hw supported maximum GCL entry
count and gate interval time.

Fixes: b60189e0392f ("net: stmmac: Integrate EST with TAPRIO scheduler API")
Signed-off-by: Rohan G Thomas <rohan.g.thomas@intel.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
index 694d6ee1438197bd4434af6e9b78f022e94ff98f..89d094abb6be5c993c81901e3f79a6b03f310511 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
@@ -981,7 +981,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
 	if (qopt->cmd == TAPRIO_CMD_DESTROY)
 		goto disable;
 
-	if (qopt->num_entries >= dep)
+	if (qopt->num_entries > dep)
 		return -EINVAL;
 	if (!qopt->cycle_time)
 		return -ERANGE;
@@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
 		s64 delta_ns = qopt->entries[i].interval;
 		u32 gates = qopt->entries[i].gate_mask;
 
-		if (delta_ns > GENMASK(wid, 0))
+		if (delta_ns >= BIT(wid))
 			return -ERANGE;
 		if (gates > GENMASK(31 - wid, 0))
 			return -ERANGE;

-- 
2.25.1



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

* [PATCH net 2/2] net: stmmac: Consider Tx VLAN offload tag length for maxSDU
  2025-09-11  8:22 [PATCH net 0/2] net: stmmac: Minor fixes for stmmac EST implementation Rohan G Thomas via B4 Relay
  2025-09-11  8:22 ` [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
@ 2025-09-11  8:23 ` Rohan G Thomas via B4 Relay
  1 sibling, 0 replies; 7+ messages in thread
From: Rohan G Thomas via B4 Relay @ 2025-09-11  8:23 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel,
	Rohan G Thomas, Matthew Gerlach

From: Rohan G Thomas <rohan.g.thomas@intel.com>

On hardware with Tx VLAN offload enabled, add the VLAN tag
length to the skb length before checking the Qbv maxSDU.
Add 4 bytes for 802.1Q an add 8 bytes for 802.1AD tagging.

Fixes: c5c3e1bfc9e0 ("net: stmmac: Offload queueMaxSDU from tc-taprio")
Signed-off-by: Rohan G Thomas <rohan.g.thomas@intel.com>
Reviewed-by: Matthew Gerlach <matthew.gerlach@altera.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 25 ++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 419cb49ee5a25519a60a84bae6bcdb0be655384e..c487ce95436c2a1f502f96d00afab6270d77c0bb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4531,6 +4531,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	bool has_vlan, set_ic;
 	int entry, first_tx;
 	dma_addr_t des;
+	u32 sdu_len;
 
 	tx_q = &priv->dma_conf.tx_queue[queue];
 	txq_stats = &priv->xstats.txq_stats[queue];
@@ -4547,13 +4548,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 			return stmmac_tso_xmit(skb, dev);
 	}
 
-	if (priv->est && priv->est->enable &&
-	    priv->est->max_sdu[queue] &&
-	    skb->len > priv->est->max_sdu[queue]){
-		priv->xstats.max_sdu_txq_drop[queue]++;
-		goto max_sdu_err;
-	}
-
 	if (unlikely(stmmac_tx_avail(priv, queue) < nfrags + 1)) {
 		if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
 			netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
@@ -4569,6 +4563,23 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 	/* Check if VLAN can be inserted by HW */
 	has_vlan = stmmac_vlan_insert(priv, skb, tx_q);
 
+	sdu_len = skb->len;
+	if (has_vlan) {
+		/* Add VLAN tag length to sdu length in case of txvlan offload */
+		if (priv->dev->features & NETIF_F_HW_VLAN_CTAG_TX)
+			sdu_len += VLAN_HLEN;
+		if (skb->vlan_proto == htons(ETH_P_8021AD) &&
+		    priv->dev->features & NETIF_F_HW_VLAN_STAG_TX)
+			sdu_len += VLAN_HLEN;
+	}
+
+	if (priv->est && priv->est->enable &&
+	    priv->est->max_sdu[queue] &&
+	    sdu_len > priv->est->max_sdu[queue]) {
+		priv->xstats.max_sdu_txq_drop[queue]++;
+		goto max_sdu_err;
+	}
+
 	entry = tx_q->cur_tx;
 	first_entry = entry;
 	WARN_ON(tx_q->tx_skbuff[first_entry]);

-- 
2.25.1



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

* Re: [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks
  2025-09-11  8:22 ` [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
@ 2025-09-11 11:24   ` Russell King (Oracle)
  2025-09-11 12:42     ` G Thomas, Rohan
  0 siblings, 1 reply; 7+ messages in thread
From: Russell King (Oracle) @ 2025-09-11 11:24 UTC (permalink / raw)
  To: rohan.g.thomas
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Matthew Gerlach

On Thu, Sep 11, 2025 at 04:22:59PM +0800, Rohan G Thomas via B4 Relay wrote:
> @@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
>  		s64 delta_ns = qopt->entries[i].interval;
>  		u32 gates = qopt->entries[i].gate_mask;
>  
> -		if (delta_ns > GENMASK(wid, 0))
> +		if (delta_ns >= BIT(wid))

While I agree this makes it look better, you don't change the version
below, which makes the code inconsistent. I also don't see anything
wrong with the original comparison.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks
  2025-09-11 11:24   ` Russell King (Oracle)
@ 2025-09-11 12:42     ` G Thomas, Rohan
  2025-09-12  0:01       ` Jakub Kicinski
  0 siblings, 1 reply; 7+ messages in thread
From: G Thomas, Rohan @ 2025-09-11 12:42 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Matthew Gerlach

Hi Russell,

Thanks for reviewing the patch.

On 9/11/2025 4:54 PM, Russell King (Oracle) wrote:
> On Thu, Sep 11, 2025 at 04:22:59PM +0800, Rohan G Thomas via B4 Relay wrote:
>> @@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
>>   		s64 delta_ns = qopt->entries[i].interval;
>>   		u32 gates = qopt->entries[i].gate_mask;
>>   
>> -		if (delta_ns > GENMASK(wid, 0))
>> +		if (delta_ns >= BIT(wid))
> 
> While I agree this makes it look better, you don't change the version
> below, which makes the code inconsistent. I also don't see anything
> wrong with the original comparison.

Just to clarify the intent behind this change:
For example, if wid = 3, then GENMASK(3, 0) = 0b1111 = 15. But the
maximum supported gate interval in this case is actually 7, since only 3
bits are available to represent the value. So in the patch, the
condition delta_ns >= BIT(wid) effectively checks if delta_ns is 8 or
more, which correctly returns an error for values that exceed the 3-bit
limit.

> Best Regards,
Rohan


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

* Re: [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks
  2025-09-11 12:42     ` G Thomas, Rohan
@ 2025-09-12  0:01       ` Jakub Kicinski
  2025-09-12  5:04         ` G Thomas, Rohan
  0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kicinski @ 2025-09-12  0:01 UTC (permalink / raw)
  To: G Thomas, Rohan
  Cc: Russell King (Oracle), Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Matthew Gerlach

On Thu, 11 Sep 2025 18:12:16 +0530 G Thomas, Rohan wrote:
> On 9/11/2025 4:54 PM, Russell King (Oracle) wrote:
> > On Thu, Sep 11, 2025 at 04:22:59PM +0800, Rohan G Thomas via B4 Relay wrote:  
> >> @@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
> >>   		s64 delta_ns = qopt->entries[i].interval;
> >>   		u32 gates = qopt->entries[i].gate_mask;
> >>   
> >> -		if (delta_ns > GENMASK(wid, 0))
> >> +		if (delta_ns >= BIT(wid))  
> > 
> > While I agree this makes it look better, you don't change the version
> > below, which makes the code inconsistent. I also don't see anything
> > wrong with the original comparison.  
> 
> Just to clarify the intent behind this change:
> For example, if wid = 3, then GENMASK(3, 0) = 0b1111 = 15. But the
> maximum supported gate interval in this case is actually 7, since only 3
> bits are available to represent the value. So in the patch, the
> condition delta_ns >= BIT(wid) effectively checks if delta_ns is 8 or
> more, which correctly returns an error for values that exceed the 3-bit
> limit.

Comparison to BIT() looks rather odd, I think it's better to correct
the GENMASK() bound?

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

* Re: [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks
  2025-09-12  0:01       ` Jakub Kicinski
@ 2025-09-12  5:04         ` G Thomas, Rohan
  0 siblings, 0 replies; 7+ messages in thread
From: G Thomas, Rohan @ 2025-09-12  5:04 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Russell King (Oracle), Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Maxime Coquelin, Alexandre Torgue, Jose Abreu,
	Rohan G Thomas, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel, Matthew Gerlach

Hi Jakub,

Thanks for reviewing the patch.

On 9/12/2025 5:31 AM, Jakub Kicinski wrote:
> On Thu, 11 Sep 2025 18:12:16 +0530 G Thomas, Rohan wrote:
>> On 9/11/2025 4:54 PM, Russell King (Oracle) wrote:
>>> On Thu, Sep 11, 2025 at 04:22:59PM +0800, Rohan G Thomas via B4 Relay wrote:
>>>> @@ -1012,7 +1012,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
>>>>    		s64 delta_ns = qopt->entries[i].interval;
>>>>    		u32 gates = qopt->entries[i].gate_mask;
>>>>    
>>>> -		if (delta_ns > GENMASK(wid, 0))
>>>> +		if (delta_ns >= BIT(wid))
>>>
>>> While I agree this makes it look better, you don't change the version
>>> below, which makes the code inconsistent. I also don't see anything
>>> wrong with the original comparison.
>>
>> Just to clarify the intent behind this change:
>> For example, if wid = 3, then GENMASK(3, 0) = 0b1111 = 15. But the
>> maximum supported gate interval in this case is actually 7, since only 3
>> bits are available to represent the value. So in the patch, the
>> condition delta_ns >= BIT(wid) effectively checks if delta_ns is 8 or
>> more, which correctly returns an error for values that exceed the 3-bit
>> limit.
> 
> Comparison to BIT() looks rather odd, I think it's better to correct
> the GENMASK() bound?

Sure I'll update the condition to use GENMASK(wid - 1, 0) in the next
version. That should make the logic consistent with the checks below.

Best Regards,
Rohan

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

end of thread, other threads:[~2025-09-12  5:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  8:22 [PATCH net 0/2] net: stmmac: Minor fixes for stmmac EST implementation Rohan G Thomas via B4 Relay
2025-09-11  8:22 ` [PATCH net 1/2] net: stmmac: est: Fix GCL bounds checks Rohan G Thomas via B4 Relay
2025-09-11 11:24   ` Russell King (Oracle)
2025-09-11 12:42     ` G Thomas, Rohan
2025-09-12  0:01       ` Jakub Kicinski
2025-09-12  5:04         ` G Thomas, Rohan
2025-09-11  8:23 ` [PATCH net 2/2] net: stmmac: Consider Tx VLAN offload tag length for maxSDU Rohan G Thomas via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).