Whamcloud - gitweb
LU-12930 various: use schedule_timeout_*interruptible
[fs/lustre-release.git] / lnet / klnds / gnilnd / gnilnd_debug.c
1 /*
2  * Copyright (C) 2009-2012 Cray, Inc.
3  *
4  *   Author: Nic Henke <nic@cray.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22 #include "gnilnd.h"
23
24 void
25 _kgnilnd_debug_msg(kgn_msg_t *msg, struct libcfs_debug_msg_data *msgdata,
26                    const char *fmt, ...)
27 {
28         struct va_format vaf;
29         va_list args;
30
31         va_start(args, fmt);
32         vaf.fmt = fmt;
33         vaf.va = &args;
34
35         /* XXX Nic TBD: add handling of gnm_u ? */
36         libcfs_debug_msg(msgdata,
37                          "%pV msg@0x%p m/v/ty/ck/pck/pl %08x/%d/%d/%x/%x/%d x%d:%s\n",
38                          &vaf, msg, msg->gnm_magic, msg->gnm_version,
39                          msg->gnm_type, msg->gnm_cksum, msg->gnm_payload_cksum,
40                          msg->gnm_payload_len, msg->gnm_seq,
41                          kgnilnd_msgtype2str(msg->gnm_type));
42         va_end(args);
43 }
44
45 void
46 _kgnilnd_debug_conn(kgn_conn_t *conn, struct libcfs_debug_msg_data *msgdata,
47                     const char *fmt, ...)
48 {
49         struct va_format vaf;
50         va_list args;
51
52         va_start(args, fmt);
53         vaf.fmt = fmt;
54         vaf.va = &args;
55
56         libcfs_debug_msg(msgdata,
57                          "%pV conn@0x%p->%s:%s cq %u, to %ds,  RX %d @ %lu/%lus; TX %d @ %lus/%lus;  NOOP %lus/%lu/%lus; sched %lus/%lus/%lus ago \n",
58                          &vaf, conn,
59                          conn->gnc_peer ? libcfs_nid2str(conn->gnc_peer->gnp_nid) :
60                          "<?>", kgnilnd_conn_state2str(conn),
61                          conn->gnc_cqid, conn->gnc_timeout,
62                          atomic_read(&conn->gnc_rx_seq),
63                          cfs_duration_sec(jiffies - conn->gnc_last_rx),
64                          cfs_duration_sec(jiffies - conn->gnc_last_rx_cq),
65                          atomic_read(&conn->gnc_tx_seq),
66                          cfs_duration_sec(jiffies - conn->gnc_last_tx),
67                          cfs_duration_sec(jiffies - conn->gnc_last_tx_cq),
68                          cfs_duration_sec(jiffies - conn->gnc_last_noop_want),
69                          cfs_duration_sec(jiffies - conn->gnc_last_noop_sent),
70                          cfs_duration_sec(jiffies - conn->gnc_last_noop_cq),
71                          cfs_duration_sec(jiffies - conn->gnc_last_sched_ask),
72                          cfs_duration_sec(jiffies - conn->gnc_last_sched_do),
73                          cfs_duration_sec(jiffies - conn->gnc_device->gnd_sched_alive));
74         va_end(args);
75 }
76
77 void
78 _kgnilnd_debug_tx(kgn_tx_t *tx, struct libcfs_debug_msg_data *msgdata,
79                   const char *fmt, ...)
80 {
81         kgn_tx_ev_id_t  *id   = &tx->tx_id;
82         char            *nid = "<?>";
83         struct va_format vaf;
84         va_list          args;
85
86         if (tx->tx_conn && tx->tx_conn->gnc_peer) {
87                 nid = libcfs_nid2str(tx->tx_conn->gnc_peer->gnp_nid);
88         }
89
90         va_start(args, fmt);
91         vaf.fmt = fmt;
92         vaf.va = &args;
93
94         libcfs_debug_msg(msgdata,
95                          "%pV tx@0x%p->%s id %#llx/%u/%d:%d msg %x/%s/%d x%d q %s@%lds->0x%p f %x re %d\n",
96                          &vaf, tx, nid, id->txe_cookie, id->txe_smsg_id, id->txe_cqid,
97                          id->txe_idx, tx->tx_msg.gnm_type,
98                          kgnilnd_msgtype2str(tx->tx_msg.gnm_type), tx->tx_buftype,
99                          tx->tx_msg.gnm_seq,
100                          kgnilnd_tx_state2str(tx->tx_list_state),
101                          cfs_duration_sec((long)jiffies - tx->tx_qtime), tx->tx_list_p,
102                          tx->tx_state, tx->tx_retrans);
103         va_end(args);
104 }
105
106 void
107 _kgnilnd_api_rc_lbug(const char* rcstr, int rc, struct libcfs_debug_msg_data *msgdata,
108                         const char *fmt, ...)
109 {
110         struct va_format vaf;
111         va_list args;
112
113         va_start(args, fmt);
114         vaf.fmt = fmt;
115         vaf.va = &args;
116
117         libcfs_debug_msg(msgdata,
118                          "%pV GNI API violated? Unexpected rc %s(%d)!\n",
119                          &vaf, rcstr, rc);
120         va_end(args);
121         LBUG();
122 }