ef10_mcdi.c (293817) | ef10_mcdi.c (293888) |
---|---|
1/*- 2 * Copyright (c) 2012-2015 Solarflare Communications Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, --- 15 unchanged lines hidden (view full) --- 24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * The views and conclusions contained in the software and documentation are 27 * those of the authors and should not be interpreted as representing official 28 * policies, either expressed or implied, of the FreeBSD Project. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2012-2015 Solarflare Communications Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, --- 15 unchanged lines hidden (view full) --- 24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * The views and conclusions contained in the software and documentation are 27 * those of the authors and should not be interpreted as representing official 28 * policies, either expressed or implied, of the FreeBSD Project. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/hunt_mcdi.c 293817 2016-01-13 07:46:21Z arybchik $"); | 32__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/hunt_mcdi.c 293888 2016-01-14 09:00:35Z arybchik $"); |
33 34#include "efx.h" 35#include "efx_impl.h" 36 37 38#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD 39 40#if EFSYS_OPT_MCDI 41 42#ifndef WITH_MCDI_V2 43#error "WITH_MCDI_V2 required for EF10 MCDIv2 commands." 44#endif 45 | 33 34#include "efx.h" 35#include "efx_impl.h" 36 37 38#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD 39 40#if EFSYS_OPT_MCDI 41 42#ifndef WITH_MCDI_V2 43#error "WITH_MCDI_V2 required for EF10 MCDIv2 commands." 44#endif 45 |
46typedef enum efx_mcdi_header_type_e { 47 EFX_MCDI_HEADER_TYPE_V1, /* MCDIv0 (BootROM), MCDIv1 commands */ 48 EFX_MCDI_HEADER_TYPE_V2, /* MCDIv2 commands */ 49} efx_mcdi_header_type_t; | |
50 | 46 |
51/* 52 * Return the header format to use for sending an MCDI request. 53 * 54 * An MCDIv1 (Siena compatible) command should use MCDIv2 encapsulation if the 55 * request input buffer or response output buffer are too large for the MCDIv1 56 * format. An MCDIv2 command must always be sent using MCDIv2 encapsulation. 57 */ 58#define EFX_MCDI_HEADER_TYPE(_cmd, _length) \ 59 ((((_cmd) & ~EFX_MASK32(MCDI_HEADER_CODE)) || \ 60 ((_length) & ~EFX_MASK32(MCDI_HEADER_DATALEN))) ? \ 61 EFX_MCDI_HEADER_TYPE_V2 : EFX_MCDI_HEADER_TYPE_V1) 62 63 64/* 65 * MCDI Header NOT_EPOCH flag 66 * ========================== 67 * A new epoch begins at initial startup or after an MC reboot, and defines when 68 * the MC should reject stale MCDI requests. 69 * 70 * The first MCDI request sent by the host should contain NOT_EPOCH=0, and all 71 * subsequent requests (until the next MC reboot) should contain NOT_EPOCH=1. 72 * 73 * After rebooting the MC will fail all requests with NOT_EPOCH=1 by writing a 74 * response with ERROR=1 and DATALEN=0 until a request is seen with NOT_EPOCH=0. 75 */ 76 77 | |
78 __checkReturn efx_rc_t 79ef10_mcdi_init( 80 __in efx_nic_t *enp, 81 __in const efx_mcdi_transport_t *emtp) 82{ 83 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); 84 efsys_mem_t *esmp = emtp->emt_dma_mem; 85 efx_dword_t dword; --- 48 unchanged lines hidden (view full) --- 134ef10_mcdi_fini( 135 __in efx_nic_t *enp) 136{ 137 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); 138 139 emip->emi_new_epoch = B_FALSE; 140} 141 | 47 __checkReturn efx_rc_t 48ef10_mcdi_init( 49 __in efx_nic_t *enp, 50 __in const efx_mcdi_transport_t *emtp) 51{ 52 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); 53 efsys_mem_t *esmp = emtp->emt_dma_mem; 54 efx_dword_t dword; --- 48 unchanged lines hidden (view full) --- 103ef10_mcdi_fini( 104 __in efx_nic_t *enp) 105{ 106 efx_mcdi_iface_t *emip = &(enp->en_mcdi.em_emip); 107 108 emip->emi_new_epoch = B_FALSE; 109} 110 |
142static void | 111 void |
143ef10_mcdi_send_request( 144 __in efx_nic_t *enp, 145 __in void *hdrp, 146 __in size_t hdr_len, 147 __in void *sdup, 148 __in size_t sdu_len) 149{ 150 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; --- 26 unchanged lines hidden (view full) --- 177 EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE); 178 179 EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 180 EFSYS_MEM_ADDR(esmp) & 0xffffffff); 181 EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE); 182} 183 184 void | 112ef10_mcdi_send_request( 113 __in efx_nic_t *enp, 114 __in void *hdrp, 115 __in size_t hdr_len, 116 __in void *sdup, 117 __in size_t sdu_len) 118{ 119 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; --- 26 unchanged lines hidden (view full) --- 146 EFX_BAR_WRITED(enp, ER_DZ_MC_DB_LWRD_REG, &dword, B_FALSE); 147 148 EFX_POPULATE_DWORD_1(dword, EFX_DWORD_0, 149 EFSYS_MEM_ADDR(esmp) & 0xffffffff); 150 EFX_BAR_WRITED(enp, ER_DZ_MC_DB_HWRD_REG, &dword, B_FALSE); 151} 152 153 void |
185ef10_mcdi_request_copyin( 186 __in efx_nic_t *enp, 187 __in efx_mcdi_req_t *emrp, 188 __in unsigned int seq, 189 __in boolean_t ev_cpl, 190 __in boolean_t new_epoch) 191{ 192#if EFSYS_OPT_MCDI_LOGGING 193 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; 194#endif /* EFSYS_OPT_MCDI_LOGGING */ 195 efx_mcdi_header_type_t hdr_type; 196 efx_dword_t hdr[2]; 197 size_t hdr_len; 198 unsigned int xflags; 199 200 EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON || 201 enp->en_family == EFX_FAMILY_MEDFORD); 202 203 xflags = 0; 204 if (ev_cpl) 205 xflags |= MCDI_HEADER_XFLAGS_EVREQ; 206 207 hdr_type = EFX_MCDI_HEADER_TYPE(emrp->emr_cmd, 208 MAX(emrp->emr_in_length, emrp->emr_out_length)); 209 210 if (hdr_type == EFX_MCDI_HEADER_TYPE_V2) { 211 /* Construct MCDI v2 header */ 212 hdr_len = sizeof (hdr); 213 EFX_POPULATE_DWORD_8(hdr[0], 214 MCDI_HEADER_CODE, MC_CMD_V2_EXTN, 215 MCDI_HEADER_RESYNC, 1, 216 MCDI_HEADER_DATALEN, 0, 217 MCDI_HEADER_SEQ, seq, 218 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1, 219 MCDI_HEADER_ERROR, 0, 220 MCDI_HEADER_RESPONSE, 0, 221 MCDI_HEADER_XFLAGS, xflags); 222 223 EFX_POPULATE_DWORD_2(hdr[1], 224 MC_CMD_V2_EXTN_IN_EXTENDED_CMD, emrp->emr_cmd, 225 MC_CMD_V2_EXTN_IN_ACTUAL_LEN, emrp->emr_in_length); 226 } else { 227 /* Construct MCDI v1 header */ 228 hdr_len = sizeof (hdr[0]); 229 EFX_POPULATE_DWORD_8(hdr[0], 230 MCDI_HEADER_CODE, emrp->emr_cmd, 231 MCDI_HEADER_RESYNC, 1, 232 MCDI_HEADER_DATALEN, emrp->emr_in_length, 233 MCDI_HEADER_SEQ, seq, 234 MCDI_HEADER_NOT_EPOCH, new_epoch ? 0 : 1, 235 MCDI_HEADER_ERROR, 0, 236 MCDI_HEADER_RESPONSE, 0, 237 MCDI_HEADER_XFLAGS, xflags); 238 } 239 240#if EFSYS_OPT_MCDI_LOGGING 241 if (emtp->emt_logger != NULL) { 242 emtp->emt_logger(emtp->emt_context, EFX_LOG_MCDI_REQUEST, 243 &hdr, hdr_len, 244 emrp->emr_in_buf, emrp->emr_in_length); 245 } 246#endif /* EFSYS_OPT_MCDI_LOGGING */ 247 248 ef10_mcdi_send_request(enp, &hdr[0], hdr_len, 249 emrp->emr_in_buf, emrp->emr_in_length); 250} 251 252 void | |
253ef10_mcdi_request_copyout( 254 __in efx_nic_t *enp, 255 __in efx_mcdi_req_t *emrp) 256{ 257#if EFSYS_OPT_MCDI_LOGGING 258 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; 259#endif /* EFSYS_OPT_MCDI_LOGGING */ 260 efx_dword_t hdr[2]; --- 186 unchanged lines hidden --- | 154ef10_mcdi_request_copyout( 155 __in efx_nic_t *enp, 156 __in efx_mcdi_req_t *emrp) 157{ 158#if EFSYS_OPT_MCDI_LOGGING 159 const efx_mcdi_transport_t *emtp = enp->en_mcdi.em_emtp; 160#endif /* EFSYS_OPT_MCDI_LOGGING */ 161 efx_dword_t hdr[2]; --- 186 unchanged lines hidden --- |