1
2
3
4
5
6#ifndef _BCMFS_QP_H_
7#define _BCMFS_QP_H_
8
9#include <rte_memzone.h>
10
11
12#define BCMFS_MAX_HW_QUEUES 32
13
14
15#define BCMFS_HW_QUEUE_IO_ADDR_LEN (64 * 1024)
16
17
18#define BCMFS_HW_OPS_NAMESIZE 32
19
20enum bcmfs_queue_type {
21
22 BCMFS_RM_TXQ,
23
24 BCMFS_RM_CPLQ
25};
26
27#define BCMFS_QP_IOBASE_XLATE(base, idx) \
28 ((base) + ((idx) * BCMFS_HW_QUEUE_IO_ADDR_LEN))
29
30
31#define BCMFS_MAX_REQS_BUFF 64
32
33
34struct bcmfs_qp_stats {
35
36 uint64_t enqueued_count;
37
38 uint64_t dequeued_count;
39
40 uint64_t enqueue_err_count;
41
42 uint64_t dequeue_err_count;
43};
44
45struct bcmfs_qp_config {
46
47 int socket_id;
48
49 void *iobase;
50
51 uint16_t nb_descriptors;
52
53 uint16_t max_descs_req;
54
55 struct bcmfs_hw_queue_pair_ops *ops;
56};
57
58struct bcmfs_queue {
59
60 void *base_addr;
61
62 rte_iova_t base_phys_addr;
63
64 enum bcmfs_queue_type q_type;
65
66 uint32_t queue_size;
67 union {
68
69 uint32_t tx_write_ptr;
70
71 uint32_t cmpl_read_ptr;
72 };
73
74 uint16_t descs_inflight;
75
76 char memz_name[RTE_MEMZONE_NAMESIZE];
77};
78
79struct bcmfs_qp {
80
81 uint16_t qpair_id;
82
83 void *ioreg;
84
85 struct bcmfs_queue tx_q;
86
87 struct bcmfs_queue cmpl_q;
88
89 uint32_t nb_descriptors;
90
91 uint16_t nb_pending_requests;
92
93 unsigned long *ctx_pool;
94
95 void *ctx_bmp_mem;
96
97 struct rte_bitmap *ctx_bmp;
98
99 struct bcmfs_qp_stats stats;
100
101 struct bcmfs_hw_queue_pair_ops *ops;
102
103 struct rte_mempool *sr_mp;
104
105 struct bcmfs_qp_message *infl_msgs[BCMFS_MAX_REQS_BUFF];
106
107} __rte_cache_aligned;
108
109
110struct bcmfs_hw_queue_pair_ops {
111
112 char name[BCMFS_HW_OPS_NAMESIZE];
113
114 int (*enq_one_req)(struct bcmfs_qp *qp, void *obj);
115
116 void (*ring_db)(struct bcmfs_qp *qp);
117
118 uint16_t (*dequeue)(struct bcmfs_qp *qp, void **obj,
119 uint16_t nb_ops);
120
121 int (*startq)(struct bcmfs_qp *qp);
122
123 void (*stopq)(struct bcmfs_qp *qp);
124};
125
126uint16_t
127bcmfs_enqueue_op_burst(void *qp, void **ops, uint16_t nb_ops);
128uint16_t
129bcmfs_dequeue_op_burst(void *qp, void **ops, uint16_t nb_ops);
130int
131bcmfs_qp_release(struct bcmfs_qp **qp_addr);
132int
133bcmfs_qp_setup(struct bcmfs_qp **qp_addr,
134 uint16_t queue_pair_id,
135 struct bcmfs_qp_config *bcmfs_conf);
136
137
138void bcmfs_qp_stats_get(struct bcmfs_qp **qp, int num_qp,
139 struct bcmfs_qp_stats *stats);
140void bcmfs_qp_stats_reset(struct bcmfs_qp **qp, int num_qp);
141
142#endif
143