Files
s390-tools/zconf/chp/chpstat/cmg_helper.h
T
Peter Oberparleiter cb77faeae7 chpstat: add tool to display channel-path statistics
Add a new tool named chpstat that can be used to view channel-path
statistics such as utilization and I/O throughput, and to query and
control the status of the channel-path statistics function.

Note: Channel-path statistics are only available on systems running in
      an LPAR or DPM partition.

When run without further options, data for all channel-paths is
displayed repeatedly with a 5 second delay in table format.

Example output:

      CHANNEL-PATH       UTILIZATION(%)   READ(B/s)  WRITE(B/s)
  ID TYP CMG SHR SPEED  PART TOTAL  BUS  PART TOTAL  PART TOTAL
  1d  25   2   1     -  7.16  7.50 7.50  129M  129M  0.00  161K
  21  1b   2   1   32G  0.00  0.00 0.00  0.00  0.00  0.00  0.00
  34  1b   2   1   32G  0.00  0.00 0.00  0.00  0.00  0.00  0.00
  61  25   2   1     -  0.00  0.01 0.00  0.00 2.00K  0.00  307K
  63  25   2   1     -  0.00  0.01 0.00  0.00  0.00  0.00  381K
  bd  11   2   1   10G     -     -    - 529.8 532.1 616.3 616.3

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
2024-05-27 16:52:27 +02:00

82 lines
2.5 KiB
C

/*
* Helper functions for implementing CMG types
*
* Copyright IBM Corp. 2024
*
* s390-tools is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifndef CMG_HELPER_H
#define CMG_HELPER_H
#include <stdbool.h>
#include "cmg.h"
#include "column.h"
#include "lib/util_base.h"
/* Duration of channel-path measurement timestamp tick. */
#define CM_TICK ((double)0.000128)
/* Initialization value for metrics fields. */
#define METRICS_INIT -1.0
/* Check whether member @field of struct @s is valid according to s->cuiv. */
#define cue_valid(s, field) \
(_cue_valid((s)->cuiv, offsetof(__typeof__(*s), field)))
/* Check whether member @field of struct @a and @b is valid according to
* a->cuiv and b->cuiv. */
#define cue_valid2(a, b, field) \
((_cue_valid((a)->cuiv, offsetof(__typeof__(*a), field))) && \
(_cue_valid((b)->cuiv, offsetof(__typeof__(*b), field))))
#define field_delta(field, a, b) \
get_delta((a)->field, (b)->field, 32)
#define field_delta64(field, a, b) \
get_delta64((a)->field, (b)->field, 64)
#define pr_u32(a, n, s, field) \
_pr_u32((a), (n), true, STRINGIFY(field), COL_NONE, CMG_NUMBER, \
(s)->field)
#define pr_cond_u32(a, n, v, s, field) \
_pr_u32((a), (n), (v), STRINGIFY(field), COL_NONE, CMG_NUMBER, \
(s)->field)
#define pr_cue_u32(a, n, s, field) \
pr_cond_u32(a, n, cue_valid(s, field), s, field)
#define pr_u64(a, n, s, field) \
_pr_u64((a), (n), true, STRINGIFY(field), COL_NONE, CMG_NUMBER, \
(s)->field)
#define pr_cond_u64(a, n, v, s, field) \
_pr_u64((a), (n), (v), STRINGIFY(field), COL_NONE, CMG_NUMBER, \
(s)->field)
/* pr_metric(array_ptr, num_ptr, struct, field, unit, column_id) */
#define pr_metric(a, n, s, field, u, c) \
_pr_double((a), (n), ((s)->field != METRICS_INIT), STRINGIFY(field), \
c, u, (s)->field)
double tick_to_s(u32 t);
u32 get_delta(u32 last, u32 curr, int width);
u64 get_delta64(u64 last, u64 curr, int width);
bool _cue_valid(u8 cuiv, int offset);
void _pr_u32(struct cmg_pair_t **a, unsigned int *n, bool valid,
const char *key, enum column_id_t col, enum cmg_unit_t unit,
u32 value);
void _pr_u64(struct cmg_pair_t **a, unsigned int *n, bool valid,
const char *key, enum column_id_t col, enum cmg_unit_t unit,
u64 value);
void _pr_double(struct cmg_pair_t **a, unsigned int *n, bool valid,
const char *key, enum column_id_t col, enum cmg_unit_t unit,
double value);
#endif /* CMG_HELPER_H */