查询网卡属性小tips
ip a 结果里找到目标网口,以enp11s0f1为例
//截取出来的 ip a 中指定网口的输出
4: enp11s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether 00:07:3e:9d:6f:4e brd ff:ff:ff:ff:ff:ff
ethtool可以用来查询网卡相关的信息,比如ethtool -i enp11s0f1可以查询到网卡使用的驱动名称、驱动版本、固件版本,ethtool -k enp11s0f1可查到网卡当前支持的各类功能比如gso、lro等等。
通过lspci可获得enp11s0f1的pci地址,网口名也可以直接拼凑出pci地址。
以enp11s0f1为例,11是总线编号,0是设备编号,1是功能号。这三个值对应到pci地址里为11:0.1(十进制的值),换成16进制即0b:00.1。这里的pci地址省略了前面的全零0000,代表pci域信息。完整的pci地址应为:0000:0b:00.1,与lspci查询到的地址相同。
[root@localhost ~]# lspci -vnn | grep -i ethernet
... ...
0b:00.0 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
0b:00.1 Ethernet controller [0200]: Intel Corporation I350 Gigabit Network Connection [8086:1521] (rev 01)
[root@localhost ~]#
拿到pci地址后,可在以下两个目录里查看相关信息:
1、 /sys/class/net/enp11s0f1/,/sys/class/下有dma、gpio、mem、nvme等等类别,这是以设备功能类型对系统内设备进行分层。
2、 /sys/bus/pci/devices/0000:0b:00.1/,/sys/bus下有i2c、scsi、usb等等类型,这是以设备所处的总线类型对系统内设备进行分层。
以上两个路径,指向的是相同的设备对象:
[root@localhost ~]# ls /sys/bus/pci/devices/0000\:0b\:00.1/net/enp11s0f1/
addr_assign_type broadcast carrier_down_count dev_id duplex ifalias link_mode netdev_group phys_port_name proto_down statistics type
address carrier carrier_up_count dev_port flags ifindex mtu operstate phys_switch_id queues subsystem uevent
addr_len carrier_changes device dormant gro_flush_timeout iflink name_assign_type phys_port_id power speed tx_queue_len
[root@localhost ~]# ls /sys/class/net/enp11s0f1/
addr_assign_type broadcast carrier_down_count dev_id duplex ifalias link_mode netdev_group phys_port_name proto_down statistics type
address carrier carrier_up_count dev_port flags ifindex mtu operstate phys_switch_id queues subsystem uevent
addr_len carrier_changes device dormant gro_flush_timeout iflink name_assign_type phys_port_id power speed tx_queue_len
[root@localhost ~]# //以上两个目录内容相等
[root@localhost ~]#
[root@localhost ~]# ls /sys/class/net/enp11s0f1/device/
aer_dev_correctable class d3cold_allowed driver_override local_cpus msi_irqs remove resource2 sriov_offset subsystem_device
aer_dev_fatal config device enable max_link_speed net rescan resource3 sriov_stride subsystem_vendor
aer_dev_nonfatal consistent_dma_mask_bits devspec i2c-4 max_link_width numa_node reset revision sriov_totalvfs uevent
ari_enabled current_link_speed dma_mask_bits irq modalias power resource sriov_drivers_autoprobe sriov_vf_device vendor
broken_parity_status current_link_width driver local_cpulist msi_bus ptp resource0 sriov_numvfs subsystem
[root@localhost ~]# ls /sys/bus/pci/devices/0000\:0b\:00.1/
aer_dev_correctable class d3cold_allowed driver_override local_cpus msi_irqs remove resource2 sriov_offset subsystem_device
aer_dev_fatal config device enable max_link_speed net rescan resource3 sriov_stride subsystem_vendor
aer_dev_nonfatal consistent_dma_mask_bits devspec i2c-4 max_link_width numa_node reset revision sriov_totalvfs uevent
ari_enabled current_link_speed dma_mask_bits irq modalias power resource sriov_drivers_autoprobe sriov_vf_device vendor
broken_parity_status current_link_width driver local_cpulist msi_bus ptp resource0 sriov_numvfs subsystem
[root@localhost ~]#//以上两个目录内容相等
查询网卡的更多信息,可通过以下两种方式。以查询网卡所在numa位置为例:
[root@localhost ~]# cat /sys/class/net/enp11s0f0/device/numa_node
0
[root@localhost ~]# cat /sys/bus/pci/devices/0000\:0b\:00.1/numa_node
0