PCIE AER and hot removal

It is very usefull to disable/enable during our verification of some functions, such as PCIE hotplug, firmware upgrade. We need use AER to maks or enable PCIE errors to stop unexpected reset.

Following script give us an example how to control AER and do hot removal and insertion, please feel free to give your comments:

#!/bin/bash

# Notice: following script is only for SLIC2

#set -n;

#set  -v;

#set  -x;

source ./aer_ctr.sh

# Disable SMI error caused by hot removal/insertion

function disable_smi()

{

setpci -s 00:05.2 0x19C.w=0xffffffff ;

setpci -s 00:05.2 0x1a0.w=0xffffffff ;

setpci -s 00:05.2 0x1a4.w=0xffffffff ;

setpci -s 00:05.2 0x1a8.w=0xffffffff ;

setpci -s 00:05.2 0x1c8.w=0xffffffff ;

}

# Enable SMI error caused by hot removal/insertion

function enable_smi()

{

setpci -s 00:05.2 0x19C.w=0x00000000 ;

setpci -s 00:05.2 0x1a0.w=0x00000000 ;

setpci -s 00:05.2 0x1a4.w=0x00000000 ;

setpci -s 00:05.2 0x1a8.w=0x00000000 ;

}

# disable SP reset on PCIE device event

function disable_sp_reset_on_slicevent()

{

ipmitool raw 0x30 0x81 0x13 0x10 0x00 0x00 0x00

}

# Power off PCIE card

function poweroff_slic()

{

ipmitool raw 0x30 0x81 0x13 0x01 0x00 0x00 0x00

# !!! DON"T REMOVE SLEEP , it is for PCIE DLL ready

sleep 1;

}

# Power on PCIE card 2

function poweron_slic()

{

ipmitool raw 0x30 0x81 0x13 0x01 0x00 0x01 0x00

# !!! DON"T REMOVE SLEEP , it is for PCIE DLL ready

sleep 1;

}

# disable SLIC hold in reset status

function disable_slic_holdinreset()

{

ipmitool raw 0x30 0x81 0x13 0x04 0x00 0x00 0x00

# !!! DON"T REMOVE SLEEP , it is for PCIE DLL ready

sleep 1;

}

# The serdes value are only for PCIE card 2

# below function also works as C code, it doesn‘t set 504.b

function apply_serdes()

{

echo "Before Apply serdes:";

#lspci -xxxxx -s 00:07.0 | tee -a before_070_0819.pci

#lspci -xxxxx -s 00:07.1 | tee -a before_071_0819.pci

#

#  setpci -s 00:06.7 0x504.b=0x76

# [CTL] 0xa80 # set serdes table

# read pci offset: bnd[0~30] to  A80

# original value is 0x55555555

#setpci  -s 00:07.0 0xa80.l=0x31810842  # correct one

setpci  -s 00:07.0 0xa80.l=0x00d10842  # correct one

#  setpci  -s 00:07.0 0xa84.l=0x04

#  setpci  -s 00:07.0 0x438.l=0x2757F

#setpci  -s 00:07.0 0x3cc.l=0x01d80000

#setpci  -s 00:07.1 0x3cc.l=0x01d80000

setpci  -s 00:07.0 0x3cc.l=0x01d80000

setpci  -s 00:07.1 0x3cc.l=0x01d80000

}

# The serdes value are only for SLIC 2

## good one which follow all steps

function apply_serdes_origin()

{

# the value of 504.b is always 0x76

setpci -s 00:06.7 0x504.b=0x76

# [CTL] 0xa80 # set serdes table

# read pci offset: bnd[0~30] to  A80

# original value is 0x55555555

setpci  -s 00:07.0 0xa80.l=0x00

#[cursor 0] 0x3cc  s.Cursorbnd0/1

# original both 0x00 0x00

setpci  -s 00:07.0 0xa80.l=0x00

#[cursor 1] 0x3cc  s.Cursorbnd2/3

# original both 0x00 0x00

#lspci  -s 00:07.1 0xa80.l=0xd80000

setpci  -s 00:07.0 0xa80.l=0x0000   # according to the C code, write 00:07.0 also

# re-training, set bit, sleep , then clear the re-trian bit

#[PR ]   0x3E   link control bit

##  check link -status [A2]

}

