Whamcloud - gitweb
* Applied the last patch in Bug 2306, which changes the portals router/NAL
[fs/lustre-release.git] / lustre / portals / knals / socknal / socknal.h
index 9dbe415..2767c41 100644 (file)
@@ -45,6 +45,7 @@
 #include <asm/system.h>
 #include <asm/uaccess.h>
 
+#include <linux/init.h>
 #include <linux/fs.h>
 #include <linux/file.h>
 #include <linux/stat.h>
 
 #define SOCKNAL_SMALL_FWD_PAGES        1               /* # pages in a small message fwd buffer */
 
-#define SOCKNAL_LARGE_FWD_PAGES (PAGE_ALIGN (sizeof (ptl_hdr_t) + PTL_MTU) >> PAGE_SHIFT)
+#define SOCKNAL_LARGE_FWD_PAGES (PAGE_ALIGN(PTL_MTU) >> PAGE_SHIFT)
                                                /* # pages in a large message fwd buffer */
 
 #define SOCKNAL_RESCHED         100             /* # scheduler loops before reschedule */
+#define SOCKNAL_ENOMEM_RETRY    1               /* jiffies between retries */
 
 #define SOCKNAL_TX_LOW_WATER(sk) (((sk)->sk_sndbuf*8)/10)
 
@@ -113,6 +115,7 @@ typedef struct                                  /* pool of forwarding buffers */
         struct list_head  fmp_idle_fmbs;        /* free buffers */
         struct list_head  fmp_blocked_conns;    /* connections waiting for a buffer */
         int               fmp_nactive_fmbs;     /* # buffers in use */
+        int               fmp_buff_pages;       /* # pages per buffer */
 } ksock_fmb_pool_t;
 
 
@@ -169,9 +172,12 @@ typedef struct {
 
         struct list_head  ksnd_deathrow_conns;  /* conns to be closed */
         struct list_head  ksnd_zombie_conns;    /* conns to be freed */
-        wait_queue_head_t ksnd_reaper_waitq;    /* reaper sleep here */
+        struct list_head  ksnd_enomem_conns;    /* conns to be retried */
+        wait_queue_head_t ksnd_reaper_waitq;    /* reaper sleeps here */
+        unsigned long     ksnd_reaper_waketime; /* when reaper will wake */
         spinlock_t        ksnd_reaper_lock;     /* serialise */
 
+        int               ksnd_enomem_tx;       /* test ENOMEM sender */
         int               ksnd_stall_tx;        /* test sluggish sender */
         int               ksnd_stall_rx;        /* test sluggish receiver */
 
@@ -188,18 +194,13 @@ typedef struct {
 #define SOCKNAL_INIT_ALL        3
 
 /* A packet just assembled for transmission is represented by 1 or more
- * struct iovec fragments and 0 or more ptl_kiov_t fragments.  Forwarded
- * messages, or messages from an MD with PTL_MD_KIOV _not_ set have 0
- * ptl_kiov_t fragments.  Messages from an MD with PTL_MD_KIOV set, have 1
- * struct iovec fragment (the header) and up to PTL_MD_MAX_IOV ptl_kiov_t
- * fragments.
+ * struct iovec fragments (the first frag contains the portals header),
+ * followed by 0 or more ptl_kiov_t fragments.
  *
  * On the receive side, initially 1 struct iovec fragment is posted for
- * receive (the header).  Once the header has been received, if the message
- * requires forwarding or will be received into mapped memory, up to
- * PTL_MD_MAX_IOV struct iovec fragments describe the target memory.
- * Otherwise up to PTL_MD_MAX_IOV ptl_kiov_t fragments are used.
- */
+ * receive (the header).  Once the header has been received, the payload is
+ * received into either struct iovec or ptl_kiov_t fragments, depending on
+ * what the header matched or whether the message needs forwarding. */
 
 struct ksock_conn;                              /* forward ref */
 struct ksock_peer;                              /* forward ref */
@@ -222,6 +223,12 @@ typedef struct                                  /* transmit packet */
 #endif
 } ksock_tx_t;
 
+typedef struct                                  /* forwarded packet */
+{
+        ksock_tx_t             ftx_tx;          /* send info */
+        struct iovec           ftx_iov;         /* hdr iovec */
+} ksock_ftx_t;
+
 #define KSOCK_ZCCD_2_TX(ptr)   list_entry (ptr, ksock_tx_t, tx_zccd)
 /* network zero copy callback descriptor embedded in ksock_tx_t */
 
@@ -249,15 +256,14 @@ typedef struct                                  /* Kernel portals Socket Forward
 {                                               /* (socknal->router) */
         struct list_head        fmb_list;       /* queue idle */
         kpr_fwd_desc_t          fmb_fwd;        /* router's descriptor */
-        int                     fmb_npages;     /* # pages allocated */
         ksock_fmb_pool_t       *fmb_pool;       /* owning pool */
         struct ksock_peer      *fmb_peer;       /* peer received from */
-        struct page            *fmb_pages[SOCKNAL_LARGE_FWD_PAGES];
-        struct iovec            fmb_iov[SOCKNAL_LARGE_FWD_PAGES];
+        ptl_hdr_t               fmb_hdr;        /* message header */
+        ptl_kiov_t              fmb_kiov[0];    /* payload frags */
 } ksock_fmb_t;
 
 /* space for the rx frag descriptors; we either read a single contiguous
- * header, or PTL_MD_MAX_IOV frags of payload of either type. */
+ * header, or up to PTL_MD_MAX_IOV frags of payload of either type. */
 typedef union {
         struct iovec    iov[PTL_MD_MAX_IOV];
         ptl_kiov_t      kiov[PTL_MD_MAX_IOV];
@@ -329,7 +335,6 @@ typedef struct ksock_route
         int                 ksnr_port;          /* port to connect to */
         int                 ksnr_buffer_size;   /* size of socket buffers */
         unsigned int        ksnr_irq_affinity:1; /* set affinity? */
-        unsigned int        ksnr_nonagel:1;     /* disable nagle? */
         unsigned int        ksnr_eager:1;       /* connect eagery? */
         unsigned int        ksnr_connecting:4;  /* autoconnects in progress by type */
         unsigned int        ksnr_connected:4;   /* connections established by type */