Documentation ¶
Overview ¶
Package pcie builds and parses PCIe Transport Layer Packets (TLP).
Index ¶
- Constants
- Variables
- func CplCalcByteCount(firstBE, lastBE, length int) int
- func CplCalcLowerAddress(firstBE int, readAddress Address) byte
- type Address
- type AddressType
- type CfgHeader
- type CfgRd
- type CfgWr
- type CompletionStatus
- type Cpl
- type CplHeader
- type DeviceID
- type IORd
- type IOWrt
- type MRd
- type MWr
- type RequestHeader
- type TlpHeader
- type TlpType
- type TrafficClass
Constants ¶
const (
// MaxTLPBuffer is a 4 dword header + max data payload.
MaxTLPBuffer = 4*dwordLen + maxDataLen*dwordLen
)
Variables ¶
var ( ErrBadType = errors.New("bad TLP header type") ErrBadLength = errors.New("bad TLP data length") ErrBadAddress = errors.New("bad TLP address") ErrTooShort = errors.New("TLP packet too short") )
errors
Functions ¶
func CplCalcByteCount ¶
See Table 2-37: Calculating Byte Count from Length and Byte Enables.
func CplCalcLowerAddress ¶
Table 2-38: Calculating Lower Address from 1st DW BE.
Types ¶
type AddressType ¶
type AddressType uint8
AddressType is the address type field in the request header.
const ( DefaultUntranslated AddressType = 0b00 TranslationRequest AddressType = 0b01 Translated AddressType = 0b10 AddressTypeReserved AddressType = 0b11 )
Supported address types.
type CfgHeader ¶
type CfgHeader struct { RequestHeader Target DeviceID // Register number (6b) RegisterNumber int // Extended register number (4b) ExtRegisterNumber int }
CfgHeader extends RequestHeader and includes the third header dword for configuration read TLPs.
type CfgRd ¶
type CfgRd struct {
CfgHeader
}
CfgRd TLP: Configuration read request.
type CfgWr ¶
CfgWr TLP: Configuration write request.
func NewCfgWrFromBytes ¶
NewCfgWrFromBytes builds a memory read request from a TLP buffer.
func (*CfgWr) FirstDataByte ¶
Returns the first enabled data.
func (*CfgWr) MemoryAddress ¶
Returns the config space memory address. Table 7-1: Enhanced Configuration Address Mapping.
type CompletionStatus ¶
type CompletionStatus uint8
CompletionStatus is the completion status field in the completion header.
const ( SuccessfulCompletion CompletionStatus = 0b000 UnsupportedRequest CompletionStatus = 0b001 ConfigurationRequestRetry CompletionStatus = 0b010 CompleterAbort CompletionStatus = 0b100 )
Supported completion status.
type Cpl ¶
Cpl TLP: Completion response.
func NewCpl ¶
func NewCpl(cplID DeviceID, bc int, status CompletionStatus, reqID DeviceID, tag, addressLow uint8, data []byte) (*Cpl, error)
NewCpl builds completion response.
func NewCplForMrd ¶
NewCplForMrd builds a completion response that matches the given memory read request.
func NewCplFromBytes ¶
NewCplFromBytes builds completion response from TLP buffer.
type CplHeader ¶
type CplHeader struct { TlpHeader // Completer ID. CplID DeviceID // Byte count: the number of bytes left for transmission, including those in // the current packet (12b). BC int // Completion status. Status CompletionStatus // Requester ID. ReqID DeviceID // Unique tag for all outstanding requests. Tag uint8 // Lower Byte Address for starting byte of Completion (7b). AddressLow uint8 }
CplHeader extends TlpHeader and includes the second and third header dwords for Completion TLPs. See section 2.2.9. Completion Rules
type DeviceID ¶
DeviceID is a configuration space address that uniquely identifies the device on the PCIe fabric.
func NewDeviceID ¶
NewDeviceID builds a new DeviceID from an encoded uint16 value.
func (*DeviceID) FromString ¶
FromString assigns DeviceID from an encoded string value.
func (*DeviceID) FromUint16 ¶
FromUint16 assigns DeviceID from an encoded uint16 value.
type IORd ¶
type IORd struct { RequestHeader Address Address }
IORd TLP: I/O read request.
type IOWrt ¶
type IOWrt struct { RequestHeader Address Address Data []byte }
IOWrt TLP: Memory write request.
type MRd ¶
type MRd struct { RequestHeader Address Address }
MRd TLP: Memory read request.
func NewMRd ¶
NewMRd builds memory read request. |length| is the number of BYTES to read and must be DWORD aligned.
func NewMRdFromBytes ¶
NewMRdFromBytes builds a memory read request from a TLP buffer.
type MWr ¶
type MWr struct { RequestHeader Address Address Data []byte }
MWr TLP: Memory write request.
func NewMWrFromBytes ¶
NewMWrFromBytes builds a memory write request from a TLP buffer.
type RequestHeader ¶
type RequestHeader struct { TlpHeader // Requester ID. ReqID DeviceID // Unique tag for all outstanding requests. Tag uint8 // First Byte Enable (4b). FirstBE uint8 // Last Byte Enable (4b). LastBE uint8 }
RequestHeader extends TlpHeader and includes the second header dword on Memory, IO, and Config Request TLPs.
type TlpHeader ¶
type TlpHeader struct { // Format and type. Type TlpType // Traffic class (3b). TC TrafficClass // Indicates that a Memory Request is an LN Read or LN Write (1b). LN bool // Presence of TLP Processing Hints (1b). TH bool // Presence of TLP digest in the form of a single DW at the end of the TLP (1b). TD bool // Indicates the TLP is poisoned (1b). EP bool // Attributes (3b): no-snoop, relaxed ordering, id-based ordering. NS bool RO bool IBO bool // Address Type (2b). AT AddressType // Length of data payload in DW (10b). Length int }
TlpHeader is the first header dword, common on all TLPs. See section 2.2.1. Common Packet Header Fields.
func (*TlpHeader) DataLength ¶
DataLength decodes h.Length to data length. See Table 2-4 Length[9:0] Field Encoding.
type TlpType ¶
type TlpType uint8
TlpType is the format and type field in the TLP header. See Table 2-3 in PCI EXPRESS BASE SPECIFICATION, REV. 3.1a.
const ( // MRd3 is a Memory Read Request encoded with 3 dwords. MRd3 TlpType = (fmt3DWNoData << 5) | 0b00000 // MRd4 is a Memory Read Request encoded with 4 dwords. MRd4 TlpType = (fmt4DWNoData << 5) | 0b00000 // MRdLk3 is a Memory Read Request-Locked encoded with 3 dwords. MRdLk3 TlpType = (fmt3DWNoData << 5) | 0b00001 // MRdLk4 is a Memory Read Request-Locked encoded with 4 dwords. MRdLk4 TlpType = (fmt4DWNoData << 5) | 0b00001 // MWr3 is a Memory Write Request encoded with 3 dwords. MWr3 TlpType = (fmt3DWWithData << 5) | 0b00000 // MWr4 is a Memory Write Request encoded with 4 dwords. MWr4 TlpType = (fmt4DWWithData << 5) | 0b00000 // IORdT is an I/O Read Request. IORdT TlpType = (fmt3DWNoData << 5) | 0b00010 // IOWrtT is an I/O Write Request. IOWrtT TlpType = (fmt3DWWithData << 5) | 0b00010 // CfgRd0 is a Configuration Read of Type 0. CfgRd0 TlpType = (fmt3DWNoData << 5) | 0b00100 // CfgWr0 is a Configuration Write of Type 0. CfgWr0 TlpType = (fmt3DWWithData << 5) | 0b00100 // CfgRd1 is a Configuration Read of Type 1. CfgRd1 TlpType = (fmt3DWNoData << 5) | 0b00101 // CfgWr1 is a Configuration Write of Type 1. CfgWr1 TlpType = (fmt3DWWithData << 5) | 0b00101 // CplE is a Completion without Data. Used for I/O and // Configuration Write Completions with any // Completion Status. CplE TlpType = (fmt3DWNoData << 5) | 0b01010 // CplD is a Completion with Data. Used for Memory, // I/O, and Configuration Read Completions. CplD TlpType = (fmt3DWWithData << 5) | 0b01010 // CplLk is a Completion for Locked Memory Read without // Data. Used only in error case. CplLk TlpType = (fmt3DWNoData << 5) | 0b01011 // CplLkD is a Completion for Locked Memory Read – // otherwise like CplD. CplLkD TlpType = (fmt3DWWithData << 5) | 0b01011 // MRIOV is a Multi-Root I/O Virtualization and Sharing (MR-IOV) TLP prefix. MRIOV TlpType = (fmtTlpPrefix << 5) | 0b00000 // LocalVendPrefix is a Local TLP prefix with vendor sub-field. LocalVendPrefix TlpType = (fmtTlpPrefix << 5) | 0b01110 // ExtTPH is an Extended TPH TLP prefix. ExtTPH TlpType = (fmtTlpPrefix << 5) | 0b10000 // PASID is a Process Address Space ID (PASID) TLP Prefix. PASID TlpType = (fmtTlpPrefix << 5) | 0b10001 // EndEndVendPrefix is an End-to-End TLP prefix with vendor sub-field. EndEndVendPrefix TlpType = (fmtTlpPrefix << 5) | 0b11110 )
type TrafficClass ¶
type TrafficClass uint8
TrafficClass is the traffic class field in the request header and used to set quality of service (QoS).
const ( TC0 TrafficClass = iota TC1 TC2 TC3 TC4 TC5 TC6 TC7 )
Supported traffic classes.