[dpdk-dev] [PATCH 01/13] net/ionic: strip out unneeded interrupt code

Andrew Boyer aboyer at pensando.io
Mon Jan 18 21:34:56 CET 2021


Only the NotifyQ uses an interrupt, so simplify the other queues.

Simplify ionic_dev_cmd_adminq_init() and ionic_cq_init().
Move ionic_intr_alloc() into ionic_notify_qcq_alloc().
Create ionic_lif_notifyq_deinit().
Simplify ionic_lif_qcq_deinit().
Remove unneeded flags and defines.

Signed-off-by: Andrew Boyer <aboyer at pensando.io>
---
 drivers/net/ionic/ionic_dev.c |   8 +--
 drivers/net/ionic/ionic_dev.h |  12 ++--
 drivers/net/ionic/ionic_lif.c | 116 ++++++++++++++++------------------
 drivers/net/ionic/ionic_lif.h |   2 -
 4 files changed, 59 insertions(+), 79 deletions(-)

diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c
index 4b5e24f98c..3507d4166f 100644
--- a/drivers/net/ionic/ionic_dev.c
+++ b/drivers/net/ionic/ionic_dev.c
@@ -323,9 +323,7 @@ ionic_intr_init(struct ionic_dev *idev, struct ionic_intr_info *intr,
 }
 
 void
