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
|
int
|
||||||
ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
|
ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs)
|
||||||
struct ionic_queue *q, uint32_t index, uint32_t num_descs,
|
|
||||||
size_t desc_size, size_t sg_desc_size)
|
|
||||||
{
|
{
|
||||||
uint32_t ring_size;
|
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;
|
return -EINVAL;
|
||||||
|
|
||||||
ring_size = rte_log2_u32(num_descs);
|
ring_size = rte_log2_u32(num_descs);
|
||||||
|
|
||||||
if (ring_size < 2 || ring_size > 16)
|
if (ring_size < 2 || ring_size > 16)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
q->lif = lif;
|
|
||||||
q->idev = idev;
|
|
||||||
q->index = index;
|
q->index = index;
|
||||||
q->num_descs = num_descs;
|
q->num_descs = num_descs;
|
||||||
q->desc_size = desc_size;
|
q->size_mask = num_descs - 1;
|
||||||
q->sg_desc_size = sg_desc_size;
|
|
||||||
q->head_idx = 0;
|
q->head_idx = 0;
|
||||||
q->tail_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->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)
|
if (ring_doorbell)
|
||||||
ionic_q_flush(q);
|
ionic_q_flush(q);
|
||||||
|
@ -135,25 +135,21 @@ struct ionic_dev {
|
|||||||
#define IONIC_INFO_PTR(_q, _i) (&(_q)->info[IONIC_INFO_IDX((_q), _i)])
|
#define IONIC_INFO_PTR(_q, _i) (&(_q)->info[IONIC_INFO_IDX((_q), _i)])
|
||||||
|
|
||||||
struct ionic_queue {
|
struct ionic_queue {
|
||||||
struct ionic_dev *idev;
|
uint16_t num_descs;
|
||||||
struct ionic_lif *lif;
|
uint16_t head_idx;
|
||||||
uint32_t index;
|
uint16_t tail_idx;
|
||||||
uint32_t type;
|
uint16_t size_mask;
|
||||||
uint32_t hw_index;
|
uint8_t type;
|
||||||
uint32_t hw_type;
|
uint8_t hw_type;
|
||||||
void *base;
|
void *base;
|
||||||
void *sg_base;
|
void *sg_base;
|
||||||
|
struct ionic_doorbell __iomem *db;
|
||||||
void **info;
|
void **info;
|
||||||
|
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t hw_index;
|
||||||
rte_iova_t base_pa;
|
rte_iova_t base_pa;
|
||||||
rte_iova_t sg_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)
|
#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);
|
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);
|
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);
|
void *cb_arg);
|
||||||
uint32_t ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
|
uint32_t ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do,
|
||||||
ionic_cq_cb cb, void *cb_arg);
|
ionic_cq_cb cb, void *cb_arg);
|
||||||
|
|
||||||
int ionic_q_init(struct ionic_lif *lif, struct ionic_dev *idev,
|
int ionic_q_init(struct ionic_queue *q, uint32_t index, uint16_t num_descs);
|
||||||
struct ionic_queue *q, uint32_t index, 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_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_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);
|
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)
|
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)
|
if (q->head_idx >= avail)
|
||||||
avail += q->num_descs - q->head_idx - 1;
|
avail += q->num_descs - q->head_idx - 1;
|
||||||
|
@ -34,7 +34,7 @@ int
|
|||||||
ionic_qcq_enable(struct ionic_qcq *qcq)
|
ionic_qcq_enable(struct ionic_qcq *qcq)
|
||||||
{
|
{
|
||||||
struct ionic_queue *q = &qcq->q;
|
struct ionic_queue *q = &qcq->q;
|
||||||
struct ionic_lif *lif = q->lif;
|
struct ionic_lif *lif = qcq->lif;
|
||||||
struct ionic_admin_ctx ctx = {
|
struct ionic_admin_ctx ctx = {
|
||||||
.pending_work = true,
|
.pending_work = true,
|
||||||
.cmd.q_control = {
|
.cmd.q_control = {
|
||||||
@ -52,7 +52,7 @@ int
|
|||||||
ionic_qcq_disable(struct ionic_qcq *qcq)
|
ionic_qcq_disable(struct ionic_qcq *qcq)
|
||||||
{
|
{
|
||||||
struct ionic_queue *q = &qcq->q;
|
struct ionic_queue *q = &qcq->q;
|
||||||
struct ionic_lif *lif = q->lif;
|
struct ionic_lif *lif = qcq->lif;
|
||||||
struct ionic_admin_ctx ctx = {
|
struct ionic_admin_ctx ctx = {
|
||||||
.pending_work = true,
|
.pending_work = true,
|
||||||
.cmd.q_control = {
|
.cmd.q_control = {
|
||||||
@ -585,16 +585,17 @@ ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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,
|
uint32_t index,
|
||||||
const char *base, uint32_t flags,
|
const char *type_name,
|
||||||
uint32_t num_descs,
|
uint16_t flags,
|
||||||
uint32_t desc_size,
|
uint16_t num_descs,
|
||||||
uint32_t cq_desc_size,
|
uint16_t desc_size,
|
||||||
uint32_t sg_desc_size,
|
uint16_t cq_desc_size,
|
||||||
|
uint16_t sg_desc_size,
|
||||||
struct ionic_qcq **qcq)
|
struct ionic_qcq **qcq)
|
||||||
{
|
{
|
||||||
struct ionic_dev *idev = &lif->adapter->idev;
|
|
||||||
struct ionic_qcq *new;
|
struct ionic_qcq *new;
|
||||||
uint32_t q_size, cq_size, sg_size, total_size;
|
uint32_t q_size, cq_size, sg_size, total_size;
|
||||||
void *q_base, *cq_base, *sg_base;
|
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;
|
new->q.type = type;
|
||||||
|
|
||||||
err = ionic_q_init(lif, idev, &new->q, index, num_descs,
|
err = ionic_q_init(&new->q, index, num_descs);
|
||||||
desc_size, sg_desc_size);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
IONIC_PRINT(ERR, "Queue initialization failed");
|
IONIC_PRINT(ERR, "Queue initialization failed");
|
||||||
goto err_out_free_info;
|
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,
|
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);
|
total_size, IONIC_ALIGN, socket_id);
|
||||||
|
|
||||||
if (!new->base_z) {
|
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;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
flags = IONIC_QCQ_F_SG;
|
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,
|
nrxq_descs,
|
||||||
sizeof(struct ionic_rxq_desc),
|
sizeof(struct ionic_rxq_desc),
|
||||||
sizeof(struct ionic_rxq_comp),
|
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;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
flags = IONIC_QCQ_F_SG;
|
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,
|
ntxq_descs,
|
||||||
sizeof(struct ionic_txq_desc),
|
sizeof(struct ionic_txq_desc),
|
||||||
sizeof(struct ionic_txq_comp),
|
sizeof(struct ionic_txq_comp),
|
||||||
@ -770,7 +778,11 @@ ionic_admin_qcq_alloc(struct ionic_lif *lif)
|
|||||||
int err = -ENOMEM;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
flags = 0;
|
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,
|
IONIC_ADMINQ_LENGTH,
|
||||||
sizeof(struct ionic_admin_cmd),
|
sizeof(struct ionic_admin_cmd),
|
||||||
sizeof(struct ionic_admin_comp),
|
sizeof(struct ionic_admin_comp),
|
||||||
@ -790,7 +802,10 @@ ionic_notify_qcq_alloc(struct ionic_lif *lif)
|
|||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
int err = -ENOMEM;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notify",
|
err = ionic_qcq_alloc(lif,
|
||||||
|
IONIC_QTYPE_NOTIFYQ,
|
||||||
|
0,
|
||||||
|
"notify",
|
||||||
flags,
|
flags,
|
||||||
IONIC_NOTIFYQ_LENGTH,
|
IONIC_NOTIFYQ_LENGTH,
|
||||||
sizeof(struct ionic_notifyq_cmd),
|
sizeof(struct ionic_notifyq_cmd),
|
||||||
@ -1216,7 +1231,7 @@ ionic_lif_handle_fw_down(struct ionic_lif *lif)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
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_base = cq->base;
|
||||||
union ionic_notifyq_comp *cq_desc = &cq_desc_base[cq_desc_index];
|
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
|
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)
|
void *cb_arg __rte_unused)
|
||||||
{
|
{
|
||||||
struct ionic_admin_comp *cq_desc_base = cq->base;
|
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;
|
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);
|
} while (curr_q_tail_idx != stop_index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -98,7 +98,7 @@ ionic_tx_flush(struct ionic_qcq *txq)
|
|||||||
while (q->tail_idx != comp_index) {
|
while (q->tail_idx != comp_index) {
|
||||||
info = IONIC_INFO_PTR(q, q->tail_idx);
|
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 */
|
/* Prefetch the next 4 descriptors */
|
||||||
if ((q->tail_idx & 0x3) == 0)
|
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) {
|
while (nb_tx < nb_pkts) {
|
||||||
last = (nb_tx == (nb_pkts - 1));
|
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) {
|
if ((next_q_head_idx & 0x3) == 0) {
|
||||||
struct ionic_txq_desc *desc_base = q->base;
|
struct ionic_txq_desc *desc_base = q->base;
|
||||||
rte_prefetch0(&desc_base[next_q_head_idx]);
|
rte_prefetch0(&desc_base[next_q_head_idx]);
|
||||||
@ -647,7 +647,7 @@ ionic_rx_empty(struct ionic_queue *q)
|
|||||||
mbuf = info[0];
|
mbuf = info[0];
|
||||||
rte_mempool_put(rxq->mb_pool, mbuf);
|
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);
|
more = (q->tail_idx != cq_desc->comp_index);
|
||||||
|
|
||||||
curr_q_tail_idx = q->tail_idx;
|
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 */
|
/* Prefetch the next 4 descriptors */
|
||||||
if ((q->tail_idx & 0x3) == 0)
|
if ((q->tail_idx & 0x3) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user