[go: up one dir, main page]

File: ziomon_util.h

package info (click to toggle)
s390-tools 1.16.0-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,332 kB
  • sloc: ansic: 46,620; sh: 8,560; cpp: 8,185; asm: 5,503; perl: 3,014; makefile: 886
file content (111 lines) | stat: -rw-r--r-- 3,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 * FCP adapter trace utility
 *
 * Utilization data collector for zfcp adapters
 *
 * Copyright IBM Corp. 2008
 * Author(s): Stefan Raspl <raspl@linux.vnet.ibm.com>
 */

#ifndef ZIOMON_UTIL_H
#define ZIOMON_UTIL_H

#include <linux/types.h>
#include <endian.h>

#include "ziomon_tools.h"


struct utilization_stats {
	__u64			count;
	struct abbrev_stat 	adapter; /* adapter utilization in percent */
	struct abbrev_stat 	bus;     /* bus utilization in percent */
	struct abbrev_stat 	cpu;     /* cpu utilization in percent */
	__u64			queue_util_integral; /* integral of the queue
					utilization over microseconds */
	__u64			queue_util_interval; /* interval length
							in microseconds */
	__u32			queue_full;	/* number of queue_full
				   instances within the given timeframe */
} __attribute__ ((packed));

struct adapter_utilization {
	struct utilization_stats	stats;
	__u32				adapter_no;	/* device identifier */
	__u16				valid;	/* ==0 in case the result is invalid */
} __attribute__ ((packed));

/** Note that this message will always be transmitted in first and final
 * interval. Inbetween, only messages with actual traffic will be transmitted.
 */
struct utilization_data {
	__u64				timestamp;
	__u16				num_adapters;
	struct adapter_utilization	adapt_utils[0];
} __attribute__ ((packed));

struct hctl_ident {
	__u32			host;	/* device identifier (1) */
	__u32			channel;/* device identifier (2) */
	__u32			target;	/* device identifier (3) */
	__u32			lun;	/* device identifier (4) */
} __attribute__ ((packed));

/**
 * Returns <0 if src is 'smaller' than tgt, >0 of 'larger' and 0 if identical.
 */
int compare_hctl_idents(const struct hctl_ident *src,
			const struct hctl_ident *tgt);

struct ioerr_cnt {
	struct hctl_ident	identifier;
	__u32			num_ioerr; /* number of io errors
						within timeframe */
} __attribute__ ((packed));

/* Note that this message will always be transmitted in first and final
 * interval. Inbetween, only messages with actual traffic will be transmitted.
 */
struct ioerr_data {
	__u64			timestamp;
	__u64			num_luns;
	struct ioerr_cnt 	ioerrors[0];	/* number of I/O errors
	                                     within the given timeframe */
} __attribute__ ((packed));


void print_utilization_result(struct utilization_data *res);

void conv_overall_result_to_BE(struct utilization_data *res);

void conv_overall_result_from_BE(struct utilization_data *res);

/**
 * Aggregate a complete utilization result with all included structures */
void aggregate_utilization_data(const struct utilization_data *src,
				struct utilization_data *tgt);

/**
 * Aggregate a result for a single adapter only */
void aggregate_adapter_result(const struct adapter_utilization *src,
			      struct adapter_utilization *tgt);

void print_ioerr_data(struct ioerr_data *data);

void conv_ioerr_data_to_BE(struct ioerr_data *data);

void conv_ioerr_data_from_BE(struct ioerr_data *data);

/**
 * src must be later data than target! We assume that both structs have
 * data for the same LUNs in the same sequence.
 */
void aggregate_ioerr_data(const struct ioerr_data *src, struct ioerr_data *tgt);

/**
 * Aggregate data for a single device only */
void aggregate_ioerr_cnt(const struct ioerr_cnt *src, struct ioerr_cnt *tgt);


#endif