xref: /illumos-gate/usr/src/uts/common/sys/ib/clients/rds/rds_kstat.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <sys/kstat.h>
37 
38 struct rds_kstat_s {
39 	kstat_named_t   rds_nports;
40 	kstat_named_t   rds_nsessions;
41 	kstat_named_t   rds_tx_bytes;
42 	kstat_named_t   rds_tx_pkts;
43 	kstat_named_t   rds_tx_errors;
44 	kstat_named_t   rds_rx_bytes;
45 	kstat_named_t   rds_rx_pkts;
46 	kstat_named_t   rds_rx_pkts_pending;
47 	kstat_named_t   rds_rx_errors;
48 	kstat_named_t   rds_tx_acks;
49 	kstat_named_t   rds_post_recv_buf_called;
50 	kstat_named_t   rds_stalls_triggered;
51 	kstat_named_t   rds_stalls_sent;
52 	kstat_named_t   rds_unstalls_triggered;
53 	kstat_named_t   rds_unstalls_sent;
54 	kstat_named_t   rds_stalls_recvd;
55 	kstat_named_t   rds_unstalls_recvd;
56 	kstat_named_t   rds_stalls_ignored;
57 	kstat_named_t   rds_enobufs;
58 	kstat_named_t   rds_ewouldblocks;
59 	kstat_named_t   rds_failovers;
60 	kstat_named_t	rds_port_quota;
61 	kstat_named_t   rds_port_quota_adjusted;
62 };
63 
64 extern void rds_increment_kstat(kstat_named_t *, boolean_t, uint_t);
65 extern void rds_decrement_kstat(kstat_named_t *, boolean_t, uint_t);
66 extern void rds_set_kstat(kstat_named_t *, boolean_t, ulong_t);
67 extern ulong_t rds_get_kstat(kstat_named_t *, boolean_t);
68 
69 extern struct rds_kstat_s  rds_kstat;
70 
71 #define	RDS_SET_NPORT(num) \
72     rds_set_kstat(&rds_kstat.rds_nports, B_TRUE, num)
73 #define	RDS_INCR_NPORT() \
74     rds_increment_kstat(&rds_kstat.rds_nports, B_TRUE, 1)
75 #define	RDS_DECR_NPORT() \
76     rds_decrement_kstat(&rds_kstat.rds_nports, B_TRUE, 1)
77 #define	RDS_GET_NPORT() \
78     rds_get_kstat(&rds_kstat.rds_nports, B_TRUE)
79 
80 #define	RDS_INCR_SESS() \
81     rds_increment_kstat(&rds_kstat.rds_nsessions, B_FALSE, 1)
82 #define	RDS_DECR_SESS()  \
83     rds_decrement_kstat(&rds_kstat.rds_nsessions, B_FALSE, 1)
84 
85 #define	RDS_INCR_TXBYTES(num) \
86     rds_increment_kstat(&rds_kstat.rds_tx_bytes, B_FALSE, num)
87 
88 #define	RDS_INCR_TXPKTS(num) \
89     rds_increment_kstat(&rds_kstat.rds_tx_pkts, B_FALSE, num)
90 
91 #define	RDS_INCR_TXERRS() \
92     rds_increment_kstat(&rds_kstat.rds_tx_errors, B_FALSE, 1)
93 
94 #define	RDS_INCR_RXBYTES(num) \
95     rds_increment_kstat(&rds_kstat.rds_rx_bytes, B_FALSE, num)
96 
97 #define	RDS_INCR_RXPKTS(num) \
98     rds_increment_kstat(&rds_kstat.rds_rx_pkts, B_FALSE, num)
99 
100 #define	RDS_INCR_RXPKTS_PEND(num) \
101     rds_increment_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE, num)
102 #define	RDS_DECR_RXPKTS_PEND(num) \
103     rds_decrement_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE, num)
104 #define	RDS_GET_RXPKTS_PEND() \
105     rds_get_kstat(&rds_kstat.rds_rx_pkts_pending, B_TRUE)
106 
107 #define	RDS_INCR_RXERRS() \
108     rds_increment_kstat(&rds_kstat.rds_rx_errors, B_FALSE, 1)
109 
110 #define	RDS_INCR_TXACKS() \
111     rds_increment_kstat(&rds_kstat.rds_tx_acks, B_FALSE, 1)
112 
113 #define	RDS_INCR_POST_RCV_BUF_CALLS() \
114     rds_increment_kstat(&rds_kstat.rds_post_recv_buf_called, B_FALSE, 1)
115 
116 #define	RDS_INCR_STALLS_TRIGGERED() \
117     rds_increment_kstat(&rds_kstat.rds_stalls_triggered, B_FALSE, 1)
118 
119 #define	RDS_INCR_STALLS_SENT() \
120     rds_increment_kstat(&rds_kstat.rds_stalls_sent, B_FALSE, 1)
121 
122 #define	RDS_INCR_UNSTALLS_TRIGGERED() \
123     rds_increment_kstat(&rds_kstat.rds_unstalls_triggered, B_FALSE, 1)
124 
125 #define	RDS_INCR_UNSTALLS_SENT() \
126     rds_increment_kstat(&rds_kstat.rds_unstalls_sent, B_FALSE, 1)
127 
128 #define	RDS_INCR_STALLS_RCVD() \
129     rds_increment_kstat(&rds_kstat.rds_stalls_recvd, B_FALSE, 1)
130 
131 #define	RDS_INCR_UNSTALLS_RCVD() \
132     rds_increment_kstat(&rds_kstat.rds_unstalls_recvd, B_FALSE, 1)
133 
134 #define	RDS_INCR_STALLS_IGNORED() \
135     rds_increment_kstat(&rds_kstat.rds_stalls_ignored, B_FALSE, 1)
136 
137 #define	RDS_INCR_ENOBUFS() \
138     rds_increment_kstat(&rds_kstat.rds_enobufs, B_FALSE, 1)
139 
140 #define	RDS_INCR_EWOULDBLOCK() \
141     rds_increment_kstat(&rds_kstat.rds_ewouldblocks, B_FALSE, 1)
142 
143 #define	RDS_INCR_FAILOVERS() \
144     rds_increment_kstat(&rds_kstat.rds_failovers, B_FALSE, 1)
145 
146 #define	RDS_SET_PORT_QUOTA(num) \
147     rds_set_kstat(&rds_kstat.rds_port_quota, B_TRUE, num)
148 #define	RDS_GET_PORT_QUOTA() \
149     rds_get_kstat(&rds_kstat.rds_port_quota, B_TRUE)
150 
151 #define	RDS_INCR_PORT_QUOTA_ADJUSTED() \
152     rds_increment_kstat(&rds_kstat.rds_port_quota_adjusted, B_FALSE, 1)
153 
154 
155 #ifdef	__cplusplus
156 }
157 #endif
158 
159 #endif	/* _RDS_KSTAT_H */
160