This will conserve resources.
Rename ionic_qcq_alloc() arg from 'base' to 'type_name' for clarity.
Signed-off-by: Andrew Boyer <aboyer@pensando.io>
}
int
-ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
- struct ionic_queue *q, uint32_t index, uint32_t num_descs,
- size_t desc_size, size_t sg_desc_size)
+ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs)
{
uint32_t ring_size;
- if (desc_size == 0 || !rte_is_power_of_2(num_descs))
+ if (!rte_is_power_of_2(num_descs))
return -EINVAL;
ring_size = rte_log2_u32(num_descs);
-
if (ring_size < 2 || ring_size > 16)
return -EINVAL;
- q->lif = lif;
- q->idev = idev;
q->index = index;
q->num_descs = num_descs;
- q->desc_size = desc_size;
- q->sg_desc_size = sg_desc_size;
+ q->size_mask = num_descs - 1;
q->head_idx = 0;
q->tail_idx = 0;
{
q->info[q->head_idx] = cb_arg;
- q->head_idx = (q->head_idx + 1) & (q->num_descs - 1);
+ q->head_idx = Q_NEXT_TO_POST(q, 1);
if (ring_doorbell)
ionic_q_flush(q);
#define IONIC_INFO_PTR(_q, _i) (&(_q)->info[IONIC_INFO_IDX((_q), _i)])
struct ionic_queue {
- struct ionic_dev *idev;
- struct ionic_lif *lif;
- uint32_t index;
- uint32_t type;
- uint32_t hw_index;
- uint32_t hw_type;
+ uint16_t num_descs;
+ uint16_t head_idx;
+ uint16_t tail_idx;
+ uint16_t size_mask;
+ uint8_t type;
+ uint8_t hw_type;
void *base;
void *sg_base;
+ struct ionic_doorbell __iomem *db;
void **info;
+
+ uint32_t index;
+ uint32_t hw_index;
rte_iova_t base_pa;
rte_iova_t sg_base_pa;
- uint32_t tail_idx;
- uint32_t head_idx;
- uint32_t num_descs;
- uint32_t desc_size;
- uint32_t sg_desc_size;
- uint32_t qid;
- uint32_t qtype;
- struct ionic_doorbell __iomem *db;
};
#define IONIC_INTR_NONE (-1)
int ionic_cq_init(struct ionic_cq *cq, uint16_t num_descs);
void ionic_cq_map(struct ionic_cq *cq, void *base, rte_iova_t base_pa);
-typedef bool (*ionic_cq_cb)(struct ionic_cq *cq, uint32_t cq_desc_index,
+typedef bool (*ionic_cq_cb)(struct ionic_cq *cq, uint16_t cq_desc_index,
void *cb_arg);
uint32_t ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
ionic_cq_cb cb, void *cb_arg);
-int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
- struct ionic_queue *q, uint32_t index, uint32_t num_descs,
- size_t desc_size, size_t sg_desc_size);
+int ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs);
void ionic_q_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
void ionic_q_sg_map(struct ionic_queue *q, void *base, rte_iova_t base_pa);
void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg);
-static inline uint32_t
+static inline uint16_t
ionic_q_space_avail(struct ionic_queue *q)
{
- uint32_t avail = q->tail_idx;
+ uint16_t avail = q->tail_idx;
if (q->head_idx >= avail)
avail += q->num_descs - q->head_idx - 1;
ionic_qcq_enable(struct ionic_qcq *qcq)
{
struct ionic_queue *q = &qcq->q;
- struct ionic_lif *lif = q->lif;
+ struct ionic_lif *lif = qcq->lif;
struct ionic_admin_ctx ctx = {
.pending_work = true,
.cmd.q_control = {
ionic_qcq_disable(struct ionic_qcq *qcq)
{
struct ionic_queue *q = &qcq->q;
- struct ionic_lif *lif = q->lif;
+ struct ionic_lif *lif = qcq->lif;
struct ionic_admin_ctx ctx = {
.pending_work = true,
.cmd.q_control = {
}
static int
-ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
+ionic_qcq_alloc(struct ionic_lif *lif,
+ uint8_t type,
uint32_t index,
- const char *base, uint32_t flags,
- uint32_t num_descs,
- uint32_t desc_size,
- uint32_t cq_desc_size,
- uint32_t sg_desc_size,
+ const char *type_name,
+ uint16_t flags,
+ uint16_t num_descs,
+ uint16_t desc_size,
+ uint16_t cq_desc_size,
+ uint16_t sg_desc_size,
struct ionic_qcq **qcq)
{
- struct ionic_dev *idev = &lif->adapter->idev;
struct ionic_qcq *new;
uint32_t q_size, cq_size, sg_size, total_size;
void *q_base, *cq_base, *sg_base;
new->q.type = type;
- err = ionic_q_init(lif, idev, &new->q, index, num_descs,
- desc_size, sg_desc_size);
+ err = ionic_q_init(&new->q, index, num_descs);
if (err) {
IONIC_PRINT(ERR, "Queue initialization failed");
goto err_out_free_info;
}
new->base_z = rte_eth_dma_zone_reserve(lif->eth_dev,
- base /* name */, index /* queue_idx */,
+ type_name, index /* queue_idx */,
total_size, IONIC_ALIGN, socket_id);
if (!new->base_z) {
int err = -ENOMEM;
flags = IONIC_QCQ_F_SG;
- err = ionic_qcq_alloc(lif, IONIC_QTYPE_RXQ, index, "rx", flags,
+ err = ionic_qcq_alloc(lif,
+ IONIC_QTYPE_RXQ,
+ index,
+ "rx",
+ flags,
nrxq_descs,
sizeof(struct ionic_rxq_desc),
sizeof(struct ionic_rxq_comp),
int err = -ENOMEM;
flags = IONIC_QCQ_F_SG;
- err = ionic_qcq_alloc(lif, IONIC_QTYPE_TXQ, index, "tx", flags,
+ err = ionic_qcq_alloc(lif,
+ IONIC_QTYPE_TXQ,
+ index,
+ "tx",
+ flags,
ntxq_descs,
sizeof(struct ionic_txq_desc),
sizeof(struct ionic_txq_comp),
int err = -ENOMEM;
flags = 0;
- err = ionic_qcq_alloc(lif, IONIC_QTYPE_ADMINQ, 0, "admin", flags,
+ err = ionic_qcq_alloc(lif,
+ IONIC_QTYPE_ADMINQ,
+ 0,
+ "admin",
+ flags,
IONIC_ADMINQ_LENGTH,
sizeof(struct ionic_admin_cmd),
sizeof(struct ionic_admin_comp),
uint32_t flags = 0;
int err = -ENOMEM;
- err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notify",
+ err = ionic_qcq_alloc(lif,
+ IONIC_QTYPE_NOTIFYQ,
+ 0,
+ "notify",
flags,
IONIC_NOTIFYQ_LENGTH,
sizeof(struct ionic_notifyq_cmd),
}
static bool
-ionic_notifyq_cb(struct ionic_cq *cq, uint32_t cq_desc_index, void *cb_arg)
+ionic_notifyq_cb(struct ionic_cq *cq, uint16_t cq_desc_index, void *cb_arg)
{
union ionic_notifyq_comp *cq_desc_base = cq->base;
union ionic_notifyq_comp *cq_desc = &cq_desc_base[cq_desc_index];
}
static bool
-ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index,
+ionic_adminq_service(struct ionic_cq *cq, uint16_t cq_desc_index,
void *cb_arg __rte_unused)
{
struct ionic_admin_comp *cq_desc_base = cq->base;
}
curr_q_tail_idx = q->tail_idx;
- q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+ q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
} while (curr_q_tail_idx != stop_index);
return true;
while (q->tail_idx != comp_index) {
info = IONIC_INFO_PTR(q, q->tail_idx);
- q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+ q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
/* Prefetch the next 4 descriptors */
if ((q->tail_idx & 0x3) == 0)
while (nb_tx < nb_pkts) {
last = (nb_tx == (nb_pkts - 1));
- next_q_head_idx = (q->head_idx + 1) & (q->num_descs - 1);
+ next_q_head_idx = Q_NEXT_TO_POST(q, 1);
if ((next_q_head_idx & 0x3) == 0) {
struct ionic_txq_desc *desc_base = q->base;
rte_prefetch0(&desc_base[next_q_head_idx]);
mbuf = info[0];
rte_mempool_put(rxq->mb_pool, mbuf);
- q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+ q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
}
}
more = (q->tail_idx != cq_desc->comp_index);
curr_q_tail_idx = q->tail_idx;
- q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
+ q->tail_idx = Q_NEXT_TO_SRVC(q, 1);
/* Prefetch the next 4 descriptors */
if ((q->tail_idx & 0x3) == 0)