libzpci: Add operational state for netdevs

The operational state is read from sysfs but can later also be updated
via AF_NETLINK.

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>
This commit is contained in:
Niklas Schnelle
2024-10-22 15:13:10 +02:00
committed by Jan Höppner
parent 8704c9c80e
commit e0caed5534
3 changed files with 92 additions and 6 deletions

View File

@@ -30,6 +30,17 @@ enum zpci_pft {
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 */
@@ -57,7 +68,7 @@ struct zpci_dev {
/* Associated netdevs if any */
int num_netdevs;
char **netdevs;
struct zpci_netdev *netdevs;
};
struct util_list *zpci_dev_list(void);
@@ -67,4 +78,7 @@ 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);
#endif /* LIB_ZPCI_PCI_LIST_H */