棋子 · 4 天前

PCIe 知识点:bus number是如何获取的

image.png

Bus number是指当前PCIe设备在PCIe系统结构中被分配的总线号。PCIe的部分TLP(Transaction Layer Packet)传输需要确定总线号才能完成。在PCIe系统中,总线号是用来标识不同的PCIe总线的,每条总线都有一个唯一的总线号。设备号是指在特定总线上的设备编号。PCIe允许在单个PCI总线上最多有32个设备号。每个设备都必须实现Function 0,并且可能包含多达8个Function的集合。设备号用于在总线上标识不同的设备

1.PCIE EP是如何响应不同的bus number和device number的  

为支持ID路由,每个PCIE设备(端点和交换开关)中都应设置有贮存设备总线号的寄存器,PCIE协议中并没在PCIe配置头空间定义bus number,bus number号存在事务层的寄存器中。复位时,该寄存器清0。每当PCIe设备收到有效的Type0类型的cfgwr时,PCIe设备就将TLP header中的第8字节写入bus number寄存器。此处需要注意:必须是有效的cfgwr0才会触发bus number捕写入动作,即不是Poison TLP、nullified TLP、也不是malformed TLP和unsupported TLP。

1.1.协议原文描述  

Spec 2.2.6.2存在如下描述

image.png

    always @(posedge clk or negedge rstn)
   begin: ID_CHECK
     if (rstn == 1'b0) begin
       busnum_captured    <= 8'b0;
     end else if (srst==1'b1 || k_upstr==1'b0) begin
       busnum_captured    <= 8'b0;
     end else begin
       // Capture bus and device numbers then start checking ID when a CfgWr0 is received;
       // but not when TLP is nullified, poisoned, malformed, unsupported because core will not
       // return a successful completion in these cases.
       // (ECRC error cannot be checked at this point so it is not included in above cases)
       if (rx_hvalid==1'b1 && is_rxcfgwr0==1'b1 && rx_hnull==1'b0 && rx_header[`TLP_EP]==1'b0        
           && err_iocfg==1'b0 && err_pfx==1'b0 && be_err_n==1'b0 && up_cfg0_ok==1'b1) begin
         busnum_captured    <= rx_header[`TLP_CFG_BUS+:8];

       end    

2.参考文档  

PCI Express Base Specification Revision 4.0 Version 1.0

END

作者:IC小鸽
文章来源:IC小鸽

推荐阅读

更多IC设计干货请关注IC设计专栏。欢迎添加极术小姐姐微信(id:aijishu20)加入技术交流群,请备注研究方向。

推荐阅读
关注数
18630
内容数
1291
主要交流IC以及SoC设计流程相关的技术和知识
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息