I am new to PCI protocol and would like to know where is the function number of a device stored? This is important for me because I have inserted an ad on a customized card in a PCI slot of my windows system. The card contains two instances of the same device. I know that these two devices will be differentiated on the basis of function number, since my bus no and device id are the same but I am unable to understand when is the function number assigned to the device and is it stored in my device BAR?
2 Answers
This thread answered it well for me: https://www.osronline.com/showthread.cfm?link=155585
The function allows a single device in a single slot to appear as multiple logical devices to the OS.
This essentially creates multiple separated communication channels between OS and device. In particular, each function has its own BAR: What is Base Address Register (BAR) in PCIe?
An example would be a network card that appears to the OS as two NICs.
What function does what is completely up to the device to implement.

- 347,512
- 102
- 1,199
- 985
Function number is "embedded" in hardware and it is not stored in device BAR(where BAR is the pci configuration space registers with read/write attribute). In your case the card has 2 functions, namely Function 0 and 1(maybe). This is hardwired in device and no one can change it. In PCI enumeration process it will be identified/enumerated and then can be access via (Bus,Dev,Func) numbers

- 193
- 2
- 15