Whamcloud - gitweb
LU-1419 lnet: Add support for Cray's Gemini interconnect
[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         va_list args;
29
30         va_start(args, fmt);
31         /* XXX Nic TBD: add handling of gnm_u ? */
32         libcfs_debug_vmsg2(msgdata, fmt, args,
33                            " msg@0x%p m/v/ty/ck/pck/pl %08x/%d/%d/%x/%x/%d x%d:%s\n",
34                            msg, msg->gnm_magic, msg->gnm_version, msg->gnm_type,
35                            msg->gnm_cksum, msg->gnm_payload_cksum,
36                            msg->gnm_payload_len, msg->gnm_seq,
37                            kgnilnd_msgtype2str(msg->gnm_type));
38         va_end(args);
39 }
40
41 void
42 _kgnilnd_debug_conn(kgn_conn_t *conn, struct libcfs_debug_msg_data *msgdata,
43                     const char *fmt, ...)
44 {
45         va_list args;
46
47         va_start(args, fmt);
48         libcfs_debug_vmsg2(msgdata, fmt, args,
49                 " conn@0x%p->%s:%s cq %u, to %ds, "
50                 " RX %d @ %lu/%lus; TX %d @ %lus/%lus; "
51                 " NOOP %lus/%lu/%lus; sched %lus/%lus/%lus ago \n",
52                 conn, conn->gnc_peer ? libcfs_nid2str(conn->gnc_peer->gnp_nid) :
53                 "<?>", kgnilnd_conn_state2str(conn),
54                 conn->gnc_cqid, conn->gnc_timeout,
55                 conn->gnc_rx_seq,
56                 cfs_duration_sec(jiffies - conn->gnc_last_rx),
57                 cfs_duration_sec(jiffies - conn->gnc_last_rx_cq),
58                 conn->gnc_tx_seq,
59                 cfs_duration_sec(jiffies - conn->gnc_last_tx),
60                 cfs_duration_sec(jiffies - conn->gnc_last_tx_cq),
61                 cfs_duration_sec(jiffies - conn->gnc_last_noop_want),
62                 cfs_duration_sec(jiffies - conn->gnc_last_noop_sent),
63                 cfs_duration_sec(jiffies - conn->gnc_last_noop_cq),
64                 cfs_duration_sec(jiffies - conn->gnc_last_sched_ask),
65                 cfs_duration_sec(jiffies - conn->gnc_last_sched_do),
66                 cfs_duration_sec(jiffies - conn->gnc_device->gnd_sched_alive));
67
68
69         va_end(args);
70 }
71
72 void
73 _kgnilnd_debug_tx(kgn_tx_t *tx, struct libcfs_debug_msg_data *msgdata,
74                   const char *fmt, ...)
75 {
76         kgn_tx_ev_id_t  *id   = &tx->tx_id;
77         char            *nid = "<?>";
78         va_list          args;
79
80         if (tx->tx_conn && tx->tx_conn->gnc_peer) {
81                 nid = libcfs_nid2str(tx->tx_conn->gnc_peer->gnp_nid);
82         }
83
84         va_start(args, fmt);
85         libcfs_debug_vmsg2(msgdata, fmt, args,
86                 " tx@0x%p->%s id "LPX64"/%u/%d:%d msg %x/%s/%d q %s@%lds->0x%p f %x re %d\n",
87                 tx, nid, id->txe_cookie, id->txe_smsg_id, id->txe_cqid,
88                 id->txe_idx, tx->tx_msg.gnm_type,
89                 kgnilnd_msgtype2str(tx->tx_msg.gnm_type), tx->tx_buftype,
90                 kgnilnd_tx_state2str(tx->tx_list_state),
91                 cfs_duration_sec((long)jiffies - tx->tx_qtime), tx->tx_list_p,
92                 tx->tx_state, tx->tx_retrans);
93         va_end(args);
94 }
95
96 void
97 _kgnilnd_api_rc_lbug(const char* rcstr, int rc, struct libcfs_debug_msg_data *msgdata,
98                         const char *fmt, ...)
99 {
100         va_list args;
101
102         va_start(args, fmt);
103         libcfs_debug_vmsg2(msgdata, fmt, args,
104                            " GNI API violated? Unexpected rc %s(%d)!\n",
105                            rcstr, rc);
106         va_end(args);
107         LBUG();
108 }