efx_intr_fini(sa->nic);
rte_memcpy(rss->key, default_rss_key, sizeof(rss->key));
+ rss->dummy_rss_context = EFX_RSS_CONTEXT_DEFAULT;
return 0;
efx_rx_hash_type_t hash_types;
unsigned int tbl[EFX_RSS_TBL_SIZE];
uint8_t key[EFX_RSS_KEY_SIZE];
+
+ uint32_t dummy_rss_context;
};
/* Adapter private data shared by primary and secondary processes */
struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
struct sfc_rss *rss = &sfc_sa2shared(sa)->rss;
unsigned int efx_hash_types;
+ uint32_t contexts[] = {EFX_RSS_CONTEXT_DEFAULT, rss->dummy_rss_context};
+ unsigned int n_contexts;
+ unsigned int mode_i = 0;
+ unsigned int key_i = 0;
+ unsigned int i = 0;
int rc = 0;
+ n_contexts = rss->dummy_rss_context == EFX_RSS_CONTEXT_DEFAULT ? 1 : 2;
+
if (sfc_sa2shared(sa)->isolated)
return -ENOTSUP;
if (rc != 0)
goto fail_rx_hf_rte_to_efx;
- rc = efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
- rss->hash_alg, efx_hash_types, B_TRUE);
- if (rc != 0)
- goto fail_scale_mode_set;
+ for (mode_i = 0; mode_i < n_contexts; mode_i++) {
+ rc = efx_rx_scale_mode_set(sa->nic, contexts[mode_i],
+ rss->hash_alg, efx_hash_types,
+ B_TRUE);
+ if (rc != 0)
+ goto fail_scale_mode_set;
+ }
if (rss_conf->rss_key != NULL) {
if (sa->state == SFC_ADAPTER_STARTED) {
- rc = efx_rx_scale_key_set(sa->nic,
- EFX_RSS_CONTEXT_DEFAULT,
- rss_conf->rss_key,
- sizeof(rss->key));
- if (rc != 0)
- goto fail_scale_key_set;
+ for (key_i = 0; key_i < n_contexts; key_i++) {
+ rc = efx_rx_scale_key_set(sa->nic,
+ contexts[key_i],
+ rss_conf->rss_key,
+ sizeof(rss->key));
+ if (rc != 0)
+ goto fail_scale_key_set;
+ }
}
rte_memcpy(rss->key, rss_conf->rss_key, sizeof(rss->key));
return 0;
fail_scale_key_set:
- if (efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
- EFX_RX_HASHALG_TOEPLITZ,
- rss->hash_types, B_TRUE) != 0)
- sfc_err(sa, "failed to restore RSS mode");
+ for (i = 0; i < key_i; i++) {
+ if (efx_rx_scale_key_set(sa->nic, contexts[i], rss->key,
+ sizeof(rss->key)) != 0)
+ sfc_err(sa, "failed to restore RSS key");
+ }
fail_scale_mode_set:
+ for (i = 0; i < mode_i; i++) {
+ if (efx_rx_scale_mode_set(sa->nic, contexts[i],
+ EFX_RX_HASHALG_TOEPLITZ,
+ rss->hash_types, B_TRUE) != 0)
+ sfc_err(sa, "failed to restore RSS mode");
+ }
+
fail_rx_hf_rte_to_efx:
sfc_adapter_unlock(sa);
return -rc;
struct sfc_flow_spec *spec = &flow->spec;
struct sfc_flow_spec_filter *spec_filter = &spec->filter;
struct sfc_rxq *rxq;
+ struct sfc_rxq_info *rxq_info;
if (queue->index >= sfc_sa2shared(sa)->rxq_count)
return -EINVAL;
rxq = &sa->rxq_ctrl[queue->index];
spec_filter->template.efs_dmaq_id = (uint16_t)rxq->hw_index;
+ rxq_info = &sfc_sa2shared(sa)->rxq_info[queue->index];
+ spec_filter->rss_hash_required = !!(rxq_info->rxq_flags &
+ SFC_RXQ_FLAG_RSS_HASH);
+
return 0;
}
struct sfc_flow_spec_filter *spec_filter = &flow->spec.filter;
struct sfc_flow_rss *flow_rss = &spec_filter->rss_conf;
uint32_t efs_rss_context = EFX_RSS_CONTEXT_DEFAULT;
+ boolean_t create_context;
unsigned int i;
int rc = 0;
- if (spec_filter->rss) {
- unsigned int rss_spread = MIN(flow_rss->rxq_hw_index_max -
- flow_rss->rxq_hw_index_min + 1,
- EFX_MAXRSS);
+ create_context = spec_filter->rss || (spec_filter->rss_hash_required &&
+ rss->dummy_rss_context == EFX_RSS_CONTEXT_DEFAULT);
+
+ if (create_context) {
+ unsigned int rss_spread;
+ unsigned int rss_hash_types;
+ uint8_t *rss_key;
+
+ if (spec_filter->rss) {
+ rss_spread = MIN(flow_rss->rxq_hw_index_max -
+ flow_rss->rxq_hw_index_min + 1,
+ EFX_MAXRSS);
+ rss_hash_types = flow_rss->rss_hash_types;
+ rss_key = flow_rss->rss_key;
+ } else {
+ /*
+ * Initialize dummy RSS context parameters to have
+ * valid RSS hash. Use default RSS hash function and
+ * key.
+ */
+ rss_spread = 1;
+ rss_hash_types = rss->hash_types;
+ rss_key = rss->key;
+ }
rc = efx_rx_scale_context_alloc(sa->nic,
EFX_RX_SCALE_EXCLUSIVE,
rc = efx_rx_scale_mode_set(sa->nic, efs_rss_context,
rss->hash_alg,
- flow_rss->rss_hash_types, B_TRUE);
+ rss_hash_types, B_TRUE);
if (rc != 0)
goto fail_scale_mode_set;
rc = efx_rx_scale_key_set(sa->nic, efs_rss_context,
- flow_rss->rss_key,
- sizeof(rss->key));
+ rss_key, sizeof(rss->key));
if (rc != 0)
goto fail_scale_key_set;
+ } else {
+ efs_rss_context = rss->dummy_rss_context;
+ }
+ if (spec_filter->rss || spec_filter->rss_hash_required) {
/*
* At this point, fully elaborated filter specifications
* have been produced from the template. To make sure that
efx_filter_spec_t *spec = &spec_filter->filters[i];
spec->efs_rss_context = efs_rss_context;
- spec->efs_dmaq_id = flow_rss->rxq_hw_index_min;
spec->efs_flags |= EFX_FILTER_FLAG_RX_RSS;
+ if (spec_filter->rss)
+ spec->efs_dmaq_id = flow_rss->rxq_hw_index_min;
}
}
if (rc != 0)
goto fail_filter_insert;
- if (spec_filter->rss) {
+ if (create_context) {
+ unsigned int dummy_tbl[RTE_DIM(flow_rss->rss_tbl)] = {0};
+ unsigned int *tbl;
+
+ tbl = spec_filter->rss ? flow_rss->rss_tbl : dummy_tbl;
+
/*
* Scale table is set after filter insertion because
* the table entries are relative to the base RxQ ID
* the table entries, and the operation will succeed
*/
rc = efx_rx_scale_tbl_set(sa->nic, efs_rss_context,
- flow_rss->rss_tbl,
- RTE_DIM(flow_rss->rss_tbl));
+ tbl, RTE_DIM(flow_rss->rss_tbl));
if (rc != 0)
goto fail_scale_tbl_set;
+
+ /* Remember created dummy RSS context */
+ if (!spec_filter->rss)
+ rss->dummy_rss_context = efs_rss_context;
}
return 0;
fail_filter_insert:
fail_scale_key_set:
fail_scale_mode_set:
- if (efs_rss_context != EFX_RSS_CONTEXT_DEFAULT)
+ if (create_context)
efx_rx_scale_context_free(sa->nic, efs_rss_context);
fail_scale_context_alloc:
void
sfc_flow_stop(struct sfc_adapter *sa)
{
+ struct sfc_adapter_shared * const sas = sfc_sa2shared(sa);
+ struct sfc_rss *rss = &sas->rss;
struct rte_flow *flow;
SFC_ASSERT(sfc_adapter_is_locked(sa));
TAILQ_FOREACH(flow, &sa->flow_list, entries)
sfc_flow_remove(sa, flow, NULL);
+
+ if (rss->dummy_rss_context != EFX_RSS_CONTEXT_DEFAULT) {
+ efx_rx_scale_context_free(sa->nic, rss->dummy_rss_context);
+ rss->dummy_rss_context = EFX_RSS_CONTEXT_DEFAULT;
+ }
}
int
unsigned int count;
/* RSS toggle */
boolean_t rss;
+ /* RSS hash toggle */
+ boolean_t rss_hash_required;
/* RSS configuration */
struct sfc_flow_rss rss_conf;
};
rxq_info->refill_threshold =
RTE_MAX(rx_free_thresh, SFC_RX_REFILL_BULK);
rxq_info->refill_mb_pool = mb_pool;
+
+ if (rss->hash_support == EFX_RX_HASH_AVAILABLE && rss->channels > 0 &&
+ (offloads & DEV_RX_OFFLOAD_RSS_HASH))
+ rxq_info->rxq_flags = SFC_RXQ_FLAG_RSS_HASH;
+ else
+ rxq_info->rxq_flags = 0;
+
rxq->buf_size = buf_size;
rc = sfc_dma_alloc(sa, "rxq", sw_index,
info.buf_size = buf_size;
info.batch_max = encp->enc_rx_batch_max;
info.prefix_size = encp->enc_rx_prefix_size;
-
- if (rss->hash_support == EFX_RX_HASH_AVAILABLE && rss->channels > 0 &&
- (offloads & DEV_RX_OFFLOAD_RSS_HASH))
- info.flags |= SFC_RXQ_FLAG_RSS_HASH;
-
+ info.flags = rxq_info->rxq_flags;
info.rxq_entries = rxq_info->entries;
info.rxq_hw_ring = rxq->mem.esm_base;
info.evq_hw_index = sfc_evq_index_by_rxq_sw_index(sa, sw_index);
boolean_t deferred_started;
unsigned int refill_threshold;
struct rte_mempool *refill_mb_pool;
+ unsigned int rxq_flags;
};
struct sfc_rxq_info *sfc_rxq_info_by_dp_rxq(const struct sfc_dp_rxq *dp_rxq);