mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 19:30:30 +09:00
UPSTREAM: net: stmmac: Implement UDP Segmentation Offload
Implement the UDP Segmentation Offload feature in stmmac. This is only
available in GMAC4+ cores.
Change-Id: I36bbc42ddadc3957ec0134b38e1c04d5d0ce87a7
Signed-off-by: Jose Abreu <Jose.Abreu@synopsys.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: David Wu <david.wu@rock-chips.com>
(cherry picked from commit b776620651)
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#include <linux/seq_file.h>
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
#include <linux/net_tstamp.h>
|
||||
#include <linux/udp.h>
|
||||
#include <net/pkt_cls.h>
|
||||
#include "stmmac_ptp.h"
|
||||
#include "stmmac.h"
|
||||
@@ -2849,16 +2850,22 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
int nfrags = skb_shinfo(skb)->nr_frags;
|
||||
u32 queue = skb_get_queue_mapping(skb);
|
||||
unsigned int first_entry, des;
|
||||
u8 proto_hdr_len, hdr;
|
||||
struct stmmac_tx_queue *tx_q;
|
||||
int tmp_pay_len = 0;
|
||||
u32 pay_len, mss;
|
||||
u8 proto_hdr_len;
|
||||
int i;
|
||||
|
||||
tx_q = &priv->tx_queue[queue];
|
||||
|
||||
/* Compute header lengths */
|
||||
proto_hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
|
||||
if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) {
|
||||
proto_hdr_len = skb_transport_offset(skb) + sizeof(struct udphdr);
|
||||
hdr = sizeof(struct udphdr);
|
||||
} else {
|
||||
proto_hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
|
||||
hdr = tcp_hdrlen(skb);
|
||||
}
|
||||
|
||||
/* Desc availability based on threshold should be enough safe */
|
||||
if (unlikely(stmmac_tx_avail(priv, queue) <
|
||||
@@ -2888,8 +2895,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
}
|
||||
|
||||
if (netif_msg_tx_queued(priv)) {
|
||||
pr_info("%s: tcphdrlen %d, hdr_len %d, pay_len %d, mss %d\n",
|
||||
__func__, tcp_hdrlen(skb), proto_hdr_len, pay_len, mss);
|
||||
pr_info("%s: hdrlen %d, hdr_len %d, pay_len %d, mss %d\n",
|
||||
__func__, hdr, proto_hdr_len, pay_len, mss);
|
||||
pr_info("\tskb->len %d, skb->data_len %d\n", skb->len,
|
||||
skb->data_len);
|
||||
}
|
||||
@@ -2987,7 +2994,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
proto_hdr_len,
|
||||
pay_len,
|
||||
1, tx_q->tx_skbuff_dma[first_entry].last_segment,
|
||||
tcp_hdrlen(skb) / 4, (skb->len - proto_hdr_len));
|
||||
hdr / 4, (skb->len - proto_hdr_len));
|
||||
|
||||
/* If context desc is used to change MSS */
|
||||
if (mss_desc) {
|
||||
@@ -3047,6 +3054,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
int i, csum_insertion = 0, is_jumbo = 0;
|
||||
u32 queue = skb_get_queue_mapping(skb);
|
||||
int nfrags = skb_shinfo(skb)->nr_frags;
|
||||
int gso = skb_shinfo(skb)->gso_type;
|
||||
int entry;
|
||||
unsigned int first_entry;
|
||||
struct dma_desc *desc, *first;
|
||||
@@ -3061,7 +3069,9 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
|
||||
/* Manage oversized TCP frames for GMAC4 device */
|
||||
if (skb_is_gso(skb) && priv->tso) {
|
||||
if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))
|
||||
if (gso & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))
|
||||
return stmmac_tso_xmit(skb, dev);
|
||||
if (priv->plat->has_gmac4 && (gso & SKB_GSO_UDP_L4))
|
||||
return stmmac_tso_xmit(skb, dev);
|
||||
}
|
||||
|
||||
@@ -3891,11 +3901,13 @@ static u16 stmmac_select_queue(struct net_device *dev, struct sk_buff *skb,
|
||||
struct net_device *sb_dev,
|
||||
select_queue_fallback_t fallback)
|
||||
{
|
||||
if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
|
||||
int gso = skb_shinfo(skb)->gso_type;
|
||||
|
||||
if (gso & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6 | SKB_GSO_UDP_L4)) {
|
||||
/*
|
||||
* There is no way to determine the number of TSO
|
||||
* There is no way to determine the number of TSO/USO
|
||||
* capable Queues. Let's use always the Queue 0
|
||||
* because if TSO is supported then at least this
|
||||
* because if TSO/USO is supported then at least this
|
||||
* one will be capable.
|
||||
*/
|
||||
return 0;
|
||||
@@ -4373,6 +4385,8 @@ int stmmac_dvr_probe(struct device *device,
|
||||
|
||||
if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) {
|
||||
ndev->hw_features |= NETIF_F_TSO | NETIF_F_TSO6;
|
||||
if (priv->plat->has_gmac4)
|
||||
ndev->hw_features |= NETIF_F_GSO_UDP_L4;
|
||||
priv->tso = true;
|
||||
dev_info(priv->device, "TSO feature enabled\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user