-ionic_dev_cmd_adminq_init(struct ionic_dev *idev,
-		struct ionic_qcq *qcq,
-		uint16_t intr_index)
+ionic_dev_cmd_adminq_init(struct ionic_dev *idev, struct ionic_qcq *qcq)
 {
 	struct ionic_queue *q = &qcq->q;
 	struct ionic_cq *cq = &qcq->cq;
@@ -335,7 +333,7 @@ ionic_dev_cmd_adminq_init(struct ionic_dev *idev,
 		.q_init.type = q->type,
 		.q_init.index = q->index,
 		.q_init.flags = IONIC_QINIT_F_ENA,
-		.q_init.intr_index = intr_index,
+		.q_init.intr_index = IONIC_INTR_NONE,
 		.q_init.ring_size = rte_log2_u32(q->num_descs),
 		.q_init.ring_base = q->base_pa,
 		.q_init.cq_ring_base = cq->base_pa,
@@ -348,7 +346,6 @@ ionic_dev_cmd_adminq_init(struct ionic_dev *idev,
 
 int
 ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
-		struct ionic_intr_info *intr,
 		uint32_t num_descs, size_t desc_size)
 {
 	if (desc_size == 0) {
@@ -365,7 +362,6 @@ ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
 	}
 
 	cq->lif = lif;
-	cq->bound_intr = intr;
 	cq->num_descs = num_descs;
 	cq->desc_size = desc_size;
 	cq->tail_idx = 0;
diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h
index 6588a373fc..6ee2918959 100644
--- a/drivers/net/ionic/ionic_dev.h
+++ b/drivers/net/ionic/ionic_dev.h
@@ -165,11 +165,9 @@ struct ionic_queue {
 	struct ionic_doorbell __iomem *db;
 };
 
-#define IONIC_INTR_INDEX_NOT_ASSIGNED	(-1)
-#define IONIC_INTR_NAME_MAX_SZ		(32)
+#define IONIC_INTR_NONE		(-1)
 
 struct ionic_intr_info {
-	char name[IONIC_INTR_NAME_MAX_SZ];
 	int index;
 	uint32_t vector;
 	struct ionic_intr __iomem *ctrl;
@@ -184,7 +182,6 @@ struct ionic_cq {
 	bool done_color;
 	void *base;
 	rte_iova_t base_pa;
-	struct ionic_intr_info *bound_intr;
 };
 
 /** ionic_admin_ctx - Admin command context.
@@ -234,15 +231,14 @@ void ionic_dev_cmd_lif_identify(struct ionic_dev *idev, uint8_t type,
 	uint8_t ver);
 void ionic_dev_cmd_lif_init(struct ionic_dev *idev, rte_iova_t addr);
 void ionic_dev_cmd_lif_reset(struct ionic_dev *idev);
-void ionic_dev_cmd_adminq_init(struct ionic_dev *idev, struct ionic_qcq *qcq,
-	uint16_t intr_index);
+
+void ionic_dev_cmd_adminq_init(struct ionic_dev *idev, struct ionic_qcq *qcq);
 
 struct ionic_doorbell __iomem *ionic_db_map(struct ionic_lif *lif,
 	struct ionic_queue *q);
 
 int ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq,
-	struct ionic_intr_info *intr, uint32_t num_descs,
-	size_t desc_size);
+	uint32_t num_descs, size_t desc_size);
 void ionic_cq_map(struct ionic_cq *cq, void *base, rte_iova_t base_pa);
 void ionic_cq_bind(struct ionic_cq *cq, struct ionic_queue *q);
 typedef bool (*ionic_cq_cb)(struct ionic_cq *cq, uint32_t cq_desc_index,
diff --git a/drivers/net/ionic/ionic_lif.c b/drivers/net/ionic/ionic_lif.c
index f39b54e8ef..856e977186 100644
--- a/drivers/net/ionic/ionic_lif.c
+++ b/drivers/net/ionic/ionic_lif.c
@@ -20,7 +20,6 @@ ionic_qcq_enable(struct ionic_qcq *qcq)
 {
 	struct ionic_queue *q = &qcq->q;
 	struct ionic_lif *lif = q->lif;
-	struct ionic_dev *idev = &lif->adapter->idev;
 	struct ionic_admin_ctx ctx = {
 		.pending_work = true,
 		.cmd.q_control = {
@@ -31,11 +30,6 @@ ionic_qcq_enable(struct ionic_qcq *qcq)
 		},
 	};
 
-	if (qcq->flags & IONIC_QCQ_F_INTR) {
-		ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
-			IONIC_INTR_MASK_CLEAR);
-	}
-
 	return ionic_adminq_post_wait(lif, &ctx);
 }
 
@@ -44,7 +38,6 @@ ionic_qcq_disable(struct ionic_qcq *qcq)
 {
 	struct ionic_queue *q = &qcq->q;
 	struct ionic_lif *lif = q->lif;
-	struct ionic_dev *idev = &lif->adapter->idev;
 	struct ionic_admin_ctx ctx = {
 		.pending_work = true,
 		.cmd.q_control = {
@@ -55,11 +48,6 @@ ionic_qcq_disable(struct ionic_qcq *qcq)
 		},
 	};
 
-	if (qcq->flags & IONIC_QCQ_F_INTR) {
-		ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
-			IONIC_INTR_MASK_SET);
-	}
-
 	return ionic_adminq_post_wait(lif, &ctx);
 }
 
@@ -584,7 +572,7 @@ ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr)
 void
 ionic_intr_free(struct ionic_lif *lif, struct ionic_intr_info *intr)
 {
-	if (intr->index != IONIC_INTR_INDEX_NOT_ASSIGNED)
+	if (intr->index != IONIC_INTR_NONE)
 		lif->adapter->intrs[intr->index] = false;
 }
 
@@ -640,7 +628,8 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	new->q.info = rte_zmalloc("ionic", sizeof(*new->q.info) * num_descs, 0);
 	if (!new->q.info) {
 		IONIC_PRINT(ERR, "Cannot allocate queue info");
-		return -ENOMEM;
+		err = -ENOMEM;
+		goto err_out_free_qcq;
 	}
 
 	new->q.type = type;
@@ -649,25 +638,13 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 		desc_size, sg_desc_size);
 	if (err) {
 		IONIC_PRINT(ERR, "Queue initialization failed");
-		return err;
+		goto err_out_free_info;
 	}
 
-	if (flags & IONIC_QCQ_F_INTR) {
-		err = ionic_intr_alloc(lif, &new->intr);
-		if (err)
-			return err;
-
-		ionic_intr_mask_assert(idev->intr_ctrl, new->intr.index,
-			IONIC_INTR_MASK_SET);
-	} else {
-		new->intr.index = IONIC_INTR_INDEX_NOT_ASSIGNED;
-	}
-
-	err = ionic_cq_init(lif, &new->cq, &new->intr,
-		num_descs, cq_desc_size);
+	err = ionic_cq_init(lif, &new->cq, num_descs, cq_desc_size);
 	if (err) {
 		IONIC_PRINT(ERR, "Completion queue initialization failed");
-		goto err_out_free_intr;
+		goto err_out_free_info;
 	}
 
 	new->base_z = rte_eth_dma_zone_reserve(lif->eth_dev,
@@ -677,7 +654,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 	if (!new->base_z) {
 		IONIC_PRINT(ERR, "Cannot reserve queue DMA memory");
 		err = -ENOMEM;
-		goto err_out_free_intr;
+		goto err_out_free_info;
 	}
 
 	new->base = new->base_z->addr;
@@ -709,9 +686,10 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type,
 
 	return 0;
 
-err_out_free_intr:
-	if (flags & IONIC_QCQ_F_INTR)
-		ionic_intr_free(lif, &new->intr);
+err_out_free_info:
+	rte_free(new->q.info);
+err_out_free_qcq:
+	rte_free(new);
 
 	return err;
 }
@@ -800,21 +778,32 @@ ionic_admin_qcq_alloc(struct ionic_lif *lif)
 static int
 ionic_notify_qcq_alloc(struct ionic_lif *lif)
 {
-	uint32_t flags;
+	struct ionic_qcq *nqcq;
+	struct ionic_dev *idev = &lif->adapter->idev;
+	uint32_t flags = 0;
 	int err = -ENOMEM;
 
-	flags = IONIC_QCQ_F_NOTIFYQ | IONIC_QCQ_F_INTR;
-
 	err = ionic_qcq_alloc(lif, IONIC_QTYPE_NOTIFYQ, 0, "notify",
 		flags,
 		IONIC_NOTIFYQ_LENGTH,
 		sizeof(struct ionic_notifyq_cmd),
 		sizeof(union ionic_notifyq_comp),
 		0,
-		&lif->notifyqcq);
+		&nqcq);
 	if (err)
 		return err;
 
+	err = ionic_intr_alloc(lif, &nqcq->intr);
+	if (err) {
+		ionic_qcq_free(nqcq);
+		return err;
+	}
+
+	ionic_intr_mask_assert(idev->intr_ctrl, nqcq->intr.index,
+		IONIC_INTR_MASK_SET);
+
+	lif->notifyqcq = nqcq;
+
 	return 0;
 }
 
@@ -1040,30 +1029,36 @@ ionic_lif_rss_teardown(struct ionic_lif *lif)
 }
 
 static void
-ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq)
+ionic_lif_qcq_deinit(struct ionic_qcq *qcq)
 {
-	struct ionic_dev *idev = &lif->adapter->idev;
-
-	if (!(qcq->flags & IONIC_QCQ_F_INITED))
-		return;
-
-	if (qcq->flags & IONIC_QCQ_F_INTR)
-		ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
-			IONIC_INTR_MASK_SET);
-
 	qcq->flags &= ~IONIC_QCQ_F_INITED;
 }
 
 void
 ionic_lif_txq_deinit(struct ionic_qcq *qcq)
 {
-	ionic_lif_qcq_deinit(qcq->lif, qcq);
+	ionic_lif_qcq_deinit(qcq);
 }
 
 void
 ionic_lif_rxq_deinit(struct ionic_qcq *qcq)
 {
-	ionic_lif_qcq_deinit(qcq->lif, qcq);
+	ionic_lif_qcq_deinit(qcq);
+}
+
+static void
+ionic_lif_notifyq_deinit(struct ionic_lif *lif)
+{
+	struct ionic_qcq *nqcq = lif->notifyqcq;
+	struct ionic_dev *idev = &lif->adapter->idev;
+
+	if (!(nqcq->flags & IONIC_QCQ_F_INITED))
+		return;
+
+	ionic_intr_mask(idev->intr_ctrl, nqcq->intr.index,
+		IONIC_INTR_MASK_SET);
+
+	nqcq->flags &= ~IONIC_QCQ_F_INITED;
 }
 
 bool
@@ -1227,7 +1222,7 @@ ionic_lif_adminq_init(struct ionic_lif *lif)
 	struct ionic_q_init_comp comp;
 	int err;
 
-	ionic_dev_cmd_adminq_init(idev, qcq, qcq->intr.index);
+	ionic_dev_cmd_adminq_init(idev, qcq);
 	err = ionic_dev_cmd_wait_check(idev, IONIC_DEVCMD_TIMEOUT);
 	if (err)
 		return err;
@@ -1242,10 +1237,6 @@ ionic_lif_adminq_init(struct ionic_lif *lif)
 	IONIC_PRINT(DEBUG, "adminq->hw_index %d", q->hw_index);
 	IONIC_PRINT(DEBUG, "adminq->db %p", q->db);
 
-	if (qcq->flags & IONIC_QCQ_F_INTR)
-		ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
-			IONIC_INTR_MASK_CLEAR);
-
 	qcq->flags |= IONIC_QCQ_F_INITED;
 
 	return 0;
@@ -1292,9 +1283,8 @@ ionic_lif_notifyq_init(struct ionic_lif *lif)
 	IONIC_PRINT(DEBUG, "notifyq->hw_index %d", q->hw_index);
 	IONIC_PRINT(DEBUG, "notifyq->db %p", q->db);
 
-	if (qcq->flags & IONIC_QCQ_F_INTR)
-		ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
-			IONIC_INTR_MASK_CLEAR);
+	ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
+		IONIC_INTR_MASK_CLEAR);
 
 	qcq->flags |= IONIC_QCQ_F_INITED;
 
@@ -1372,7 +1362,7 @@ ionic_lif_txq_init(struct ionic_qcq *qcq)
 			.type = q->type,
 			.index = q->index,
 			.flags = IONIC_QINIT_F_SG | IONIC_QINIT_F_ENA,
-			.intr_index = cq->bound_intr->index,
+			.intr_index = IONIC_INTR_NONE,
 			.ring_size = rte_log2_u32(q->num_descs),
 			.ring_base = q->base_pa,
 			.cq_ring_base = cq->base_pa,
@@ -1418,7 +1408,7 @@ ionic_lif_rxq_init(struct ionic_qcq *qcq)
 			.type = q->type,
 			.index = q->index,
 			.flags = IONIC_QINIT_F_SG | IONIC_QINIT_F_ENA,
-			.intr_index = cq->bound_intr->index,
+			.intr_index = IONIC_INTR_NONE,
 			.ring_size = rte_log2_u32(q->num_descs),
 			.ring_base = q->base_pa,
 			.cq_ring_base = cq->base_pa,
@@ -1544,10 +1534,10 @@ ionic_lif_init(struct ionic_lif *lif)
 	ionic_rx_filters_deinit(lif);
 
 err_out_notifyq_deinit:
-	ionic_lif_qcq_deinit(lif, lif->notifyqcq);
+	ionic_lif_notifyq_deinit(lif);
 
 err_out_adminq_deinit:
-	ionic_lif_qcq_deinit(lif, lif->adminqcq);
+	ionic_lif_qcq_deinit(lif->adminqcq);
 
 	return err;
 }
@@ -1560,8 +1550,8 @@ ionic_lif_deinit(struct ionic_lif *lif)
 
 	ionic_rx_filters_deinit(lif);
 	ionic_lif_rss_teardown(lif);
-	ionic_lif_qcq_deinit(lif, lif->notifyqcq);
-	ionic_lif_qcq_deinit(lif, lif->adminqcq);
+	ionic_lif_notifyq_deinit(lif);
+	ionic_lif_qcq_deinit(lif->adminqcq);
 
 	lif->state &= ~IONIC_LIF_F_INITED;
 }
diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h
index 4f48845eb9..d245c6da01 100644
--- a/drivers/net/ionic/ionic_lif.h
+++ b/drivers/net/ionic/ionic_lif.h
@@ -48,8 +48,6 @@ struct ionic_rx_stats {
 
 #define IONIC_QCQ_F_INITED	BIT(0)
 #define IONIC_QCQ_F_SG		BIT(1)
-#define IONIC_QCQ_F_INTR	BIT(2)
-#define IONIC_QCQ_F_NOTIFYQ	BIT(3)
 #define IONIC_QCQ_F_DEFERRED	BIT(4)
 
 /* Queue / Completion Queue */
-- 
2.17.1



More information about the dev mailing list