1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2019-2021 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 __in const efx_pci_ops_t *epop,
51 __out efx_bar_region_t *ebrp)
53 boolean_t xilinx_tbl_found = B_FALSE;
54 unsigned int xilinx_tbl_bar;
55 efsys_dma_addr_t xilinx_tbl_offset;
56 size_t pci_capa_offset = 0;
57 boolean_t bar_found = B_FALSE;
65 * SF-119689-TC Riverhead Host Interface section 4.2.2. describes
66 * the following discovery steps.
69 rc = efx_pci_find_next_xilinx_cap_table(espcp, epop,
75 * SF-119689-TC Riverhead Host Interface section 4.2.2.
76 * defines the following fallbacks for the memory bar
77 * and the offset when no Xilinx capabilities table is
80 if (rc == ENOENT && xilinx_tbl_found == B_FALSE) {
81 ebrp->ebr_type = EFX_BAR_TYPE_MEM;
82 ebrp->ebr_index = EFX_MEM_BAR_RIVERHEAD;
93 xilinx_tbl_found = B_TRUE;
95 rc = epop->epo_find_mem_bar(espcp, xilinx_tbl_bar, &xil_eb);
99 rc = rhead_xilinx_cap_tbl_find_ef100_locator(&xil_eb,
103 /* Found valid EF100 locator. */
106 } else if (rc != ENOENT) {
107 /* Table access failed, so terminate search. */
112 if (bar_found == B_FALSE)
115 rc = epop->epo_find_mem_bar(espcp, ebrp->ebr_index, &nic_eb);
119 EFSYS_BAR_READD(&nic_eb, ebrp->ebr_offset + ER_GZ_NIC_MAGIC_OFST,
122 magic = EFX_DWORD_FIELD(magic_ed, ERF_GZ_NIC_MAGIC);
123 if (magic != EFE_GZ_NIC_MAGIC_EXPECTED) {
141 EFSYS_PROBE1(fail1, efx_rc_t, rc);
146 #endif /* EFSYS_OPT_RIVERHEAD && EFSYS_OPT_PCI */