2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 /* Some Cheap statistics which should be shared with the rxkad definitions, but
11 * aren't. The layout should match the layout in rxkad/rxkad.p.h. */
13 #ifndef OPENAFS_DES_STATS_H
14 #define OPENAFS_DES_STATS_H
17 /* this is an optimization for pthreads environments. Instead of having global
18 rxkad statistics, make them thread-specific, and only perform aggregation on
19 the stats structures when necessary. Furthermore, don't do any locking, and
20 live with the nearly accurate aggregation (e.g. you might miss a few increments,
21 but the resulting aggregation should be almost correct). */
23 #ifdef AFS_PTHREAD_ENV
24 typedef struct rxkad_stats_t {
28 afs_uint32 connections[3]; /* client side only */
29 afs_uint32 destroyObject; /* client security objects */
30 afs_uint32 destroyClient; /* client connections */
31 afs_uint32 destroyUnused; /* unused server conn */
32 afs_uint32 destroyUnauth; /* unauthenticated server conn */
33 afs_uint32 destroyConn[3]; /* server conn per level */
34 afs_uint32 expired; /* server packets rejected */
35 afs_uint32 challengesSent; /* server challenges sent */
36 afs_uint32 challenges[3]; /* challenges seen by client */
37 afs_uint32 responses[3]; /* responses seen by server */
38 afs_uint32 preparePackets[6];
39 afs_uint32 checkPackets[6];
40 afs_uint32 bytesEncrypted[2]; /* index just by type */
41 afs_uint32 bytesDecrypted[2];
42 afs_uint32 fc_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */
43 afs_uint32 fc_key_scheds; /* key schedule creations */
44 afs_uint32 des_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */
45 afs_uint32 des_key_scheds; /* key schedule creations */
46 afs_uint32 des_randoms; /* random blocks generated */
47 afs_uint32 clientObjects;
48 afs_uint32 serverObjects;
50 #ifdef AFS_PTHREAD_ENV
51 struct rxkad_stats_t * next;
52 struct rxkad_stats_t * prev;
53 } rxkad_stats_t; /* put these here for convenience */
54 #else /* AFS_PTHREAD_ENV */
55 } rxkad_stats; /* put these here for convenience */
56 #endif /* AFS_PTHREAD_ENV */
59 #ifdef AFS_PTHREAD_ENV
60 struct rxkad_global_stats {
61 rxkad_stats_t * first;
67 extern pthread_mutex_t rxkad_global_stats_lock;
68 extern pthread_key_t rxkad_stats_key;
70 extern void rxkad_global_stats_init();
71 extern rxkad_stats_t * rxkad_thr_stats_init();
72 extern int rxkad_stats_agg(rxkad_stats_t *);
76 #define END } while(0)
78 #define RXKAD_GLOBAL_STATS_LOCK assert(pthread_mutex_lock(&rxkad_global_stats_lock)==0)
79 #define RXKAD_GLOBAL_STATS_UNLOCK assert(pthread_mutex_unlock(&rxkad_global_stats_lock)==0)
80 #define GET_RXKAD_STATS(stats) rxkad_stats_agg(stats)
81 #define GET_RXKAD_THR_STATS(rxkad_stats) \
83 (rxkad_stats) = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \
84 if ((rxkad_stats) == NULL) { \
85 assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \
88 #define INC_RXKAD_STATS(stats_elem) \
90 rxkad_stats_t * rxkad_stats; \
91 rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \
92 if (rxkad_stats == NULL) { \
93 assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \
95 rxkad_stats->stats_elem++; \
97 #define DEC_RXKAD_STATS(stats_elem) \
99 rxkad_stats_t * rxkad_stats; \
100 rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \
101 if (rxkad_stats == NULL) { \
102 assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \
104 rxkad_stats->stats_elem--; \
106 #define ADD_RXKAD_STATS(stats_elem, inc_value) \
108 rxkad_stats_t * rxkad_stats; \
109 rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \
110 if (rxkad_stats == NULL) { \
111 assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \
113 rxkad_stats->stats_elem += inc_value; \
115 #define SUB_RXKAD_STATS(stats_elem, dec_value) \
117 rxkad_stats_t * rxkad_stats; \
118 rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \
119 if (rxkad_stats == NULL) { \
120 assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \
122 rxkad_stats->stats_elem -= dec_value; \
124 #else /* AFS_PTHREAD_ENV */
125 #define INC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem++
126 #define DEC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem--
127 #define ADD_RXKAD_STATS(stats_elem, inc_value) rxkad_stats.stats_elem += (inc_value)
128 #define SUB_RXKAD_STATS(stats_elem, dec_value) rxkad_stats.stats_elem -= (dec_value)
129 #define GET_RXKAD_STATS(stats) memcpy((stats), &rxkad_stats, sizeof(rxkad_stats))
130 #endif /* AFS_PTHREAD_ENV */
133 #if defined(AFS_NT40_ENV) && defined(AFS_PTHREAD_ENV)
134 #ifndef RXKAD_STATS_DECLSPEC
135 #define RXKAD_STATS_DECLSPEC __declspec(dllimport) extern
138 #define RXKAD_STATS_DECLSPEC extern
141 #ifdef AFS_PTHREAD_ENV
142 RXKAD_STATS_DECLSPEC struct rxkad_global_stats rxkad_global_stats;
143 #else /* AFS_PTHREAD_ENV */
144 RXKAD_STATS_DECLSPEC struct rxkad_stats rxkad_stats;
148 #endif /* OPENAFS_DES_STATS_H */