Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[fs/lustre-release.git] / lnet / klnds / socklnd / socklnd.h
index 08bbab9..a82ac93 100644 (file)
 # define SOCKNAL_RISK_KMAP_DEADLOCK  1
 #endif
 
+enum ksocklnd_ni_lnd_tunables_attr {
+       LNET_NET_SOCKLND_TUNABLES_ATTR_UNSPEC = 0,
+
+       LNET_NET_SOCKLND_TUNABLES_ATTR_CONNS_PER_PEER,
+       LNET_NET_SOCKLND_TUNABLES_ATTR_LND_TIMEOUT,
+       LNET_NET_SOCKLND_TUNABLES_ATTR_LND_TOS,
+       __LNET_NET_SOCKLND_TUNABLES_ATTR_MAX_PLUS_ONE,
+};
+
+#define LNET_NET_SOCKLND_TUNABLES_ATTR_MAX (__LNET_NET_SOCKLND_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
+
 /* per scheduler state */
 struct ksock_sched {
        /* serialise */
@@ -168,6 +179,7 @@ struct ksock_net {
        struct list_head  ksnn_list;            /* chain on global list */
        atomic_t          ksnn_npeers;          /* # peers */
        struct ksock_interface ksnn_interface;  /* IP interface */
+       struct lnet_ni    *ksnn_ni;
 };
 /* When the ksock_net is shut down, this (negative) bias is added to
  * ksnn_npeers, which prevents new peers from being added.
@@ -338,8 +350,9 @@ struct ksock_conn {
                                                 * V2.x message takes the
                                                 * whole struct
                                                 * V1.x message is a bare
-                                                * struct lnet_hdr, it's stored
-                                                * in ksnc_msg.ksm_u.lnetmsg
+                                                * struct lnet_hdr_nid4, it's
+                                                * stored in
+                                                * ksnc_msg.ksm_u.lnetmsg
                                                 */
        /* -- WRITER -- */
        /* where I enq waiting for output space */
@@ -363,6 +376,7 @@ struct ksock_conn {
 };
 
 #define SOCKNAL_CONN_COUNT_MAX_BITS    8       /* max conn count bits */
+#define SOCKNAL_MAX_BUSY_RETRIES       3
 
 struct ksock_conn_cb {
        struct list_head        ksnr_connd_list;/* chain on ksnr_connd_routes */
@@ -372,17 +386,21 @@ struct ksock_conn_cb {
                                                 * can happen next
                                                 */
        time64_t                ksnr_retry_interval;/* secs between retries */
-       int                     ksnr_myiface;   /* interface index */
        struct sockaddr_storage ksnr_addr;      /* IP address to connect to */
        unsigned int            ksnr_scheduled:1;/* scheduled for attention */
        unsigned int            ksnr_connecting:1;/* connection in progress */
        unsigned int            ksnr_connected:4;/* connections by type */
        unsigned int            ksnr_deleted:1; /* been removed from peer_ni? */
-       unsigned int            ksnr_ctrl_conn_count:1; /* # conns by type */
+       unsigned int            ksnr_ctrl_conn_count:2; /* # conns by type */
        unsigned int            ksnr_blki_conn_count:8;
        unsigned int            ksnr_blko_conn_count:8;
        int                     ksnr_conn_count;/* total # conns for this cb */
-
+       unsigned int            ksnr_max_conns; /* conns_per_peer at peer
+                                                * creation
+                                                */
+       unsigned int            ksnr_busy_retry_count;/* counts retry attempts
+                                                      * due to EALREADY rc
+                                                      */
 };
 
 #define SOCKNAL_KEEPALIVE_PING          1       /* cookie for keepalive ping */
@@ -390,7 +408,7 @@ struct ksock_conn_cb {
 struct ksock_peer_ni {
        struct hlist_node       ksnp_list;      /* stash on global peer_ni list */
        time64_t                ksnp_last_alive;/* when (in seconds) I was last alive */
-       struct lnet_process_id  ksnp_id;        /* who's on the other end(s) */
+       struct lnet_processid   ksnp_id;        /* who's on the other end(s) */
        refcount_t              ksnp_refcount;  /* # users */
        int                     ksnp_closing;   /* being closed */
        int                     ksnp_accepting; /* # passive connections pending */
@@ -406,8 +424,6 @@ struct ksock_peer_ni {
        struct list_head        ksnp_zc_req_list;
        time64_t                ksnp_send_keepalive; /* time to send keepalive */
        struct lnet_ni          *ksnp_ni;       /* which network */
-       int                     ksnp_n_passive_ips; /* # of... */
-       __u32                   ksnp_passive_ips[LNET_INTERFACES_NUM]; /* preferred local interfaces */
 };
 
 struct ksock_connreq {
@@ -421,6 +437,7 @@ struct ksock_connreq {
 
 extern struct ksock_nal_data ksocknal_data;
 extern struct ksock_tunables ksocknal_tunables;
+extern struct lnet_ioctl_config_socklnd_tunables ksock_default_tunables;
 
 #define SOCKNAL_MATCH_NO        0        /* TX can't match type of connection */
 #define SOCKNAL_MATCH_YES       1        /* TX matches type of connection */
@@ -431,7 +448,7 @@ struct ksock_proto {
        int         (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);     /* handshake function */
        int         (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);/* handshake function */
        void        (*pro_pack)(struct ksock_tx *);                                  /* message pack */
-       void        (*pro_unpack)(struct ksock_msg *);                          /* message unpack */
+       void        (*pro_unpack)(struct ksock_msg *, struct lnet_hdr *);       /* message unpack */
        struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *);          /* queue tx on the connection */
        int         (*pro_queue_tx_zcack)(struct ksock_conn *, struct ksock_tx *, __u64); /* queue ZC ack on the connection */
        int         (*pro_handle_zcreq)(struct ksock_conn *, __u64, int);            /* handle ZC request */
@@ -446,6 +463,7 @@ struct ksock_proto {
 extern const struct ksock_proto ksocknal_protocol_v1x;
 extern const struct ksock_proto ksocknal_protocol_v2x;
 extern const struct ksock_proto ksocknal_protocol_v3x;
+extern const struct ksock_proto ksocknal_protocol_v4x;
 
 #define KSOCK_PROTO_V1_MAJOR    LNET_PROTO_TCP_VERSION_MAJOR
 #define KSOCK_PROTO_V1_MINOR    LNET_PROTO_TCP_VERSION_MINOR
@@ -455,6 +473,11 @@ extern const struct ksock_proto ksocknal_protocol_v3x;
 #define CPU_MASK_NONE   0UL
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
+#undef netdev_notifier_info_to_dev
+#define netdev_notifier_info_to_dev(ndev) ndev
+#endif
+
 static inline __u32 ksocknal_csum(__u32 crc, unsigned char const *p, size_t len)
 {
 #if 1
@@ -586,12 +609,14 @@ int ksocknal_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
                   unsigned int offset, unsigned int mlen, unsigned int rlen);
 int ksocknal_accept(struct lnet_ni *ni, struct socket *sock);
 
-int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id,
+unsigned int ksocknal_get_conn_count_by_type(struct ksock_conn_cb *conn_cb,
+                                            int type);
+int ksocknal_add_peer(struct lnet_ni *ni, struct lnet_processid *id,
                      struct sockaddr *addr);
 struct ksock_peer_ni *ksocknal_find_peer_locked(struct lnet_ni *ni,
-                                          struct lnet_process_id id);
+                                          struct lnet_processid *id);
 struct ksock_peer_ni *ksocknal_find_peer(struct lnet_ni *ni,
-                                   struct lnet_process_id id);
+                                        struct lnet_processid *id);
 extern void ksocknal_peer_failed(struct ksock_peer_ni *peer_ni);
 extern int ksocknal_create_conn(struct lnet_ni *ni,
                                struct ksock_conn_cb *conn_cb,
@@ -602,12 +627,12 @@ extern void ksocknal_destroy_conn(struct ksock_conn *conn);
 extern int  ksocknal_close_peer_conns_locked(struct ksock_peer_ni *peer_ni,
                                             struct sockaddr *peer, int why);
 extern int ksocknal_close_conn_and_siblings(struct ksock_conn *conn, int why);
-int ksocknal_close_matching_conns(struct lnet_process_id id, __u32 ipaddr);
+int ksocknal_close_matching_conns(struct lnet_processid *id, __u32 ipaddr);
 extern struct ksock_conn *ksocknal_find_conn_locked(struct ksock_peer_ni *peer_ni,
                                                    struct ksock_tx *tx, int nonblk);
 
 extern int  ksocknal_launch_packet(struct lnet_ni *ni, struct ksock_tx *tx,
-                                  struct lnet_process_id id);
+                                  struct lnet_processid *id);
 extern struct ksock_tx *ksocknal_alloc_tx(int type, int size);
 extern void ksocknal_free_tx(struct ksock_tx *tx);
 extern struct ksock_tx *ksocknal_alloc_tx_noop(__u64 cookie, int nonblk);
@@ -615,7 +640,15 @@ extern void ksocknal_next_tx_carrier(struct ksock_conn *conn);
 extern void ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn);
 extern void ksocknal_txlist_done(struct lnet_ni *ni, struct list_head *txlist,
                                 int error);
-extern int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name);
+#define ksocknal_thread_start(fn, data, namefmt, arg...)               \
+       ({                                                              \
+               struct task_struct *__task = kthread_run(fn, data,      \
+                                                        namefmt, ##arg); \
+               if (!IS_ERR(__task))                                    \
+                       atomic_inc(&ksocknal_data.ksnd_nthreads);       \
+               PTR_ERR_OR_ZERO(__task);                                \
+       })
+
 extern void ksocknal_thread_fini(void);
 extern void ksocknal_launch_all_connections_locked(struct ksock_peer_ni *peer_ni);
 extern struct ksock_conn_cb *ksocknal_find_connectable_conn_cb_locked(struct ksock_peer_ni *peer_ni);
@@ -625,10 +658,11 @@ extern int ksocknal_scheduler(void *arg);
 extern int ksocknal_connd(void *arg);
 extern int ksocknal_reaper(void *arg);
 int ksocknal_send_hello(struct lnet_ni *ni, struct ksock_conn *conn,
-                       lnet_nid_t peer_nid, struct ksock_hello_msg *hello);
+                       struct lnet_nid *peer_nid,
+                       struct ksock_hello_msg *hello);
 int ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
                        struct ksock_hello_msg *hello,
-                       struct lnet_process_id *id,
+                       struct lnet_processid *id,
                        __u64 *incarnation);
 extern void ksocknal_read_callback(struct ksock_conn *conn);
 extern void ksocknal_write_callback(struct ksock_conn *conn);
@@ -640,7 +674,7 @@ extern void ksocknal_lib_reset_callback(struct socket *sock,
                                        struct ksock_conn *conn);
 extern void ksocknal_lib_push_conn(struct ksock_conn *conn);
 extern int ksocknal_lib_get_conn_addrs(struct ksock_conn *conn);
-extern int ksocknal_lib_setup_sock(struct socket *so);
+extern int ksocknal_lib_setup_sock(struct socket *sock, struct lnet_ni *ni);
 extern int ksocknal_lib_send_hdr(struct ksock_conn *conn, struct ksock_tx *tx,
                                 struct kvec *scratch_iov);
 extern int ksocknal_lib_send_kiov(struct ksock_conn *conn, struct ksock_tx *tx,
@@ -654,6 +688,7 @@ extern int ksocknal_lib_get_conn_tunables(struct ksock_conn *conn, int *txmem,
                                          int *rxmem, int *nagle);
 
 extern int ksocknal_tunables_init(void);
+extern void ksocknal_tunables_setup(struct lnet_ni *ni);
 
 extern void ksocknal_lib_csum_tx(struct ksock_tx *tx);