aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/benet/be_main.c
diff options
context:
space:
mode:
authorSathya Perla <sathyap@serverengines.com>2009-06-17 20:10:27 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-19 03:18:42 -0400
commita8f447bda3ee00e3a3ab080c48db40078ea65221 (patch)
tree7b164e3dd0dee5da5229462c668c98a6297517a3 /drivers/net/benet/be_main.c
parent24307eef74bd38e3fc6a6df8f8a1bfc48967f9f6 (diff)
be2net: receive asynchronous link status notifications from BE
Rcv and process ansync link status notifications from BE instead of polling for link status in the be_worker thread. 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.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/net/benet/be_main.c b/drivers/net/benet/be_main.c
index 3dc68034c21d..66c10c87f517 100644
--- a/drivers/net/benet/be_main.c
+++ b/drivers/net/benet/be_main.c
@@ -214,28 +214,24 @@ static void netdev_stats_update(struct be_adapter *adapter)
214 dev_stats->tx_window_errors = 0; 214 dev_stats->tx_window_errors = 0;
215} 215}
216 216
217static void be_link_status_update(struct be_adapter *adapter) 217void be_link_status_update(void *ctxt, bool link_up)
218{ 218{
219 struct be_link_info *prev = &adapter->link; 219 struct be_adapter *adapter = ctxt;
220 struct be_link_info now = { 0 };
221 struct net_device *netdev = adapter->netdev; 220 struct net_device *netdev = adapter->netdev;
222 221
223 be_cmd_link_status_query(&adapter->ctrl, &now);
224
225 /* If link came up or went down */ 222 /* If link came up or went down */
226 if (now.speed != prev->speed && (now.speed == PHY_LINK_SPEED_ZERO || 223 if (adapter->link_up != link_up) {
227 prev->speed == PHY_LINK_SPEED_ZERO)) { 224 if (link_up) {
228 if (now.speed == PHY_LINK_SPEED_ZERO) {
229 netif_stop_queue(netdev);
230 netif_carrier_off(netdev);
231 printk(KERN_INFO "%s: Link down\n", netdev->name);
232 } else {
233 netif_start_queue(netdev); 225 netif_start_queue(netdev);
234 netif_carrier_on(netdev); 226 netif_carrier_on(netdev);
235 printk(KERN_INFO "%s: Link up\n", netdev->name); 227 printk(KERN_INFO "%s: Link up\n", netdev->name);
228 } else {
229 netif_stop_queue(netdev);
230 netif_carrier_off(netdev);
231 printk(KERN_INFO "%s: Link down\n", netdev->name);
236 } 232 }
233 adapter->link_up = link_up;
237 } 234 }
238 *prev = now;
239} 235}
240 236
241/* Update the EQ delay n BE based on the RX frags consumed / sec */ 237/* Update the EQ delay n BE based on the RX frags consumed / sec */
@@ -1395,9 +1391,6 @@ static void be_worker(struct work_struct *work)
1395 container_of(work, struct be_adapter, work.work); 1391 container_of(work, struct be_adapter, work.work);
1396 int status; 1392 int status;
1397 1393
1398 /* Check link */
1399 be_link_status_update(adapter);
1400
1401 /* Get Stats */ 1394 /* Get Stats */
1402 status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd); 1395 status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd);
1403 if (!status) 1396 if (!status)
@@ -1522,6 +1515,8 @@ static int be_open(struct net_device *netdev)
1522 struct be_ctrl_info *ctrl = &adapter->ctrl; 1515 struct be_ctrl_info *ctrl = &adapter->ctrl;
1523 struct be_eq_obj *rx_eq = &adapter->rx_eq; 1516 struct be_eq_obj *rx_eq = &adapter->rx_eq;
1524 struct be_eq_obj *tx_eq = &adapter->tx_eq; 1517 struct be_eq_obj *tx_eq = &adapter->tx_eq;
1518 bool link_up;
1519 int status;
1525 1520
1526 /* First time posting */ 1521 /* First time posting */
1527 be_post_rx_frags(adapter); 1522 be_post_rx_frags(adapter);
@@ -1540,7 +1535,10 @@ static int be_open(struct net_device *netdev)
1540 /* Rx compl queue may be in unarmed state; rearm it */ 1535 /* Rx compl queue may be in unarmed state; rearm it */
1541 be_cq_notify(ctrl, adapter->rx_obj.cq.id, true, 0); 1536 be_cq_notify(ctrl, adapter->rx_obj.cq.id, true, 0);
1542 1537
1543 be_link_status_update(adapter); 1538 status = be_cmd_link_status_query(ctrl, &link_up);
1539 if (status)
1540 return status;
1541 be_link_status_update(adapter, link_up);
1544 1542
1545 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100)); 1543 schedule_delayed_work(&adapter->work, msecs_to_jiffies(100));
1546 return 0; 1544 return 0;
@@ -1617,7 +1615,7 @@ static int be_close(struct net_device *netdev)
1617 1615
1618 netif_stop_queue(netdev); 1616 netif_stop_queue(netdev);
1619 netif_carrier_off(netdev); 1617 netif_carrier_off(netdev);
1620 adapter->link.speed = PHY_LINK_SPEED_ZERO; 1618 adapter->link_up = false;
1621 1619
1622 be_intr_set(ctrl, false); 1620 be_intr_set(ctrl, false);
1623 1621
@@ -1808,6 +1806,9 @@ static int be_ctrl_init(struct be_adapter *adapter)
1808 spin_lock_init(&ctrl->mcc_lock); 1806 spin_lock_init(&ctrl->mcc_lock);
1809 spin_lock_init(&ctrl->mcc_cq_lock); 1807 spin_lock_init(&ctrl->mcc_cq_lock);
1810 1808
1809 ctrl->async_cb = be_link_status_update;
1810 ctrl->adapter_ctxt = adapter;
1811
1811 val = ioread32(ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET); 1812 val = ioread32(ctrl->pcicfg + PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET);
1812 ctrl->pci_func = (val >> MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT) & 1813 ctrl->pci_func = (val >> MEMBAR_CTRL_INT_CTRL_PFUNC_SHIFT) &
1813 MEMBAR_CTRL_INT_CTRL_PFUNC_MASK; 1814 MEMBAR_CTRL_INT_CTRL_PFUNC_MASK;