+ struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
+
+ if (!rxq)
+ return;
+
+ bnxt_rx_queue_release_mbufs(rxq);
+
+ bnxt_free_ring(rxq->rx_ring->rx_ring_struct);
+ rte_free(rxq->rx_ring->rx_ring_struct);
+ rte_free(rxq->rx_ring);
+
+ rte_free(rxq);
+}
+
+int bnxt_rep_tx_queue_setup_op(struct rte_eth_dev *eth_dev,
+ uint16_t queue_idx,
+ uint16_t nb_desc,
+ unsigned int socket_id,
+ __rte_unused const struct rte_eth_txconf *tx_conf)
+{
+ struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
+ struct bnxt *parent_bp = rep_bp->parent_dev->data->dev_private;
+ struct bnxt_tx_queue *parent_txq, *txq;
+ struct bnxt_vf_rep_tx_queue *vfr_txq;
+
+ if (queue_idx >= BNXT_MAX_VF_REP_RINGS) {
+ PMD_DRV_LOG(ERR,
+ "Cannot create Tx rings %d. %d rings available\n",
+ queue_idx, BNXT_MAX_VF_REP_RINGS);
+ return -EINVAL;
+ }
+
+ if (!nb_desc || nb_desc > MAX_TX_DESC_CNT) {
+ PMD_DRV_LOG(ERR, "nb_desc %d is invalid", nb_desc);
+ return -EINVAL;
+ }
+
+ if (!parent_bp->tx_queues) {
+ PMD_DRV_LOG(ERR, "Parent Tx qs not configured yet\n");
+ return -EINVAL;
+ }
+
+ parent_txq = parent_bp->tx_queues[queue_idx];
+ if (!parent_txq) {
+ PMD_DRV_LOG(ERR, "Parent TxQ has not been configured yet\n");
+ return -EINVAL;
+ }
+
+ if (nb_desc != parent_txq->nb_tx_desc) {
+ PMD_DRV_LOG(ERR, "nb_desc %d do not match parent txq", nb_desc);
+ return -EINVAL;
+ }
+
+ if (eth_dev->data->tx_queues) {
+ vfr_txq = eth_dev->data->tx_queues[queue_idx];
+ bnxt_rep_tx_queue_release_op(vfr_txq);
+ vfr_txq = NULL;
+ }
+
+ vfr_txq = rte_zmalloc_socket("bnxt_vfr_tx_queue",
+ sizeof(struct bnxt_vf_rep_tx_queue),
+ RTE_CACHE_LINE_SIZE, socket_id);
+ if (!vfr_txq) {
+ PMD_DRV_LOG(ERR, "bnxt_vfr_tx_queue allocation failed!");
+ return -ENOMEM;
+ }
+ txq = rte_zmalloc_socket("bnxt_tx_queue",
+ sizeof(struct bnxt_tx_queue),
+ RTE_CACHE_LINE_SIZE, socket_id);
+ if (!txq) {
+ PMD_DRV_LOG(ERR, "bnxt_tx_queue allocation failed!");
+ rte_free(vfr_txq);
+ return -ENOMEM;
+ }
+
+ txq->nb_tx_desc = nb_desc;
+ txq->queue_id = queue_idx;
+ txq->port_id = eth_dev->data->port_id;
+ vfr_txq->txq = txq;
+ vfr_txq->bp = rep_bp;
+ eth_dev->data->tx_queues[queue_idx] = vfr_txq;
+
+ return 0;
+}
+
+void bnxt_rep_tx_queue_release_op(void *tx_queue)
+{
+ struct bnxt_vf_rep_tx_queue *vfr_txq = tx_queue;
+
+ if (!vfr_txq)
+ return;
+
+ rte_free(vfr_txq->txq);
+ rte_free(vfr_txq);
+}
+
+int bnxt_rep_stats_get_op(struct rte_eth_dev *eth_dev,
+ struct rte_eth_stats *stats)
+{
+ struct bnxt_representor *rep_bp = eth_dev->data->dev_private;
+ int i;
+
+ memset(stats, 0, sizeof(*stats));
+ for (i = 0; i < BNXT_MAX_VF_REP_RINGS; i++) {
+ stats->obytes += rep_bp->tx_bytes[i];
+ stats->opackets += rep_bp->tx_pkts[i];
+ stats->ibytes += rep_bp->rx_bytes[i];
+ stats->ipackets += rep_bp->rx_pkts[i];
+ stats->imissed += rep_bp->rx_drop_pkts[i];
+
+ stats->q_ipackets[i] = rep_bp->rx_pkts[i];
+ stats->q_ibytes[i] = rep_bp->rx_bytes[i];
+ stats->q_opackets[i] = rep_bp->tx_pkts[i];
+ stats->q_obytes[i] = rep_bp->tx_bytes[i];
+ stats->q_errors[i] = rep_bp->rx_drop_pkts[i];
+ }
+