blob: 397660d1b3de0b809b274137a583901a91e097d9 [file] [log] [blame]
Ben Hutchingsafd4aea2009-11-29 15:15:25 +00001/****************************************************************************
Ben Hutchingsf7a6d2c2013-08-29 23:32:48 +01002 * Driver for Solarflare network controllers and boards
3 * Copyright 2008-2013 Solarflare Communications Inc.
Ben Hutchingsafd4aea2009-11-29 15:15:25 +00004 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
8 */
9
10#ifndef EFX_MCDI_H
11#define EFX_MCDI_H
12
13/**
Ben Hutchingsf76fe122012-10-26 17:53:11 +010014 * enum efx_mcdi_state - MCDI request handling state
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000015 * @MCDI_STATE_QUIESCENT: No pending MCDI requests. If the caller holds the
Ben Hutchingsf76fe122012-10-26 17:53:11 +010016 * mcdi @iface_lock then they are able to move to %MCDI_STATE_RUNNING
Ben Hutchingscade7152013-08-27 23:12:31 +010017 * @MCDI_STATE_RUNNING_SYNC: There is a synchronous MCDI request pending.
18 * Only the thread that moved into this state is allowed to move out of it.
19 * @MCDI_STATE_RUNNING_ASYNC: There is an asynchronous MCDI request pending.
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000020 * @MCDI_STATE_COMPLETED: An MCDI request has completed, but the owning thread
21 * has not yet consumed the result. For all other threads, equivalent to
Ben Hutchingsf76fe122012-10-26 17:53:11 +010022 * %MCDI_STATE_RUNNING.
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000023 */
24enum efx_mcdi_state {
25 MCDI_STATE_QUIESCENT,
Ben Hutchingscade7152013-08-27 23:12:31 +010026 MCDI_STATE_RUNNING_SYNC,
27 MCDI_STATE_RUNNING_ASYNC,
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000028 MCDI_STATE_COMPLETED,
29};
30
Edward Creee2835462014-04-16 19:27:48 +010031/**
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 */
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000037enum efx_mcdi_mode {
38 MCDI_MODE_POLL,
39 MCDI_MODE_EVENTS,
Edward Creee2835462014-04-16 19:27:48 +010040 MCDI_MODE_FAIL,
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000041};
42
43/**
Ben Hutchingsf76fe122012-10-26 17:53:11 +010044 * struct efx_mcdi_iface - MCDI protocol context
Ben Hutchingscade7152013-08-27 23:12:31 +010045 * @efx: The associated NIC.
Ben Hutchingsf76fe122012-10-26 17:53:11 +010046 * @state: Request handling state. Waited for by @wq.
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000047 * @mode: Poll for mcdi completion, or wait for an mcdi_event.
Ben Hutchingsf76fe122012-10-26 17:53:11 +010048 * @wq: Wait queue for threads waiting for @state != %MCDI_STATE_RUNNING
Daniel Pieczkod36a08b2013-06-20 11:40:07 +010049 * @new_epoch: Indicates start of day or start of MC reboot recovery
Ben Hutchingscade7152013-08-27 23:12:31 +010050 * @iface_lock: Serialises access to @seqno, @credits and response metadata
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000051 * @seqno: The next sequence number to use for mcdi requests.
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000052 * @credits: Number of spurious MCDI completion events allowed before we
Ben Hutchingsf76fe122012-10-26 17:53:11 +010053 * trigger a fatal error
Ben Hutchings5bc283e2012-10-08 21:43:00 +010054 * @resprc: Response error/success code (Linux numbering)
Ben Hutchingsdf2cd8a2012-09-19 00:56:18 +010055 * @resp_hdr_len: Response header length
56 * @resp_data_len: Response data (SDU or error) length
Ben Hutchingscade7152013-08-27 23:12:31 +010057 * @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
Edward Cree75aba2a2015-05-27 13:13:54 +010061 * @logging_buffer: buffer that may be used to build MCDI tracing messages
Edward Creee7fef9b2015-05-27 13:14:01 +010062 * @logging_enabled: whether to trace MCDI
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000063 */
64struct efx_mcdi_iface {
Ben Hutchingscade7152013-08-27 23:12:31 +010065 struct efx_nic *efx;
Ben Hutchings251111d2013-08-27 23:04:29 +010066 enum efx_mcdi_state state;
Ben Hutchingsf76fe122012-10-26 17:53:11 +010067 enum efx_mcdi_mode mode;
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000068 wait_queue_head_t wq;
69 spinlock_t iface_lock;
Daniel Pieczkod36a08b2013-06-20 11:40:07 +010070 bool new_epoch;
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000071 unsigned int credits;
72 unsigned int seqno;
Ben Hutchings5bc283e2012-10-08 21:43:00 +010073 int resprc;
Bert Kenwardac28d172015-12-23 08:56:40 +000074 int resprc_raw;
Ben Hutchingsdf2cd8a2012-09-19 00:56:18 +010075 size_t resp_hdr_len;
76 size_t resp_data_len;
Ben Hutchingscade7152013-08-27 23:12:31 +010077 spinlock_t async_lock;
78 struct list_head async_list;
79 struct timer_list async_timer;
Edward Cree75aba2a2015-05-27 13:13:54 +010080#ifdef CONFIG_SFC_MCDI_LOGGING
81 char *logging_buffer;
Edward Creee7fef9b2015-05-27 13:14:01 +010082 bool logging_enabled;
Edward Cree75aba2a2015-05-27 13:13:54 +010083#endif
Ben Hutchingsafd4aea2009-11-29 15:15:25 +000084};
85
Ben Hutchings55c5e0f82012-01-06 20:25:39 +000086struct efx_mcdi_mon {
87 struct efx_buffer dma_buf;
88 struct mutex update_lock;
89 unsigned long last_update;
90 struct device *device;
91 struct efx_mcdi_mon_attribute *attrs;
Guenter Roeck85493e62013-11-27 18:54:31 -080092 struct attribute_group group;
93 const struct attribute_group *groups[2];
Ben Hutchings55c5e0f82012-01-06 20:25:39 +000094 unsigned int n_attrs;
95};
96
Ben Hutchings45a3fd52012-11-28 04:38:14 +000097struct efx_mcdi_mtd_partition {
98 struct efx_mtd_partition common;
99 bool updating;
Ben Hutchings8127d662013-08-29 19:19:29 +0100100 u16 nvram_type;
Ben Hutchings45a3fd52012-11-28 04:38:14 +0000101 u16 fw_subtype;
102};
103
104#define to_efx_mcdi_mtd_partition(mtd) \
105 container_of(mtd, struct efx_mcdi_mtd_partition, common.mtd)
106
Ben Hutchingsf3ad5002012-09-18 02:33:56 +0100107/**
108 * struct efx_mcdi_data - extra state for NICs that implement MCDI
109 * @iface: Interface/protocol state
110 * @hwmon: Hardware monitor state
Ben Hutchings8349f7f2013-10-16 18:32:34 +0100111 * @fn_flags: Flags for this function, as returned by %MC_CMD_DRV_ATTACH.
Ben Hutchingsf3ad5002012-09-18 02:33:56 +0100112 */
113struct efx_mcdi_data {
114 struct efx_mcdi_iface iface;
115#ifdef CONFIG_SFC_MCDI_MON
116 struct efx_mcdi_mon hwmon;
117#endif
Ben Hutchings8349f7f2013-10-16 18:32:34 +0100118 u32 fn_flags;
Ben Hutchingsf3ad5002012-09-18 02:33:56 +0100119};
120
Edward Creee2835462014-04-16 19:27:48 +0100121static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
122{
123 EFX_BUG_ON_PARANOID(!efx->mcdi);
124 return &efx->mcdi->iface;
125}
126
Ben Hutchingsf3ad5002012-09-18 02:33:56 +0100127#ifdef CONFIG_SFC_MCDI_MON
128static inline struct efx_mcdi_mon *efx_mcdi_mon(struct efx_nic *efx)
129{
130 EFX_BUG_ON_PARANOID(!efx->mcdi);
131 return &efx->mcdi->hwmon;
132}
133#endif
134
Joe Perches00aef982013-09-23 11:37:59 -0700135int efx_mcdi_init(struct efx_nic *efx);
136void efx_mcdi_fini(struct efx_nic *efx);
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000137
Joe Perches00aef982013-09-23 11:37:59 -0700138int efx_mcdi_rpc(struct efx_nic *efx, unsigned cmd, const efx_dword_t *inbuf,
139 size_t inlen, efx_dword_t *outbuf, size_t outlen,
140 size_t *outlen_actual);
Edward Cree1e0b8122013-05-31 18:36:12 +0100141int efx_mcdi_rpc_quiet(struct efx_nic *efx, unsigned cmd,
142 const efx_dword_t *inbuf, size_t inlen,
143 efx_dword_t *outbuf, size_t outlen,
144 size_t *outlen_actual);
Joe Perches00aef982013-09-23 11:37:59 -0700145
146int efx_mcdi_rpc_start(struct efx_nic *efx, unsigned cmd,
147 const efx_dword_t *inbuf, size_t inlen);
148int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
Ben Hutchings9528b922012-09-14 17:31:41 +0100149 efx_dword_t *outbuf, size_t outlen,
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000150 size_t *outlen_actual);
Edward Cree1e0b8122013-05-31 18:36:12 +0100151int efx_mcdi_rpc_finish_quiet(struct efx_nic *efx, unsigned cmd,
152 size_t inlen, efx_dword_t *outbuf,
153 size_t outlen, size_t *outlen_actual);
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000154
Ben Hutchingscade7152013-08-27 23:12:31 +0100155typedef void efx_mcdi_async_completer(struct efx_nic *efx,
156 unsigned long cookie, int rc,
157 efx_dword_t *outbuf,
158 size_t outlen_actual);
Joe Perches00aef982013-09-23 11:37:59 -0700159int efx_mcdi_rpc_async(struct efx_nic *efx, unsigned int cmd,
160 const efx_dword_t *inbuf, size_t inlen, size_t outlen,
161 efx_mcdi_async_completer *complete,
162 unsigned long cookie);
Edward Cree1e0b8122013-05-31 18:36:12 +0100163int efx_mcdi_rpc_async_quiet(struct efx_nic *efx, unsigned int cmd,
164 const efx_dword_t *inbuf, size_t inlen,
165 size_t outlen,
166 efx_mcdi_async_completer *complete,
167 unsigned long cookie);
168
169void efx_mcdi_display_error(struct efx_nic *efx, unsigned cmd,
170 size_t inlen, efx_dword_t *outbuf,
171 size_t outlen, int rc);
Ben Hutchings9528b922012-09-14 17:31:41 +0100172
Joe Perches00aef982013-09-23 11:37:59 -0700173int efx_mcdi_poll_reboot(struct efx_nic *efx);
174void efx_mcdi_mode_poll(struct efx_nic *efx);
175void efx_mcdi_mode_event(struct efx_nic *efx);
176void efx_mcdi_flush_async(struct efx_nic *efx);
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000177
Joe Perches00aef982013-09-23 11:37:59 -0700178void efx_mcdi_process_event(struct efx_channel *channel, efx_qword_t *event);
179void efx_mcdi_sensor_event(struct efx_nic *efx, efx_qword_t *ev);
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000180
Ben Hutchings9528b922012-09-14 17:31:41 +0100181/* We expect that 16- and 32-bit fields in MCDI requests and responses
Ben Hutchings338f74d2012-10-10 23:20:17 +0100182 * are appropriately aligned, but 64-bit fields are only
183 * 32-bit-aligned. Also, on Siena we must copy to the MC shared
184 * memory strictly 32 bits at a time, so add any necessary padding.
Ben Hutchings9528b922012-09-14 17:31:41 +0100185 */
Jon Cooperaa09a3d2015-05-20 11:10:41 +0100186#define _MCDI_DECLARE_BUF(_name, _len) \
Ben Hutchings9528b922012-09-14 17:31:41 +0100187 efx_dword_t _name[DIV_ROUND_UP(_len, 4)]
Jon Cooperaa09a3d2015-05-20 11:10:41 +0100188#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)
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100192#define _MCDI_PTR(_buf, _offset) \
193 ((u8 *)(_buf) + (_offset))
Ben Hutchings30af6912012-09-14 17:30:44 +0100194#define MCDI_PTR(_buf, _field) \
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100195 _MCDI_PTR(_buf, MC_CMD_ ## _field ## _OFST)
Ben Hutchings9528b922012-09-14 17:31:41 +0100196#define _MCDI_CHECK_ALIGN(_ofst, _align) \
197 ((_ofst) + BUILD_BUG_ON_ZERO((_ofst) & (_align - 1)))
Ben Hutchings30af6912012-09-14 17:30:44 +0100198#define _MCDI_DWORD(_buf, _field) \
Ben Hutchings9528b922012-09-14 17:31:41 +0100199 ((_buf) + (_MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, 4) >> 2))
Ben Hutchings59cfc472012-09-14 17:30:10 +0100200
Ben Hutchings8127d662013-08-29 19:19:29 +0100201#define MCDI_WORD(_buf, _field) \
202 ((u16)BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \
203 le16_to_cpu(*(__force const __le16 *)MCDI_PTR(_buf, _field)))
Ben Hutchings30af6912012-09-14 17:30:44 +0100204#define MCDI_SET_DWORD(_buf, _field, _value) \
205 EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0, _value)
206#define MCDI_DWORD(_buf, _field) \
207 EFX_DWORD_FIELD(*_MCDI_DWORD(_buf, _field), EFX_DWORD_0)
Ben Hutchingsf5253d92012-10-10 23:24:51 +0100208#define MCDI_POPULATE_DWORD_1(_buf, _field, _name1, _value1) \
209 EFX_POPULATE_DWORD_1(*_MCDI_DWORD(_buf, _field), \
210 MC_CMD_ ## _name1, _value1)
211#define MCDI_POPULATE_DWORD_2(_buf, _field, _name1, _value1, \
212 _name2, _value2) \
213 EFX_POPULATE_DWORD_2(*_MCDI_DWORD(_buf, _field), \
214 MC_CMD_ ## _name1, _value1, \
215 MC_CMD_ ## _name2, _value2)
216#define MCDI_POPULATE_DWORD_3(_buf, _field, _name1, _value1, \
217 _name2, _value2, _name3, _value3) \
218 EFX_POPULATE_DWORD_3(*_MCDI_DWORD(_buf, _field), \
219 MC_CMD_ ## _name1, _value1, \
220 MC_CMD_ ## _name2, _value2, \
221 MC_CMD_ ## _name3, _value3)
222#define MCDI_POPULATE_DWORD_4(_buf, _field, _name1, _value1, \
223 _name2, _value2, _name3, _value3, \
224 _name4, _value4) \
225 EFX_POPULATE_DWORD_4(*_MCDI_DWORD(_buf, _field), \
226 MC_CMD_ ## _name1, _value1, \
227 MC_CMD_ ## _name2, _value2, \
228 MC_CMD_ ## _name3, _value3, \
229 MC_CMD_ ## _name4, _value4)
230#define MCDI_POPULATE_DWORD_5(_buf, _field, _name1, _value1, \
231 _name2, _value2, _name3, _value3, \
232 _name4, _value4, _name5, _value5) \
233 EFX_POPULATE_DWORD_5(*_MCDI_DWORD(_buf, _field), \
234 MC_CMD_ ## _name1, _value1, \
235 MC_CMD_ ## _name2, _value2, \
236 MC_CMD_ ## _name3, _value3, \
237 MC_CMD_ ## _name4, _value4, \
238 MC_CMD_ ## _name5, _value5)
239#define MCDI_POPULATE_DWORD_6(_buf, _field, _name1, _value1, \
240 _name2, _value2, _name3, _value3, \
241 _name4, _value4, _name5, _value5, \
242 _name6, _value6) \
243 EFX_POPULATE_DWORD_6(*_MCDI_DWORD(_buf, _field), \
244 MC_CMD_ ## _name1, _value1, \
245 MC_CMD_ ## _name2, _value2, \
246 MC_CMD_ ## _name3, _value3, \
247 MC_CMD_ ## _name4, _value4, \
248 MC_CMD_ ## _name5, _value5, \
249 MC_CMD_ ## _name6, _value6)
250#define MCDI_POPULATE_DWORD_7(_buf, _field, _name1, _value1, \
251 _name2, _value2, _name3, _value3, \
252 _name4, _value4, _name5, _value5, \
253 _name6, _value6, _name7, _value7) \
254 EFX_POPULATE_DWORD_7(*_MCDI_DWORD(_buf, _field), \
255 MC_CMD_ ## _name1, _value1, \
256 MC_CMD_ ## _name2, _value2, \
257 MC_CMD_ ## _name3, _value3, \
258 MC_CMD_ ## _name4, _value4, \
259 MC_CMD_ ## _name5, _value5, \
260 MC_CMD_ ## _name6, _value6, \
261 MC_CMD_ ## _name7, _value7)
Ben Hutchings338f74d2012-10-10 23:20:17 +0100262#define MCDI_SET_QWORD(_buf, _field, _value) \
263 do { \
264 EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[0], \
265 EFX_DWORD_0, (u32)(_value)); \
266 EFX_POPULATE_DWORD_1(_MCDI_DWORD(_buf, _field)[1], \
267 EFX_DWORD_0, (u64)(_value) >> 32); \
268 } while (0)
Ben Hutchings30af6912012-09-14 17:30:44 +0100269#define MCDI_QWORD(_buf, _field) \
270 (EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[0], EFX_DWORD_0) | \
271 (u64)EFX_DWORD_FIELD(_MCDI_DWORD(_buf, _field)[1], EFX_DWORD_0) << 32)
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100272#define MCDI_FIELD(_ptr, _type, _field) \
Ben Hutchings0a6e5002012-09-11 21:46:41 +0100273 EFX_EXTRACT_DWORD( \
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100274 *(efx_dword_t *) \
275 _MCDI_PTR(_ptr, MC_CMD_ ## _type ## _ ## _field ## _OFST & ~3),\
276 MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f, \
277 (MC_CMD_ ## _type ## _ ## _field ## _LBN & 0x1f) + \
278 MC_CMD_ ## _type ## _ ## _field ## _WIDTH - 1)
279
Ben Hutchings9528b922012-09-14 17:31:41 +0100280#define _MCDI_ARRAY_PTR(_buf, _field, _index, _align) \
281 (_MCDI_PTR(_buf, _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, _align))\
282 + (_index) * _MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _LEN, _align))
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100283#define MCDI_DECLARE_STRUCT_PTR(_name) \
Ben Hutchings9528b922012-09-14 17:31:41 +0100284 efx_dword_t *_name
285#define MCDI_ARRAY_STRUCT_PTR(_buf, _field, _index) \
286 ((efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100287#define MCDI_VAR_ARRAY_LEN(_len, _field) \
288 min_t(size_t, MC_CMD_ ## _field ## _MAXNUM, \
289 ((_len) - MC_CMD_ ## _field ## _OFST) / MC_CMD_ ## _field ## _LEN)
290#define MCDI_ARRAY_WORD(_buf, _field, _index) \
291 (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 2) + \
292 le16_to_cpu(*(__force const __le16 *) \
Ben Hutchings9528b922012-09-14 17:31:41 +0100293 _MCDI_ARRAY_PTR(_buf, _field, _index, 2)))
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100294#define _MCDI_ARRAY_DWORD(_buf, _field, _index) \
295 (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 4) + \
Ben Hutchings9528b922012-09-14 17:31:41 +0100296 (efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100297#define MCDI_SET_ARRAY_DWORD(_buf, _field, _index, _value) \
298 EFX_SET_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index), \
299 EFX_DWORD_0, _value)
300#define MCDI_ARRAY_DWORD(_buf, _field, _index) \
301 EFX_DWORD_FIELD(*_MCDI_ARRAY_DWORD(_buf, _field, _index), EFX_DWORD_0)
Ben Hutchings338f74d2012-10-10 23:20:17 +0100302#define _MCDI_ARRAY_QWORD(_buf, _field, _index) \
303 (BUILD_BUG_ON_ZERO(MC_CMD_ ## _field ## _LEN != 8) + \
304 (efx_dword_t *)_MCDI_ARRAY_PTR(_buf, _field, _index, 4))
305#define MCDI_SET_ARRAY_QWORD(_buf, _field, _index, _value) \
306 do { \
307 EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[0],\
308 EFX_DWORD_0, (u32)(_value)); \
309 EFX_SET_DWORD_FIELD(_MCDI_ARRAY_QWORD(_buf, _field, _index)[1],\
310 EFX_DWORD_0, (u64)(_value) >> 32); \
311 } while (0)
Ben Hutchingsa649dfc2012-09-14 17:30:58 +0100312#define MCDI_ARRAY_FIELD(_buf, _field1, _type, _index, _field2) \
313 MCDI_FIELD(MCDI_ARRAY_STRUCT_PTR(_buf, _field1, _index), \
314 _type ## _TYPEDEF, _field2)
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000315
Ben Hutchings30af6912012-09-14 17:30:44 +0100316#define MCDI_EVENT_FIELD(_ev, _field) \
317 EFX_QWORD_FIELD(_ev, MCDI_EVENT_ ## _field)
318
Joe Perches00aef982013-09-23 11:37:59 -0700319void efx_mcdi_print_fwver(struct efx_nic *efx, char *buf, size_t len);
320int efx_mcdi_get_board_cfg(struct efx_nic *efx, u8 *mac_address,
321 u16 *fw_subtype_list, u32 *capabilities);
322int efx_mcdi_log_ctrl(struct efx_nic *efx, bool evq, bool uart, u32 dest_evq);
323int efx_mcdi_nvram_types(struct efx_nic *efx, u32 *nvram_types_out);
324int efx_mcdi_nvram_info(struct efx_nic *efx, unsigned int type,
325 size_t *size_out, size_t *erase_size_out,
326 bool *protected_out);
327int efx_mcdi_nvram_test_all(struct efx_nic *efx);
328int efx_mcdi_handle_assertion(struct efx_nic *efx);
329void efx_mcdi_set_id_led(struct efx_nic *efx, enum efx_led_mode mode);
330int efx_mcdi_wol_filter_set_magic(struct efx_nic *efx, const u8 *mac,
331 int *id_out);
332int efx_mcdi_wol_filter_get_magic(struct efx_nic *efx, int *id_out);
333int efx_mcdi_wol_filter_remove(struct efx_nic *efx, int id);
334int efx_mcdi_wol_filter_reset(struct efx_nic *efx);
335int efx_mcdi_flush_rxqs(struct efx_nic *efx);
336int efx_mcdi_port_probe(struct efx_nic *efx);
337void efx_mcdi_port_remove(struct efx_nic *efx);
338int efx_mcdi_port_reconfigure(struct efx_nic *efx);
339int efx_mcdi_port_get_number(struct efx_nic *efx);
340u32 efx_mcdi_phy_get_caps(struct efx_nic *efx);
341void efx_mcdi_process_link_change(struct efx_nic *efx, efx_qword_t *ev);
342int efx_mcdi_set_mac(struct efx_nic *efx);
Ben Hutchings43f775b22012-09-18 02:33:54 +0100343#define EFX_MC_STATS_GENERATION_INVALID ((__force __le64)(-1))
Joe Perches00aef982013-09-23 11:37:59 -0700344void efx_mcdi_mac_start_stats(struct efx_nic *efx);
345void efx_mcdi_mac_stop_stats(struct efx_nic *efx);
Jon Cooperf8f3b5a2013-09-30 17:36:50 +0100346void efx_mcdi_mac_pull_stats(struct efx_nic *efx);
Joe Perches00aef982013-09-23 11:37:59 -0700347bool efx_mcdi_mac_check_fault(struct efx_nic *efx);
348enum reset_type efx_mcdi_map_reset_reason(enum reset_type reason);
349int efx_mcdi_reset(struct efx_nic *efx, enum reset_type method);
Daniel Pieczko34ccfe62015-07-21 15:09:43 +0100350int efx_mcdi_set_workaround(struct efx_nic *efx, u32 type, bool enabled,
351 unsigned int *flags);
Edward Cree267d9d72015-05-06 00:59:18 +0100352int efx_mcdi_get_workarounds(struct efx_nic *efx, unsigned int *impl_out,
353 unsigned int *enabled_out);
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000354
Ben Hutchings55c5e0f82012-01-06 20:25:39 +0000355#ifdef CONFIG_SFC_MCDI_MON
Joe Perches00aef982013-09-23 11:37:59 -0700356int efx_mcdi_mon_probe(struct efx_nic *efx);
357void efx_mcdi_mon_remove(struct efx_nic *efx);
Ben Hutchings55c5e0f82012-01-06 20:25:39 +0000358#else
359static inline int efx_mcdi_mon_probe(struct efx_nic *efx) { return 0; }
360static inline void efx_mcdi_mon_remove(struct efx_nic *efx) {}
361#endif
362
Ben Hutchings45a3fd52012-11-28 04:38:14 +0000363#ifdef CONFIG_SFC_MTD
Joe Perches00aef982013-09-23 11:37:59 -0700364int efx_mcdi_mtd_read(struct mtd_info *mtd, loff_t start, size_t len,
365 size_t *retlen, u8 *buffer);
366int efx_mcdi_mtd_erase(struct mtd_info *mtd, loff_t start, size_t len);
367int efx_mcdi_mtd_write(struct mtd_info *mtd, loff_t start, size_t len,
368 size_t *retlen, const u8 *buffer);
369int efx_mcdi_mtd_sync(struct mtd_info *mtd);
370void efx_mcdi_mtd_rename(struct efx_mtd_partition *part);
Ben Hutchings45a3fd52012-11-28 04:38:14 +0000371#endif
372
Ben Hutchingsafd4aea2009-11-29 15:15:25 +0000373#endif /* EFX_MCDI_H */