Article View: linux.kernel.netdev
Article #25153Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev
From: "Xin Tian"
Date: Tue, 01 Dec 2026 10:06
Date: Tue, 01 Dec 2026 10:06
93 lines
12111 bytes
12111 bytes
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
Technical Details
Message-ID:
<0d411c10-e724-43e6-a1a9-8bb99344571a@yunsilicon.com>Path:
mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374928-linux-kernel-netdev=dewy.ruReferences:
<20261126145711.70868-1-tianx@yunsilicon.com> <20261126145730.70868-8-tianx@yunsilicon.com> <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374928-linux-kernel-netdev=dewy.ru
From: tianx@yunsilicon.com ("Xin Tian")
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev
Date: Tue, 1 Dec 2026 18:06:33 +0800
Organization: Usenet Network
Message-ID: <0d411c10-e724-43e6-a1a9-8bb99344571a@yunsilicon.com>
References: <20261126145711.70868-1-tianx@yunsilicon.com> <20261126145730.70868-8-tianx@yunsilicon.com> <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="1681182"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:RdMdfPz2Co02FHpBOSCMEzz5+sA= sha256:I1IQTkYLyc1U13FjJdXP//ZUGUmxjIe7bdJOcHbPsNo=
sha1:ZOjG2cU4blmveoti+HmD/mJdCZk= sha256:aArb0kGyn7VX+V0NGu/+6eTpQwkPQ2uStDp81H/Pckw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 27A471172FF; Tue, 1 Dec 2026 13:07:05 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, MSGID_FROM_MTA_HEADER=0.001,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=yunsilicon.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id IkjYreHslohW;
Tue, 1 Dec 2026 13:07:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374928-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=yunsilicon.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 1D8A511716E; Tue, 1 Dec 2026 13:06:52 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 6A53F2FCF0; Tue, 1 Dec 2026 10:06:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796119611;
b=t0W2QWy4d9eCZPTVP6YRjiDmdoNx6xMQWB2TvIKY8ihu8im+bYxyYiMn7Y1HnMfqumyD
bD+gkyTIHhdyNC6rcFOCpp4AwY553F2nnqy+4jugRu/TxpIfmo1efvapKKgbLlPZSGrVP
8eahrKEtSzunViHzDBoopJnXR7hlpqqHmcCXZootGQvAXIno0HOxua7TnCoRrGmRMnECK
TM7BNCk5QakowZYc28Dcmh89Eqe2QR5vkHC4Q9OhRL8G8aCPiMhaqYs9wriD0RegxBq5T
bkZYOVIDn/tUtBZB5U45IH18YglmBaIx+rasyljttfUwudTKLPrOdRpldSZm00EaHwA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796119611;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Cc:Subject:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:Mime-Version:
Content-Transfer-Encoding:In-Reply-To:To:From:X-Lms-Return-Path:
References:Content-Type:Message-Id:Received:Date:X-Original-From:
User-Agent;
bh=T060rLmwJGPUZy80p3DVkecwAvVo0d7+xIKX6njeaFo=;
b=2MBIgkD+DCnRi7t+lsknVDO2sHJc76BGLqbBJZAwIR62gMb3kGBJbPiNYaukx5bV1KW7
H/pp2PIOLbD4Gj2rCOFfbm0k9dPZaaX0WGDeJLfzEoPZ2dMJ0djt/sHThwCgkdTB6N4sq
go55YNrQ6So45lHplXpfJJ8LXgyfxJ+iLcmQt7a9yTzShocPmCN8Ca+wzBlm1q0qi5ttg
86GNz3VEfsXl+HwG+8FZ0ghdJm/c5fkamIKtE8+i/mgaC6NAaO/S/7v090Qun+d2k/vCb
npuPwCGfHmvy+5PuvgnrFF6mmlnr/CGdh74x6nDa54LpTsvTKatp4QpgPZ/xlNl+C5w==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=Lz5tKU50;
dmarc=none header.from=yunsilicon.com;
spf=pass smtp.mailfrom=yunsilicon.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 41F7B606A32C;
Tue, 1 Dec 2026 10:06:51 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=Lz5tKU50
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.127.231.40
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796119610;
b=whYN9pNg4kpQPWUeXKF3AC4YajnWuPkN5K/PE6pXGAlHkzH4SC/omvyqAUj+SuZHN76S
KLK3AeAogCd4/ny9prwUUeESSYzmb6JwyaUNuemEJ88yeBD09jysUY/H+7kh8axgsK5Zp
EnZpW0b6M1HsZwzlAeoc0hOTefBrBkBWhiJ7JM3mqmbnxjgNqVAsRVONBMPI+tS+v5Jqh
8x4i408jEbkM4gV9EHVESygK9OKHQkQKOPXRUMcXRfdhUcds092q5IcRSFZFob9GZgKgd
8b6GYMHBmbWD2zMmMKD6NYBaSOswlbDqY9mKkhFb5xo8KOQJJ0IwueTCPEiqYjOpuNw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796119610;
h=DMARC-Filter:DKIM-Signature:Cc:Subject:Mime-Version:
Content-Transfer-Encoding:In-Reply-To:To:From:X-Lms-Return-Path:
References:Content-Type:Message-Id:Received:Date:X-Original-From:
User-Agent;
bh=T060rLmwJGPUZy80p3DVkecwAvVo0d7+xIKX6njeaFo=;
b=Lo/05KCLvXVIBUznGW6DTrBLEJe0gF43sA1S85AUpiiGfAWqB/Pp10bq5j+R4y4sO8dg
d+iUZ7iF9/jv1mzK+xVamJsVomLtVXCMmzN4iUhrPrpP2BTPLennwyoXu0Y3nclETQbY1
wfCLZk99/dclmmk0fHpnHJ6SJEm15X9rhjYdgEZqhFav0+TZVPrIxVv6HskJ9cxgMyusK
USyZsd1u/P90YyFO030f9gRbq3VFGqW2DdRWBqFBg9ETMFrMAWsVyTEOVqhaYqMuz8EXU
s40hNTJG8wC0VaDipdLBRmkZIwESK/oqnJ2zYrUD9jOVBfQJoKFfGpiLpdCoWz3HyXQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=none header.from=yunsilicon.com;
spf=pass smtp.mailfrom=yunsilicon.com;
dkim=pass header.d=yunsilicon.com header.i=@yunsilicon.com header.a=rsa-sha256 header.s=feishu2403070942 header.b=Lz5tKU50;
arc=none smtp.remote-ip=209.127.231.40
X-Received: from va-2-40.ptr.blmpb.com (va-2-40.ptr.blmpb.com [209.127.231.40])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDA35606A31A
for <netdev@vger.kernel.org>; Tue, 1 Dec 2026 10:06:48 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CDA35606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=yunsilicon.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yunsilicon.com
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
s=feishu2403070942; d=yunsilicon.com; t=1796119602; h=from:subject:
mime-version:from:date:message-id:subject:to:cc:reply-to:content-type:
mime-version:in-reply-to:message-id;
bh=T060rLmwJGPUZy80p3DVkecwAvVo0d7+xIKX6njeaFo=;
b=Lz5tKU50+CXYNnBk1nxaqrb7wxevTctE++YPDtR1l95jWni8eTp8D7KtH4z7Fll5ttGRSg
48IA+lq8KPiNA5ziaJmDH0ZvbjRa/Y7khPWLUebbXxPRYzqQm8qR7Gtit++P2Rel5AAyq6
/wT5/nFjtusnzczakfpkzLUzHmPSUHhYn6llAEGuAxH9NIR/xs8K5Hz0FCO2nudHbDb4yj
BF4BW3oRS3bNCIKyRPNPu5bp1Z9pShBnqZ1qyn67FqscZCqf1x578GfazyX5efjdIzIVC+
iDjOqesH95FeB2Ik6nZ6BVyL/ApH343DfQomLPEqjWyUKNIok+JYP4r+Q099ng==
X-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>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>
X-Lms-Return-Path: <lba+26b0e9c30+440b5e+vger.kernel.org+tianx@yunsilicon.com>
X-Received: from [127.0.0.1] ([183.193.56.176]) by smtp.feishu.cn with ESMTPS; Tue, 01 Dec 2026 18:06:39 +0800
X-Original-From: Xin Tian <tianx@yunsilicon.com>
X-User-Agent: Mozilla Thunderbird