Tuesday, April 8, 2014

PCI Express advanced topics: Part 2

PCIe Enumeration 

Before we go to the details of enumeration, lets use the following nomenclature. 
PCIe port : physical group of transmitter(s)/receiver(s) on same chip
PCIe lane : one pair of differential transmitter and receiver
PCIe link : collection of lane(s). 
Upstream device : is the root complex
Downstream device : end point that implements atleast one function
Upstream port : resides on the downstream device facing the upstream device
Downstream port : resides on the upstream device facing the downstream device

Figure -1 denotes these nomenclature.

Figure -1
Now, let's take an example of single lane (lane 0) - one root complex connected to one PCIe device that implements one function for illustrating the enumeration process.

Enumeration is the process where the root complex driver discovers the PCI(e) bus topology by traversing through the hierarchy from root complex (which is at the top of the hierarchy). 

Following are the per-requisites that needs to be satisfied
a) Root complex is on the Bus 0 and configuration space access of the root complex is accessible using embedded CPU (via API or known mechanism)
b) The EP device that implements a function must have a Vendor ID that is not all '0xF's
c) link training has completed and link has been established on both the sides of the link and the Data link layer is in DL_ACTIVE state.

Steps below outlines the simplified enumeration procedure.
1) RC driver steps through the hierarchy to find all the connected downstream devices by looping the bus number. For E.g. read the vendor ID of the downstream device for bus 1 and device 0, function 0 
using the API to access the configuration space with the address set to 

CFG_ADDR = base_addr | 1<<20.

If there is valid function implemented on this downstream device, it must return a valid vendor ID and it is first step to discover this device

2) If the device is found, now the device needs to be assigned the memory window so that it gets allocated the memory space on the system memory map. This is done by scanning the BAR's and check for the BAR size and do the allocation accordingly. Downstream device BAR size can be found by writing all one's to the respective BAR register and checking for the bits that are zero's. Root complex driver needs to only set here the base address of the requested memory size.

e.g. EP device BAR0 after writing all '1's returns with  0xFF0000000 implies that the memory size requested by this EP device is 16MB and it is 32 bit addressable. Therefore the RC driver can assign any based address in the 4GB space to allocate  the requested 16MB memory 
e.g. BAR0 = 0x1C000000 as the base address

3) After the base address is assigned EP device needs to be configured to enable as bus master so that it can start sending memory TLP requests. 
set the command register to enable Bus master, memory enable and IO enable.

CMD_REGISTER | =  1<<2 | 1<<1 | 1<<0;
the above steps are basic functions required to for any PCIe based applications. End point now has to manage this allocated memory from the system as a memory resource for the their application specific implementation.

1 comment:

Rose Jurgen said...

Here is  my testimony on how I was cured of HIV by Dr Akhigbe,with his natural herbal medicine.  on a regular basis in efforts to help others when I could. As you may know, each donation is tested.  Well, on July 6th I had a meeting with a Red Cross representative and was told that I had HIV. “What went through your mind when you heard that "Rose" Good question reader! To be honest, I thought my life was over, that I would ever find love, get married, have children or anything normal. Lucky for me I have an amazing support system.  My family supported me then I never thought that I was invincible to STD s or pregnancy or anything else parents warn their kids about. I just didn’t think about it. I was in a monogamous relationship and thought that I asked the right questions.  We even talked about marriage Scary.  During that time I was in college and donated blood on a re as well. who helped me in search of cure through the media.there we saw a good testimony of sister 'Kate' about the good work of Dr Akhigbe natural herbal medicine cure.then I copied his email address and contacted him. A good herbalist doctor with a good heart, he is kind, loving and caring. He replied back to my message and told me what to do. After a week the doctor sent me my herbal medicine and instructed me how to take it.Yes it worked very well, after drinking it I went to the hospital for another test and everything turned negative. What a wonderful testimony I can never forget in my life. Dr Akhigbe is a man who gave me a life to live happily forever so all I want you all to believe and know that cure of HIV is real and herbs is a powerful medicine and it works and heals.  Dr Akhigbe also used his herbal medicine to cure diseases like:   HERPES, DIABETES, SCABIES, HEPATITIS A/B, STROKE, CANCER, ALS, TUBERCULOSIS, ASTHMA, PENIS ENLARGEMENT, MALARIA, LUPUS, LIVER CIRRHOSIS, DEPRESSION, HIV/AIDS, EPILEPSY, BACTERIAL, DIARRHEA, HEART DISEASES, HIGH BLOOD PRESSURE, PARKINSON'S, ALZHEIMER, COLD URTICARIA, HUMAN PAPILLOMAVIRUS,INSOMNIA,  BACTERIAL VAGINOSIS, SCHIZOPHRENIA, JOINT PAIN, STOMACH PAIN, CHROME DISEASES, CHLAMYDIA, INSOMNIA HEARTBURN, ,  THYROID, MAR BURG DISEASES, MENINGITIS, ARTHRITIS, BODY WEAK, SMALLPOX, DENGUE, FEVER, CURBS, CHANCRE, AND OTHERS VARIOUS DISEASES/ VIRUS.   You are there and you find yourself in any of these situations, kindly contact Dr Akhigbe now to help you get rid of it. Here is his email address:
   drrealakhigbe@gmail.com      or you can write to him on whats app with his phone number:   +2349010754824.
  My appreciation is to share his testimony for the world to know the good work Dr Akhigbe has done for me and he will do the same for you.