Whamcloud - gitweb
* ranal passes netregression
[fs/lustre-release.git] / lnet / klnds / ralnd / ralnd.h
index cc5c2e6..e6602dd 100644 (file)
 #include <linux/sysctl.h>
 
 #include <net/sock.h>
+#include <linux/in.h>
 
 #define DEBUG_SUBSYSTEM S_NAL
 
 #include <linux/kp30.h>
+#include <linux/portals_compat25.h>
 #include <portals/p30.h>
 #include <portals/lib-p30.h>
 #include <portals/nal.h>
@@ -75,7 +77,7 @@
 #define RANAL_NTX             64                /* # tx descs */
 #define RANAL_NTX_NBLK        256               /* # reserved tx descs */
 
-#define RANAL_FMA_CQ_SIZE     8192              /* # entries in receive CQ 
+#define RANAL_FMA_CQ_SIZE     8192              /* # entries in receive CQ
                                                  * (overflow is a performance hit) */
 
 #define RANAL_RESCHED         100               /* # scheduler loops before reschedule */
 /* default vals for runtime tunables */
 #define RANAL_TIMEOUT           30              /* comms timeout (seconds) */
 #define RANAL_LISTENER_TIMEOUT   5              /* listener timeout (seconds) */
+#define RANAL_BACKLOG          127              /* listener's backlog */
+#define RANAL_PORT             988              /* listener's port */
 #define RANAL_MAX_IMMEDIATE    (2<<10)          /* immediate payload breakpoint */
 
-typedef struct 
+typedef struct
 {
         int               kra_timeout;          /* comms timeout (seconds) */
         int               kra_listener_timeout; /* max time the listener can block */
@@ -102,9 +106,8 @@ typedef struct
 typedef struct
 {
         RAP_PVOID               rad_handle;     /* device handle */
-        RAP_PROTECTION_HANDLE   rad_ptag;       /* protection tag */
-        RAP_CQ_HANDLE           rad_fma_cq;     /* FMA (small message) completion queue */
-        RAP_CQ_HANDLE           rad_rdma_cq;    /* rdma completion queue */
+        RAP_PVOID               rad_fma_cqh;    /* FMA completion queue handle */
+        RAP_PVOID               rad_rdma_cqh;   /* rdma completion queue handle */
         int                     rad_id;         /* device id */
         int                     rad_idx;        /* index in kra_devices */
         int                     rad_ready;      /* set by device callback */
@@ -114,8 +117,8 @@ typedef struct
         spinlock_t              rad_lock;       /* serialise */
         void                   *rad_scheduler;  /* scheduling thread */
 } kra_device_t;
-        
-typedef struct 
+
+typedef struct
 {
         int               kra_init;             /* initialisation state */
         int               kra_shutdown;         /* shut down? */
@@ -145,8 +148,9 @@ typedef struct
         long              kra_new_min_timeout;  /* minimum timeout on any new conn */
         wait_queue_head_t kra_reaper_waitq;     /* reaper sleeps here */
         spinlock_t        kra_reaper_lock;      /* serialise */
-        
+
         struct list_head  kra_connd_peers;      /* peers waiting for a connection */
+        struct list_head  kra_connd_acceptq;    /* accepted sockets to handshake */
         wait_queue_head_t kra_connd_waitq;      /* connection daemons sleep here */
         spinlock_t        kra_connd_lock;       /* serialise */
 
@@ -162,6 +166,12 @@ typedef struct
 #define RANAL_INIT_LIB             2
 #define RANAL_INIT_ALL             3
 
+typedef struct kra_acceptsock                   /* accepted socket queued for connd */
+{
+        struct list_head     ras_list;          /* queue for attention */
+        struct socket       *ras_sock;          /* the accepted socket */
+} kra_acceptsock_t;
+
 /************************************************************************
  * Wire message structs.  These are sent in sender's byte order
  * (i.e. receiver checks magic and flips if required).
@@ -172,7 +182,8 @@ typedef struct kra_connreq                      /* connection request/response *
         __u32             racr_magic;           /* I'm an ranal connreq */
         __u16             racr_version;         /* this is my version number */
         __u16             racr_devid;           /* sender's device ID */
-        __u64             racr_nid;             /* sender's NID */
+        __u64             racr_srcnid;          /* sender's NID */
+        __u64             racr_dstnid;          /* who sender expects to listen */
         __u64             racr_peerstamp;       /* sender's instance stamp */
         __u64             racr_connstamp;       /* sender's connection stamp */
         __u32             racr_timeout;         /* sender's timeout */
@@ -258,7 +269,7 @@ typedef struct kra_tx                           /* message descriptor */
         struct list_head          tx_list;      /* queue on idle_txs/rac_sendq/rac_waitq */
         struct kra_conn          *tx_conn;      /* owning conn */
         lib_msg_t                *tx_libmsg[2]; /* lib msgs to finalize on completion */
-        unsigned long             tx_qtime;     /* when tx started to wait for something */
+        unsigned long             tx_qtime;     /* when tx started to wait for something (jiffies) */
         int                       tx_isnblk;    /* I'm reserved for non-blocking sends */
         int                       tx_nob;       /* # bytes of payload */
         int                       tx_buftype;   /* payload buffer type */
@@ -295,7 +306,7 @@ typedef struct kra_tx                           /* message descriptor */
 #define RANAL_TX_GETT_DONE       0x52           /* GET target about to send GET_DONE */
 
 typedef struct kra_conn
-{ 
+{
         struct kra_peer    *rac_peer;           /* owning peer */
         struct list_head    rac_list;           /* stash on peer's conn list */
         struct list_head    rac_hashlist;       /* stash in connection hash table */
@@ -306,10 +317,10 @@ typedef struct kra_conn
         __u64               rac_peerstamp;      /* peer's unique stamp */
         __u64               rac_peer_connstamp; /* peer's unique connection stamp */
         __u64               rac_my_connstamp;   /* my unique connection stamp */
-        unsigned long       rac_last_tx;        /* when I last sent an FMA message */
-        unsigned long       rac_last_rx;        /* when I last received an FMA messages */
-        long                rac_keepalive;      /* keepalive interval */
-        long                rac_timeout;        /* infer peer death on (last_rx + timout > now) */
+        unsigned long       rac_last_tx;        /* when I last sent an FMA message (jiffies) */
+        unsigned long       rac_last_rx;        /* when I last received an FMA messages (jiffies) */
+        long                rac_keepalive;      /* keepalive interval (seconds) */
+        long                rac_timeout;        /* infer peer death if no rx for this many seconds */
         __u32               rac_cqid;           /* my completion callback id (non-unique) */
         __u32               rac_tx_seq;         /* tx msg sequence number */
         __u32               rac_rx_seq;         /* rx msg sequence number */
@@ -341,7 +352,7 @@ typedef struct kra_peer
         atomic_t            rap_refcount;       /* # users */
         int                 rap_persistence;    /* "known" peer refs */
         int                 rap_connecting;     /* connection forming */
-        unsigned long       rap_reconnect_time; /* CURRENT_TIME when reconnect OK */
+        unsigned long       rap_reconnect_time; /* CURRENT_SECONDS when reconnect OK */
         unsigned long       rap_reconnect_interval; /* exponential backoff */
 } kra_peer_t;
 
@@ -383,10 +394,10 @@ kranal_peer_decref(kra_peer_t *peer)
 }
 
 static inline struct list_head *
-kranal_nid2peerlist (ptl_nid_t nid) 
+kranal_nid2peerlist (ptl_nid_t nid)
 {
         unsigned int hash = ((unsigned int)nid) % kranal_data.kra_peer_hash_size;
-        
+
         return (&kranal_data.kra_peers[hash]);
 }
 
@@ -415,27 +426,27 @@ kranal_conn_decref(kra_conn_t *conn)
 }
 
 static inline struct list_head *
-kranal_cqid2connlist (__u32 cqid) 
+kranal_cqid2connlist (__u32 cqid)
 {
         unsigned int hash = cqid % kranal_data.kra_conn_hash_size;
-        
+
         return (&kranal_data.kra_conns [hash]);
 }
 
 static inline kra_conn_t *
-kranal_cqid2conn_locked (__u32 cqid) 
+kranal_cqid2conn_locked (__u32 cqid)
 {
         struct list_head *conns = kranal_cqid2connlist(cqid);
         struct list_head *tmp;
         kra_conn_t       *conn;
-        
+
         list_for_each(tmp, conns) {
                 conn = list_entry(tmp, kra_conn_t, rac_hashlist);
-                
+
                 if (conn->rac_cqid == cqid)
                         return conn;
         }
-        
+
         return NULL;
 }
 
@@ -446,30 +457,25 @@ kranal_tx_mapped (kra_tx_t *tx)
                 tx->tx_buftype == RANAL_BUF_PHYS_MAPPED);
 }
 
