Re: [RFC PATCH net-next 04/10] net: hibmcge: Add interrupt supported in this module

From: Jijie Shao
Date: Mon Aug 05 2024 - 09:30:09 EST



on 2024/8/5 20:57, Simon Horman wrote:
On Wed, Jul 31, 2024 at 05:42:39PM +0800, Jijie Shao wrote:
The driver supports four interrupts: TX interrupt, RX interrupt,
mdio interrupt, and error interrupt.

Actually, the driver does not use the mdio interrupt.
Therefore, the driver does not request the mdio interrupt.

The error interrupt distinguishes different error information
by using different masks. To distinguish different errors,
the statistics count is added for each error.

To ensure the consistency of the code process, masks are added for the
TX interrupt and RX interrupt.

This patch implements interrupt request and free, and provides a
unified entry for the interrupt handler function. However,
the specific interrupt handler function of each interrupt
is not implemented currently.

Signed-off-by: Jijie Shao <shaojijie@xxxxxxxxxx>
...

diff --git a/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c b/drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c
...

+int hbg_irq_init(struct hbg_priv *priv)
+{
+ struct hbg_vector *vectors = &priv->vectors;
+ struct hbg_irq *irq;
+ int ret;
+ int i;
+
+ ret = pci_alloc_irq_vectors(priv->pdev, HBG_VECTOR_NUM, HBG_VECTOR_NUM,
+ PCI_IRQ_MSI);
+ if (ret < 0) {
+ dev_err(&priv->pdev->dev,
+ "failed to allocate MSI vectors, vectors = %d\n", ret);
+ return ret;
+ }
+
+ if (ret != HBG_VECTOR_NUM) {
+ dev_err(&priv->pdev->dev,
+ "requested %u MSI, but allocated %d MSI\n",
+ HBG_VECTOR_NUM, ret);
+ ret = -EINVAL;
+ goto free_vectors;
+ }
+
+ vectors->irqs = devm_kcalloc(&priv->pdev->dev, HBG_VECTOR_NUM,
+ sizeof(struct hbg_irq), GFP_KERNEL);
+ if (!vectors->irqs) {
+ ret = -ENOMEM;
+ goto free_vectors;
+ }
+
+ /* mdio irq not request */
+ vectors->irq_count = HBG_VECTOR_NUM - 1;
+ for (i = 0; i < vectors->irq_count; i++) {
+ irq = &vectors->irqs[i];
+ snprintf(irq->name, sizeof(irq->name) - 1, "%s-%s-%s",
+ HBG_DEV_NAME, pci_name(priv->pdev), irq_names_map[i]);
+
+ irq->id = pci_irq_vector(priv->pdev, i);
+ irq_set_status_flags(irq->id, IRQ_NOAUTOEN);
I think that you <linux/irq.h> needs to be included.
Else allmodconfig builds - on x86_64 but curiously not ARM64 - fail.

Thank you, this is very confusing. I built successfully on both ARM and x86.
I will rebuild it according to your Clang version to fix this error

Jijie Shao


CC drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.o
drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c: In function 'hbg_irq_init':
drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c:150:17: error: implicit declaration of function 'irq_set_status_flags' [-Wimplicit-function-declaration]
150 | irq_set_status_flags(irq->id, IRQ_NOAUTOEN);
| ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/hisilicon/hibmcge/hbg_irq.c:150:47: error: 'IRQ_NOAUTOEN' undeclared (first use in this function); did you mean 'IRQF_NO_AUTOEN'?
150 | irq_set_status_flags(irq->id, IRQ_NOAUTOEN);
| ^~~~~~~~~~~~
| IRQF_NO_AUTOEN

...