From: "Xin Tian" <tianx@yunsilicon.com>
To: "Andrew Lunn" <andrew@lunn.ch>
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>, <netdev@vger.kernel.org>,
<kerneljasonxing@gmail.com>
Subject: Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev
Date: Tue, 1 Dec 2026 18:06:33 +0800 [thread overview]
Message-ID: <0d411c10-e724-43e6-a1a9-8bb99344571a@yunsilicon.com> (raw)
In-Reply-To: <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>
On 11/29/2026 1:49 AM, Andrew Lunn wrote:
>> +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().
I'd like to keep xsc_eth_set_hw_mtu(). Fixed MTU just means the netdev
MTU isn't user-changeable; the function sends a SET_MTU firmware command
that programs the port's frame length and RX buffer size into the
hardware,
which has to happen at probe either way.
>> +++ 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?
Will remove the unused <linux/udp.h> include.
>
>> +#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.
Right, I'll drop the SW_DEFAULT_MTU alias and use ETH_DATA_LEN directly.
>> +#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
Agreed, XSC_ETH_HARD_MTU is not a descriptive name. I will drop
XSC_ETH_HARD_MTU and write the length calculation where it is used:
#define XSC_SW2HW_MTU(mtu) ((mtu) + ETH_HLEN + 2 * VLAN_HLEN +
ETH_FCS_LEN)
Thanks,
Xin
next prev parent reply other threads:[~2026-12-01 10:06 UTC|newest]
Thread overview: 42+ 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-12-06 2:56 ` Xin Tian
2026-11-28 17:32 ` Andrew Lunn
2026-12-01 9:48 ` Xin Tian
2026-11-29 2:53 ` Jason Xing
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-12-06 3:14 ` Xin Tian
2026-11-29 5:47 ` Jason Xing
2026-12-01 9:16 ` Xin Tian
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-12-06 8:58 ` Xin Tian
2026-11-29 7:30 ` Jason Xing
2026-12-01 9:22 ` Xin Tian
2026-12-02 6:21 ` Jason Xing
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-12-06 9:04 ` Xin Tian
2026-11-29 7:48 ` Jason Xing
2026-12-01 9:24 ` Xin Tian
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-12-06 9:11 ` Xin Tian
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-12-06 9:36 ` Xin Tian
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-12-06 9:40 ` Xin Tian
2026-11-28 17:49 ` Andrew Lunn
2026-12-01 10:06 ` Xin Tian [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=0d411c10-e724-43e6-a1a9-8bb99344571a@yunsilicon.com \
--to=tianx@yunsilicon.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@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=netdev@vger.kernel.org \
--cc=pabeni@redhat.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