From: Randy Dunlap <rdunlap@infradead.org>
To: Dong Yibo <dong100@mucse.com>,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
corbet@lwn.net, gur.stavi@huawei.com, maddy@linux.ibm.com,
mpe@ellerman.id.au, danishanwar@ti.com, lee@trager.us,
gongfan1@huawei.com, lorenzo@kernel.org, geert+renesas@glider.be,
Parthiban.Veerasooran@microchip.com, lukas.bulwahn@redhat.com,
alexanderduyck@fb.com, richardcochran@gmail.com, kees@kernel.org,
gustavoars@kernel.org
Cc: netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH net-next v8 4/5] net: rnpgbe: Add basic mbx_fw support
Date: Tue, 26 Aug 2025 22:26:38 -0700 [thread overview]
Message-ID: <4b6eb676-10f5-4438-9457-6aeda0ee7fb0@infradead.org> (raw)
In-Reply-To: <20250827034509.501980-5-dong100@mucse.com>
On 8/26/25 8:45 PM, Dong Yibo wrote:
> Initialize basic mbx_fw ops, such as get_capability, reset phy
> and so on.
>
> Signed-off-by: Dong Yibo <dong100@mucse.com>
> ---
> drivers/net/ethernet/mucse/rnpgbe/Makefile | 3 +-
> drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 1 +
> .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 253 ++++++++++++++++++
> .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h | 126 +++++++++
> 4 files changed, 382 insertions(+), 1 deletion(-)
> create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
> create mode 100644 drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h
>
> diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
> new file mode 100644
> index 000000000000..d3b323760708
> --- /dev/null
> +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c
> @@ -0,0 +1,253 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright(c) 2020 - 2025 Mucse Corporation. */
> +
> +#include <linux/pci.h>
> +#include <linux/if_ether.h>
> +
> +#include "rnpgbe.h"
> +#include "rnpgbe_hw.h"
> +#include "rnpgbe_mbx.h"
> +#include "rnpgbe_mbx_fw.h"
> +
> +/**
> + * mucse_fw_send_cmd_wait - Send cmd req and wait for response
> + * @hw: pointer to the HW structure
> + * @req: pointer to the cmd req structure
> + * @reply: pointer to the fw reply structure
> + *
> + * mucse_fw_send_cmd_wait sends req to pf-fw mailbox and wait
> + * reply from fw.
> + *
> + * @return: 0 on success, negative on failure
Use of @return: is not a documented feature although kernel-doc does accept it.
I prefer that people don't use it, but I can't insist since it does work.
> + **/
> +static int mucse_fw_send_cmd_wait(struct mucse_hw *hw,
> + struct mbx_fw_cmd_req *req,
> + struct mbx_fw_cmd_reply *reply)
> +{
> + int len = le16_to_cpu(req->datalen);
> + int retry_cnt = 3;
> + int err;
> +
> + err = mutex_lock_interruptible(&hw->mbx.lock);
> + if (err)
> + return err;
> + err = mucse_write_posted_mbx(hw, (u32 *)req, len);
> + if (err)
> + goto out;
> + do {
> + err = mucse_read_posted_mbx(hw, (u32 *)reply,
> + sizeof(*reply));
> + if (err)
> + goto out;
> + /* mucse_write_posted_mbx return 0 means fw has
> + * received request, wait for the expect opcode
> + * reply with 'retry_cnt' times.
> + */
> + } while (--retry_cnt >= 0 && reply->opcode != req->opcode);
> +out:
> + mutex_unlock(&hw->mbx.lock);
> + if (!err && retry_cnt < 0)
> + return -ETIMEDOUT;
> + if (!err && reply->error_code)
> + return -EIO;
> + return err;
> +}
[snip]
> +
> +/**
> + * mucse_fw_get_capability - Get hw abilities from fw
> + * @hw: pointer to the HW structure
> + * @abil: pointer to the hw_abilities structure
> + *
> + * mucse_fw_get_capability tries to get hw abilities from
> + * hw.
> + *
> + * @return: 0 on success, negative on failure
negative errno or just some negative number?
> + **/
> +static int mucse_fw_get_capability(struct mucse_hw *hw,
> + struct hw_abilities *abil)
> +{
> + struct mbx_fw_cmd_reply reply = {};
> + struct mbx_fw_cmd_req req = {};
> + int err;
> +
> + build_phy_abilities_req(&req);
> + err = mucse_fw_send_cmd_wait(hw, &req, &reply);
> + if (!err)
> + memcpy(abil, &reply.hw_abilities, sizeof(*abil));
> + return err;
> +}
--
~Randy
next prev parent reply other threads:[~2025-08-27 5:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 3:45 [PATCH net-next v8 0/5] Add driver for 1Gbe network chips from MUCSE Dong Yibo
2025-08-27 3:45 ` [PATCH net-next v8 1/5] net: rnpgbe: Add build support for rnpgbe Dong Yibo
2025-08-27 3:45 ` [PATCH net-next v8 2/5] net: rnpgbe: Add n500/n210 chip support Dong Yibo
2025-08-27 3:45 ` [PATCH net-next v8 3/5] net: rnpgbe: Add basic mbx ops support Dong Yibo
2025-08-27 3:45 ` [PATCH net-next v8 4/5] net: rnpgbe: Add basic mbx_fw support Dong Yibo
2025-08-27 5:26 ` Randy Dunlap [this message]
2025-08-27 6:34 ` Yibo Dong
2025-08-27 3:45 ` [PATCH net-next v8 5/5] net: rnpgbe: Add register_netdev Dong Yibo
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=4b6eb676-10f5-4438-9457-6aeda0ee7fb0@infradead.org \
--to=rdunlap@infradead.org \
--cc=Parthiban.Veerasooran@microchip.com \
--cc=alexanderduyck@fb.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=dong100@mucse.com \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=gongfan1@huawei.com \
--cc=gur.stavi@huawei.com \
--cc=gustavoars@kernel.org \
--cc=horms@kernel.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=lee@trager.us \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.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;
as well as URLs for NNTP newsgroup(s).