1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
12 struct nitrox_softreq;
14 struct command_queue {
15 const struct rte_memzone *mz;
16 uint8_t *dbell_csr_addr;
22 struct nitrox_softreq *sr;
26 struct command_queue cmdq;
31 struct rte_mempool *sr_mp;
32 struct rte_cryptodev_stats stats;
34 rte_atomic16_t pending_count;
37 static inline uint16_t
38 nitrox_qp_free_count(struct nitrox_qp *qp)
40 uint16_t pending_count = rte_atomic16_read(&qp->pending_count);
42 RTE_ASSERT(qp->count >= pending_count);
43 return (qp->count - pending_count);
47 nitrox_qp_is_empty(struct nitrox_qp *qp)
49 return (rte_atomic16_read(&qp->pending_count) == 0);
52 static inline uint16_t
53 nitrox_qp_used_count(struct nitrox_qp *qp)
55 return rte_atomic16_read(&qp->pending_count);
58 static inline struct nitrox_softreq *
59 nitrox_qp_get_softreq(struct nitrox_qp *qp)
61 uint32_t tail = qp->tail % qp->count;
64 return qp->ridq[tail].sr;
68 nitrox_ring_dbell(struct nitrox_qp *qp, uint16_t cnt)
70 struct command_queue *cmdq = &qp->cmdq;
76 rte_write64(cnt, cmdq->dbell_csr_addr);
80 nitrox_qp_enqueue(struct nitrox_qp *qp, void *instr, struct nitrox_softreq *sr)
82 uint32_t head = qp->head % qp->count;
85 memcpy(&qp->cmdq.ring[head * qp->cmdq.instr_size],
86 instr, qp->cmdq.instr_size);
87 qp->ridq[head].sr = sr;
89 rte_atomic16_inc(&qp->pending_count);
93 nitrox_qp_dequeue(struct nitrox_qp *qp)
96 rte_atomic16_dec(&qp->pending_count);
99 int nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr,
100 const char *dev_name, uint32_t nb_descriptors,
101 uint8_t inst_size, int socket_id);
102 int nitrox_qp_release(struct nitrox_qp *qp, uint8_t *bar_addr);
104 #endif /* _NITROX_QP_H_ */