44 #include <sys/types.h> 48 #include <sys/ioctl.h> 50 #include <linux/ethtool.h> 51 #include <linux/sockios.h> 87 "Address",
"Sock",
"VID:PID",
"Link Speed",
"Driver",
88 "Product Name",
"Vital Product Data");
93 if (d->device_class != PCI_CLASS_NETWORK_ETHERNET && !show_all)
98 if (d->numa_node >= 0)
99 s = format (s,
" %d", d->numa_node);
101 vlib_cli_output (vm,
"%-13U%-5v%04x:%04x %-13U%-16s%-32v%U",
102 format_vlib_pci_addr, &d->bus_address, s,
103 d->vendor_id, d->device_id,
104 format_vlib_pci_link_speed, d,
105 d->driver_name ? (char *) d->driver_name :
"",
107 format_vlib_pci_vpd, d->vpd_r, 0);
118 vlib_pci_addr_t *
addr = va_arg (*args, vlib_pci_addr_t *);
121 if (!
unformat (input,
"%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
127 addr->function = x[3];
135 vlib_pci_addr_t *
addr = va_arg (*va, vlib_pci_addr_t *);
136 return format (s,
"%04x:%02x:%02x.%x", addr->domain, addr->bus,
137 addr->slot, addr->function);
143 vlib_pci_addr_t *
addr = va_arg (*va, vlib_pci_addr_t *);
144 return format (s,
"%x/%x/%x", addr->bus, addr->slot, addr->function);
151 pcie_config_regs_t *r =
156 return format (s,
"unknown");
158 width = (r->link_status >> 4) & 0x3f;
160 if ((r->link_status & 0xf) == 1)
161 return format (s,
"2.5 GT/s x%u", width);
162 if ((r->link_status & 0xf) == 2)
163 return format (s,
"5.0 GT/s x%u", width);
164 if ((r->link_status & 0xf) == 3)
165 return format (s,
"8.0 GT/s x%u", width);
166 return format (s,
"unknown");
172 u8 *data = va_arg (*args,
u8 *);
173 u8 *
id = va_arg (*args,
u8 *);
175 char *string_types[] = {
"PN",
"EC",
"SN",
"MN", 0 };
185 if (data[p] == 0 && data[p + 1] == 0)
188 if (p + data[p + 2] >
vec_len (data))
194 char **
c = string_types;
198 if (*(
u16 *) & data[p] == *(
u16 *) c[0])
213 s =
format (s,
"%c%c: ", data[p], data[p + 1]);
215 vec_add (s, data + p + 3, data[p + 2]);
219 const int max_bytes = 8;
221 for (i = 0; i <
clib_min (data[p + 2], max_bytes); i++)
222 s =
format (s,
" %02x", data[p + 3 + i]);
224 if (data[p + 2] > max_bytes)
229 else if (*(
u16 *) & data[p] == *(
u16 *)
id)
231 vec_add (s, data + p + 3, data[p + 2]);
235 p += 3 + data[p + 2];
245 .short_help =
"show pci [all]",
sll srl srl sll sra u16x4 i
clib_error_t * pci_bus_init(vlib_main_t *vm)
static void * pci_config_find_capability(pci_config_type0_regs_t *t, int cap_type)
u8 * format_vlib_pci_link_speed(u8 *s, va_list *va)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
uword * pci_dev_index_by_pci_addr
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
vlib_pci_device_t * pci_devs
static clib_error_t * show_pci_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_vlib_pci_addr(unformat_input_t *input, va_list *args)
#define vec_free(V)
Free vector's memory (no header).
u8 * format_vlib_pci_vpd(u8 *s, va_list *args)
#define VLIB_CLI_COMMAND(x,...)
pci_config_type0_regs_t config0
u8 * format_vlib_pci_addr(u8 *s, va_list *va)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u8 * format_vlib_pci_handle(u8 *s, va_list *va)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
vlib_pci_device_t * vlib_get_pci_device(vlib_pci_addr_t *addr)