From patchwork Tue Feb 16 20:35:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Boyer X-Patchwork-Id: 87940 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4E98A054D; Tue, 16 Feb 2021 21:35:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C848B160795; Tue, 16 Feb 2021 21:35:52 +0100 (CET) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id 37161160795 for ; Tue, 16 Feb 2021 21:35:51 +0100 (CET) Received: by mail-pg1-f172.google.com with SMTP id o63so6989836pgo.6 for ; Tue, 16 Feb 2021 12:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=csVYXIbKUE93u08l6RzyXGyxicFBEJweaqPygffB038=; b=vYUqAWSC3DkIVcWOVOmJkTHFej9dncpnH5YiKEVYWrc1HhfI1suPljaG7DVJzHPC1i vVIJisC9gj0PrPwwFSroyvb9v6vu30TQ7GFm85Xxaj6tdaNB4YtS+SDoB+bAIKUojAtT NatXCEzh0tUivjGPHsQebsqvmybzFTDid99W+g8fP3r9t9xyWlyDRznfO77hUt2L5Myc vjE19kxGYeKnFOgeuPRmN8uQAmyxdeM2m/SEQa5qazO5cM3a8HFQ618K1NN3NDg9eODR QAGpj/xjuKVWxvGC56XJn+GZ6wd9lyhP+NykpoZy4EjhM0ZEL8Mt7RgBgzpCL/b2Sx9G sMxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=csVYXIbKUE93u08l6RzyXGyxicFBEJweaqPygffB038=; b=g1UsA/bQHUTsRMik0rBGvisL2otlWjh12QNYfDuxqHSvQmhoyyZyBaZJIIebRPyK4k g9E22YTbxjOKdlQdRkNQ3DTBoJyWx67krgspk2QzIDpRW6RC0lkxA8TcYvVf7tvSMhIk FHqpS+fLBzt6y9Jyrt1eFhM53frjlVAbPhKSpyWf5EfXmNeo/xtSzL+a9avlaYGXJ0XQ Mn7WjJzC62mLMphKzgaYTpCXAA8MPCdBOzLOpTZ8dLWFWRQfpLnEU0un2odYwJaHFqP9 p6ejU0n7aGMWufS5qQIEE/f/kedUOOJgWgfa81sQtZsi/iQSFWFnEy8WHrNRG6GuvVOL B2jw== X-Gm-Message-State: AOAM533LOPGfyNnU26vGuHliOyQaAc0JZgJUAdkSCFLf5829WNvAeCq/ PnTRVNZCMbLKEmwyohHeM+L/yEM1tbi8iw== X-Google-Smtp-Source: ABdhPJzfoSHcbmZuagGAUXfgC7dW5XPyirNCs4vuoRSODzkoz0/sc+JJSVApFm9DZfdATPPZMsbVpg== X-Received: by 2002:a62:16cb:0:b029:1da:358c:4338 with SMTP id 194-20020a6216cb0000b02901da358c4338mr21030283pfw.36.1613507749998; Tue, 16 Feb 2021 12:35:49 -0800 (PST) Received: from driver-dev1.pensando.io ([12.226.153.42]) by smtp.gmail.com with ESMTPSA id u17sm11371pgh.72.2021.02.16.12.35.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 12:35:49 -0800 (PST) From: Andrew Boyer To: dev@dpdk.org Cc: Alfredo Cardigliano , Andrew Boyer Date: Tue, 16 Feb 2021 12:35:26 -0800 Message-Id: <20210216203540.29290-2-aboyer@pensando.io> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210216203540.29290-1-aboyer@pensando.io> References: <20210216203540.29290-1-aboyer@pensando.io> In-Reply-To: <20210204195853.13411-1-aboyer@pensando.io> References: <20210204195853.13411-1-aboyer@pensando.io> Subject: [dpdk-dev] [PATCH v2 01/15] net/ionic: cut down completion queue structure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add Q_NEXT_TO_POST() and Q_NEXT_TO_SRVC() macros. Use a precomputed size mask. This will conserve resources. Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_dev.c | 14 +++----------- drivers/net/ionic/ionic_dev.h | 14 +++++++------- drivers/net/ionic/ionic_lif.c | 5 +++-- drivers/net/ionic/ionic_lif.h | 3 ++- drivers/net/ionic/ionic_rxtx.c | 24 ++++++++++++------------ 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/net/ionic/ionic_dev.c b/drivers/net/ionic/ionic_dev.c index a9f9e2faf9..f837817a0a 100644 --- a/drivers/net/ionic/ionic_dev.c +++ b/drivers/net/ionic/ionic_dev.c @@ -358,14 +358,8 @@ ionic_dev_cmd_adminq_init(struct ionic_dev *idev, struct ionic_qcq *qcq) } int -ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq, - uint32_t num_descs, size_t desc_size) +ionic_cq_init(struct ionic_cq *cq, uint16_t num_descs) { - if (desc_size == 0) { - IONIC_PRINT(ERR, "Descriptor size is %zu", desc_size); - return -EINVAL; - } - if (!rte_is_power_of_2(num_descs) || num_descs < IONIC_MIN_RING_DESC || num_descs > IONIC_MAX_RING_DESC) { @@ -374,9 +368,8 @@ ionic_cq_init(struct ionic_lif *lif, struct ionic_cq *cq, return -EINVAL; } - cq->lif = lif; cq->num_descs = num_descs; - cq->desc_size = desc_size; + cq->size_mask = num_descs - 1; cq->tail_idx = 0; cq->done_color = 1; @@ -393,7 +386,6 @@ 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) { - cq->bound_q = q; q->bound_cq = cq; } @@ -407,7 +399,7 @@ ionic_cq_service(struct ionic_cq *cq, uint32_t work_to_do, return 0; while (cb(cq, cq->tail_idx, cb_arg)) { - cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1); + cq->tail_idx = Q_NEXT_TO_SRVC(cq, 1); if (cq->tail_idx == 0) cq->done_color = !cq->done_color; diff --git a/drivers/net/ionic/ionic_dev.h b/drivers/net/ionic/ionic_dev.h index bacbe3f053..b29bfd13be 100644 --- a/drivers/net/ionic/ionic_dev.h +++ b/drivers/net/ionic/ionic_dev.h @@ -142,6 +142,9 @@ struct ionic_desc_info { 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)) + struct ionic_queue { struct ionic_dev *idev; struct ionic_lif *lif; @@ -174,11 +177,9 @@ struct ionic_intr_info { }; struct ionic_cq { - struct ionic_lif *lif; - struct ionic_queue *bound_q; - uint32_t tail_idx; - uint32_t num_descs; - uint32_t desc_size; + uint16_t tail_idx; + uint16_t num_descs; + uint16_t size_mask; bool done_color; void *base; rte_iova_t base_pa; @@ -240,8 +241,7 @@ 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, - uint32_t num_descs, size_t desc_size); +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_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 e083f92417..a9fe34c0f2 100644 --- a/drivers/net/ionic/ionic_lif.c +++ b/drivers/net/ionic/ionic_lif.c @@ -656,7 +656,7 @@ ionic_qcq_alloc(struct ionic_lif *lif, uint8_t type, goto err_out_free_info; } - err = ionic_cq_init(lif, &new->cq, num_descs, cq_desc_size); + err = ionic_cq_init(&new->cq, num_descs); if (err) { IONIC_PRINT(ERR, "Completion queue initialization failed"); goto err_out_free_info; @@ -1169,11 +1169,12 @@ ionic_adminq_service(struct ionic_cq *cq, uint32_t cq_desc_index, { struct ionic_admin_comp *cq_desc_base = cq->base; struct ionic_admin_comp *cq_desc = &cq_desc_base[cq_desc_index]; + struct ionic_qcq *qcq = IONIC_CQ_TO_QCQ(cq); if (!color_match(cq_desc->color, cq->done_color)) return false; - ionic_q_service(cq->bound_q, cq_desc_index, cq_desc->comp_index, NULL); + ionic_q_service(&qcq->q, cq_desc_index, cq_desc->comp_index, NULL); return true; } diff --git a/drivers/net/ionic/ionic_lif.h b/drivers/net/ionic/ionic_lif.h index 8f01aefd60..1a898a0ef9 100644 --- a/drivers/net/ionic/ionic_lif.h +++ b/drivers/net/ionic/ionic_lif.h @@ -71,7 +71,8 @@ struct ionic_qcq { struct ionic_intr_info intr; }; -#define IONIC_Q_TO_QCQ(q) container_of(q, struct ionic_qcq, q) +#define IONIC_Q_TO_QCQ(_q) container_of(_q, struct ionic_qcq, q) +#define IONIC_CQ_TO_QCQ(_cq) container_of(_cq, struct ionic_qcq, cq) #define IONIC_Q_TO_TX_STATS(q) (&IONIC_Q_TO_QCQ(q)->stats.tx) #define IONIC_Q_TO_RX_STATS(q) (&IONIC_Q_TO_QCQ(q)->stats.rx) diff --git a/drivers/net/ionic/ionic_rxtx.c b/drivers/net/ionic/ionic_rxtx.c index 99920109eb..76de82882d 100644 --- a/drivers/net/ionic/ionic_rxtx.c +++ b/drivers/net/ionic/ionic_rxtx.c @@ -68,9 +68,10 @@ ionic_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id, } static __rte_always_inline void -ionic_tx_flush(struct ionic_cq *cq) +ionic_tx_flush(struct ionic_qcq *txq) { - struct ionic_queue *q = cq->bound_q; + 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; @@ -79,7 +80,7 @@ ionic_tx_flush(struct ionic_cq *cq) cq_desc = &cq_desc_base[cq->tail_idx]; while (color_match(cq_desc->color, cq->done_color)) { - cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1); + cq->tail_idx = Q_NEXT_TO_SRVC(cq, 1); /* Prefetch the next 4 descriptors (not really useful here) */ if ((cq->tail_idx & 0x3) == 0) @@ -149,7 +150,7 @@ ionic_dev_tx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t tx_queue_id) ionic_qcq_disable(txq); - ionic_tx_flush(&txq->cq); + ionic_tx_flush(txq); return 0; } @@ -521,7 +522,6 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, { struct ionic_qcq *txq = (struct ionic_qcq *)tx_queue; struct ionic_queue *q = &txq->q; - struct ionic_cq *cq = &txq->cq; struct ionic_tx_stats *stats = IONIC_Q_TO_TX_STATS(q); uint32_t next_q_head_idx; uint32_t bytes_tx = 0; @@ -530,7 +530,7 @@ ionic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, bool last; /* Cleaning old buffers */ - ionic_tx_flush(cq); + ionic_tx_flush(txq); if (unlikely(ionic_q_space_avail(q) < nb_pkts)) { stats->stop += nb_pkts; @@ -1018,10 +1018,11 @@ ionic_dev_rx_queue_start(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) } static __rte_always_inline void -ionic_rxq_service(struct ionic_cq *cq, uint32_t work_to_do, +ionic_rxq_service(struct ionic_qcq *rxq, uint32_t work_to_do, void *service_cb_arg) { - struct ionic_queue *q = cq->bound_q; + 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; @@ -1035,7 +1036,7 @@ ionic_rxq_service(struct ionic_cq *cq, uint32_t work_to_do, cq_desc = &cq_desc_base[cq->tail_idx]; while (color_match(cq_desc->pkt_type_color, cq->done_color)) { curr_cq_tail_idx = cq->tail_idx; - cq->tail_idx = (cq->tail_idx + 1) & (cq->num_descs - 1); + cq->tail_idx = Q_NEXT_TO_SRVC(cq, 1); if (cq->tail_idx == 0) cq->done_color = !cq->done_color; @@ -1087,7 +1088,7 @@ ionic_dev_rx_queue_stop(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) ionic_qcq_disable(rxq); /* Flush */ - ionic_rxq_service(&rxq->cq, -1, NULL); + ionic_rxq_service(rxq, -1, NULL); return 0; } @@ -1099,14 +1100,13 @@ ionic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, struct ionic_qcq *rxq = (struct ionic_qcq *)rx_queue; uint32_t frame_size = rxq->lif->eth_dev->data->dev_conf.rxmode.max_rx_pkt_len; - struct ionic_cq *cq = &rxq->cq; struct ionic_rx_service service_cb_arg; service_cb_arg.rx_pkts = rx_pkts; service_cb_arg.nb_pkts = nb_pkts; service_cb_arg.nb_rx = 0; - ionic_rxq_service(cq, nb_pkts, &service_cb_arg); + ionic_rxq_service(rxq, nb_pkts, &service_cb_arg); ionic_rx_fill(rxq, frame_size);