#if EFSYS_OPT_PCI
+typedef struct efx_pci_ops_s {
+ /*
+ * Function for reading PCIe configuration space.
+ *
+ * espcp System-specific PCIe device handle;
+ * offset Offset inside PCIe configuration space to start reading
+ * from;
+ * edp EFX DWORD structure that should be populated by function
+ * in little-endian order;
+ *
+ * Returns status code, 0 on success, any other value on error.
+ */
+ efx_rc_t (*epo_config_readd)(efsys_pci_config_t *espcp,
+ uint32_t offset, efx_dword_t *edp);
+ /*
+ * Function for finding PCIe memory bar handle by its index from a PCIe
+ * device handle. The found memory bar is available in read-only mode.
+ *
+ * configp System-specific PCIe device handle;
+ * index Memory bar index;
+ * memp Pointer to the found memory bar handle;
+ *
+ * Returns status code, 0 on success, any other value on error.
+ */
+ efx_rc_t (*epo_find_mem_bar)(efsys_pci_config_t *configp,
+ int index, efsys_bar_t *memp);
+} efx_pci_ops_t;
+
/* Determine EFX family and perform lookup of the function control window
*
* The function requires PCI config handle from which all memory bars can
__in uint16_t venid,
__in uint16_t devid,
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__out efx_family_t *efp,
__out efx_bar_region_t *ebrp);
extern __checkReturn efx_rc_t
efx_pci_config_find_next_ext_cap(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__in uint16_t cap_id,
__inout size_t *offsetp);
extern __checkReturn efx_rc_t
efx_pci_config_next_ext_cap(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__inout size_t *offsetp);
/*
extern __checkReturn efx_rc_t
efx_pci_find_next_xilinx_cap_table(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__inout size_t *pci_cap_offsetp,
__out unsigned int *xilinx_tbl_barp,
__out efsys_dma_addr_t *xilinx_tbl_offsetp);
extern __checkReturn efx_rc_t
efx_pci_read_ext_cap_xilinx_table(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__in size_t cap_offset,
__out unsigned int *barp,
__out efsys_dma_addr_t *offsetp);
__in uint16_t venid,
__in uint16_t devid,
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__out efx_family_t *efp,
__out efx_bar_region_t *ebrp)
{
#if EFSYS_OPT_RIVERHEAD
case EFX_PCI_DEVID_RIVERHEAD:
case EFX_PCI_DEVID_RIVERHEAD_VF:
- rc = rhead_pci_nic_membar_lookup(espcp, ebrp);
+ rc = rhead_pci_nic_membar_lookup(espcp, epop, ebrp);
if (rc == 0)
*efp = EFX_FAMILY_RIVERHEAD;
__checkReturn efx_rc_t
efx_pci_config_next_ext_cap(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__inout size_t *offsetp)
{
efx_dword_t hdr;
if (*offsetp == 0) {
*offsetp = ESE_GZ_PCI_BASE_CONFIG_SPACE_SIZE;
} else {
- EFSYS_PCI_CONFIG_READD(espcp, *offsetp +
+ rc = epop->epo_config_readd(espcp, *offsetp +
(EFX_LOW_BIT(ESF_GZ_PCI_EXPRESS_XCAP_ID) / 8),
- &hdr, &rc);
+ &hdr);
if (rc != 0) {
rc = EIO;
goto fail2;
__checkReturn efx_rc_t
efx_pci_config_find_next_ext_cap(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__in uint16_t cap_id,
__inout size_t *offsetp)
{
position = *offsetp;
while (1) {
- rc = efx_pci_config_next_ext_cap(espcp, &position);
+ rc = efx_pci_config_next_ext_cap(espcp, epop, &position);
if (rc != 0) {
if (rc == ENOENT)
break;
goto fail2;
}
- EFSYS_PCI_CONFIG_READD(espcp, position +
+ rc = epop->epo_config_readd(espcp, position +
(EFX_LOW_BIT(ESF_GZ_PCI_EXPRESS_XCAP_ID) / 8),
- &hdr, &rc);
+ &hdr);
if (rc != 0) {
rc = EIO;
goto fail3;
__checkReturn efx_rc_t
efx_pci_find_next_xilinx_cap_table(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__inout size_t *pci_cap_offsetp,
__out unsigned int *xilinx_tbl_barp,
__out efsys_dma_addr_t *xilinx_tbl_offsetp)
unsigned int tbl_bar;
efsys_dma_addr_t tbl_offset;
- rc = efx_pci_config_find_next_ext_cap(espcp,
+ rc = efx_pci_config_find_next_ext_cap(espcp, epop,
ESE_GZ_PCI_EXPRESS_XCAP_ID_VNDR, &cap_offset);
if (rc != 0) {
if (rc == ENOENT)
* locator. Try to read it and skip it if the capability is
* not the locator.
*/
- rc = efx_pci_read_ext_cap_xilinx_table(espcp, cap_offset,
+ rc = efx_pci_read_ext_cap_xilinx_table(espcp, epop, cap_offset,
&tbl_bar, &tbl_offset);
if (rc == 0) {
*xilinx_tbl_barp = tbl_bar;
__checkReturn efx_rc_t
efx_pci_read_ext_cap_xilinx_table(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__in size_t cap_offset,
__out unsigned int *barp,
__out efsys_dma_addr_t *offsetp)
efsys_dma_addr_t offset;
efx_rc_t rc;
- EFSYS_PCI_CONFIG_READD(espcp, cap_offset +
+ rc = epop->epo_config_readd(espcp, cap_offset +
(EFX_LOW_BIT(ESF_GZ_PCI_EXPRESS_XCAP_ID) / 8),
- &cap_hdr, &rc);
+ &cap_hdr);
if (rc != 0) {
rc = EIO;
goto fail1;
goto fail2;
}
- EFSYS_PCI_CONFIG_READD(espcp, vsec_offset +
+ rc = epop->epo_config_readd(espcp, vsec_offset +
(EFX_LOW_BIT(ESF_GZ_VSEC_ID) / 8),
- &vsec.eo_dword[0], &rc);
+ &vsec.eo_dword[0]);
if (rc != 0) {
rc = EIO;
goto fail3;
goto fail5;
}
- EFSYS_PCI_CONFIG_READD(espcp, vsec_offset +
+ rc = epop->epo_config_readd(espcp, vsec_offset +
(EFX_LOW_BIT(ESF_GZ_VSEC_TBL_BAR) / 8),
- &vsec.eo_dword[1], &rc);
+ &vsec.eo_dword[1]);
if (rc != 0) {
rc = EIO;
goto fail6;
offset_low = EFX_OWORD_FIELD32(vsec, ESF_GZ_VSEC_TBL_OFF_LO);
if (vsec_len >= ESE_GZ_VSEC_LEN_HIGH_OFFT) {
- EFSYS_PCI_CONFIG_READD(espcp, vsec_offset +
+ rc = epop->epo_config_readd(espcp, vsec_offset +
(EFX_LOW_BIT(ESF_GZ_VSEC_TBL_OFF_HI) / 8),
- &vsec.eo_dword[2], &rc);
+ &vsec.eo_dword[2]);
if (rc != 0) {
rc = EIO;
goto fail7;
extern __checkReturn efx_rc_t
rhead_pci_nic_membar_lookup(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__out efx_bar_region_t *ebrp);
#endif /* EFSYS_OPT_PCI */
__checkReturn efx_rc_t
rhead_pci_nic_membar_lookup(
__in efsys_pci_config_t *espcp,
+ __in const efx_pci_ops_t *epop,
__out efx_bar_region_t *ebrp)
{
boolean_t xilinx_tbl_found = B_FALSE;
* the following discovery steps.
*/
while (1) {
- rc = efx_pci_find_next_xilinx_cap_table(espcp, &pci_capa_offset,
+ rc = efx_pci_find_next_xilinx_cap_table(espcp, epop,
+ &pci_capa_offset,
&xilinx_tbl_bar,
&xilinx_tbl_offset);
if (rc != 0) {
xilinx_tbl_found = B_TRUE;
- EFSYS_PCI_FIND_MEM_BAR(espcp, xilinx_tbl_bar, &xil_eb, &rc);
+ rc = epop->epo_find_mem_bar(espcp, xilinx_tbl_bar, &xil_eb);
if (rc != 0)
goto fail2;
if (bar_found == B_FALSE)
goto fail4;
- EFSYS_PCI_FIND_MEM_BAR(espcp, ebrp->ebr_index, &nic_eb, &rc);
+ rc = epop->epo_find_mem_bar(espcp, ebrp->ebr_index, &nic_eb);
if (rc != 0)
goto fail5;