IB/rxe: Introduce functions for queue draining
authorBart Van Assche <bart.vanassche@sandisk.com>
Tue, 10 Jan 2017 19:15:49 +0000 (11:15 -0800)
committerDoug Ledford <dledford@redhat.com>
Tue, 10 Jan 2017 21:52:47 +0000 (16:52 -0500)
This change makes the code easier to read and avoids that code is
duplicated.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Andrew Boyer <andrew.boyer@dell.com>
Cc: Moni Shoua <monis@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/sw/rxe/rxe_comp.c
drivers/infiniband/sw/rxe/rxe_resp.c

index e912e5396e8c1d12f25476ddbe360c8ecbfdd6a5..6769a075501ecdfc82b9722e3de2954758779c80 100644 (file)
@@ -503,57 +503,40 @@ static inline enum comp_state complete_wqe(struct rxe_qp *qp,
        return COMPST_GET_WQE;
 }
 
-int rxe_completer(void *arg)
+static void rxe_drain_resp_pkts(struct rxe_qp *qp, bool notify)
 {
-       struct rxe_qp *qp = (struct rxe_qp *)arg;
-       struct rxe_send_wqe *wqe = wqe;
-       struct sk_buff *skb = NULL;
-       struct rxe_pkt_info *pkt = NULL;
-       enum comp_state state;
-
-       rxe_add_ref(qp);
-
-       if (!qp->valid) {
-               while ((skb = skb_dequeue(&qp->resp_pkts))) {
-                       rxe_drop_ref(qp);
-                       kfree_skb(skb);
-               }
-               skb = NULL;
-               pkt = NULL;
-
-               while (queue_head(qp->sq.queue))
-                       advance_consumer(qp->sq.queue);
+       struct sk_buff *skb;
+       struct rxe_send_wqe *wqe;
 
-               goto exit;
+       while ((skb = skb_dequeue(&qp->resp_pkts))) {
+               rxe_drop_ref(qp);
+               kfree_skb(skb);
        }
 
-       if (qp->req.state == QP_STATE_ERROR) {
-               while ((skb = skb_dequeue(&qp->resp_pkts))) {
-                       rxe_drop_ref(qp);
-                       kfree_skb(skb);
-               }
-               skb = NULL;
-               pkt = NULL;
-
-               while ((wqe = queue_head(qp->sq.queue))) {
+       while ((wqe = queue_head(qp->sq.queue))) {
+               if (notify) {
                        wqe->status = IB_WC_WR_FLUSH_ERR;
                        do_complete(qp, wqe);
+               } else {
+                       advance_consumer(qp->sq.queue);
                }
-
-               goto exit;
        }
+}
 
-       if (qp->req.state == QP_STATE_RESET) {
-               while ((skb = skb_dequeue(&qp->resp_pkts))) {
-                       rxe_drop_ref(qp);
-                       kfree_skb(skb);
-               }
-               skb = NULL;
-               pkt = NULL;
+int rxe_completer(void *arg)
+{
+       struct rxe_qp *qp = (struct rxe_qp *)arg;
+       struct rxe_send_wqe *wqe = wqe;
+       struct sk_buff *skb = NULL;
+       struct rxe_pkt_info *pkt = NULL;
+       enum comp_state state;
 
-               while (queue_head(qp->sq.queue))
-                       advance_consumer(qp->sq.queue);
+       rxe_add_ref(qp);
 
+       if (!qp->valid || qp->req.state == QP_STATE_ERROR ||
+           qp->req.state == QP_STATE_RESET) {
+               rxe_drain_resp_pkts(qp, qp->valid &&
+                                   qp->req.state == QP_STATE_ERROR);
                goto exit;
        }
 
index 6dbd069689fcfa7dc7f81214d8669a6c7d4f93e4..51c134dbc6c83b7eb62d8027c7b10e8b812a6d13 100644 (file)
@@ -1207,6 +1207,19 @@ static enum resp_states do_class_d1e_error(struct rxe_qp *qp)
        }
 }
 
+static void rxe_drain_req_pkts(struct rxe_qp *qp)
+{
+       struct sk_buff *skb;
+
+       while ((skb = skb_dequeue(&qp->req_pkts))) {
+               rxe_drop_ref(qp);
+               kfree_skb(skb);
+       }
+
+       while (!qp->srq && qp->rq.queue && queue_head(qp->rq.queue))
+               advance_consumer(qp->rq.queue);
+}
+
 int rxe_responder(void *arg)
 {
        struct rxe_qp *qp = (struct rxe_qp *)arg;
@@ -1374,21 +1387,10 @@ int rxe_responder(void *arg)
 
                        goto exit;
 
-               case RESPST_RESET: {
-                       struct sk_buff *skb;
-
-                       while ((skb = skb_dequeue(&qp->req_pkts))) {
-                               rxe_drop_ref(qp);
-                               kfree_skb(skb);
-                       }
-
-                       while (!qp->srq && qp->rq.queue &&
-                              queue_head(qp->rq.queue))
-                               advance_consumer(qp->rq.queue);
-
+               case RESPST_RESET:
+                       rxe_drain_req_pkts(qp);
                        qp->resp.wqe = NULL;
                        goto exit;
-               }
 
                case RESPST_ERROR:
                        qp->resp.goto_error = 0;