# do PCIE retraning by set the bridge control register

function retrain()

{

#exp=83;

# step 0.0: display original link status reg

# let exp=exp+0x40;

# step 1: clear the linkBandwidth management bit

#setpci -s 00:03.0 0xa2.b=0xff;

#lspci -xxxxx -s 00:03.0 | tee -a  gdrootp2_0.lspci

# step 1.2: use link bridge contrl to reset the link bit

setpci -s 00:03.0 0x3e.w=0x0053;

#sleep 1

usleep 500000

#lspci -xxxxx -s 00:03.0 | tee -a  gdrootp2_1.lspci

setpci -s 00:03.0 0x3e.w=0x0013;

#sleep 1

usleep 500000

#lspci -xxxxx -s 00:03.0 | tee -a  gdrootp2_3.lspci

# step 1.5: save original link status reg

temp=`lspci -xxx -s 00:03.0 | grep "a0:" `;

exp=`echo $temp | awk ‘{print $4}‘`;

echo "Notice!!!! current link status is : $exp";

# let exp=exp+0x40;

# step 2: set the link train bit of control reg

# for root port 2 (slot 2)

# original 0x40

#setpci -s 00:03.0 0xa0.b=0x60;

#lspci -xxx -s 00:03.0 | grep "a0:"

# wait until link staus is ready

# step 3: check and wait until finish link training

#    status=`lspci -xxx -s 00:03.0 | grep "a0:" | awk ‘{print $4}‘`;

#

#    while [ $exp -ne $status ]

#    do

#

# echo "Current Link Status is $status" | tee -a lspci.log;

#        sleep 1;

#        status=`lspci -xxx -s 00:03.0 | grep a0: | awk ‘{print $4}‘ `

#    done

#setpci -s 1f:00.0 0xbc.b=0x6;

#setpci -s 1f:00.1 0xbc.b=0x6;

#setpci -s 1f:00.2 0xbc.b=0x6;

#setpci -s 1f:00.3 0xbc.b=0x6;

}

# test shows it doesn‘t matter whether it is set or not

function restore_bar()

{

echo "restore_bar";

}

# test shows it doesn‘t matter whether it is set or not

function restore_cmd()

{

echo "restore_cmd";

}

function unhide_regs()

{

# original value

# b0: c0 00 20 01 ce 00 20 01 c0 00 24 01 ec 00 20 01

# c0: e0 08 48 00 e0 0f 48 00 e0 0f 04 00 e0 05 00 00

#

setpci -s 7f:10.7 0xb0.l=0x00;

setpci -s 7f:10.7 0xb4.l=0x00;

setpci -s 7f:10.7 0xb8.l=0x00;

setpci -s 7f:10.7 0xbc.l=0x00;

setpci -s 7f:10.7 0xc0.l=0x00;

setpci -s 7f:10.7 0xc4.l=0x00;

setpci -s 7f:10.7 0xc8.l=0x00;

setpci -s 7f:10.7 0xcc.l=0x00;

setpci -s ff:10.7 0xb0.l=0x00;

setpci -s ff:10.7 0xb4.l=0x00;

setpci -s ff:10.7 0xb8.l=0x00;

setpci -s ff:10.7 0xbc.l=0x00;

setpci -s ff:10.7 0xc0.l=0x00;

setpci -s ff:10.7 0xc4.l=0x00;

setpci -s ff:10.7 0xc8.l=0x00;

setpci -s ff:10.7 0xcc.l=0x00;

#echo "After unhide regs:" | tee -a lspci.log

#lspci -vvvv -t | tee -a lspci.log

}

function hide_regs1()

