2018-01-08 13:35:34 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2016-11-29 16:18:42 +00:00
|
|
|
*
|
2018-01-08 13:35:34 +00:00
|
|
|
* Copyright (c) 2012-2018 Solarflare Communications Inc.
|
|
|
|
* All rights reserved.
|
2016-11-29 16:18:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "efx.h"
|
|
|
|
#include "efx_impl.h"
|
|
|
|
|
|
|
|
|
2018-02-20 07:33:34 +00:00
|
|
|
#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
static __checkReturn efx_rc_t
|
|
|
|
efx_mcdi_init_rxq(
|
|
|
|
__in efx_nic_t *enp,
|
2017-11-16 08:04:20 +00:00
|
|
|
__in uint32_t ndescs,
|
2016-11-29 16:18:42 +00:00
|
|
|
__in uint32_t target_evq,
|
|
|
|
__in uint32_t label,
|
|
|
|
__in uint32_t instance,
|
|
|
|
__in efsys_mem_t *esmp,
|
|
|
|
__in boolean_t disable_scatter,
|
2017-12-24 10:46:37 +00:00
|
|
|
__in boolean_t want_inner_classes,
|
2016-11-29 16:18:42 +00:00
|
|
|
__in uint32_t ps_bufsize)
|
|
|
|
{
|
2017-11-16 08:04:17 +00:00
|
|
|
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
|
2016-11-29 16:18:42 +00:00
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_INIT_RXQ_EXT_IN_LEN,
|
|
|
|
MC_CMD_INIT_RXQ_EXT_OUT_LEN)];
|
2017-11-16 08:04:20 +00:00
|
|
|
int npages = EFX_RXQ_NBUFS(ndescs);
|
2016-11-29 16:18:42 +00:00
|
|
|
int i;
|
|
|
|
efx_qword_t *dma_addr;
|
|
|
|
uint64_t addr;
|
|
|
|
efx_rc_t rc;
|
|
|
|
uint32_t dma_mode;
|
2017-11-16 08:04:17 +00:00
|
|
|
boolean_t want_outer_classes;
|
2016-11-29 16:18:42 +00:00
|
|
|
|
2017-11-16 08:04:20 +00:00
|
|
|
EFSYS_ASSERT3U(ndescs, <=, EFX_RXQ_MAXNDESCS);
|
2016-11-29 16:18:42 +00:00
|
|
|
|
2018-02-20 07:33:52 +00:00
|
|
|
if ((esmp == NULL) || (EFSYS_MEM_SIZE(esmp) < EFX_RXQ_SIZE(ndescs))) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
if (ps_bufsize > 0)
|
|
|
|
dma_mode = MC_CMD_INIT_RXQ_EXT_IN_PACKED_STREAM;
|
|
|
|
else
|
|
|
|
dma_mode = MC_CMD_INIT_RXQ_EXT_IN_SINGLE_PACKET;
|
|
|
|
|
2017-12-24 10:46:37 +00:00
|
|
|
if (encp->enc_tunnel_encapsulations_supported != 0 &&
|
|
|
|
!want_inner_classes) {
|
2017-11-16 08:04:17 +00:00
|
|
|
/*
|
|
|
|
* WANT_OUTER_CLASSES can only be specified on hardware which
|
|
|
|
* supports tunnel encapsulation offloads, even though it is
|
|
|
|
* effectively the behaviour the hardware gives.
|
|
|
|
*
|
|
|
|
* Also, on hardware which does support such offloads, older
|
|
|
|
* firmware rejects the flag if the offloads are not supported
|
|
|
|
* by the current firmware variant, which means this may fail if
|
|
|
|
* the capabilities are not updated when the firmware variant
|
|
|
|
* changes. This is not an issue on newer firmware, as it was
|
|
|
|
* changed in bug 69842 (v6.4.2.1007) to permit this flag to be
|
|
|
|
* specified on all firmware variants.
|
|
|
|
*/
|
|
|
|
want_outer_classes = B_TRUE;
|
|
|
|
} else {
|
|
|
|
want_outer_classes = B_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_INIT_RXQ;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_INIT_RXQ_EXT_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_INIT_RXQ_EXT_OUT_LEN;
|
|
|
|
|
2017-11-16 08:04:20 +00:00
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_SIZE, ndescs);
|
2016-11-29 16:18:42 +00:00
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_TARGET_EVQ, target_evq);
|
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_LABEL, label);
|
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_INSTANCE, instance);
|
2017-11-16 08:04:17 +00:00
|
|
|
MCDI_IN_POPULATE_DWORD_9(req, INIT_RXQ_EXT_IN_FLAGS,
|
2016-11-29 16:18:42 +00:00
|
|
|
INIT_RXQ_EXT_IN_FLAG_BUFF_MODE, 0,
|
|
|
|
INIT_RXQ_EXT_IN_FLAG_HDR_SPLIT, 0,
|
|
|
|
INIT_RXQ_EXT_IN_FLAG_TIMESTAMP, 0,
|
|
|
|
INIT_RXQ_EXT_IN_CRC_MODE, 0,
|
|
|
|
INIT_RXQ_EXT_IN_FLAG_PREFIX, 1,
|
|
|
|
INIT_RXQ_EXT_IN_FLAG_DISABLE_SCATTER, disable_scatter,
|
|
|
|
INIT_RXQ_EXT_IN_DMA_MODE,
|
|
|
|
dma_mode,
|
2017-11-16 08:04:17 +00:00
|
|
|
INIT_RXQ_EXT_IN_PACKED_STREAM_BUFF_SIZE, ps_bufsize,
|
|
|
|
INIT_RXQ_EXT_IN_FLAG_WANT_OUTER_CLASSES, want_outer_classes);
|
2016-11-29 16:18:42 +00:00
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_OWNER_ID, 0);
|
|
|
|
MCDI_IN_SET_DWORD(req, INIT_RXQ_EXT_IN_PORT_ID, EVB_PORT_ID_ASSIGNED);
|
|
|
|
|
|
|
|
dma_addr = MCDI_IN2(req, efx_qword_t, INIT_RXQ_IN_DMA_ADDR);
|
|
|
|
addr = EFSYS_MEM_ADDR(esmp);
|
|
|
|
|
|
|
|
for (i = 0; i < npages; i++) {
|
|
|
|
EFX_POPULATE_QWORD_2(*dma_addr,
|
|
|
|
EFX_DWORD_1, (uint32_t)(addr >> 32),
|
|
|
|
EFX_DWORD_0, (uint32_t)(addr & 0xffffffff));
|
|
|
|
|
|
|
|
dma_addr++;
|
|
|
|
addr += EFX_BUF_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
efx_mcdi_execute(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
2018-02-20 07:33:52 +00:00
|
|
|
goto fail2;
|
2016-11-29 16:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
2018-02-20 07:33:52 +00:00
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
2016-11-29 16:18:42 +00:00
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __checkReturn efx_rc_t
|
|
|
|
efx_mcdi_fini_rxq(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t instance)
|
|
|
|
{
|
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_FINI_RXQ_IN_LEN,
|
|
|
|
MC_CMD_FINI_RXQ_OUT_LEN)];
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_FINI_RXQ;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_FINI_RXQ_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_FINI_RXQ_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, FINI_RXQ_IN_INSTANCE, instance);
|
|
|
|
|
|
|
|
efx_mcdi_execute_quiet(enp, &req);
|
|
|
|
|
2017-05-27 07:55:31 +00:00
|
|
|
if (req.emr_rc != 0) {
|
2016-11-29 16:18:42 +00:00
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail1:
|
2017-05-27 07:55:31 +00:00
|
|
|
/*
|
|
|
|
* EALREADY is not an error, but indicates that the MC has rebooted and
|
|
|
|
* that the RXQ has already been destroyed.
|
|
|
|
*/
|
|
|
|
if (rc != EALREADY)
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:53 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
static __checkReturn efx_rc_t
|
|
|
|
efx_mcdi_rss_context_alloc(
|
|
|
|
__in efx_nic_t *enp,
|
2017-08-30 18:17:35 +00:00
|
|
|
__in efx_rx_scale_context_type_t type,
|
2016-11-29 16:18:53 +00:00
|
|
|
__in uint32_t num_queues,
|
|
|
|
__out uint32_t *rss_contextp)
|
|
|
|
{
|
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN,
|
|
|
|
MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN)];
|
|
|
|
uint32_t rss_context;
|
|
|
|
uint32_t context_type;
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
if (num_queues > EFX_MAXRSS) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2017-08-30 18:17:35 +00:00
|
|
|
switch (type) {
|
2016-11-29 16:18:53 +00:00
|
|
|
case EFX_RX_SCALE_EXCLUSIVE:
|
|
|
|
context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_EXCLUSIVE;
|
|
|
|
break;
|
|
|
|
case EFX_RX_SCALE_SHARED:
|
|
|
|
context_type = MC_CMD_RSS_CONTEXT_ALLOC_IN_TYPE_SHARED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_RSS_CONTEXT_ALLOC;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_RSS_CONTEXT_ALLOC_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_UPSTREAM_PORT_ID,
|
|
|
|
EVB_PORT_ID_ASSIGNED);
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_TYPE, context_type);
|
2017-11-16 08:04:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For exclusive contexts, NUM_QUEUES is only used to validate
|
|
|
|
* indirection table offsets.
|
|
|
|
* For shared contexts, the provided context will spread traffic over
|
|
|
|
* NUM_QUEUES many queues.
|
|
|
|
*/
|
2016-11-29 16:18:53 +00:00
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_ALLOC_IN_NUM_QUEUES, num_queues);
|
|
|
|
|
|
|
|
efx_mcdi_execute(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.emr_out_length_used < MC_CMD_RSS_CONTEXT_ALLOC_OUT_LEN) {
|
|
|
|
rc = EMSGSIZE;
|
|
|
|
goto fail4;
|
|
|
|
}
|
|
|
|
|
|
|
|
rss_context = MCDI_OUT_DWORD(req, RSS_CONTEXT_ALLOC_OUT_RSS_CONTEXT_ID);
|
|
|
|
if (rss_context == EF10_RSS_CONTEXT_INVALID) {
|
|
|
|
rc = ENOENT;
|
|
|
|
goto fail5;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rss_contextp = rss_context;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail5:
|
|
|
|
EFSYS_PROBE(fail5);
|
|
|
|
fail4:
|
|
|
|
EFSYS_PROBE(fail4);
|
|
|
|
fail3:
|
|
|
|
EFSYS_PROBE(fail3);
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
static efx_rc_t
|
|
|
|
efx_mcdi_rss_context_free(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t rss_context)
|
|
|
|
{
|
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_FREE_IN_LEN,
|
|
|
|
MC_CMD_RSS_CONTEXT_FREE_OUT_LEN)];
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
if (rss_context == EF10_RSS_CONTEXT_INVALID) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_RSS_CONTEXT_FREE;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_RSS_CONTEXT_FREE_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_RSS_CONTEXT_FREE_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_FREE_IN_RSS_CONTEXT_ID, rss_context);
|
|
|
|
|
|
|
|
efx_mcdi_execute_quiet(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
static efx_rc_t
|
|
|
|
efx_mcdi_rss_context_set_flags(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t rss_context,
|
|
|
|
__in efx_rx_hash_type_t type)
|
|
|
|
{
|
2018-04-25 17:51:39 +00:00
|
|
|
efx_nic_cfg_t *encp = &enp->en_nic_cfg;
|
2018-04-25 17:51:38 +00:00
|
|
|
efx_rx_hash_type_t type_ipv4;
|
|
|
|
efx_rx_hash_type_t type_ipv4_tcp;
|
|
|
|
efx_rx_hash_type_t type_ipv6;
|
|
|
|
efx_rx_hash_type_t type_ipv6_tcp;
|
2018-04-25 17:51:39 +00:00
|
|
|
efx_rx_hash_type_t modes;
|
2016-11-29 16:18:53 +00:00
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN,
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN)];
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
2018-04-25 17:51:38 +00:00
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV4_TCP_LBN ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV4_RSS_MODE_LBN);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV4_TCP_WIDTH ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV4_RSS_MODE_WIDTH);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV4_LBN ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV4_RSS_MODE_LBN);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV4_WIDTH ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV4_RSS_MODE_WIDTH);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV6_TCP_LBN ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV6_RSS_MODE_LBN);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV6_TCP_WIDTH ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV6_RSS_MODE_WIDTH);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV6_LBN ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV6_RSS_MODE_LBN);
|
|
|
|
EFX_STATIC_ASSERT(EFX_RX_CLASS_IPV6_WIDTH ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV6_RSS_MODE_WIDTH);
|
|
|
|
|
2016-11-29 16:18:53 +00:00
|
|
|
if (rss_context == EF10_RSS_CONTEXT_INVALID) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_FLAGS;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_FLAGS_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_FLAGS_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_FLAGS_IN_RSS_CONTEXT_ID,
|
|
|
|
rss_context);
|
|
|
|
|
2018-04-25 17:51:39 +00:00
|
|
|
type_ipv4 = EFX_RX_HASH(IPV4, 2TUPLE) | EFX_RX_HASH(IPV4_TCP, 2TUPLE) |
|
|
|
|
EFX_RX_HASH(IPV4_UDP, 2TUPLE);
|
2018-04-25 17:51:38 +00:00
|
|
|
type_ipv4_tcp = EFX_RX_HASH(IPV4_TCP, 4TUPLE);
|
2018-04-25 17:51:39 +00:00
|
|
|
type_ipv6 = EFX_RX_HASH(IPV6, 2TUPLE) | EFX_RX_HASH(IPV6_TCP, 2TUPLE) |
|
|
|
|
EFX_RX_HASH(IPV6_UDP, 2TUPLE);
|
2018-04-25 17:51:38 +00:00
|
|
|
type_ipv6_tcp = EFX_RX_HASH(IPV6_TCP, 4TUPLE);
|
|
|
|
|
2018-04-25 17:51:39 +00:00
|
|
|
/*
|
|
|
|
* Create a copy of the original hash type.
|
|
|
|
* The copy will be used to fill in RSS_MODE bits and
|
|
|
|
* may be cleared beforehand. The original variable
|
|
|
|
* and, thus, EN bits will remain unaffected.
|
|
|
|
*/
|
|
|
|
modes = type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the firmware lacks support for additional modes, RSS_MODE
|
|
|
|
* fields must contain zeros, otherwise the operation will fail.
|
|
|
|
*/
|
|
|
|
if (encp->enc_rx_scale_additional_modes_supported == B_FALSE)
|
|
|
|
modes = 0;
|
|
|
|
|
|
|
|
#define EXTRACT_RSS_MODE(_type, _class) \
|
|
|
|
(EFX_EXTRACT_NATIVE(_type, 0, 31, \
|
|
|
|
EFX_LOW_BIT(EFX_RX_CLASS_##_class), \
|
|
|
|
EFX_HIGH_BIT(EFX_RX_CLASS_##_class)) & \
|
|
|
|
EFX_MASK32(EFX_RX_CLASS_##_class))
|
|
|
|
|
|
|
|
MCDI_IN_POPULATE_DWORD_10(req, RSS_CONTEXT_SET_FLAGS_IN_FLAGS,
|
2016-11-29 16:18:53 +00:00
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV4_EN,
|
2018-04-25 17:51:38 +00:00
|
|
|
((type & type_ipv4) == type_ipv4) ? 1 : 0,
|
2016-11-29 16:18:53 +00:00
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV4_EN,
|
2018-04-25 17:51:38 +00:00
|
|
|
((type & type_ipv4_tcp) == type_ipv4_tcp) ? 1 : 0,
|
2016-11-29 16:18:53 +00:00
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_IPV6_EN,
|
2018-04-25 17:51:38 +00:00
|
|
|
((type & type_ipv6) == type_ipv6) ? 1 : 0,
|
2016-11-29 16:18:53 +00:00
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TOEPLITZ_TCPV6_EN,
|
2018-04-25 17:51:39 +00:00
|
|
|
((type & type_ipv6_tcp) == type_ipv6_tcp) ? 1 : 0,
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV4_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV4_TCP),
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_UDP_IPV4_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV4_UDP),
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV4_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV4),
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_TCP_IPV6_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV6_TCP),
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_UDP_IPV6_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV6_UDP),
|
|
|
|
RSS_CONTEXT_SET_FLAGS_IN_OTHER_IPV6_RSS_MODE,
|
|
|
|
EXTRACT_RSS_MODE(modes, IPV6));
|
|
|
|
|
|
|
|
#undef EXTRACT_RSS_MODE
|
2016-11-29 16:18:53 +00:00
|
|
|
|
|
|
|
efx_mcdi_execute(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
static efx_rc_t
|
|
|
|
efx_mcdi_rss_context_set_key(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t rss_context,
|
|
|
|
__in_ecount(n) uint8_t *key,
|
|
|
|
__in size_t n)
|
|
|
|
{
|
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN,
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN)];
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
if (rss_context == EF10_RSS_CONTEXT_INVALID) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_KEY;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_KEY_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_KEY_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_KEY_IN_RSS_CONTEXT_ID,
|
|
|
|
rss_context);
|
|
|
|
|
|
|
|
EFSYS_ASSERT3U(n, ==, MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN);
|
|
|
|
if (n != MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(MCDI_IN2(req, uint8_t, RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY),
|
|
|
|
key, n);
|
|
|
|
|
|
|
|
efx_mcdi_execute(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail3;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail3:
|
|
|
|
EFSYS_PROBE(fail3);
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
static efx_rc_t
|
|
|
|
efx_mcdi_rss_context_set_table(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t rss_context,
|
|
|
|
__in_ecount(n) unsigned int *table,
|
|
|
|
__in size_t n)
|
|
|
|
{
|
|
|
|
efx_mcdi_req_t req;
|
|
|
|
uint8_t payload[MAX(MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN,
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_TABLE_OUT_LEN)];
|
|
|
|
uint8_t *req_table;
|
|
|
|
int i, rc;
|
|
|
|
|
|
|
|
if (rss_context == EF10_RSS_CONTEXT_INVALID) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) memset(payload, 0, sizeof (payload));
|
|
|
|
req.emr_cmd = MC_CMD_RSS_CONTEXT_SET_TABLE;
|
|
|
|
req.emr_in_buf = payload;
|
|
|
|
req.emr_in_length = MC_CMD_RSS_CONTEXT_SET_TABLE_IN_LEN;
|
|
|
|
req.emr_out_buf = payload;
|
|
|
|
req.emr_out_length = MC_CMD_RSS_CONTEXT_SET_TABLE_OUT_LEN;
|
|
|
|
|
|
|
|
MCDI_IN_SET_DWORD(req, RSS_CONTEXT_SET_TABLE_IN_RSS_CONTEXT_ID,
|
|
|
|
rss_context);
|
|
|
|
|
|
|
|
req_table =
|
|
|
|
MCDI_IN2(req, uint8_t, RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE);
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
i < MC_CMD_RSS_CONTEXT_SET_TABLE_IN_INDIRECTION_TABLE_LEN;
|
|
|
|
i++) {
|
|
|
|
req_table[i] = (n > 0) ? (uint8_t)table[i % n] : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
efx_mcdi_execute(enp, &req);
|
|
|
|
|
|
|
|
if (req.emr_rc != 0) {
|
|
|
|
rc = req.emr_rc;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_init(
|
|
|
|
__in efx_nic_t *enp)
|
|
|
|
{
|
2016-11-29 16:18:53 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
|
|
|
|
if (efx_mcdi_rss_context_alloc(enp, EFX_RX_SCALE_EXCLUSIVE, EFX_MAXRSS,
|
|
|
|
&enp->en_rss_context) == 0) {
|
|
|
|
/*
|
|
|
|
* Allocated an exclusive RSS context, which allows both the
|
|
|
|
* indirection table and key to be modified.
|
|
|
|
*/
|
2017-08-30 18:17:35 +00:00
|
|
|
enp->en_rss_context_type = EFX_RX_SCALE_EXCLUSIVE;
|
2016-11-29 16:18:53 +00:00
|
|
|
enp->en_hash_support = EFX_RX_HASH_AVAILABLE;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Failed to allocate an exclusive RSS context. Continue
|
|
|
|
* operation without support for RSS. The pseudo-header in
|
|
|
|
* received packets will not contain a Toeplitz hash value.
|
|
|
|
*/
|
2017-08-30 18:17:35 +00:00
|
|
|
enp->en_rss_context_type = EFX_RX_SCALE_UNAVAILABLE;
|
2016-11-29 16:18:53 +00:00
|
|
|
enp->en_hash_support = EFX_RX_HASH_UNAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:52 +00:00
|
|
|
#if EFSYS_OPT_RX_SCATTER
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scatter_enable(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in unsigned int buf_size)
|
|
|
|
{
|
|
|
|
_NOTE(ARGUNUSED(enp, buf_size))
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCATTER */
|
|
|
|
|
2017-08-30 18:17:36 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scale_context_alloc(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in efx_rx_scale_context_type_t type,
|
|
|
|
__in uint32_t num_queues,
|
|
|
|
__out uint32_t *rss_contextp)
|
|
|
|
{
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
rc = efx_mcdi_rss_context_alloc(enp, type, num_queues, rss_contextp);
|
|
|
|
if (rc != 0)
|
|
|
|
goto fail1;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scale_context_free(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint32_t rss_context)
|
|
|
|
{
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
rc = efx_mcdi_rss_context_free(enp, rss_context);
|
|
|
|
if (rc != 0)
|
|
|
|
goto fail1;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
2016-11-29 16:18:53 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scale_mode_set(
|
|
|
|
__in efx_nic_t *enp,
|
2017-08-30 18:17:37 +00:00
|
|
|
__in uint32_t rss_context,
|
2016-11-29 16:18:53 +00:00
|
|
|
__in efx_rx_hash_alg_t alg,
|
|
|
|
__in efx_rx_hash_type_t type,
|
|
|
|
__in boolean_t insert)
|
|
|
|
{
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
EFSYS_ASSERT3U(alg, ==, EFX_RX_HASHALG_TOEPLITZ);
|
|
|
|
EFSYS_ASSERT3U(insert, ==, B_TRUE);
|
|
|
|
|
|
|
|
if ((alg != EFX_RX_HASHALG_TOEPLITZ) || (insert == B_FALSE)) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2017-08-30 18:17:37 +00:00
|
|
|
if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
|
|
|
|
if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
|
|
|
|
rc = ENOTSUP;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
rss_context = enp->en_rss_context;
|
2016-11-29 16:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc = efx_mcdi_rss_context_set_flags(enp,
|
2017-08-30 18:17:37 +00:00
|
|
|
rss_context, type)) != 0)
|
2016-11-29 16:18:53 +00:00
|
|
|
goto fail3;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail3:
|
|
|
|
EFSYS_PROBE(fail3);
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scale_key_set(
|
|
|
|
__in efx_nic_t *enp,
|
2017-08-30 18:17:37 +00:00
|
|
|
__in uint32_t rss_context,
|
2016-11-29 16:18:53 +00:00
|
|
|
__in_ecount(n) uint8_t *key,
|
|
|
|
__in size_t n)
|
|
|
|
{
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
2017-08-30 18:17:39 +00:00
|
|
|
EFX_STATIC_ASSERT(EFX_RSS_KEY_SIZE ==
|
|
|
|
MC_CMD_RSS_CONTEXT_SET_KEY_IN_TOEPLITZ_KEY_LEN);
|
|
|
|
|
2017-08-30 18:17:37 +00:00
|
|
|
if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
|
|
|
|
if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
|
|
|
|
rc = ENOTSUP;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
rss_context = enp->en_rss_context;
|
2016-11-29 16:18:53 +00:00
|
|
|
}
|
|
|
|
|
2017-08-30 18:17:37 +00:00
|
|
|
if ((rc = efx_mcdi_rss_context_set_key(enp, rss_context, key, n)) != 0)
|
2016-11-29 16:18:53 +00:00
|
|
|
goto fail2;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_scale_tbl_set(
|
|
|
|
__in efx_nic_t *enp,
|
2017-08-30 18:17:37 +00:00
|
|
|
__in uint32_t rss_context,
|
2016-11-29 16:18:53 +00:00
|
|
|
__in_ecount(n) unsigned int *table,
|
|
|
|
__in size_t n)
|
|
|
|
{
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
2017-08-30 18:17:37 +00:00
|
|
|
|
|
|
|
if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
|
|
|
|
if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
|
|
|
|
rc = ENOTSUP;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
rss_context = enp->en_rss_context;
|
2016-11-29 16:18:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc = efx_mcdi_rss_context_set_table(enp,
|
2017-08-30 18:17:37 +00:00
|
|
|
rss_context, table, n)) != 0)
|
2016-11-29 16:18:53 +00:00
|
|
|
goto fail2;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* EF10 RX pseudo-header
|
|
|
|
* ---------------------
|
|
|
|
*
|
|
|
|
* Receive packets are prefixed by an (optional) 14 byte pseudo-header:
|
|
|
|
*
|
|
|
|
* +00: Toeplitz hash value.
|
|
|
|
* (32bit little-endian)
|
|
|
|
* +04: Outer VLAN tag. Zero if the packet did not have an outer VLAN tag.
|
|
|
|
* (16bit big-endian)
|
|
|
|
* +06: Inner VLAN tag. Zero if the packet did not have an inner VLAN tag.
|
|
|
|
* (16bit big-endian)
|
|
|
|
* +08: Packet Length. Zero if the RX datapath was in cut-through mode.
|
|
|
|
* (16bit little-endian)
|
|
|
|
* +10: MAC timestamp. Zero if timestamping is not enabled.
|
|
|
|
* (32bit little-endian)
|
|
|
|
*
|
|
|
|
* See "The RX Pseudo-header" in SF-109306-TC.
|
|
|
|
*/
|
|
|
|
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_prefix_pktlen(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in uint8_t *buffer,
|
|
|
|
__out uint16_t *lengthp)
|
|
|
|
{
|
|
|
|
_NOTE(ARGUNUSED(enp))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The RX pseudo-header contains the packet length, excluding the
|
|
|
|
* pseudo-header. If the hardware receive datapath was operating in
|
|
|
|
* cut-through mode then the length in the RX pseudo-header will be
|
|
|
|
* zero, and the packet length must be obtained from the DMA length
|
|
|
|
* reported in the RX event.
|
|
|
|
*/
|
|
|
|
*lengthp = buffer[8] | (buffer[9] << 8);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:53 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
|
|
|
__checkReturn uint32_t
|
|
|
|
ef10_rx_prefix_hash(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in efx_rx_hash_alg_t func,
|
|
|
|
__in uint8_t *buffer)
|
|
|
|
{
|
|
|
|
_NOTE(ARGUNUSED(enp))
|
|
|
|
|
|
|
|
switch (func) {
|
|
|
|
case EFX_RX_HASHALG_TOEPLITZ:
|
|
|
|
return (buffer[0] |
|
|
|
|
(buffer[1] << 8) |
|
|
|
|
(buffer[2] << 16) |
|
|
|
|
(buffer[3] << 24));
|
|
|
|
|
|
|
|
default:
|
|
|
|
EFSYS_ASSERT(0);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
|
|
|
|
2017-11-16 08:04:11 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
|
|
|
/*
|
|
|
|
* Fake length for RXQ descriptors in packed stream mode
|
|
|
|
* to make hardware happy
|
|
|
|
*/
|
|
|
|
#define EFX_RXQ_PACKED_STREAM_FAKE_BUF_SIZE 32
|
|
|
|
#endif
|
|
|
|
|
2017-11-16 08:04:20 +00:00
|
|
|
void
|
2016-11-29 16:18:42 +00:00
|
|
|
ef10_rx_qpost(
|
2017-11-16 08:04:20 +00:00
|
|
|
__in efx_rxq_t *erp,
|
|
|
|
__in_ecount(ndescs) efsys_dma_addr_t *addrp,
|
|
|
|
__in size_t size,
|
|
|
|
__in unsigned int ndescs,
|
|
|
|
__in unsigned int completed,
|
|
|
|
__in unsigned int added)
|
2016-11-29 16:18:42 +00:00
|
|
|
{
|
|
|
|
efx_qword_t qword;
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int offset;
|
|
|
|
unsigned int id;
|
|
|
|
|
2017-11-16 08:04:34 +00:00
|
|
|
_NOTE(ARGUNUSED(completed))
|
|
|
|
|
2017-11-16 08:04:11 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
|
|
|
/*
|
|
|
|
* Real size of the buffer does not fit into ESF_DZ_RX_KER_BYTE_CNT
|
|
|
|
* and equal to 0 after applying mask. Hardware does not like it.
|
|
|
|
*/
|
|
|
|
if (erp->er_ev_qstate->eers_rx_packed_stream)
|
|
|
|
size = EFX_RXQ_PACKED_STREAM_FAKE_BUF_SIZE;
|
|
|
|
#endif
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
/* The client driver must not overfill the queue */
|
2017-11-16 08:04:20 +00:00
|
|
|
EFSYS_ASSERT3U(added - completed + ndescs, <=,
|
2016-11-29 16:18:42 +00:00
|
|
|
EFX_RXQ_LIMIT(erp->er_mask + 1));
|
|
|
|
|
|
|
|
id = added & (erp->er_mask);
|
2017-11-16 08:04:20 +00:00
|
|
|
for (i = 0; i < ndescs; i++) {
|
2016-11-29 16:18:42 +00:00
|
|
|
EFSYS_PROBE4(rx_post, unsigned int, erp->er_index,
|
|
|
|
unsigned int, id, efsys_dma_addr_t, addrp[i],
|
|
|
|
size_t, size);
|
|
|
|
|
|
|
|
EFX_POPULATE_QWORD_3(qword,
|
|
|
|
ESF_DZ_RX_KER_BYTE_CNT, (uint32_t)(size),
|
|
|
|
ESF_DZ_RX_KER_BUF_ADDR_DW0,
|
|
|
|
(uint32_t)(addrp[i] & 0xffffffff),
|
|
|
|
ESF_DZ_RX_KER_BUF_ADDR_DW1,
|
|
|
|
(uint32_t)(addrp[i] >> 32));
|
|
|
|
|
|
|
|
offset = id * sizeof (efx_qword_t);
|
|
|
|
EFSYS_MEM_WRITEQ(erp->er_esmp, offset, &qword);
|
|
|
|
|
|
|
|
id = (id + 1) & (erp->er_mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ef10_rx_qpush(
|
|
|
|
__in efx_rxq_t *erp,
|
|
|
|
__in unsigned int added,
|
|
|
|
__inout unsigned int *pushedp)
|
|
|
|
{
|
|
|
|
efx_nic_t *enp = erp->er_enp;
|
|
|
|
unsigned int pushed = *pushedp;
|
|
|
|
uint32_t wptr;
|
|
|
|
efx_dword_t dword;
|
|
|
|
|
|
|
|
/* Hardware has alignment restriction for WPTR */
|
|
|
|
wptr = P2ALIGN(added, EF10_RX_WPTR_ALIGN);
|
|
|
|
if (pushed == wptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*pushedp = wptr;
|
|
|
|
|
|
|
|
/* Push the populated descriptors out */
|
|
|
|
wptr &= erp->er_mask;
|
|
|
|
|
|
|
|
EFX_POPULATE_DWORD_1(dword, ERF_DZ_RX_DESC_WPTR, wptr);
|
|
|
|
|
|
|
|
/* Guarantee ordering of memory (descriptors) and PIO (doorbell) */
|
|
|
|
EFX_DMA_SYNC_QUEUE_FOR_DEVICE(erp->er_esmp, erp->er_mask + 1,
|
|
|
|
wptr, pushed & erp->er_mask);
|
|
|
|
EFSYS_PIO_WRITE_BARRIER();
|
2018-02-20 07:33:41 +00:00
|
|
|
EFX_BAR_VI_WRITED(enp, ER_DZ_RX_DESC_UPD_REG,
|
|
|
|
erp->er_index, &dword, B_FALSE);
|
2016-11-29 16:18:42 +00:00
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:57 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
|
|
|
|
|
|
|
void
|
2017-11-16 08:04:05 +00:00
|
|
|
ef10_rx_qpush_ps_credits(
|
|
|
|
__in efx_rxq_t *erp)
|
2016-11-29 16:18:57 +00:00
|
|
|
{
|
|
|
|
efx_nic_t *enp = erp->er_enp;
|
|
|
|
efx_dword_t dword;
|
2017-11-16 08:04:10 +00:00
|
|
|
efx_evq_rxq_state_t *rxq_state = erp->er_ev_qstate;
|
2017-11-16 08:04:09 +00:00
|
|
|
uint32_t credits;
|
2016-11-29 16:18:57 +00:00
|
|
|
|
|
|
|
EFSYS_ASSERT(rxq_state->eers_rx_packed_stream);
|
|
|
|
|
|
|
|
if (rxq_state->eers_rx_packed_stream_credits == 0)
|
|
|
|
return;
|
|
|
|
|
2017-11-16 08:04:09 +00:00
|
|
|
/*
|
|
|
|
* It is a bug if we think that FW has utilized more
|
|
|
|
* credits than it is allowed to have (maximum). However,
|
|
|
|
* make sure that we do not credit more than maximum anyway.
|
|
|
|
*/
|
|
|
|
credits = MIN(rxq_state->eers_rx_packed_stream_credits,
|
|
|
|
EFX_RX_PACKED_STREAM_MAX_CREDITS);
|
2016-11-29 16:18:57 +00:00
|
|
|
EFX_POPULATE_DWORD_3(dword,
|
|
|
|
ERF_DZ_RX_DESC_MAGIC_DOORBELL, 1,
|
|
|
|
ERF_DZ_RX_DESC_MAGIC_CMD,
|
|
|
|
ERE_DZ_RX_DESC_MAGIC_CMD_PS_CREDITS,
|
2017-11-16 08:04:09 +00:00
|
|
|
ERF_DZ_RX_DESC_MAGIC_DATA, credits);
|
2018-02-20 07:33:41 +00:00
|
|
|
EFX_BAR_VI_WRITED(enp, ER_DZ_RX_DESC_UPD_REG,
|
2016-11-29 16:18:57 +00:00
|
|
|
erp->er_index, &dword, B_FALSE);
|
|
|
|
|
|
|
|
rxq_state->eers_rx_packed_stream_credits = 0;
|
|
|
|
}
|
|
|
|
|
2017-11-16 08:04:07 +00:00
|
|
|
/*
|
|
|
|
* In accordance with SF-112241-TC the received data has the following layout:
|
|
|
|
* - 8 byte pseudo-header which consist of:
|
|
|
|
* - 4 byte little-endian timestamp
|
|
|
|
* - 2 byte little-endian captured length in bytes
|
|
|
|
* - 2 byte little-endian original packet length in bytes
|
|
|
|
* - captured packet bytes
|
|
|
|
* - optional padding to align to 64 bytes boundary
|
|
|
|
* - 64 bytes scratch space for the host software
|
|
|
|
*/
|
2016-11-29 16:18:57 +00:00
|
|
|
__checkReturn uint8_t *
|
|
|
|
ef10_rx_qps_packet_info(
|
|
|
|
__in efx_rxq_t *erp,
|
|
|
|
__in uint8_t *buffer,
|
|
|
|
__in uint32_t buffer_length,
|
|
|
|
__in uint32_t current_offset,
|
|
|
|
__out uint16_t *lengthp,
|
|
|
|
__out uint32_t *next_offsetp,
|
|
|
|
__out uint32_t *timestamp)
|
|
|
|
{
|
|
|
|
uint16_t buf_len;
|
|
|
|
uint8_t *pkt_start;
|
|
|
|
efx_qword_t *qwordp;
|
2017-11-16 08:04:10 +00:00
|
|
|
efx_evq_rxq_state_t *rxq_state = erp->er_ev_qstate;
|
2016-11-29 16:18:57 +00:00
|
|
|
|
|
|
|
EFSYS_ASSERT(rxq_state->eers_rx_packed_stream);
|
|
|
|
|
|
|
|
buffer += current_offset;
|
|
|
|
pkt_start = buffer + EFX_RX_PACKED_STREAM_RX_PREFIX_SIZE;
|
|
|
|
|
|
|
|
qwordp = (efx_qword_t *)buffer;
|
|
|
|
*timestamp = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_TSTAMP);
|
|
|
|
*lengthp = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_ORIG_LEN);
|
|
|
|
buf_len = EFX_QWORD_FIELD(*qwordp, ES_DZ_PS_RX_PREFIX_CAP_LEN);
|
|
|
|
|
|
|
|
buf_len = P2ROUNDUP(buf_len + EFX_RX_PACKED_STREAM_RX_PREFIX_SIZE,
|
|
|
|
EFX_RX_PACKED_STREAM_ALIGNMENT);
|
|
|
|
*next_offsetp =
|
|
|
|
current_offset + buf_len + EFX_RX_PACKED_STREAM_ALIGNMENT;
|
|
|
|
|
|
|
|
EFSYS_ASSERT3U(*next_offsetp, <=, buffer_length);
|
|
|
|
EFSYS_ASSERT3U(current_offset + *lengthp, <, *next_offsetp);
|
|
|
|
|
|
|
|
if ((*next_offsetp ^ current_offset) &
|
2017-11-16 08:04:09 +00:00
|
|
|
EFX_RX_PACKED_STREAM_MEM_PER_CREDIT)
|
|
|
|
rxq_state->eers_rx_packed_stream_credits++;
|
2016-11-29 16:18:57 +00:00
|
|
|
|
|
|
|
return (pkt_start);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_qflush(
|
|
|
|
__in efx_rxq_t *erp)
|
|
|
|
{
|
|
|
|
efx_nic_t *enp = erp->er_enp;
|
|
|
|
efx_rc_t rc;
|
|
|
|
|
|
|
|
if ((rc = efx_mcdi_fini_rxq(enp, erp->er_index)) != 0)
|
|
|
|
goto fail1;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
fail1:
|
2017-05-27 07:55:31 +00:00
|
|
|
/*
|
|
|
|
* EALREADY is not an error, but indicates that the MC has rebooted and
|
|
|
|
* that the RXQ has already been destroyed. Callers need to know that
|
|
|
|
* the RXQ flush has completed to avoid waiting until timeout for a
|
|
|
|
* flush done event that will not be delivered.
|
|
|
|
*/
|
|
|
|
if (rc != EALREADY)
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ef10_rx_qenable(
|
|
|
|
__in efx_rxq_t *erp)
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
_NOTE(ARGUNUSED(erp))
|
|
|
|
/* FIXME */
|
|
|
|
}
|
|
|
|
|
|
|
|
__checkReturn efx_rc_t
|
|
|
|
ef10_rx_qcreate(
|
|
|
|
__in efx_nic_t *enp,
|
|
|
|
__in unsigned int index,
|
|
|
|
__in unsigned int label,
|
|
|
|
__in efx_rxq_type_t type,
|
2017-12-24 10:46:36 +00:00
|
|
|
__in uint32_t type_data,
|
2016-11-29 16:18:42 +00:00
|
|
|
__in efsys_mem_t *esmp,
|
2017-11-16 08:04:20 +00:00
|
|
|
__in size_t ndescs,
|
2016-11-29 16:18:42 +00:00
|
|
|
__in uint32_t id,
|
2017-12-24 10:46:35 +00:00
|
|
|
__in unsigned int flags,
|
2016-11-29 16:18:42 +00:00
|
|
|
__in efx_evq_t *eep,
|
|
|
|
__in efx_rxq_t *erp)
|
|
|
|
{
|
|
|
|
efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
|
|
|
|
efx_rc_t rc;
|
|
|
|
boolean_t disable_scatter;
|
2017-12-24 10:46:37 +00:00
|
|
|
boolean_t want_inner_classes;
|
2016-11-29 16:18:42 +00:00
|
|
|
unsigned int ps_buf_size;
|
|
|
|
|
2018-01-19 06:47:06 +00:00
|
|
|
_NOTE(ARGUNUSED(id, erp, type_data))
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
EFX_STATIC_ASSERT(EFX_EV_RX_NLABELS == (1 << ESF_DZ_RX_QLABEL_WIDTH));
|
|
|
|
EFSYS_ASSERT3U(label, <, EFX_EV_RX_NLABELS);
|
|
|
|
EFSYS_ASSERT3U(enp->en_rx_qcount + 1, <, encp->enc_rxq_limit);
|
|
|
|
|
|
|
|
EFX_STATIC_ASSERT(ISP2(EFX_RXQ_MAXNDESCS));
|
|
|
|
EFX_STATIC_ASSERT(ISP2(EFX_RXQ_MINNDESCS));
|
|
|
|
|
2017-11-16 08:04:20 +00:00
|
|
|
if (!ISP2(ndescs) ||
|
|
|
|
(ndescs < EFX_RXQ_MINNDESCS) || (ndescs > EFX_RXQ_MAXNDESCS)) {
|
2016-11-29 16:18:42 +00:00
|
|
|
rc = EINVAL;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
if (index >= encp->enc_rxq_limit) {
|
|
|
|
rc = EINVAL;
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case EFX_RXQ_TYPE_DEFAULT:
|
|
|
|
ps_buf_size = 0;
|
|
|
|
break;
|
2016-11-29 16:18:57 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
2017-12-24 10:46:36 +00:00
|
|
|
case EFX_RXQ_TYPE_PACKED_STREAM:
|
|
|
|
switch (type_data) {
|
|
|
|
case EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M:
|
|
|
|
ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M;
|
|
|
|
break;
|
|
|
|
case EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K:
|
|
|
|
ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_512K;
|
|
|
|
break;
|
|
|
|
case EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K:
|
|
|
|
ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_256K;
|
|
|
|
break;
|
|
|
|
case EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K:
|
|
|
|
ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_128K;
|
|
|
|
break;
|
|
|
|
case EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K:
|
|
|
|
ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_64K;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = ENOTSUP;
|
|
|
|
goto fail3;
|
|
|
|
}
|
2016-11-29 16:18:57 +00:00
|
|
|
break;
|
|
|
|
#endif /* EFSYS_OPT_RX_PACKED_STREAM */
|
2016-11-29 16:18:42 +00:00
|
|
|
default:
|
|
|
|
rc = ENOTSUP;
|
2017-12-24 10:46:36 +00:00
|
|
|
goto fail4;
|
2016-11-29 16:18:42 +00:00
|
|
|
}
|
|
|
|
|
2016-11-29 16:18:57 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
|
|
|
if (ps_buf_size != 0) {
|
|
|
|
/* Check if datapath firmware supports packed stream mode */
|
|
|
|
if (encp->enc_rx_packed_stream_supported == B_FALSE) {
|
|
|
|
rc = ENOTSUP;
|
2017-12-24 10:46:36 +00:00
|
|
|
goto fail5;
|
2016-11-29 16:18:57 +00:00
|
|
|
}
|
|
|
|
/* Check if packed stream allows configurable buffer sizes */
|
2017-12-24 10:46:36 +00:00
|
|
|
if ((ps_buf_size != MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M) &&
|
2016-11-29 16:18:57 +00:00
|
|
|
(encp->enc_rx_var_packed_stream_supported == B_FALSE)) {
|
|
|
|
rc = ENOTSUP;
|
2017-12-24 10:46:36 +00:00
|
|
|
goto fail6;
|
2016-11-29 16:18:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#else /* EFSYS_OPT_RX_PACKED_STREAM */
|
2016-11-29 16:18:42 +00:00
|
|
|
EFSYS_ASSERT(ps_buf_size == 0);
|
2016-11-29 16:18:57 +00:00
|
|
|
#endif /* EFSYS_OPT_RX_PACKED_STREAM */
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
/* Scatter can only be disabled if the firmware supports doing so */
|
2017-12-24 10:46:35 +00:00
|
|
|
if (flags & EFX_RXQ_FLAG_SCATTER)
|
2016-11-29 16:18:42 +00:00
|
|
|
disable_scatter = B_FALSE;
|
|
|
|
else
|
|
|
|
disable_scatter = encp->enc_rx_disable_scatter_supported;
|
|
|
|
|
2017-12-24 10:46:37 +00:00
|
|
|
if (flags & EFX_RXQ_FLAG_INNER_CLASSES)
|
|
|
|
want_inner_classes = B_TRUE;
|
|
|
|
else
|
|
|
|
want_inner_classes = B_FALSE;
|
|
|
|
|
2017-11-16 08:04:20 +00:00
|
|
|
if ((rc = efx_mcdi_init_rxq(enp, ndescs, eep->ee_index, label, index,
|
2017-12-24 10:46:37 +00:00
|
|
|
esmp, disable_scatter, want_inner_classes,
|
|
|
|
ps_buf_size)) != 0)
|
2017-12-24 10:46:36 +00:00
|
|
|
goto fail7;
|
2016-11-29 16:18:42 +00:00
|
|
|
|
|
|
|
erp->er_eep = eep;
|
|
|
|
erp->er_label = label;
|
|
|
|
|
2017-11-16 08:04:06 +00:00
|
|
|
ef10_ev_rxlabel_init(eep, erp, label, type);
|
2016-11-29 16:18:42 +00:00
|
|
|
|
2017-11-16 08:04:10 +00:00
|
|
|
erp->er_ev_qstate = &erp->er_eep->ee_rxq_state[label];
|
|
|
|
|
2016-11-29 16:18:42 +00:00
|
|
|
return (0);
|
|
|
|
|
2017-12-24 10:46:36 +00:00
|
|
|
fail7:
|
|
|
|
EFSYS_PROBE(fail7);
|
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
2016-11-29 16:18:42 +00:00
|
|
|
fail6:
|
|
|
|
EFSYS_PROBE(fail6);
|
2016-11-29 16:18:57 +00:00
|
|
|
fail5:
|
|
|
|
EFSYS_PROBE(fail5);
|
2017-12-24 10:46:36 +00:00
|
|
|
#endif /* EFSYS_OPT_RX_PACKED_STREAM */
|
2016-11-29 16:18:57 +00:00
|
|
|
fail4:
|
|
|
|
EFSYS_PROBE(fail4);
|
2017-12-24 10:46:36 +00:00
|
|
|
#if EFSYS_OPT_RX_PACKED_STREAM
|
2016-11-29 16:18:42 +00:00
|
|
|
fail3:
|
|
|
|
EFSYS_PROBE(fail3);
|
2017-12-24 10:46:36 +00:00
|
|
|
#endif /* EFSYS_OPT_RX_PACKED_STREAM */
|
2016-11-29 16:18:42 +00:00
|
|
|
fail2:
|
|
|
|
EFSYS_PROBE(fail2);
|
|
|
|
fail1:
|
|
|
|
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
|
|
|
|
|
|
|
return (rc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ef10_rx_qdestroy(
|
|
|
|
__in efx_rxq_t *erp)
|
|
|
|
{
|
|
|
|
efx_nic_t *enp = erp->er_enp;
|
|
|
|
efx_evq_t *eep = erp->er_eep;
|
|
|
|
unsigned int label = erp->er_label;
|
|
|
|
|
|
|
|
ef10_ev_rxlabel_fini(eep, label);
|
|
|
|
|
|
|
|
EFSYS_ASSERT(enp->en_rx_qcount != 0);
|
|
|
|
--enp->en_rx_qcount;
|
|
|
|
|
|
|
|
EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_rxq_t), erp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ef10_rx_fini(
|
|
|
|
__in efx_nic_t *enp)
|
|
|
|
{
|
2016-11-29 16:18:53 +00:00
|
|
|
#if EFSYS_OPT_RX_SCALE
|
2017-08-30 18:17:35 +00:00
|
|
|
if (enp->en_rss_context_type != EFX_RX_SCALE_UNAVAILABLE)
|
2016-11-29 16:18:53 +00:00
|
|
|
(void) efx_mcdi_rss_context_free(enp, enp->en_rss_context);
|
|
|
|
enp->en_rss_context = 0;
|
2017-08-30 18:17:35 +00:00
|
|
|
enp->en_rss_context_type = EFX_RX_SCALE_UNAVAILABLE;
|
2016-11-29 16:18:53 +00:00
|
|
|
#else
|
2016-11-29 16:18:42 +00:00
|
|
|
_NOTE(ARGUNUSED(enp))
|
2016-11-29 16:18:53 +00:00
|
|
|
#endif /* EFSYS_OPT_RX_SCALE */
|
2016-11-29 16:18:42 +00:00
|
|
|
}
|
|
|
|
|
2018-02-20 07:33:34 +00:00
|
|
|
#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
|