*/
#define DEBUG_PORTAL_ALLOC
-#define EXPORT_SYMTAB
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
#include <linux/config.h>
#include <linux/module.h>
#include <linux/kp30.h>
#include <portals/p30.h>
#include <portals/lib-p30.h>
+#include <portals/socknal.h>
#if CONFIG_SMP
-# define SOCKNAL_N_SCHED smp_num_cpus /* # socknal schedulers */
+# define SOCKNAL_N_SCHED num_online_cpus() /* # socknal schedulers */
#else
# define SOCKNAL_N_SCHED 1 /* # socknal schedulers */
#endif
/* default vals for runtime tunables */
#define SOCKNAL_IO_TIMEOUT 50 /* default comms timeout (seconds) */
-#define SOCKNAL_EAGER_ACK 1 /* default eager ack (boolean) */
+#define SOCKNAL_EAGER_ACK 0 /* default eager ack (boolean) */
+#define SOCKNAL_TYPED_CONNS 1 /* unidirectional large, bidirectional small? */
#define SOCKNAL_ZC_MIN_FRAG (2<<10) /* default smallest zerocopy fragment */
-
+#define SOCKNAL_MIN_BULK (1<<10) /* smallest "large" message */
#define SOCKNAL_USE_KEEPALIVES 0 /* use tcp/ip keepalive? */
#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
-#if PTL_LARGE_MTU
-# define SOCKNAL_MAX_FWD_PAYLOAD (256<<10) /* biggest payload I can forward */
-#else
-# define SOCKNAL_MAX_FWD_PAYLOAD (64<<10) /* biggest payload I can forward */
-#endif
-
#define SOCKNAL_NLTXS 128 /* # normal transmit messages */
#define SOCKNAL_NNBLK_LTXS 128 /* # transmit messages reserved if can't block */
#define SOCKNAL_SMALL_FWD_PAGES 1 /* # pages in a small message fwd buffer */
-#define SOCKNAL_LARGE_FWD_PAGES (PAGE_ALIGN (sizeof (ptl_hdr_t) + SOCKNAL_MAX_FWD_PAYLOAD) >> PAGE_SHIFT)
+#define SOCKNAL_LARGE_FWD_PAGES (PAGE_ALIGN (sizeof (ptl_hdr_t) + PTL_MTU) >> PAGE_SHIFT)
/* # pages in a large message fwd buffer */
#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
# define sk_socket socket
#endif
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+# define sk_wmem_queued wmem_queued
+#endif
+
typedef struct /* pool of forwarding buffers */
{
spinlock_t fmp_lock; /* serialise */
int ksnd_init; /* initialisation state */
int ksnd_io_timeout; /* "stuck" socket timeout (seconds) */
int ksnd_eager_ack; /* make TCP ack eagerly? */
+ int ksnd_typed_conns; /* drive sockets by type? */
+ int ksnd_min_bulk; /* smallest "large" message */
#if SOCKNAL_ZC
unsigned int ksnd_zc_min_frag; /* minimum zero copy frag size */
#endif
struct ctl_table_header *ksnd_sysctl; /* sysctl interface */
+ __u64 ksnd_incarnation; /* my epoch */
rwlock_t ksnd_global_lock; /* stabilize peer/conn ops */
struct list_head *ksnd_peers; /* hash table of all my known peers */
__u32 ksnc_ipaddr; /* peer's IP */
int ksnc_port; /* peer's port */
int ksnc_closing; /* being shut down */
+ int ksnc_type; /* type of connection */
+ __u64 ksnc_incarnation; /* peer's incarnation */
- /* READER */
+ /* reader */
struct list_head ksnc_rx_list; /* where I enq waiting input or a forwarding descriptor */
unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times out */
int ksnc_rx_started; /* started receiving a message */
int ksnc_tx_scheduled; /* being progressed */
} ksock_conn_t;
+#define KSNR_TYPED_ROUTES ((1 << SOCKNAL_CONN_CONTROL) | \
+ (1 << SOCKNAL_CONN_BULK_IN) | \
+ (1 << SOCKNAL_CONN_BULK_OUT))
+
typedef struct ksock_route
{
struct list_head ksnr_list; /* chain on peer route list */
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_xchange_nids:1; /* do hello protocol? */
unsigned int ksnr_nonagel:1; /* disable nagle? */
unsigned int ksnr_eager:1; /* connect eagery? */
- unsigned int ksnr_connecting:1; /* autoconnect in progress? */
+ unsigned int ksnr_connecting:4; /* autoconnects in progress by type */
+ unsigned int ksnr_connected:4; /* connections established by type */
unsigned int ksnr_deleted:1; /* been removed from peer? */
- int ksnr_generation; /* connection incarnation # */
- ksock_conn_t *ksnr_conn; /* NULL/active connection */
+ int ksnr_conn_count; /* # conns established by this route */
} ksock_route_t;
typedef struct ksock_peer
extern ksock_peer_t *ksocknal_get_peer (ptl_nid_t nid);
extern int ksocknal_del_route (ptl_nid_t nid, __u32 ipaddr,
int single, int keep_conn);
-extern int ksocknal_create_conn (ptl_nid_t nid, ksock_route_t *route,
- struct socket *sock, int bind_irq);
+extern int ksocknal_create_conn (ksock_route_t *route,
+ struct socket *sock, int bind_irq, int type);
extern void ksocknal_close_conn_locked (ksock_conn_t *conn, int why);
-extern int ksocknal_close_conn_unlocked (ksock_conn_t *conn, int why);
extern void ksocknal_terminate_conn (ksock_conn_t *conn);
extern void ksocknal_destroy_conn (ksock_conn_t *conn);
extern void ksocknal_put_conn (ksock_conn_t *conn);
-extern int ksocknal_close_conn (ptl_nid_t nid, __u32 ipaddr);
+extern int ksocknal_close_stale_conns_locked (ksock_peer_t *peer, __u64 incarnation);
+extern int ksocknal_close_conn_and_siblings (ksock_conn_t *conn, int why);
+extern int ksocknal_close_matching_conns (ptl_nid_t nid, __u32 ipaddr);
extern void ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn);
extern void ksocknal_tx_done (ksock_tx_t *tx, int asynch);
extern int ksocknal_autoconnectd (void *arg);
extern int ksocknal_reaper (void *arg);
extern int ksocknal_setup_sock (struct socket *sock);
+extern int ksocknal_hello (struct socket *sock,
+ ptl_nid_t *nid, int *type, __u64 *incarnation);