]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
be2net: replenish when posting to rx-queue is starved in out of mem conditions
authorSathya Perla <sathyap@serverengines.com>
Fri, 20 Mar 2009 06:56:20 +0000 (23:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 Mar 2009 06:56:20 +0000 (23:56 -0700)
This is a patch to replenish the rx-queue when it is in a starved
state (due to out-of-mem conditions)

Signed-off-by: Sathya Perla <sathyap@serverengines.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/benet/be.h
drivers/net/benet/be_main.c

index 63d593d53153d78fb7038022bbf0c8ece044ba4a..f327be57ca9689d3f2151fdd17ae287d24454181 100644 (file)
@@ -194,6 +194,7 @@ struct be_adapter {
        struct be_eq_obj rx_eq;
        struct be_rx_obj rx_obj;
        u32 big_page_size;      /* Compounded page size shared by rx wrbs */
+       bool rx_post_starved;   /* Zero rx frags have been posted to BE */
 
        struct vlan_group *vlan_grp;
        u16 num_vlans;
index 897a63de5bdb46e08f7155088009617b1b997cd8..80fe1e055d918d99b2c048d803da08d4b54302e0 100644 (file)
@@ -273,26 +273,6 @@ static void be_rx_eqd_update(struct be_adapter *adapter)
        rx_eq->cur_eqd = eqd;
 }
 
-static void be_worker(struct work_struct *work)
-{
-       struct be_adapter *adapter =
-               container_of(work, struct be_adapter, work.work);
-       int status;
-
-       /* Check link */
-       be_link_status_update(adapter);
-
-       /* Get Stats */
-       status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd);
-       if (!status)
-               netdev_stats_update(adapter);
-
-       /* Set EQ delay */
-       be_rx_eqd_update(adapter);
-
-       schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
-}
-
 static struct net_device_stats *be_get_stats(struct net_device *dev)
 {
        struct be_adapter *adapter = netdev_priv(dev);
@@ -900,8 +880,11 @@ static void be_post_rx_frags(struct be_adapter *adapter)
                page_info->last_page_user = true;
 
        if (posted) {
-               be_rxq_notify(&adapter->ctrl, rxq->id, posted);
                atomic_add(posted, &rxq->used);
+               be_rxq_notify(&adapter->ctrl, rxq->id, posted);
+       } else if (atomic_read(&rxq->used) == 0) {
+               /* Let be_worker replenish when memory is available */
+               adapter->rx_post_starved = true;
        }
 
        return;
@@ -1305,6 +1288,31 @@ int be_poll_tx(struct napi_struct *napi, int budget)
        return 1;
 }
 
+static void be_worker(struct work_struct *work)
+{
+       struct be_adapter *adapter =
+               container_of(work, struct be_adapter, work.work);
+       int status;
+
+       /* Check link */
+       be_link_status_update(adapter);
+
+       /* Get Stats */
+       status = be_cmd_get_stats(&adapter->ctrl, &adapter->stats.cmd);
+       if (!status)
+               netdev_stats_update(adapter);
+
+       /* Set EQ delay */
+       be_rx_eqd_update(adapter);
+
+       if (adapter->rx_post_starved) {
+               adapter->rx_post_starved = false;
+               be_post_rx_frags(adapter);
+       }
+
+       schedule_delayed_work(&adapter->work, msecs_to_jiffies(1000));
+}
+
 static void be_msix_enable(struct be_adapter *adapter)
 {
        int i, status;