Files
s390-tools/zpcimon/zpcimon.h
Niklas Schnelle 113e9ebfef zpcimon: Split optics monitoring out into separate monitor
Introduce the concept of a generic zPCI device monitor by creating the
zpcimon_ops operations struct turning all optics specific calls into
abstract monitor calls. Handle monitors as a static array of zpcimon_ops
based monitors of which the now split out optics monitor is currently
the only one. All operations are in principle optional though a monitor
which provides an init operation must also provide the corresponding
destroy operation.

Keep the base64 based JSON pair as non optics specific for later re-use
and make it just skip the output in the very unlikely case that encoding
fails. In follow on commits a monitor for NVMe devices collecting SMART
data will be added.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2026-07-24 18:21:50 +02:00

53 lines
1.2 KiB
C

/*
* 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 ZPCIMON_ZPCIMON_H
#define ZPCIMON_ZPCIMON_H
#include <stdbool.h>
#include <stdint.h>
#include "lib/util_fmt.h"
#include "opticsmon.h"
#define API_LEVEL 1
struct options {
uint32_t interval_seconds;
bool monitor;
bool report;
bool quiet;
enum util_fmt_t format;
bool explicit_format;
/* Optics Monitoring Specific */
bool module_info;
};
struct zpcimon_ctx {
struct options opts;
struct util_list *zpci_list;
struct opticsmon_ctx opticsmon_ctx;
};
struct zpcimon_ops {
int (*collect_adapter_data)(struct zpcimon_ctx *ctx, struct zpci_dev *zdev);
int (*open_monitor)(struct zpcimon_ctx *ctx);
int (*get_monitor_fd)(struct zpcimon_ctx *ctx);
void (*monitor_fd_handle)(struct zpcimon_ctx *ctx);
void (*close_monitor)(struct zpcimon_ctx *ctx);
int (*init)(struct zpcimon_ctx *ctx);
void (*destroy)(struct zpcimon_ctx *ctx);
};
void zpci_list_reload(struct util_list **zpci_list);
void zpcimon_json_base64_pair(char *name, uint8_t *buf, int len);
#endif /* ZPCIMON_ZPCIMON_H */