mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Gur Stavi <gur.stavi@huawei.com>, Fan Gong <gongfan1@huawei.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>,
	Lee Trager <lee@trager.us>, Michael Ellerman <mpe@ellerman.id.au>,
	Suman Ghosh <sumang@marvell.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Joe Damato <jdamato@fastly.com>
Subject: Re: [PATCH net-next v11 1/1] hinic3: module initialization and tx/rx logic
Date: Mon, 21 Apr 2025 11:51:50 +0200	[thread overview]
Message-ID: <f7b99e11-c331-4613-8112-4fb5387649e8@wanadoo.fr> (raw)
In-Reply-To: <60ec4dd1d484d9df8cdb8310980676bb2f6c5559.1745221384.git.gur.stavi@huawei.com>

Le 21/04/2025 à 09:47, Gur Stavi a écrit :
> From: Fan Gong <gongfan1@huawei.com>
> 
> This is [1/3] part of hinic3 Ethernet driver initial submission.
> With this patch hinic3 is a valid kernel module but non-functional
> driver.
> 
> The driver parts contained in this patch:
> Module initialization.
> PCI driver registration but with empty id_table.
> Auxiliary driver registration.
> Net device_ops registration but open/stop are empty stubs.
> tx/rx logic.
> 
> All major data structures of the driver are fully introduced with the
> code that uses them but without their initialization code that requires
> management interface with the hw.
> 
> Co-developed-by: Xin Guo <guoxin09@huawei.com>
> Signed-off-by: Xin Guo <guoxin09@huawei.com>
> Signed-off-by: Fan Gong <gongfan1@huawei.com>
> Co-developed-by: Gur Stavi <gur.stavi@huawei.com>
> Signed-off-by: Gur Stavi <gur.stavi@huawei.com>
> ---

Hi,

a few nitpick, should it help and in case of a v12.


> +static const struct auxiliary_device_id hinic3_nic_id_table[] = {
> +	{
> +		.name = HINIC3_NIC_DRV_NAME ".nic",
> +	},
> +	{},

Unneeded trailing , after a terminator.

> +};

...

> +int hinic3_alloc_txqs(struct net_device *netdev)
> +{
> +	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> +	struct hinic3_hwdev *hwdev = nic_dev->hwdev;
> +	u16 q_id, num_txqs = nic_dev->max_qps;
> +	struct pci_dev *pdev = nic_dev->pdev;
> +	struct hinic3_txq *txq;
> +	u64 txq_size;
> +
> +	txq_size = num_txqs * sizeof(*nic_dev->txqs);
> +	if (!txq_size) {

I think that if (!num_txqs) would be enough.

> +		dev_err(hwdev->dev, "Cannot allocate zero size txqs\n");
> +		return -EINVAL;
> +	}
> +
> +	nic_dev->txqs = kzalloc(txq_size, GFP_KERNEL);

and kcalloc() could be used here. (even if it is trivial that it can not 
overflow)

> +	if (!nic_dev->txqs)
> +		return -ENOMEM;
> +
> +	for (q_id = 0; q_id < num_txqs; q_id++) {
> +		txq = &nic_dev->txqs[q_id];
> +		txq->netdev = netdev;
> +		txq->q_id = q_id;
> +		txq->q_depth = nic_dev->q_params.sq_depth;
> +		txq->q_mask = nic_dev->q_params.sq_depth - 1;
> +		txq->dev = &pdev->dev;
> +	}
> +
> +	return 0;
> +}

...

> +netdev_tx_t hinic3_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
> +{
> +	struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
> +	u16 q_id = skb_get_queue_mapping(skb);
> +	struct hinic3_txq *txq;
> +
> +	if (unlikely(!netif_carrier_ok(netdev))) {
> +		dev_kfree_skb_any(skb);
> +		return NETDEV_TX_OK;

Why not goto err_drop_pkt;?

> +	}
> +
> +	if (unlikely(q_id >= nic_dev->q_params.num_qps)) {
> +		txq = &nic_dev->txqs[0];

Why update txd? It won't be used after the goto.

> +		goto err_drop_pkt;
> +	}
> +	txq = &nic_dev->txqs[q_id];
> +
> +	return hinic3_send_one_skb(skb, netdev, txq);
> +
> +err_drop_pkt:
> +	dev_kfree_skb_any(skb);
> +	return NETDEV_TX_OK;
> +}

...

CJ

      reply	other threads:[~2025-04-21 10:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21  7:47 [PATCH net-next v11 0/1] net: hinic3: Add a driver for Huawei 3rd gen NIC Gur Stavi
2025-04-21  7:47 ` [PATCH net-next v11 1/1] hinic3: module initialization and tx/rx logic Gur Stavi
2025-04-21  9:51   ` Christophe JAILLET [this message]

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=f7b99e11-c331-4613-8112-4fb5387649e8@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=andrew+netdev@lunn.ch \
    --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=jdamato@fastly.com \
    --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 \
    /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

all inboxes | Powered by JetHome®