{

# original value

# b0: c0 00 20 01 ce 00 20 01 c0 00 24 01 ec 00 20 01

# c0: e0 08 48 00 e0 0f 48 00 e0 0f 04 00 e0 05 00 00

#

setpci -s 7f:10.7 0xb0.l=0xffffffff;

setpci -s 7f:10.7 0xb4.l=0xffffffff;

setpci -s 7f:10.7 0xb8.l=0xffffffff;

setpci -s 7f:10.7 0xbc.l=0xffffffff;

setpci -s 7f:10.7 0xc0.l=0xffffffff;

setpci -s 7f:10.7 0xc4.l=0xffffffff;

setpci -s 7f:10.7 0xc8.l=0xffffffff;

setpci -s 7f:10.7 0xcc.l=0xffffffff;

setpci -s ff:10.7 0xb0.l=0xffffffff;

setpci -s ff:10.7 0xb4.l=0xffffffff;

setpci -s ff:10.7 0xb8.l=0xffffffff;

setpci -s ff:10.7 0xbc.l=0xffffffff;

setpci -s ff:10.7 0xc0.l=0xffffffff;

setpci -s ff:10.7 0xc4.l=0xffffffff;

setpci -s ff:10.7 0xc8.l=0xffffffff;

setpci -s ff:10.7 0xcc.l=0xffffffff;

echo "After hide regs:" | tee -a lspci.log

lspci -vvvv -t | tee -a lspci.log

}

function hide_regs()

{

# original value

# b0: c0 00 20 01 ce 00 20 01 c0 00 24 01 ec 00 20 01

# c0: e0 08 48 00 e0 0f 48 00 e0 0f 04 00 e0 05 00 00

#

setpci -s 7f:10.7 0xb0.b=0xc0;

setpci -s 7f:10.7 0xb4.b=0xce;

setpci -s 7f:10.7 0xb8.b=0xc0;

setpci -s 7f:10.7 0xbc.b=0xec;

setpci -s 7f:10.7 0xc0.b=0xe0;

setpci -s 7f:10.7 0xc4.b=0xe0;

setpci -s 7f:10.7 0xc8.b=0xe0;

setpci -s 7f:10.7 0xcc.b=0xe0;

setpci -s ff:10.7 0xb0.b=0xc0;

setpci -s ff:10.7 0xb4.b=0xce;

setpci -s ff:10.7 0xb8.b=0xc0;

setpci -s ff:10.7 0xbc.b=0xec;

setpci -s ff:10.7 0xc0.b=0xe0;

setpci -s ff:10.7 0xc4.b=0xe0;

setpci -s ff:10.7 0xc8.b=0xe0;

setpci -s ff:10.7 0xcc.b=0xe0;

#echo "After hide regs:" | tee -a lspci.log

#lspci -vvvv -t | tee -a lspci.log

}

function unhide_regs_original()

{

# original value

# b0: c0 00 20 01 ce 00 20 01 c0 00 24 01 ec 00 20 01

# c0: e0 08 48 00 e0 0f 48 00 e0 0f 04 00 e0 05 00 00

#

setpci -s 7f:10.7 0xb0.b=0x00;

setpci -s 7f:10.7 0xb4.b=0x0e;

setpci -s 7f:10.7 0xb8.b=0x00;

setpci -s 7f:10.7 0xbc.b=0x2c;

#setpci -s 7f:10.7 0xc0.b=0x20;

#setpci -s 7f:10.7 0xc4.b=0x20;

#setpci -s 7f:10.7 0xc8.b=0x20;

#setpci -s 7f:10.7 0xcc.b=0x20;

setpci -s ff:10.7 0xb0.b=0x00;

setpci -s ff:10.7 0xb4.b=0x0e;

setpci -s ff:10.7 0xb8.b=0x00;

setpci -s ff:10.7 0xbc.b=0x2c;

#setpci -s ff:10.7 0xc0.b=0x20;

#setpci -s ff:10.7 0xc4.b=0x20;

#setpci -s ff:10.7 0xc8.b=0x20;

#setpci -s ff:10.7 0xcc.b=0x20;

echo "After unhide regs:" | tee -a lspci.log

lspci -vvvv -t -A intel-conf1 | tee -a lspci.log

}

function hide_regs_original()

