Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6276273ybx; Mon, 11 Nov 2019 06:44:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwaWUjpBHmsnAdilMgHYVxJ5jQdOB6P8Nm4uF4cLhyKOK10oHLnxUODAxoqua7ActiYTPPc X-Received: by 2002:a17:906:ecf5:: with SMTP id qt21mr22660075ejb.295.1573483451114; Mon, 11 Nov 2019 06:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573483451; cv=none; d=google.com; s=arc-20160816; b=v+E7I/M3dfJLxfOmBF/t7WzK/agYJG5Joj1RTVUravO3cQudLDzaskTTLkr3tI31iW j+45rzW/FVk+iAiz5vrOEVGtuO0xIx18HIKJ8joKs581DSdMZDZODcJLgQaUZSjAcJMg WoPup12DfahCjfRzWWftAi0H9zqWU88fP96eNvMbaRIV4eRlAChRwpaur3HQmSBES0I+ 5LbGLwwmhxC2/DdWTY6VnhwJVn3pYLopyUQohsDGMa4S/Z0W8MxuFMeGc7i47SB+VrcR j3vo1qiO6cjE4WsfQ64WK07LVyxfMnsU56aVy1NfFcoZW0TWgwRVrORcQKibzTjtqkWh Tktg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=aHFvkJ9JgW/542p4eJHMX08mMr2BpA6DR+kpA3QkcM8=; b=firl2uO8qBWsHeOBRq6yILX5uZeCMIwSRTYZAZL9BK/CD2GFDFKhFgFqn/zY46pcX6 8Hu1eugH8hR1/qK2lqwhWlL+vjVOg8u2ek3A9EWAnZX0eT6mwmA7MZNHVx1R+ULPEmAn efeByTqOr8Pp/xIF4/HqsFldeQJ+HOmxk9kjEwNwT8QhY693eQDOy2B3UQLGK1yi9rrF S0/ZSAvgrhpJFGSFWBsybAhkVFq6ntp7A/OXYkmpUlGneS7wYab+84M/eEIroN8qH06/ N8bnLyBhR6ei7QuNoeiINjO0d/pULgI7xZszKjr6QB/dNE9Z2rpTGdNlsWMb4GEl9Ttj Rf8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=hbn0NJ+m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si9686170edv.43.2019.11.11.06.43.46; Mon, 11 Nov 2019 06:44:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=hbn0NJ+m; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbfKKOnF (ORCPT + 99 others); Mon, 11 Nov 2019 09:43:05 -0500 Received: from us03-smtprelay2.synopsys.com ([149.117.87.133]:55184 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726877AbfKKOnF (ORCPT ); Mon, 11 Nov 2019 09:43:05 -0500 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 8422FC08BA; Mon, 11 Nov 2019 14:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1573483383; bh=EoTBZOC0Je6korS7Ma+EpCD7GT0gwifStY63b9qn/QM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=hbn0NJ+mb/rTGEomSAZ4/TiBwfPh7NpN2ndEFXioU0VRtifnVv8mwXrzxpss9syqz WLXHnVtHFcyNNOjIVG7AlWNOxaxt/F89Zls9BDrBRDh28+iTQoyshwXY4mReHFODlK RCXQ/t+/EL8Dal16GUPwVvtiOoI1JxZwaRcbkhWtUKUIwVe3xsLxzCvF4ZxKon8gBL mWkJRDObUtMdvSxAaucvEdN5/15WxIEtkcy5WyJiU3gAWw3mb+MiULcriweMFPHpVW 7uK7Q3kZpV0jGxJhIr5sP8M+CugVf4UdVTGN82pW/IMWwOKcdbwrJud+A4YRGkIuCX gn1rDEw3/ckEw== Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by mailhost.synopsys.com (Postfix) with ESMTP id 3E315A025B; Mon, 11 Nov 2019 14:42:57 +0000 (UTC) From: Jose Abreu To: netdev@vger.kernel.org Cc: Joao Pinto , Jose Abreu , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/6] net: stmmac: Implement UDP Segmentation Offload Date: Mon, 11 Nov 2019 15:42:39 +0100 Message-Id: <7a62a0532edaec95312308d7a4ced7eae331bc6d.1573482992.git.Jose.Abreu@synopsys.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement the UDP Segmentation Offload feature in stmmac. This is only available in GMAC4+ cores. Signed-off-by: Jose Abreu --- Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Cc: Jose Abreu Cc: "David S. Miller" Cc: Maxime Coquelin Cc: netdev@vger.kernel.org Cc: linux-stm32@st-md-mailman.stormreply.com Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 32 ++++++++++++++++------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index a2fac7772666..39b4efd521f9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -36,6 +36,7 @@ #endif /* CONFIG_DEBUG_FS */ #include #include +#include #include #include "stmmac_ptp.h" #include "stmmac.h" @@ -2916,9 +2917,9 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) u32 queue = skb_get_queue_mapping(skb); struct stmmac_tx_queue *tx_q; unsigned int first_entry; + u8 proto_hdr_len, hdr; int tmp_pay_len = 0; u32 pay_len, mss; - u8 proto_hdr_len; dma_addr_t des; bool has_vlan; int i; @@ -2926,7 +2927,13 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev) 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) < @@ -2956,8 +2963,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); } @@ -3071,7 +3078,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) { @@ -3130,6 +3137,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; struct dma_desc *desc, *first; struct stmmac_tx_queue *tx_q; unsigned int first_entry; @@ -3145,7 +3153,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); } @@ -4036,11 +4046,13 @@ static int stmmac_setup_tc(struct net_device *ndev, enum tc_setup_type type, static u16 stmmac_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev) { - 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; @@ -4555,6 +4567,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"); } -- 2.7.4