🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #23964

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

#23964
From: Andrew Lunn
Date: Sat, 28 Nov 2026 17:49
77 lines
10733 bytes
> +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
Technical Details
Message-ID: <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373254-linux-kernel-netdev=dewy.ru
References: <20261126145711.70868-1-tianx@yunsilicon.com> <20261126145730.70868-8-tianx@yunsilicon.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373254-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH v2 07/11] net/xsc: add the ethernet netdev
Date: Sat, 28 Nov 2026 18:49:27 +0100
Organization: Usenet Network
Message-ID: <8615f31b-57d6-4db5-b4aa-c6a421414231@lunn.ch>
References: <20261126145711.70868-1-tianx@yunsilicon.com>
 <20261126145730.70868-8-tianx@yunsilicon.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="999975"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:bdTIVvWRwOsD2X2Ocp5Z9XifuEU= sha256:KP+/Z7LxmnmgGXxajmzFPTcZR52Lev0y0b9QHVPdesw=
	sha1:BiGhpMAuTplLs1yRJu+a9J96yV0= sha256:HH00crF9jHILYxHfU1zHnKYZMm2VIrNp0XBB6FojcfA=
Content-Disposition: inline
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 8AC5D125F87; Sat, 28 Nov 2026 20:50:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 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, 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 (1024-bit key)
	header.d=lunn.ch
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 DQiG3JnZZCsD;
	Sat, 28 Nov 2026 20:50:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373254-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id BFFB3125F84; Sat, 28 Nov 2026 20:50:05 +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 0ABC72734C; Sat, 28 Nov 2026 17:50:04 +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=1795888203;
	b=ycU4m6O1trWBP8QFgAH2sW2SK4BUlzqGn2oXvEDhMxQEvDr2e3+L8Ye3E2xzRuYEmSu+
	 QDbrAwnBpJAiq+U0e7WHiAw5WRDALD2vI+T+HqHQj0FX6U8kqgzI7iMblja4zjN1hYYCJ
	 yVlN3Urd7B+fY7gtD3yhy7o4+ghcBNvkplW+o8ZCGos+wniX7/VFnjJO7bLrsBZq8spFa
	 LVLxm3yu+g6FLfugDts9hXJYvpVsqWF7WCB8R5Yxnz/6kK8uku7qJU4+nEmp8arv829s3
	 /uCBzGcrHZEPfuHz07afQSy44JSd1gbEfkx48giSPASFNWJZ0vaNhHkPzpfKHEmpI2Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795888203;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:Date:
	 From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=v0TZTafjXeE7cShJV5rlyuLnh47Gj42rqWddvHQLLEU=;
	b=RtLUijP5wFVNO9oeFDGtrj25gd61kOMlZGGZbJ+yzozJmgm+Hro7olMXInkZ4BbrXVnC
	 4L3xZLCuMlin9ayFlOD0oC0VGr9y/FJ7jw/C5XbSAGL5uL8Ww2H/zQYrWJJgshVKQSMiD
	 OBmDdGy4nnhOA1WurujApl648Oa/4AcG1MZXJD2Lo8qkYBm1UB28TmIBAPjmrBEER3sv0
	 EFeHLmwQ5dJYdT3gkNgfiaCEfJzpcBp3UaP5zsV6tBxR0phOYg6hWVtSgOpkgcvzHMfwz
	 lUya6vdP2OOrglTBrP4doigggDGpN4X9UpJFlNDuNwytiuDSKpm3e711JQy8uVQU2Rg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=A1ZkAwFe;
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	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 D4FC1606A325;
	Sat, 28 Nov 2026 17:50:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=A1ZkAwFe
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795888193;
	b=uYRHTGYDFM0Ubqfq1ahv8IGTKFSfskOXGLsocXSa0nTXW1jqMMtPjdS3x6xd7dRqX1eV
	 p7ALkiRdlWTnGa+W5CzRQN6k8FpsR2lfEag/OqU3wocOkkXj6wj52MKbP0OmgWKkCROEV
	 JhoHJsROqg3GAx4l+CBQw2sCFJ4byzywZV54rVcBubIjYxRZfpm3BbnNyQLS6MYld2H2J
	 3yRhXr4kB4O646MO1BUOHCaUmEbq/Zns3ngDQsoGNdL+SZt57GZa1ucQNZK3ptE9yALp6
	 xjH/qW3LMLf+eGAMrEE0ZvCAN7DUVi25Z9ao1zOJDSc5O13j0TDotGG19HX2aBYCgAQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795888193;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=v0TZTafjXeE7cShJV5rlyuLnh47Gj42rqWddvHQLLEU=;
	b=l5TtmK7dE+BcpP+OK1rEoAnnuGkZQ2CKyIZUQAAhx69/Nn5vAHYZUAh6NP9G0EtU39dU
	 YGrbWjJaHCBYcZyPT8J8xldyQUQgpiafYVicXtroXXpmRL8DAudEVtvOM3bz6mgpMv28i
	 /D3+QD4cHWFbDiKXu4QPCcCah+Htu/g2DWDy57J6TYfR74sS9iuaA8u1XYYdPcwxjuSYb
	 tahAFvcEt5ZPM5MyRZFUqZWJ3dg0M1BDJ3Yt+mt+yyimlBmXMQDibdZDvVFUx6fvlgoJm
	 i/gwXd2+eNzQ5DVV+0Cs+er283mC0JxLkiUtPmU4lDGwOuwLehVWOU0NkUIrlS772gQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=A1ZkAwFe;
	arc=none smtp.remote-ip=156.67.10.101
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A92D5606A31C;
	Sat, 28 Nov 2026 17:49:52 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A92D5606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch;
	s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version:
	References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject:
	Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
	Content-ID:Content-Description:Content-Disposition:In-Reply-To:References;
	bh=v0TZTafjXeE7cShJV5rlyuLnh47Gj42rqWddvHQLLEU=; b=A1ZkAwFe8Ha4fHjv8xXokHQvYO
	b0hJKaf/zkcXjffniKF7+G5VEbLVxAsRwQ+fyFLSSBis869Pe937i7BZwNq3Bc/0nxUNeMCq9hv82
	fHDPVYmH20dxN4ar5eh8hwGw0C+htBT5Vus+nqsV/1UeEH49c307LeVCETfscjshQMV0=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xXMYB-00213P-M3; Sat, 28 Nov 2026 18:49:27 +0100
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,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-rdma@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: <20261126145730.70868-8-tianx@yunsilicon.com>