From: Simon Horman <horms@kernel.org>
To: Xin Tian <tianx@yunsilicon.com>
Cc: netdev@vger.kernel.org, leon@kernel.org, andrew+netdev@lunn.ch,
kuba@kernel.org, pabeni@redhat.com, edumazet@google.com,
davem@davemloft.net, jeff.johnson@oss.qualcomm.com,
przemyslaw.kitszel@intel.com, weihg@yunsilicon.com,
wanry@yunsilicon.com
Subject: Re: [PATCH v3 02/14] net-next/yunsilicon: Enable CMDQ
Date: Thu, 16 Jan 2025 13:55:59 +0000 [thread overview]
Message-ID: <20250116135559.GB6206@kernel.org> (raw)
In-Reply-To: <20250115102245.3541496-3-tianx@yunsilicon.com>
On Wed, Jan 15, 2025 at 06:22:46PM +0800, Xin Tian wrote:
> Enable cmd queue to support driver-firmware communication.
> Hardware control will be performed through cmdq mostly.
>
> Co-developed-by: Honggang Wei <weihg@yunsilicon.com>
> Signed-off-by: Honggang Wei <weihg@yunsilicon.com>
> Co-developed-by: Lei Yan <jacky@yunsilicon.com>
> Signed-off-by: Lei Yan <jacky@yunsilicon.com>
> Signed-off-by: Xin Tian <tianx@yunsilicon.com>
...
> diff --git a/drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c b/drivers/net/ethernet/yunsilicon/xsc/pci/cmdq.c
...
> +static void cmd_work_handler(struct work_struct *work)
> +{
> + struct xsc_cmd_work_ent *ent = container_of(work, struct xsc_cmd_work_ent, work);
> + struct xsc_cmd *cmd = ent->cmd;
> + struct xsc_core_device *xdev = container_of(cmd, struct xsc_core_device, cmd);
> + struct xsc_cmd_layout *lay;
> + struct semaphore *sem;
> + unsigned long flags;
Hi Xin Tian,
Please consider arranging local variables in reverse xmas tree order -
longest line to shortest - as is preferred in Networking code.
Separating initialisation from declarations as needed.
And also, please consider limiting lines to 80 columns wide or less,
where it can be achieved without reducing readability. This is also
preferred in Networking code.
I think that in this case that both could be achieved like this
(completely untested):
struct xsc_cmd_work_ent *ent;
struct xsc_core_device *xdev;
struct xsc_cmd_layout *lay;
struct semaphore *sem;
struct xsc_cmd *cmd;
unsigned long flags;
ent = container_of(work, struct xsc_cmd_work_ent, work);
cmd = ent->cmd;
xdev = container_of(cmd, struct xsc_core_device, cmd);
With regards to reverse xmas tree ordering, this tool can be useful:
https://github.com/ecree-solarflare/xmastree
...
> +static void xsc_cmd_comp_handler(struct xsc_core_device *xdev, u8 idx, struct xsc_rsp_layout *rsp)
> +{
> + struct xsc_cmd *cmd = &xdev->cmd;
> + struct xsc_cmd_work_ent *ent;
> + struct xsc_inbox_hdr *hdr;
> +
> + if (idx > cmd->max_reg_cmds || (cmd->bitmask & (1 << idx))) {
> + pci_err(xdev->pdev, "idx[%d] exceed max cmds, or has no relative request.\n", idx);
> + return;
> + }
> + ent = cmd->ent_arr[idx];
> + ent->rsp_lay = rsp;
> + ktime_get_ts64(&ent->ts2);
> +
> + memcpy(ent->out->first.data, ent->rsp_lay->out, sizeof(ent->rsp_lay->out));
> + if (!cmd->checksum_disabled)
> + ent->ret = verify_signature(ent);
> + else
> + ent->ret = 0;
> + ent->status = 0;
> +
> + hdr = (struct xsc_inbox_hdr *)ent->in->first.data;
nit: hdr is set but otherwise unused in this function.
Perhaps it can be removed (and added in a later patch if needed there)?
Flagged by W=1 builds.
> + free_ent(cmd, ent->idx);
> + complete(&ent->done);
> + up(&cmd->sem);
> +}
...
next prev parent reply other threads:[~2025-01-16 13:56 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 10:23 [PATCH v3 00/14] net-next/yunsilicon: ADD Yunsilicon XSC Ethernet Driver Xin Tian
2025-01-15 10:22 ` [PATCH v3 01/14] net-next/yunsilicon: Add xsc driver basic framework Xin Tian
2025-01-15 15:54 ` Simon Horman
2025-01-16 7:03 ` tianx
2025-01-15 16:04 ` Simon Horman
2025-01-16 8:04 ` tianx
2025-01-16 10:53 ` Simon Horman
2025-01-15 10:22 ` [PATCH v3 02/14] net-next/yunsilicon: Enable CMDQ Xin Tian
2025-01-16 10:30 ` Przemek Kitszel
2025-02-13 2:09 ` tianx
2025-01-16 13:55 ` Simon Horman [this message]
2025-01-17 3:42 ` tianx
2025-01-17 13:33 ` Simon Horman
2025-01-15 10:22 ` [PATCH v3 03/14] net-next/yunsilicon: Add hardware setup APIs Xin Tian
2025-01-15 10:22 ` [PATCH v3 04/14] net-next/yunsilicon: Add qp and cq management Xin Tian
2025-01-17 13:45 ` Simon Horman
2025-01-15 10:22 ` [PATCH v3 05/14] net-next/yunsilicon: Add eq and alloc Xin Tian
2025-01-15 10:22 ` [PATCH v3 06/14] net-next/yunsilicon: Add pci irq Xin Tian
2025-01-15 10:22 ` [PATCH v3 07/14] net-next/yunsilicon: Init auxiliary device Xin Tian
2025-01-15 10:23 ` [PATCH v3 08/14] net-next/yunsilicon: Add ethernet interface Xin Tian
2025-01-15 10:23 ` [PATCH v3 09/14] net-next/yunsilicon: Init net device Xin Tian
2025-01-15 10:23 ` [PATCH v3 10/14] net-next/yunsilicon: Add eth needed qp and cq apis Xin Tian
2025-01-15 10:23 ` [PATCH v3 11/14] net-next/yunsilicon: ndo_open and ndo_stop Xin Tian
2025-01-15 10:23 ` [PATCH v3 12/14] net-next/yunsilicon: Add ndo_start_xmit Xin Tian
2025-01-15 10:23 ` [PATCH v3 13/14] net-next/yunsilicon: Add eth rx Xin Tian
2025-01-15 10:23 ` [PATCH v3 14/14] net-next/yunsilicon: add ndo_get_stats64 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=20250116135559.GB6206@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jeff.johnson@oss.qualcomm.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 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).