All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Fan Gong <gongfan1@huawei.com>, Zhu Yikai <zhuyikai1@h-partners.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	linux-doc@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	Bjorn Helgaas <helgaas@kernel.org>, luosifu <luosifu@huawei.com>,
	Xin Guo <guoxin09@huawei.com>,
	Shen Chenyang <shenchenyang1@hisilicon.com>,
	Zhou Shuai <zhoushuai28@huawei.com>, Wu Like <wulike1@huawei.com>,
	Shi Jing <shijing34@huawei.com>,
	Meny Yossefi <meny.yossefi@huawei.com>,
	Gur Stavi <gur.stavi@huawei.com>, Lee Trager <lee@trager.us>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Suman Ghosh <sumang@marvell.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Subject: Re: [PATCH net-next v01 08/12] hinic3: Queue pair context initialization
Date: Tue, 26 Aug 2025 17:42:46 +0100	[thread overview]
Message-ID: <cf5d9158-4833-4355-8e4d-0894411d0d46@linux.dev> (raw)
In-Reply-To: <fc3dd2c0d29c54332169bc5a2e5be4e4eac77b07.1756195078.git.zhuyikai1@h-partners.com>

On 26/08/2025 10:05, Fan Gong wrote:
> Initialize queue pair context of hardware interaction.
> 
> Co-developed-by: Xin Guo <guoxin09@huawei.com>
> Signed-off-by: Xin Guo <guoxin09@huawei.com>
> Co-developed-by: Zhu Yikai <zhuyikai1@h-partners.com>
> Signed-off-by: Zhu Yikai <zhuyikai1@h-partners.com>
> Signed-off-by: Fan Gong <gongfan1@huawei.com>
> ---

a bit of styling nits, but as you still have to do another version it
would be great to fix.

[...]

