1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2020 Xilinx, Inc.
4 * Copyright(c) 2019 Solarflare Communications Inc.
10 #if EFSYS_OPT_RIVERHEAD && EFSYS_OPT_PCI
13 * Search for a EF100 resource locator from the given offset of an entry
14 * in a Xilinx capabilities table.
16 static __checkReturn efx_rc_t
17 rhead_xilinx_cap_tbl_find_ef100_locator(
18 __in efsys_bar_t *esbp,
19 __in efsys_dma_addr_t tbl_offset,
20 __out efx_bar_region_t *ef100_ebrp)
23 efsys_dma_addr_t entry_offset = tbl_offset;
25 rc = efx_pci_xilinx_cap_tbl_find(esbp, ESE_GZ_CFGBAR_ENTRY_EF100,
26 B_FALSE, &entry_offset);
28 /* EF100 locator not found (ENOENT) or other error */
32 rc = rhead_nic_xilinx_cap_tbl_read_ef100_locator(esbp, entry_offset,
42 EFSYS_PROBE1(fail1, efx_rc_t, rc);
47 __checkReturn efx_rc_t
48 rhead_pci_nic_membar_lookup(
49 __in efsys_pci_config_t *espcp,
50 __out efx_bar_region_t *ebrp)
52 boolean_t xilinx_tbl_found = B_FALSE;
53 unsigned int xilinx_tbl_bar;
54 efsys_dma_addr_t xilinx_tbl_offset;
55 size_t pci_capa_offset = 0;
56 boolean_t bar_found = B_FALSE;
61 * SF-119689-TC Riverhead Host Interface section 4.2.2. describes
62 * the following discovery steps.
65 rc = efx_pci_find_next_xilinx_cap_table(espcp, &pci_capa_offset,
70 * SF-119689-TC Riverhead Host Interface section 4.2.2.
71 * defines the following fallbacks for the memory bar
72 * and the offset when no Xilinx capabilities table is
75 if (rc == ENOENT && xilinx_tbl_found == B_FALSE) {
76 ebrp->ebr_type = EFX_BAR_TYPE_MEM;
77 ebrp->ebr_index = EFX_MEM_BAR_RIVERHEAD;
88 xilinx_tbl_found = B_TRUE;
90 EFSYS_PCI_FIND_MEM_BAR(espcp, xilinx_tbl_bar, &xil_eb, &rc);
94 rc = rhead_xilinx_cap_tbl_find_ef100_locator(&xil_eb,
98 /* Found valid EF100 locator. */
101 } else if (rc != ENOENT) {
102 /* Table access failed, so terminate search. */
107 if (bar_found == B_FALSE)
119 EFSYS_PROBE1(fail1, efx_rc_t, rc);
124 #endif /* EFSYS_OPT_RIVERHEAD && EFSYS_OPT_PCI */