linux pcie RC 框架

2023-05-16

1. linux pcie rc framework

 

Following is a brief explanation of layers shown in the diagram:

  • There are different drivers for the connected PCIe devices like pci_endpoint_test, tg-3, r8169, xhci-pci, ahci, etc. It could be vendor-specific like most of the ethernet cards (tg3, r8169) or class-specific like xhci-pci and ahci. Each of these drivers will also interact with it’s own domain-specific stack. For example, tg3 will interface with network stack, and xhci-pci will interface with USB stack.

  • The PCI core layer scans the PCIe bus to identify and detect any PCIe devices. It also binds the driver from the layer above, for the PCIe device, based on vendorid, deviceid and class.

  • The PCI BIOS layer handles resource management. For example, allocation of memory resources for BARs.

  • The bottom-most layer consists of the PCIe platform drivers like pcie-cadence, pcie-designware, etc. pci-j721e and pci-dra7xx are TI’s wrappers over these drivers. They configure platform-specific controllers and perform actual register writes. 

另一种架构图:

  • arch pcie driver:放一些和架构强相关的pcie的函数实现,对应arch/arm64/kernel/pci.c

  • acpi pcie driver: apci扫描时所涉及到的pcie代码,包括host bridge的解析初始化,pcie bus的创建,ecam的映射等, 对应drivers/acpi/pci*.c

  • pcie core driver: pcie的子系统代码,包括pcie的枚举流程,资源分配流程,中断流程等,主要对应drivers/pci/*.c

  • pcie port bus driver: 是pcie port的四个service代码的整合, 四个service主要指的是pcie dpc/pme/hotplug/aer,对应的是drivers/pci/pcie/*

  • pcie ep driver:是叶子节点的设备驱动,比如显卡,网卡,nvme等。

2. pci device driver

基于pci core实现pci ep deivce driver

rtl8168 pcie网卡设备驱动向上与网络协议栈对接

pci_endpoint_test会虚拟成一个设备,在应用层直接通过ioctl来控制

3. pci core

kernel\linux\linux-4.19.125\drivers\pci\pci.c

3.1 register driver

pci_register_driver

module_pci_driver -> pci_register_driver

3.2 Device Initialization Steps(do this in pci device driver probe)

1) Enable the device

pci_enable_device() Before touching any device registers, the driver needs to enable the PCI device by calling pci_enable_device()

pci_set_master() will enable DMA by setting the bus master bit in the PCI_COMMAND register.

pcim_enable_device()  Managed pci_enable_device()

2) Request MMIO/IOP resources

The device driver needs to call pci_request_region() to verify no other device is already using the same address resource.

Generic flavors of pci_request_region() are request_mem_region() (for MMIO ranges) and request_region() (for IO Port ranges).

3) Set the DMA mask size (for both coherent and streaming DMA)

Drivers for all PCI-X and PCIe compliant devices must call pci_set_dma_mask() as they are 64-bit DMA devices.

4) Allocate and initialize shared control data 

pci_allocate_coherent()

5) Access device configuration space (if needed)

6) Register IRQ handler (request_irq())

request_irq()

pci_alloc_irq_vectors()

MSI capability can be enabled by calling pci_alloc_irq_vectors() with the

PCI_IRQ_MSI and/or PCI_IRQ_MSIX flags before calling request_irq().

7) Initialize non-PCI (i.e. LAN/SCSI/etc parts of the chip)

8) Enable DMA/processing engines

3.3 How to access PCI config space

pci_(read|write)_config_(byte|word|dword)

pci_bus_(read|write)_config_(byte|word|dword)

pci_find_capability()

3.4 Other interesting functions

pci_set_power_state()        Set PCI Power Management state (0=D0 ... 3=D3)

pci_find_capability()        Find specified capability in device's capability list.

pci_resource_start()        Returns bus start address for a given PCI region

pci_resource_end()        Returns bus end address for a given PCI region

pci_resource_len()        Returns the byte length of a PCI region

pci_set_drvdata()        Set private driver data pointer for a pci_dev

pci_get_drvdata()        Return private driver data pointer for a pci_dev

pci_set_mwi()            Enable Memory-Write-Invalidate transactions.

pci_clear_mwi()            Disable Memory-Write-Invalidate transactions.

pcim_set_mwi            a device-managed pci_set_mwi()

3.5 访问配置空间

pci_bus_read_config_byte

pci_bus_read_config_word

pci_bus_read_config_dword

pci_bus_write_config_byte

pci_bus_write_config_word

pci_bus_write_config_dword

3.6 other

pci_ioremap_bar(): 设备驱动程序调用pci_ioremap_bar()将写入EP BAR的总线地址(保存在resource数组中)映射到系统内存的虚拟地址,之后软件就可以通过虚拟地址访问PCI设备的存储空间

pci_remap_iospace

devm_pci_remap_cfgspace

pcim_iomap_regions

4. pci bios

linux-4.19.125/arch/arm64/kernel/pci.c

linux-4.19.125/arch/arm64/kernel/bios32.c

pcibios只有使能了CONFIG_ACPI,才会被使用。

5. pci host controller driver

5.1 dw_pcie_host_init使用到的PCI API

dw_plat_pcie_probe -> dw_plat_add_pcie_port -> dw_pcie_host_init:

  • devm_pci_alloc_host_bridge

  • devm_of_pci_get_host_bridge_resources

  • devm_request_pci_bus_resources

  • devm_pci_remap_cfgspace -> pci_remap_cfgspace

  • pci_scan_root_bus_bridge

  • pci_bus_size_bridges

  • pci_bus_assign_resources

  • pci_bus_add_devices

以上这些函数均在linux-4.19.125/drivers/pci/*中实现

也可以直接调用pci_host_probe带代替调用pci_scan_root_bus_bridge & pci_bus_size_bridges & pci_bus_assign_resources & pci_bus_add_devices这些函数

pci_host_probe -> pci_scan_root_bus_bridge & pci_bus_size_bridges & pci_bus_assign_resources & pci_bus_add_devices

如linux-4.19.125\drivers\pci\controller\pcie-cadence-host.c

cdns_pcie_host_probe -> devm_pci_alloc_host_bridge & devm_pci_remap_cfg_resource &  cdns_pcie_host_init & pci_host_probe

5.2 init RC

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

linux pcie RC 框架 的相关文章

  • PHP 无法打开流:是一个目录

    非常简单的 PHP 脚本 我在我亲自设置的 Ubuntu Web 服务器上的 EE 模板中运行 我知道这与权限有关 并且我已经将我尝试写入的目录的所有者更改为 Apache 用户 我得到的错误是 遇到 PHP 错误 严重性 警告 消息 fi
  • 如何通过ssh检查ubuntu服务器上是否存在php和apache

    如何通过ssh检查Ubuntu服务器上apache是 否安装了php和mysql 另外如果安装的话在哪个目录 如果安装了其他软件包 例如 lighttpd 那么它在哪里 确定程序是否已安装的另一种方法是使用which命令 它将显示您正在搜索
  • Linux 上有关 getBounds() 和 setBounds() 的 bug_id=4806603 的解决方法?

    在 Linux 平台上 Frame getBounds 和 Frame setBounds 的工作方式不一致 这在 2003 年就已经有报道了 请参见此处 http bugs java com bugdatabase view bug do
  • 删除 Git 存储库,但保留所有文件

    在我使用 Linux 的过程中的某个时刻 我决定将我的主目录中的所有内容都放入源代码管理中是个好主意 我不是在问这是否是一个好主意 我是在问如何撤销它 删除存储库的原因是我最近安装了 Oh My Zsh 而且我非常喜欢它 问题是我的主目录有
  • 我不明白 execlp() 在 Linux 中如何工作

    过去两天我一直在试图理解execlp 系统调用 但我还在这里 让我直奔主题 The man pageexeclp 将系统调用声明为int execlp const char file const char arg 与描述 execl exe
  • 如何在基于 Linux 的系统上的 C 程序中使用 mqueue?

    如何在基于 Linux 的系统上的 C 程序中使用 mqueue 消息队列 我正在寻找一些好的代码示例 可以展示如何以正确且正确的方式完成此操作 也许是一个操作指南 下面是一个服务器的简单示例 该服务器接收来自客户端的消息 直到收到告诉其停
  • php exec 返回的结果比直接进入命令行要少

    我有一个 exec 命令 它的行为与通过 Penguinet 给 linux 的相同命令不同 res exec cd mnt mydirectory zcat log file gz echo res 当将命令直接放入命令行时 我在日志文件
  • 如何减去两个 gettimeofday 实例?

    我想减去两个 gettimeofday 实例 并以毫秒为单位给出答案 这个想法是 static struct timeval tv gettimeofday tv NULL static struct timeval tv2 gettime
  • Linux - 从第二个选项卡获取文本

    假设我们有这样的文件 一些文本11 一些文本12 一些文本13 一些文本21 一些文本22 一些文本23 文本由制表符分隔 我们知道第 1 列中的一些文本 但希望从第 2 列中获取文本 我知道我可以通过以下方式获取线路 grep somet
  • 进程退出后 POSIX 名称信号量不会释放

    我正在尝试使用 POSIX 命名信号量进行跨进程同步 我注意到进程死亡或退出后 信号量仍然被系统打开 在进程 打开它 死亡或退出后是否有办法使其关闭 释放 早期的讨论在这里 当将信号量递减至零的进程崩溃时 如何恢复信号量 https sta
  • 子目录中的头文件(例如 gtk/gtk.h 与 gtk-2.0/gtk/gtk.h)

    我正在尝试使用 GTK 构建一个 hello world 其中包括以下行 include
  • 快速像素绘图库

    我的应用程序以每像素的方式生成 动画 因此我需要有效地绘制它们 我尝试过不同的策略 库 但结果并不令人满意 尤其是在更高分辨率的情况下 这是我尝试过的 SDL 好的 但是慢 OpenGL 像素操作效率低下 xlib 更好 但仍然太慢 svg
  • C++ Boost ASIO 简单的周期性定时器?

    我想要一个非常简单的周期性计时器每 50 毫秒调用我的代码 我可以创建一个始终休眠 50 毫秒的线程 但这很痛苦 我可以开始研究用于制作计时器的 Linux API 但它不可移植 I d like使用升压 我只是不确定这是否可能 boost
  • 如何构建任务“gems:install”

    我正在将 Rails 应用程序部署到 Linux 服务器 并且缺少一些 rake 任务 包括 rake gems install 和 rake db 我正在运行来自 GEM 的 Rails 2 3 4 为什么是这样 我该如何解决 我可以以某
  • 高效的内存屏障

    我有一个多线程应用程序 其中每个线程都有一个整数类型的变量 这些变量在程序执行期间递增 在代码中的某些点 线程将其计数变量与其他线程的计数变量进行比较 现在 我们知道在多核上运行的线程可能会无序执行 一个线程可能无法读取其他线程的预期计数器
  • 为什么我可以在 /proc/pid/maps 输出中看到几个相同的段?

    测试在32位Linux上进行 代码如下 int foo int a int b int c a b return c int main int e 0 int d foo 1 2 printf d n d scanf d e return
  • 使用 plistBuddy 获取值数组

    var keychain access groups declare a val usr libexec PlistBuddy c Print var sample plist echo val echo val 0 Ouput Array
  • 后台分叉无法正常工作[重复]

    这个问题在这里已经有答案了 我运行这个程序 在前景和背景中 int main int pid printf App Start pid d n getpid while 1 pid fork if pid 0 printf Child n
  • 如何从 PROC 获取有关子进程的信息

    我正在尝试编写一个以几个进程作为参数的程序 然后父进程执行每个子进程并打印出一些相关的统计信息 示例 generate ls l 将生成一个程序 打印出有关 ls l 的一些统计信息 特别是其系统时间 用户时间和上下文切换次数 我不想使用
  • Gearman,php 扩展问题:使用终端在 .. 中找不到类“GearmanWorker”,但可以在浏览器上使用

    我最近在 ubuntu 10 04 上安装了 gearman 并安装了它的 pecl 扩展 现在 当我在浏览器中运行一个 php 文件时 其中包含 client new GearmanWorker die var Dump client I

随机推荐

  • 优化USB UVC ISO传输速度

    1 issue USB3 0单路uvc iso传输速率只有92MB s 1080p yuv 23 4fps 我们需要优化UVC传输速率 提高YUV帧率 2 analysis 2 1 ISO速度 ISO速度由mult burst max pa
  • UVC V4L2的实现

    linux 4 19 125 drivers media usb uvc uvc v4l2 c 1 uvc ops const struct v4l2 file operations uvc fops owner THIS MODULE o
  • USB3.0 PIPE接口

    1 introduction PHY Interface for the PCI Express and USB 3 0 Architectures USB SuperSpeed PHY Layer The USB SuperSpeed P
  • USB2.0 UTMI接口

    1 UTM Functional Block Diagram 2 UTMI Signal Descriptions 2 1 nbsp System Interface Signals 2 2 Data Interface Signals n
  • USB2.0 ULPI接口介绍

    UTMI Low Pin Interface ULPI nbsp a generic low pin interface LPI between a Link and a PHY 1 general ULPI defines a PHY t
  • 《IT项目管理》(郭宁编著) 课后习题答案

    目录 第一章 it项目管理概述 第二章 组织环境与项目管理过程 第三章 it项目整体管理 第四章 it项目范围管理 第五章 it项目时间管理 第六章 it项目成本管理 第七章 it项目质量管理 第八章 项目人力资源管理 第九章 项目沟通管理
  • FPGA USB device原型验证流程及调试手段

    device mode enable usb ACM usb serial gadget function and connect it to PC host 1 register access check if register acce
  • FPGA USB host原型验证流程及调试手段

    host mode plug in a device for test super speed device usb3 0 usb storage high speed device usb2 0 usb storage full spee
  • USB2.0 UTMI+接口

    1 UTMI The UTMI standard contains progressive levels of technology support because the complexity requirements for devic
  • cadence usb linux配置

    1 kernel config 2 dts
  • USB3.0 host xHCI驱动

    xHCI驱动在usb host中 主要初始化xHCI xHCI作为usb nbsp host部分的驱动 1 nbsp xhci driver与device的匹配 usb host xhci plat c static struct plat
  • windows PCIe 工具: TeleScan

    TeleScan PE for Windows 用户可以通过TeleScan PE来扫描系统中的PCI PCIe设备 xff0c 并提供了读写其配置空间中的寄存器的功能 download Teledyne LeCroy PCI Expres
  • intel 82574 1000M pcie 网卡 kernel driver

    0 kernel config Device Drivers gt Network device support gt Ethernet driver support gt Intel devices lt gt Intel R PRO 1
  • Windows NFS server:Winnfsd

    1 Winnfsd GitHub winnfsd winnfsd Usage WinNFSd exe id lt uid gt lt gid gt log on off pathFile lt file gt addr lt ip gt e
  • windows dhcp server

    1 tool Open DHCP Server Open Source Freeware Windows Linux MultiSubnet MultiDomain DHCP Server supports every Industry S
  • uboot环境变量保存到EMMC

    1 cmd 命令行可以用setenv printenv saveenv uboot u boot 2020 04 cmd nvedit c setenv gt do env set gt do env set gt hsearch r en
  • 安装VScode配置c/c++环境出现问题提示#include errors detected. Please update your includePath......解决办法

    文章目录 1 vscode下载安装以及c c 43 43 插件安装 2 MinGW安装3 配置环境变量4 配置几个json文件 1 vscode下载安装以及c c 43 43 插件安装 VScode下载地址 2 MinGW安装 官网下载地址
  • linux支持ipv6

    1 kernel config Networking support gt Networking options gt lt gt The IPv6 protocol gt 2 test 2 1 proc net if inet6 查看 p
  • 以太网 网线分类

    1 双绞线分类 一类线 xff1a 主要用于传输语音 xff08 一类标准主要用于八十年代初之前的电话线缆 xff09 xff0c 不同于数据传输 二类线 xff1a 传输频率为1MHZ xff0c 用于语音传输和最高传输速率4Mbps的数
  • linux pcie RC 框架

    1 linux pcie rc framework Following is a brief explanation of layers shown in the diagram There are different drivers fo