net/ionic: cut down queue structure
This will conserve resources. Rename ionic_qcq_alloc() arg from 'base' to 'type_name' for clarity. Signed-off-by: Andrew Boyer <aboyer@pensando.io>
This commit is contained in:
parent
aeb70a00b1
commit
4ad56b7a7c
@ -405,26 +405,20 @@ ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -450,7 +444,7 @@ ionic_q_post(struct ionic_queue *q, bool ring_doorbell, void *cb_arg)
|
||||
{
|
||||
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);
|
||||
|
@ -135,25 +135,21 @@ struct ionic_dev {
|
||||
#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)
|
||||
@ -220,22 +216,20 @@ struct ionic_doorbell __iomem *ionic_db_map(struct ionic_lif *lif,
|
||||
|
||||
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;
|
||||
|
@ -34,7 +34,7 @@ int
|
||||
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 = {
|
||||
@ -52,7 +52,7 @@ int
|
||||
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 = {
|
||||
@ -585,16 +585,17 @@ ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr)
|
||||
}
|
||||
|
||||
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;
|
||||
@ -642,8 +643,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
|
||||
|
||||
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;
|
||||
@ -656,7 +656,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -727,7 +727,11 @@ ionic_rx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t nrxq_descs,
|
||||
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),
|
||||
@ -749,7 +753,11 @@ ionic_tx_qcq_alloc(struct ionic_lif *lif, uint32_t index, uint16_t ntxq_descs,
|
||||
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),
|
||||
@ -770,7 +778,11 @@ ionic_admin_qcq_alloc(struct ionic_lif *lif)
|
||||
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),
|
||||
@ -790,7 +802,10 @@ ionic_notify_qcq_alloc(struct ionic_lif *lif)
|
||||
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),
|
||||
@ -1216,7 +1231,7 @@ ionic_lif_handle_fw_down(struct ionic_lif *lif)
|
||||
}
|
||||
|
||||
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];
|
||||
|
@ -146,7 +146,7 @@ ionic_adminq_check_err(struct ionic_admin_ctx *ctx, bool timeout)
|
||||
}
|
||||
|
||||
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;
|
||||
@ -174,7 +174,7 @@ ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_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);
|
||||
} while (curr_q_tail_idx != stop_index);
|
||||
|
||||
return true;
|
||||
|
@ -98,7 +98,7 @@ ionic_tx_flush(struct ionic_qcq *txq)
|
||||
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)
|
||||
@ -540,7 +540,7 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
|
||||
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]);
|
||||
@ -647,7 +647,7 @@ ionic_rx_empty(struct ionic_queue *q)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1055,7 +1055,7 @@ ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do,
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user