Files
s390-tools/include/lib/pci_sclp.h
Niklas Schnelle c34adb9cab opticsmon: Introduce opticsmon tool
The optics monitoring tool opticsmon implements the user-space portion
of reporting optics data to the SE. Its basic functionality is to
collect optical module information equivalent to "ethtool --module-info"
for PCI Physical Functions and forwards this data to the SE using the
new SCLP Write Event Data Action Qualifier 3.

For the part of finding all PFs we need to look at all PCI
functions and determine which ones are PFs and what netdevs they
correspond to. This is a generally useful functionality so this part as
well as the SCLP issuing code go into a new libzpci library which also
includes a standalone example for listing PCI functions and their s390x
specific attributes. Medium term we plan to add this functionality to
lszdev.

For the opticsmon tool itself there are 2 basic operating modes:

* One-shot Mode: Without parameters opticsmon collects optical module
  data and prints a summary of the netdevice in JSON format. With
  --module-data it also includes a base64 encoded raw dump equivalent to
  ethtool --module-info <netdev> raw on.
* Monitor Mode: With the --monitor flag opticsmon runs continuously
  usually started via a systemd unit and collects new optical module
  data on a time interval (default 24h) or when the operational state
  ("/sys/class/net/<netdev/operstate") changes. The tool listens for
  changes via netlink so no polling on sysfs is necessary

Note: Both modes will *NOT* issues SCLPs without adding the
--send-report flag but will output a JSON summary for each data
collection so can be tested without firmware impact.

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2024-12-06 10:57:34 +01:00

57 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @defgroup pci_sclp_h libzpci: zPCI device handling
* @{
* @brief Issue SCLPs for zPCI devices
*
* 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 LIB_ZPCI_PCI_SCLP_H
#define LIB_ZPCI_PCI_SCLP_H
#include <linux/types.h>
#include <stddef.h>
#include "lib/zt_common.h"
#define SCLP_ERRNOTIFY_AQ_RESET 0
#define SCLP_ERRNOTIFY_AQ_DECONF 1
#define SCLP_ERRNOTIFY_AQ_REPORT_ERR 2
#define SCLP_ERRNOTIFY_AQ_OPTICS_DATA 3
#define SCLP_ERRNOTIFY_ID_ZPCICTL 0x4713
#define SCLP_ERRNOTIFY_ID_OPTICSMON 0x4714
#define SCLP_ERRNOTIFY_DATA_SIZE 4054
struct zpci_report_error_header {
__u8 version; /* Interface version byte */
__u8 action; /* Action qualifier byte
* 0: Adapter Reset Request
* 1: Deconfigure and repair action requested
* 2: Informational Report
* 3: Optics Data
*/
__u16 length; /* Length of Subsequent Data (up to 4K SCLP header) */
} __packed;
struct zpci_report_error_data {
__u64 timestamp;
__u64 err_log_id;
/* We cannot exceed a total of 4074 bytes (header + data) */
char log_data[SCLP_ERRNOTIFY_DATA_SIZE];
} __packed;
struct zpci_report_error {
struct zpci_report_error_header header;
struct zpci_report_error_data data;
} __packed;
int zpci_sclp_issue_action(char *pci_addr, int action,
char *data, size_t length, u64 err_log_id);
#endif /* LIB_ZPCI_PCI_SCLP_H */