Whamcloud - gitweb
LU-7734 lnet: proper cpt locking
[fs/lustre-release.git] / lnet / include / lnet / lib-types.h
index c073953..76f5d31 100644 (file)
@@ -68,6 +68,8 @@ typedef struct lnet_msg {
        struct list_head        msg_list;       /* Q for credits/MD */
 
        lnet_process_id_t       msg_target;
+       /* Primary NID of the source. */
+       lnet_nid_t              msg_initiator;
        /* where is it from, it's only for building event */
        lnet_nid_t              msg_from;
        __u32                   msg_type;
@@ -290,13 +292,19 @@ enum lnet_ni_state {
        LNET_NI_STATE_DELETING
 };
 
+struct lnet_element_stats {
+       atomic_t        send_count;
+       atomic_t        recv_count;
+       atomic_t        drop_count;
+};
+
 struct lnet_net {
        /* chain on the ln_nets */
        struct list_head        net_list;
 
-       /* net ID, which is compoed of
+       /* net ID, which is composed of
         * (net_type << 16) | net_num.
-        * net_type can be one of the enumarated types defined in
+        * net_type can be one of the enumerated types defined in
         * lnet/include/lnet/nidstr.h */
        __u32                   net_id;
 
@@ -355,6 +363,9 @@ typedef struct lnet_ni {
        /* instance-specific data */
        void                    *ni_data;
 
+       /* per ni credits */
+       atomic_t                ni_tx_credits;
+
        /* percpt TX queues */
        struct lnet_tx_queue    **ni_tx_queues;
 
@@ -379,6 +390,12 @@ typedef struct lnet_ni {
        /* lnd tunables set explicitly */
        bool ni_lnd_tunables_set;
 
+       /* NI statistics */
+       struct lnet_element_stats ni_stats;
+
+       /* physical device CPT */
+       int                     dev_cpt;
+
        /* sequence number used to round robin over nis within a net */
        __u32                   ni_seq;
 
@@ -422,8 +439,10 @@ typedef struct {
 } lnet_rc_data_t;
 
 struct lnet_peer_ni {
-       /* cahian on peer_net */
+       /* chain on peer_net */
        struct list_head        lpni_on_peer_net_list;
+       /* chain on remote peer list */
+       struct list_head        lpni_on_remote_peer_ni_list;
        /* chain on peer hash */
        struct list_head        lpni_hashlist;
        /* messages blocking for tx credits */
@@ -434,6 +453,10 @@ struct lnet_peer_ni {
        struct list_head        lpni_rtr_list;
        /* pointer to peer net I'm part of */
        struct lnet_peer_net    *lpni_peer_net;
+       /* statistics kept on each peer NI */
+       struct lnet_element_stats lpni_stats;
+       /* spin lock protecting credits and lpni_txq / lpni_rtrq */
+       spinlock_t              lpni_lock;
        /* # tx credits available */
        int                     lpni_txcredits;
        /* low water mark */
@@ -443,16 +466,16 @@ struct lnet_peer_ni {
        /* low water mark */
        int                     lpni_minrtrcredits;
        /* alive/dead? */
-       unsigned int            lpni_alive:1;
+       bool                    lpni_alive;
        /* notification outstanding? */
-       unsigned int            lpni_notify:1;
+       bool                    lpni_notify;
        /* outstanding notification for LND? */
-       unsigned int            lpni_notifylnd:1;
+       bool                    lpni_notifylnd;
        /* some thread is handling notification */
-       unsigned int            lpni_notifying:1;
+       bool                    lpni_notifying;
        /* SEND event outstanding from ping */
-       unsigned int            lpni_ping_notsent;
-       /* # times router went dead<->alive */
+       bool                    lpni_ping_notsent;
+       /* # times router went dead<->alive. Protected with lpni_lock */
        int                     lpni_alive_count;
        /* bytes queued for sending */
        long                    lpni_txqnob;
@@ -480,7 +503,7 @@ struct lnet_peer_ni {
        __u32                   lpni_seq;
        /* health flag */
        bool                    lpni_healthy;
-       /* returned RC ping features */
+       /* returned RC ping features. Protected with lpni_lock */
        unsigned int            lpni_ping_feats;
        /* routes on this peer */
        struct list_head        lpni_routes;
@@ -530,11 +553,11 @@ struct lnet_peer_net {
 /* peer hash table */
 struct lnet_peer_table {
        int                     pt_version;     /* /proc validity stamp */
-       int                     pt_number;      /* # peers extant */
-       int                     pt_zombies;     /* # zombies to go to deathrow
-                                                * (and not there yet) */
-       struct list_head        pt_deathrow;    /* zombie peers */
+       atomic_t                pt_number;      /* # peers extant */
        struct list_head        *pt_hash;       /* NID->peer hash */
+       struct list_head        pt_zombie_list; /* zombie peers */
+       int                     pt_zombies;     /* # zombie peers */
+       spinlock_t              pt_zombie_lock; /* protect list and count */
 };
 
 /* peer aliveness is enabled only on routers for peers in a network where the
@@ -744,6 +767,8 @@ typedef struct
        struct lnet_peer_table          **ln_peer_tables;
        /* list of configured or discovered peers */
        struct list_head                ln_peers;
+       /* list of peer nis not on a local network */
+       struct list_head                ln_remote_peer_ni_list;
        /* failure simulation */
        struct list_head                ln_test_peers;
        struct list_head                ln_drop_rules;