2013-12-21 14:13:11 +08:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* Intel Ethernet Controller XL710 Family Linux Virtual Function Driver
|
2014-04-05 15:46:11 +08:00
|
|
|
* Copyright(c) 2013 - 2014 Intel Corporation.
|
2013-12-21 14:13:11 +08:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
2014-04-05 15:46:11 +08:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2013-12-21 14:13:11 +08:00
|
|
|
* The full GNU General Public License is included in this distribution in
|
|
|
|
* the file called "COPYING".
|
|
|
|
*
|
|
|
|
* Contact Information:
|
|
|
|
* e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
|
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _I40E_ADMINQ_H_
|
|
|
|
#define _I40E_ADMINQ_H_
|
|
|
|
|
|
|
|
#include "i40e_osdep.h"
|
2014-11-13 16:23:22 +08:00
|
|
|
#include "i40e_status.h"
|
2013-12-21 14:13:11 +08:00
|
|
|
#include "i40e_adminq_cmd.h"
|
|
|
|
|
|
|
|
#define I40E_ADMINQ_DESC(R, i) \
|
|
|
|
(&(((struct i40e_aq_desc *)((R).desc_buf.va))[i]))
|
|
|
|
|
|
|
|
#define I40E_ADMINQ_DESC_ALIGNMENT 4096
|
|
|
|
|
|
|
|
struct i40e_adminq_ring {
|
|
|
|
struct i40e_virt_mem dma_head; /* space for dma structures */
|
|
|
|
struct i40e_dma_mem desc_buf; /* descriptor ring memory */
|
|
|
|
struct i40e_virt_mem cmd_buf; /* command buffer memory */
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct i40e_dma_mem *asq_bi;
|
|
|
|
struct i40e_dma_mem *arq_bi;
|
|
|
|
} 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-05 04:41:17 +08:00
|
|
|
u32 bah;
|
|
|
|
u32 bal;
|
2013-12-21 14:13:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ASQ transaction details */
|
|
|
|
struct i40e_asq_cmd_details {
|
|
|
|
void *callback; /* cast from type I40E_ADMINQ_CALLBACK */
|
|
|
|
u64 cookie;
|
|
|
|
u16 flags_ena;
|
|
|
|
u16 flags_dis;
|
|
|
|
bool async;
|
|
|
|
bool postpone;
|
2015-08-27 23:42:42 +08:00
|
|
|
struct i40e_aq_desc *wb_desc;
|
2013-12-21 14:13:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define I40E_ADMINQ_DETAILS(R, i) \
|
|
|
|
(&(((struct i40e_asq_cmd_details *)((R).cmd_buf.va))[i]))
|
|
|
|
|
|
|
|
/* ARQ event information */
|
|
|
|
struct i40e_arq_event_info {
|
|
|
|
struct i40e_aq_desc desc;
|
2014-11-12 04:02:19 +08:00
|
|
|
u16 msg_len;
|
|
|
|
u16 buf_len;
|
2013-12-21 14:13:11 +08:00
|
|
|
u8 *msg_buf;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Admin Queue information */
|
|
|
|
struct i40e_adminq_info {
|
|
|
|
struct i40e_adminq_ring arq; /* receive queue */
|
|
|
|
struct i40e_adminq_ring asq; /* send queue */
|
2014-06-05 04:41:43 +08:00
|
|
|
u32 asq_cmd_timeout; /* send queue cmd write back timeout*/
|
2013-12-21 14:13:11 +08: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 14:58:41 +08:00
|
|
|
u32 fw_build; /* firmware build number */
|
2013-12-21 14:13:11 +08: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 */
|
|
|
|
enum i40e_admin_queue_err asq_last_status;
|
|
|
|
enum i40e_admin_queue_err arq_last_status;
|
|
|
|
};
|
|
|
|
|
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 15:46:09 +08:00
|
|
|
/**
|
|
|
|
* i40e_aq_rc_to_posix - convert errors to user-land codes
|
2015-07-24 04:54:30 +08: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 15:46:09 +08:00
|
|
|
**/
|
2015-07-24 04:54:30 +08: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 15:46:09 +08:00
|
|
|
{
|
|
|
|
int aq_to_posix[] = {
|
|
|
|
0, /* I40E_AQ_RC_OK */
|
|
|
|
-EPERM, /* I40E_AQ_RC_EPERM */
|
|
|
|
-ENOENT, /* I40E_AQ_RC_ENOENT */
|
|
|
|
-ESRCH, /* I40E_AQ_RC_ESRCH */
|
|
|
|
-EINTR, /* I40E_AQ_RC_EINTR */
|
|
|
|
-EIO, /* I40E_AQ_RC_EIO */
|
|
|
|
-ENXIO, /* I40E_AQ_RC_ENXIO */
|
|
|
|
-E2BIG, /* I40E_AQ_RC_E2BIG */
|
|
|
|
-EAGAIN, /* I40E_AQ_RC_EAGAIN */
|
|
|
|
-ENOMEM, /* I40E_AQ_RC_ENOMEM */
|
|
|
|
-EACCES, /* I40E_AQ_RC_EACCES */
|
|
|
|
-EFAULT, /* I40E_AQ_RC_EFAULT */
|
|
|
|
-EBUSY, /* I40E_AQ_RC_EBUSY */
|
|
|
|
-EEXIST, /* I40E_AQ_RC_EEXIST */
|
|
|
|
-EINVAL, /* I40E_AQ_RC_EINVAL */
|
|
|
|
-ENOTTY, /* I40E_AQ_RC_ENOTTY */
|
|
|
|
-ENOSPC, /* I40E_AQ_RC_ENOSPC */
|
|
|
|
-ENOSYS, /* I40E_AQ_RC_ENOSYS */
|
|
|
|
-ERANGE, /* I40E_AQ_RC_ERANGE */
|
|
|
|
-EPIPE, /* I40E_AQ_RC_EFLUSHED */
|
|
|
|
-ESPIPE, /* I40E_AQ_RC_BAD_ADDR */
|
|
|
|
-EROFS, /* I40E_AQ_RC_EMODE */
|
|
|
|
-EFBIG, /* I40E_AQ_RC_EFBIG */
|
|
|
|
};
|
|
|
|
|
2014-11-13 16:23:22 +08:00
|
|
|
/* aq_rc is invalid if AQ timed out */
|
|
|
|
if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
|
|
|
|
return -EAGAIN;
|
|
|
|
|
2015-08-27 03:14:11 +08:00
|
|
|
if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
|
2014-11-13 16:23:16 +08:00
|
|
|
return -ERANGE;
|
2015-07-24 04:54:30 +08: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 15:46:09 +08:00
|
|
|
return aq_to_posix[aq_rc];
|
|
|
|
}
|
|
|
|
|
2013-12-21 14:13:11 +08:00
|
|
|
/* general information */
|
|
|
|
#define I40E_AQ_LARGE_BUF 512
|
i40e: reduce wait time for adminq command completion
When sending an adminq command, we wait for the command to complete in
a loop. This loop waits for an entire millisecond, when in practice the
adminq command is processed often much faster.
Change the loop to use i40e_usec_delay instead, and wait for 50 usecs
each time instead. This appears to be about the minimum time required,
based on some manual observation and testing.
The primary benefit of this change is reducing latency of various
operations in the PF driver, especially when related to having a large
number of VFs enabled.
For example, on Linux, when instantiating 128 VFs, the time to finish
the operation dropped from about 9 seconds down to under 6 seconds.
Additionally, the time it takes to finish a PF reset with 128 VFs
dropped from 5.1 seconds down to 0.7 seconds.
As the examples above show, a significant portion of the delay is wasted
waiting for admiqn operations which have already finished.
This patch shouldn't cause impact to functionality, as we still check
and keep waiting until the command does get processed. The only expected
change is an increase in CPU utilization as we now check for completion
far more times. However, in practice the commands appear to generally be
complete within the first delay window anyways.
Change-ID: If8af8388e100da0a14eaf9e1af3afadf73a958cf
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
2017-04-13 16:45:49 +08:00
|
|
|
#define I40E_ASQ_CMD_TIMEOUT 250000 /* usecs */
|
2013-12-21 14:13:11 +08:00
|
|
|
|
|
|
|
void i40evf_fill_default_direct_cmd_desc(struct i40e_aq_desc *desc,
|
|
|
|
u16 opcode);
|
|
|
|
|
|
|
|
#endif /* _I40E_ADMINQ_H_ */
|