2018-03-22 10:08:48 -07:00
/* SPDX-License-Identifier: GPL-2.0 */
2018-04-26 08:08:09 -07:00
/* Copyright(c) 2013 - 2018 Intel Corporation. */
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:55 -07:00
# ifndef _IAVF_ADMINQ_H_
# define _IAVF_ADMINQ_H_
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:56 -07:00
# include "iavf_osdep.h"
# include "iavf_status.h"
2019-04-17 15:17:29 -07:00
# include "iavf_adminq_cmd.h"
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:51 -07:00
# define IAVF_ADMINQ_DESC(R, i) \
2019-04-17 15:17:32 -07:00
( & ( ( ( struct iavf_aq_desc * ) ( ( R ) . desc_buf . va ) ) [ i ] ) )
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:51 -07:00
# define IAVF_ADMINQ_DESC_ALIGNMENT 4096
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:55 -07:00
struct iavf_adminq_ring {
struct iavf_virt_mem dma_head ; /* space for dma structures */
struct iavf_dma_mem desc_buf ; /* descriptor ring memory */
struct iavf_virt_mem cmd_buf ; /* command buffer memory */
2013-12-21 06:13:11 +00:00
union {
2018-09-14 17:37:55 -07:00
struct iavf_dma_mem * asq_bi ;
struct iavf_dma_mem * arq_bi ;
2013-12-21 06:13:11 +00:00
} r ;
u16 count ; /* Number of descriptors */
u16 rx_buf_len ; /* Admin Receive Queue buffer length */
/* used for interrupt processing */
u16 next_to_use ;
u16 next_to_clean ;
/* used for queue tracking */
u32 head ;
u32 tail ;
u32 len ;
2014-06-04 20:41:17 +00:00
u32 bah ;
u32 bal ;
2013-12-21 06:13:11 +00:00
} ;
/* ASQ transaction details */
2019-04-17 15:17:32 -07:00
struct iavf_asq_cmd_details {
void * callback ; /* cast from type IAVF_ADMINQ_CALLBACK */
2013-12-21 06:13:11 +00:00
u64 cookie ;
u16 flags_ena ;
u16 flags_dis ;
bool async ;
bool postpone ;
2019-04-17 15:17:32 -07:00
struct iavf_aq_desc * wb_desc ;
2013-12-21 06:13:11 +00:00
} ;
2019-04-17 15:17:32 -07:00
# define IAVF_ADMINQ_DETAILS(R, i) \
( & ( ( ( struct iavf_asq_cmd_details * ) ( ( R ) . cmd_buf . va ) ) [ i ] ) )
2013-12-21 06:13:11 +00:00
/* ARQ event information */
2019-04-17 15:17:32 -07:00
struct iavf_arq_event_info {
struct iavf_aq_desc desc ;
2014-11-11 20:02:19 +00:00
u16 msg_len ;
u16 buf_len ;
2013-12-21 06:13:11 +00:00
u8 * msg_buf ;
} ;
/* Admin Queue information */
2018-09-14 17:37:55 -07:00
struct iavf_adminq_info {
struct iavf_adminq_ring arq ; /* receive queue */
struct iavf_adminq_ring asq ; /* send queue */
2014-06-04 20:41:43 +00:00
u32 asq_cmd_timeout ; /* send queue cmd write back timeout*/
2013-12-21 06:13:11 +00:00
u16 num_arq_entries ; /* receive queue depth */
u16 num_asq_entries ; /* send queue depth */
u16 arq_buf_size ; /* receive queue buffer size */
u16 asq_buf_size ; /* send queue buffer size */
u16 fw_maj_ver ; /* firmware major version */
u16 fw_min_ver ; /* firmware minor version */
2015-02-24 06:58:41 +00:00
u32 fw_build ; /* firmware build number */
2013-12-21 06:13:11 +00:00
u16 api_maj_ver ; /* api major version */
u16 api_min_ver ; /* api minor version */
struct mutex asq_mutex ; /* Send queue lock */
struct mutex arq_mutex ; /* Receive queue lock */
/* last status values on send and receive queues */
2019-04-17 15:17:32 -07:00
enum iavf_admin_queue_err asq_last_status ;
enum iavf_admin_queue_err arq_last_status ;
2013-12-21 06:13:11 +00:00
} ;
i40e/i40evf: Add nvmupdate support
This implements a state machine intended to support the userland tool for
updating the device eeprom. The state machine implements one-shot reads,
writes, multi-step write sessions, and checksum requests. If we're in the middle
of a multi-step write session, no one should fire off other writes, however, one
shot reads are valid. The userland tool is expected to keep track of its session
status, arrange the placement and ordering of the writes, and deal with the
checksum requirement.
This patch also adds nvmupdate support to ethtool callbacks.
The get_eeprom() and set_eeprom() services in ethtool are used here to
facilitate the userland NVMUpdate tool. The 'magic' value in the get and
set commands is used to pass additional control information for managing
the read and write steps.
The read operation works both as normally expected in the standard ethtool
method, as well as with the extra NVM controls. The write operation
works only for the expanded NVM functions - the normal ethtool method is
not allowed because of the NVM semaphore management needed for multipart
writes, as well as the checksum requirement.
Change-ID: I1d84a170153a9f437906744e2e350fd68fe7563d
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2014-07-09 07:46:09 +00:00
/**
* i40e_aq_rc_to_posix - convert errors to user - land codes
2015-07-23 16:54:30 -04:00
* aq_ret : AdminQ handler error code can override aq_rc
* aq_rc : AdminQ firmware error code to convert
i40e/i40evf: Add nvmupdate support
This implements a state machine intended to support the userland tool for
updating the device eeprom. The state machine implements one-shot reads,
writes, multi-step write sessions, and checksum requests. If we're in the middle
of a multi-step write session, no one should fire off other writes, however, one
shot reads are valid. The userland tool is expected to keep track of its session
status, arrange the placement and ordering of the writes, and deal with the
checksum requirement.
This patch also adds nvmupdate support to ethtool callbacks.
The get_eeprom() and set_eeprom() services in ethtool are used here to
facilitate the userland NVMUpdate tool. The 'magic' value in the get and
set commands is used to pass additional control information for managing
the read and write steps.
The read operation works both as normally expected in the standard ethtool
method, as well as with the extra NVM controls. The write operation
works only for the expanded NVM functions - the normal ethtool method is
not allowed because of the NVM semaphore management needed for multipart
writes, as well as the checksum requirement.
Change-ID: I1d84a170153a9f437906744e2e350fd68fe7563d
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2014-07-09 07:46:09 +00:00
* */
2015-07-23 16:54:30 -04:00
static inline int i40e_aq_rc_to_posix ( int aq_ret , int aq_rc )
i40e/i40evf: Add nvmupdate support
This implements a state machine intended to support the userland tool for
updating the device eeprom. The state machine implements one-shot reads,
writes, multi-step write sessions, and checksum requests. If we're in the middle
of a multi-step write session, no one should fire off other writes, however, one
shot reads are valid. The userland tool is expected to keep track of its session
status, arrange the placement and ordering of the writes, and deal with the
checksum requirement.
This patch also adds nvmupdate support to ethtool callbacks.
The get_eeprom() and set_eeprom() services in ethtool are used here to
facilitate the userland NVMUpdate tool. The 'magic' value in the get and
set commands is used to pass additional control information for managing
the read and write steps.
The read operation works both as normally expected in the standard ethtool
method, as well as with the extra NVM controls. The write operation
works only for the expanded NVM functions - the normal ethtool method is
not allowed because of the NVM semaphore management needed for multipart
writes, as well as the checksum requirement.
Change-ID: I1d84a170153a9f437906744e2e350fd68fe7563d
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2014-07-09 07:46:09 +00:00
{
int aq_to_posix [ ] = {
2019-04-17 15:17:32 -07:00
0 , /* IAVF_AQ_RC_OK */
- EPERM , /* IAVF_AQ_RC_EPERM */
- ENOENT , /* IAVF_AQ_RC_ENOENT */
- ESRCH , /* IAVF_AQ_RC_ESRCH */
- EINTR , /* IAVF_AQ_RC_EINTR */
- EIO , /* IAVF_AQ_RC_EIO */
- ENXIO , /* IAVF_AQ_RC_ENXIO */
- E2BIG , /* IAVF_AQ_RC_E2BIG */
- EAGAIN , /* IAVF_AQ_RC_EAGAIN */
- ENOMEM , /* IAVF_AQ_RC_ENOMEM */
- EACCES , /* IAVF_AQ_RC_EACCES */
- EFAULT , /* IAVF_AQ_RC_EFAULT */
- EBUSY , /* IAVF_AQ_RC_EBUSY */
- EEXIST , /* IAVF_AQ_RC_EEXIST */
- EINVAL , /* IAVF_AQ_RC_EINVAL */
- ENOTTY , /* IAVF_AQ_RC_ENOTTY */
- ENOSPC , /* IAVF_AQ_RC_ENOSPC */
- ENOSYS , /* IAVF_AQ_RC_ENOSYS */
- ERANGE , /* IAVF_AQ_RC_ERANGE */
- EPIPE , /* IAVF_AQ_RC_EFLUSHED */
- ESPIPE , /* IAVF_AQ_RC_BAD_ADDR */
- EROFS , /* IAVF_AQ_RC_EMODE */
- EFBIG , /* IAVF_AQ_RC_EFBIG */
i40e/i40evf: Add nvmupdate support
This implements a state machine intended to support the userland tool for
updating the device eeprom. The state machine implements one-shot reads,
writes, multi-step write sessions, and checksum requests. If we're in the middle
of a multi-step write session, no one should fire off other writes, however, one
shot reads are valid. The userland tool is expected to keep track of its session
status, arrange the placement and ordering of the writes, and deal with the
checksum requirement.
This patch also adds nvmupdate support to ethtool callbacks.
The get_eeprom() and set_eeprom() services in ethtool are used here to
facilitate the userland NVMUpdate tool. The 'magic' value in the get and
set commands is used to pass additional control information for managing
the read and write steps.
The read operation works both as normally expected in the standard ethtool
method, as well as with the extra NVM controls. The write operation
works only for the expanded NVM functions - the normal ethtool method is
not allowed because of the NVM semaphore management needed for multipart
writes, as well as the checksum requirement.
Change-ID: I1d84a170153a9f437906744e2e350fd68fe7563d
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2014-07-09 07:46:09 +00:00
} ;
2014-11-13 08:23:22 +00:00
/* aq_rc is invalid if AQ timed out */
if ( aq_ret = = I40E_ERR_ADMIN_QUEUE_TIMEOUT )
return - EAGAIN ;
2015-08-26 15:14:11 -04:00
if ( ! ( ( u32 ) aq_rc < ( sizeof ( aq_to_posix ) / sizeof ( ( aq_to_posix ) [ 0 ] ) ) ) )
2014-11-13 08:23:16 +00:00
return - ERANGE ;
2015-07-23 16:54:30 -04:00
i40e/i40evf: Add nvmupdate support
This implements a state machine intended to support the userland tool for
updating the device eeprom. The state machine implements one-shot reads,
writes, multi-step write sessions, and checksum requests. If we're in the middle
of a multi-step write session, no one should fire off other writes, however, one
shot reads are valid. The userland tool is expected to keep track of its session
status, arrange the placement and ordering of the writes, and deal with the
checksum requirement.
This patch also adds nvmupdate support to ethtool callbacks.
The get_eeprom() and set_eeprom() services in ethtool are used here to
facilitate the userland NVMUpdate tool. The 'magic' value in the get and
set commands is used to pass additional control information for managing
the read and write steps.
The read operation works both as normally expected in the standard ethtool
method, as well as with the extra NVM controls. The write operation
works only for the expanded NVM functions - the normal ethtool method is
not allowed because of the NVM semaphore management needed for multipart
writes, as well as the checksum requirement.
Change-ID: I1d84a170153a9f437906744e2e350fd68fe7563d
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Jim Young <jamesx.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2014-07-09 07:46:09 +00:00
return aq_to_posix [ aq_rc ] ;
}
2013-12-21 06:13:11 +00:00
/* general information */
2019-04-17 15:17:32 -07:00
# define IAVF_AQ_LARGE_BUF 512
# define IAVF_ASQ_CMD_TIMEOUT 250000 /* usecs */
2013-12-21 06:13:11 +00:00
2019-04-17 15:17:32 -07:00
void iavf_fill_default_direct_cmd_desc ( struct iavf_aq_desc * desc , u16 opcode ) ;
2013-12-21 06:13:11 +00:00
2018-09-14 17:37:55 -07:00
# endif /* _IAVF_ADMINQ_H_ */