net/cnxk: support meter ops get
[dpdk.git] / drivers / net / cnxk / cnxk_ethdev.c
index ec00e62..d2ee39d 100644 (file)
@@ -209,7 +209,7 @@ nix_enable_mseg_on_jumbo(struct cnxk_eth_rxq_sp *rxq)
        mbp_priv = rte_mempool_get_priv(rxq->qconf.mp);
        buffsz = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
 
-       if (eth_dev->data->dev_conf.rxmode.max_rx_pkt_len > buffsz) {
+       if (eth_dev->data->mtu + (uint32_t)CNXK_NIX_L2_OVERHEAD > buffsz) {
                dev->rx_offloads |= DEV_RX_OFFLOAD_SCATTER;
                dev->tx_offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
        }
@@ -220,18 +220,13 @@ nix_recalc_mtu(struct rte_eth_dev *eth_dev)
 {
        struct rte_eth_dev_data *data = eth_dev->data;
        struct cnxk_eth_rxq_sp *rxq;
-       uint16_t mtu;
        int rc;
 
        rxq = ((struct cnxk_eth_rxq_sp *)data->rx_queues[0]) - 1;
        /* Setup scatter mode if needed by jumbo */
        nix_enable_mseg_on_jumbo(rxq);
 
-       /* Setup MTU based on max_rx_pkt_len */
-       mtu = data->dev_conf.rxmode.max_rx_pkt_len - CNXK_NIX_L2_OVERHEAD +
-                               CNXK_NIX_MAX_VTAG_ACT_SIZE;
-
-       rc = cnxk_nix_mtu_set(eth_dev, mtu);
+       rc = cnxk_nix_mtu_set(eth_dev, data->mtu);
        if (rc)
                plt_err("Failed to set default MTU size, rc=%d", rc);
 
@@ -346,7 +341,7 @@ cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
        /* Free memory prior to re-allocation if needed. */
        if (eth_dev->data->tx_queues[qid] != NULL) {
                plt_nix_dbg("Freeing memory prior to re-allocation %d", qid);
-               dev_ops->tx_queue_release(eth_dev->data->tx_queues[qid]);
+               dev_ops->tx_queue_release(eth_dev, qid);
                eth_dev->data->tx_queues[qid] = NULL;
        }
 
@@ -396,20 +391,20 @@ cnxk_nix_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
 }
 
 static void
-cnxk_nix_tx_queue_release(void *txq)
+cnxk_nix_tx_queue_release(struct rte_eth_dev *eth_dev, uint16_t qid)
 {
+       void *txq = eth_dev->data->tx_queues[qid];
        struct cnxk_eth_txq_sp *txq_sp;
        struct cnxk_eth_dev *dev;
        struct roc_nix_sq *sq;
-       uint16_t qid;
        int rc;
 
        if (!txq)
                return;
 
        txq_sp = cnxk_eth_txq_to_sp(txq);
+
        dev = txq_sp->dev;
-       qid = txq_sp->qid;
 
        plt_nix_dbg("Releasing txq %u", qid);
 
@@ -464,7 +459,7 @@ cnxk_nix_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t qid,
                const struct eth_dev_ops *dev_ops = eth_dev->dev_ops;
 
                plt_nix_dbg("Freeing memory prior to re-allocation %d", qid);
-               dev_ops->rx_queue_release(eth_dev->data->rx_queues[qid]);
+               dev_ops->rx_queue_release(eth_dev, qid);
                eth_dev->data->rx_queues[qid] = NULL;
        }
 
@@ -572,13 +567,13 @@ fail:
 }
 
 static void