> +static int init_sq_ctxts(struct hinic3_nic_dev *nic_dev)
> +{
> +	struct hinic3_nic_io *nic_io = nic_dev->nic_io;
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +	struct hinic3_sq_ctxt_block *sq_ctxt_block;
> +	u16 q_id, curr_id, max_ctxts, i;
> +	struct hinic3_sq_ctxt *sq_ctxt;
> +	struct hinic3_cmd_buf *cmd_buf;
> +	struct hinic3_io_queue *sq;
> +	__le64 out_param;
> +	int err = 0;
> +
> +	cmd_buf = hinic3_alloc_cmd_buf(hwdev);
> +	if (!cmd_buf) {
> +		dev_err(hwdev->dev, "Failed to allocate cmd buf\n");
> +		return -ENOMEM;
> +	}
> +
> +	q_id = 0;
> +	while (q_id < nic_io->num_qps) {
> +		sq_ctxt_block = cmd_buf->buf;
> +		sq_ctxt = sq_ctxt_block->sq_ctxt;
> +
> +		max_ctxts = (nic_io->num_qps - q_id) > HINIC3_Q_CTXT_MAX ?
> +			     HINIC3_Q_CTXT_MAX : (nic_io->num_qps - q_id);
> +
> +		hinic3_qp_prepare_cmdq_header(&sq_ctxt_block->cmdq_hdr,
> +					      HINIC3_QP_CTXT_TYPE_SQ, max_ctxts,
> +					      q_id);
> +
> +		for (i = 0; i < max_ctxts; i++) {
> +			curr_id = q_id + i;
> +			sq = &nic_io->sq[curr_id];
> +			hinic3_sq_prepare_ctxt(sq, curr_id, &sq_ctxt[i]);
> +		}
> +
> +		hinic3_cmdq_buf_swab32(sq_ctxt_block, sizeof(*sq_ctxt_block));
> +
> +		cmd_buf->size = cpu_to_le16(SQ_CTXT_SIZE(max_ctxts));
> +		err = hinic3_cmdq_direct_resp(hwdev, MGMT_MOD_L2NIC,
> +					      L2NIC_UCODE_CMD_MODIFY_QUEUE_CTX,
> +					      cmd_buf, &out_param);
> +		if (err || out_param != 0) {

no need for "!= 0" ...

> +			dev_err(hwdev->dev, "Failed to set SQ ctxts, err: %d, out_param: 0x%llx\n",
> +				err, out_param);
> +			err = -EFAULT;
> +			break;
> +		}
> +
> +		q_id += max_ctxts;
> +	}
> +
> +	hinic3_free_cmd_buf(hwdev, cmd_buf);
> +
> +	return err;
> +}
> +
> +static int init_rq_ctxts(struct hinic3_nic_dev *nic_dev)
> +{
> +	struct hinic3_nic_io *nic_io = nic_dev->nic_io;
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +	struct hinic3_rq_ctxt_block *rq_ctxt_block;
> +	u16 q_id, curr_id, max_ctxts, i;
> +	struct hinic3_rq_ctxt *rq_ctxt;
> +	struct hinic3_cmd_buf *cmd_buf;
> +	struct hinic3_io_queue *rq;
> +	__le64 out_param;
> +	int err = 0;
> +
> +	cmd_buf = hinic3_alloc_cmd_buf(hwdev);
> +	if (!cmd_buf) {
> +		dev_err(hwdev->dev, "Failed to allocate cmd buf\n");
> +		return -ENOMEM;
> +	}
> +
> +	q_id = 0;
> +	while (q_id < nic_io->num_qps) {
> +		rq_ctxt_block = cmd_buf->buf;
> +		rq_ctxt = rq_ctxt_block->rq_ctxt;
> +
> +		max_ctxts = (nic_io->num_qps - q_id) > HINIC3_Q_CTXT_MAX ?
> +				HINIC3_Q_CTXT_MAX : (nic_io->num_qps - q_id);
> +
> +		hinic3_qp_prepare_cmdq_header(&rq_ctxt_block->cmdq_hdr,
> +					      HINIC3_QP_CTXT_TYPE_RQ, max_ctxts,
> +					      q_id);
> +
> +		for (i = 0; i < max_ctxts; i++) {
> +			curr_id = q_id + i;
> +			rq = &nic_io->rq[curr_id];
> +			hinic3_rq_prepare_ctxt(rq, &rq_ctxt[i]);
> +		}
> +
> +		hinic3_cmdq_buf_swab32(rq_ctxt_block, sizeof(*rq_ctxt_block));
> +
> +		cmd_buf->size = cpu_to_le16(RQ_CTXT_SIZE(max_ctxts));
> +
> +		err = hinic3_cmdq_direct_resp(hwdev, MGMT_MOD_L2NIC,
> +					      L2NIC_UCODE_CMD_MODIFY_QUEUE_CTX,
> +					      cmd_buf, &out_param);
> +		if (err || out_param != 0) {

... here as well

> +			dev_err(hwdev->dev, "Failed to set RQ ctxts, err: %d, out_param: 0x%llx\n",
> +				err, out_param);
> +			err = -EFAULT;
> +			break;
> +		}
> +
> +		q_id += max_ctxts;
> +	}
> +
> +	hinic3_free_cmd_buf(hwdev, cmd_buf);
> +
> +	return err;
> +}

[...]

