net/bnxt: improve small ring sizes support
[dpdk.git] / drivers / net / bnxt / bnxt_rxq.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2014-2018 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _BNXT_RQX_H_
7 #define _BNXT_RQX_H_
8
9 /* Maximum receive burst supported in vector mode. */
10 #define RTE_BNXT_MAX_RX_BURST           32U
11
12 struct bnxt;
13 struct bnxt_rx_ring_info;
14 struct bnxt_cp_ring_info;
15 struct bnxt_rx_queue {
16         rte_spinlock_t          lock;   /* Synchronize between rx_queue_stop
17                                          * and fast path
18                                          */
19         struct rte_mempool      *mb_pool; /* mbuf pool for RX ring */
20         struct rte_mbuf         *pkt_first_seg; /* 1st seg of pkt */
21         struct rte_mbuf         *pkt_last_seg; /* Last seg of pkt */
22         uint64_t                mbuf_initializer; /* val to init mbuf */
23         uint16_t                nb_rx_desc; /* num of RX desc */
24         uint16_t                rx_tail; /* cur val of RDT register */
25         uint16_t                nb_rx_hold; /* num held free RX desc */
26         uint16_t                rx_free_thresh; /* max free RX desc to hold */
27         uint16_t                queue_id; /* RX queue index */
28 #if defined(RTE_ARCH_X86) || defined(RTE_ARCH_ARM64)
29         uint16_t                rxrearm_nb; /* number of descs to reinit. */
30         uint16_t                rxrearm_start; /* next desc index to reinit. */
31 #endif
32         uint16_t                reg_idx; /* RX queue register index */
33         uint16_t                port_id; /* Device port identifier */
34         uint8_t                 crc_len; /* 0 if CRC stripped, 4 otherwise */
35         uint8_t                 rx_deferred_start; /* not in global dev start */
36         uint8_t                 rx_started; /* RX queue is started */
37
38         struct bnxt             *bp;
39         int                     index;
40         struct bnxt_vnic_info   *vnic;
41
42         uint32_t                        rx_buf_size;
43         struct bnxt_rx_ring_info        *rx_ring;
44         struct bnxt_cp_ring_info        *cp_ring;
45         rte_atomic64_t          rx_mbuf_alloc_fail;
46         const struct rte_memzone *mz;
47 };
48
49 void bnxt_free_rxq_stats(struct bnxt_rx_queue *rxq);
50 int bnxt_mq_rx_configure(struct bnxt *bp);
51 void bnxt_rx_queue_release_op(void *rx_queue);
52 int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev,
53                                uint16_t queue_idx,
54                                uint16_t nb_desc,
55                                unsigned int socket_id,
56                                const struct rte_eth_rxconf *rx_conf,
57                                struct rte_mempool *mp);
58 void bnxt_free_rx_mbufs(struct bnxt *bp);
59 int bnxt_rx_queue_intr_enable_op(struct rte_eth_dev *eth_dev,
60                                  uint16_t queue_id);
61 int bnxt_rx_queue_intr_disable_op(struct rte_eth_dev *eth_dev,
62                                   uint16_t queue_id);
63 int bnxt_rx_queue_start(struct rte_eth_dev *dev,
64                         uint16_t rx_queue_id);
65 int bnxt_rx_queue_stop(struct rte_eth_dev *dev,
66                        uint16_t rx_queue_id);
67 void bnxt_rx_queue_release_mbufs(struct bnxt_rx_queue *rxq);
68 #endif