1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2020 Broadcom
9 #include <rte_memzone.h>
11 /* Maximum number of h/w queues supported by device */
12 #define BCMFS_MAX_HW_QUEUES 32
14 /* H/W queue IO address space len */
15 #define BCMFS_HW_QUEUE_IO_ADDR_LEN (64 * 1024)
17 /* Maximum size of device ops name */
18 #define BCMFS_HW_OPS_NAMESIZE 32
20 enum bcmfs_queue_type {
21 /* TX or submission queue */
23 /* Completion or receive queue */
27 struct bcmfs_qp_stats {
28 /* Count of all operations enqueued */
29 uint64_t enqueued_count;
30 /* Count of all operations dequeued */
31 uint64_t dequeued_count;
32 /* Total error count on operations enqueued */
33 uint64_t enqueue_err_count;
34 /* Total error count on operations dequeued */
35 uint64_t dequeue_err_count;
38 struct bcmfs_qp_config {
39 /* Socket to allocate memory on */
41 /* Mapped iobase for qp */
43 /* nb_descriptors or requests a h/w queue can accommodate */
44 uint16_t nb_descriptors;
45 /* Maximum number of h/w descriptors needed by a request */
46 uint16_t max_descs_req;
50 /* Base virt address */
53 rte_iova_t base_phys_addr;
55 enum bcmfs_queue_type q_type;
56 /* Queue size based on nb_descriptors and max_descs_reqs */
59 /* s/w pointer for tx h/w queue*/
60 uint32_t tx_write_ptr;
61 /* s/w pointer for completion h/w queue*/
62 uint32_t cmpl_read_ptr;
65 char memz_name[RTE_MEMZONE_NAMESIZE];
71 /* Mapped IO address */
74 struct bcmfs_queue tx_q;
75 /* A Completion queue */
76 struct bcmfs_queue cmpl_q;
77 /* Number of requests queue can accommodate */
78 uint32_t nb_descriptors;
79 /* Number of pending requests and enqueued to h/w queue */
80 uint16_t nb_pending_requests;
81 /* A pool which act as a hash for <request-ID and virt address> pair */
82 unsigned long *ctx_pool;
83 /* virt address for mem allocated for bitmap */
86 struct rte_bitmap *ctx_bmp;
87 /* Associated stats */
88 struct bcmfs_qp_stats stats;
89 /* h/w ops associated with qp */
90 struct bcmfs_hw_queue_pair_ops *ops;
92 } __rte_cache_aligned;
94 /* Structure defining h/w queue pair operations */
95 struct bcmfs_hw_queue_pair_ops {
97 char name[BCMFS_HW_OPS_NAMESIZE];
98 /* Enqueue an object */
99 int (*enq_one_req)(struct bcmfs_qp *qp, void *obj);
101 void (*ring_db)(struct bcmfs_qp *qp);
102 /* Dequeue objects */
103 uint16_t (*dequeue)(struct bcmfs_qp *qp, void **obj,
105 /* Start the h/w queue */
106 int (*startq)(struct bcmfs_qp *qp);
107 /* Stop the h/w queue */
108 void (*stopq)(struct bcmfs_qp *qp);
112 bcmfs_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops);
114 bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops);
116 bcmfs_qp_release(struct bcmfs_qp **qp_addr);
118 bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
119 uint16_t queue_pair_id,
120 struct bcmfs_qp_config *bcmfs_conf);
122 #endif /* _BCMFS_QP_H_ */