-cnxk_nix_rx_queue_release(void *rxq)
+cnxk_nix_rx_queue_release(struct rte_eth_dev *eth_dev, uint16_t qid)
 {
+       void *rxq = eth_dev->data->rx_queues[qid];
        struct cnxk_eth_rxq_sp *rxq_sp;
        struct cnxk_eth_dev *dev;
        struct roc_nix_rq *rq;
        struct roc_nix_cq *cq;
-       uint16_t qid;
        int rc;
 
        if (!rxq)
@@ -586,7 +581,6 @@ cnxk_nix_rx_queue_release(void *rxq)
 
        rxq_sp = cnxk_eth_rxq_to_sp(rxq);
        dev = rxq_sp->dev;
-       qid = rxq_sp->qid;
        rq = &dev->rqs[qid];
 
        plt_nix_dbg("Releasing rxq %u", qid);
@@ -755,7 +749,7 @@ nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
                txq_sp = cnxk_eth_txq_to_sp(txq[i]);
                memcpy(&tx_qconf[i], &txq_sp->qconf, sizeof(*tx_qconf));
                tx_qconf[i].valid = true;
-               dev_ops->tx_queue_release(txq[i]);
+               dev_ops->tx_queue_release(eth_dev, i);
                eth_dev->data->tx_queues[i] = NULL;
        }
 
@@ -769,7 +763,7 @@ nix_store_queue_cfg_and_then_release(struct rte_eth_dev *eth_dev)
                rxq_sp = cnxk_eth_rxq_to_sp(rxq[i]);
                memcpy(&rx_qconf[i], &rxq_sp->qconf, sizeof(*rx_qconf));
                rx_qconf[i].valid = true;
-               dev_ops->rx_queue_release(rxq[i]);
+               dev_ops->rx_queue_release(eth_dev, i);
                eth_dev->data->rx_queues[i] = NULL;
        }
 
@@ -791,7 +785,6 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
        struct cnxk_eth_qconf *tx_qconf = dev->tx_qconf;
        struct cnxk_eth_qconf *rx_qconf = dev->rx_qconf;
        int rc, i, nb_rxq, nb_txq;
-       void **txq, **rxq;
 
        nb_rxq = RTE_MIN(dev->nb_rxq, eth_dev->data->nb_rx_queues);
        nb_txq = RTE_MIN(dev->nb_txq, eth_dev->data->nb_tx_queues);
@@ -826,9 +819,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
                                             &tx_qconf[i].conf.tx);
                if (rc) {
                        plt_err("Failed to setup tx queue rc=%d", rc);
-                       txq = eth_dev->data->tx_queues;
                        for (i -= 1; i >= 0; i--)
-                               dev_ops->tx_queue_release(txq[i]);
+                               dev_ops->tx_queue_release(eth_dev, i);
                        goto fail;
                }
        }
@@ -844,9 +836,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
                                             rx_qconf[i].mp);
                if (rc) {
                        plt_err("Failed to setup rx queue rc=%d", rc);
-                       rxq = eth_dev->data->rx_queues;
                        for (i -= 1; i >= 0; i--)
-                               dev_ops->rx_queue_release(rxq[i]);
+                               dev_ops->rx_queue_release(eth_dev, i);
                        goto tx_queue_release;
                }
        }
@@ -857,9 +848,8 @@ nix_restore_queue_cfg(struct rte_eth_dev *eth_dev)
        return 0;
 
 tx_queue_release:
-       txq = eth_dev->data->tx_queues;
        for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
-               dev_ops->tx_queue_release(txq[i]);
+               dev_ops->tx_queue_release(eth_dev, i);
 fail:
        if (tx_qconf)
                free(tx_qconf);
@@ -1498,6 +1488,7 @@ struct eth_dev_ops cnxk_eth_dev_ops = {
        .set_mc_addr_list = cnxk_nix_mc_addr_list_configure,
        .set_queue_rate_limit = cnxk_nix_tm_set_queue_rate_limit,
        .tm_ops_get = cnxk_nix_tm_ops_get,
+       .mtr_ops_get = cnxk_nix_mtr_ops_get,
 };
 
 static int
@@ -1664,14 +1655,14 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset)
 
        /* Free up SQs */
        for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
-               dev_ops->tx_queue_release(eth_dev->data->tx_queues[i]);
+               dev_ops->tx_queue_release(eth_dev, i);
                eth_dev->data->tx_queues[i] = NULL;
        }
        eth_dev->data->nb_tx_queues = 0;
 
        /* Free up RQ's and CQ's */
        for (i = 0; i < eth_dev->data->nb_rx_queues; i++) {
-               dev_ops->rx_queue_release(eth_dev->data->rx_queues[i]);
+               dev_ops->rx_queue_release(eth_dev, i);
                eth_dev->data->rx_queues[i] = NULL;
        }
        eth_dev->data->nb_rx_queues = 0;