From: Jakub Kicinski <kuba@kernel.org>
To: "Xin Tian" <tianx@yunsilicon.com>
Cc: <netdev@vger.kernel.org>, <leon@kernel.org>,
<andrew+netdev@lunn.ch>, <pabeni@redhat.com>,
<edumazet@google.com>, <davem@davemloft.net>,
<jeff.johnson@oss.qualcomm.com>, <przemyslaw.kitszel@intel.com>,
<weihg@yunsilicon.com>, <wanry@yunsilicon.com>,
<jacky@yunsilicon.com>, <horms@kernel.org>,
<parthiban.veerasooran@microchip.com>, <masahiroy@kernel.org>,
<kalesh-anakkur.purayil@broadcom.com>, <geert+renesas@glider.be>,
<geert@linux-m68k.org>
Subject: Re: [PATCH net-next v9 09/14] xsc: Init net device
Date: Tue, 25 Mar 2025 05:19:34 -0700 [thread overview]
Message-ID: <20250325051934.002db3cd@kernel.org> (raw)
In-Reply-To: <20250318151510.1376756-10-tianx@yunsilicon.com>
On Tue, 18 Mar 2025 23:15:11 +0800 Xin Tian wrote:
> +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 ret;
> +
> + 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;
> +
> + ret = xsc_cmd_exec(xdev, &in, sizeof(struct xsc_set_mtu_mbox_in), &out,
> + sizeof(struct xsc_set_mtu_mbox_out));
> + if (ret || out.hdr.status) {
> + netdev_err(((struct xsc_adapter *)xdev->eth_priv)->netdev,
Please use temporary variable or define a local print macro.
The cast is too ugly.
> + "failed to set hw_mtu=%u rx_buf_sz=%u, err=%d, status=%d\n",
> + mtu, rx_buf_sz, ret, out.hdr.status);
> + ret = -ENOEXEC;
Why are you overwriting the ret code from xsc_cmd_exec() ?
And why with such an unusual errno ?
> +static int xsc_eth_get_mac(struct xsc_core_device *xdev, char *mac)
> +{
> + struct xsc_query_eth_mac_mbox_out *out;
> + struct xsc_query_eth_mac_mbox_in in;
> + int err = 0;
> +
> + out = kzalloc(sizeof(*out), GFP_KERNEL);
> + if (!out)
> + return -ENOMEM;
> +
> + memset(&in, 0, sizeof(in));
> + in.hdr.opcode = cpu_to_be16(XSC_CMD_OP_QUERY_ETH_MAC);
> +
> + err = xsc_cmd_exec(xdev, &in, sizeof(in), out, sizeof(*out));
> + if (err || out->hdr.status) {
> + netdev_err(((struct xsc_adapter *)xdev->eth_priv)->netdev,
> + "get mac failed! err=%d, out.status=%u\n",
> + err, out->hdr.status);
> + err = -ENOEXEC;
> + goto err_free;
> + }
> +
> + memcpy(mac, out->mac, 6);
6 -> ETH_ALEN or ether_addr_copy()
> +
> +err_free:
> + kfree(out);
> + return err;
> +}
> +
> +static void xsc_eth_l2_addr_init(struct xsc_adapter *adapter)
> +{
> + struct net_device *netdev = adapter->netdev;
> + char mac[6] = {0};
> + int ret = 0;
> +
> + ret = xsc_eth_get_mac(adapter->xdev, mac);
> + if (ret) {
> + netdev_err(netdev, "get mac failed %d, generate random mac...",
> + ret);
> + eth_random_addr(mac);
eth_hw_addr_random()
> + }
> + dev_addr_mod(netdev, 0, mac, 6);
Why not dev_addr_set() ?!
next prev parent reply other threads:[~2025-03-25 12:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 15:15 [PATCH net-next v9 00/14] xsc: ADD Yunsilicon XSC Ethernet Driver Xin Tian
2025-03-18 15:14 ` [PATCH net-next v9 01/14] xsc: Add xsc driver basic framework Xin Tian
2025-03-18 15:14 ` [PATCH net-next v9 02/14] xsc: Enable command queue Xin Tian
2025-03-18 15:14 ` [PATCH net-next v9 03/14] xsc: Add hardware setup APIs Xin Tian
2025-03-18 15:14 ` [PATCH net-next v9 04/14] xsc: Add qp and cq management Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 05/14] xsc: Add eq and alloc Xin Tian
2025-03-25 12:11 ` Jakub Kicinski
2025-04-07 6:56 ` Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 06/14] xsc: Init pci irq Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 07/14] xsc: Init auxiliary device Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 08/14] xsc: Add ethernet interface Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 09/14] xsc: Init net device Xin Tian
2025-03-25 12:19 ` Jakub Kicinski [this message]
2025-04-07 9:16 ` Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 10/14] xsc: Add eth needed qp and cq apis Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 11/14] xsc: ndo_open and ndo_stop Xin Tian
2025-03-26 10:14 ` Simon Horman
2025-04-07 10:44 ` Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 12/14] xsc: Add ndo_start_xmit Xin Tian
2025-03-26 10:17 ` Simon Horman
2025-04-09 7:36 ` Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 13/14] xsc: Add eth reception data path Xin Tian
2025-03-26 10:27 ` Simon Horman
2025-04-09 8:06 ` Xin Tian
2025-03-18 15:15 ` [PATCH net-next v9 14/14] xsc: add ndo_get_stats64 Xin Tian
2025-03-26 10:31 ` Simon Horman
2025-04-09 8:08 ` Xin Tian
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=20250325051934.002db3cd@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=geert@linux-m68k.org \
--cc=horms@kernel.org \
--cc=jacky@yunsilicon.com \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=leon@kernel.org \
--cc=masahiroy@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=parthiban.veerasooran@microchip.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=tianx@yunsilicon.com \
--cc=wanry@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.