Linux Audio

Check our new training course

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