net: stmmac: Tx coe sw fallback
authorRohan G Thomas <rohan.g.thomas@intel.com>
Sat, 16 Sep 2023 06:33:12 +0000 (14:33 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 18 Sep 2023 10:37:08 +0000 (11:37 +0100)
Add sw fallback of tx checksum calculation for those tx queues that
don't support tx checksum offloading. DW xGMAC IP can be synthesized
such that it can support tx checksum offloading only for a few
initial tx queues. Also as Serge pointed out, for the DW QoS IP, tx
coe can be individually configured for each tx queue.

So when tx coe is enabled, for any tx queue that doesn't support
tx coe with 'coe-unsupported' flag set will have a sw fallback
happen in the driver for tx checksum calculation when any packets to
be transmitted on these tx queues.

Signed-off-by: Rohan G Thomas <rohan.g.thomas@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
include/linux/stmmac.h

index 2206789802bf78d9068bc7dc6cc2e46be423649c..9201ed778ebcf1085906110783963e0e27d20481 100644 (file)
@@ -4401,6 +4401,16 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
        WARN_ON(tx_q->tx_skbuff[first_entry]);
 
        csum_insertion = (skb->ip_summed == CHECKSUM_PARTIAL);
+       /* DWMAC IPs can be synthesized to support tx coe only for a few tx
+        * queues. In that case, checksum offloading for those queues that don't
+        * support tx coe needs to fallback to software checksum calculation.
+        */
+       if (csum_insertion &&
+           priv->plat->tx_queues_cfg[queue].coe_unsupported) {
+               if (unlikely(skb_checksum_help(skb)))
+                       goto dma_map_err;
+               csum_insertion = !csum_insertion;
+       }
 
        if (likely(priv->extend_desc))
                desc = (struct dma_desc *)(tx_q->dma_etx + entry);
index 0f28795e581c23957fba5c81c83ba9d248521a97..a09014c9e7d0ae2d3c991bf1bcd3257c6a103afb 100644 (file)
@@ -276,6 +276,9 @@ static int stmmac_mtl_setup(struct platform_device *pdev,
                        plat->tx_queues_cfg[queue].use_prio = true;
                }
 
+               plat->tx_queues_cfg[queue].coe_unsupported =
+                       of_property_read_bool(q_node, "snps,coe-unsupported");
+
                queue++;
        }
        if (queue != plat->tx_queues_to_use) {
index ce89cc3e491354c8a5054ccaeda5d68fa5fd2e64..c0079a7574ae6233221d99c802c1c59aaf26da2f 100644 (file)
@@ -139,6 +139,7 @@ struct stmmac_rxq_cfg {
 
 struct stmmac_txq_cfg {
        u32 weight;
+       bool coe_unsupported;
        u8 mode_to_use;
        /* Credit Base Shaper parameters */
        u32 send_slope;