From: Andrew Lunn <andrew@lunn.ch>
To: Xin Tian <tianx@yunsilicon.com>
Cc: 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>,
Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
Junxian Huang <huangjunxian6@hisilicon.com>,
weihg@yunsilicon.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
kerneljasonxing@gmail.com
Subject: Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev
Date: Sat, 28 Nov 2026 18:49:27 +0100 [thread overview]
Message-ID: <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch> (raw)
In-Reply-To: <20261126145730.70868-8-tianx@yunsilicon.com>
> +static void xsc_eth_build_nic_params(struct xsc_adapter *adapter)
> +{
> + struct xsc_eth_params *params = &adapter->nic_param;
> +
> + params->mtu = SW_DEFAULT_MTU;
> +}
> +static int xsc_eth_set_hw_mtu(struct xsc_core_device *xdev,
> + u16 mtu, u16 rx_buf_sz)
> +{
> + struct xsc_set_mtu_mbox_out out;
> + struct xsc_set_mtu_mbox_in in;
> + int err;
> +
> + memset(&in, 0, sizeof(struct xsc_set_mtu_mbox_in));
> + memset(&out, 0, sizeof(struct xsc_set_mtu_mbox_out));
> +
> + in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_SET_MTU);
> + in.mtu = cpu_to_be16(mtu);
> + in.rx_buf_sz_min = cpu_to_be16(rx_buf_sz);
> + in.mac_port = xdev->mac_port;
> +
> + err = xsc_cmd_exec(xdev, &in, sizeof(struct xsc_set_mtu_mbox_in), &out,
> + sizeof(struct xsc_set_mtu_mbox_out));
> + if (err) {
> + netdev_err(xsc_dev_to_netdev(xdev),
> + "failed to set hw_mtu=%u rx_buf_sz=%u, err=%d, status=%d\n",
> + mtu, rx_buf_sz, err, out.hdr.status);
> + return err;
> + }
> +
> + return 0;
> +}
> +static void xsc_eth_build_nic_netdev(struct xsc_adapter *adapter)
> +{
> + struct net_device *netdev = adapter->netdev;
> +
> + netdev->netdev_ops = &xsc_netdev_ops;
> +
> + netdev->min_mtu = SW_DEFAULT_MTU;
> + netdev->max_mtu = SW_DEFAULT_MTU;
> + netdev->mtu = SW_DEFAULT_MTU;
If the MTU is fixed, it seems pointless having xsc_eth_set_hw_mtu().
> +++ b/drivers/net/ethernet/yunsilicon/xsc/net/xsc_eth.h
> @@ -0,0 +1,33 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright (C) 2021-2026, Shanghai Yunsilicon Technology Co., Ltd.
> + * All rights reserved.
> + */
> +
> +#ifndef __XSC_ETH_H
> +#define __XSC_ETH_H
> +
> +#include <linux/udp.h>
Why this header? How is UDP special?
> +#define SW_DEFAULT_MTU ETH_DATA_LEN
Please don't alias well known #defines. I know what ETH_DATA_LEN is,
fixing the MTU to that makes sense. But i had not idea what
SW_DEFAULT_MTU was until i got here. So you are just obfuscating the
code.
> +#define XSC_ETH_HW_MTU_SEND 9800
> +#define XSC_ETH_HARD_MTU (ETH_HLEN + VLAN_HLEN * 2 + ETH_FCS_LEN)
The code would be a lot more readable if you used these in the actual
code, rather than hide them here. I can see this and see you need
space for the ethernet header, up to two VLAN headers and the trailing
CRC. XSC_ETH_HARD_MTU tells me nothing.
Andrew
next prev parent reply other threads:[~2026-11-28 17:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:57 [PATCH v2 00/11] net/xsc: add the Yunsilicon XSC ethernet driver Xin Tian
2026-11-26 14:57 ` [PATCH v2 01/11] net/xsc: add Yunsilicon XSC ethernet PCI driver Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-28 17:32 ` Andrew Lunn
2026-11-26 14:57 ` [PATCH v2 02/11] net/xsc: add doorbell and cmdq MMIO accessors Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 03/11] net/xsc: add the command queue Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 04/11] net/xsc: query HCA capabilities and reset function Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 05/11] net/xsc: add event queues and MSI-X Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 06/11] net/xsc: add CQ and QP helpers Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 07/11] net/xsc: add the ethernet netdev Xin Tian
2026-11-27 15:57 ` netdev-bot+sashiko
2026-11-28 17:49 ` Andrew Lunn [this message]
2026-11-26 14:57 ` [PATCH v2 08/11] net/xsc: add the single TX/RX channel Xin Tian
2026-11-27 15:58 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 09/11] net/xsc: report link state changes Xin Tian
2026-11-27 15:58 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 10/11] net/xsc: add the transmit path Xin Tian
2026-11-27 15:58 ` netdev-bot+sashiko
2026-11-26 14:57 ` [PATCH v2 11/11] net/xsc: add the receive path Xin Tian
2026-11-27 15:58 ` netdev-bot+sashiko
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=8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch \
--to=andrew@lunn.ch \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=huangjunxian6@hisilicon.com \
--cc=jgg@ziepe.ca \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tianx@yunsilicon.com \
--cc=weihg@yunsilicon.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
all inboxes | Powered by JetHome®