net: stmmac: fix and clean up TSO/GSO support
Subsystems (4)
cover net: stmmac: fix and clean up TSO/GSO support
This series:
1. moves setting priv->tso from stmmac_fix_features() to stmmac_set_features() as fix_features is not supposed to change driver state.
2. simplifies the TSO/GSP test in stmmac_xmit() to simply check if the skbuff is a GSO buffer, and whether the gso_type is one that we should handle.
A previous version of patch 1 was posted in February:
https://lore.kernel.org/r/[email protected]/
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 38 +++++++++++------------ 2 files changed, 21 insertions(+), 20 deletions(-)
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
PATCH 1/2 net: stmmac: fix .ndo_fix_features()
netdev features documentation requires that .ndo_fix_features() is
stateless: it shouldn't modify driver state. Yet, stmmac_fix_features() does exactly that, changing whether GSO frames are processed by the driver.
Move this code to stmmac_set_features() instead, which is the correct place for it. We don't need to check whether TSO is supported; this is already handled via the setup of netdev->hw_features, and we are guaranteed that if netdev->hw_features indicates that a feature is not supported, .ndo_set_features() won't be called with it set.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -8
@@ -6068,14 +6068,6 @@ static netdev_features_t stmmac_fix_features(struct net_device *dev,if (priv->plat->bugged_jumbo && (dev->mtu >ETH_DATA_LEN )) features &= ~NETIF_F_CSUM_MASK ; -/* Disable tso if asked by ethtool */ -if ((priv->plat->flags &STMMAC_FLAG_TSO_EN ) && (priv->dma_cap.tsoen)) { -if (features &NETIF_F_TSO ) - priv->tso = true; -else - priv->tso = false; - } -return features; }
@@ -6102,6 +6094,8 @@ static int stmmac_set_features(struct net_device *netdev,stmmac_enable_sph (priv, priv->ioaddr, sph_en, chan); } + priv->tso = !!(features &NETIF_F_TSO ); +if (features &NETIF_F_HW_VLAN_CTAG_RX ) priv->hw->hw_vlan_en = true;else
Signature · 1 line
2.47.3
PATCH 2/2 net: stmmac: simplify GSO/TSO test in stmmac_xmit()
In reply to Russell King (Oracle)The test in stmmac_xmit() to see whether we should pass the skbuff to stmmac_tso_xmit() is more complex than it needs to be. This test can be simplified by storing the mask of GSO types that we will pass, and setting it according to the enabled features.
Note that "tso" is a mis-nomer since commit b776620651a1 ("net:
stmmac: Implement UDP Segmentation Offload"). Also note that this commit controls both via the TSO feature. We preserve this behaviour in this commit.
Also, this commit unconditionally accessed skb_shinfo(skb)->gso_type for all frames, even when skb_is_gso() was false. This access is eliminated.
--- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 30 +++++++++++-------- 2 files changed, 20 insertions(+), 13 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac.h +2 -1
@@ -265,8 +265,9 @@ struct stmmac_priv {u32 rx_coal_frames[MTL_MAX_RX_QUEUES ];int hwts_tx_en; +/* skb_shinfo(skb)->gso_type types that we handle */ +unsigned int gso_enabled_types;bool tx_path_in_lpi_mode; -bool tso;bool sph_active;bool sph_capable;u32 sarc_type;
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +18 -12
@@ -3700,7 +3700,7 @@ static int stmmac_hw_setup(struct net_device *dev)stmmac_set_rings_length (priv);/* Enable TSO */ -if (priv->tso) { +if (priv->gso_enabled_types) {for (chan =0 ; chan < tx_cnt; chan++) {struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];
@@ -4675,7 +4675,6 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)u32 queue =skb_get_queue_mapping (skb);int nfrags =skb_shinfo (skb)->nr_frags;unsigned int first_entry, tx_packets; -int gso =skb_shinfo (skb)->gso_type;struct stmmac_txq_stats *txq_stats;struct dma_desc *desc, *first_desc;struct stmmac_tx_queue *tx_q;
@@ -4687,14 +4686,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)if (priv->tx_path_in_lpi_mode && priv->eee_sw_timer_en)stmmac_stop_sw_lpi (priv); -/* Manage oversized TCP frames for GMAC4 device */ -if (skb_is_gso (skb) && priv->tso) { -if (gso & (SKB_GSO_TCPV4 |SKB_GSO_TCPV6 )) -return stmmac_tso_xmit (skb, dev); -if (priv->plat->core_type ==DWMAC_CORE_GMAC4 && - (gso &SKB_GSO_UDP_L4 )) -return stmmac_tso_xmit (skb, dev); - } +if (skb_is_gso (skb) && +skb_shinfo (skb)->gso_type & priv->gso_enabled_types) +return stmmac_tso_xmit (skb, dev);if (priv->est && priv->est->enable && priv->est->max_sdu[queue]) {
@@ -6049,6 +6043,18 @@ static int stmmac_change_mtu(struct net_device *dev, int new_mtu)return 0 ; } +static void stmmac_set_gso_types (struct stmmac_priv *priv,bool tso) +{ +if (!tso) { + priv->gso_enabled_types =0 ; + }else { +/* Manage oversized TCP frames for GMAC4 device */ + priv->gso_enabled_types =SKB_GSO_TCPV4 |SKB_GSO_TCPV6 ; +if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) + priv->gso_enabled_types |=SKB_GSO_UDP_L4 ; + } +} +static netdev_features_t stmmac_fix_features (struct net_device *dev,netdev_features_t features) {
@@ -6094,7 +6100,7 @@ static int stmmac_set_features(struct net_device *netdev,stmmac_enable_sph (priv, priv->ioaddr, sph_en, chan); } - priv->tso = !!(features &NETIF_F_TSO ); +stmmac_set_gso_types (priv, features &NETIF_F_TSO );if (features &NETIF_F_HW_VLAN_CTAG_RX ) priv->hw->hw_vlan_en = true;
@@ -7828,7 +7834,7 @@ static int __stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ; - priv->tso = true; +stmmac_set_gso_types (priv, true);dev_info (priv->device,"TSO feature enabled\n" ); }
Signature · 1 line
2.47.3
Re: [PATCH net-next 2/2] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
Quoted 10 lines · Russell King (Oracle)
The test in
stmmac_xmit()to see whether we should pass the skbuff tostmmac_tso_xmit()is more complex than it needs to be. This test can be simplified by storing the mask of GSO types that we will pass, and setting it according to the enabled features.Note that "tso" is a mis-nomer since commit
b776620651a1("net:
stmmac: Implement UDP Segmentation Offload"). Also note that this commit controls both via the TSO feature. We preserve this behaviour in this commit.
Quoted 5 lines
Also, this commit unconditionally accessed skb_shinfo(skb)->gso_type for all frames, even when
skb_is_gso()was false. This access is eliminated.Signed-off-by Russell King (Oracle) <[email protected]>
AI review of this patch regurgitates Jakub's point that was discussed.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3700,7 +3700,7 @@ static int stmmac_hw_setup(struct net_device *dev)stmmac_set_rings_length (priv);/* Enable TSO */ -if (priv->tso) { +if (priv->gso_enabled_types) {for (chan =0 ; chan < tx_cnt; chan++) {struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];
...
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_dvr_probe(struct device *device, · line 7837
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -7828,7 +7834,7 @@ static int __stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ; - priv->tso = true; +stmmac_set_gso_types (priv, true);
Clearly, the issue it is regurgitating has been there for a long time and isn't a new issue introduced by this patch.
AI needs to stop doing this, because it is encouraging multiple changes in a single patch, which is against the normal kernel process.
As already pointed out, there are multiple issues with stmmac TSO support, particularly with glue drivers that enable TSO on some queues/channels and not others, since netdev core TSO support is global across all channels.
So, won't the AI response in this patch - it's just another pre- existing issue that needs fixing in a separate patch.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next 2/2] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
Quoted 44 lines · Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)
The test in
stmmac_xmit()to see whether we should pass the skbuff tostmmac_tso_xmit()is more complex than it needs to be. This test can be simplified by storing the mask of GSO types that we will pass, and setting it according to the enabled features.Note that "tso" is a mis-nomer since commit
b776620651a1("net:
stmmac: Implement UDP Segmentation Offload"). Also note that this commit controls both via the TSO feature. We preserve this behaviour in this commit.Quoted 5 lines
Also, this commit unconditionally accessed skb_shinfo(skb)->gso_type for all frames, even when
skb_is_gso()was false. This access is eliminated.Signed-off-by Russell King (Oracle) <[email protected]>AI review of this patch regurgitates Jakub's point that was discussed.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3700,7 +3700,7 @@ static int stmmac_hw_setup(struct net_device *dev)stmmac_set_rings_length (priv);/* Enable TSO */ -if (priv->tso) { +if (priv->gso_enabled_types) {for (chan =0 ; chan < tx_cnt; chan++) {struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];...
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_dvr_probe(struct device *device, · line 7837
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -7828,7 +7834,7 @@ static int __stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ; - priv->tso = true; +stmmac_set_gso_types (priv, true);Clearly, the issue it is regurgitating has been there for a long time and isn't a new issue introduced by this patch.
AI needs to stop doing this, because it is encouraging multiple changes in a single patch, which is against the normal kernel process.
Quoted 7 lines
As already pointed out, there are multiple issues with stmmac TSO support, particularly with glue drivers that enable TSO on some queues/channels and not others, since netdev core TSO support is global across all channels.
So, won't the AI response in this patch - it's just another pre- existing issue that needs fixing in a separate patch.
Looking at the TSO vs TBS issue (which precludes the use of TSO on a channel in stmmac) I can't find an obvious reason for this in the available documentation. However, unfortunately, iMX8MP doesn't support TSO, so the TSO bits are elided there, but does support TBS (needing enhanced descriptors to be enabled). STM32MP151 on the other hand supports TSO but not TBS, and thus fails to mention anything about enhanced descriptors or TBS.
When stmmac_enable_tbs() enables TBS, it isn't actually enabling a feature specific bit, but switching the channel to use enhanced descriptor format. This format extends the basic descriptors by placing four extra 32-bit words before the basic descriptor.
Looking at the enhanced normal descriptor format for TDES3, it indicates that the format includes bit 18 in the control field, which is the TSE bit (TCP segmentation enable for this packet.) So, it seems it's not a limitation of the descriptor format.
So, either "TSO and TBS cannot co-exist" is incorrect, or there is a hardware limitation that isn't documented between these two manuals.
One other interesting point is that stmmac_tso_xmit() seems to handle the case where TSO and TBS are enabled on the channel:
if (tx_q->tbs & STMMAC_TBS_AVAIL)
mss_desc = &tx_q->dma_entx[tx_q->cur_tx].basic;
else
mss_desc = &tx_q->dma_tx[tx_q->cur_tx];
stmmac_set_mss(priv, mss_desc, mss);
...
if (tx_q->tbs & STMMAC_TBS_AVAIL)
desc = &tx_q->dma_entx[first_entry].basic;
else
desc = &tx_q->dma_tx[first_entry];
first = desc;etc.
Avoiding enabling TSO for a TBS channel was added by this commit:
commit 5e6038b88a5718910dd74b949946d9d9cee9a041
Author: Ong Boon Leong <[email protected]> Date: Wed Apr 21 17:11:49 2021 +0800
net: stmmac: fix TSO and TBS feature enabling during driver open
TSO and TBS cannot co-exist and current implementation requires two fixes:
1) stmmac_open() does not need to call stmmac_enable_tbs() because the MAC is reset in stmmac_init_dma_engine() anyway.
2) Inside stmmac_hw_setup(), we should call stmmac_enable_tso() for TX Q that is _not_ configured for TBS.
which doesn't really explain the background, and leaves all the TBS cruft in the TSO transmit path (nothing like properly updating the driver, eh? No wonder stmmac is such a mess!)
Maybe Ong Boon Leong can indicate where this restriction comes from?
Note: as mentioned previously, disabling TSO only on some channels is actually wrong - the netdev core doesn't know which channels support TSO and which don't, so the driver is likely to still get TSO skbuffs for channels that the above commit has disabled TSO support. So, if TBS is enabled and it is incompatible with TSO, then either we need to use software TSO support _or_ disable TSO for the entire interface.
Incidentally, while looking at this, I found a few more pre-conditions for TSO:
- TxPBL must be >= 4
- MSS[13:0] must be more than the configured data width in bytes, up to a maximum of 1023 bytes.
I'm fairly certain that the driver does nothing to ensure that this in the case for either of these two points.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next 2/2] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
Quoted 108 lines · Russell King (Oracle)
Quoted 44 lines · Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)
The test in
stmmac_xmit()to see whether we should pass the skbuff tostmmac_tso_xmit()is more complex than it needs to be. This test can be simplified by storing the mask of GSO types that we will pass, and setting it according to the enabled features.Note that "tso" is a mis-nomer since commit
b776620651a1("net:
stmmac: Implement UDP Segmentation Offload"). Also note that this commit controls both via the TSO feature. We preserve this behaviour in this commit.Quoted 5 lines
Also, this commit unconditionally accessed skb_shinfo(skb)->gso_type for all frames, even when
skb_is_gso()was false. This access is eliminated.Signed-off-by Russell King (Oracle) <[email protected]>AI review of this patch regurgitates Jakub's point that was discussed.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3700,7 +3700,7 @@ static int stmmac_hw_setup(struct net_device *dev)stmmac_set_rings_length (priv);/* Enable TSO */ -if (priv->tso) { +if (priv->gso_enabled_types) {for (chan =0 ; chan < tx_cnt; chan++) {struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];...
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_dvr_probe(struct device *device, · line 7837
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -7828,7 +7834,7 @@ static int __stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ; - priv->tso = true; +stmmac_set_gso_types (priv, true);Clearly, the issue it is regurgitating has been there for a long time and isn't a new issue introduced by this patch.
AI needs to stop doing this, because it is encouraging multiple changes in a single patch, which is against the normal kernel process.
Quoted 7 lines
As already pointed out, there are multiple issues with stmmac TSO support, particularly with glue drivers that enable TSO on some queues/channels and not others, since netdev core TSO support is global across all channels.
So, won't the AI response in this patch - it's just another pre- existing issue that needs fixing in a separate patch.
Looking at the TSO vs TBS issue (which precludes the use of TSO on a channel in stmmac) I can't find an obvious reason for this in the available documentation. However, unfortunately, iMX8MP doesn't support TSO, so the TSO bits are elided there, but does support TBS (needing enhanced descriptors to be enabled). STM32MP151 on the other hand supports TSO but not TBS, and thus fails to mention anything about enhanced descriptors or TBS.
When
stmmac_enable_tbs()enables TBS, it isn't actually enabling a feature specific bit, but switching the channel to use enhanced descriptor format. This format extends the basic descriptors by placing four extra 32-bit words before the basic descriptor.Looking at the enhanced normal descriptor format for TDES3, it indicates that the format includes bit 18 in the control field, which is the TSE bit (TCP segmentation enable for this packet.) So, it seems it's not a limitation of the descriptor format.
So, either "TSO and TBS cannot co-exist" is incorrect, or there is a hardware limitation that isn't documented between these two manuals.
One other interesting point is that
stmmac_tso_xmit()seems to handle the case where TSO and TBS are enabled on the channel:if (tx_q->tbs & STMMAC_TBS_AVAIL) mss_desc = &tx_q->dma_entx[tx_q->cur_tx].basic; else mss_desc = &tx_q->dma_tx[tx_q->cur_tx]; stmmac_set_mss(priv, mss_desc, mss); ... if (tx_q->tbs & STMMAC_TBS_AVAIL) desc = &tx_q->dma_entx[first_entry].basic; else desc = &tx_q->dma_tx[first_entry]; first = desc;etc.
Avoiding enabling TSO for a TBS channel was added by this commit:
commit
5e6038b88a5718910dd74b949946d9d9cee9a041Author: Ong Boon Leong <[email protected]> Date: Wed Apr 21 17:11:49 2021 +0800net: stmmac: fix TSO and TBS feature enabling during driver open
TSO and TBS cannot co-exist and current implementation requires two fixes:
1)
stmmac_open()does not need to callstmmac_enable_tbs()because the MAC is reset instmmac_init_dma_engine()anyway.
2) Insidestmmac_hw_setup(), we should callstmmac_enable_tso()for TX Q that is _not_ configured for TBS.
Quoted 7 lines
Fixes 579a25a854d4 ("net: stmmac: Initial support for TBS")Signed-off-by Ong Boon Leong <[email protected]>Signed-off-by David S. Miller <[email protected]>which doesn't really explain the background, and leaves all the TBS cruft in the TSO transmit path (nothing like properly updating the driver, eh? No wonder stmmac is such a mess!)
The more I look at this, the more I'm convinced this commit is incorrect, even if it is the case that the hardware doesn't support TSO and TBS together.
When TSO is enabled (NETIF_F_TSO set in the netif's features) then the core net layer can submit skbuffs that need to be processed using TSO.
If such a skbuff hits a channel that has TSO disabled (because the above commit caused:
stmmac_enable_tso(priv, priv->ioaddr, 1, chan);
not to be called) then the TSE bit in the transmit control register will not be set, thereby disabling TSO on this particular channel.
However, stmmac_xmit() will still call through to stmmac_tso_xmit() which will dutifully populate the transmit ring with descriptors that assume TSE has been set in the transmit control register.
It seems to me _that_ is even more broken than "the hardware doesn't support TSO and TBS together" - I have no idea what the stmmac hardware does if it encounters descriptors with TSE set but TSE is disabled in the transmit control register. My guess would be it would ignore the TSE bit in the descriptor and assume that it's one very large packet to be sent - and either error out because it's longer than the maximum the hardware can support or it will just try to transmit it anyway.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next 2/2] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
Quoted 137 lines · Russell King (Oracle)
Quoted 108 lines · Russell King (Oracle)
Quoted 44 lines · Russell King (Oracle)
Quoted 10 lines · Russell King (Oracle)
The test in
stmmac_xmit()to see whether we should pass the skbuff tostmmac_tso_xmit()is more complex than it needs to be. This test can be simplified by storing the mask of GSO types that we will pass, and setting it according to the enabled features.Note that "tso" is a mis-nomer since commit
b776620651a1("net:
stmmac: Implement UDP Segmentation Offload"). Also note that this commit controls both via the TSO feature. We preserve this behaviour in this commit.Quoted 5 lines
Also, this commit unconditionally accessed skb_shinfo(skb)->gso_type for all frames, even when
skb_is_gso()was false. This access is eliminated.Signed-off-by Russell King (Oracle) <[email protected]>AI review of this patch regurgitates Jakub's point that was discussed.
Quoted 9 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -3700,7 +3700,7 @@ static int stmmac_hw_setup(struct net_device *dev)stmmac_set_rings_length (priv);/* Enable TSO */ -if (priv->tso) { +if (priv->gso_enabled_types) {for (chan =0 ; chan < tx_cnt; chan++) {struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[chan];...
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c static int __stmmac_dvr_probe(struct device *device, · line 7837
Quoted 6 lines
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1
-1@@ -7828,7 +7834,7 @@ static int __stmmac_dvr_probe(struct device *device, ndev->hw_features |=NETIF_F_TSO |NETIF_F_TSO6 ;if (priv->plat->core_type ==DWMAC_CORE_GMAC4 ) ndev->hw_features |=NETIF_F_GSO_UDP_L4 ; - priv->tso = true; +stmmac_set_gso_types (priv, true);Clearly, the issue it is regurgitating has been there for a long time and isn't a new issue introduced by this patch.
AI needs to stop doing this, because it is encouraging multiple changes in a single patch, which is against the normal kernel process.
Quoted 7 lines
As already pointed out, there are multiple issues with stmmac TSO support, particularly with glue drivers that enable TSO on some queues/channels and not others, since netdev core TSO support is global across all channels.
So, won't the AI response in this patch - it's just another pre- existing issue that needs fixing in a separate patch.
Looking at the TSO vs TBS issue (which precludes the use of TSO on a channel in stmmac) I can't find an obvious reason for this in the available documentation. However, unfortunately, iMX8MP doesn't support TSO, so the TSO bits are elided there, but does support TBS (needing enhanced descriptors to be enabled). STM32MP151 on the other hand supports TSO but not TBS, and thus fails to mention anything about enhanced descriptors or TBS.
When
stmmac_enable_tbs()enables TBS, it isn't actually enabling a feature specific bit, but switching the channel to use enhanced descriptor format. This format extends the basic descriptors by placing four extra 32-bit words before the basic descriptor.Looking at the enhanced normal descriptor format for TDES3, it indicates that the format includes bit 18 in the control field, which is the TSE bit (TCP segmentation enable for this packet.) So, it seems it's not a limitation of the descriptor format.
So, either "TSO and TBS cannot co-exist" is incorrect, or there is a hardware limitation that isn't documented between these two manuals.
One other interesting point is that
stmmac_tso_xmit()seems to handle the case where TSO and TBS are enabled on the channel:if (tx_q->tbs & STMMAC_TBS_AVAIL) mss_desc = &tx_q->dma_entx[tx_q->cur_tx].basic; else mss_desc = &tx_q->dma_tx[tx_q->cur_tx]; stmmac_set_mss(priv, mss_desc, mss); ... if (tx_q->tbs & STMMAC_TBS_AVAIL) desc = &tx_q->dma_entx[first_entry].basic; else desc = &tx_q->dma_tx[first_entry]; first = desc;etc.
Avoiding enabling TSO for a TBS channel was added by this commit:
commit
5e6038b88a5718910dd74b949946d9d9cee9a041Author: Ong Boon Leong <[email protected]> Date: Wed Apr 21 17:11:49 2021 +0800net: stmmac: fix TSO and TBS feature enabling during driver open
TSO and TBS cannot co-exist and current implementation requires two fixes:
1)
stmmac_open()does not need to callstmmac_enable_tbs()because the MAC is reset instmmac_init_dma_engine()anyway.
2) Insidestmmac_hw_setup(), we should callstmmac_enable_tso()for TX Q that is _not_ configured for TBS.Quoted 7 lines
Fixes 579a25a854d4 ("net: stmmac: Initial support for TBS")Signed-off-by Ong Boon Leong <[email protected]>Signed-off-by David S. Miller <[email protected]>which doesn't really explain the background, and leaves all the TBS cruft in the TSO transmit path (nothing like properly updating the driver, eh? No wonder stmmac is such a mess!)
The more I look at this, the more I'm convinced this commit is incorrect, even if it is the case that the hardware doesn't support TSO and TBS together.
When TSO is enabled (
NETIF_F_TSOset in the netif's features) then the core net layer can submit skbuffs that need to be processed using TSO.If such a skbuff hits a channel that has TSO disabled (because the above commit caused:
stmmac_enable_tso(priv, priv->ioaddr, 1, chan);not to be called) then the TSE bit in the transmit control register will not be set, thereby disabling TSO on this particular channel.
However,
stmmac_xmit()will still call through tostmmac_tso_xmit()which will dutifully populate the transmit ring with descriptors that assume TSE has been set in the transmit control register.
Quoted 8 lines
It seems to me _that_ is even more broken than "the hardware doesn't support TSO and TBS together" - I have no idea what the stmmac hardware does if it encounters descriptors with TSE set but TSE is disabled in the transmit control register. My guess would be it would ignore the TSE bit in the descriptor and assume that it's one very large packet to be sent - and either error out because it's longer than the maximum the hardware can support or it will just try to transmit it anyway.
Okay, I've found a statement in the stm32mp25xx documentation which backs up Intel's commit, but that commit is still wrong because it only half does the job.
However, I think I now have a solution - implementing .ndo_features_check() which will mask out the NETIF_F_GSO_MASK features if either the header length is greater than 1023 (the hardware maximum) or the queue (as returned by skb_get_queue_mapping(skb)) is for a queue which has TBS available, and thus has TSO disabled.
I'm surprised we haven't had reports of brokenness in this area.
I think it's time to re-shuffle these patches (plus I think there's a bit more scope to clean up some of the TSO code which would mean placing stmmac_set_gso_types() in a different location to keep all the TSO-related code together. I'll mark this series as superseded once I have its replacement ready.
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net-next 2/2] net: stmmac: simplify GSO/TSO test in stmmac_xmit()
Quoted 1 line
I'm surprised we haven't had reports of brokenness in this area.
Could a self test be written for this case?
Andrew