diff options
author | Sathya Perla <sathyap@serverengines.com> | 2009-08-16 20:58:26 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-17 20:48:28 -0400 |
commit | b628bde2b5390776efc30837798d016ec1aa3ebe (patch) | |
tree | 07c0c773535e8aedd29d58e7f435f245b4953414 /drivers/net/benet/be_main.c | |
parent | a65027e4d80ece5a5a3bd4fc4808a83208430929 (diff) |
be2net: refactor be_msix_(un)register() code.
Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/benet/be_main.c')
-rw-r--r-- | drivers/net/benet/be_main.c | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c index 362346045ed3..010175f4b8f1 100644 --- a/drivers/net/benet/be_main.c +++ b/drivers/net/benet/be_main.c | |||
@@ -1303,6 +1303,12 @@ rx_eq_free: | |||
1303 | return rc; | 1303 | return rc; |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | /* There are 8 evt ids per func. Retruns the evt id's bit number */ | ||
1307 | static inline int be_evt_bit_get(struct be_adapter *adapter, u32 eq_id) | ||
1308 | { | ||
1309 | return eq_id - 8 * be_pci_func(adapter); | ||
1310 | } | ||
1311 | |||
1306 | static irqreturn_t be_intx(int irq, void *dev) | 1312 | static irqreturn_t be_intx(int irq, void *dev) |
1307 | { | 1313 | { |
1308 | struct be_adapter *adapter = dev; | 1314 | struct be_adapter *adapter = dev; |
@@ -1476,31 +1482,44 @@ static void be_msix_enable(struct be_adapter *adapter) | |||
1476 | 1482 | ||
1477 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) | 1483 | static inline int be_msix_vec_get(struct be_adapter *adapter, u32 eq_id) |
1478 | { | 1484 | { |
1479 | return adapter->msix_entries[eq_id - 8 * be_pci_func(adapter)].vector; | 1485 | return adapter->msix_entries[ |
1486 | be_evt_bit_get(adapter, eq_id)].vector; | ||
1480 | } | 1487 | } |
1481 | 1488 | ||
1482 | static int be_msix_register(struct be_adapter *adapter) | 1489 | static int be_request_irq(struct be_adapter *adapter, |
1490 | struct be_eq_obj *eq_obj, | ||
1491 | void *handler, char *desc) | ||
1483 | { | 1492 | { |
1484 | struct net_device *netdev = adapter->netdev; | 1493 | struct net_device *netdev = adapter->netdev; |
1485 | struct be_eq_obj *tx_eq = &adapter->tx_eq; | 1494 | int vec; |
1486 | struct be_eq_obj *rx_eq = &adapter->rx_eq; | 1495 | |
1487 | int status, vec; | 1496 | sprintf(eq_obj->desc, "%s-%s", netdev->name, desc); |
1497 | vec = be_msix_vec_get(adapter, eq_obj->q.id); | ||
1498 | return request_irq(vec, handler, 0, eq_obj->desc, adapter); | ||
1499 | } | ||
1500 | |||
1501 | static void be_free_irq(struct be_adapter *adapter, struct be_eq_obj *eq_obj) | ||
1502 | { | ||
1503 | int vec = be_msix_vec_get(adapter, eq_obj->q.id); | ||
1504 | free_irq(vec, adapter); | ||
1505 | } | ||
1488 | 1506 | ||
1489 | sprintf(tx_eq->desc, "%s-tx", netdev->name); | 1507 | static int be_msix_register(struct be_adapter *adapter) |
1490 | vec = be_msix_vec_get(adapter, tx_eq->q.id); | 1508 | { |
1491 | status = request_irq(vec, be_msix_tx_mcc, 0, tx_eq->desc, adapter); | 1509 | int status; |
1510 | |||
1511 | status = be_request_irq(adapter, &adapter->tx_eq, be_msix_tx_mcc, "tx"); | ||
1492 | if (status) | 1512 | if (status) |
1493 | goto err; | 1513 | goto err; |
1494 | 1514 | ||
1495 | sprintf(rx_eq->desc, "%s-rx", netdev->name); | 1515 | status = be_request_irq(adapter, &adapter->rx_eq, be_msix_rx, "rx"); |
1496 | vec = be_msix_vec_get(adapter, rx_eq->q.id); | 1516 | if (status) |
1497 | status = request_irq(vec, be_msix_rx, 0, rx_eq->desc, adapter); | 1517 | goto free_tx_irq; |
1498 | if (status) { /* Free TX IRQ */ | 1518 | |
1499 | vec = be_msix_vec_get(adapter, tx_eq->q.id); | ||
1500 | free_irq(vec, adapter); | ||
1501 | goto err; | ||
1502 | } | ||
1503 | return 0; | 1519 | return 0; |
1520 | |||
1521 | free_tx_irq: | ||
1522 | be_free_irq(adapter, &adapter->tx_eq); | ||
1504 | err: | 1523 | err: |
1505 | dev_warn(&adapter->pdev->dev, | 1524 | dev_warn(&adapter->pdev->dev, |
1506 | "MSIX Request IRQ failed - err %d\n", status); | 1525 | "MSIX Request IRQ failed - err %d\n", status); |
@@ -1537,7 +1556,6 @@ done: | |||
1537 | static void be_irq_unregister(struct be_adapter *adapter) | 1556 | static void be_irq_unregister(struct be_adapter *adapter) |
1538 | { | 1557 | { |
1539 | struct net_device *netdev = adapter->netdev; | 1558 | struct net_device *netdev = adapter->netdev; |
1540 | int vec; | ||
1541 | 1559 | ||
1542 | if (!adapter->isr_registered) | 1560 | if (!adapter->isr_registered) |
1543 | return; | 1561 | return; |
@@ -1549,10 +1567,8 @@ static void be_irq_unregister(struct be_adapter *adapter) | |||
1549 | } | 1567 | } |
1550 | 1568 | ||
1551 | /* MSIx */ | 1569 | /* MSIx */ |
1552 | vec = be_msix_vec_get(adapter, adapter->tx_eq.q.id); | 1570 | be_free_irq(adapter, &adapter->tx_eq); |
1553 | free_irq(vec, adapter); | 1571 | be_free_irq(adapter, &adapter->rx_eq); |
1554 | vec = be_msix_vec_get(adapter, adapter->rx_eq.q.id); | ||
1555 | free_irq(vec, adapter); | ||
1556 | done: | 1572 | done: |
1557 | adapter->isr_registered = false; | 1573 | adapter->isr_registered = false; |
1558 | return; | 1574 | return; |