From patchwork Thu Mar 26 22:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 221764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A2F7C43331 for ; Thu, 26 Mar 2020 22:41:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2F56B2077D for ; Thu, 26 Mar 2020 22:41:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Aw7nbTJe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727685AbgCZWlI (ORCPT ); Thu, 26 Mar 2020 18:41:08 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37496 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgCZWlH (ORCPT ); Thu, 26 Mar 2020 18:41:07 -0400 Received: by mail-wm1-f67.google.com with SMTP id d1so10027924wmb.2 for ; Thu, 26 Mar 2020 15:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eoc/anp9hI4hmzoROmqXY5/InuJ0Eh4KwcgSSqkOB/8=; b=Aw7nbTJeQV0hvE+8Z+7LO51RetG0Ins3YlmpaNTH6ymaEWBZi7xJFzwXT+DrZYUBYF 7+hBGteklVt2I4dwm0ENcM47WEw8iF1WXPj9WOWUpRoDekEjFHWIBdFdjPF+tUC5tLsn Bm0rtAqy52k2fhCmvO985E8FZRNXY7KKhKJPq6cE1waC/zQPD3qB5ug7ZbugOyYmjevs vUBgD4NsuCJjcJ54wtUmkYgySQVDZPi06i3eK6qXf/YbHAY2UePIfRKkuov02pvRBTdR ASDqYnJ5K4Cwc/7/aTT+fXde4XtamkdCARMBznzEwRvRbb7Iy3OqQn+Ra2VM9CZ2SgD3 SVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eoc/anp9hI4hmzoROmqXY5/InuJ0Eh4KwcgSSqkOB/8=; b=qAnrCXu3BCeRMRYVAv20QeQLffkZySFhc6QvvDt2/1fIBmeq2DWo+onxr7GXqA8khv y1I5F8pat9P9oWmgGtGnhEgGCjO6Kv/OVQHQn50xzdfDv2wHTfhqG6/S/yXBkaPIs37t k/xx/MgmHU6PmTYMWtR3S6Q9bxjtvmjkl8JBw+cTloPXPH2vXTBhqKWO16S9PWV1pifb z+nQ0AJqbuMrVbHwLY1FPmRzib5LqFghN/dfxYl5pc+R8XU+XTOn7dGuKxTLarGFXK3m x1S1r+s2oBxJjIrU+MVA/onb7aflMfr+Et7DLZ2uU//8BUVsbJeR6ax1hHMj18ARngRf hDXw== X-Gm-Message-State: ANhLgQ3klCuRysk3q52VKtbHSe3GkUf8yORbCkRdrHl4PNBhEXsxDzuu TpeiPp21eRxLtv5BO6mJcF4= X-Google-Smtp-Source: ADFU+vun8dUkWEVSSRXFgfNGZIVrwXSJUF5hoVUEO0sUKVSaYGI2va2we2yDq5zzgfYOULK3c59qBg== X-Received: by 2002:a05:6000:48:: with SMTP id k8mr11619847wrx.91.1585262464600; Thu, 26 Mar 2020 15:41:04 -0700 (PDT) Received: from localhost.localdomain ([79.115.60.40]) by smtp.gmail.com with ESMTPSA id t81sm5522783wmb.15.2020.03.26.15.41.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 15:41:04 -0700 (PDT) From: Vladimir Oltean To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, davem@davemloft.net, jakub.kicinski@netronome.com Cc: murali.policharla@broadcom.com, stephen@networkplumber.org, jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org, nikolay@cumulusnetworks.com, netdev@vger.kernel.org Subject: [PATCH v3 net-next 2/8] bgmac: configure MTU and add support for frames beyond 8192 byte size Date: Fri, 27 Mar 2020 00:40:34 +0200 Message-Id: <20200326224040.32014-3-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326224040.32014-1-olteanv@gmail.com> References: <20200326224040.32014-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Murali Krishna Policharla Change DMA descriptor length to handle jumbo frames beyond 8192 bytes. Also update jumbo frame max size to include FCS, the DMA packet length received includes FCS. Signed-off-by: Murali Krishna Policharla Reviewed-by: Arun Parameswaran Reviewed-by: Ray Jui Signed-off-by: Vladimir Oltean --- Changes in v3: Squashed the entire bgmac implementation in one patch. Changes in v2: Patch is new. drivers/net/ethernet/broadcom/bgmac.c | 12 ++++++++++++ drivers/net/ethernet/broadcom/bgmac.h | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index 1bb07a5d82c9..98ec1b8a7d8e 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c @@ -1248,6 +1248,14 @@ static int bgmac_set_mac_address(struct net_device *net_dev, void *addr) return 0; } +static int bgmac_change_mtu(struct net_device *net_dev, int mtu) +{ + struct bgmac *bgmac = netdev_priv(net_dev); + + bgmac_write(bgmac, BGMAC_RXMAX_LENGTH, 32 + mtu); + return 0; +} + static const struct net_device_ops bgmac_netdev_ops = { .ndo_open = bgmac_open, .ndo_stop = bgmac_stop, @@ -1256,6 +1264,7 @@ static const struct net_device_ops bgmac_netdev_ops = { .ndo_set_mac_address = bgmac_set_mac_address, .ndo_validate_addr = eth_validate_addr, .ndo_do_ioctl = phy_do_ioctl_running, + .ndo_change_mtu = bgmac_change_mtu, }; /************************************************** @@ -1530,6 +1539,9 @@ int bgmac_enet_probe(struct bgmac *bgmac) net_dev->hw_features = net_dev->features; net_dev->vlan_features = net_dev->features; + /* Omit FCS from max MTU size */ + net_dev->max_mtu = BGMAC_RX_MAX_FRAME_SIZE - ETH_FCS_LEN; + err = register_netdev(bgmac->net_dev); if (err) { dev_err(bgmac->dev, "Cannot register net device\n"); diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index 40d02fec2747..351c598a3ec6 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h @@ -351,7 +351,7 @@ #define BGMAC_DESC_CTL0_IOC 0x20000000 /* IRQ on complete */ #define BGMAC_DESC_CTL0_EOF 0x40000000 /* End of frame */ #define BGMAC_DESC_CTL0_SOF 0x80000000 /* Start of frame */ -#define BGMAC_DESC_CTL1_LEN 0x00001FFF +#define BGMAC_DESC_CTL1_LEN 0x00003FFF #define BGMAC_PHY_NOREGS BRCM_PSEUDO_PHY_ADDR #define BGMAC_PHY_MASK 0x1F @@ -366,7 +366,8 @@ #define BGMAC_RX_FRAME_OFFSET 30 /* There are 2 unused bytes between header and real data */ #define BGMAC_RX_BUF_OFFSET (NET_SKB_PAD + NET_IP_ALIGN - \ BGMAC_RX_FRAME_OFFSET) -#define BGMAC_RX_MAX_FRAME_SIZE 1536 /* Copied from b44/tg3 */ +/* Jumbo frame size with FCS */ +#define BGMAC_RX_MAX_FRAME_SIZE 9724 #define BGMAC_RX_BUF_SIZE (BGMAC_RX_FRAME_OFFSET + BGMAC_RX_MAX_FRAME_SIZE) #define BGMAC_RX_ALLOC_SIZE (SKB_DATA_ALIGN(BGMAC_RX_BUF_SIZE + BGMAC_RX_BUF_OFFSET) + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) From patchwork Thu Mar 26 22:40:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 221762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 163C7C2D0E8 for ; Thu, 26 Mar 2020 22:41:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DED7420719 for ; Thu, 26 Mar 2020 22:41:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="by0qYJ8E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727724AbgCZWlM (ORCPT ); Thu, 26 Mar 2020 18:41:12 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:36618 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727696AbgCZWlK (ORCPT ); Thu, 26 Mar 2020 18:41:10 -0400 Received: by mail-wm1-f66.google.com with SMTP id g62so10061119wme.1 for ; Thu, 26 Mar 2020 15:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G4ajGnsm6J0V4DS1Hs9z3LTG7liZ4Sv6fY3Unr7rPaU=; b=by0qYJ8EyZiKmVBp8yEj/l2uUPlKCffMKNgNHi5L0Rpp8fr/KXGN3tL5YnCEr/e5vc Hc5Qw1/zIuExL4oGXwaEujFVmMnl9myi35rN0d9l2D/5PQqtuDiax7MnDlhjmPhCQeUq YgHV3Sx0Oqs4vhGpbkUwJTTl9kY1xD1Oyvn+AuRbVNZiafmcTbk/8e0Bb85k4/zMIGTd 8CJ+3RNRRL5VICrcIXP4GRBYtV7ilnJOt3j8uAhwNulS6nFQA8OOl1DWAcyevToY8uXk twGOaZCJkHIoxtW29nf/HOKcSOdNjHJe3fRfm67MN9i2oPjl67pFS0HRZ4VqRgYnKbkY WPww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G4ajGnsm6J0V4DS1Hs9z3LTG7liZ4Sv6fY3Unr7rPaU=; b=TznlzvTITXaVsuoOW9nVJT6LmxodJo0IP6AfjzzqrVJTEt+CuiPrx/4kDvIlQGE393 pigj1xieDb+VYvKNQrUTwa+2cLIeLlxazQ8wqCLwtTvnVExO8Cih+rQ21lI5BLyl/ElS ZclGrZlYGCeMxtuRwNCKAze4+LzujnEvbhoqPicdrOZbaUziBXYxNndLnz+YomvSvy3F XOSRoZ6A6dbH2VgCqDf7jHWS5xGdfvtkaRqVN+3CpMBbJ6C3ppoTs3XK+p6D+R8/AjHJ IpGHDnxm9xKv4FELHRK3TQfnMcBHcwg5ynqpmIESaJ4Kx4rNLyU27YnhaJNFMvDf1Hou Mm7Q== X-Gm-Message-State: ANhLgQ0b4WfIAunlAgm+yZauQldva2CoWdiDI2wz7Zyj8K2/NtCVqbtj 29w2G5Ko+/NNIry46Ch9aYY= X-Google-Smtp-Source: ADFU+vtpgodKyYNA4tuFvTRmGLvOFJgOM39MdyvhYTAbfWmRPd05kNp0AZyNQPk/UXRkCsCTt22Fxw== X-Received: by 2002:a5d:4f08:: with SMTP id c8mr723853wru.27.1585262468459; Thu, 26 Mar 2020 15:41:08 -0700 (PDT) Received: from localhost.localdomain ([79.115.60.40]) by smtp.gmail.com with ESMTPSA id t81sm5522783wmb.15.2020.03.26.15.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 15:41:08 -0700 (PDT) From: Vladimir Oltean To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, davem@davemloft.net, jakub.kicinski@netronome.com Cc: murali.policharla@broadcom.com, stephen@networkplumber.org, jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org, nikolay@cumulusnetworks.com, netdev@vger.kernel.org Subject: [PATCH v3 net-next 5/8] net: dsa: b53: add MTU configuration support Date: Fri, 27 Mar 2020 00:40:37 +0200 Message-Id: <20200326224040.32014-6-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326224040.32014-1-olteanv@gmail.com> References: <20200326224040.32014-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Murali Krishna Policharla It looks like the Broadcomm switches supported by the b53 driver don't support precise configuration of the MTU, but just a mumbo-jumbo boolean flag. Set that. Also configure BCM583XX devices to send and receive jumbo frames when ports are configured with 10/100 Mbps speed. Signed-off-by: Murali Krishna Policharla Signed-off-by: Vladimir Oltean --- Changes in v3: Using the b53_set_jumbo function that was already there. Changes in v2: Patch is new. drivers/net/dsa/b53/b53_common.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index ceafce446317..f432edf618e1 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -699,9 +699,6 @@ int b53_configure_vlan(struct dsa_switch *ds) b53_write16(dev, B53_VLAN_PAGE, B53_VLAN_PORT_DEF_TAG(i), def_vid); - if (!is5325(dev) && !is5365(dev)) - b53_set_jumbo(dev, dev->enable_jumbo, false); - return 0; } EXPORT_SYMBOL(b53_configure_vlan); @@ -807,8 +804,6 @@ static int b53_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val) static int b53_reset_switch(struct b53_device *priv) { /* reset vlans */ - priv->enable_jumbo = false; - memset(priv->vlans, 0, sizeof(*priv->vlans) * priv->num_vlans); memset(priv->ports, 0, sizeof(*priv->ports) * priv->num_ports); @@ -2065,6 +2060,26 @@ int b53_set_mac_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) } EXPORT_SYMBOL(b53_set_mac_eee); +static int b53_change_mtu(struct dsa_switch *ds, int port, int mtu) +{ + struct b53_device *dev = ds->priv; + bool enable_jumbo; + bool allow_10_100; + + if (is5325(dev) || is5365(dev)) + return -EOPNOTSUPP; + + enable_jumbo = (mtu >= JMS_MIN_SIZE); + allow_10_100 = (dev->chip_id == BCM58XX_DEVICE_ID); + + return b53_set_jumbo(dev, enable_jumbo, allow_10_100); +} + +static int b53_get_max_mtu(struct dsa_switch *ds, int port) +{ + return JMS_MAX_SIZE; +} + static const struct dsa_switch_ops b53_switch_ops = { .get_tag_protocol = b53_get_tag_protocol, .setup = b53_setup, @@ -2102,6 +2117,8 @@ static const struct dsa_switch_ops b53_switch_ops = { .port_mdb_prepare = b53_mdb_prepare, .port_mdb_add = b53_mdb_add, .port_mdb_del = b53_mdb_del, + .port_max_mtu = b53_get_max_mtu, + .port_change_mtu = b53_change_mtu, }; struct b53_chip_data { From patchwork Thu Mar 26 22:40:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 221763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A88CC43331 for ; Thu, 26 Mar 2020 22:41:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE3E720719 for ; Thu, 26 Mar 2020 22:41:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T7hatM7m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbgCZWlP (ORCPT ); Thu, 26 Mar 2020 18:41:15 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40790 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727708AbgCZWlM (ORCPT ); Thu, 26 Mar 2020 18:41:12 -0400 Received: by mail-wm1-f67.google.com with SMTP id a81so10024809wmf.5 for ; Thu, 26 Mar 2020 15:41:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Sx2clxuTbIqAwT1Jf/4nrCEiE87w5o3flWc3jxp/iSM=; b=T7hatM7mYjH8tCDNxogloHgoRgmqyYZn3YDutYqXpqV2/WJTTJ2Z2yu60wC/6UnE6f JRzXvUKAW2Vog3l/niBNgTy2i7d4Z0dvuw7Ov3aXbO7t1QLv45inQvp4ijMBPHvz8Pzk ITGaaUiQ5jgLmOWcGvgtM71KbZOOZcUTNnN1G55H73Xqy1KixUoUWbscJ/53enwE/XS9 61wYVmnotpTBGt4+vdO0WAOcjz6cfbEHPM9FhwxvLyXZpAm7OsfDjGXRYc3AlOGQBx4C hDluV5nQcBF1SLxcJzu4dfvn49vsBlvOnXQ8C8rImjm3MQSJl4S5Shjw5sq5okyA72z7 e9og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Sx2clxuTbIqAwT1Jf/4nrCEiE87w5o3flWc3jxp/iSM=; b=FOUV/6peIvKkg2KK5alN7pYHIsrZQBhBudgWY3dpv9qHF21Rd4sEXeEgupq3s5ndQk kgpqjAgtA5VhtEPpFfsWs4PGVpHFYdJVbEvpUde5NYKjPGILpkxP+oqJ1Lu/rDnh45uq ac3cKVIhxlPwEDHCm81lkxi2kq9N1zIZinpk0qjT7QoQUqR58VmLNZnywfLVkX93ehYp aXpZPl7xiotU0FN72rmrljZkqqVEy1Wa6V6YqC/Jpz8leV3Mnkru3NMQfBKMtyE+JyIT ydzm6AU9rc9X7CVI6VIXxmaOPlvu4vmvdC+yIpKCTKVUI4a9dqMK8XcDX32kqO3DyE6t t0UA== X-Gm-Message-State: ANhLgQ2e9PrZabjW38S9pWkiBKkAcKEyPFPiP4xQe/G57A+nW1nzE5jA BD+A3Kq6UfDj5dcAh2FEvCYNz53UL26jLQ== X-Google-Smtp-Source: ADFU+vsT8j810zGgbPieGONKBIPmP7a1HcswG7DcwKWQ96v2KN771ynvW43lBRdr9Yw7RmBuyoRhBg== X-Received: by 2002:a5d:4683:: with SMTP id u3mr688570wrq.248.1585262470925; Thu, 26 Mar 2020 15:41:10 -0700 (PDT) Received: from localhost.localdomain ([79.115.60.40]) by smtp.gmail.com with ESMTPSA id t81sm5522783wmb.15.2020.03.26.15.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 15:41:10 -0700 (PDT) From: Vladimir Oltean To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, davem@davemloft.net, jakub.kicinski@netronome.com Cc: murali.policharla@broadcom.com, stephen@networkplumber.org, jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org, nikolay@cumulusnetworks.com, netdev@vger.kernel.org Subject: [PATCH v3 net-next 7/8] net: dsa: vsc73xx: make the MTU configurable Date: Fri, 27 Mar 2020 00:40:39 +0200 Message-Id: <20200326224040.32014-8-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200326224040.32014-1-olteanv@gmail.com> References: <20200326224040.32014-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean Instead of hardcoding the MTU to the maximum value allowed by the hardware, obey the value known by the operating system. Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- Changes in v3: None. Changes in v2: None. drivers/net/dsa/vitesse-vsc73xx-core.c | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c index 6e21a2a5cf01..19ce4aa0973b 100644 --- a/drivers/net/dsa/vitesse-vsc73xx-core.c +++ b/drivers/net/dsa/vitesse-vsc73xx-core.c @@ -664,16 +664,6 @@ static void vsc73xx_init_port(struct vsc73xx *vsc, int port) VSC73XX_MAC_CFG_TX_EN | VSC73XX_MAC_CFG_RX_EN); - /* Max length, we can do up to 9.6 KiB, so allow that. - * According to application not "VSC7398 Jumbo Frames" setting - * up the MTU to 9.6 KB does not affect the performance on standard - * frames, so just enable it. It is clear from the application note - * that "9.6 kilobytes" == 9600 bytes. - */ - vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, - port, - VSC73XX_MAXLEN, 9600); - /* Flow control for the CPU port: * Use a zero delay pause frame when pause condition is left * Obey pause control frames @@ -1030,6 +1020,24 @@ static void vsc73xx_get_ethtool_stats(struct dsa_switch *ds, int port, } } +static int vsc73xx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) +{ + struct vsc73xx *vsc = ds->priv; + + return vsc73xx_write(vsc, VSC73XX_BLOCK_MAC, port, + VSC73XX_MAXLEN, new_mtu); +} + +/* According to application not "VSC7398 Jumbo Frames" setting + * up the MTU to 9.6 KB does not affect the performance on standard + * frames. It is clear from the application note that + * "9.6 kilobytes" == 9600 bytes. + */ +static int vsc73xx_get_max_mtu(struct dsa_switch *ds, int port) +{ + return 9600; +} + static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_tag_protocol = vsc73xx_get_tag_protocol, .setup = vsc73xx_setup, @@ -1041,6 +1049,8 @@ static const struct dsa_switch_ops vsc73xx_ds_ops = { .get_sset_count = vsc73xx_get_sset_count, .port_enable = vsc73xx_port_enable, .port_disable = vsc73xx_port_disable, + .port_change_mtu = vsc73xx_change_mtu, + .port_max_mtu = vsc73xx_get_max_mtu, }; static int vsc73xx_gpio_get(struct gpio_chip *chip, unsigned int offset)