From: Nikolay Aleksandrov <razor@blackwall.org>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
netdev@vger.kernel.org
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>,
Ian MacDonald <ian@netstatz.com>,
Salvatore Bonaccorso <carnil@debian.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jay Vosburgh <jv@jvosburgh.net>, Simon Horman <horms@kernel.org>
Subject: Re: [PATCH RESEND net-next v2 2/5] net: thunderbolt: Allow changing MTU of the device
Date: Fri, 9 Jan 2026 14:35:41 +0200 [thread overview]
Message-ID: <b070f4f6-e81b-4674-954b-609ad17f1cda@blackwall.org> (raw)
In-Reply-To: <20260109122606.3586895-3-mika.westerberg@linux.intel.com>
On 09/01/2026 14:26, Mika Westerberg wrote:
> In some cases it is useful to be able to use different MTU than the
> default one. Especially when dealing against non-Linux networking stack.
> For this reason add possibility to change the MTU of the device.
>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> ---
> drivers/net/thunderbolt/main.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
> index 57b226afeb84..20bac55a3e20 100644
> --- a/drivers/net/thunderbolt/main.c
> +++ b/drivers/net/thunderbolt/main.c
> @@ -1257,12 +1257,23 @@ static void tbnet_get_stats64(struct net_device *dev,
> stats->rx_missed_errors = net->stats.rx_missed_errors;
> }
>
> +static int tbnet_change_mtu(struct net_device *dev, int new_mtu)
> +{
> + /* Keep the MTU within supported range */
> + if (new_mtu < 68 || new_mtu > (TBNET_MAX_MTU - ETH_HLEN))
> + return -EINVAL;
> +
> + dev->mtu = new_mtu;
> + return 0;
> +}
> +
> static const struct net_device_ops tbnet_netdev_ops = {
> .ndo_open = tbnet_open,
> .ndo_stop = tbnet_stop,
> .ndo_start_xmit = tbnet_start_xmit,
> .ndo_set_mac_address = eth_mac_addr,
> .ndo_get_stats64 = tbnet_get_stats64,
> + .ndo_change_mtu = tbnet_change_mtu,
> };
>
> static void tbnet_generate_mac(struct net_device *dev)
You can use struct net_device's min/max_mtu instead of a custom
ndo_change_mtu.
They will be validated by dev_validate_mtu().
Cheers,
Nik
next prev parent reply other threads:[~2026-01-09 12:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 12:26 [PATCH RESEND net-next v2 0/5] net: thunderbolt: Various improvements Mika Westerberg
2026-01-09 12:26 ` [PATCH RESEND net-next v2 1/5] net: thunderbolt: Allow changing MAC address of the device Mika Westerberg
2026-01-10 17:57 ` Andrew Lunn
2026-01-09 12:26 ` [PATCH RESEND net-next v2 2/5] net: thunderbolt: Allow changing MTU " Mika Westerberg
2026-01-09 12:35 ` Nikolay Aleksandrov [this message]
2026-01-09 12:40 ` Nikolay Aleksandrov
2026-01-09 12:26 ` [PATCH RESEND net-next v2 3/5] net: ethtool: Add define for SPEED_80000 Mika Westerberg
2026-01-10 18:03 ` Andrew Lunn
2026-01-09 12:26 ` [PATCH RESEND net-next v2 4/5] bonding: 3ad: Add support " Mika Westerberg
2026-01-09 12:37 ` Nikolay Aleksandrov
2026-01-09 12:26 ` [PATCH RESEND net-next v2 5/5] net: thunderbolt: Allow reading link settings Mika Westerberg
2026-01-10 18:08 ` Andrew Lunn
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=b070f4f6-e81b-4674-954b-609ad17f1cda@blackwall.org \
--to=razor@blackwall.org \
--cc=YehezkelShB@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=carnil@debian.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=ian@netstatz.com \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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