efx_mcdi.h (b138e49c) | efx_mcdi.h (e948693e) |
---|---|
1/*- | 1/*- |
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD | 2 * Copyright 2009 Solarflare Communications Inc. All rights reserved. |
3 * | 3 * |
4 * Copyright (c) 2009-2016 Solarflare Communications Inc. 5 * All rights reserved. 6 * | |
7 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions are met: | 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. |
9 * | 12 * |
10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * The views and conclusions contained in the software and documentation are 29 * those of the authors and should not be interpreted as representing official 30 * policies, either expressed or implied, of the FreeBSD Project. 31 * 32 * $FreeBSD$ | 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. |
33 */ 34 35#ifndef _SYS_EFX_MCDI_H 36#define _SYS_EFX_MCDI_H 37 38#include "efx.h" | 24 */ 25 26#ifndef _SYS_EFX_MCDI_H 27#define _SYS_EFX_MCDI_H 28 29#include "efx.h" |
30#include "efx_regs.h" |
|
39#include "efx_regs_mcdi.h" 40 | 31#include "efx_regs_mcdi.h" 32 |
41#if EFSYS_OPT_NAMES 42#include "efx_regs_mcdi_strs.h" 43#endif /* EFSYS_OPT_NAMES */ 44 | |
45#ifdef __cplusplus 46extern "C" { 47#endif 48 | 33#ifdef __cplusplus 34extern "C" { 35#endif 36 |
49/* 50 * A reboot/assertion causes the MCDI status word to be set after the 51 * command word is set or a REBOOT event is sent. If we notice a reboot 52 * via these mechanisms then wait 10ms for the status word to be set. 53 */ 54#define EFX_MCDI_STATUS_SLEEP_US 10000 | 37/* Number of retries attempted for init code */ 38#define EFX_MCDI_REQ_RETRY_INIT 2 |
55 56struct efx_mcdi_req_s { | 39 40struct efx_mcdi_req_s { |
57 boolean_t emr_quiet; | |
58 /* Inputs: Command #, input buffer and length */ 59 unsigned int emr_cmd; 60 uint8_t *emr_in_buf; 61 size_t emr_in_length; | 41 /* Inputs: Command #, input buffer and length */ 42 unsigned int emr_cmd; 43 uint8_t *emr_in_buf; 44 size_t emr_in_length; |
62 /* Outputs: retcode, buffer, length, and length used */ 63 efx_rc_t emr_rc; | 45 /* Outputs: retcode, buffer, length, and length used*/ 46 int emr_rc; |
64 uint8_t *emr_out_buf; 65 size_t emr_out_length; 66 size_t emr_out_length_used; | 47 uint8_t *emr_out_buf; 48 size_t emr_out_length; 49 size_t emr_out_length_used; |
67 /* Internals: low level transport details */ 68 unsigned int emr_err_code; 69 unsigned int emr_err_arg; 70#if EFSYS_OPT_MCDI_PROXY_AUTH 71 uint32_t emr_proxy_handle; 72#endif | |
73}; 74 75typedef struct efx_mcdi_iface_s { | 50}; 51 52typedef struct efx_mcdi_iface_s { |
53 const efx_mcdi_transport_t *emi_mtp; |
|
76 unsigned int emi_port; | 54 unsigned int emi_port; |
77 unsigned int emi_max_version; | |
78 unsigned int emi_seq; 79 efx_mcdi_req_t *emi_pending_req; 80 boolean_t emi_ev_cpl; | 55 unsigned int emi_seq; 56 efx_mcdi_req_t *emi_pending_req; 57 boolean_t emi_ev_cpl; |
81 boolean_t emi_new_epoch; | |
82 int emi_aborted; 83 uint32_t emi_poll_cnt; | 58 int emi_aborted; 59 uint32_t emi_poll_cnt; |
84 uint32_t emi_mc_reboot_status; | |
85} efx_mcdi_iface_t; 86 87extern void 88efx_mcdi_execute( 89 __in efx_nic_t *enp, | 60} efx_mcdi_iface_t; 61 62extern void 63efx_mcdi_execute( 64 __in efx_nic_t *enp, |
90 __inout efx_mcdi_req_t *emrp); | 65 __in efx_mcdi_req_t *emrp); |
91 92extern void | 66 67extern void |
93efx_mcdi_execute_quiet( 94 __in efx_nic_t *enp, 95 __inout efx_mcdi_req_t *emrp); 96 97extern void | |
98efx_mcdi_ev_cpl( 99 __in efx_nic_t *enp, 100 __in unsigned int seq, 101 __in unsigned int outlen, 102 __in int errcode); 103 | 68efx_mcdi_ev_cpl( 69 __in efx_nic_t *enp, 70 __in unsigned int seq, 71 __in unsigned int outlen, 72 __in int errcode); 73 |
104#if EFSYS_OPT_MCDI_PROXY_AUTH 105extern __checkReturn efx_rc_t 106efx_mcdi_get_proxy_handle( 107 __in efx_nic_t *enp, 108 __in efx_mcdi_req_t *emrp, 109 __out uint32_t *handlep); 110 | |
111extern void | 74extern void |
112efx_mcdi_ev_proxy_response( 113 __in efx_nic_t *enp, 114 __in unsigned int handle, 115 __in unsigned int status); 116#endif 117 118extern void | |
119efx_mcdi_ev_death( 120 __in efx_nic_t *enp, 121 __in int rc); 122 | 75efx_mcdi_ev_death( 76 __in efx_nic_t *enp, 77 __in int rc); 78 |
123extern __checkReturn efx_rc_t 124efx_mcdi_request_errcode( 125 __in unsigned int err); 126 127extern void 128efx_mcdi_raise_exception( 129 __in efx_nic_t *enp, 130 __in_opt efx_mcdi_req_t *emrp, 131 __in int rc); 132 | |
133typedef enum efx_mcdi_boot_e { 134 EFX_MCDI_BOOT_PRIMARY, 135 EFX_MCDI_BOOT_SECONDARY, 136 EFX_MCDI_BOOT_ROM, 137} efx_mcdi_boot_t; 138 | 79typedef enum efx_mcdi_boot_e { 80 EFX_MCDI_BOOT_PRIMARY, 81 EFX_MCDI_BOOT_SECONDARY, 82 EFX_MCDI_BOOT_ROM, 83} efx_mcdi_boot_t; 84 |
139extern __checkReturn efx_rc_t | 85extern __checkReturn int |
140efx_mcdi_version( 141 __in efx_nic_t *enp, 142 __out_ecount_opt(4) uint16_t versionp[4], 143 __out_opt uint32_t *buildp, 144 __out_opt efx_mcdi_boot_t *statusp); 145 | 86efx_mcdi_version( 87 __in efx_nic_t *enp, 88 __out_ecount_opt(4) uint16_t versionp[4], 89 __out_opt uint32_t *buildp, 90 __out_opt efx_mcdi_boot_t *statusp); 91 |
146extern __checkReturn efx_rc_t 147efx_mcdi_get_capabilities( 148 __in efx_nic_t *enp, 149 __out_opt uint32_t *flagsp, 150 __out_opt uint16_t *rx_dpcpu_fw_idp, 151 __out_opt uint16_t *tx_dpcpu_fw_idp, 152 __out_opt uint32_t *flags2p, 153 __out_opt uint32_t *tso2ncp); 154 155extern __checkReturn efx_rc_t 156efx_mcdi_read_assertion( 157 __in efx_nic_t *enp); 158 159extern __checkReturn efx_rc_t 160efx_mcdi_exit_assertion_handler( 161 __in efx_nic_t *enp); 162 163extern __checkReturn efx_rc_t 164efx_mcdi_drv_attach( 165 __in efx_nic_t *enp, 166 __in boolean_t attach); 167 168extern __checkReturn efx_rc_t 169efx_mcdi_get_board_cfg( 170 __in efx_nic_t *enp, 171 __out_opt uint32_t *board_typep, 172 __out_opt efx_dword_t *capabilitiesp, 173 __out_ecount_opt(6) uint8_t mac_addrp[6]); 174 175extern __checkReturn efx_rc_t 176efx_mcdi_get_phy_cfg( 177 __in efx_nic_t *enp); 178 179extern __checkReturn efx_rc_t 180efx_mcdi_firmware_update_supported( 181 __in efx_nic_t *enp, 182 __out boolean_t *supportedp); 183 184extern __checkReturn efx_rc_t 185efx_mcdi_macaddr_change_supported( 186 __in efx_nic_t *enp, 187 __out boolean_t *supportedp); 188 189extern __checkReturn efx_rc_t 190efx_mcdi_link_control_supported( 191 __in efx_nic_t *enp, 192 __out boolean_t *supportedp); 193 194extern __checkReturn efx_rc_t 195efx_mcdi_mac_spoofing_supported( 196 __in efx_nic_t *enp, 197 __out boolean_t *supportedp); 198 199#if EFSYS_OPT_BIST 200#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 201extern __checkReturn efx_rc_t 202efx_mcdi_bist_enable_offline( 203 __in efx_nic_t *enp); 204#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */ 205extern __checkReturn efx_rc_t 206efx_mcdi_bist_start( 207 __in efx_nic_t *enp, 208 __in efx_bist_type_t type); 209#endif /* EFSYS_OPT_BIST */ 210 211extern __checkReturn efx_rc_t 212efx_mcdi_get_resource_limits( 213 __in efx_nic_t *enp, 214 __out_opt uint32_t *nevqp, 215 __out_opt uint32_t *nrxqp, 216 __out_opt uint32_t *ntxqp); 217 218extern __checkReturn efx_rc_t 219efx_mcdi_log_ctrl( 220 __in efx_nic_t *enp); 221 222extern __checkReturn efx_rc_t 223efx_mcdi_mac_stats_clear( 224 __in efx_nic_t *enp); 225 226extern __checkReturn efx_rc_t 227efx_mcdi_mac_stats_upload( 228 __in efx_nic_t *enp, 229 __in efsys_mem_t *esmp); 230 231extern __checkReturn efx_rc_t 232efx_mcdi_mac_stats_periodic( 233 __in efx_nic_t *enp, 234 __in efsys_mem_t *esmp, 235 __in uint16_t period_ms, 236 __in boolean_t events); 237 238#if EFSYS_OPT_LOOPBACK 239extern __checkReturn efx_rc_t 240efx_mcdi_get_loopback_modes( 241 __in efx_nic_t *enp); 242#endif /* EFSYS_OPT_LOOPBACK */ 243 244extern __checkReturn efx_rc_t 245efx_mcdi_phy_module_get_info( 246 __in efx_nic_t *enp, 247 __in uint8_t dev_addr, 248 __in size_t offset, 249 __in size_t len, 250 __out_bcount(len) uint8_t *data); 251 | |
252#define MCDI_IN(_emr, _type, _ofst) \ 253 ((_type *)((_emr).emr_in_buf + (_ofst))) 254 255#define MCDI_IN2(_emr, _type, _ofst) \ 256 MCDI_IN(_emr, _type, MC_CMD_ ## _ofst ## _OFST) 257 258#define MCDI_IN_SET_BYTE(_emr, _ofst, _value) \ 259 EFX_POPULATE_BYTE_1(*MCDI_IN2(_emr, efx_byte_t, _ofst), \ 260 EFX_BYTE_0, _value) 261 | 92#define MCDI_IN(_emr, _type, _ofst) \ 93 ((_type *)((_emr).emr_in_buf + (_ofst))) 94 95#define MCDI_IN2(_emr, _type, _ofst) \ 96 MCDI_IN(_emr, _type, MC_CMD_ ## _ofst ## _OFST) 97 98#define MCDI_IN_SET_BYTE(_emr, _ofst, _value) \ 99 EFX_POPULATE_BYTE_1(*MCDI_IN2(_emr, efx_byte_t, _ofst), \ 100 EFX_BYTE_0, _value) 101 |
262#define MCDI_IN_SET_WORD(_emr, _ofst, _value) \ 263 EFX_POPULATE_WORD_1(*MCDI_IN2(_emr, efx_word_t, _ofst), \ 264 EFX_WORD_0, _value) 265 | |
266#define MCDI_IN_SET_DWORD(_emr, _ofst, _value) \ 267 EFX_POPULATE_DWORD_1(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 268 EFX_DWORD_0, _value) 269 | 102#define MCDI_IN_SET_DWORD(_emr, _ofst, _value) \ 103 EFX_POPULATE_DWORD_1(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 104 EFX_DWORD_0, _value) 105 |
270#define MCDI_IN_SET_DWORD_FIELD(_emr, _ofst, _field, _value) \ 271 EFX_SET_DWORD_FIELD(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 272 MC_CMD_ ## _field, _value) 273 | |
274#define MCDI_IN_POPULATE_DWORD_1(_emr, _ofst, _field1, _value1) \ 275 EFX_POPULATE_DWORD_1(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 276 MC_CMD_ ## _field1, _value1) 277 278#define MCDI_IN_POPULATE_DWORD_2(_emr, _ofst, _field1, _value1, \ 279 _field2, _value2) \ 280 EFX_POPULATE_DWORD_2(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 281 MC_CMD_ ## _field1, _value1, \ --- 33 unchanged lines hidden (view full) --- 315 MC_CMD_ ## _field3, _value3, \ 316 MC_CMD_ ## _field4, _value4, \ 317 MC_CMD_ ## _field5, _value5, \ 318 MC_CMD_ ## _field6, _value6) 319 320#define MCDI_IN_POPULATE_DWORD_7(_emr, _ofst, _field1, _value1, \ 321 _field2, _value2, _field3, _value3, _field4, _value4, \ 322 _field5, _value5, _field6, _value6, _field7, _value7) \ | 106#define MCDI_IN_POPULATE_DWORD_1(_emr, _ofst, _field1, _value1) \ 107 EFX_POPULATE_DWORD_1(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 108 MC_CMD_ ## _field1, _value1) 109 110#define MCDI_IN_POPULATE_DWORD_2(_emr, _ofst, _field1, _value1, \ 111 _field2, _value2) \ 112 EFX_POPULATE_DWORD_2(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ 113 MC_CMD_ ## _field1, _value1, \ --- 33 unchanged lines hidden (view full) --- 147 MC_CMD_ ## _field3, _value3, \ 148 MC_CMD_ ## _field4, _value4, \ 149 MC_CMD_ ## _field5, _value5, \ 150 MC_CMD_ ## _field6, _value6) 151 152#define MCDI_IN_POPULATE_DWORD_7(_emr, _ofst, _field1, _value1, \ 153 _field2, _value2, _field3, _value3, _field4, _value4, \ 154 _field5, _value5, _field6, _value6, _field7, _value7) \ |
323 EFX_POPULATE_DWORD_7(*MCDI_IN2(_emr, efx_dword_t, _ofst), \ | 155 EFX_POPULATE_DWORD_7(MCDI_IN2(_emr, efx_dword_t, _ofst), \ |
324 MC_CMD_ ## _field1, _value1, \ 325 MC_CMD_ ## _field2, _value2, \ 326 MC_CMD_ ## _field3, _value3, \ 327 MC_CMD_ ## _field4, _value4, \ 328 MC_CMD_ ## _field5, _value5, \ 329 MC_CMD_ ## _field6, _value6, \ 330 MC_CMD_ ## _field7, _value7) 331 --- 51 unchanged lines hidden (view full) --- 383#define MCDI_OUT_BYTE(_emr, _ofst) \ 384 EFX_BYTE_FIELD(*MCDI_OUT2(_emr, efx_byte_t, _ofst), \ 385 EFX_BYTE_0) 386 387#define MCDI_OUT_WORD(_emr, _ofst) \ 388 EFX_WORD_FIELD(*MCDI_OUT2(_emr, efx_word_t, _ofst), \ 389 EFX_WORD_0) 390 | 156 MC_CMD_ ## _field1, _value1, \ 157 MC_CMD_ ## _field2, _value2, \ 158 MC_CMD_ ## _field3, _value3, \ 159 MC_CMD_ ## _field4, _value4, \ 160 MC_CMD_ ## _field5, _value5, \ 161 MC_CMD_ ## _field6, _value6, \ 162 MC_CMD_ ## _field7, _value7) 163 --- 51 unchanged lines hidden (view full) --- 215#define MCDI_OUT_BYTE(_emr, _ofst) \ 216 EFX_BYTE_FIELD(*MCDI_OUT2(_emr, efx_byte_t, _ofst), \ 217 EFX_BYTE_0) 218 219#define MCDI_OUT_WORD(_emr, _ofst) \ 220 EFX_WORD_FIELD(*MCDI_OUT2(_emr, efx_word_t, _ofst), \ 221 EFX_WORD_0) 222 |
391#define MCDI_OUT_WORD_FIELD(_emr, _ofst, _field) \ 392 EFX_WORD_FIELD(*MCDI_OUT2(_emr, efx_word_t, _ofst), \ 393 MC_CMD_ ## _field) 394 | |
395#define MCDI_OUT_DWORD(_emr, _ofst) \ 396 EFX_DWORD_FIELD(*MCDI_OUT2(_emr, efx_dword_t, _ofst), \ 397 EFX_DWORD_0) 398 399#define MCDI_OUT_DWORD_FIELD(_emr, _ofst, _field) \ 400 EFX_DWORD_FIELD(*MCDI_OUT2(_emr, efx_dword_t, _ofst), \ 401 MC_CMD_ ## _field) 402 403#define MCDI_EV_FIELD(_eqp, _field) \ | 223#define MCDI_OUT_DWORD(_emr, _ofst) \ 224 EFX_DWORD_FIELD(*MCDI_OUT2(_emr, efx_dword_t, _ofst), \ 225 EFX_DWORD_0) 226 227#define MCDI_OUT_DWORD_FIELD(_emr, _ofst, _field) \ 228 EFX_DWORD_FIELD(*MCDI_OUT2(_emr, efx_dword_t, _ofst), \ 229 MC_CMD_ ## _field) 230 231#define MCDI_EV_FIELD(_eqp, _field) \ |
404 EFX_QWORD_FIELD(*_eqp, MCDI_EVENT_ ## _field) | 232 EFX_QWORD_FIELD(*eqp, MCDI_EVENT_ ## _field) |
405 | 233 |
406#define MCDI_CMD_DWORD_FIELD(_edp, _field) \ 407 EFX_DWORD_FIELD(*_edp, MC_CMD_ ## _field) 408 409#define EFX_MCDI_HAVE_PRIVILEGE(mask, priv) \ 410 (((mask) & (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) == \ 411 (MC_CMD_PRIVILEGE_MASK_IN_GRP_ ## priv)) 412 413#define EFX_MCDI_BUF_SIZE(_in_len, _out_len) \ 414 EFX_P2ROUNDUP(size_t, \ 415 MAX(MAX(_in_len, _out_len), (2 * sizeof (efx_dword_t))),\ 416 sizeof (efx_dword_t)) 417 418/* 419 * The buffer size must be a multiple of dword to ensure that MCDI works 420 * properly with Siena based boards (which use on-chip buffer). Also, it 421 * should be at minimum the size of two dwords to allow space for extended 422 * error responses if the request/response buffer sizes are smaller. 423 */ 424#define EFX_MCDI_DECLARE_BUF(_name, _in_len, _out_len) \ 425 uint8_t _name[EFX_MCDI_BUF_SIZE(_in_len, _out_len)] = {0} 426 427typedef enum efx_mcdi_feature_id_e { 428 EFX_MCDI_FEATURE_FW_UPDATE = 0, 429 EFX_MCDI_FEATURE_LINK_CONTROL, 430 EFX_MCDI_FEATURE_MACADDR_CHANGE, 431 EFX_MCDI_FEATURE_MAC_SPOOFING, 432 EFX_MCDI_FEATURE_NIDS 433} efx_mcdi_feature_id_t; 434 | |
435#ifdef __cplusplus 436} 437#endif 438 439#endif /* _SYS_EFX_MCDI_H */ | 234#ifdef __cplusplus 235} 236#endif 237 238#endif /* _SYS_EFX_MCDI_H */ |