New upstream version 17.11
[deb_dpdk.git] / drivers / net / sfc / sfc_tx.c
index b8581d1..d1320f4 100644 (file)
@@ -79,9 +79,8 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, uint16_t nb_tx_desc,
        if (tx_conf->tx_thresh.pthresh != 0 ||
            tx_conf->tx_thresh.hthresh != 0 ||
            tx_conf->tx_thresh.wthresh != 0) {
-               sfc_err(sa,
+               sfc_warn(sa,
                        "prefetch/host/writeback thresholds are not supported");
-               rc = EINVAL;
        }
 
        if (((flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) &&
@@ -91,6 +90,21 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, uint16_t nb_tx_desc,
                rc = EINVAL;
        }
 
+       if (((flags & ETH_TXQ_FLAGS_NOMULTMEMP) == 0) &&
+           (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL)) {
+               sfc_err(sa, "multi-mempool is not supported by %s datapath",
+                       sa->dp_tx->dp.name);
+               rc = EINVAL;
+       }
+
+       if (((flags & ETH_TXQ_FLAGS_NOREFCOUNT) == 0) &&
+           (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT)) {
+               sfc_err(sa,
+                       "mbuf reference counters are neglected by %s datapath",
+                       sa->dp_tx->dp.name);
+               rc = EINVAL;
+       }
+
        if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
                if (!encp->enc_hw_tx_insert_vlan_enabled) {
                        sfc_err(sa, "VLAN offload is not supported");
@@ -185,7 +199,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
        info.mem_bar = sa->mem_bar.esb_base;
 
        rc = sa->dp_tx->qcreate(sa->eth_dev->data->port_id, sw_index,
-                               &SFC_DEV_TO_PCI(sa->eth_dev)->addr,
+                               &RTE_ETH_DEV_TO_PCI(sa->eth_dev)->addr,
                                socket_id, &info, &txq->dp);
        if (rc != 0)
                goto fail_dp_tx_qinit;
@@ -479,6 +493,7 @@ sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
        struct sfc_txq *txq;
        unsigned int retry_count;
        unsigned int wait_count;
+       int rc;
 
        sfc_log_init(sa, "TxQ = %u", sw_index);
 
@@ -502,8 +517,10 @@ sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
             ((txq->state & SFC_TXQ_FLUSHED) == 0) &&
             (retry_count < SFC_TX_QFLUSH_ATTEMPTS);
             ++retry_count) {
-               if (efx_tx_qflush(txq->common) != 0) {
-                       txq->state |= SFC_TXQ_FLUSHING;
+               rc = efx_tx_qflush(txq->common);
+               if (rc != 0) {
+                       txq->state |= (rc == EALREADY) ?
+                               SFC_TXQ_FLUSHED : SFC_TXQ_FLUSH_FAILED;
                        break;
                }
 
@@ -747,7 +764,7 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
                        size_t                  seg_len;
 
                        seg_len = m_seg->data_len;
-                       next_frag = rte_mbuf_data_dma_addr(m_seg);
+                       next_frag = rte_mbuf_data_iova(m_seg);
 
                        /*
                         * If we've started TSO transaction few steps earlier,
@@ -974,6 +991,44 @@ sfc_efx_tx_qreap(struct sfc_dp_txq *dp_txq)
        txq->flags &= ~SFC_EFX_TXQ_FLAG_STARTED;
 }
 
+static sfc_dp_tx_qdesc_status_t sfc_efx_tx_qdesc_status;
+static int
+sfc_efx_tx_qdesc_status(struct sfc_dp_txq *dp_txq, uint16_t offset)
+{
+       struct sfc_efx_txq *txq = sfc_efx_txq_by_dp_txq(dp_txq);
+
+       if (unlikely(offset > txq->ptr_mask))
+               return -EINVAL;
+
+       if (unlikely(offset >= EFX_TXQ_LIMIT(txq->ptr_mask + 1)))
+               return RTE_ETH_TX_DESC_UNAVAIL;
+
+       /*
+        * Poll EvQ to derive up-to-date 'txq->pending' figure;
+        * it is required for the queue to be running, but the
+        * check is omitted because API design assumes that it
+        * is the duty of the caller to satisfy all conditions
+        */
+       SFC_ASSERT((txq->flags & SFC_EFX_TXQ_FLAG_RUNNING) ==
+                  SFC_EFX_TXQ_FLAG_RUNNING);
+       sfc_ev_qpoll(txq->evq);
+
+       /*
+        * Ring tail is 'txq->pending', and although descriptors
+        * between 'txq->completed' and 'txq->pending' are still
+        * in use by the driver, they should be reported as DONE
+        */
+       if (unlikely(offset < (txq->added - txq->pending)))
+               return RTE_ETH_TX_DESC_FULL;
+
+       /*
+        * There is no separate return value for unused descriptors;
+        * the latter will be reported as DONE because genuine DONE
+        * descriptors will be freed anyway in SW on the next burst
+        */
+       return RTE_ETH_TX_DESC_DONE;
+}
+
 struct sfc_dp_tx sfc_efx_tx = {
        .dp = {
                .name           = SFC_KVARG_DATAPATH_EFX,
@@ -982,11 +1037,14 @@ struct sfc_dp_tx sfc_efx_tx = {
        },
        .features               = SFC_DP_TX_FEAT_VLAN_INSERT |
                                  SFC_DP_TX_FEAT_TSO |
+                                 SFC_DP_TX_FEAT_MULTI_POOL |
+                                 SFC_DP_TX_FEAT_REFCNT |
                                  SFC_DP_TX_FEAT_MULTI_SEG,
        .qcreate                = sfc_efx_tx_qcreate,
        .qdestroy               = sfc_efx_tx_qdestroy,
        .qstart                 = sfc_efx_tx_qstart,
        .qstop                  = sfc_efx_tx_qstop,
        .qreap                  = sfc_efx_tx_qreap,
+       .qdesc_status           = sfc_efx_tx_qdesc_status,
        .pkt_burst              = sfc_efx_xmit_pkts,
 };