{

# original value

# b0: c0 00 20 01 ce 00 20 01 c0 00 24 01 ec 00 20 01

# c0: e0 08 48 00 e0 0f 48 00 e0 0f 04 00 e0 05 00 00

#

setpci -s 7f:10.7 0xb0.b=0xc0;

setpci -s 7f:10.7 0xb4.b=0xce;

setpci -s 7f:10.7 0xb8.b=0xc0;

setpci -s 7f:10.7 0xbc.b=0xec;

#setpci -s 7f:10.7 0xc0.b=0xe0;

#setpci -s 7f:10.7 0xc4.b=0xe0;

#setpci -s 7f:10.7 0xc8.b=0xe0;

#setpci -s 7f:10.7 0xcc.b=0xe0;

setpci -s ff:10.7 0xb0.b=0xc0;

setpci -s ff:10.7 0xb4.b=0xce;

setpci -s ff:10.7 0xb8.b=0xc0;

setpci -s ff:10.7 0xbc.b=0xec;

#setpci -s ff:10.7 0xc0.b=0xe0;

#setpci -s ff:10.7 0xc4.b=0xe0;

#setpci -s ff:10.7 0xc8.b=0xe0;

#setpci -s ff:10.7 0xcc.b=0xe0;

echo "After hide regs:" | tee -a lspci.log

lspci -vvvv -t -A intel-conf1 | tee -a lspci.log

}

# to set eeprom, however it doens‘t matter to verify the process of hot plug even if it is emplty

set_eeprom()

{

echo "Set EEPROM done!";

}

# the main process, notice:

## 1. either disable_aer/enable_aer or disable_smi/enable_smi can be used, but it is not recommended

##    to use like this method: disable_aer/enable_smi or disable_smi/enable_aer.

## 2. This fucntion is only for PCIE card 2 and assume the card is: Broadcom Corporation BCM57840 NetXtreme II 10 Gigabit Ethernet,

##      that means it is a ROckslide (Broadcom q-port 10GbE) card

main3()

{

if [ $1 -eq 1 ]

then

#disable_smi;

#enable_aer 00:03.0

disable_aer 00:03.0

disable_sp_reset_on_slicevent;

poweroff_slic;

# do remove the slic

echo "after power off slic" | tee -a lspci.log

#lspci -vvvv -t -A intel-conf1 | tee -a lspci.log

clear_aer 00:03.0

#enable_smi

#enable_aer 00:03.0

#disable_aer 00:03.0

fi

#echo "sleep 2s";

#sleep 2;

#echo "sleep 2s done";

# insert the SLIC again

#echo 1 > /sys/bus/pci/rescan

if [ $1 -eq 0 ]

then

temp=`lspci -xxx -s 00:03.0| grep "a0:"`;

exp=`echo $temp | awk ‘{print $4}‘`;

echo "Before power on slic: Original link status is : $exp";

poweron_slic

disable_slic_holdinreset

unhide_regs_original;

unhide_regs

echo 1 > /sys/bus/pci/rescan

apply_serdes

#disable_aer 00:03.0

temp=`lspci -xxx -s 00:03.0| grep "a0:"`;

exp=`echo $temp | awk ‘{print $4}‘`;

echo "Before retarin: Original link status is : $exp";

retrain

#hide_regs_original

#clear_aer 00:03.0

#clear_aer 80:02.0

#clear_aer 00:03.0

#clear_aer 00:01.0

#hide_regs

#echo 1 > /sys/bus/pci/rescan

#echo 1 > /sys/bus/pci/devices/0000:00:03.0/rescan

restore_bar;

restore_cmd;

enable_aer 00:03.0

#enable_smi

# echo "After retrain and rescan" | tee -a lspci.log

# lspci -vvvv -t -A intel-conf1 | tee -a lspci.log

fi

}

main3 $1;

## usage as below:  ###

#main3 0 ## hot insertion

#main3 1 ## hot removal

时间: 2024-10-21 08:27:08

PCIE AER and hot removal的相关文章

多功能PCIE交换机之一:概述

多功能PCIE交换机之一:概述 作为服务器或者系统升级的重要方法,横向扩展越来越时髦,越来越多的厂家利用这种方法来实现产品的升级.传统网络.InfinBand.PCIE都可以用来帮助实现横向扩展,这里着重介绍基于PCIE技术实现的横向扩展和容错设计.基于PCIE实现横向扩展和容错设计离不开PCIE多功能交换机.所谓多功能PCIE交换机,指的是一种拥有多个PCIE桥.支持多种配置.自带非透明桥甚至DMA功能的配置灵活.管理方便的芯片. 为了便于读者有更直观的认识,后面都以PLX某款多功能PCIE

make menuconfig简介

