Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev

From: Andrew Lunn

Date: Sat Nov 28 2026 - 12:50:02 EST


> +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