> +static int clean_queue_offload_ctxt(struct hinic3_nic_dev *nic_dev,
> +				    enum hinic3_qp_ctxt_type ctxt_type)
> +{
> +	struct hinic3_nic_io *nic_io = nic_dev->nic_io;
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +	struct hinic3_clean_queue_ctxt *ctxt_block;
> +	struct hinic3_cmd_buf *cmd_buf;
> +	__le64 out_param;
> +	int err;
> +
> +	cmd_buf = hinic3_alloc_cmd_buf(hwdev);
> +	if (!cmd_buf) {
> +		dev_err(hwdev->dev, "Failed to allocate cmd buf\n");
> +		return -ENOMEM;
> +	}
> +
> +	ctxt_block = cmd_buf->buf;
> +	ctxt_block->cmdq_hdr.num_queues = cpu_to_le16(nic_io->max_qps);
> +	ctxt_block->cmdq_hdr.queue_type = cpu_to_le16(ctxt_type);
> +	ctxt_block->cmdq_hdr.start_qid = 0;
> +	ctxt_block->cmdq_hdr.rsvd = 0;
> +	ctxt_block->rsvd = 0;
> +
> +	hinic3_cmdq_buf_swab32(ctxt_block, sizeof(*ctxt_block));
> +
> +	cmd_buf->size = cpu_to_le16(sizeof(*ctxt_block));
> +
> +	err = hinic3_cmdq_direct_resp(hwdev, MGMT_MOD_L2NIC,
> +				      L2NIC_UCODE_CMD_CLEAN_QUEUE_CTX,
> +				      cmd_buf, &out_param);
> +	if ((err) || (out_param)) {

no need for extra parenthesis

> +		dev_err(hwdev->dev, "Failed to clean queue offload ctxts, err: %d,out_param: 0x%llx\n",
> +			err, out_param);
> +
> +		err = -EFAULT;
> +	}
> +
> +	hinic3_free_cmd_buf(hwdev, cmd_buf);


  reply	other threads:[~2025-08-26 16:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  9:05 [PATCH net-next v01 00/12] net: hinic3: Add a driver for Huawei 3rd gen NIC - sw and hw initialization Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 01/12] hinic3: HW initialization Fan Gong
2025-08-26 11:37   ` Vadim Fedorenko
2025-08-26 19:52   ` ALOK TIWARI
2025-08-26  9:05 ` [PATCH net-next v01 02/12] hinic3: HW management interfaces Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 03/12] hinic3: HW common function initialization Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 04/12] hinic3: HW capability initialization Fan Gong
2025-08-26 14:17   ` Vadim Fedorenko
2025-08-26  9:05 ` [PATCH net-next v01 05/12] hinic3: Command Queue flush interfaces Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 06/12] hinic3: Nic_io initialization Fan Gong
2025-08-26 15:49   ` Vadim Fedorenko
2025-08-26  9:05 ` [PATCH net-next v01 07/12] hinic3: Queue pair resource initialization Fan Gong
2025-08-26 16:08   ` Vadim Fedorenko
2025-08-26 20:05   ` ALOK TIWARI
2025-08-26  9:05 ` [PATCH net-next v01 08/12] hinic3: Queue pair context initialization Fan Gong
2025-08-26 16:42   ` Vadim Fedorenko [this message]
2025-08-26  9:05 ` [PATCH net-next v01 09/12] hinic3: Tx & Rx configuration Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 10/12] hinic3: Add Rss function Fan Gong
2025-08-26 17:06   ` Vadim Fedorenko
2025-08-26 17:49     ` Jakub Kicinski
2025-08-26 17:54   ` Eric Dumazet
2025-08-27  9:50     ` Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 11/12] hinic3: Add port management Fan Gong
2025-08-26  9:05 ` [PATCH net-next v01 12/12] hinic3: Fix missing napi->dev in netif_queue_set_napi Fan Gong

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=cf5d9158-4833-4355-8e4d-0894411d0d46@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=andrew+netdev@lunn.ch \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gongfan1@huawei.com \
    --cc=guoxin09@huawei.com \
    --cc=gur.stavi@huawei.com \
    --cc=helgaas@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=lee@trager.us \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luosifu@huawei.com \
    --cc=meny.yossefi@huawei.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=shenchenyang1@hisilicon.com \
    --cc=shijing34@huawei.com \
    --cc=sumang@marvell.com \
    --cc=wulike1@huawei.com \
    --cc=zhoushuai28@huawei.com \
    --cc=zhuyikai1@h-partners.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.