]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/ethernet/cadence/macb_main.c
net: macb: Limit maximum GEM TX length in TSO
[linux.git] / drivers / net / ethernet / cadence / macb_main.c
index 7a2fe63d1136877b1ab0fad1297c0b2e3259b107..4508f0d150da95d8e838d0ead806e8ef74794cc5 100644 (file)
@@ -73,7 +73,11 @@ struct sifive_fu540_macb_mgmt {
 /* Max length of transmit frame must be a multiple of 8 bytes */
 #define MACB_TX_LEN_ALIGN      8
 #define MACB_MAX_TX_LEN                ((unsigned int)((1 << MACB_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1)))
-#define GEM_MAX_TX_LEN         ((unsigned int)((1 << GEM_TX_FRMLEN_SIZE) - 1) & ~((unsigned int)(MACB_TX_LEN_ALIGN - 1)))
+/* Limit maximum TX length as per Cadence TSO errata. This is to avoid a
+ * false amba_error in TX path from the DMA assuming there is not enough
+ * space in the SRAM (16KB) even when there is.
+ */
+#define GEM_MAX_TX_LEN         (unsigned int)(0x3FC0)
 
 #define GEM_MTU_MIN_SIZE       ETH_MIN_MTU
 #define MACB_NETIF_LSO         NETIF_F_TSO
@@ -1791,16 +1795,14 @@ static netdev_features_t macb_features_check(struct sk_buff *skb,
 
        /* Validate LSO compatibility */
 
-       /* there is only one buffer */
-       if (!skb_is_nonlinear(skb))
+       /* there is only one buffer or protocol is not UDP */
+       if (!skb_is_nonlinear(skb) || (ip_hdr(skb)->protocol != IPPROTO_UDP))
                return features;
 
        /* length of header */
        hdrlen = skb_transport_offset(skb);
-       if (ip_hdr(skb)->protocol == IPPROTO_TCP)
-               hdrlen += tcp_hdrlen(skb);
 
-       /* For LSO:
+       /* For UFO only:
         * When software supplies two or more payload buffers all payload buffers
         * apart from the last must be a multiple of 8 bytes in size.
         */