Portál AbcLinuxu, 31. října 2025 21:40
[root@fw-liberec ~]# lspci -v|sed -e '/./{H;$!d;}' -e 'x;/Ethernet/!d;'
03:04.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5714 Gigabit Ethernet (rev a3)
        Subsystem: Hewlett-Packard Company NC324i PCIe Dual Port Gigabit Server Adapter
        Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 74
        Memory at fdef0000 (64-bit, non-prefetchable) [size=64K]
        Memory at fdee0000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [40] PCI-X non-bridge device
        Capabilities: [48] Power Management version 2
        Capabilities: [50] Vital Product Data
        Capabilities: [58] Message Signalled Interrupts: 64bit+ Queue=0/3 Enable+
03:04.1 Ethernet controller: Broadcom Corporation NetXtreme BCM5714 Gigabit Ethernet (rev a3)
        Subsystem: Hewlett-Packard Company NC324i PCIe Dual Port Gigabit Server Adapter
        Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 82
        Memory at fded0000 (64-bit, non-prefetchable) [size=64K]
        Memory at fdec0000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [40] PCI-X non-bridge device
        Capabilities: [48] Power Management version 2
        Capabilities: [50] Vital Product Data
        Capabilities: [58] Message Signalled Interrupts: 64bit+ Queue=0/3 Enable+
07:00.0 Ethernet controller: Intel Corporation 82572EI Gigabit Ethernet Controller (Copper) (rev 06)
        Subsystem: Intel Corporation PRO/1000 PT Desktop Adapter
        Flags: bus master, fast devsel, latency 0, IRQ 66
        Memory at fdfe0000 (32-bit, non-prefetchable) [size=128K]
        Memory at fdfc0000 (32-bit, non-prefetchable) [size=128K]
        I/O ports at 4000 [size=32]
        [virtual] Expansion ROM at 50000000 [disabled] [size=128K]
        Capabilities: [c8] Power Management version 2
        Capabilities: [d0] Message Signalled Interrupts: 64bit+ Queue=0/0 Enable+
        Capabilities: [e0] Express Endpoint IRQ 0
cat /proc/interrupts |grep eth
 66:     554805     674656         PCI-MSI  eth0
 74:   16674884   73688875         PCI-MSI  eth1
 82:   64585323   15132785         PCI-MSI  eth2
eth0 Intel Corporation 82572EI Gigabit Ethernet Controller (Copper) (rev 06)
eth1 Broadcom Corporation NetXtreme BCM5714 Gigabit Ethernet (rev a3)
eth2 Broadcom Corporation NetXtreme BCM5714 Gigabit Ethernet (rev a3)
#!/usr/bin/python
import subprocess
irqeth = {}
for line in file('/proc/interrupts'):
    if 'eth' not in line: continue
    spl = line.strip().split()
    irq = int(spl[0].rstrip(':'))
    eth = spl[-1]
    irqeth[irq] = eth
cmd = ['/sbin/lspci', '-v']
pr = subprocess.Popen(cmd, stdout = subprocess.PIPE)
ethdevs = {}
chunk = []
eth = None
for line in pr.stdout:
    line = line.strip()
    if not line:
        if eth:
            ethdevs[eth] = (irq, chunk)
        chunk = []
    else:
        chunk.append(line)
        if 'IRQ' in line:
            spl = line.split()
            irq = int(spl[spl.index('IRQ') + 1])
            try:
                eth = irqeth[irq]
            except KeyError:
                pass
for eth in ethdevs:
    print eth
    print 'IRQ', ethdevs[eth][0]
    print ethdevs[eth][1][0] #prvni radek
kdyby základní myšlenka fungovala, třeba bych to ještě nějak učesal.
            
        Tiskni
            
                Sdílej:
                 
                 
                 
                 
                 
                 
            
    
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.