Commit b628bde2 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: refactor be_msix_(un)register() code.

Signed-off-by: default avatarSathya Perla <sathyap@serverengines.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a65027e4
...@@ -1303,6 +1303,12 @@ static int be_rx_queues_create(struct be_adapter *adapter) ...@@ -1303,6 +1303,12 @@ static int be_rx_queues_create(struct be_adapter *adapter)
return rc; return rc;
} }
/* There are 8 evt ids per func. Retruns the evt id's bit number */
static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id)
{
return eq_id - 8 * be_pci_func(adapter);
}
static irqreturn_t be_intx(int irq, void *dev) static irqreturn_t be_intx(int irq, void *dev)
{ {
struct be_adapter *adapter = dev; struct be_adapter *adapter = dev;
...@@ -1476,31 +1482,44 @@ static void be_msix_enable(struct be_adapter *adapter) ...@@ -1476,31 +1482,44 @@ static void be_msix_enable(struct be_adapter *adapter)
static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id)
{ {
return adapter->msix_entries[eq_id - 8 * be_pci_func(adapter)].vector; return adapter->msix_entries[
be_evt_bit_get(adapter, eq_id)].vector;
} }
static int be_msix_register(struct be_adapter *adapter) static int be_request_irq(struct be_adapter *adapter,
struct be_eq_obj *eq_obj,
void *handler, char *desc)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
struct be_eq_obj *tx_eq = &adapter->tx_eq; int vec;
struct be_eq_obj *rx_eq = &adapter->rx_eq;
int status, vec; sprintf(eq_obj->desc, "%s-%s", netdev->name, desc);
vec = be_msix_vec_get(adapter, eq_obj->q.id);
return request_irq(vec, handler, 0, eq_obj->desc, adapter);
}
static void be_free_irq(struct be_adapter *adapter, struct be_eq_obj *eq_obj)
{
int vec = be_msix_vec_get(adapter, eq_obj->q.id);
free_irq(vec, adapter);
}
sprintf(tx_eq->desc, "%s-tx", netdev->name); static int be_msix_register(struct be_adapter *adapter)
vec = be_msix_vec_get(adapter, tx_eq->q.id); {
status = request_irq(vec, be_msix_tx_mcc, 0, tx_eq->desc, adapter); int status;
status = be_request_irq(adapter, &adapter->tx_eq, be_msix_tx_mcc, "tx");
if (status) if (status)
goto err; goto err;
sprintf(rx_eq->desc, "%s-rx", netdev->name); status = be_request_irq(adapter, &adapter->rx_eq, be_msix_rx, "rx");
vec = be_msix_vec_get(adapter, rx_eq->q.id); if (status)
status = request_irq(vec, be_msix_rx, 0, rx_eq->desc, adapter); goto free_tx_irq;
if (status) { /* Free TX IRQ */
vec = be_msix_vec_get(adapter, tx_eq->q.id);
free_irq(vec, adapter);
goto err;
}
return 0; return 0;
free_tx_irq:
be_free_irq(adapter, &adapter->tx_eq);
err: err:
dev_warn(&adapter->pdev->dev, dev_warn(&adapter->pdev->dev,
"MSIX Request IRQ failed - err %d\n", status); "MSIX Request IRQ failed - err %d\n", status);
...@@ -1537,7 +1556,6 @@ static int be_irq_register(struct be_adapter *adapter) ...@@ -1537,7 +1556,6 @@ static int be_irq_register(struct be_adapter *adapter)
static void be_irq_unregister(struct be_adapter *adapter) static void be_irq_unregister(struct be_adapter *adapter)
{ {
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
int vec;
if (!adapter->isr_registered) if (!adapter->isr_registered)
return; return;
...@@ -1549,10 +1567,8 @@ static void be_irq_unregister(struct be_adapter *adapter) ...@@ -1549,10 +1567,8 @@ static void be_irq_unregister(struct be_adapter *adapter)
} }
/* MSIx */ /* MSIx */
vec = be_msix_vec_get(adapter, adapter->tx_eq.q.id); be_free_irq(adapter, &adapter->tx_eq);
free_irq(vec, adapter); be_free_irq(adapter, &adapter->rx_eq);
vec = be_msix_vec_get(adapter, adapter->rx_eq.q.id);
free_irq(vec, adapter);
done: done:
adapter->isr_registered = false; adapter->isr_registered = false;
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment