mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
The SCLP Write Event Data Action Qualifier 4 is only available for NVMes with subsystem vendor ID matching IBM. Add both IDs to struct zpci_dev in libzpci. Also add them to the libzpci_example output and adjust its output to multiline to handle more data. 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>
108 lines
2.3 KiB
C
108 lines
2.3 KiB
C
/**
|
|
* @defgroup pci_list_h libzpci: zPCI device handling
|
|
* @{
|
|
* @brief Work with 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_LIST_H
|
|
#define LIB_ZPCI_PCI_LIST_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#include "util_list.h"
|
|
|
|
#define PCI_BDF_LEN 13 /* DDDD:BB:dd.f\0 */
|
|
#define PCI_VENDOR_ID_IBM 0x1014
|
|
|
|
enum zpci_pft {
|
|
ZPCI_PFT_UNCLASSIFIED = 0x00,
|
|
|
|
ZPCI_PFT_ROCE_EXPRESS = 0x02,
|
|
ZPCI_PFT_ROCE_EXPRESS2 = 0x0a,
|
|
ZPCI_PFT_CNW = 0x0d,
|
|
ZPCI_PFT_NETH = 0x0c,
|
|
ZPCI_PFT_NETD = 0x0f,
|
|
|
|
ZPCI_PFT_NVME = 0x0b,
|
|
ZPCI_PFT_ISM = 0x05
|
|
};
|
|
|
|
/*
|
|
* Follows RFC 2863 operational states with the
|
|
* numeric values from IF_OPER_* in linux/if.h:
|
|
*/
|
|
typedef uint8_t operstate_t;
|
|
|
|
struct zpci_netdev {
|
|
char *name;
|
|
operstate_t operstate;
|
|
};
|
|
|
|
struct zpci_dev {
|
|
struct util_list_node entry;
|
|
/* PCI Domain */
|
|
uint32_t domain_nr;
|
|
/* PCI Bus (8 bits), Device (5 bits), Function (3 bits) */
|
|
union {
|
|
uint16_t val;
|
|
struct {
|
|
uint16_t bus : 8;
|
|
uint16_t dev : 5;
|
|
uint16_t fn : 3;
|
|
};
|
|
} bdf;
|
|
|
|
/* Function attributes (see linux/Documentation/arch/s390/pci.rst) */
|
|
uint32_t fid;
|
|
uint32_t uid;
|
|
uint16_t pchid;
|
|
uint16_t vfn;
|
|
uint8_t port;
|
|
enum zpci_pft pft;
|
|
bool uid_is_unique;
|
|
/* Configuration state 0 - Standby, 1 Configured */
|
|
bool conf;
|
|
/* Common PCI attributes */
|
|
uint16_t subsystem_vendor;
|
|
uint16_t subsystem_device;
|
|
|
|
/* Associated netdevs if any */
|
|
int num_netdevs;
|
|
struct zpci_netdev *netdevs;
|
|
};
|
|
|
|
/**
|
|
* Get if a PCI device is a PCI Virtual Function
|
|
*
|
|
* @param[in] zdev The device in question
|
|
*
|
|
* @return true if the device is a VF false otherwise
|
|
*/
|
|
static inline bool zpci_is_vf(struct zpci_dev *zdev)
|
|
{
|
|
return !!zdev->vfn;
|
|
}
|
|
|
|
struct util_list *zpci_dev_list(void);
|
|
void zpci_free_dev_list(struct util_list *zpci_list);
|
|
void zpci_free_dev(struct zpci_dev *zdev);
|
|
|
|
char *zpci_pci_addr(struct zpci_dev *zdev);
|
|
const char *zpci_pft_str(struct zpci_dev *zdev);
|
|
|
|
const char *zpci_operstate_str(operstate_t state);
|
|
operstate_t zpci_operstate_from_str(const char *oper_str);
|
|
|
|
struct zpci_dev *zpci_find_by_netdev(struct util_list *zpci_list, char *netdev_name,
|
|
struct zpci_netdev **netdev);
|
|
|
|
char *zpci_get_nvme_device_node(const char *pci_addr);
|
|
|
|
#endif /* LIB_ZPCI_PCI_LIST_H */
|