以下是截取 r8125 2.5G 网卡的 lspci 的输出,可以看出
region0 是用来通过 io 端口配置设备的, region2 是用来通过 mmio 来配置和操作设备的, region4 是用来设置设备的 msix 中断的,
我可以称 region4 映射的内容是 msix table ,但不知道该怎么称呼 region2 映射的内容,是叫“mmio device register”,还是叫“mmio device data”,我只知道这个 region 是用来配置和操作设备的,不知道里面的东西该怎么称呼。
因为要给开源社区提交 patch 才纠结这个问题,我希望对 region2 映射的内容的描述肯定能让人看懂没有歧义。
root@develop:~# lspci -s 07:00.0 -vv
07:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 05)
DeviceName: Realtek RTL8125BG LAN
Subsystem: ASUSTeK Computer Inc. Device 87d7
Control: I/O+ Mem+ BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Interrupt: pin A routed to IRQ 37
IOMMU group: 17
Region 0: I/O ports at d000 [size=256]
Region 2: Memory at fcb00000 (64-bit, non-prefetchable) [size=64K]
Region 4: Memory at fcb10000 (64-bit, non-prefetchable) [size=16K]
Capabilities: [40] Power Management version 3
Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=375mA PME(D0+,D1+,D2+,D3hot+,D3cold+)
Status: D3 NoSoftRst+ PME-Enable+ DSel=0 DScale=0 PME-
Capabilities: [50] MSI: Enable- Count=1/1 Maskable+ 64bit+
Address: 0000000000000000 Data: 0000
Masking: 00000000 Pending: 00000000
Capabilities: [70] Express (v2) Endpoint, MSI 01
DevCap: MaxPayload 256 bytes, PhantFunc 0, Latency L0s <512ns, L1 <64us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE+ FLReset- SlotPowerLimit 26W
DevCtl: CorrErr+ NonFatalErr+ FatalErr+ UnsupReq+
RlxdOrd+ ExtTag- PhantFunc- AuxPwr- NoSnoop-
MaxPayload 128 bytes, MaxReadReq 4096 bytes
DevSta: CorrErr- NonFatalErr- FatalErr- UnsupReq- AuxPwr+ TransPend-
LnkCap: Port #0, Speed 5GT/s, Width x1, ASPM L0s L1, Exit Latency L0s unlimited, L1 <64us
ClockPM+ Surprise- LLActRep- BwNot- ASPMOptComp+
LnkCtl: ASPM L1 Enabled; RCB 64 bytes, Disabled- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 5GT/s, Width x1
TrErr- Train- SlotClk+ DLActive- BWMgmt- ABWMgmt-
DevCap2: Completion Timeout: Range ABCD, TimeoutDis+ NROPrPrP- LTR+
10BitTagComp- 10BitTagReq- OBFF Via message/WAKE#, ExtFmt- EETLPPrefix-
EmergencyPowerReduction Not Supported, EmergencyPowerReductionInit-
FRS- TPHComp+ ExtTPHComp-
AtomicOpsCap: 32bit- 64bit- 128bitCAS-
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis- LTR+ 10BitTagReq- OBFF Disabled,
AtomicOpsCtl: ReqEn-
LnkCap2: Supported Link Speeds: 2.5-5GT/s, Crosslink- Retimer- 2Retimers- DRS-
LnkCtl2: Target Link Speed: 5GT/s, EnterCompliance- SpeedDis-
Transmit Margin: Normal Operating Range, EnterModifiedCompliance- ComplianceSOS-
Compliance Preset/De-emphasis: -6dB de-emphasis, 0dB preshoot
LnkSta2: Current De-emphasis Level: -6dB, EqualizationComplete- EqualizationPhase1-
EqualizationPhase2- EqualizationPhase3- LinkEqualizationRequest-
Retimer- 2Retimers- CrosslinkRes: unsupported
Capabilities: [b0] MSI-X: Enable- Count=32 Masked-
Vector table: BAR=4 offset=00000000
PBA: BAR=4 offset=00000800
Capabilities: [d0] Vital Product Data
1
churchmice 2023-01-26 17:29:48 +08:00 via Android
那个不叫 region2,叫做 bar2
pcie 的配置寄存器分两块,一块用 conifg read/write 来访问,大小 4K,里面是跟 pcie 本身的配置,一般不涉及具体的设备性质 另一部分叫做 mmio,通过 bar 的形式映射到系统的 mmio 空间里面,你可以叫 bar0,bar1,bar2...bar5 ,每一个都是 32bit 的 bar 当然你也可以把 bar0/bar1 合在一块变成一个 64bit 的 bar0 |
2
wniming OP @churchmice 感谢回复,那么 lspci 输出中的 region 是什么意思?
|
3
churchmice 2023-01-26 19:22:08 +08:00 via Android
@wniming region 就是 bar,只不过在 pcie spec 里面只有 bar,没有 region 这种说法
|
4
RobertYang 2023-02-10 10:21:27 +08:00
BAR 是 base address register ,他指示 MEM 或 IO 空间的基地址和属性,所以这里写 region 也没问题。
|
5
RobertYang 2023-02-10 10:24:10 +08:00
每个 BAR 空间里面的功能你需要去看网卡的定义,PCIe 协议里面没有规定,PCIe 只对配置空间有规定。
|