xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/rds/rds_kstat.h (revision 2d6eb4a5e0a47d30189497241345dc5466bb68ab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_RDS_KSTAT_H
27 #define	_RDS_KSTAT_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <sys/kstat.h>
35 
36 struct rds_kstat_s {
37 	kstat_named_t   rds_nports;
38 	kstat_named_t   rds_nsessions;
39 	kstat_named_t   rds_tx_bytes;
40 	kstat_named_t   rds_tx_pkts;
41 	kstat_named_t   rds_tx_errors;
42 	kstat_named_t   rds_rx_bytes;
43 	kstat_named_t   rds_rx_pkts;
44 	kstat_named_t   rds_rx_pkts_pending;
45 	kstat_named_t   rds_rx_errors;
46 	kstat_named_t   rds_tx_acks;
47 	kstat_named_t   rds_post_recv_buf_called;
48 	kstat_named_t   rds_stalls_triggered;
49 	kstat_named_t   rds_stalls_sent;
50 	kstat_named_t   rds_unstalls_triggered;
51 	kstat_named_t   rds_unstalls_sent;
52 	kstat_named_t   rds_stalls_recvd;
53 	kstat_named_t   rds_unstalls_recvd;
54 	kstat_named_t   rds_stalls_ignored;
55 	kstat_named_t   rds_enobufs;
56 	kstat_named_t   rds_ewouldblocks;
57 	kstat_named_t   rds_failovers;
58 	kstat_named_t	rds_port_quota;
59 	kstat_named_t   rds_port_quota_adjusted;
60 };
61 
62 extern void rds_increment_kstat(kstat_named_t *, boolean_t, uint_t);
63 extern void rds_decrement_kstat(kstat_named_t *, boolean_t, uint_t);
64 extern void rds_set_kstat(kstat_named_t *, boolean_t, ulong_t);
65 extern ulong_t rds_get_kstat(kstat_named_t *, boolean_t);
66 
67 extern struct rds_kstat_s  rds_kstat;
68 
69 #define	RDS_SET_NPORT(num) \
70     rds_set_kstat(&rds_kstat.rds_nports, B_TRUE, num)
71 #define	RDS_INCR_NPORT() \
72     rds_increment_kstat(&rds_kstat.rds_nports, B_TRUE, 1)
73 #define	RDS_DECR_NPORT() \
74     rds_decrement_kstat(&rds_kstat.rds_nports, B_TRUE, 1)
75 #define	RDS_GET_NPORT() \
76     rds_get_kstat(&rds_kstat.rds_nports, B_TRUE)
77 
78 #define	RDS_INCR_SESS() \
79     rds_increment_kstat(&rds_kstat.rds_nsessions, B_FALSE, 1)
80 #define	RDS_DECR_SESS()  \
81     rds_decrement_kstat(&rds_kstat.rds_nsessions, B_FALSE, 1)
82 
83 #define	RDS_INCR_TXBYTES(num) \
84     rds_increment_kstat(&rds_kstat.rds_tx_bytes, B_FALSE, num)
85 
86 #define	RDS_INCR_TXPKTS(num) \
87     rds_increment_kstat(&rds_kstat.rds_tx_pkts, B_FALSE, num)
88 
89 #define	RDS_INCR_TXERRS() \
90     rds_increment_kstat(&rds_kstat.rds_tx_errors, B_FALSE, 1)
91 
92 #define	RDS_INCR_RXBYTES(num) \
93     rds_increment_kstat(&rds_kstat.rds_rx_bytes, B_FALSE, num)
94 
95 #define	RDS_INCR_RXPKTS(num) \
96     rds_increment_kstat(&rds_kstat.rds_rx_pkts, B_FALSE, num)
97 
98 #define	RDS_INCR_RXPKTS_PEND(num) \
99     rds_increment_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE, num)
100 #define	RDS_DECR_RXPKTS_PEND(num) \
101     rds_decrement_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE, num)
102 #define	RDS_GET_RXPKTS_PEND() \
103     rds_get_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE)
104 
105 #define	RDS_INCR_RXERRS() \
106     rds_increment_kstat(&rds_kstat.rds_rx_errors, B_FALSE, 1)
107 
108 #define	RDS_INCR_TXACKS() \
109     rds_increment_kstat(&rds_kstat.rds_tx_acks, B_FALSE, 1)
110 
111 #define	RDS_INCR_POST_RCV_BUF_CALLS() \
112     rds_increment_kstat(&rds_kstat.rds_post_recv_buf_called, B_FALSE, 1)
113 
114 #define	RDS_INCR_STALLS_TRIGGERED() \
115     rds_increment_kstat(&rds_kstat.rds_stalls_triggered, B_FALSE, 1)
116 
117 #define	RDS_INCR_STALLS_SENT() \
118     rds_increment_kstat(&rds_kstat.rds_stalls_sent, B_FALSE, 1)
119 
120 #define	RDS_INCR_UNSTALLS_TRIGGERED() \
121     rds_increment_kstat(&rds_kstat.rds_unstalls_triggered, B_FALSE, 1)
122 
123 #define	RDS_INCR_UNSTALLS_SENT() \
124     rds_increment_kstat(&rds_kstat.rds_unstalls_sent, B_FALSE, 1)
125 
126 #define	RDS_INCR_STALLS_RCVD() \
127     rds_increment_kstat(&rds_kstat.rds_stalls_recvd, B_FALSE, 1)
128 
129 #define	RDS_INCR_UNSTALLS_RCVD() \
130     rds_increment_kstat(&rds_kstat.rds_unstalls_recvd, B_FALSE, 1)
131 
132 #define	RDS_INCR_STALLS_IGNORED() \
133     rds_increment_kstat(&rds_kstat.rds_stalls_ignored, B_FALSE, 1)
134 
135 #define	RDS_INCR_ENOBUFS() \
136     rds_increment_kstat(&rds_kstat.rds_enobufs, B_FALSE, 1)
137 
138 #define	RDS_INCR_EWOULDBLOCK() \
139     rds_increment_kstat(&rds_kstat.rds_ewouldblocks, B_FALSE, 1)
140 
141 #define	RDS_INCR_FAILOVERS() \
142     rds_increment_kstat(&rds_kstat.rds_failovers, B_FALSE, 1)
143 
144 #define	RDS_SET_PORT_QUOTA(num) \
145     rds_set_kstat(&rds_kstat.rds_port_quota, B_TRUE, num)
146 #define	RDS_GET_PORT_QUOTA() \
147     rds_get_kstat(&rds_kstat.rds_port_quota, B_TRUE)
148 
149 #define	RDS_INCR_PORT_QUOTA_ADJUSTED() \
150     rds_increment_kstat(&rds_kstat.rds_port_quota_adjusted, B_FALSE, 1)
151 
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif	/* _RDS_KSTAT_H */
158