+ rep_bp->rx_queues = (void *)eth_dev->data->rx_queues;
+ rep_bp->tx_nr_rings = eth_dev->data->nb_tx_queues;
+ rep_bp->rx_nr_rings = eth_dev->data->nb_rx_queues;
+
+ return 0;
+}
+
+int bnxt_vf_rep_rx_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_rxconf *rx_conf,
+ __rte_unused struct rte_mempool *mp)
+{
+ struct bnxt_vf_representor *rep_bp = eth_dev->data->dev_private;
+ struct bnxt *parent_bp = rep_bp->parent_dev->data->dev_private;
+ struct bnxt_rx_queue *parent_rxq;
+ struct bnxt_rx_queue *rxq;
+ struct bnxt_sw_rx_bd *buf_ring;
+ int rc = 0;
+
+ if (queue_idx >= BNXT_MAX_VF_REP_RINGS) {
+ PMD_DRV_LOG(ERR,
+ "Cannot create Rx ring %d. %d rings available\n",
+ queue_idx, BNXT_MAX_VF_REP_RINGS);
+ return -EINVAL;
+ }
+
+ if (!nb_desc || nb_desc > MAX_RX_DESC_CNT) {
+ PMD_DRV_LOG(ERR, "nb_desc %d is invalid\n", nb_desc);
+ return -EINVAL;
+ }
+
+ parent_rxq = parent_bp->rx_queues[queue_idx];
+ if (!parent_rxq) {
+ PMD_DRV_LOG(ERR, "Parent RxQ has not been configured yet\n");
+ return -EINVAL;
+ }
+
+ if (nb_desc != parent_rxq->nb_rx_desc) {
+ PMD_DRV_LOG(ERR, "nb_desc %d do not match parent rxq", nb_desc);
+ return -EINVAL;
+ }
+
+ if (eth_dev->data->rx_queues) {
+ rxq = eth_dev->data->rx_queues[queue_idx];
+ if (rxq)
+ bnxt_rx_queue_release_op(rxq);
+ }
+
+ rxq = rte_zmalloc_socket("bnxt_vfr_rx_queue",
+ sizeof(struct bnxt_rx_queue),
+ RTE_CACHE_LINE_SIZE, socket_id);
+ if (!rxq) {
+ PMD_DRV_LOG(ERR, "bnxt_vfr_rx_queue allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ rxq->nb_rx_desc = nb_desc;
+
+ rc = bnxt_init_rx_ring_struct(rxq, socket_id);
+ if (rc)
+ goto out;
+
+ buf_ring = rte_zmalloc_socket("bnxt_rx_vfr_buf_ring",
+ sizeof(struct bnxt_sw_rx_bd) *
+ rxq->rx_ring->rx_ring_struct->ring_size,
+ RTE_CACHE_LINE_SIZE, socket_id);
+ if (!buf_ring) {
+ PMD_DRV_LOG(ERR, "bnxt_rx_vfr_buf_ring allocation failed!\n");
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rxq->rx_ring->rx_buf_ring = buf_ring;
+ rxq->queue_id = queue_idx;
+ rxq->port_id = eth_dev->data->port_id;
+ eth_dev->data->rx_queues[queue_idx] = rxq;
+
+ return 0;
+
+out:
+ if (rxq)
+ bnxt_rx_queue_release_op(rxq);
+
+ return rc;
+}
+
+void bnxt_vf_rep_rx_queue_release_op(void *rx_queue)
+{
+ 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);
+ bnxt_free_ring(rxq->rx_ring->ag_ring_struct);
+ bnxt_free_ring(rxq->cp_ring->cp_ring_struct);
+
+ rte_free(rxq);
+}
+
+int bnxt_vf_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_vf_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;
+ }
+
+ 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_vf_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;
+