net/sfc: correct RSS hash availability condition
[dpdk.git] / drivers / net / sfc / sfc_rx.c
index 56130b2..2ecd6f2 100644 (file)
@@ -122,10 +122,10 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq)
                        rxd = &rxq->sw_desc[id];
                        rxd->mbuf = m;
 
-                       rte_mbuf_refcnt_set(m, 1);
+                       SFC_ASSERT(rte_mbuf_refcnt_read(m) == 1);
                        m->data_off = RTE_PKTMBUF_HEADROOM;
-                       m->next = NULL;
-                       m->nb_segs = 1;
+                       SFC_ASSERT(m->next == NULL);
+                       SFC_ASSERT(m->nb_segs == 1);
                        m->port = port_id;
 
                        addr[i] = rte_pktmbuf_mtophys(m);
@@ -577,7 +577,7 @@ sfc_rx_qflush(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq)
 {
-       boolean_t rss = (sa->rss_channels > 1) ? B_TRUE : B_FALSE;
+       boolean_t rss = (sa->rss_channels > 0) ? B_TRUE : B_FALSE;
        struct sfc_port *port = &sa->port;
        int rc;
 
@@ -930,7 +930,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        info.prefix_size = encp->enc_rx_prefix_size;
 
 #if EFSYS_OPT_RX_SCALE
-       if (sa->hash_support == EFX_RX_HASH_AVAILABLE)
+       if (sa->hash_support == EFX_RX_HASH_AVAILABLE && sa->rss_channels > 0)
                info.flags |= SFC_RXQ_FLAG_RSS_HASH;
 #endif
 
@@ -1052,7 +1052,7 @@ sfc_rx_rss_config(struct sfc_adapter *sa)
        int rc = 0;
 
 #if EFSYS_OPT_RX_SCALE
-       if (sa->rss_channels > 1) {
+       if (sa->rss_channels > 0) {
                rc = efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
                                           sa->rss_hash_types, B_TRUE);
                if (rc != 0)
@@ -1289,9 +1289,9 @@ sfc_rx_configure(struct sfc_adapter *sa)
 
 #if EFSYS_OPT_RX_SCALE
        sa->rss_channels = (dev_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) ?
-                          MIN(sa->rxq_count, EFX_MAXRSS) : 1;
+                          MIN(sa->rxq_count, EFX_MAXRSS) : 0;
 
-       if (sa->rss_channels > 1) {
+       if (sa->rss_channels > 0) {
                for (sw_index = 0; sw_index < EFX_RSS_TBL_SIZE; ++sw_index)
                        sa->rss_tbl[sw_index] = sw_index % sa->rss_channels;
        }
@@ -1320,6 +1320,8 @@ sfc_rx_close(struct sfc_adapter *sa)
 {
        sfc_rx_fini_queues(sa, 0);
 
+       sa->rss_channels = 0;
+
        rte_free(sa->rxq_info);
        sa->rxq_info = NULL;
 }