]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
IB/hfi1: Add fast and slow handlers for receive context
authorMike Marciniszyn <mike.marciniszyn@intel.com>
Mon, 6 Jan 2020 13:41:51 +0000 (08:41 -0500)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 10 Jan 2020 14:57:16 +0000 (10:57 -0400)
This patch eliminate special cases by adding a fast_handler member to the
receive context and changes to the fast handler as specified in the new
variable. Initialize the variable as soon as the setting for dma tail is
known when the context is created.

Setting fast path is called every time when any context has entered slow
path. Add function to check if contexts is using fast path and do not set
fast path when it is already done to improve RCD fastpath setting.

Link: https://lore.kernel.org/r/20200106134150.119356.87558.stgit@awfm-01.aw.intel.com
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Grzegorz Andrejczuk <grzegorz.andrejczuk@intel.com>
Signed-off-by: Sadanand Warrier <sadanand.warrier@intel.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hfi1/driver.c
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/init.c
drivers/infiniband/hw/hfi1/trace_rx.h

index 8374922ea6e59a1ff3348860f20416e2e5af1627..3671191b5aed04f44834913a6c5bf974d2e31b5f 100644 (file)
@@ -883,9 +883,8 @@ int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *rcd, int thread)
        return last;
 }
 
-static inline void set_nodma_rtail(struct hfi1_devdata *dd, u16 ctxt)
+static void set_all_fastpath(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)
 {
-       struct hfi1_ctxtdata *rcd;
        u16 i;
 
        /*
@@ -893,50 +892,17 @@ static inline void set_nodma_rtail(struct hfi1_devdata *dd, u16 ctxt)
         * interrupt handler only for that context. Otherwise, switch
         * interrupt handler for all statically allocated kernel contexts.
         */
-       if (ctxt >= dd->first_dyn_alloc_ctxt) {
-               rcd = hfi1_rcd_get_by_index_safe(dd, ctxt);
-               if (rcd) {
-                       rcd->do_interrupt =
-                               &handle_receive_interrupt_nodma_rtail;
-                       hfi1_rcd_put(rcd);
-               }
-               return;
-       }
-
-       for (i = HFI1_CTRL_CTXT + 1; i < dd->first_dyn_alloc_ctxt; i++) {
-               rcd = hfi1_rcd_get_by_index(dd, i);
-               if (rcd)
-                       rcd->do_interrupt =
-                               &handle_receive_interrupt_nodma_rtail;
+       if (rcd->ctxt >= dd->first_dyn_alloc_ctxt && !rcd->is_vnic) {
+               hfi1_rcd_get(rcd);
+               hfi1_set_fast(rcd);
                hfi1_rcd_put(rcd);
-       }
-}
-
-static inline void set_dma_rtail(struct hfi1_devdata *dd, u16 ctxt)
-{
-       struct hfi1_ctxtdata *rcd;
-       u16 i;
-
-       /*
-        * For dynamically allocated kernel contexts (like vnic) switch
-        * interrupt handler only for that context. Otherwise, switch
-        * interrupt handler for all statically allocated kernel contexts.
-        */
-       if (ctxt >= dd->first_dyn_alloc_ctxt) {
-               rcd = hfi1_rcd_get_by_index_safe(dd, ctxt);
-               if (rcd) {
-                       rcd->do_interrupt =
-                               &handle_receive_interrupt_dma_rtail;
-                       hfi1_rcd_put(rcd);
-               }
                return;
        }
 
-       for (i = HFI1_CTRL_CTXT + 1; i < dd->first_dyn_alloc_ctxt; i++) {
+       for (i = HFI1_CTRL_CTXT + 1; i < dd->num_rcv_contexts; i++) {
                rcd = hfi1_rcd_get_by_index(dd, i);
-               if (rcd)
-                       rcd->do_interrupt =
-                               &handle_receive_interrupt_dma_rtail;
+               if (rcd && (i < dd->first_dyn_alloc_ctxt || rcd->is_vnic))
+                       hfi1_set_fast(rcd);
                hfi1_rcd_put(rcd);
        }
 }
@@ -952,7 +918,7 @@ void set_all_slowpath(struct hfi1_devdata *dd)
                if (!rcd)
                        continue;
                if (i < dd->first_dyn_alloc_ctxt || rcd->is_vnic)
-                       rcd->do_interrupt = &handle_receive_interrupt;
+                       rcd->do_interrupt = rcd->slow_handler;
 
                hfi1_rcd_put(rcd);
        }
@@ -1065,11 +1031,6 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
                if (!get_dma_rtail_setting(rcd)) {
                        if (hfi1_seq_incr(rcd, rhf_rcv_seq(packet.rhf)))
                                last = RCV_PKT_DONE;
-                       if (needset) {
-                               dd_dev_info(dd, "Switching to NO_DMA_RTAIL\n");
-                               set_nodma_rtail(dd, rcd->ctxt);
-                               needset = 0;
-                       }
                } else {
                        if (packet.rhqoff == hdrqtail)
                                last = RCV_PKT_DONE;
@@ -1085,15 +1046,12 @@ int handle_receive_interrupt(struct hfi1_ctxtdata *rcd, int thread)
                                if (!last && lseq)
                                        skip_pkt = 1;
                        }
-
-                       if (needset) {
-                               dd_dev_info(dd,
-                                           "Switching to DMA_RTAIL\n");
-                               set_dma_rtail(dd, rcd->ctxt);
-                               needset = 0;
-                       }
                }
 
