uint32_t port_info_sz;
};
-struct ionic_queue;
-struct ionic_desc_info;
-
-typedef void (*desc_cb)(struct ionic_queue *q,
- uint32_t q_desc_index,
- uint32_t cq_desc_index,
- void *cb_arg, void *service_cb_arg);
-
-struct ionic_desc_info {
- desc_cb cb;
- void *cb_arg;
-};
-
#define Q_NEXT_TO_POST(_q, _n) (((_q)->head_idx + (_n)) & ((_q)->size_mask))
#define Q_NEXT_TO_SRVC(_q, _n) (((_q)->tail_idx + (_n)) & ((_q)->size_mask))
+#define IONIC_INFO_IDX(_q, _i) (_i)
+#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 hw_type;
void *base;
void *sg_base;
+ void **info;
rte_iova_t base_pa;
rte_iova_t sg_base_pa;
- struct ionic_desc_info *info;
uint32_t tail_idx;
uint32_t head_idx;
uint32_t num_descs;
size_t desc_size, size_t sg_desc_size);
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, desc_cb cb,
- void *cb_arg);
+void ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg);
static inline uint32_t
ionic_q_space_avail(struct ionic_queue *q)
struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq);
struct ionic_queue *q = &qcq->q;
struct ionic_admin_ctx *ctx;
- struct ionic_desc_info *desc_info;
uint16_t curr_q_tail_idx;
uint16_t stop_index;
+ void **info;
if (!color_match(cq_desc->color, cq->done_color))
return false;
stop_index = rte_le_to_cpu_16(cq_desc->comp_index);
do {
- desc_info = &q->info[q->tail_idx];
+ info = IONIC_INFO_PTR(q, q->tail_idx);
- ctx = desc_info->cb_arg;
+ ctx = info[0];
if (ctx) {
memcpy(&ctx->comp, cq_desc, sizeof(*cq_desc));
memcpy(q_desc, &ctx->cmd, sizeof(ctx->cmd));
- ionic_q_post(q, true, NULL, ctx);
+ ionic_q_post(q, true, ctx);
err_out:
rte_spinlock_unlock(&lif->adminq_lock);
{
struct ionic_cq *cq = &txq->cq;
struct ionic_queue *q = &txq->q;
- struct ionic_desc_info *q_desc_info;
struct rte_mbuf *txm, *next;
struct ionic_txq_comp *cq_desc_base = cq->base;
struct ionic_txq_comp *cq_desc;
+ void **info;
u_int32_t comp_index = (u_int32_t)-1;
cq_desc = &cq_desc_base[cq->tail_idx];
if (comp_index != (u_int32_t)-1) {
while (q->tail_idx != comp_index) {
- q_desc_info = &q->info[q->tail_idx];
+ info = IONIC_INFO_PTR(q, q->tail_idx);
q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
* Note: you can just use rte_pktmbuf_free,
* but this loop is faster
*/
- txm = q_desc_info->cb_arg;
+ txm = info[0];
while (txm != NULL) {
next = txm->next;
rte_pktmbuf_free_seg(txm);
desc->hdr_len = hdrlen;
desc->mss = mss;
- ionic_q_post(q, done, NULL, done ? txm : NULL);
+ ionic_q_post(q, done, done ? txm : NULL);
}
static struct ionic_txq_desc *
txm_seg = txm_seg->next;
}
- ionic_q_post(q, not_xmit_more, NULL, txm);
+ ionic_q_post(q, not_xmit_more, txm);
return 0;
}
ionic_rx_empty(struct ionic_queue *q)
{
struct ionic_qcq *rxq = IONIC_Q_TO_QCQ(q);
- struct ionic_desc_info *cur;
struct rte_mbuf *mbuf;
+ void **info;
while (q->tail_idx != q->head_idx) {
- cur = &q->info[q->tail_idx];
- mbuf = cur->cb_arg;
+ info = IONIC_INFO_PTR(q, q->tail_idx);
+ mbuf = info[0];
rte_mempool_put(rxq->mb_pool, mbuf);
q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
static __rte_always_inline void
ionic_rx_clean(struct ionic_queue *q,
uint32_t q_desc_index, uint32_t cq_desc_index,
- void *cb_arg, void *service_cb_arg)
+ void *service_cb_arg)
{
struct ionic_rxq_comp *cq_desc_base = q->bound_cq->base;
struct ionic_rxq_comp *cq_desc = &cq_desc_base[cq_desc_index];
- struct rte_mbuf *rxm = cb_arg;
- struct rte_mbuf *rxm_seg;
+ struct rte_mbuf *rxm, *rxm_seg;
struct ionic_qcq *rxq = IONIC_Q_TO_QCQ(q);
uint32_t max_frame_size =
rxq->lif->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len;
(rte_pktmbuf_data_room_size(rxq->mb_pool) -
RTE_PKTMBUF_HEADROOM);
uint32_t left;
+ void **info;
+
+ assert(q_desc_index == cq_desc->comp_index);
+
+ info = IONIC_INFO_PTR(q, cq_desc->comp_index);
+
+ rxm = info[0];
if (!recv_args) {
stats->no_cb_arg++;
new->addr = old->addr;
new->len = old->len;
- ionic_q_post(q, true, ionic_rx_clean, mbuf);
+ ionic_q_post(q, true, mbuf);
}
static __rte_always_inline int
ring_doorbell = ((q->head_idx + 1) &
IONIC_RX_RING_DOORBELL_STRIDE) == 0;
- ionic_q_post(q, ring_doorbell, ionic_rx_clean, rxm);
+ ionic_q_post(q, ring_doorbell, rxm);
}
return 0;
{
struct ionic_cq *cq = &rxq->cq;
struct ionic_queue *q = &rxq->q;
- struct ionic_desc_info *q_desc_info;
struct ionic_rxq_comp *cq_desc_base = cq->base;
struct ionic_rxq_comp *cq_desc;
bool more;
do {
more = (q->tail_idx != cq_desc->comp_index);
- q_desc_info = &q->info[q->tail_idx];
-
curr_q_tail_idx = q->tail_idx;
q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);
rte_prefetch0(&q->info[q->tail_idx]);
ionic_rx_clean(q, curr_q_tail_idx, curr_cq_tail_idx,
- q_desc_info->cb_arg, service_cb_arg);
+ service_cb_arg);
} while (more);