From patchwork Fri May 10 22:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13661972 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00B6D13CFAB for ; Fri, 10 May 2024 22:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378938; cv=none; b=dHhLKsamE5o9KCFEKBKM3AAtNSaNfChB2hf7t662khWTtoZHvRpnR/8Xegm5lVPvwHjA0XxTxhOaHqVbj01o5yQVVVogL17RUrED0li2AwEvHqbRbEZPOhPtULlKBd3gHxOuNHGu5A0P+0Cesr/6SBIso90OqJwoAilNSrp93y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378938; c=relaxed/simple; bh=TOcnDy0PN34+98xhqM6Q+UsUioQYwT3XmDQis0oaur4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pr15/rVrheUFKJgvl8OWUq6+EU6LBqH1xWt+Z5KINMm1lxQveTE8i2dBfMhVxoWpJ4i6NUIMITIsLZgky3UdHBFG5oNhFFJHq/BOJ6OANyLKVGWuGL1ilkUwixgky6qAGy/7cO5z/Og5wE/oyaOzN1mi+I69TJdPFAAAXBh9YQ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=zXbB+Zpy; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zXbB+Zpy" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a59a609dd3fso440476566b.0 for ; Fri, 10 May 2024 15:08:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715378935; x=1715983735; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GkfteHNXU4Gc7U7F5jS8dOpIBUIN8TpFTqroJmbcsZ8=; b=zXbB+Zpy9I2UhQ1TlUiibvwd4t3YWkm+OWyd3CsCTn/Z4WLPrLnRGdNwVNlF7GvMQF QdM+NseqHIfhTaAZSldi46l6IonZ/k8KCgbzutavXyT5SLdPVZ0IR5GQdudcHNbK41aO C/KmPW9t2X+Y/Ci5R87g2Xs7IszXqzDu77ZVOhSGNpgMCtv9y+oraFkKgualN+tb/jVH JMQQKOun/SiR5LcqYMI4CTo+a+ivsMlxKy3+i0/7WJ9vTDCrCHiQrN0PqkmEtFUrAi7r LHQUKprpRgHhk3/JzSeaFZCag8bhn5REvRBKiKrbd62n8KFw8O7I5Ui79C5zbRGi0KPT D7Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715378935; x=1715983735; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GkfteHNXU4Gc7U7F5jS8dOpIBUIN8TpFTqroJmbcsZ8=; b=MJGI+4Pot7AVbPbDCMDSzqfq06NamRtYBZ83OkF92I4Cz19tYIZGiyEUwvCqEkjCZg WgnUiCXK5xpKcr6e7oSxKwfc0IhTsB3hcbkFJ57dmY1TYgpxHneQ0PS1MPWmNjJ1KGOa O48SosvtG0shCUwo03xakA3bbV4bRlSj+SkVcqkA0i5Athu8WdNn5v1yopNRsGlIkfzS JmLdG41jaIA0WvlyiEaLpcLJxIKibMRaw0qY1P9zv/ZZA9nqCnVknSrrg/Atz/swpE3B 79ih97Dr4pnprWTscpz5jm9kB93t6CQNk3D4dH6M+dLCQQay1dvay97wWAukL6o2RsCl C7VA== X-Gm-Message-State: AOJu0YxLa2eJ6al3ybfwygoWPxtuYnrKBc9mbmHfeMFd5gKRuB3fGLrG +EUdcmMg5adThumhoBUozWG5XHBX+KLPCHhf5ONuY9L4N8JwMq5+CsBpalHJbHeoryqRuFMiLoL l X-Google-Smtp-Source: AGHT+IFZv8zxor3aelYx0Z+QuoX97OOpApTZXRfWJNtP4SdKsu9Fc5JVznA7ZNAdzNSQNOws8XG/QQ== X-Received: by 2002:a17:906:b7c4:b0:a59:bb24:a61 with SMTP id a640c23a62f3a-a5a2d292a23mr325908966b.30.1715378935372; Fri, 10 May 2024 15:08:55 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781ce3fsm228219866b.4.2024.05.10.15.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:08:54 -0700 (PDT) From: Linus Walleij Date: Sat, 11 May 2024 00:08:39 +0200 Subject: [PATCH net-next v2 1/5] net: ethernet: cortina: Restore TSO support Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-gemini-ethernet-fix-tso-v2-1-2ed841574624@linaro.org> References: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> In-Reply-To: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org An earlier commit deleted the TSO support in the Cortina Gemini driver because the driver was confusing gso_size and MTU, probably because what the Linux kernel calls "gso_size" was called "MTU" in the datasheet. Restore the functionality properly reading the gso_size from the skbuff. Tested with iperf3, running a server on a different machine and client on the device with the cortina gemini ethernet: Connecting to host 192.168.1.2, port 5201 60008000.ethernet-port eth0: segment offloading mss = 05ea len=1c8a 60008000.ethernet-port eth0: segment offloading mss = 05ea len=1c8a 60008000.ethernet-port eth0: segment offloading mss = 05ea len=27da 60008000.ethernet-port eth0: segment offloading mss = 05ea len=0b92 60008000.ethernet-port eth0: segment offloading mss = 05ea len=2bda (...) (The hardware MSS 0x05ea here includes the ethernet headers.) If I disable all segment offloading on the receiving host and dump packets using tcpdump -xx like this: ethtool -K enp2s0 gro off gso off tso off tcpdump -xx -i enp2s0 host 192.168.1.136 I get segmented packages such as this when running iperf3: 23:16:54.024139 IP OpenWrt.lan.59168 > Fecusia.targus-getdata1: Flags [.], seq 1486:2934, ack 1, win 4198, options [nop,nop,TS val 3886192908 ecr 3601341877], length 1448 0x0000: fc34 9701 a0c6 14d6 4da8 3c4f 0800 4500 0x0010: 05dc 16a0 4000 4006 9aa1 c0a8 0188 c0a8 0x0020: 0102 e720 1451 ff25 9822 4c52 29cf 8010 0x0030: 1066 ac8c 0000 0101 080a e7a2 990c d6a8 (...) 0x05c0: 5e49 e109 fe8c 4617 5e18 7a82 7eae d647 0x05d0: e8ee ae64 dc88 c897 3f8a 07a4 3a33 6b1b 0x05e0: 3501 a30f 2758 cc44 4b4a Several such packets often follow after each other verifying the segmentation into 0x05a8 (1448) byte packages also on the reveiving end. As can be seen, the ethernet frames are 0x05ea (1514) in size. Performance with iperf3 before this patch: ~15.5 Mbit/s Performance with iperf3 after this patch: ~175 Mbit/s This was running a 60 second test (twice) the best measurement was 179 Mbit/s. For comparison if I run iperf3 with UDP I get around 1.05 Mbit/s both before and after this patch. While this is a gigabit ethernet interface, the CPU is a cheap D-Link DIR-685 router (based on the ARMv5 Faraday FA526 at ~50 MHz), and the software is not supposed to drive traffic, as the device has a DSA chip, so this kind of numbers can be expected. Fixes: ac631873c9e7 ("net: ethernet: cortina: Drop TSO support") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index f9523022be9b..b2ac9dfe1aae 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -79,7 +79,8 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); #define GMAC0_IRQ4_8 (GMAC0_MIB_INT_BIT | GMAC0_RX_OVERRUN_INT_BIT) #define GMAC_OFFLOAD_FEATURES (NETIF_F_SG | NETIF_F_IP_CSUM | \ - NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM) + NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | \ + NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) /** * struct gmac_queue_page - page buffer per-page info @@ -1148,13 +1149,25 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, skb_frag_t *skb_frag; dma_addr_t mapping; void *buffer; + u16 mss; int ret; - /* TODO: implement proper TSO using MTU in word3 */ word1 = skb->len; word3 = SOF_BIT; - if (skb->len >= ETH_FRAME_LEN) { + mss = skb_shinfo(skb)->gso_size; + if (mss) { + /* This means we are dealing with TCP and skb->len is the + * sum total of all the segments. The TSO will deal with + * chopping this up for us. + */ + /* The accelerator needs the full frame size here */ + mss += skb_tcp_all_headers(skb); + netdev_dbg(netdev, "segment offloading mss = %04x len=%04x\n", + mss, skb->len); + word1 |= TSS_MTU_ENABLE_BIT; + word3 |= mss; + } else if (skb->len >= ETH_FRAME_LEN) { /* Hardware offloaded checksumming isn't working on frames * bigger than 1514 bytes. A hypothesis about this is that the * checksum buffer is only 1518 bytes, so when the frames get @@ -1169,7 +1182,9 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, return ret; } word1 |= TSS_BYPASS_BIT; - } else if (skb->ip_summed == CHECKSUM_PARTIAL) { + } + + if (skb->ip_summed == CHECKSUM_PARTIAL) { int tcp = 0; /* We do not switch off the checksumming on non TCP/UDP From patchwork Fri May 10 22:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13661973 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 417E613CFB7 for ; Fri, 10 May 2024 22:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378940; cv=none; b=iVnIAGTAFs3dlZTjO4QNLK8ijZ6GMYQlz9Lr7gnK44eEX8RVoqXG08geziixHkcNtga2KDP6dKjHWq7o9awNDdF02Mah+4Ej22UKg/FSlCP/i2vuV6JaBmNrKhXIyXUkGjmT6od2ri+VExQzZHE5Gcq8wlSbxakQ1L1PAZg+j/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378940; c=relaxed/simple; bh=b2ZaZuAXoLgiE853TvZNovEefrO1OrW6SCZpSyhLG9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cpieK5ywXX5vfuOcvg5VQMaqaNPLOJrdfg/WgZnH+7O06SJqQzPqnfWfGrWTSLirBlpjuG3sGHBQkJDBhti3jl13eCaLMo/nUIT6uWIWlSEScYCW9rZsBiLHx2OFVpxeEzGHy0QN9XrAK/fVdErxAiX26K8fEzjbeuGyA3R9mkg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=faUWGNhZ; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="faUWGNhZ" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51f71e4970bso2895641e87.2 for ; Fri, 10 May 2024 15:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715378936; x=1715983736; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kFSaFpCcqr8xkac6+4cEe6s97eneJvsC2wKr3pUSeSQ=; b=faUWGNhZ+u/H703XIiS0I7WSnuGKYTnn0V70gxqaLemkpw49LaYfLF1fCGcc1o8qnm PpDVLGh2O8uCNu2d14LFPaKZAE060Mgew6vVnKrdJpmFUeUXNveQ8kDxwOa2SfCloJ+I eJL86dZHSwhBsbl6bZKMyntV7lIUdW60XLJXzZpmLcu9ZDqTT/9Y7iWeJmgnZZHxDgcA ObAOcylh/OIGGo1QvoRZSOgYIYPZIr4PHgmaAtgQuDIta2Hmtc9jQchMpSj+dnZ7ZJ8d rOUNY0yyD2ipeh1a75WF5bu6Kc5UinDDWtoFQeh6LFn+0ut7bDgRJLdqVUSBnjKvppFi Xr3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715378936; x=1715983736; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kFSaFpCcqr8xkac6+4cEe6s97eneJvsC2wKr3pUSeSQ=; b=JwQQI/3vjQRaywIU45vhTt5iynCln+lPCzPimc1QuZwCR8/00Zvwn3sHTozQ8lFxcr OUGhwz/TJApqlfTmFf0IBnM1D4bU3jJOsBtDbG/1ktMLY0y017esle7KX9B1zQCCgW2A OxNUihHuluTDLLRZu5H3SvypK7YYf57wCWlnc2Va9xpMxc5yVRSfaw6jN4BXopm/Re0Z 9uZ+N1WweI1PRZmx9noSUy5g6/7ZDROoNSs6xi0ckvCll6mH3grKJ8rddTYij9s8gs8f Ddrl1N6pHJ+aF5Z4icvIDeyJo94RCS2MaM9D+JxPOtXJS9aw0jFQrATr9Zgg9740hxiB JXXw== X-Gm-Message-State: AOJu0YwYS85bDYKkKm10l9j6TkBWnTLmy9RQbGnzvacPdX4BEHLA0ZDw rUiYeVJV3WgX5qN4QR+2jGIZCnrg0rsDxY1IwnzX0ZMPqloTYryDuNXLEZAmgNc= X-Google-Smtp-Source: AGHT+IGL75tO/4jHaA/CpM+86i9MINHZbynV9KEX4JA/gQ8sOHvkgdf9PB66tiYdZLsqOQ3d6+9Kbw== X-Received: by 2002:a05:6512:3a8f:b0:51e:876d:17d0 with SMTP id 2adb3069b0e04-5221016b5dcmr3995815e87.52.1715378936336; Fri, 10 May 2024 15:08:56 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781ce3fsm228219866b.4.2024.05.10.15.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:08:55 -0700 (PDT) From: Linus Walleij Date: Sat, 11 May 2024 00:08:40 +0200 Subject: [PATCH net-next v2 2/5] net: ethernet: cortina: Use TSO also on common TCP Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-gemini-ethernet-fix-tso-v2-2-2ed841574624@linaro.org> References: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> In-Reply-To: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org It is possible to push the segment offloader to also process non-segmented frames: just pass the skb->len or desired MSS to the offloader and it will handle them. This is especially good if the user sets up the MTU and the frames get big, because the checksumming engine cannot handle any frames bigger than 1518 bytes, so segmenting them all to be at max that will be helpful for the hardware, which only need to quirk odd frames such as big UDP ping packets. The vendor driver always uses the TSO like this, and the driver seems more stable after this, so apparently the hardware may have been engineered to always use the TSO on anything it can handle. Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index b2ac9dfe1aae..3ba579550cdd 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1148,6 +1148,7 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, struct gmac_txdesc *txd; skb_frag_t *skb_frag; dma_addr_t mapping; + bool tcp = false; void *buffer; u16 mss; int ret; @@ -1155,6 +1156,13 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, word1 = skb->len; word3 = SOF_BIT; + /* Determine if we are doing TCP */ + if (skb->protocol == htons(ETH_P_IP)) + tcp = (ip_hdr(skb)->protocol == IPPROTO_TCP); + else + /* IPv6 */ + tcp = (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP); + mss = skb_shinfo(skb)->gso_size; if (mss) { /* This means we are dealing with TCP and skb->len is the @@ -1167,6 +1175,20 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, mss, skb->len); word1 |= TSS_MTU_ENABLE_BIT; word3 |= mss; + } else if (tcp) { + /* Even if we are not using TSO, use the segment offloader + * for transferring the TCP frame: the TSO engine will deal + * with chopping up frames that exceed ETH_DATA_LEN which + * the checksumming engine cannot handle (see below) into + * manageable chunks. It flawlessly deals with quite big + * frames and frames containing custom DSA EtherTypes. + */ + mss = netdev->mtu + skb_tcp_all_headers(skb); + mss = min(mss, skb->len); + netdev_dbg(netdev, "botched TSO len %04x mtu %04x mss %04x\n", + skb->len, netdev->mtu, mss); + word1 |= TSS_MTU_ENABLE_BIT; + word3 |= mss; } else if (skb->len >= ETH_FRAME_LEN) { /* Hardware offloaded checksumming isn't working on frames * bigger than 1514 bytes. A hypothesis about this is that the @@ -1185,21 +1207,16 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, } if (skb->ip_summed == CHECKSUM_PARTIAL) { - int tcp = 0; - /* We do not switch off the checksumming on non TCP/UDP * frames: as is shown from tests, the checksumming engine * is smart enough to see that a frame is not actually TCP * or UDP and then just pass it through without any changes * to the frame. */ - if (skb->protocol == htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) word1 |= TSS_IP_CHKSUM_BIT; - tcp = ip_hdr(skb)->protocol == IPPROTO_TCP; - } else { /* IPv6 */ + else word1 |= TSS_IPV6_ENABLE_BIT; - tcp = ipv6_hdr(skb)->nexthdr == IPPROTO_TCP; - } word1 |= tcp ? TSS_TCP_CHKSUM_BIT : TSS_UDP_CHKSUM_BIT; } From patchwork Fri May 10 22:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13661974 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0B0E13D243 for ; Fri, 10 May 2024 22:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378940; cv=none; b=GwrTxo5BnAPkahNe1T6SSRgdH4SQTgoHN6dtHTIOF6HsRGs2NqBnfhwWAa+bg9hhsjPuHxvQhj/7b9fCkEbkfSIHrViwiRUbAShUNVPpKfaHNjApvjvjjB+OyOlR3DxOnz3KKw3A0y72M3D/0sCGR9s9+PH3zb0+RKGVP4HTHAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378940; c=relaxed/simple; bh=xQIYBxkBv0T2jXpUE0izOur858+mVuU9VH6jubzoR5s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FHx0K7d4J/vWgbIgXEN8mXkoY1DuDrRy8eRKMchVYVhFAEUX7kdN6ASqkO3MKiFKDnVTpbyyva4H55CAgjU3QUDgF6GCLaBt5yFj/wnYRV2USe62mPJZ5g9fp+cuvMidoHfChKW/V8ReDu9zH15Uie4rNnGifY+vvBJYCNrWG9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hPhihtCb; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hPhihtCb" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a5a157a1cd1so622329266b.0 for ; Fri, 10 May 2024 15:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715378937; x=1715983737; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JY2M0W5sJkBljmZwX5JiVcqYzpxebL05MDZ/Dt9N2Bo=; b=hPhihtCbMNXAyI9KJCdVQF4vrXfi4BOU/AvH4bgPcVpcUYqvuSvRhMdFOtgkGbGCon 7Qgfu0BlClNbtAiiaxhHbYvwNSnxo6fWp0bRSnpTQLM3d/lLtR5oGYwMRhzbPa6i1It3 zg7ox4gi+g2wnY99Zgrj7OsLfXJyl1g5ioFNs4vm3pMs+FBd3xP9kA4gXXLi4ye0MoKQ sQXj24sw2wl7OIiTD/xGR8iNRuE+JhXdcprm1Fr05OsfaBIGNYQxAy3bsRyG2KpayGOd PVgWOEDuUNOllWzOA8fp2d2WlBhee1gnMYNfHm90l0NQiZ4HIaFq7syH6fdd77JdA1Pt Nf5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715378937; x=1715983737; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JY2M0W5sJkBljmZwX5JiVcqYzpxebL05MDZ/Dt9N2Bo=; b=kqB+lsExYcVyXKwJsbKariHCzBfuDoyV+v/GDN6Bldp5OYCvR7cuGSD/pEPTh5uOr3 UuknySJtlakiVW6jllJAK2chnkzkKq6jGHSDC1Tmn8J7SkGkYFXw0sOEW8KUqWVKmSLh OhIgrYyyoof/sZcDDWdg11cuOdfSzsgA416uwOctyhDbQ2jERj38dV1bV1WGkr4iZbaE TwMuzcI4PIwyWBlbb1pNMihY25FaENH+op8Q0MQyHO3beTAJUU2D1Qk0Wie1MXwJQVxx JCeqTajzZGxfLcfYJjcizbqi6v6U08R7wlWCcOFpKVmzE6yMHNmLHhk5hu7WxKHrr4kx SxpQ== X-Gm-Message-State: AOJu0YxUdJ4AXQV5ggWYa/W0BSk3HfVZShswLD31tRsWz6XLnNgxUkpd 5j6RAGCgSji3JXXNLRs3AZOhTjz0ocn6/ezbV+Xl+8mXGLxgJ4sHyp9T/JFmltY= X-Google-Smtp-Source: AGHT+IHwKWKKEsG7kwRGgj+0NRYPmkZB3ozttc89r2itP9s1NVipFrp/9nBlJv0Vcn31ba6KEtSvpA== X-Received: by 2002:a17:906:c452:b0:a59:ee81:fd68 with SMTP id a640c23a62f3a-a5a2d68089bmr259803066b.71.1715378937287; Fri, 10 May 2024 15:08:57 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781ce3fsm228219866b.4.2024.05.10.15.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:08:56 -0700 (PDT) From: Linus Walleij Date: Sat, 11 May 2024 00:08:41 +0200 Subject: [PATCH net-next v2 3/5] net: ethernet: cortina: Rename adjust link callback Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-gemini-ethernet-fix-tso-v2-3-2ed841574624@linaro.org> References: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> In-Reply-To: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org The callback passed to of_phy_get_and_connect() in the Cortina Gemini driver is called "gmac_speed_set" which is archaic, rename it to "gmac_adjust_link" following the pattern of most other drivers. Signed-off-by: Linus Walleij Reviewed-by: Andrew Lunn --- drivers/net/ethernet/cortina/gemini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 3ba579550cdd..e9b4946ec45f 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -288,7 +288,7 @@ static void gmac_set_flow_control(struct net_device *netdev, bool tx, bool rx) spin_unlock_irqrestore(&port->config_lock, flags); } -static void gmac_speed_set(struct net_device *netdev) +static void gmac_adjust_link(struct net_device *netdev) { struct gemini_ethernet_port *port = netdev_priv(netdev); struct phy_device *phydev = netdev->phydev; @@ -367,7 +367,7 @@ static int gmac_setup_phy(struct net_device *netdev) phy = of_phy_get_and_connect(netdev, dev->of_node, - gmac_speed_set); + gmac_adjust_link); if (!phy) return -ENODEV; netdev->phydev = phy; From patchwork Fri May 10 22:08:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13661975 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E28613D25A for ; Fri, 10 May 2024 22:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378941; cv=none; b=fFFcpBGyCBobMt82tigcKFIfXCw2IRQkd++dRh+XzjN/z6B269OKE1pA09PYKJto4n90Kjq+PRlYmrveq1pMXEDz8nZZlAqqHXdadv5LTdHebScNGuElFHI754P8HCZwbRGJzHlN0tiqch3YccSQ5gh6LeZUIjfIKSBpmZNivA8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378941; c=relaxed/simple; bh=6V6RqJXtAOVDpZCKczamPr5DHDi9TbnzlmxJ5b+iceQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m3T10zcYzLE9FYXQNf0mK8r0y5O0kZfyb9hwqGi5n9Sqpa6eY5nXIk4gF40QPBPZNyMxrQoKHFuWAk55IdXPpibS/S7gx/7ds+FDivd4hP3efjgegIeVcjOboyFEbb+y52BW8Wd2xHawdTOCyPCr98ARwL6oY0G/lwGMq0hs+Ks= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=GHuc2Ti4; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GHuc2Ti4" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a5a2d0d8644so414101866b.1 for ; Fri, 10 May 2024 15:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715378938; x=1715983738; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=jkIbJ/qflXfSFw4UpiGmwq8QzkxZY+hDO2BaC+txcYw=; b=GHuc2Ti4KHLXWoGvhV6XoKPhz4wPjqrywL2HwkvhZLCYGJT4vGuUvvlC/U4um7d2xd ZNlhng/bY5BU7DclKMkbVthwEnl6kpzGoq60vu5S2jxjoGVO2/e7kKTmRDpoN/wi0jXG sLhkdsJI3p4ISlECKaY0fTGQSOqVbkIpOd5+dL9ucgzh1BG+fJcIC/BbNslUOgt1nGJc C2yRTqKl+1HhbEKAyhmrjSBnF8efZPHFH7r1SQpmAnpLfxL0LeppFVyvzIgugEuOtZ8P LtfCAd31eD0AaCEWHcLDGY6+b5Q9qsF546ozjbI/9Gj/syktZpE2OZ4rA3TLmh2OU9Q/ UV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715378938; x=1715983738; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jkIbJ/qflXfSFw4UpiGmwq8QzkxZY+hDO2BaC+txcYw=; b=an1fO/xXywAE/knaHkxzvBa3bXWY1gV/aFxZGNTD6AbOXiWMeo0Iedk/1VdMcuCQpR wQE1Hoj1LEr8+vmaLXHuoM8/n0JAU9XHXBKEnfPVjesxXBnPjiIlkZGxPoGIO7QGiLKE y5x41O8ZUpKGmWtIxPYPYrTKgEAmhUdhPaiJKOhdFfoaMNltLX2ahHdfyUKCJUTomeYF xAnwY53ThUapQfGKR9VbD9F5EuFVG/ACoZHzTcP/GILplslCxjAdstU0VJEV4EOUoOj4 1G7ogg/XGyvvYmcAE3Fa7T0sU7EYpBACKrU2NaS12JLbVyRcaVBCWqr0vN56uPtjaUNx TLgw== X-Gm-Message-State: AOJu0Yz8TuYoI6ye8ZLOqOS+qrnn3TPcFVjjmxnVBMKwZGBjo+Okk80g i2pofnjjpmEun3gQUc6dRuwOuYcF3bj/9CQRoPOzj5oF2D3YRFQdQ/tBLPrhFGD17X3DPZTSKRH 2 X-Google-Smtp-Source: AGHT+IH2T0tARdewDiZtc81LFzwnvq3lzID7G8IfCzWaPDGXnmdgHxztlKAp0Ge1g+M/tFpn7YesdA== X-Received: by 2002:a17:906:118b:b0:a59:9edf:14b6 with SMTP id a640c23a62f3a-a5a2d5f2606mr244149666b.45.1715378938361; Fri, 10 May 2024 15:08:58 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781ce3fsm228219866b.4.2024.05.10.15.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:08:57 -0700 (PDT) From: Linus Walleij Date: Sat, 11 May 2024 00:08:42 +0200 Subject: [PATCH net-next v2 4/5] net: ethernet: cortina: Use negotiated TX/RX pause Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-gemini-ethernet-fix-tso-v2-4-2ed841574624@linaro.org> References: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> In-Reply-To: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org Instead of directly poking into registers of the PHY, use the existing function to query phylib about this directly. Suggested-by: Andrew Lunn Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index e9b4946ec45f..d3134db032a2 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -293,8 +293,8 @@ static void gmac_adjust_link(struct net_device *netdev) struct gemini_ethernet_port *port = netdev_priv(netdev); struct phy_device *phydev = netdev->phydev; union gmac_status status, old_status; - int pause_tx = 0; - int pause_rx = 0; + bool pause_tx = false; + bool pause_rx = false; status.bits32 = readl(port->gmac_base + GMAC_STATUS); old_status.bits32 = status.bits32; @@ -328,19 +328,13 @@ static void gmac_adjust_link(struct net_device *netdev) phydev->speed, phydev_name(phydev)); } - if (phydev->duplex == DUPLEX_FULL) { - u16 lcladv = phy_read(phydev, MII_ADVERTISE); - u16 rmtadv = phy_read(phydev, MII_LPA); - u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); - - if (cap & FLOW_CTRL_RX) - pause_rx = 1; - if (cap & FLOW_CTRL_TX) - pause_tx = 1; + if (phydev->autoneg) { + phy_get_pause(phydev, &pause_tx, &pause_rx); + netdev_dbg(netdev, "set negotiated pause params pause TX = %s, pause RX = %s\n", + pause_tx ? "ON" : "OFF", pause_rx ? "ON" : "OFF"); + gmac_set_flow_control(netdev, pause_tx, pause_rx); } - gmac_set_flow_control(netdev, pause_tx, pause_rx); - if (old_status.bits32 == status.bits32) return; From patchwork Fri May 10 22:08:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13661976 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3622513D275 for ; Fri, 10 May 2024 22:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378942; cv=none; b=Pi/pSzVm2RBN3TkQFPgzK/DJI68t/GGP8BLT8351GcvsCSqz79KklGlwn+YLmJa8yG4YafGSShiD2K9UHytIjtr+oOlG9Jbjr+tHuGzuxA9VHt6Fvm4m4dnhw2bSU/Mw+EIerYDbcHK+NHYtR/uelA5RUbhfmB3+0+lZl9pnN9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715378942; c=relaxed/simple; bh=hK1AwCcD4OmTuWhTNoyavke80bEp/QmDUm1yjQRGk/4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YBi0p2JZ8au9PPp31MQ7khJYHpfEiMapvfjkjURXG0KpcXYqwxO6hMv1u1C3s8QdrOmPkWpC2DAxyNIi+hFFJXn8qd5ilaptyAkPM4OSlup43iHrmys375KLwanQxb2EoN01cx5zoOOP3FnzCQxUxOq+ZtUhLVQQwR2AFqUepLc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gDDyRqxc; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gDDyRqxc" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-51f12ccff5eso3427890e87.1 for ; Fri, 10 May 2024 15:09:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715378939; x=1715983739; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=eqHQx/qPXsoWvKvCs+iR2iSoM0kbh7ImNwOPcq13Hhs=; b=gDDyRqxc47OybD/9Cd8gfbWnNvFzG/vQ4DUCTVaFlWj4EAmN0THsgCwHCepy4s6LFj DiIEOUv7j5ISq/jxmx8HE/3PQfWi+knjpolNXgKBCDv/hQpzGU8H12JiJzphPm9VN1/T SbOVIyjGYlYl2egqgrWgUDAfs6WRNmyZpLvBNYl+oIt+xH/jAfShufoTh70MDBmhQd+3 hC1P2/Lylbt65f5SQ4Xh4ws83KxSsrjT0UE5Djbuvhpo5QjyYR7cpOVchQ2XhHs96N7S nIw4mrV0ChnmduJC+K04mnCJ33zMW7e/2T5ct8oxGQXqDVNvHUUded9RSL272lTHJcar m0BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715378939; x=1715983739; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eqHQx/qPXsoWvKvCs+iR2iSoM0kbh7ImNwOPcq13Hhs=; b=U4yjoDI4rnirJeFHctHyxN9OMvEBJ3MWznyIsxgpA65HYCcDud1MuwSmgIgkPXevZf 70phC5BYL94CuIwOMwt1nqlQ2J1lQHNhnt5BVzf0fMe6QsdcvJkFce3qhsJRN3dNTN1i ZtvDhLrepk4mx7FuEA5dIEAmdE2xn69egRxtBwtYkVtfSomQ+vCzS1tR+60ugv2gJC6O 8Oa0ZAtickpOxKFCM6kJXgFktYjud5t0gNLY9BUgA3jAG2HjCsGR+dycjJpNnQ5Xo5xV o0fPJu2TykEE+lh8s6fL1ErFvgazeWFfc0u/7y0vp6zsQAk3wSAUFps1FkWzFFzeqd20 xmkQ== X-Gm-Message-State: AOJu0Yx/XXTkVBP82LazfDG8Dywjj/nF2bCnW3ihttrrQsoevp1FvQa5 C0u3yGdBy+/6bYfdPYRR/loWAjyqYkgE6R2Tx6Q0goCj/HcUNDC7rf2kVhIbtWY= X-Google-Smtp-Source: AGHT+IG9etHAzRkra2Pva4AqH5dC9t3zCo3LQlQjK11jutNSxDdpm+VlkAopy+jbZCKqeOE6gCyhAA== X-Received: by 2002:ac2:4c2f:0:b0:518:96b5:f2c5 with SMTP id 2adb3069b0e04-5221057923bmr2490205e87.46.1715378939428; Fri, 10 May 2024 15:08:59 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781ce3fsm228219866b.4.2024.05.10.15.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 15:08:59 -0700 (PDT) From: Linus Walleij Date: Sat, 11 May 2024 00:08:43 +0200 Subject: [PATCH net-next v2 5/5] net: ethernet: cortina: Implement .set_pauseparam() Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240511-gemini-ethernet-fix-tso-v2-5-2ed841574624@linaro.org> References: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> In-Reply-To: <20240511-gemini-ethernet-fix-tso-v2-0-2ed841574624@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.13.0 X-Patchwork-Delegate: kuba@kernel.org The Cortina Gemini ethernet can very well set up TX or RX pausing, so add this functionality to the driver in a .set_pauseparam() callback. Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index d3134db032a2..137242a4977c 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -2145,6 +2145,17 @@ static void gmac_get_pauseparam(struct net_device *netdev, pparam->autoneg = true; } +static int gmac_set_pauseparam(struct net_device *netdev, + struct ethtool_pauseparam *pparam) +{ + struct phy_device *phydev = netdev->phydev; + + gmac_set_flow_control(netdev, pparam->tx_pause, pparam->rx_pause); + phy_set_asym_pause(phydev, pparam->rx_pause, pparam->tx_pause); + + return 0; +} + static void gmac_get_ringparam(struct net_device *netdev, struct ethtool_ringparam *rp, struct kernel_ethtool_ringparam *kernel_rp, @@ -2265,6 +2276,7 @@ static const struct ethtool_ops gmac_351x_ethtool_ops = { .set_link_ksettings = gmac_set_ksettings, .nway_reset = gmac_nway_reset, .get_pauseparam = gmac_get_pauseparam, + .set_pauseparam = gmac_set_pauseparam, .get_ringparam = gmac_get_ringparam, .set_ringparam = gmac_set_ringparam, .get_coalesce = gmac_get_coalesce,