+               if (needset) {
+                       needset = false;
+                       set_all_fastpath(dd, rcd);
+               }
                process_rcv_update(last, &packet);
        }
 
index d662fcc9a1b4fd3ab5111d1c549cbe808fcc4169..0c643bcd9b1798ef0a7f037011fd2825cbc8f5e1 100644 (file)
@@ -197,6 +197,8 @@ struct exp_tid_set {
        u32 count;
 };
 
+struct hfi1_ctxtdata;
+typedef int (*intr_handler)(struct hfi1_ctxtdata *rcd, int data);
 typedef int (*rhf_rcv_function_ptr)(struct hfi1_packet *packet);
 
 struct tid_queue {
@@ -226,7 +228,11 @@ struct hfi1_ctxtdata {
         * be valid. Worst case is we process an extra interrupt and up to 64
         * packets with the wrong interrupt handler.
         */
-       int (*do_interrupt)(struct hfi1_ctxtdata *rcd, int threaded);
+       intr_handler do_interrupt;
+       /** fast handler after autoactive */
+       intr_handler fast_handler;
+       /** slow handler */
+       intr_handler slow_handler;
        /* verbs rx_stats per rcd */
        struct hfi1_opcode_stats_perctx *opstats;
        /* clear interrupt mask */
@@ -1616,6 +1622,39 @@ static inline u16 get_hdrq_cnt(struct hfi1_ctxtdata *rcd)
        return rcd->rcvhdrq_cnt;
 }
 
+/**
+ * hfi1_is_slowpath - check if this context is slow path
+ * @rcd: the receive context
+ */
+static inline bool hfi1_is_slowpath(struct hfi1_ctxtdata *rcd)
+{
+       return rcd->do_interrupt == rcd->slow_handler;
+}
+
+/**
+ * hfi1_is_fastpath - check if this context is fast path
+ * @rcd: the receive context
+ */
+static inline bool hfi1_is_fastpath(struct hfi1_ctxtdata *rcd)
+{
+       if (rcd->ctxt == HFI1_CTRL_CTXT)
+               return false;
+
+       return rcd->do_interrupt == rcd->fast_handler;
+}
+
+/**
+ * hfi1_set_fast - change to the fast handler
+ * @rcd: the receive context
+ */
+static inline void hfi1_set_fast(struct hfi1_ctxtdata *rcd)
+{
+       if (unlikely(!rcd))
+               return;
+       if (unlikely(!hfi1_is_fastpath(rcd)))
+               rcd->do_interrupt = rcd->fast_handler;
+}
+
 int hfi1_reset_device(int);
 
 void receive_interrupt_work(struct work_struct *work);
index 81c35516bf401d7358abde62bd311cbe5bbbcc27..925f75f944874652d15c59eeb3bbb4b75f91b020 100644 (file)
@@ -150,6 +150,11 @@ static int hfi1_create_kctxt(struct hfi1_devdata *dd,
        /* Control context must use DMA_RTAIL */
        if (rcd->ctxt == HFI1_CTRL_CTXT)
                rcd->flags |= HFI1_CAP_DMA_RTAIL;
+       rcd->fast_handler = get_dma_rtail_setting(rcd) ?
+                               handle_receive_interrupt_dma_rtail :
+                               handle_receive_interrupt_nodma_rtail;
+       rcd->slow_handler = handle_receive_interrupt;
+
        hfi1_set_seq_cnt(rcd, 1);
 
        rcd->sc = sc_alloc(dd, SC_ACK, rcd->rcvhdrqentsize, dd->node);
index ebce81c7ac414102e4607be4c938979454742ebe..168079ed122ce4a41e3ce7ab00ddbaafcaaebc5d 100644 (file)
@@ -106,11 +106,7 @@ TRACE_EVENT(hfi1_receive_interrupt,
                             ),
            TP_fast_assign(DD_DEV_ASSIGN(dd);
                        __entry->ctxt = rcd->ctxt;
-                       if (rcd->do_interrupt ==
-                           &handle_receive_interrupt)
-                               __entry->slow_path = 1;
-                       else
-                               __entry->slow_path = 0;
+                       __entry->slow_path = hfi1_is_slowpath(rcd);
                        __entry->dma_rtail = get_dma_rtail_setting(rcd);
                        ),
            TP_printk("[%s] ctxt %d SlowPath: %d DmaRtail: %d",