/* SPDX-License-Identifier: GPL-2.0-only */ /**************************************************************************** * Driver for Solarflare network controllers and boards * Copyright 2008-2013 Solarflare Communications Inc.
*/
#ifndef EFX_MCDI_H #define EFX_MCDI_H
/** * enum efx_mcdi_state - MCDI request handling state * @MCDI_STATE_QUIESCENT: No pending MCDI requests. If the caller holds the * mcdi @iface_lock then they are able to move to %MCDI_STATE_RUNNING * @MCDI_STATE_RUNNING_SYNC: There is a synchronous MCDI request pending. * Only the thread that moved into this state is allowed to move out of it. * @MCDI_STATE_RUNNING_ASYNC: There is an asynchronous MCDI request pending. * @MCDI_STATE_PROXY_WAIT: An MCDI request has completed with a response that * indicates we must wait for a proxy try again message. * @MCDI_STATE_COMPLETED: An MCDI request has completed, but the owning thread * has not yet consumed the result. For all other threads, equivalent to * %MCDI_STATE_RUNNING.
*/ enum efx_mcdi_state {
MCDI_STATE_QUIESCENT,
MCDI_STATE_RUNNING_SYNC,
MCDI_STATE_RUNNING_ASYNC,
MCDI_STATE_PROXY_WAIT,
MCDI_STATE_COMPLETED,
};
/** * enum efx_mcdi_mode - MCDI transaction mode * @MCDI_MODE_POLL: poll for MCDI completion, until timeout * @MCDI_MODE_EVENTS: wait for an mcdi_event. On timeout, poll once * @MCDI_MODE_FAIL: we think MCDI is dead, so fail-fast all calls
*/ enum efx_mcdi_mode {
MCDI_MODE_POLL,
MCDI_MODE_EVENTS,
MCDI_MODE_FAIL,
};
/** * struct efx_mcdi_iface - MCDI protocol context * @efx: The associated NIC. * @state: Request handling state. Waited for by @wq. * @mode: Poll for mcdi completion, or wait for an mcdi_event. * @wq: Wait queue for threads waiting for @state != %MCDI_STATE_RUNNING * @new_epoch: Indicates start of day or start of MC reboot recovery * @iface_lock: Serialises access to @seqno, @credits and response metadata * @seqno: The next sequence number to use for mcdi requests. * @credits: Number of spurious MCDI completion events allowed before we * trigger a fatal error * @resprc: Response error/success code (Linux numbering) * @resp_hdr_len: Response header length * @resp_data_len: Response data (SDU or error) length * @async_lock: Serialises access to @async_list while event processing is * enabled * @async_list: Queue of asynchronous requests * @async_timer: Timer for asynchronous request timeout * @logging_buffer: buffer that may be used to build MCDI tracing messages * @logging_enabled: whether to trace MCDI * @proxy_rx_handle: Most recently received proxy authorisation handle * @proxy_rx_status: Status of most recent proxy authorisation * @proxy_rx_wq: Wait queue for updates to proxy_rx_handle
*/ struct efx_mcdi_iface { struct efx_nic *efx; enum efx_mcdi_state state; enum efx_mcdi_mode mode;
wait_queue_head_t wq;
spinlock_t iface_lock; bool new_epoch; unsignedint credits; unsignedint seqno; int resprc; int resprc_raw;
size_t resp_hdr_len;
size_t resp_data_len;
spinlock_t async_lock; struct list_head async_list; struct timer_list async_timer; #ifdef CONFIG_SFC_MCDI_LOGGING char *logging_buffer; bool logging_enabled; #endif unsignedint proxy_rx_handle; int proxy_rx_status;
wait_queue_head_t proxy_rx_wq;
};
/** * struct efx_mcdi_data - extra state for NICs that implement MCDI * @iface: Interface/protocol state * @hwmon: Hardware monitor state * @fn_flags: Flags for this function, as returned by %MC_CMD_DRV_ATTACH.
*/ struct efx_mcdi_data { struct efx_mcdi_iface iface; #ifdef CONFIG_SFC_MCDI_MON struct efx_mcdi_mon hwmon; #endif
u32 fn_flags;
};
/* We expect that 16- and 32-bit fields in MCDI requests and responses * are appropriately aligned, but 64-bit fields are only * 32-bit-aligned. Also, on Siena we must copy to the MC shared * memory strictly 32 bits at a time, so add any necessary padding.
*/ #define MCDI_TX_BUF_LEN(_len) DIV_ROUND_UP((_len), 4) #define _MCDI_DECLARE_BUF(_name, _len) \
efx_dword_t _name[DIV_ROUND_UP(_len, 4)] #define MCDI_DECLARE_BUF(_name, _len) \
_MCDI_DECLARE_BUF(_name, _len) = {{{0}}} #define MCDI_DECLARE_BUF_ERR(_name) \
MCDI_DECLARE_BUF(_name, 8) #define _MCDI_PTR(_buf, _offset) \
((u8 *)(_buf) + (_offset)) #define MCDI_PTR(_buf, _field) \
_MCDI_PTR(_buf, MC_CMD_ ## _field ## _OFST) /* Use MCDI_STRUCT_ functions to access members of MCDI structuredefs. * _buf should point to the start of the structure, typically obtained with * MCDI_DECLARE_STRUCT_PTR(structure) = _MCDI_DWORD(mcdi_buf, FIELD_WHICH_IS_STRUCT);
*/ #define MCDI_STRUCT_PTR(_buf, _field) \
_MCDI_PTR(_buf, _field ## _OFST) #define _MCDI_CHECK_ALIGN(_ofst, _align) \
((_ofst) + BUILD_BUG_ON_ZERO((_ofst) & (_align - 1))) #define _MCDI_DWORD(_buf, _field) \
((_buf) + (_MCDI_CHECK_ALIGN(MC_CMD_ ## _field ## _OFST, 4) >> 2)) #define _MCDI_STRUCT_DWORD(_buf, _field) \
((_buf) + (_MCDI_CHECK_ALIGN(_field ## _OFST, 4) >> 2))
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.