| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/**************************************************************************** |
| 3 |
* Driver for Solarflare network controllers and boards |
| 4 |
* Copyright 2008-2013 Solarflare Communications Inc. |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef EFX_MCDI_H |
| 8 |
#define EFX_MCDI_H |
| 9 |
|
| 10 |
/** |
| 11 |
* enum efx_mcdi_state - MCDI request handling state |
| 12 |
* @MCDI_STATE_QUIESCENT: No pending MCDI requests. If the caller holds the |
| 13 |
* mcdi @iface_lock then they are able to move to %MCDI_STATE_RUNNING |
| 14 |
* @MCDI_STATE_RUNNING_SYNC: There is a synchronous MCDI request pending. |
| 15 |
* Only the thread that moved into this state is allowed to move out of it. |
| 16 |
* @MCDI_STATE_RUNNING_ASYNC: There is an asynchronous MCDI request pending. |
| 17 |
* @MCDI_STATE_PROXY_WAIT: An MCDI request has completed with a response that |
| 18 |
* indicates we must wait for a proxy try again message. |
| 19 |
* @MCDI_STATE_COMPLETED: An MCDI request has completed, but the owning thread |
| 20 |
* has not yet consumed the result. For all other threads, equivalent to |
| 21 |
* %MCDI_STATE_RUNNING. |
| 22 |
*/ |
| 23 |
enum efx_mcdi_state { |
| 24 |
MCDI_STATE_QUIESCENT, |
| 25 |
MCDI_STATE_RUNNING_SYNC, |
| 26 |
MCDI_STATE_RUNNING_ASYNC, |
| 27 |
MCDI_STATE_PROXY_WAIT, |
| 28 |
MCDI_STATE_COMPLETED, |
| 29 |
}; |
| 30 |
|
| 31 |
/** |
| 32 |
* enum efx_mcdi_mode - MCDI transaction mode |
| 33 |
* @MCDI_MODE_POLL: poll for MCDI completion, until timeout |
| 34 |
* @MCDI_MODE_EVENTS: wait for an mcdi_event. On timeout, poll once |
| 35 |
* @MCDI_MODE_FAIL: we think MCDI is dead, so fail-fast all calls |
| 36 |
*/ |
| 37 |
enum efx_mcdi_mode { |
| 38 |
MCDI_MODE_POLL, |
| 39 |
MCDI_MODE_EVENTS, |
| 40 |
MCDI_MODE_FAIL, |
| 41 |
}; |
| 42 |
|
| 43 |
/** |
| 44 |
* struct efx_mcdi_iface - MCDI protocol context |
| 45 |
* @efx: The associated NIC. |
| 46 |
* @state: Request handling state. Waited for by @wq. |
| 47 |
* @mode: Poll for mcdi completion, or wait for an mcdi_event. |
| 48 |
* @wq: Wait queue for threads waiting for @state != %MCDI_STATE_RUNNING |
| 49 |
* @new_epoch: Indicates start of day or start of MC reboot recovery |
| 50 |
* @iface_lock: Serialises access to @seqno, @credits and response metadata |
| 51 |
* @seqno: The next sequence number to use for mcdi requests. |
| 52 |
* @credits: Number of spurious MCDI completion events allowed before we |
| 53 |
* trigger a fatal error |
| 54 |
* @resprc: Response error/success code (Linux numbering) |
| 55 |
* @resp_hdr_len: Response header length |
| 56 |
* @resp_data_len: Response data (SDU or error) length |
| 57 |
* @async_lock: Serialises access to @async_list while event processing is |
| 58 |
* enabled |
| 59 |
* @async_list: Queue of asynchronous requests |
| 60 |
* @async_timer: Timer for asynchronous request timeout |
| 61 |
* @logging_buffer: buffer that may be used to build MCDI tracing messages |
| 62 |
* @logging_enabled: whether to trace MCDI |
| 63 |
* @proxy_rx_handle: Most recently received proxy authorisation handle |
| 64 |
* @proxy_rx_status: Status of most recent proxy authorisation |
| 65 |
* @proxy_rx_wq: Wait queue for updates to proxy_rx_handle |
| 66 |
*/ |
| 67 |
struct efx_mcdi_iface { |
| 68 |
struct efx_nic *efx; |
| 69 |
enum efx_mcdi_state state; |
| 70 |
enum efx_mcdi_mode mode; |
| 71 |
wait_queue_head_t wq; |
| 72 |
spinlock_t iface_lock; |
| 73 |
bool new_epoch; |
| 74 |
unsigned int credits; |
| 75 |
unsigned int seqno; |
| 76 |
int resprc; |
| 77 |
int resprc_raw; |
| 78 |
size_t resp_hdr_len; |
| 79 |
size_t resp_data_len; |
| 80 |
spinlock_t async_lock; |
| 81 |
struct list_head async_list; |
| 82 |
struct timer_list async_timer; |
| 83 |
#ifdef CONFIG_SFC_MCDI_LOGGING |
| 84 |
char *logging_buffer; |
| 85 |
bool logging_enabled; |
| 86 |
#endif |
| 87 |
unsigned int proxy_rx_handle; |
| 88 |
int proxy_rx_status; |
| 89 |
wait_queue_head_t proxy_rx_wq; |
| 90 |
}; |
| 91 |
|
| 92 |
struct efx_mcdi_mon { |
| 93 |
struct efx_buffer dma_buf; |
| 94 |
struct mutex update_lock; |
| 95 |
unsigned long last_update; |
| 96 |
struct device *device; |
| 97 |
struct efx_mcdi_mon_attribute *attrs; |
| 98 |
struct attribute_group group; |
| 99 |
const struct attribute_group *groups[2]; |
| 100 |
unsigned int n_attrs; |
| 101 |
}; |
| 102 |
|
| 103 |
struct efx_mcdi_mtd_partition { |
| 104 |
struct efx_mtd_partition common; |
| 105 |
bool updating; |
| 106 |
u16 nvram_type; |
| 107 |
u16 fw_subtype; |
| 108 |
}; |
| 109 |
|
| 110 |
#define to_efx_mcdi_mtd_partition(mtd) \ |
| 111 |
container_of(mtd, struct efx_mcdi_mtd_partition, common.mtd) |
| 112 |
|
| 113 |
/** |
| 114 |
* struct efx_mcdi_data - extra state for NICs that implement MCDI |
| 115 |
* @iface: Interface/protocol state |
| 116 |
* @hwmon: Hardware monitor state |
| 117 |
* @fn_flags: Flags for this function, as returned by %MC_CMD_DRV_ATTACH. |
| 118 |
*/ |
| 119 |
struct efx_mcdi_data { |
| 120 |
struct efx_mcdi_iface iface; |
| 121 |
#ifdef CONFIG_SFC_MCDI_MON |
| 122 |
struct efx_mcdi_mon hwmon; |
| 123 |
#endif |
| 124 |
u32 fn_flags; |
| 125 |
}; |
| 126 |
|
| 127 |
static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx) |
| 128 |
{ |
| 129 |
EFX_WARN_ON_PARANOID(!efx->mcdi); |
| 130 |
return &efx->mcdi->iface; |
| 131 |
} |
| 132 |
|
| 133 |
#ifdef CONFIG_SFC_MCDI_MON |
| 134 |
static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx) |
| 135 |
{ |
| 136 |
EFX_WARN_ON_PARANOID(!efx->mcdi); |
| 137 |
return &efx->mcdi->hwmon; |
| 138 |
} |
| 139 |
#endif |
| 140 |
|
| 141 |
int efx_mcdi_init(struct efx_nic *efx); |
| 142 |
void efx_mcdi_detach(struct efx_nic *efx); |
| 143 |
void efx_mcdi_fini(struct efx_nic *efx); |
| 144 |
|
| 145 |
int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const efx_dword_t *inbuf, |
| 146 |
size_t inlen, efx_dword_t *outbuf, size_t outlen, |
| 147 |
size_t *outlen_actual); |
| 148 |
int efx_mcdi_rpc_quiet(struct efx_nic *efx, unsigned cmd, |
| 149 |
const efx_dword_t *inbuf, size_t inlen, |
| 150 |
efx_dword_t *outbuf, size_t outlen, |
| 151 |
size_t *outlen_actual); |
| 152 |
|
| 153 |
int efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd, |
| 154 |
const efx_dword_t *inbuf, size_t inlen); |
| 155 |
int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen, |
| 156 |
efx_dword_t *outbuf, size_t outlen, |
| 157 |
size_t *outlen_actual); |
| 158 |
|
| 159 |
typedef void efx_mcdi_async_completer(struct efx_nic *efx, |
| 160 |
unsigned long cookie, int rc, |
| 161 |
efx_dword_t *outbuf, |
| 162 |
size_t outlen_actual); |
| 163 |
int efx_mcdi_rpc_async(struct efx_nic *efx, unsigned int cmd, |
| 164 |
const efx_dword_t *inbuf, size_t inlen, size_t outlen, |
| 165 |
efx_mcdi_async_completer *complete, |
| 166 |
unsigned long cookie); |
| 167 |
|
| 168 |
void efx_mcdi_display_error(struct efx_nic *efx, unsigned cmd, |
| 169 |
size_t inlen, efx_dword_t *outbuf, |
| 170 |
size_t outlen, int rc); |
| 171 |
|
| 172 |
int efx_mcdi_poll_reboot(struct efx_nic *efx); |
| 173 |
void efx_mcdi_mode_poll(struct efx_nic *efx); |
| 174 |
void efx_mcdi_mode_event(struct efx_nic *efx); |
| 175 |
void efx_mcdi_flush_async(struct efx_nic *efx); |
| 176 |
|
| 177 |
void efx_mcdi_process_event(struct efx_channel *channel, efx_qword_t *event); |
| 178 |
void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev); |
| 179 |
|
| 180 |
/* We expect that 16- and 32-bit fields in MCDI requests and responses |
| 181 |
* are appropriately aligned, but 64-bit fields are only |
| 182 |
* 32-bit-aligned. Also, on Siena we must copy to the MC shared |
| 183 |
* memory strictly 32 bits at a time, so add any necessary padding. |
| 184 |
*/ |
| 185 |
#define MCDI_TX_BUF_LEN(_len) DIV_ROUND_UP((_len), 4) |
| 186 |
#define _MCDI_DECLARE_BUF(_name, _len) \ |
| 187 |
efx_dword_t _name[DIV_ROUND_UP(_len, 4)] |
| 188 |
#define MCDI_DECLARE_BUF(_name, _len) \ |
| 189 |
_MCDI_DECLARE_BUF(_name, _len) = {{{0}}} |
| 190 |
#define MCDI_DECLARE_BUF_ERR(_name) \ |
| 191 |
MCDI_DECLARE_BUF(_name, 8) |
| 192 |
#define _MCDI_PTR(_buf, _offset) \ |
| 193 |
((u8 *)(_buf) + (_offset)) |
| 194 |
#define MCDI_PTR(_buf, _field) \ |
| 195 |
_MCDI_PTR(_buf, MC_CMD_ ## _field ## _OFST) |
| 196 |
/* Use MCDI_STRUCT_ functions to access members of MCDI structuredefs. |
| 197 |
* _buf should point to the start of the structure, typically obtained with |
| 198 |
* MCDI_DECLARE_STRUCT_PTR(structure) = _MCDI_DWORD(mcdi_buf, FIELD_WHICH_IS_STRUCT); |
| 199 |
*/ |
| 200 |
#define MCDI_STRUCT_PTR(_buf, _field) \ |
| 201 |
_MCDI_PTR(_buf, _field ## _OFST) |
| 202 |
#define _MCDI_CHECK_ALIGN(_ofst, _align) \ |
| 203 |
((_ofst) + BUILD_BUG_ON_ZERO((_ofst) & (_align - 1))) |
| 204 |
#define _MCDI_DWORD(_buf, _field) \ |
| 205 |
((_buf) + (_MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, 4) >> 2)) |
| 206 |
#define _MCDI_STRUCT_DWORD(_buf, _field) \ |
| 207 |
((_buf) + (_MCDI_CHECK_ALIGN(_field ## _OFST, 4) >> 2)) |
| 208 |
|
| 209 |
#define MCDI_STRUCT_SET_BYTE(_buf, _field, _value) do { \ |
| 210 |
BUILD_BUG_ON(_field ## _LEN != 1); \ |
| 211 |
*(u8 *)MCDI_STRUCT_PTR(_buf, _field) = _value; \ |
| 212 |
} while (0) |
| 213 |
#define MCDI_STRUCT_POPULATE_BYTE_1(_buf, _field, _name, _value) do { \ |
| 214 |
efx_dword_t _temp; \ |
| 215 |
EFX_POPULATE_DWORD_1(_temp, _name, _value); \ |
| 216 |
MCDI_STRUCT_SET_BYTE(_buf, _field, \ |
| 217 |
EFX_DWORD_FIELD(_temp, EFX_BYTE_0)); \ |
| 218 |
} while (0) |
| 219 |
#define MCDI_BYTE(_buf, _field) \ |
| 220 |
((void)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 1), \ |
| 221 |
*MCDI_PTR(_buf, _field)) |
| 222 |
#define MCDI_STRUCT_BYTE(_buf, _field) \ |
| 223 |
((void)BUILD_BUG_ON_ZERO(_field ## _LEN != 1), \ |
| 224 |
*MCDI_STRUCT_PTR(_buf, _field)) |
| 225 |
#define MCDI_SET_WORD(_buf, _field, _value) do { \ |
| 226 |
BUILD_BUG_ON(MC_CMD_ ## _field ## _LEN != 2); \ |
| 227 |
BUILD_BUG_ON(MC_CMD_ ## _field ## _OFST & 1); \ |
| 228 |
*(__force __le16 *)MCDI_PTR(_buf, _field) = cpu_to_le16(_value);\ |
| 229 |
} while (0) |
| 230 |
#define MCDI_STRUCT_SET_WORD(_buf, _field, _value) do { \ |
| 231 |
BUILD_BUG_ON(_field ## _LEN != 2); \ |
| 232 |
BUILD_BUG_ON(_field ## _OFST & 1); \ |
| 233 |
*(__force __le16 *)MCDI_STRUCT_PTR(_buf, _field) = cpu_to_le16(_value);\ |
| 234 |
} while (0) |
| 235 |
#define MCDI_WORD(_buf, _field) \ |
| 236 |
((u16)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \ |
| 237 |
le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field))) |
| 238 |
#define MCDI_STRUCT_WORD(_buf, _field) \ |
| 239 |
((void)BUILD_BUG_ON_ZERO(_field ## _LEN != 2), \ |
| 240 |
le16_to_cpu(*(__force const __le16 *)MCDI_STRUCT_PTR(_buf, _field))) |
| 241 |
/* Write a 16-bit field defined in the protocol as being big-endian. */ |
| 242 |
#define MCDI_SET_WORD_BE(_buf, _field, _value) do { \ |
| 243 |
BUILD_BUG_ON(MC_CMD_ ## _field ## _LEN != 2); \ |
| 244 |
BUILD_BUG_ON(MC_CMD_ ## _field ## _OFST & 1); \ |
| 245 |
*(__force __be16 *)MCDI_PTR(_buf, _field) = (_value); \ |
| 246 |
} while (0) |
| 247 |
#define MCDI_STRUCT_SET_WORD_BE(_buf, _field, _value) do { \ |
| 248 |
BUILD_BUG_ON(_field ## _LEN != 2); \ |
| 249 |
BUILD_BUG_ON(_field ## _OFST & 1); \ |
| 250 |
*(__force __be16 *)MCDI_STRUCT_PTR(_buf, _field) = (_value); \ |
| 251 |
} while (0) |
| 252 |
#define MCDI_SET_DWORD(_buf, _field, _value) \ |
| 253 |
EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0, _value) |
| 254 |
#define MCDI_STRUCT_SET_DWORD(_buf, _field, _value) \ |
| 255 |
EFX_POPULATE_DWORD_1(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0, _value) |
| 256 |
#define MCDI_DWORD(_buf, _field) \ |
| 257 |
EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0) |
| 258 |
#define MCDI_STRUCT_DWORD(_buf, _field) \ |
| 259 |
EFX_DWORD_FIELD(*_MCDI_STRUCT_DWORD(_buf, _field), EFX_DWORD_0) |
| 260 |
/* Write a 32-bit field defined in the protocol as being big-endian. */ |
| 261 |
#define MCDI_STRUCT_SET_DWORD_BE(_buf, _field, _value) do { \ |
| 262 |
BUILD_BUG_ON(_field ## _LEN != 4); \ |
| 263 |
BUILD_BUG_ON(_field ## _OFST & 3); \ |
| 264 |
*(__force __be32 *)MCDI_STRUCT_PTR(_buf, _field) = (_value); \ |
| 265 |
} while (0) |
| 266 |
#define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1) \ |
| 267 |
EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), \ |
| 268 |
MC_CMD_ ## _name1, _value1) |
| 269 |
#define MCDI_POPULATE_DWORD_2(_buf, _field, _name1, _value1, \ |
| 270 |
_name2, _value2) \ |
| 271 |
EFX_POPULATE_DWORD_2(*_MCDI_DWORD(_buf, _field), \ |
| 272 |
MC_CMD_ ## _name1, _value1, \ |
| 273 |
MC_CMD_ ## _name2, _value2) |
| 274 |
#define MCDI_POPULATE_DWORD_3(_buf, _field, _name1, _value1, \ |
| 275 |
_name2, _value2, _name3, _value3) \ |
| 276 |
EFX_POPULATE_DWORD_3(*_MCDI_DWORD(_buf, _field), \ |
| 277 |
MC_CMD_ ## _name1, _value1, \ |
| 278 |
MC_CMD_ ## _name2, _value2, \ |
| 279 |
MC_CMD_ ## _name3, _value3) |
| 280 |
#define MCDI_POPULATE_DWORD_4(_buf, _field, _name1, _value1, \ |
| 281 |
_name2, _value2, _name3, _value3, \ |
| 282 |
_name4, _value4) \ |
| 283 |
EFX_POPULATE_DWORD_4(*_MCDI_DWORD(_buf, _field), \ |
| 284 |
MC_CMD_ ## _name1, _value1, \ |
| 285 |
MC_CMD_ ## _name2, _value2, \ |
| 286 |
MC_CMD_ ## _name3, _value3, \ |
| 287 |
MC_CMD_ ## _name4, _value4) |
| 288 |
#define MCDI_POPULATE_DWORD_5(_buf, _field, _name1, _value1, \ |
| 289 |
_name2, _value2, _name3, _value3, \ |
| 290 |
_name4, _value4, _name5, _value5) \ |
| 291 |
EFX_POPULATE_DWORD_5(*_MCDI_DWORD(_buf, _field), \ |
| 292 |
MC_CMD_ ## _name1, _value1, \ |
| 293 |
MC_CMD_ ## _name2, _value2, \ |
| 294 |
MC_CMD_ ## _name3, _value3, \ |
| 295 |
MC_CMD_ ## _name4, _value4, \ |
| 296 |
MC_CMD_ ## _name5, _value5) |
| 297 |
#define MCDI_POPULATE_DWORD_6(_buf, _field, _name1, _value1, \ |
| 298 |
_name2, _value2, _name3, _value3, \ |
| 299 |
_name4, _value4, _name5, _value5, \ |
| 300 |
_name6, _value6) \ |
| 301 |
EFX_POPULATE_DWORD_6(*_MCDI_DWORD(_buf, _field), \ |
| 302 |
MC_CMD_ ## _name1, _value1, \ |
| 303 |
MC_CMD_ ## _name2, _value2, \ |
| 304 |
MC_CMD_ ## _name3, _value3, \ |
| 305 |
MC_CMD_ ## _name4, _value4, \ |
| 306 |
MC_CMD_ ## _name5, _value5, \ |
| 307 |
MC_CMD_ ## _name6, _value6) |
| 308 |
#define MCDI_POPULATE_DWORD_7(_buf, _field, _name1, _value1, \ |
| 309 |
_name2, _value2, _name3, _value3, \ |
| 310 |
_name4, _value4, _name5, _value5, \ |
| 311 |
_name6, _value6, _name7, _value7) \ |
| 312 |
EFX_POPULATE_DWORD_7(*_MCDI_DWORD(_buf, _field), \ |
| 313 |
MC_CMD_ ## _name1, _value1, \ |
| 314 |
MC_CMD_ ## _name2, _value2, \ |
| 315 |
MC_CMD_ ## _name3, _value3, \ |
| 316 |
MC_CMD_ ## _name4, _value4, \ |
| 317 |
MC_CMD_ ## _name5, _value5, \ |
| 318 |
MC_CMD_ ## _name6, _value6, \ |
| 319 |
MC_CMD_ ## _name7, _value7) |
| 320 |
#define MCDI_SET_QWORD(_buf, _field, _value) \ |
| 321 |
do { \ |
| 322 |
EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[0], \ |
| 323 |
EFX_DWORD_0, (u32)(_value)); \ |
| 324 |
EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[1], \ |
| 325 |
EFX_DWORD_0, (u64)(_value) >> 32); \ |
| 326 |
} while (0) |
| 327 |
#define MCDI_QWORD(_buf, _field) \ |
| 328 |
(EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[0], EFX_DWORD_0) | \ |
| 329 |
(u64)EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[1], EFX_DWORD_0) << 32) |
| 330 |
#define MCDI_FIELD(_ptr, _type, _field) \ |
| 331 |
EFX_EXTRACT_DWORD( \ |
| 332 |
*(efx_dword_t *) \ |
| 333 |
_MCDI_PTR(_ptr, MC_CMD_ ## _type ## _ ## _field ## _OFST & ~3),\ |
| 334 |
MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f, \ |
| 335 |
(MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f) + \ |
| 336 |
MC_CMD_ ## _type ## _ ## _field ## _WIDTH - 1) |
| 337 |
|
| 338 |
#define _MCDI_ARRAY_PTR(_buf, _field, _index, _align) \ |
| 339 |
(_MCDI_PTR(_buf, _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, _align))\ |
| 340 |
+ (_index) * _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _LEN, _align)) |
| 341 |
#define MCDI_DECLARE_STRUCT_PTR(_name) \ |
| 342 |
efx_dword_t *_name |
| 343 |
#define MCDI_ARRAY_STRUCT_PTR(_buf, _field, _index) \ |
| 344 |
((efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4)) |
| 345 |
#define MCDI_VAR_ARRAY_LEN(_len, _field) \ |
| 346 |
min_t(size_t, MC_CMD_ ## _field ## _MAXNUM, \ |
| 347 |
((_len) - MC_CMD_ ## _field ## _OFST) / MC_CMD_ ## _field ## _LEN) |
| 348 |
#define MCDI_ARRAY_WORD(_buf, _field, _index) \ |
| 349 |
(BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \ |
| 350 |
le16_to_cpu(*(__force const __le16 *) \ |
| 351 |
_MCDI_ARRAY_PTR(_buf, _field, _index, 2))) |
| 352 |
#define _MCDI_ARRAY_DWORD(_buf, _field, _index) \ |
| 353 |
(BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 4) + \ |
| 354 |
(efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4)) |
| 355 |
#define MCDI_SET_ARRAY_DWORD(_buf, _field, _index, _value) \ |
| 356 |
EFX_SET_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index), \ |
| 357 |
EFX_DWORD_0, _value) |
| 358 |
#define MCDI_ARRAY_DWORD(_buf, _field, _index) \ |
| 359 |
EFX_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index), EFX_DWORD_0) |
| 360 |
#define _MCDI_ARRAY_QWORD(_buf, _field, _index) \ |
| 361 |
(BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 8) + \ |
| 362 |
(efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4)) |
| 363 |
#define MCDI_SET_ARRAY_QWORD(_buf, _field, _index, _value) \ |
| 364 |
do { \ |
| 365 |
EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[0],\ |
| 366 |
EFX_DWORD_0, (u32)(_value)); \ |
| 367 |
EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[1],\ |
| 368 |
EFX_DWORD_0, (u64)(_value) >> 32); \ |
| 369 |
} while (0) |
| 370 |
#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2) \ |
| 371 |
MCDI_FIELD(MCDI_ARRAY_STRUCT_PTR(_buf, _field1, _index), \ |
| 372 |
_type ## _TYPEDEF, _field2) |
| 373 |
|
| 374 |
#define MCDI_EVENT_FIELD(_ev, _field) \ |
| 375 |
EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field) |
| 376 |
|
| 377 |
#define MCDI_CAPABILITY(field) \ |
| 378 |
MC_CMD_GET_CAPABILITIES_V8_OUT_ ## field ## _LBN |
| 379 |
|
| 380 |
#define MCDI_CAPABILITY_OFST(field) \ |
| 381 |
MC_CMD_GET_CAPABILITIES_V8_OUT_ ## field ## _OFST |
| 382 |
|
| 383 |
#define efx_has_cap(efx, field) \ |
| 384 |
efx->type->check_caps(efx, \ |
| 385 |
MCDI_CAPABILITY(field), \ |
| 386 |
MCDI_CAPABILITY_OFST(field)) |
| 387 |
|
| 388 |
void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len); |
| 389 |
int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address, |
| 390 |
u16 *fw_subtype_list, u32 *capabilities); |
| 391 |
int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq); |
| 392 |
int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out); |
| 393 |
int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type, |
| 394 |
size_t *size_out, size_t *erase_size_out, |
| 395 |
size_t *write_size_out, bool *protected_out); |
| 396 |
int efx_new_mcdi_nvram_test_all(struct efx_nic *efx); |
| 397 |
int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type, |
| 398 |
u32 *subtype, u16 version[4], char *desc, |
| 399 |
size_t descsize); |
| 400 |
int efx_mcdi_nvram_test_all(struct efx_nic *efx); |
| 401 |
int efx_mcdi_handle_assertion(struct efx_nic *efx); |
| 402 |
int efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode); |
| 403 |
int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx, const u8 *mac, |
| 404 |
int *id_out); |
| 405 |
int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id); |
| 406 |
int efx_mcdi_wol_filter_reset(struct efx_nic *efx); |
| 407 |
void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev); |
| 408 |
void efx_mcdi_mac_start_stats(struct efx_nic *efx); |
| 409 |
void efx_mcdi_mac_stop_stats(struct efx_nic *efx); |
| 410 |
void efx_mcdi_mac_pull_stats(struct efx_nic *efx); |
| 411 |
enum reset_type efx_mcdi_map_reset_reason(enum reset_type reason); |
| 412 |
int efx_mcdi_reset(struct efx_nic *efx, enum reset_type method); |
| 413 |
int efx_mcdi_set_workaround(struct efx_nic *efx, u32 type, bool enabled, |
| 414 |
unsigned int *flags); |
| 415 |
int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out, |
| 416 |
unsigned int *enabled_out); |
| 417 |
int efx_mcdi_get_privilege_mask(struct efx_nic *efx, u32 *mask); |
| 418 |
|
| 419 |
#ifdef CONFIG_SFC_MCDI_MON |
| 420 |
int efx_mcdi_mon_probe(struct efx_nic *efx); |
| 421 |
void efx_mcdi_mon_remove(struct efx_nic *efx); |
| 422 |
#else |
| 423 |
static inline int efx_mcdi_mon_probe(struct efx_nic *efx) { return 0; } |
| 424 |
static inline void efx_mcdi_mon_remove(struct efx_nic *efx) {} |
| 425 |
#endif |
| 426 |
|
| 427 |
int efx_mcdi_nvram_update_start(struct efx_nic *efx, unsigned int type); |
| 428 |
int efx_mcdi_nvram_write(struct efx_nic *efx, unsigned int type, |
| 429 |
loff_t offset, const u8 *buffer, size_t length); |
| 430 |
int efx_mcdi_nvram_erase(struct efx_nic *efx, unsigned int type, |
| 431 |
loff_t offset, size_t length); |
| 432 |
int efx_mcdi_nvram_metadata(struct efx_nic *efx, unsigned int type, |
| 433 |
u32 *subtype, u16 version[4], char *desc, |
| 434 |
size_t descsize); |
| 435 |
|
| 436 |
enum efx_update_finish_mode { |
| 437 |
EFX_UPDATE_FINISH_WAIT, |
| 438 |
EFX_UPDATE_FINISH_BACKGROUND, |
| 439 |
EFX_UPDATE_FINISH_POLL, |
| 440 |
EFX_UPDATE_FINISH_ABORT, |
| 441 |
}; |
| 442 |
|
| 443 |
int efx_mcdi_nvram_update_finish(struct efx_nic *efx, unsigned int type, |
| 444 |
enum efx_update_finish_mode mode); |
| 445 |
int efx_mcdi_nvram_update_finish_polled(struct efx_nic *efx, unsigned int type); |
| 446 |
|
| 447 |
#ifdef CONFIG_SFC_MTD |
| 448 |
int efx_mcdi_mtd_read(struct mtd_info *mtd, loff_t start, size_t len, |
| 449 |
size_t *retlen, u8 *buffer); |
| 450 |
int efx_mcdi_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len); |
| 451 |
int efx_mcdi_mtd_write(struct mtd_info *mtd, loff_t start, size_t len, |
| 452 |
size_t *retlen, const u8 *buffer); |
| 453 |
int efx_mcdi_mtd_sync(struct mtd_info *mtd); |
| 454 |
void efx_mcdi_mtd_rename(struct efx_mtd_partition *part); |
| 455 |
#endif |
| 456 |
|
| 457 |
#endif /* EFX_MCDI_H */ |