/sys/class/net /sys/devices /sy/bus/pci
https://access.redhat.com/discussions/895293
[root@localhost rules.d]# lspci -v | grep -i ether -B 4 Capabilities: [100] Advanced Error Reporting Capabilities: [280] Access Control Services Capabilities: [310] #19 05:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (2*25GE) (rev 45) -- Capabilities: [630] Access Control Services Kernel driver in use: vfio-pci Kernel modules: hinic 06:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (2*25GE) (rev 45) -- Capabilities: [b0] Power Management version 3 Capabilities: [100] Access Control Services Kernel driver in use: pcieport 7d:00.0 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) -- Capabilities: [450] Alternative Routing-ID Interpretation (ARI) Kernel driver in use: hns3 Kernel modules: hclge, hns3, hns_roce_hw_v2 7d:00.1 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) -- Capabilities: [450] Alternative Routing-ID Interpretation (ARI) Kernel driver in use: hns3 Kernel modules: hclge, hns3 7d:00.2 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) -- Capabilities: [450] Alternative Routing-ID Interpretation (ARI) Kernel driver in use: hns3 Kernel modules: hclge, hns3, hns_roce_hw_v2 7d:00.3 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) [root@localhost rules.d]# lspci -v | grep -i ether -B 4
[root@bogon rules.d]# ls /sys/class/net/enahisic2i0/device/driver/ -al total 0 drwxr-xr-x 2 root root 0 Sep 2 16:57 . drwxr-xr-x 86 root root 0 Jul 16 04:25 .. --w------- 1 root root 65536 Sep 2 16:57 bind lrwxrwxrwx 1 root root 0 Sep 2 16:57 HISI00C2:00 -> ../../../../devices/platform/HISI00C2:00 lrwxrwxrwx 1 root root 0 Sep 2 16:57 HISI00C2:01 -> ../../../../devices/platform/HISI00C2:01 lrwxrwxrwx 1 root root 0 Sep 2 16:57 HISI00C2:02 -> ../../../../devices/platform/HISI00C2:02 lrwxrwxrwx 1 root root 0 Sep 2 16:57 HISI00C2:03 -> ../../../../devices/platform/HISI00C2:03 lrwxrwxrwx 1 root root 0 Sep 2 16:57 module -> ../../../../module/hns_enet_drv --w------- 1 root root 65536 Jul 16 04:25 uevent --w------- 1 root root 65536 Sep 2 16:57 unbind [root@bogon rules.d]# readlink -f /sys/class/net/enahisic2i0/device/driver/module /sys/module/hns_enet_drv [root@bogon rules.d]#
http://www.jeepxie.net/article/347890.html
=> Usually, all Linux kernel modules (drivers) are stored in the module directory located that /lib/modules/$(uname -r) directory. To see current modules, type:$ ls /lib/modules/$(uname -r)
Output:
build modules.ccwmap modules.order initrd modules.dep modules.pcimap kernel modules.dep.bin modules.seriomap misc modules.devname modules.softdep modules.alias modules.ieee1394map modules.symbols modules.alias.bin modules.inputmap modules.symbols.bin modules.builtin modules.isapnpmap modules.usbmap modules.builtin.bin modules.ofmap updates
Use the following command to list all drivers for various devices:$ ls /lib/modules/$(uname -r)/kernel/drivers/
Sample outputs:
Fig.01: Device drivers on my Linux based system
Task: Add a Module (driver) Called foo
Type the following command as root user:# modprobe foo
In this example, I am loading a module called i8k, enter:# modprobe -v i8k
Sample outputs:
insmod /lib/modules/3.5.0-30-generic/kernel/drivers/char/i8k.ko
Find out info about loaded module
You need to use the modinfo command to see information about a Linux Kernel module. The syntax is:# modinfo -v {module-name-here}
# modinfo i8k
Sample outputs:
Fig.02: Displaying information about a Linux Kernel module called i8k
Task: List all loaded modules
Use the lsmod command to show the status of modules in the Linux Kernel:# lsmod
Sample outputs:
Module Size Used by smbfs 75465 0 md5 5953 1 ipv6 284193 10 ipt_TOS 4033 2 iptable_mangle 4545 1 ip_conntrack_ftp 74801 0 ip_conntrack_irc 74033 0 ipt_REJECT 8897 43 ipt_LOG 8513 2 ipt_limit 4033 6 iptable_filter 4673 1 ipt_multiport 3521 4 ipt_state 3393 16 ip_conntrack 54297 3 ip_conntrack_ftp,ip_conntrack_irc,ipt_state ip_tables 21825 8 ipt_TOS,iptable_mangle,ipt_REJECT,ipt_LOG,ipt_limit,iptable_filter,ipt_multiport,ipt_state i2c_dev 13889 0 i2c_core 28865 1 i2c_dev dm_mirror 32721 0 dm_mod 68609 1 dm_mirror button 9313 0 battery 11465 0 ac 6985 0 ohci_hcd 24529 0 ehci_hcd 33989 0 tg3 109381 0 floppy 66065 0 ext3 137937 2 jbd 69105 1 ext3 sata_svw 10053 3 libata 78345 1 sata_svw sd_mod 19393 4 scsi_mod 141457 2 libata,sd_mod
Task: Remove a module called foo
Pass the -r option to modprobe command to remove a module, type:# modprobe -r foo
You can also use the rmmod command, which is simple program to remove a module from the Linux Kernel:# rmmod foo
[root@localhost ~]# lspci | grep -i eth 7d:00.0 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) 7d:00.1 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) 7d:00.2 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) 7d:00.3 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) 85:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (2*100GE) (rev 45) 86:00.0 Ethernet controller: Huawei Technologies Co., Ltd. Hi1822 Family (2*100GE) (rev 45) bd:00.0 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) bd:00.1 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) bd:00.2 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE RDMA Network Controller (rev 21) bd:00.3 Ethernet controller: Huawei Technologies Co., Ltd. HNS GE/10GE/25GE Network Controller (rev 21) [root@localhost ~]# lspci -v -n -s 7d:00.0 7d:00.0 0200: 19e5:a222 (rev 21) Flags: bus master, fast devsel, latency 0, NUMA node 0 Memory at 121000000 (64-bit, prefetchable) [size=64K] Memory at 120000000 (64-bit, prefetchable) [size=1M] Capabilities: [40] Express Endpoint, MSI 00 Capabilities: [a0] MSI-X: Enable+ Count=131 Masked- Capabilities: [b0] Power Management version 3 Capabilities: [100] Access Control Services Capabilities: [200] Single Root I/O Virtualization (SR-IOV) Capabilities: [300] Transaction Processing Hints Capabilities: [450] Alternative Routing-ID Interpretation (ARI) Kernel driver in use: hns3 Kernel modules: hns3, hclge, hns_roce_hw_v2 [root@localhost ~]# lspci -v -n -s 85:00.0 85:00.0 0200: 19e5:0200 (rev 45) Subsystem: 19e5:d139 Flags: bus master, fast devsel, latency 0, NUMA node 2 Memory at 28000f800000 (64-bit, prefetchable) [size=128K] Memory at 28000fbe0000 (64-bit, prefetchable) [size=32K] Memory at 28000f700000 (64-bit, prefetchable) [size=1M] Expansion ROM at b0000000 [size=1M] Capabilities: [40] Express Endpoint, MSI 00 Capabilities: [80] MSI: Enable- Count=1/32 Maskable+ 64bit+ Capabilities: [a0] MSI-X: Enable+ Count=32 Masked- Capabilities: [b0] Power Management version 3 Capabilities: [c0] Vital Product Data Capabilities: [100] Advanced Error Reporting Capabilities: [150] Alternative Routing-ID Interpretation (ARI) Capabilities: [200] Single Root I/O Virtualization (SR-IOV) Capabilities: [310] Secondary PCI Express <?> Capabilities: [4e0] Device Serial Number ac-8d-34-ff-ff-d2-f9-ef Capabilities: [4f0] Transaction Processing Hints Capabilities: [600] Vendor Specific Information: ID=0000 Rev=0 Len=028 <?> Capabilities: [630] Access Control Services Kernel driver in use: hinic Kernel modules: hinic [root@localhost ~]# lsmod | grep hinic hinic 655360 0 [root@localhost ~]# lsmod | grep hns3 hns3 262144 0 hnae3 262144 3 hclge,hns3,hns_roce_hw_v2 [root@localhost ~]# lspci -v -n -s 80:00.0 80:00.0 0604: 19e5:a120 (rev 21) (prog-if 00 [Normal decode]) Flags: bus master, fast devsel, latency 0, IRQ 75, NUMA node 2 Bus: primary=80, secondary=81, subordinate=81, sec-latency=0 I/O behind bridge: None Memory behind bridge: None Prefetchable memory behind bridge: None Capabilities: [40] Express Root Port (Slot+), MSI 00 Capabilities: [80] MSI: Enable- Count=1/32 Maskable+ 64bit+ Capabilities: [b0] Power Management version 3 Capabilities: [d0] Subsystem: 19e5:371e Capabilities: [100] Advanced Error Reporting Capabilities: [310] Secondary PCI Express <?> Capabilities: [400] Virtual Channel Capabilities: [630] Access Control Services Capabilities: [700] Data Link Feature <?> Capabilities: [70c] Lane Margining at the Receiver <?> Capabilities: [800] Designated Vendor-Specific <?> Capabilities: [880] Physical Layer 16.0 GT/s <?> Capabilities: [900] Designated Vendor-Specific <?> [root@localhost ~]#
[root@localhost ~]# modinfo -p hnae3 [root@localhost ~]# modinfo hnae3 filename: /lib/modules/4.19.90-9.ky10.aarch64/kernel/drivers/net/ethernet/hisilicon/hns3/hnae3.ko version: 1.9.30.0 description: HNAE3(Hisilicon Network Acceleration Engine) Framework license: GPL author: Huawei Tech. Co., Ltd. srcversion: D3B198A560105B00239EC51