mirror of
https://github.com/corundum/corundum.git
synced 2025-01-16 08:12:53 +08:00
Add IRQ mapping
This commit is contained in:
parent
171eb144cb
commit
b6e5216ab4
@ -80,7 +80,8 @@ struct mqnic_dev {
|
|||||||
|
|
||||||
char name[16];
|
char name[16];
|
||||||
|
|
||||||
int msi_nvecs;
|
int irq_count;
|
||||||
|
int irq_map[32];
|
||||||
|
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
struct list_head dev_list_node;
|
struct list_head dev_list_node;
|
||||||
|
@ -89,7 +89,7 @@ static irqreturn_t mqnic_interrupt(int irq, void *data)
|
|||||||
|
|
||||||
for (k = 0; k < MQNIC_MAX_IF; k++)
|
for (k = 0; k < MQNIC_MAX_IF; k++)
|
||||||
{
|
{
|
||||||
if (!mqnic->ndev[k])
|
if (unlikely(!mqnic->ndev[k]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
priv = netdev_priv(mqnic->ndev[k]);
|
priv = netdev_priv(mqnic->ndev[k]);
|
||||||
@ -229,8 +229,8 @@ static int mqnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate MSI IRQs
|
// Allocate MSI IRQs
|
||||||
mqnic->msi_nvecs = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI);
|
mqnic->irq_count = pci_alloc_irq_vectors(pdev, 1, 32, PCI_IRQ_MSI);
|
||||||
if (mqnic->msi_nvecs < 0)
|
if (mqnic->irq_count < 0)
|
||||||
{
|
{
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
dev_err(dev, "Failed to allocate IRQs");
|
dev_err(dev, "Failed to allocate IRQs");
|
||||||
@ -238,7 +238,7 @@ static int mqnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up interrupts
|
// Set up interrupts
|
||||||
for (k = 0; k < mqnic->msi_nvecs; k++)
|
for (k = 0; k < mqnic->irq_count; k++)
|
||||||
{
|
{
|
||||||
ret = pci_request_irq(pdev, k, mqnic_interrupt, 0, mqnic, "mqnic%d-%d", mqnic->id, k);
|
ret = pci_request_irq(pdev, k, mqnic_interrupt, 0, mqnic, "mqnic%d-%d", mqnic->id, k);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -246,6 +246,8 @@ static int mqnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||||||
dev_err(dev, "Failed to request IRQ");
|
dev_err(dev, "Failed to request IRQ");
|
||||||
goto fail_irq;
|
goto fail_irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mqnic->irq_map[k] = pci_irq_vector(pdev, k);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up I2C interfaces
|
// Set up I2C interfaces
|
||||||
@ -327,7 +329,7 @@ fail_init_netdev:
|
|||||||
pci_clear_master(pdev);
|
pci_clear_master(pdev);
|
||||||
fail_i2c:
|
fail_i2c:
|
||||||
mqnic_remove_i2c(mqnic);
|
mqnic_remove_i2c(mqnic);
|
||||||
for (k = 0; k < mqnic->msi_nvecs; k++)
|
for (k = 0; k < mqnic->irq_count; k++)
|
||||||
{
|
{
|
||||||
pci_free_irq(pdev, k, mqnic);
|
pci_free_irq(pdev, k, mqnic);
|
||||||
}
|
}
|
||||||
@ -371,7 +373,7 @@ static void mqnic_remove(struct pci_dev *pdev)
|
|||||||
|
|
||||||
pci_clear_master(pdev);
|
pci_clear_master(pdev);
|
||||||
mqnic_remove_i2c(mqnic);
|
mqnic_remove_i2c(mqnic);
|
||||||
for (k = 0; k < mqnic->msi_nvecs; k++)
|
for (k = 0; k < mqnic->irq_count; k++)
|
||||||
{
|
{
|
||||||
pci_free_irq(pdev, k, mqnic);
|
pci_free_irq(pdev, k, mqnic);
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@ static int mqnic_start_port(struct net_device *ndev)
|
|||||||
// set up event queues
|
// set up event queues
|
||||||
for (k = 0; k < priv->event_queue_count; k++)
|
for (k = 0; k < priv->event_queue_count; k++)
|
||||||
{
|
{
|
||||||
priv->event_ring[k]->irq = pci_irq_vector(mdev->pdev, k % mdev->msi_nvecs);
|
priv->event_ring[k]->irq = mdev->irq_map[k % mdev->irq_count];
|
||||||
mqnic_activate_eq_ring(priv, priv->event_ring[k], k % mdev->msi_nvecs);
|
mqnic_activate_eq_ring(priv, priv->event_ring[k], k % mdev->irq_count);
|
||||||
mqnic_arm_eq(priv->event_ring[k]);
|
mqnic_arm_eq(priv->event_ring[k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user