From: Vladimir Oltean <olteanv@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Woojung Huh <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com, Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, Arun.Ramadoss@microchip.com
Subject: Re: [PATCH net-next v3 3/3] net: dsa: microchip: ksz8: add MTU configuration support
Date: Tue, 8 Nov 2022 11:21:16 +0200 [thread overview]
Message-ID: <20221108092116.fpwvlxz3bbvkha66@skbuf> (raw)
In-Reply-To: <20221108054336.4165931-4-o.rempel@pengutronix.de>
On Tue, Nov 08, 2022 at 06:43:36AM +0100, Oleksij Rempel wrote:
> +static int ksz8863_change_mtu(struct ksz_device *dev, int port, int max_frame)
Don't pass "int port" if you're not going to use it.
> +{
> + u8 ctrl2 = 0;
> +
> + if (max_frame <= KSZ8_LEGAL_PACKET_SIZE)
> + ctrl2 |= KSZ8863_LEGAL_PACKET_ENABLE;
> + else if (max_frame > KSZ8863_NORMAL_PACKET_SIZE)
> + ctrl2 |= KSZ8863_HUGE_PACKET_ENABLE;
> +
> + return ksz_rmw8(dev, REG_SW_CTRL_2, KSZ8863_LEGAL_PACKET_ENABLE
> + | KSZ8863_HUGE_PACKET_ENABLE, ctrl2);
Coding conventions are to not start a new line with an operator, but to
put it at the end of the previous line:
return ksz_rmw8(dev, REG_SW_CTRL_2, KSZ8863_LEGAL_PACKET_ENABLE |
KSZ8863_HUGE_PACKET_ENABLE, ctrl2);
> +}
> +
> +static int ksz8795_change_mtu(struct ksz_device *dev, int port, int max_frame)
Same.
> +{
> + u8 ctrl1 = 0, ctrl2 = 0;
> + int ret;
> +
> + if (max_frame > KSZ8_LEGAL_PACKET_SIZE)
> + ctrl2 |= SW_LEGAL_PACKET_DISABLE;
> + else if (max_frame > KSZ8863_NORMAL_PACKET_SIZE)
> + ctrl1 |= SW_HUGE_PACKET;
> +
> + ret = ksz_rmw8(dev, REG_SW_CTRL_1, SW_HUGE_PACKET, ctrl1);
> + if (ret)
> + return ret;
> +
> + return ksz_rmw8(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, ctrl2);
> +}
> +
> +int ksz8_change_mtu(struct ksz_device *dev, int port, int mtu)
> +{
> + u16 frame_size, max_frame = 0;
> + int i;
> +
> + frame_size = mtu + VLAN_ETH_HLEN + ETH_FCS_LEN;
> +
> + /* Cache the per-port MTU setting */
> + dev->ports[port].max_frame = frame_size;
> +
> + for (i = 0; i < dev->info->port_cnt; i++)
> + max_frame = max(max_frame, dev->ports[i].max_frame);
You can do what other switches do, and instead of caching into an array,
"return 0" for everything except the CPU port. The CPU port will always
be programmed with the largest MTU.
> +
> + switch (dev->chip_id) {
> + case KSZ8795_CHIP_ID:
> + case KSZ8794_CHIP_ID:
> + case KSZ8765_CHIP_ID:
> + return ksz8795_change_mtu(dev, port, max_frame);
> + case KSZ8830_CHIP_ID:
> + return ksz8863_change_mtu(dev, port, max_frame);
> + }
> +
> + return -EOPNOTSUPP;
> +}
> +
prev parent reply other threads:[~2022-11-08 9:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 5:43 [PATCH net-next v3 0/3] net: dsa: microchip: add MTU support for KSZ8 series Oleksij Rempel
2022-11-08 5:43 ` [PATCH net-next v3 1/3] net: dsa: microchip: move max mtu to one location Oleksij Rempel
2022-11-09 15:19 ` Arun.Ramadoss
2022-11-08 5:43 ` [PATCH net-next v3 2/3] net: dsa: microchip: add ksz_rmw8() function Oleksij Rempel
2022-11-08 5:43 ` [PATCH net-next v3 3/3] net: dsa: microchip: ksz8: add MTU configuration support Oleksij Rempel
2022-11-08 6:47 ` Arun.Ramadoss
2022-11-08 9:21 ` Vladimir Oltean [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221108092116.fpwvlxz3bbvkha66@skbuf \
--to=olteanv@gmail.com \
--cc=Arun.Ramadoss@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox