summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Kinsella <mdr@ashroe.eu>2021-11-02 13:26:49 +0000
committerDamjan Marion <dmarion@me.com>2021-11-02 22:25:40 +0000
commit6efe025ce58c092e513e1f7f10556a3fa394438d (patch)
tree847947e14960a036b958417433d2f1417190aae6 /src
parent4b1e76b8e6f8d9ae7a3455402e4cb179b693a925 (diff)
vlib: add format pci link port
Added a function to nicely format pci link ports. Similar to the existing link_speed etc format functions. Type: improvement Signed-off-by: Ray Kinsella <mdr@ashroe.eu> Change-Id: Ic1f104e0cb34dad274f6c959e776a32c0bab697d
Diffstat (limited to 'src')
-rw-r--r--src/vlib/pci/pci.c13
-rw-r--r--src/vlib/pci/pci.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/vlib/pci/pci.c b/src/vlib/pci/pci.c
index 1c1f4b636f5..18d93acbf08 100644
--- a/src/vlib/pci/pci.c
+++ b/src/vlib/pci/pci.c
@@ -143,6 +143,19 @@ format_vlib_pci_addr (u8 * s, va_list * va)
}
u8 *
+format_vlib_pci_link_port (u8 *s, va_list *va)
+{
+ vlib_pci_device_info_t *d = va_arg (*va, vlib_pci_device_info_t *);
+ pcie_config_regs_t *r =
+ pci_config_find_capability (&d->config0, PCI_CAP_ID_PCIE);
+
+ if (!r)
+ return format (s, "unknown");
+
+ return format (s, "P%d", r->link_status >> 24);
+}
+
+u8 *
format_vlib_pci_link_speed (u8 * s, va_list * va)
{
vlib_pci_device_info_t *d = va_arg (*va, vlib_pci_device_info_t *);
diff --git a/src/vlib/pci/pci.h b/src/vlib/pci/pci.h
index 5aae597f825..01f7d5b9669 100644
--- a/src/vlib/pci/pci.h
+++ b/src/vlib/pci/pci.h
@@ -325,6 +325,7 @@ int vlib_pci_supports_virtual_addr_dma (vlib_main_t * vm,
unformat_function_t unformat_vlib_pci_addr;
format_function_t format_vlib_pci_addr;
format_function_t format_vlib_pci_link_speed;
+format_function_t format_vlib_pci_link_port;
format_function_t format_vlib_pci_vpd;
#endif /* included_vlib_pci_h */