mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
The opticsmon tool started out as a tool for monitoring the health of optical modules in directly attached PCI NICs. In the future however it will also monitor the health of other PCI devices. In particular in a first step it will monitor the health of directly attached NVMe devices. To reflect this broadening of its scope rename opticsmon to zpcimon. Add zpcimon.service and install it both under the new name and symlinked as opticsmon.service for backwards compatibility. Since users are expected to mostly just enable the service this keeps old instructions just working. 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>
51 lines
1.1 KiB
C
51 lines
1.1 KiB
C
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include "lib/pci_sclp.h"
|
|
#include "lib/util_libc.h"
|
|
|
|
#include "optics_sclp.h"
|
|
|
|
static struct sclp_optics_data *init_sclp_optics_data(struct optics *oi, size_t *length)
|
|
{
|
|
struct sclp_optics_data *od;
|
|
|
|
*length = sizeof(*od) + oi->size;
|
|
od = util_zalloc(*length);
|
|
od->module_present = optics_type(oi) != OPTICS_TYPE_UNKNOWN;
|
|
od->rx_los = optics_rx_los(oi) == OPTICS_LOS;
|
|
od->tx_fault = optics_tx_fault(oi) == OPTICS_LOS;
|
|
switch (optics_type(oi)) {
|
|
case OPTICS_TYPE_SFP:
|
|
od->data_identifier = 1;
|
|
break;
|
|
case OPTICS_TYPE_QSFP28:
|
|
od->data_identifier = 2;
|
|
break;
|
|
default:
|
|
od->data_identifier = 0;
|
|
}
|
|
memcpy(od->data, oi->raw, oi->size);
|
|
|
|
return od;
|
|
}
|
|
|
|
int sclp_issue_optics_report(struct zpci_dev *zdev, struct optics *oi)
|
|
{
|
|
struct sclp_optics_data *od;
|
|
size_t length;
|
|
char *pci_addr;
|
|
int rc;
|
|
|
|
if (zdev->pft != ZPCI_PFT_NETD)
|
|
return -ENOTSUP;
|
|
od = init_sclp_optics_data(oi, &length);
|
|
pci_addr = zpci_pci_addr(zdev);
|
|
rc = zpci_sclp_issue_action(pci_addr, SCLP_ERRNOTIFY_AQ_OPTICS_DATA,
|
|
(char *)od, length, SCLP_ERRNOTIFY_ID_OPTICSMON);
|
|
free(pci_addr);
|
|
free(od);
|
|
return rc;
|
|
}
|