net/bnxt: support Rx queue count
[dpdk.git] / drivers / net / bnxt / bnxt_ethdev.c
index 6e5cb88..5c68797 100644 (file)
@@ -378,6 +378,7 @@ static void bnxt_dev_info_get_op(struct rte_eth_dev *eth_dev,
        dev_info->max_rx_queues = max_rx_rings;
        dev_info->max_tx_queues = max_rx_rings;
        dev_info->reta_size = bp->max_rsscos_ctx;
+       dev_info->hash_key_size = 40;
        max_vnics = bp->max_vnics;
 
        /* Fast path specifics */
@@ -837,6 +838,10 @@ static int bnxt_rss_hash_update_op(struct rte_eth_dev *eth_dev,
                if (rss_conf->rss_hf & BNXT_ETH_RSS_SUPPORT)
                        return -EINVAL;
        }
+
+       bp->flags |= BNXT_FLAG_UPDATE_HASH;
+       memcpy(&bp->rss_conf, rss_conf, sizeof(*rss_conf));
+
        if (rss_conf->rss_hf & ETH_RSS_IPV4)
                hash_type |= HWRM_VNIC_RSS_CFG_INPUT_HASH_TYPE_IPV4;
        if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP)
@@ -1522,6 +1527,51 @@ bnxt_dev_led_off_op(struct rte_eth_dev *dev)
        return bnxt_hwrm_port_led_cfg(bp, false);
 }
 
+static uint32_t
+bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)
+{
+       uint32_t desc = 0, raw_cons = 0, cons;
+       struct bnxt_cp_ring_info *cpr;
+       struct bnxt_rx_queue *rxq;
+       struct rx_pkt_cmpl *rxcmp;
+       uint16_t cmp_type;
+       uint8_t cmp = 1;
+       bool valid;
+
+       rxq = dev->data->rx_queues[rx_queue_id];
+       cpr = rxq->cp_ring;
+       valid = cpr->valid;
+
+       while (raw_cons < rxq->nb_rx_desc) {
+               cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
+               rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
+
+               if (!CMPL_VALID(rxcmp, valid))
+                       goto nothing_to_do;
+               valid = FLIP_VALID(cons, cpr->cp_ring_struct->ring_mask, valid);
+               cmp_type = CMP_TYPE(rxcmp);
+               if (cmp_type == RX_PKT_CMPL_TYPE_RX_L2_TPA_END) {
+                       cmp = (rte_le_to_cpu_32(
+                                       ((struct rx_tpa_end_cmpl *)
+                                        (rxcmp))->agg_bufs_v1) &
+                              RX_TPA_END_CMPL_AGG_BUFS_MASK) >>
+                               RX_TPA_END_CMPL_AGG_BUFS_SFT;
+                       desc++;
+               } else if (cmp_type == 0x11) {
+                       desc++;
+                       cmp = (rxcmp->agg_bufs_v1 &
+                                  RX_PKT_CMPL_AGG_BUFS_MASK) >>
+                               RX_PKT_CMPL_AGG_BUFS_SFT;
+               } else {
+                       cmp = 1;
+               }
+nothing_to_do:
+               raw_cons += cmp ? cmp : 2;
+       }
+
+       return desc;
+}
+
 /*
  * Initialization
  */
@@ -1569,6 +1619,9 @@ static const struct eth_dev_ops bnxt_dev_ops = {
        .txq_info_get = bnxt_txq_info_get_op,
        .dev_led_on = bnxt_dev_led_on_op,
        .dev_led_off = bnxt_dev_led_off_op,
+       .xstats_get_by_id = bnxt_dev_xstats_get_by_id_op,
+       .xstats_get_names_by_id = bnxt_dev_xstats_get_names_by_id_op,
+       .rx_queue_count = bnxt_rx_queue_count_op,
 };
 
 static bool bnxt_vf_pciid(uint16_t id)
@@ -1648,6 +1701,9 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
        rte_atomic64_init(&bp->rx_mbuf_alloc_fail);
        bp->dev_stopped = 1;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               goto skip_init;
+
        if (bnxt_vf_pciid(pci_dev->id.device_id))
                bp->flags |= BNXT_FLAG_VF;
 
@@ -1657,7 +1713,10 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
                        "Board initialization failed rc: %x\n", rc);
                goto error;
        }
+skip_init:
        eth_dev->dev_ops = &bnxt_dev_ops;
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return 0;
        eth_dev->rx_pkt_burst = &bnxt_recv_pkts;
        eth_dev->tx_pkt_burst = &bnxt_xmit_pkts;
 
@@ -1882,6 +1941,9 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
        struct bnxt *bp = eth_dev->data->dev_private;
        int rc;
 
+       if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+               return -EPERM;
+
        bnxt_disable_int(bp);
        bnxt_free_int(bp);
        bnxt_free_mem(bp);