netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Gur Stavi <gur.stavi@huawei.com>
Cc: Fan Gong <gongfan1@huawei.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>, Lee Trager <lee@trager.us>,
	<linux-doc@vger.kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Cai Huoqing <cai.huoqing@linux.dev>, 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>,
	Suman Ghosh <sumang@marvell.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Joe Damato <jdamato@fastly.com>
Subject: Re: [PATCH net-next v09 1/1] hinic3: module initialization and tx/rx logic
Date: Tue, 25 Mar 2025 03:46:41 -0700	[thread overview]
Message-ID: <20250325034641.65536e13@kernel.org> (raw)
In-Reply-To: <60a3c7b146920eee8b15464e0b0d1ea35db0b30e.1742202778.git.gur.stavi@huawei.com>

On Mon, 17 Mar 2025 11:40:39 +0200 Gur Stavi wrote:
> +static int hinic3_poll(struct napi_struct *napi, int budget)
> +{
> +	struct hinic3_irq_cfg *irq_cfg =
> +		container_of(napi, struct hinic3_irq_cfg, napi);
> +	struct hinic3_nic_dev *nic_dev;
> +	int tx_pkts, rx_pkts;
> +
> +	nic_dev = netdev_priv(irq_cfg->netdev);
> +	rx_pkts = hinic3_rx_poll(irq_cfg->rxq, budget);
> +
> +	tx_pkts = hinic3_tx_poll(irq_cfg->txq, budget);

You should service Tx first, it frees skbs into a cache which Rx 
can then use, while they are hopefully still cache-warm.

> +	if (tx_pkts >= budget || rx_pkts >= budget)
> +		return budget;
> +
> +	napi_complete(napi);

Please use napi_complete_done().

> +	hinic3_set_msix_state(nic_dev->hwdev, irq_cfg->msix_entry_idx,
> +			      HINIC3_MSIX_ENABLE);
> +
> +	return max(tx_pkts, rx_pkts);
> +}

> +static int hinic3_nic_probe(struct auxiliary_device *adev,
> +			    const struct auxiliary_device_id *id)

> +	err = register_netdev(netdev);
> +	if (err)
> +		goto err_register_netdev;
> +
> +	netif_carrier_off(netdev);

You should carrier_off before you register

> +	err = pci_enable_device(pdev);
> +	if (err) {
> +		dev_err(&pdev->dev, "Failed to enable PCI device\n");
> +		goto err_pci_enable;
> +	}
> +
> +	err = pci_request_regions(pdev, HINIC3_NIC_DRV_NAME);
> +	if (err) {
> +		dev_err(&pdev->dev, "Failed to request regions\n");
> +		goto err_pci_regions;
> +	}
> +
> +	pci_set_master(pdev);
> +
> +	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> +	if (err) {
> +		dev_warn(&pdev->dev, "Couldn't set 64-bit DMA mask\n");
> +		/* try 32 bit DMA mask if 64 bit fails */
> +		err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
> +		if (err) {
> +			dev_err(&pdev->dev, "Failed to set DMA mask\n");
> +			goto err_dma_mask;
> +		}
> +	}
> +
> +	return 0;
> +
> +err_dma_mask:
> +	pci_clear_master(pdev);
> +	pci_release_regions(pdev);
> +
> +err_pci_regions:
> +	pci_disable_device(pdev);
> +
> +err_pci_enable:
> +	pci_set_drvdata(pdev, NULL);
> +	mutex_destroy(&pci_adapter->pdev_mutex);
> +	kfree(pci_adapter);

Please name the error labels after the target, not the source.

Quoting documentation:

  Choose label names which say what the goto does or why the goto exists.  An
  example of a good name could be ``out_free_buffer:`` if the goto frees ``buffer``.

See: https://www.kernel.org/doc/html/next/process/coding-style.html#centralized-exiting-of-functions
-- 
pw-bot: cr

      parent reply	other threads:[~2025-03-25 10:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  9:40 [PATCH net-next v09 0/1] net: hinic3: Add a driver for Huawei 3rd gen NIC Gur Stavi
2025-03-17  9:40 ` [PATCH net-next v09 1/1] hinic3: module initialization and tx/rx logic Gur Stavi
2025-03-20 14:55   ` Simon Horman
2025-03-25 10:46   ` Jakub Kicinski [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=20250325034641.65536e13@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=cai.huoqing@linux.dev \
    --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=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=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;
as well as URLs for NNTP newsgroup(s).