1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef _HALDEF_NVSWITCH_H_
25 #define _HALDEF_NVSWITCH_H_
26 
27 #include "ctrl_dev_nvswitch.h"
28 
29 #include "inforom/ifrstruct.h"
30 #include "inforom/omsdef.h"
31 
32 //
33 // List of functions halified in the NVSwitch Driver
34 //
35 // Note: All hal fns must be implemented for each chip.
36 //       There is no automatic stubbing here.
37 //
38 // This 'xmacro' list is fed into generator macros which then use the
39 // _FUNCTION_LIST to generate HAL declarations, function prototypes, and HAL
40 // construction.  Xmacros are a useful way to maintain consistency between
41 // parallel lists.
42 // The components of the _FUNCTION_LIST are similar to a function prototype
43 // declaration, with the addition of an '_arch' parameter suffixed on to it
44 // which is used on some _FUNCTION_LIST expansions to generate arch-specific
45 // information.
46 // The format of each line is:
47 //     _op(return type, function name, (parameter list), _arch)
48 //
49 
50 #define NVSWITCH_HAL_FUNCTION_LIST(_op, _arch)                                          \
51     _op(NvlStatus, nvswitch_initialize_device_state, (nvswitch_device *device), _arch)  \
52     _op(void,      nvswitch_destroy_device_state,    (nvswitch_device *device), _arch)  \
53     _op(void,      nvswitch_determine_platform,      (nvswitch_device *device), _arch)  \
54     _op(NvU32,     nvswitch_get_num_links,           (nvswitch_device *device), _arch)  \
55     _op(NvU8,      nvswitch_get_num_links_per_nvlipt,(nvswitch_device *device), _arch)  \
56     _op(NvBool,    nvswitch_is_link_valid,           (nvswitch_device *device, NvU32 link_id), _arch)  \
57     _op(void,      nvswitch_set_fatal_error,         (nvswitch_device *device, NvBool device_fatal, NvU32 link_id), _arch)  \
58     _op(NvU32,     nvswitch_get_swap_clk_default,    (nvswitch_device *device), _arch)  \
59     _op(NvU32,     nvswitch_get_latency_sample_interval_msec, (nvswitch_device *device), _arch)  \
60     _op(void,      nvswitch_internal_latency_bin_log,(nvswitch_device *device), _arch)  \
61     _op(void,      nvswitch_ecc_writeback_task,      (nvswitch_device *device), _arch)  \
62     _op(void,      nvswitch_monitor_thermal_alert,   (nvswitch_device *device), _arch)  \
63     _op(void,      nvswitch_hw_counter_shutdown,     (nvswitch_device *device), _arch)  \
64     _op(NvlStatus, nvswitch_get_rom_info,            (nvswitch_device *device, NVSWITCH_EEPROM_TYPE *eeprom), _arch)  \
65     _op(void,      nvswitch_lib_enable_interrupts,   (nvswitch_device *device), _arch)  \
66     _op(void,      nvswitch_lib_disable_interrupts,  (nvswitch_device *device), _arch)  \
67     _op(NvlStatus, nvswitch_lib_check_interrupts,    (nvswitch_device *device), _arch)  \
68     _op(NvlStatus, nvswitch_lib_service_interrupts,  (nvswitch_device *device), _arch)  \
69     _op(NvU64,     nvswitch_hw_counter_read_counter, (nvswitch_device *device), _arch)  \
70     _op(NvBool,    nvswitch_is_link_in_use,          (nvswitch_device *device, NvU32 link_id), _arch)  \
71     _op(NvlStatus, nvswitch_reset_and_drain_links,   (nvswitch_device *device, NvU64 link_mask), _arch)  \
72     _op(NvlStatus, nvswitch_ctrl_get_info,           (nvswitch_device *device, NVSWITCH_GET_INFO *p), _arch)  \
73     _op(NvlStatus, nvswitch_ctrl_get_nvlink_status,  (nvswitch_device *device, NVSWITCH_GET_NVLINK_STATUS_PARAMS *ret), _arch)  \
74     _op(NvlStatus, nvswitch_ctrl_get_counters,       (nvswitch_device *device, NVSWITCH_NVLINK_GET_COUNTERS_PARAMS *ret), _arch)  \
75     _op(NvlStatus, nvswitch_ctrl_set_switch_port_config,    (nvswitch_device *device, NVSWITCH_SET_SWITCH_PORT_CONFIG *p), _arch)  \
76     _op(NvlStatus, nvswitch_set_nport_port_config,   (nvswitch_device *device, NVSWITCH_SET_SWITCH_PORT_CONFIG *p), _arch)  \
77     _op(NvlStatus, nvswitch_ctrl_get_ingress_request_table, (nvswitch_device *device, NVSWITCH_GET_INGRESS_REQUEST_TABLE_PARAMS *params), _arch)  \
78     _op(NvlStatus, nvswitch_ctrl_set_ingress_request_table, (nvswitch_device *device, NVSWITCH_SET_INGRESS_REQUEST_TABLE *p), _arch)  \
79     _op(NvlStatus, nvswitch_ctrl_set_ingress_request_valid, (nvswitch_device *device, NVSWITCH_SET_INGRESS_REQUEST_VALID *p), _arch)  \
80     _op(NvlStatus, nvswitch_ctrl_get_ingress_response_table, (nvswitch_device *device, NVSWITCH_GET_INGRESS_RESPONSE_TABLE_PARAMS *params), _arch)  \
81     _op(NvlStatus, nvswitch_ctrl_set_ingress_response_table, (nvswitch_device *device, NVSWITCH_SET_INGRESS_RESPONSE_TABLE *p), _arch)  \
82     _op(NvlStatus, nvswitch_ctrl_set_ganged_link_table,      (nvswitch_device *device, NVSWITCH_SET_GANGED_LINK_TABLE *p), _arch)  \
83     _op(void,      nvswitch_init_npg_multicast,     (nvswitch_device *device), _arch)  \
84     _op(void,      nvswitch_init_warm_reset,        (nvswitch_device *device), _arch)  \
85     _op(NvlStatus, nvswitch_ctrl_set_remap_policy,  (nvswitch_device *device, NVSWITCH_SET_REMAP_POLICY *p), _arch)  \
86     _op(NvlStatus, nvswitch_ctrl_get_remap_policy,  (nvswitch_device *device, NVSWITCH_GET_REMAP_POLICY_PARAMS *params), _arch)  \
87     _op(NvlStatus, nvswitch_ctrl_set_remap_policy_valid, (nvswitch_device *device, NVSWITCH_SET_REMAP_POLICY_VALID *p), _arch)  \
88     _op(NvlStatus, nvswitch_ctrl_set_routing_id,    (nvswitch_device *device, NVSWITCH_SET_ROUTING_ID *p), _arch)  \
89     _op(NvlStatus, nvswitch_ctrl_get_routing_id,    (nvswitch_device *device, NVSWITCH_GET_ROUTING_ID_PARAMS *params), _arch)  \
90     _op(NvlStatus, nvswitch_ctrl_set_routing_id_valid, (nvswitch_device *device, NVSWITCH_SET_ROUTING_ID_VALID *p), _arch)  \
91     _op(NvlStatus, nvswitch_ctrl_set_routing_lan,   (nvswitch_device *device, NVSWITCH_SET_ROUTING_LAN *p), _arch)  \
92     _op(NvlStatus, nvswitch_ctrl_get_routing_lan,   (nvswitch_device *device, NVSWITCH_GET_ROUTING_LAN_PARAMS *params), _arch)  \
93     _op(NvlStatus, nvswitch_ctrl_set_routing_lan_valid, (nvswitch_device *device, NVSWITCH_SET_ROUTING_LAN_VALID *p), _arch)  \
94     _op(NvlStatus, nvswitch_ctrl_get_internal_latency, (nvswitch_device *device, NVSWITCH_GET_INTERNAL_LATENCY *p), _arch)  \
95     _op(NvlStatus, nvswitch_ctrl_set_latency_bins,  (nvswitch_device *device, NVSWITCH_SET_LATENCY_BINS *p), _arch)  \
96     _op(NvlStatus, nvswitch_ctrl_get_ingress_reqlinkid, (nvswitch_device *device, NVSWITCH_GET_INGRESS_REQLINKID_PARAMS *params), _arch)  \
97     _op(NvU32,     nvswitch_i2c_get_port_info,      (nvswitch_device *device, NvU32 port), _arch)  \
98     _op(NvlStatus, nvswitch_ctrl_register_read,     (nvswitch_device *device, NVSWITCH_REGISTER_READ *p), _arch)  \
99     _op(NvlStatus, nvswitch_ctrl_register_write,    (nvswitch_device *device, NVSWITCH_REGISTER_WRITE *p), _arch)  \
100     _op(NvlStatus, nvswitch_ctrl_i2c_indexed,       (nvswitch_device *device, NVSWITCH_CTRL_I2C_INDEXED_PARAMS *pParams), _arch)  \
101     _op(NvlStatus, nvswitch_ctrl_therm_read_temperature, (nvswitch_device *device, NVSWITCH_CTRL_GET_TEMPERATURE_PARAMS *info), _arch)  \
102     _op(NvlStatus, nvswitch_ctrl_therm_get_temperature_limit, (nvswitch_device *device, NVSWITCH_CTRL_GET_TEMPERATURE_LIMIT_PARAMS *info), _arch)  \
103     _op(NvlStatus, nvswitch_ctrl_get_throughput_counters, (nvswitch_device *device, NVSWITCH_GET_THROUGHPUT_COUNTERS_PARAMS *p), _arch)  \
104     _op(NvlStatus, nvswitch_corelib_add_link,       (nvlink_link *link), _arch)  \
105     _op(NvlStatus, nvswitch_corelib_remove_link,    (nvlink_link *link), _arch)  \
106     _op(NvlStatus, nvswitch_corelib_set_dl_link_mode, (nvlink_link *link, NvU64 mode, NvU32 flags), _arch)  \
107     _op(NvlStatus, nvswitch_corelib_get_dl_link_mode, (nvlink_link *link, NvU64 *mode), _arch)  \
108     _op(NvlStatus, nvswitch_corelib_set_tl_link_mode, (nvlink_link *link, NvU64 mode, NvU32 flags), _arch)  \
109     _op(NvlStatus, nvswitch_corelib_get_tl_link_mode, (nvlink_link *link, NvU64 *mode), _arch)  \
110     _op(NvlStatus, nvswitch_corelib_set_tx_mode,    (nvlink_link *link, NvU64 mode, NvU32 flags), _arch)  \
111     _op(NvlStatus, nvswitch_corelib_get_tx_mode,    (nvlink_link *link, NvU64 *mode, NvU32 *subMode), _arch)  \
112     _op(NvlStatus, nvswitch_corelib_set_rx_mode,    (nvlink_link *link, NvU64 mode, NvU32 flags), _arch)  \
113     _op(NvlStatus, nvswitch_corelib_get_rx_mode,    (nvlink_link *link, NvU64 *mode, NvU32 *subMode), _arch)  \
114     _op(NvlStatus, nvswitch_corelib_set_rx_detect,  (nvlink_link *link, NvU32 flags), _arch)  \
115     _op(NvlStatus, nvswitch_corelib_get_rx_detect,  (nvlink_link *link), _arch)  \
116     _op(void,      nvswitch_corelib_training_complete, (nvlink_link *link), _arch)  \
117     _op(NvU32,     nvswitch_get_device_dma_width,   (nvswitch_device *device), _arch)  \
118     _op(NvU32,     nvswitch_get_link_ip_version,    (nvswitch_device *device, NvU32 link_id), _arch)  \
119     _op(NvlStatus, nvswitch_ctrl_get_fom_values,    (nvswitch_device *device, NVSWITCH_GET_FOM_VALUES_PARAMS *p), _arch)  \
120     _op(NvlStatus, nvswitch_deassert_link_reset,    (nvswitch_device *device, nvlink_link *link), _arch)  \
121     _op(NvBool,    nvswitch_is_soe_supported,       (nvswitch_device *device), _arch)  \
122     _op(NvlStatus, nvswitch_init_soe, (nvswitch_device *device), _arch)  \
123     _op(NvBool,    nvswitch_is_inforom_supported,   (nvswitch_device *device), _arch)  \
124     _op(NvBool,    nvswitch_is_spi_supported,       (nvswitch_device *device), _arch)  \
125     _op(NvBool,    nvswitch_is_smbpbi_supported,   (nvswitch_device *device), _arch)  \
126     _op(NvlStatus, nvswitch_post_init_device_setup, (nvswitch_device *device), _arch)  \
127     _op(void,      nvswitch_post_init_blacklist_device_setup, (nvswitch_device *device), _arch)  \
128     _op(NvlStatus, nvswitch_setup_system_registers, (nvswitch_device *device), _arch)  \
129     _op(void,      nvswitch_setup_link_system_registers, (nvswitch_device *device, nvlink_link *link), _arch)  \
130     _op(void,      nvswitch_load_link_disable_settings, (nvswitch_device *device, nvlink_link *link), _arch)  \
131     _op(NvlStatus, nvswitch_read_vbios_link_entries, (nvswitch_device *device, NvU32 tblPtr,NvU32 expected_link_entriesCount,NVLINK_CONFIG_DATA_LINKENTRY *link_entries, NvU32 *identified_link_entriesCount), _arch)  \
132     _op(NvlStatus, nvswitch_vbios_read_structure, (nvswitch_device *device, void *structure, NvU32 offset, NvU32 *ppacked_size, const char *format), _arch)  \
133     _op(NvlStatus, nvswitch_get_nvlink_ecc_errors,  (nvswitch_device *device, NVSWITCH_GET_NVLINK_ECC_ERRORS_PARAMS *p), _arch)  \
134     _op(NvlStatus, nvswitch_inforom_ecc_log_error_event, (nvswitch_device *device, INFOROM_ECC_OBJECT *pEccGeneric, INFOROM_NVS_ECC_ERROR_EVENT *error_event), _arch)  \
135     _op(void,      nvswitch_oms_set_device_disable, (INFOROM_OMS_STATE *pOmsState, NvBool bForceDeviceDisable), _arch)  \
136     _op(NvBool,    nvswitch_oms_get_device_disable, (INFOROM_OMS_STATE *pOmsState), _arch)  \
137     _op(NvlStatus, nvswitch_inforom_nvl_log_error_event, (nvswitch_device *device, void *pNvlGeneric, void *error_event, NvBool *bDirty), _arch)  \
138     _op(NvlStatus, nvswitch_inforom_nvl_update_link_correctable_error_info, (nvswitch_device *device, void *pNvlGeneric, void *pData, NvU8 linkId, NvU8 nvliptInstance, NvU8 localLinkIdx, void *pErrorCounts, NvBool *bDirty), _arch)  \
139     _op(NvlStatus, nvswitch_inforom_nvl_get_max_correctable_error_rate,  (nvswitch_device *device, NVSWITCH_GET_NVLINK_MAX_CORRECTABLE_ERROR_RATES_PARAMS *p), _arch)  \
140     _op(NvlStatus, nvswitch_inforom_nvl_get_errors,  (nvswitch_device *device, NVSWITCH_GET_NVLINK_ERROR_COUNTS_PARAMS *p), _arch)  \
141     _op(NvlStatus, nvswitch_inforom_nvl_setL1Threshold, (nvswitch_device *device, void *pNvlGeneric, NvU32 word1, NvU32 word2), _arch)  \
142     _op(NvlStatus, nvswitch_inforom_nvl_getL1Threshold, (nvswitch_device *device, void *pNvlGeneric, NvU32 *word1, NvU32 *word2), _arch)  \
143     _op(NvlStatus, nvswitch_inforom_nvl_setup_nvlink_state, (nvswitch_device *device, INFOROM_NVLINK_STATE *pNvlinkState, NvU8 version), _arch)  \
144     _op(NvlStatus, nvswitch_inforom_ecc_get_errors,  (nvswitch_device *device, NVSWITCH_GET_ECC_ERROR_COUNTS_PARAMS *p), _arch)  \
145     _op(void,      nvswitch_load_uuid,              (nvswitch_device *device), _arch)  \
146     _op(void,      nvswitch_i2c_set_hw_speed_mode,  (nvswitch_device *device, NvU32 port, NvU32 speedMode), _arch)  \
147     _op(NvlStatus, nvswitch_ctrl_get_bios_info,     (nvswitch_device *device, NVSWITCH_GET_BIOS_INFO_PARAMS *p), _arch)  \
148     _op(NvlStatus, nvswitch_ctrl_get_inforom_version,  (nvswitch_device *device, NVSWITCH_GET_INFOROM_VERSION_PARAMS *p), _arch)  \
149     _op(NvlStatus, nvswitch_read_oob_blacklist_state, (nvswitch_device *device), _arch)  \
150     _op(NvlStatus, nvswitch_write_fabric_state,     (nvswitch_device *device), _arch)  \
151     _op(void,      nvswitch_initialize_oms_state,   (nvswitch_device *device, INFOROM_OMS_STATE *pOmsState), _arch)  \
152     _op(NvlStatus, nvswitch_oms_inforom_flush,      (nvswitch_device *device), _arch)  \
153     _op(void,      nvswitch_inforom_ecc_get_total_errors,   (nvswitch_device *device, INFOROM_ECC_OBJECT *pEccGeneric, NvU64 *corCount, NvU64 *uncCount), _arch)  \
154     _op(NvlStatus, nvswitch_inforom_load_obd, (nvswitch_device *device), _arch)  \
155     _op(NvlStatus, nvswitch_bbx_add_sxid, (nvswitch_device *device, NvU32 exceptionType, NvU32 data0, NvU32 data1, NvU32 data2), _arch)  \
156     _op(NvlStatus, nvswitch_bbx_unload, (nvswitch_device *device), _arch)  \
157     _op(NvlStatus, nvswitch_bbx_load, (nvswitch_device *device, NvU64 time_ns, NvU8 osType, NvU32 osVersion), _arch)  \
158     _op(NvlStatus, nvswitch_bbx_get_sxid, (nvswitch_device *device, NVSWITCH_GET_SXIDS_PARAMS * params), _arch)  \
159     _op(NvlStatus, nvswitch_smbpbi_alloc,           (nvswitch_device *device), _arch)  \
160     _op(NvlStatus, nvswitch_smbpbi_post_init_hal,   (nvswitch_device *device), _arch)  \
161     _op(void,      nvswitch_smbpbi_destroy_hal,     (nvswitch_device *device), _arch)  \
162     _op(void,      nvswitch_smbpbi_send_unload,     (nvswitch_device *device), _arch)  \
163     _op(NvlStatus, nvswitch_smbpbi_dem_load,        (nvswitch_device *device), _arch)  \
164     _op(void,      nvswitch_smbpbi_dem_flush,       (nvswitch_device *device), _arch)  \
165     _op(NvlStatus, nvswitch_smbpbi_get_dem_num_messages,    (nvswitch_device *device, NvU8 *pMsgCount), _arch)  \
166     _op(void,      nvswitch_smbpbi_log_message,     (nvswitch_device *device, NvU32 num, NvU32 msglen, NvU8 *osErrorString), _arch)  \
167     _op(NvlStatus, nvswitch_smbpbi_send_init_data,  (nvswitch_device *device), _arch)  \
168     _op(NvlStatus, nvswitch_set_minion_initialized, (nvswitch_device *device, NvU32 idx_minion, NvBool initialized), _arch)  \
169     _op(NvBool,    nvswitch_is_minion_initialized,  (nvswitch_device *device, NvU32 idx_minion), _arch)  \
170     _op(NvlStatus, nvswitch_get_link_public_id, (nvswitch_device *device, NvU32 linkId, NvU32 *publicId), _arch)  \
171     _op(NvlStatus, nvswitch_get_link_local_idx, (nvswitch_device *device, NvU32 linkId, NvU32 *localLinkIdx), _arch)  \
172     _op(NvlStatus, nvswitch_set_training_error_info, (nvswitch_device *device, NVSWITCH_SET_TRAINING_ERROR_INFO_PARAMS *pLinkTrainingErrorInfoParams), _arch)  \
173     _op(NvlStatus, nvswitch_ctrl_get_fatal_error_scope, (nvswitch_device *device, NVSWITCH_GET_FATAL_ERROR_SCOPE_PARAMS *pParams), _arch)  \
174     _op(void,      nvswitch_init_scratch,       (nvswitch_device *device), _arch)  \
175     _op(NvlStatus, nvswitch_device_discovery,   (nvswitch_device *device, NvU32 discovery_offset), _arch)  \
176     _op(void,      nvswitch_filter_discovery,   (nvswitch_device *device), _arch)  \
177     _op(NvlStatus, nvswitch_process_discovery,  (nvswitch_device *device), _arch)  \
178     _op(NvlStatus, nvswitch_init_minion,        (nvswitch_device *device), _arch)  \
179     _op(NvU32,     nvswitch_get_eng_base,   (nvswitch_device *device, NVSWITCH_ENGINE_ID eng_id, NvU32 eng_bcast, NvU32 eng_instance), _arch)  \
180     _op(NvU32,     nvswitch_get_eng_count,  (nvswitch_device *device, NVSWITCH_ENGINE_ID eng_id, NvU32 eng_bcast), _arch)  \
181     _op(NvU32,     nvswitch_eng_rd,         (nvswitch_device *device, NVSWITCH_ENGINE_ID eng_id, NvU32 eng_bcast, NvU32 eng_instance, NvU32 offset), _arch)  \
182     _op(void,      nvswitch_eng_wr,         (nvswitch_device *device, NVSWITCH_ENGINE_ID eng_id, NvU32 eng_bcast, NvU32 eng_instance, NvU32 offset, NvU32 data), _arch)  \
183     _op(NvU32,     nvswitch_get_link_eng_inst,  (nvswitch_device *device, NvU32 link_id, NVSWITCH_ENGINE_ID eng_id), _arch)  \
184     _op(void *,    nvswitch_alloc_chipdevice,   (nvswitch_device *device), _arch)  \
185     _op(NvlStatus, nvswitch_init_thermal,       (nvswitch_device *device), _arch)  \
186     _op(NvlStatus, nvswitch_init_pll_config,    (nvswitch_device *device), _arch)  \
187     _op(NvlStatus, nvswitch_init_pll,           (nvswitch_device *device), _arch)  \
188     _op(void,      nvswitch_init_clock_gating,  (nvswitch_device *device), _arch)  \
189     _op(NvU32,     nvswitch_read_physical_id,   (nvswitch_device *device), _arch)  \
190     _op(NvU32,     nvswitch_get_caps_nvlink_version,    (nvswitch_device *device), _arch)  \
191     _op(void,      nvswitch_initialize_interrupt_tree,  (nvswitch_device *device), _arch)  \
192     _op(void,      nvswitch_init_dlpl_interrupts,       (nvlink_link *link), _arch)  \
193     _op(NvlStatus, nvswitch_initialize_pmgr,    (nvswitch_device *device), _arch)  \
194     _op(NvlStatus, nvswitch_initialize_ip_wrappers,     (nvswitch_device *device), _arch)  \
195     _op(NvlStatus, nvswitch_initialize_route,   (nvswitch_device *device), _arch)  \
196     _op(void,      nvswitch_soe_unregister_events,      (nvswitch_device *device), _arch)  \
197     _op(NvlStatus, nvswitch_soe_register_event_callbacks,  (nvswitch_device *device), _arch)  \
198     _op(NVSWITCH_BIOS_NVLINK_CONFIG *, nvswitch_get_bios_nvlink_config, (nvswitch_device *device), _arch)  \
199     _op(NvlStatus, nvswitch_minion_send_command, (nvswitch_device *device, NvU32 linkNumber, NvU32 command, NvU32 scratch0), _arch)  \
200     _op(NvlStatus, nvswitch_init_nport,      (nvswitch_device *device), _arch)  \
201     _op(NvlStatus, nvswitch_init_nxbar,      (nvswitch_device *device), _arch)  \
202     _op(NvlStatus, nvswitch_clear_nport_rams,       (nvswitch_device *device), _arch)  \
203     _op(NvlStatus, nvswitch_pri_ring_init,          (nvswitch_device *device), _arch)  \
204     _op(NvlStatus, nvswitch_get_remap_table_selector,   (nvswitch_device *device, NVSWITCH_TABLE_SELECT_REMAP table_selector, NvU32 *remap_ram_sel), _arch)  \
205     _op(NvU32,     nvswitch_get_ingress_ram_size,   (nvswitch_device *device, NvU32 ingress_ram_selector), _arch)  \
206     _op(NvlStatus, nvswitch_minion_get_dl_status,   (nvswitch_device *device, NvU32 linkId, NvU32 statusIdx, NvU32 statusArgs, NvU32 *statusData), _arch)  \
207     _op(void,      nvswitch_corelib_get_uphy_load, (nvlink_link *link, NvBool *bUnlocked), _arch) \
208     _op(NvBool,    nvswitch_is_i2c_supported, (nvswitch_device *device), _arch) \
209     _op(NvlStatus, nvswitch_poll_sublink_state, (nvswitch_device *device, nvlink_link *link), _arch)\
210     _op(void,      nvswitch_setup_link_loopback_mode, (nvswitch_device *device, NvU32 linkNumber), _arch)\
211     _op(void,      nvswitch_reset_persistent_link_hw_state, (nvswitch_device *device, NvU32 linkNumber), _arch)\
212     _op(void,      nvswitch_store_topology_information, (nvswitch_device *device, nvlink_link *link), _arch) \
213     _op(void,      nvswitch_init_lpwr_regs, (nvlink_link *link), _arch) \
214     _op(NvlStatus, nvswitch_set_training_mode, (nvswitch_device *device), _arch) \
215     _op(NvU32,     nvswitch_get_sublink_width, (nvswitch_device *device, NvU32 linkNumber), _arch) \
216     _op(NvBool,    nvswitch_i2c_is_device_access_allowed, (nvswitch_device *device, NvU32 port, NvU8 addr, NvBool bIsRead), _arch) \
217     _op(NvlStatus, nvswitch_parse_bios_image, (nvswitch_device *device), _arch) \
218     _op(NvBool,    nvswitch_is_link_in_reset, (nvswitch_device *device, nvlink_link *link), _arch) \
219     _op(void,      nvswitch_init_buffer_ready, (nvswitch_device *device, nvlink_link * link, NvBool bNportBufferReady), _arch) \
220     _op(NvlStatus, nvswitch_ctrl_get_nvlink_lp_counters, (nvswitch_device *device, NVSWITCH_GET_NVLINK_LP_COUNTERS_PARAMS *p), _arch) \
221     _op(void,      nvswitch_apply_recal_settings, (nvswitch_device *device, nvlink_link *), _arch) \
222     _op(NvlStatus, nvswitch_service_nvldl_fatal_link, (nvswitch_device *device, NvU32 nvliptInstance, NvU32 link), _arch) \
223     _op(NvlStatus, nvswitch_service_minion_link, (nvswitch_device *device, NvU32 link_id), _arch) \
224     _op(NvlStatus, nvswitch_ctrl_get_sw_info,  (nvswitch_device *device, NVSWITCH_GET_SW_INFO_PARAMS *p), _arch) \
225     _op(NvlStatus, nvswitch_ctrl_get_err_info, (nvswitch_device *device, NVSWITCH_NVLINK_GET_ERR_INFO_PARAMS *ret), _arch) \
226     _op(NvlStatus, nvswitch_ctrl_clear_counters, (nvswitch_device *device, NVSWITCH_NVLINK_CLEAR_COUNTERS_PARAMS *ret), _arch) \
227     _op(NvlStatus, nvswitch_ctrl_set_nvlink_error_threshold, (nvswitch_device *device, NVSWITCH_SET_NVLINK_ERROR_THRESHOLD_PARAMS *pParams), _arch) \
228     _op(NvlStatus, nvswitch_ctrl_get_nvlink_error_threshold, (nvswitch_device *device, NVSWITCH_GET_NVLINK_ERROR_THRESHOLD_PARAMS *pParams), _arch) \
229     _op(NvlStatus, nvswitch_ctrl_get_board_part_number, (nvswitch_device *device, NVSWITCH_GET_BOARD_PART_NUMBER_VECTOR *p), _arch) \
230     _op(NvlStatus, nvswitch_ctrl_therm_read_voltage, (nvswitch_device *device, NVSWITCH_CTRL_GET_VOLTAGE_PARAMS *info), _arch) \
231     _op(void,      nvswitch_soe_init_l2_state,       (nvswitch_device *device), _arch) \
232 
233 #define NVSWITCH_HAL_FUNCTION_LIST_LS10(_op, _arch) \
234     _op(NvlStatus, nvswitch_launch_ALI, (nvswitch_device *device), _arch) \
235     _op(NvlStatus, nvswitch_launch_ALI_link_training, (nvswitch_device *device, nvlink_link *link, NvBool bSync), _arch) \
236     _op(NvlStatus, nvswitch_ctrl_inband_send_data, (nvswitch_device *device, NVSWITCH_INBAND_SEND_DATA_PARAMS *p), _arch) \
237     _op(NvlStatus, nvswitch_ctrl_inband_read_data, (nvswitch_device *device, NVSWITCH_INBAND_READ_DATA_PARAMS *p), _arch) \
238     _op(void,      nvswitch_send_inband_nack, (nvswitch_device *device, NvU32 *msghdr, NvU32  linkId), _arch) \
239     _op(NvU32,     nvswitch_get_max_persistent_message_count, (nvswitch_device *device), _arch) \
240     _op(NvlStatus, nvswitch_ctrl_set_mc_rid_table,  (nvswitch_device *device, NVSWITCH_SET_MC_RID_TABLE_PARAMS *p), _arch)  \
241     _op(NvlStatus, nvswitch_ctrl_get_mc_rid_table,  (nvswitch_device *device, NVSWITCH_GET_MC_RID_TABLE_PARAMS *p), _arch)  \
242     _op(NvlStatus, nvswitch_ctrl_set_residency_bins, (nvswitch_device *device, NVSWITCH_SET_RESIDENCY_BINS *p), _arch) \
243     _op(NvlStatus, nvswitch_ctrl_get_residency_bins, (nvswitch_device *device, NVSWITCH_GET_RESIDENCY_BINS *p), _arch) \
244     _op(NvlStatus, nvswitch_ctrl_get_rb_stall_busy, (nvswitch_device *device, NVSWITCH_GET_RB_STALL_BUSY *p), _arch) \
245     _op(NvlStatus, nvswitch_ctrl_get_multicast_id_error_vector, (nvswitch_device *device, NVSWITCH_GET_MULTICAST_ID_ERROR_VECTOR *p), _arch) \
246     _op(NvlStatus, nvswitch_ctrl_clear_multicast_id_error_vector, (nvswitch_device *device, NVSWITCH_CLEAR_MULTICAST_ID_ERROR_VECTOR *p), _arch) \
247     _op(NvlStatus, nvswitch_reset_and_train_link, (nvswitch_device *device, nvlink_link *link), _arch) \
248 
249 //
250 // Declare HAL function pointer table
251 //
252 // This macro takes the xmacro _FUNCTION_LIST and uses some components in it to
253 // automatically generate the HAL structure declaration in a form:
254 //     NvU32    (*function_foo1)(nvswitch_device device);
255 //     void     (*function_foo2)(nvswitch_device device, NvU32 parameter1);
256 //     NvlStatus (*function_foo3)(nvswitch_device device, NvU32 parameter1, void *parameter2);
257 //
258 
259 #define DECLARE_HAL_FUNCTIONS(_return, _function, _params, _arch)   \
260     _return (*_function)_params;
261 
262 typedef struct nvswitch_hal_functions
263 {
264     NVSWITCH_HAL_FUNCTION_LIST(DECLARE_HAL_FUNCTIONS, HAL)
265     NVSWITCH_HAL_FUNCTION_LIST_LS10(DECLARE_HAL_FUNCTIONS, HAL)
266 
267 } nvswitch_hal;
268 
269 //
270 // Fill in HAL function pointer table
271 //
272 // This macro takes the xmacro _FUNCTION_LIST and uses some components in it to
273 // automatically generate all the HAL function fill-in assignments for a given
274 // architecture.
275 //
276 
277 #define CREATE_HAL_FUNCTIONS(_return, _function, _params, _arch)    \
278     device->hal._function = _function##_##_arch;                    \
279 
280 #define NVSWITCH_INIT_HAL(device, arch)                             \
281     NVSWITCH_HAL_FUNCTION_LIST(CREATE_HAL_FUNCTIONS, arch)          \
282 
283 #define NVSWITCH_INIT_HAL_LS10(device, arch)                         \
284     NVSWITCH_HAL_FUNCTION_LIST_LS10(CREATE_HAL_FUNCTIONS, arch)      \
285 
286 //
287 // Declare HAL function dispatch functions
288 //
289 // This macro takes the xmacro _FUNCTION_LIST and uses some components in it to
290 // automatically generate the function prototypes for the dispatcher functions
291 // that dereference the correct arch HAL function.
292 //
293 
294 #define DECLARE_HAL_DISPATCHERS(_return, _function, _params, _arch) \
295     _return _function _params;
296 
297 NVSWITCH_HAL_FUNCTION_LIST(DECLARE_HAL_DISPATCHERS, unused_argument)
298 NVSWITCH_HAL_FUNCTION_LIST_LS10(DECLARE_HAL_DISPATCHERS, unused_argument)
299 
300 // HAL functions
301 void nvswitch_setup_hal_lr10(nvswitch_device *device);
302 void nvswitch_setup_hal_ls10(nvswitch_device *device);
303 
304 #endif //_HALDEF_NVSWITCH_H_
305