Y--将该功能编译进内核  N--不将该功能编译进内核 M--将该功能编译成可以在需要时动态插入到内核中的模块  如果你是使用的是 make xconfig,那使用鼠标就可以选择对应的选项.这里使用的是 make  menuconfig,所以需要使用空格键进行选取.在每一个选项前都有一个括号, 有的是中括号有的是尖括号,还有圆括号.用空格键选择时可以发现,中括号里要么是空,要么是"*": 而尖括号里可以是空,"*"表示编译到内核里:"M"表示编译

systemtap 列出所有linux 内核模块与相关函数1

阿里云主机 [[email protected] klvl]# uname -aLinux monitor 2.6.32-431.23.3.el6.x86_64 #1 SMP Thu Jul 31 17:20:51 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux stap -l 'module("模块名").function("*")'   //EG:mmc_block.ko不要.ok stap -l 'module("mm

linux kernel menuconfig【转载】

原文网址:http://www.cnblogs.com/kulin/archive/2013/01/04/linux-core.html Linux内核裁减 (1)安装新内核: i)将新内核copy到/usr/src下, #tar xzvf linux-2.6.38.4.tar.gz -----解压缩. ii) 将名为linux的符号链接删掉,这是旧版本内核的符号链接. #ln -s linux-2.6.38.4 linux ------建立linux-2.6.38.4的符号链接linux. (

PCIE知识点

引自:http://bbs.eetop.cn/thread-442072-1-1.html 1.从速度上来讲PCIE1.0标准 2.5G(8B/10B),pcie2.0标准 5.0G(8B/10B)pcie3.0标准8G(128B/130B) 通道来讲:X1,X2,X4,X8,X16. 中断实现:1:lengcy INTN2:传统中断3:MSI中断. 辅助功能 :1:功耗管理2:AER机制.3:FC流量控制与调节机制. 从结构上来讲分为GTP+数据链路层+应用层,其中GTP和数据链路层是IP提供

Intel CPU屏蔽PCIE错误的两种方法

HasWell CPU PCIE Error 屏蔽的两种办法 在做PCIE卡设备热插拔,或者需要强行断掉PCIE卡的供电且不导致系统重启的情况下,HaswellCPU提供了多种方式. 方式一是利用PCIE的PCIE 和AER capability的相关位,屏蔽这些位可以防止上述操作导致系统重启:清除这些位后并打开屏蔽位后,就可以继续向CPU传递PCI的各种错误.下面分别讲述如何屏幕和打开错误使能位然后执行相应PCIE卡槽的操作. 1.      Disable AER: I.          

imx6 PCIE使能加载ath9k无线网卡

imx6q配置pcie无线网卡遇到如下问题: imx6q-pcie 1ffc000.pcie: PCI host bridge to bus 0000:00 pci_bus 0000:00: root bus resource [io  0x1000-0x10000] pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] pci_bus 0000:00: root bus resource [bus 00-ff] pci 0

怎样訪问pcie整个4k的配置空间

眼下用于訪问PCIe配置空间寄存器的方法须要追溯到原始的PCI规范. 为了发起PCI总线配置周期,Intel实现的PCI规范使用IO空间的CF8h和CFCh来分别作为索引和数据寄存器,这样的方法能够訪问全部PCI设备的255 bytes配置寄存器.Intel Chipsets眼下仍然支持这样的訪问PCI配置空间的方法. PCIe规范在PCI规范的基础上,将配置空间扩展到4K bytes,至于为什么扩展到4K,详细能够參考PCIe规范,这些功能都须要配置空间.原来的CF8/CFC方法仍然能够訪问全

多功能PCIE交换机之九:单NT系统中需要注意的问题

多功能PCIE交换机之九:单NT系统中需要注意的问题 1.单NT与双NT系统差异 NTB通常用在双控或者多控的系统上,用来实现跨节点的数据传输.在由多个节点构成的系统上,通常每个节点上都有一个NTB芯片,以实现全系统地址空间划分和路由.顾名思义,单NT是指用一个PCIE非透明桥来实现节点间数据传输的方案,通常用在两个节点之间.和多NT的系统相比,这种方法实现相对比较简单,成本较低,开发周期较短,能够缩短整个系统的关键功能和性能的验证周期. 2.单NT系统的实现 单NT的实现需要结合整个系统的设计