[dpdk-dev,3/8] net/bnxt: add support for rx_descriptor_status
Checks
Commit Message
add support for rx_descriptor_status dev_op
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt_ethdev.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
Comments
On 8/24/2017 5:29 PM, Ajit Khaparde wrote:
> add support for rx_descriptor_status dev_op
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
<...>
> +static int
> +bnxt_rx_descriptor_status_op(void *rx_queue, uint16_t offset)
> +{
> + struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
> + struct bnxt_cp_ring_info *cpr;
> + struct rx_pkt_cmpl *rxcmp;
> + uint32_t cons;
> +
> + if (!rxq)
> + return -EINVAL;
> +
> + cpr = rxq->cp_ring;
> +
> + if (offset >= rxq->nb_rx_desc)
> + return -EINVAL;
> +
> + cons = RING_CMP(cpr->cp_ring_struct, offset);
> + rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
> +
> + if (CMP_VALID(rxcmp, offset, cpr->cp_ring_struct))
> + return RTE_ETH_RX_DESC_DONE;
> +
> + return RTE_ETH_RX_DESC_AVAIL;
Do we need a check to be sure if descriptor is available. Is PMD using
rx_free_thresh?
If so descriptor can be in a state that packet parsed by software but
descriptor not freed yet: RTE_ETH_RX_DESC_UNAVAIL
> +}
<...>
@@ -1539,6 +1539,31 @@ bnxt_rx_queue_count_op(struct rte_eth_dev *dev, uint16_t rx_queue_id)
return desc;
}
+static int
+bnxt_rx_descriptor_status_op(void *rx_queue, uint16_t offset)
+{
+ struct bnxt_rx_queue *rxq = (struct bnxt_rx_queue *)rx_queue;
+ struct bnxt_cp_ring_info *cpr;
+ struct rx_pkt_cmpl *rxcmp;
+ uint32_t cons;
+
+ if (!rxq)
+ return -EINVAL;
+
+ cpr = rxq->cp_ring;
+
+ if (offset >= rxq->nb_rx_desc)
+ return -EINVAL;
+
+ cons = RING_CMP(cpr->cp_ring_struct, offset);
+ rxcmp = (struct rx_pkt_cmpl *)&cpr->cp_desc_ring[cons];
+
+ if (CMP_VALID(rxcmp, offset, cpr->cp_ring_struct))
+ return RTE_ETH_RX_DESC_DONE;
+
+ return RTE_ETH_RX_DESC_AVAIL;
+}
+
/*
* Initialization
*/
@@ -1589,6 +1614,7 @@ static const struct eth_dev_ops bnxt_dev_ops = {
.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,
+ .rx_descriptor_status = bnxt_rx_descriptor_status_op,
};
static bool bnxt_vf_pciid(uint16_t id)