#include <asm/system.h>
#include <asm/uaccess.h>
+#include <asm/irq.h>
+#include <linux/init.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/stat.h>
#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
-#define SOCKNAL_NLTXS 128 /* # normal transmit messages */
-#define SOCKNAL_NNBLK_LTXS 128 /* # transmit messages reserved if can't block */
-
#define SOCKNAL_SMALL_FWD_NMSGS 128 /* # small messages I can be forwarding at any time */
#define SOCKNAL_LARGE_FWD_NMSGS 64 /* # large messages I can be forwarding at any time */
#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)
typedef struct /* pool of forwarding buffers */
{
spinlock_t fmp_lock; /* serialise */
- struct list_head fmp_idle_fmbs; /* buffers waiting for a connection */
+ 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;
kpr_router_t ksnd_router; /* THE router */
- void *ksnd_fmbs; /* all the pre-allocated FMBs */
ksock_fmb_pool_t ksnd_small_fmp; /* small message forwarding buffers */
ksock_fmb_pool_t ksnd_large_fmp; /* large message forwarding buffers */
- void *ksnd_ltxs; /* all the pre-allocated LTXs */
- spinlock_t ksnd_idle_ltx_lock; /* serialise ltx alloc/free */
- struct list_head ksnd_idle_ltx_list; /* where to get an idle LTX */
- struct list_head ksnd_idle_nblk_ltx_list; /* where to get an idle LTX if you can't block */
- wait_queue_head_t ksnd_idle_ltx_waitq; /* where to block for an idle LTX */
- int ksnd_active_ltxs; /* #active ltxs */
+ atomic_t ksnd_nactive_ltxs; /* #active ltxs */
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 */
#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 */
#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 */
-/* space for the tx frag descriptors: hdr is always 1 iovec
- * and payload is PTL_MD_MAX of either type. */
-typedef struct
-{
- struct iovec hdr;
- union {
- struct iovec iov[PTL_MD_MAX_IOV];
- ptl_kiov_t kiov[PTL_MD_MAX_IOV];
- } payload;
-} ksock_txiovspace_t;
-
typedef struct /* locally transmitted packet */
{
ksock_tx_t ltx_tx; /* send info */
- struct list_head *ltx_idle; /* where to put when idle */
void *ltx_private; /* lib_finalize() callback arg */
void *ltx_cookie; /* lib_finalize() callback arg */
- ksock_txiovspace_t ltx_iov_space; /* where to stash frag descriptors */
ptl_hdr_t ltx_hdr; /* buffer for packet header */
+ int ltx_desc_size; /* bytes allocated for this desc */
+ struct iovec ltx_iov[1]; /* iov for hdr + payload */
+ ptl_kiov_t ltx_kiov[0]; /* kiov for payload */
} ksock_ltx_t;
#define KSOCK_TX_2_KPR_FWD_DESC(ptr) list_entry ((kprfd_scratch_t *)ptr, kpr_fwd_desc_t, kprfd_scratch)
{ /* (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];
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 */