net/sfc: support more options for a number of Rx descriptors
authorAndrew Rybchenko <arybchenko@solarflare.com>
Tue, 9 Jan 2018 20:24:54 +0000 (20:24 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
The number of Rx descriptors is not used as HW Rx ring size any more.
It simply defines maximum fill level.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
drivers/net/sfc/sfc_dp_rx.h
drivers/net/sfc/sfc_ef10_rx.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_rx.c

index 029ebaf..b817f34 100644 (file)
@@ -102,6 +102,13 @@ struct sfc_dp_rx_qcreate_info {
        volatile void           *mem_bar;
 };
 
+/**
+ * Get Rx datapath specific device info.
+ *
+ * @param dev_info             Device info to be adjusted
+ */
+typedef void (sfc_dp_rx_get_dev_info_t)(struct rte_eth_dev_info *dev_info);
+
 /**
  * Get size of receive and event queue rings by the number of Rx
  * descriptors.
@@ -186,6 +193,7 @@ struct sfc_dp_rx {
 #define SFC_DP_RX_FEAT_SCATTER                 0x1
 #define SFC_DP_RX_FEAT_MULTI_PROCESS           0x2
 #define SFC_DP_RX_FEAT_TUNNELS                 0x4
+       sfc_dp_rx_get_dev_info_t                *get_dev_info;
        sfc_dp_rx_qsize_up_rings_t              *qsize_up_rings;
        sfc_dp_rx_qcreate_t                     *qcreate;
        sfc_dp_rx_qdestroy_t                    *qdestroy;
index ad84629..b651bd7 100644 (file)
@@ -638,6 +638,19 @@ sfc_ef10_rx_qdesc_status(__rte_unused struct sfc_dp_rxq *dp_rxq,
 }
 
 
+static sfc_dp_rx_get_dev_info_t sfc_ef10_rx_get_dev_info;
+static void
+sfc_ef10_rx_get_dev_info(struct rte_eth_dev_info *dev_info)
+{
+       /*
+        * Number of descriptors just defines maximum number of pushed
+        * descriptors (fill level).
+        */
+       dev_info->rx_desc_lim.nb_min = SFC_RX_REFILL_BULK;
+       dev_info->rx_desc_lim.nb_align = SFC_RX_REFILL_BULK;
+}
+
+
 static sfc_dp_rx_qsize_up_rings_t sfc_ef10_rx_qsize_up_rings;
 static int
 sfc_ef10_rx_qsize_up_rings(uint16_t nb_rx_desc,
@@ -645,9 +658,19 @@ sfc_ef10_rx_qsize_up_rings(uint16_t nb_rx_desc,
                           unsigned int *evq_entries,
                           unsigned int *rxq_max_fill_level)
 {
-       *rxq_entries = nb_rx_desc;
-       *evq_entries = nb_rx_desc;
-       *rxq_max_fill_level = SFC_EF10_RXQ_LIMIT(*rxq_entries);
+       /*
+        * rte_ethdev API guarantees that the number meets min, max and
+        * alignment requirements.
+        */
+       if (nb_rx_desc <= EFX_RXQ_MINNDESCS)
+               *rxq_entries = EFX_RXQ_MINNDESCS;
+       else
+               *rxq_entries = rte_align32pow2(nb_rx_desc);
+
+       *evq_entries = *rxq_entries;
+
+       *rxq_max_fill_level = RTE_MIN(nb_rx_desc,
+                                     SFC_EF10_RXQ_LIMIT(*evq_entries));
        return 0;
 }
 
@@ -809,6 +832,7 @@ struct sfc_dp_rx sfc_ef10_rx = {
        },
        .features               = SFC_DP_RX_FEAT_MULTI_PROCESS |
                                  SFC_DP_RX_FEAT_TUNNELS,
+       .get_dev_info           = sfc_ef10_rx_get_dev_info,
        .qsize_up_rings         = sfc_ef10_rx_qsize_up_rings,
        .qcreate                = sfc_ef10_rx_qcreate,
        .qdestroy               = sfc_ef10_rx_qdestroy,
index 1b700b1..fec91c3 100644 (file)
@@ -170,6 +170,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
        if (sa->tso)
                dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
 
+       /* Initialize to hardware limits */
        dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
        dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
        /* The RXQ hardware requires that the descriptor count is a power
@@ -184,6 +185,9 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
         * of 2, but tx_desc_lim cannot properly describe that constraint
         */
        dev_info->tx_desc_lim.nb_align = EFX_TXQ_MINNDESCS;
+
+       if (sa->dp_rx->get_dev_info != NULL)
+               sa->dp_rx->get_dev_info(dev_info);
 }
 
 static const uint32_t *
index 387f855..b355ea3 100644 (file)
@@ -933,6 +933,10 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
                                       &rxq_max_fill_level);
        if (rc != 0)
                goto fail_size_up_rings;
+       SFC_ASSERT(rxq_entries >= EFX_RXQ_MINNDESCS);
+       SFC_ASSERT(rxq_entries <= EFX_RXQ_MAXNDESCS);
+       SFC_ASSERT(rxq_entries >= nb_rx_desc);
+       SFC_ASSERT(rxq_max_fill_level <= nb_rx_desc);
 
        rc = sfc_rx_qcheck_conf(sa, rxq_max_fill_level, rx_conf);
        if (rc != 0)