-#if CONFIG_X86
 static inline __u64
 kranal_page2phys (struct page *p)
 {
-        __u64 page_number = p - mem_map;
-        
-        return (page_number << PAGE_SHIFT);
+        return page_to_phys(p);
 }
-#else
-# error "no page->phys"
-#endif
 
-extern int kranal_listener_procint(ctl_table *table, 
-                                   int write, struct file *filp, 
-                                   void *buffer, size_t *lenp);
-extern void kranal_update_reaper_timeout(long timeout);
+extern void kranal_free_acceptsock (kra_acceptsock_t *ras);
+extern int kranal_listener_procint (ctl_table *table,
+                                    int write, struct file *filp,
+                                    void *buffer, size_t *lenp);
+extern void kranal_update_reaper_timeout (long timeout);
 extern void kranal_tx_done (kra_tx_t *tx, int completion);
 extern void kranal_unlink_peer_locked (kra_peer_t *peer);
-extern void kranal_schedule_conn(kra_conn_t *conn);
+extern void kranal_schedule_conn (kra_conn_t *conn);
 extern kra_peer_t *kranal_create_peer (ptl_nid_t nid);
 extern kra_peer_t *kranal_find_peer_locked (ptl_nid_t nid);
 extern void kranal_post_fma (kra_conn_t *conn, kra_tx_t *tx);
 extern int kranal_del_peer (ptl_nid_t nid, int single_share);
-extern void kranal_device_callback(RAP_INT32 devid);
+extern void kranal_device_callback (RAP_INT32 devid, RAP_PVOID arg);
 extern int kranal_thread_start (int(*fn)(void *arg), void *arg);
 extern int kranal_connd (void *arg);
 extern int kranal_reaper (void *arg);
@@ -477,3 +483,5 @@ extern int kranal_scheduler (void *arg);
 extern void kranal_close_conn_locked (kra_conn_t *conn, int error);
 extern void kranal_terminate_conn_locked (kra_conn_t *conn);
 extern void kranal_connect (kra_peer_t *peer);
+extern int kranal_conn_handshake (struct socket *sock, kra_peer_t *peer);
+extern void kranal_pause(int ticks);