If the poll loop executes more than once (and it happens on my system with two
flood pings):
        - no need to calculate "budget - done" on every iteration (but
                will require to do this once, when returning from fn)
        - check for one variable being non-zero instead of comparing two
                vars for every iteration.

Signed-off-by: Krishna Kumar <[EMAIL PROTECTED]>
---
 ipoib_ib.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff -ruNp a/drivers/infiniband/ulp/ipoib/ipoib_ib.c 
b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c   2007-09-21 13:20:42.000000000 
+0530
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c   2007-09-21 13:37:20.000000000 
+0530
@@ -286,30 +286,30 @@ int ipoib_poll(struct napi_struct *napi,
        struct ipoib_dev_priv *priv = container_of(napi, struct ipoib_dev_priv, 
napi);
        struct net_device *dev = priv->dev;
        int num_wc, max_wc;
-       int done = 0;
+       int remaining = budget;
 
 poll_more:
        do {
                int i;
 
-               max_wc = min(IPOIB_NUM_WC, budget - done);
+               max_wc = min(IPOIB_NUM_WC, remaining);
                num_wc = ib_poll_cq(priv->cq, max_wc, priv->ibwc);
 
-               for (i = 0; i < n; i++) {
+               for (i = 0; i < num_wc; i++) {
                        struct ib_wc *wc = priv->ibwc + i;
 
                        if (wc->wr_id & IPOIB_CM_OP_SRQ) {
-                               ++done;
+                               --remaining;
                                ipoib_cm_handle_rx_wc(dev, wc);
                        } else if (wc->wr_id & IPOIB_OP_RECV) {
-                               ++done;
+                               --remaining;
                                ipoib_ib_handle_rx_wc(dev, wc);
                        } else
                                ipoib_ib_handle_tx_wc(dev, wc);
                }
-       } while (num_wc == max_wc && done < budget);
+       } while (num_wc == max_wc && remaining);
 
-       if (done < budget) {
+       if (remaining) {
                netif_rx_complete(dev, napi);
                if (unlikely(ib_req_notify_cq(priv->cq,
                                              IB_CQ_NEXT_COMP |
@@ -318,7 +318,8 @@ poll_more:
                        goto poll_more;
        }
 
-       return done;
+       /* return number of receives processed */
+       return budget - remaining;
 }
 
 void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to