78 unsigned int cap = vpd->
cap;
120 DBGC ( vpd,
PCI_FMT " VPD %04x read via %02x timed out\n",
136 unsigned int cap = vpd->
cap;
137 unsigned int retries;
169 DBGC ( vpd,
PCI_FMT " VPD %04x write via %02x timed out\n",
202 for ( i = 4 ; i ; i-- ) {
240 if ( skip_len || (
len <= 0x03 ) ) {
247 for ( i = 4 ; i ; i-- ) {
283 sizeof ( buf ) ) ) != 0 )
309 sizeof ( read_tag ) ) ) != 0 )
315 sizeof ( read_len ) ) ) != 0)
317 *
address +=
sizeof ( read_len );
326 if (
tag == read_tag ) {
370 while ( *
len >=
sizeof ( read_field ) ) {
374 sizeof ( read_field ) ) ) != 0 )
376 *
address +=
sizeof ( read_field );
377 *
len -=
sizeof ( read_field );
391 if ( read_field.
len > *
len )
416 unsigned int rw_address;
417 unsigned int old_address;
418 unsigned int copy_address;
419 unsigned int dst_address;
420 unsigned int dump_address;
423 size_t available_len;
441 &old_len ) ) == 0 ) {
444 if ( old_address > rw_address ) {
446 " at [%04x,%04zx) is after field " 450 old_address, ( old_address + old_len ),
452 rw_address, ( rw_address + rw_len ) );
456 dst_address = ( old_address -
sizeof ( old_field ) );
457 copy_address = ( old_address + old_len );
458 copy_len = ( rw_address -
sizeof ( rw_field ) - copy_address );
461 available_len = ( rw_len + old_len );
466 dst_address = ( rw_address -
sizeof ( rw_field ) );
467 copy_address = dst_address;
471 available_len = ( ( rw_len >
sizeof ( new_field ) ) ?
472 ( rw_len -
sizeof ( new_field ) ) : 0 );
476 dump_address = dst_address;
477 dump_len = ( rw_address + rw_len - dump_address );
486 if (
len > available_len ) {
490 len, available_len );
496 copy =
malloc ( copy_len );
501 if ( (
rc =
pci_vpd_read ( vpd, copy_address, copy, copy_len ) ) != 0 )
509 sizeof ( new_field ) ) ) != 0 )
511 dst_address +=
sizeof ( new_field );
516 ( dst_address + new_field.
len ) );
525 if ( (
rc =
pci_vpd_write ( vpd, dst_address, copy, copy_len ) ) != 0 )
527 dst_address += copy_len;
531 rw_field.
len = ( rw_len +
532 ( rw_address -
sizeof ( rw_field ) ) - dst_address );
534 sizeof ( rw_field ) ) ) != 0 )
536 dst_address +=
sizeof ( rw_field );
540 ( dst_address + rw_field.
len ) );
#define PCI_VPD_MAX_WAIT_MS
Maximum wait for PCI VPD (in ms)
int pci_vpd_find(struct pci_vpd *vpd, unsigned int field, unsigned int *address, size_t *len)
Locate PCI VPD field.
struct arbelprm_rc_send_wqe rc
#define PCI_VPD_TAG(field)
Extract PCI VPD ISAPnP tag.
#define PCI_VPD_FLAG
PCI VPD write flag.
int pci_vpd_read(struct pci_vpd *vpd, unsigned int address, void *buf, size_t len)
Read PCI VPD.
uint64_t address
Base address.
int pci_write_config_word(struct pci_device *pci, unsigned int where, uint16_t value)
Write 16-bit word to PCI configuration space.
#define ISAPNP_SMALL_TAG_NAME(tag)
#define ENOENT
No such file or directory.
int pci_read_config_word(struct pci_device *pci, unsigned int where, uint16_t *value)
Read 16-bit word from PCI configuration space.
int pci_vpd_resize(struct pci_vpd *vpd, unsigned int field, size_t len, unsigned int *address)
Resize VPD field.
static void pci_vpd_invalidate_cache(struct pci_vpd *vpd)
Invalidate PCI VPD read cache.
static int pci_vpd_read_dword(struct pci_vpd *vpd, int address, uint32_t *data)
Read one dword of PCI Vital Product Data.
#define PCI_VPD_TAG_RW
PCI VPD Read-Write field tag.
int cap
VPD capability offset.
static int pci_vpd_find_tag(struct pci_vpd *vpd, unsigned int tag, unsigned int *address, size_t *len)
Locate PCI VPD tag.
#define PCI_VPD_MAX_LEN
Maximum PCI VPD field length.
static int pci_vpd_cache_is_valid(struct pci_vpd *vpd)
Check if PCI VPD read cache is valid.
#define ENOMEM
Not enough space.
#define ISAPNP_SMALL_TAG_LEN(tag)
#define ISAPNP_LARGE_TAG_NAME(tag)
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
int pci_read_config_dword(struct pci_device *pci, unsigned int where, uint32_t *value)
Read 32-bit dword from PCI configuration space.
#define PCI_VPD_FIELD_FMT
PCI VPD field debug message format.
static void(* free)(struct refcnt *refcnt))
#define PCI_FMT
PCI device debug message format.
int pci_vpd_write(struct pci_vpd *vpd, unsigned int address, const void *buf, size_t len)
Write PCI VPD.
struct pci_vpd_cache cache
Read cache.
#define PCI_VPD_ADDRESS
PCI VPD address register.
#define ISAPNP_IS_LARGE_TAG(tag)
#define le16_to_cpu(value)
void * malloc(size_t size)
Allocate memory.
#define PCI_VPD_FIELD_ARGS(field)
PCI VPD field debug message arguments.
void mdelay(unsigned long msecs)
Delay for a fixed number of milliseconds.
#define ENXIO
No such device or address.
#define ENOSPC
No space left on device.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
struct pci_device * pci
PCI device.
#define ENOTTY
Inappropriate I/O control operation.
#define PCI_ARGS(pci)
PCI device debug message arguments.
static int pci_vpd_write_dword(struct pci_vpd *vpd, int address, uint32_t data)
Write one dword of PCI Vital Product Data.
int pci_write_config_dword(struct pci_device *pci, unsigned int where, uint32_t value)
Write 32-bit dword to PCI configuration space.
static void pci_vpd_dump(struct pci_vpd *vpd, unsigned int address, size_t len)
Dump PCI VPD region (for debugging)
uint8_t data[48]
Additional event data.
#define PCI_VPD_KEYWORD(field)
Extract PCI VPD keyword.
#define PCI_VPD_FIELD_RW
PCI VPD Remaining Read/Write Area field descriptor.
#define PCI_VPD_DATA
PCI VPD data register.
uint32_t flag
Flag number.
uint64_t tag
Identity tag.
#define PCI_CAP_ID_VPD
Vital product data.
#define ETIMEDOUT
Connection timed out.
int pci_vpd_init(struct pci_vpd *vpd, struct pci_device *pci)
Initialise PCI Vital Product Data.