https://zhuanlan.zhihu.com/p/380414834
本文介绍PCI Express Port Bus driver基础知识,如何使能注册和反注册PCI Express Port Bus Driver. PCIe Port bus driver 所处PCIe软件架构位置如下图红色。
- PCI Express Port Bus Driver作用
PCIe port包含Root Port and the Switch Port, switch port又分为Upstream Port和Downstream Port。PCIe port通常提供多个高级服务,如native hotplug support (HP), power management event support (PME), advanced error reporting support (AER), and Downstream Port Containment(DPC)。PCIe port bus driver就是提供PCIe port driver设备的创建,中断申请,为PCIe高级服务做好基础准备。
- PCI Express Port Bus Driver实现
drivers/pci/pcie/portdrv_pci.c
- 关键结构
支持设备类型 PCI-Express port、PCI-to-PCI bridge、Root Complex Event Collector
/*
* LINUX Device Driver Model
*/
static const struct pci_device_id port_pci_ids[] = {
/* handle any PCI-Express port */
{ PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0) },
/* subtractive decode PCI-to-PCI bridge, class type is 060401h */
{ PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x01), ~0) },
/* handle any Root Complex Event Collector */
{ PCI_DEVICE_CLASS(((PCI_CLASS_SYSTEM_RCEC << 8) | 0x00), ~0) },
{ },
};
static const struct pci_error_handlers pcie_portdrv_err_handler = {
.error_detected = pcie_portdrv_error_detected,
.slot_reset = pcie_portdrv_slot_reset,
.mmio_enabled = pcie_portdrv_mmio_enabled,
.resume = pcie_portdrv_err_resume,
};
static struct pci_driver pcie_portdriver = {
.name = "pcieport",
.id_table = &port_pci_ids[0],
.probe = pcie_portdrv_probe,
.remove = pcie_portdrv_remove,
.shutdown = pcie_portdrv_remove,
.err_handler = &pcie_portdrv_err_handler,
.driver.pm = PCIE_PORTDRV_PM_OPS,
};
关键接口pcie_port_device_register, 为高级服务Hotplug、AER、DPC、PME申请中中断,
注册PCIe port service设备。
/**
* pcie_port_device_register - register PCI Express port
* @dev: PCI Express port to register
*
* Allocate the port extension structure and register services associated with
* the port.
*/
int pcie_port_device_register(struct pci_dev *dev);
高级服务Hotplug、AER、DPC、PME申请中断实现
/**
* pcie_init_service_irqs - initialize irqs for PCI Express port services
* @dev: PCI Express port to handle
* @irqs: Array of irqs to populate
* @mask: Bitmask of port capabilities returned by get_port_device_capability()
*
* Return value: Interrupt mode associated with the port
*/
static int pcie_init_service_irqs(struct pci_dev *dev, int *irqs, int mask)
AER中断定义PCIe 5.0 section 7.8.4.10 Root Error Status Register (Offset 30h)
Hotplug和PME使用的是同一个中断,其定义在PCIe 5.0 section 7.5.3.2 PCI Express Capabilities Register (Offset 02h)
DPC中断定义在PCIe 5.0 section 7.9.15.2 DPC Capability Register (Offset 04h)
PCI Express port service device接口的申请
/**
* pcie_device_init - allocate and initialize PCI Express port service device
* @pdev: PCI Express port to associate the service device with
* @service: Type of service to associate with the service device
* @irq: Interrupt vector to associate with the service device
*/
static int pcie_device_init(struct pci_dev *pdev, int service, int irq)
- 小结
本文介绍PCIe软件中的PCI Express Port Bus Driver,通过此文可以掌握了解其功能和关键结构和接口的定义实现。
标签:Express,Drive,port,PCIe,PCI,device,Port From: https://www.cnblogs.com/hshy/p/16961964.html