From patchwork Mon Nov 2 08:12:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leyi Rong X-Patchwork-Id: 83363 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D64E2A04E7; Mon, 2 Nov 2020 09:36:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 24F6B9AEB; Mon, 2 Nov 2020 09:36:10 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 1957472F0 for ; Mon, 2 Nov 2020 09:36:07 +0100 (CET) IronPort-SDR: fLOfKTq+G0+rZrmQS24uTLCS1zilA/Aey74bkOkakYoOqF8GD1N7tLr+9r1v5utBF2WmdrFjzY sAalDiU7waIg== X-IronPort-AV: E=McAfee;i="6000,8403,9792"; a="165349086" X-IronPort-AV: E=Sophos;i="5.77,444,1596524400"; d="scan'208";a="165349086" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2020 00:36:05 -0800 IronPort-SDR: 1AeH8gV6SJtIoT6ERF7GQbkfBQTpCpmjJ4gBQH68Ss/lBZilEixbZgNJqLwzRSddzHWfZyWDvh AKuGgfJ99RQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,444,1596524400"; d="scan'208";a="537933081" Received: from dpdk-lrong-srv-04.sh.intel.com ([10.67.119.221]) by orsmga005.jf.intel.com with ESMTP; 02 Nov 2020 00:36:04 -0800 From: Leyi Rong To: qi.z.zhang@intel.com Cc: dev@dpdk.org, Leyi Rong Date: Mon, 2 Nov 2020 16:12:18 +0800 Message-Id: <20201102081218.78431-1-leyi.rong@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/l3fwd: enable multiple Tx queues on a lcore X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" This patch enable multiple Tx queues handling on a lcore. Signed-off-by: Leyi Rong --- examples/l3fwd/l3fwd_common.h | 6 ++--- examples/l3fwd/l3fwd_em.c | 2 +- examples/l3fwd/l3fwd_em_hlm.h | 4 ++-- examples/l3fwd/l3fwd_em_sequential.h | 5 +++-- examples/l3fwd/l3fwd_lpm.c | 2 +- examples/l3fwd/l3fwd_lpm_sse.h | 5 +++-- examples/l3fwd/l3fwd_sse.h | 4 ++-- examples/l3fwd/main.c | 33 ++++++++++++++++------------ 8 files changed, 34 insertions(+), 27 deletions(-) diff --git a/examples/l3fwd/l3fwd_common.h b/examples/l3fwd/l3fwd_common.h index 7d83ff641a..ab114af8c6 100644 --- a/examples/l3fwd/l3fwd_common.h +++ b/examples/l3fwd/l3fwd_common.h @@ -178,8 +178,8 @@ static const struct { }; static __rte_always_inline void -send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[], - uint32_t num) +send_packetsx4(struct lcore_conf *qconf, uint16_t port, uint16_t queueid, + struct rte_mbuf *m[], uint32_t num) { uint32_t len, j, n; @@ -190,7 +190,7 @@ send_packetsx4(struct lcore_conf *qconf, uint16_t port, struct rte_mbuf *m[], * then send them straightway. */ if (num >= MAX_TX_BURST && len == 0) { - n = rte_eth_tx_burst(port, qconf->tx_queue_id[port], m, num); + n = rte_eth_tx_burst(port, queueid, m, num); if (unlikely(n < num)) { do { rte_pktmbuf_free(m[n]); diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c index 9996bfba34..8fddb8d55d 100644 --- a/examples/l3fwd/l3fwd_em.c +++ b/examples/l3fwd/l3fwd_em.c @@ -686,7 +686,7 @@ em_main_loop(__rte_unused void *dummy) #if defined RTE_ARCH_X86 || defined __ARM_NEON l3fwd_em_send_packets(nb_rx, pkts_burst, - portid, qconf); + portid, queueid, qconf); #else l3fwd_em_no_opt_send_packets(nb_rx, pkts_burst, portid, qconf); diff --git a/examples/l3fwd/l3fwd_em_hlm.h b/examples/l3fwd/l3fwd_em_hlm.h index 278707c18c..d08f393eed 100644 --- a/examples/l3fwd/l3fwd_em_hlm.h +++ b/examples/l3fwd/l3fwd_em_hlm.h @@ -183,7 +183,7 @@ em_get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt, */ static inline void l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, - uint16_t portid, struct lcore_conf *qconf) + uint16_t portid, uint16_t queueid, struct lcore_conf *qconf) { int32_t i, j, pos; uint16_t dst_port[MAX_PKT_BURST]; @@ -238,7 +238,7 @@ l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, for (; j < nb_rx; j++) dst_port[j] = em_get_dst_port(qconf, pkts_burst[j], portid); - send_packets_multi(qconf, pkts_burst, dst_port, nb_rx); + send_packets_multi(qconf, pkts_burst, dst_port, queueid, nb_rx); } diff --git a/examples/l3fwd/l3fwd_em_sequential.h b/examples/l3fwd/l3fwd_em_sequential.h index 6170052cf8..2d7071b0c9 100644 --- a/examples/l3fwd/l3fwd_em_sequential.h +++ b/examples/l3fwd/l3fwd_em_sequential.h @@ -74,7 +74,8 @@ em_get_dst_port(const struct lcore_conf *qconf, struct rte_mbuf *pkt, */ static inline void l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, - uint16_t portid, struct lcore_conf *qconf) + uint16_t portid, uint16_t queueid, + struct lcore_conf *qconf) { int32_t i, j; uint16_t dst_port[MAX_PKT_BURST]; @@ -93,7 +94,7 @@ l3fwd_em_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, dst_port[j] = em_get_dst_port(qconf, pkts_burst[j], portid); } - send_packets_multi(qconf, pkts_burst, dst_port, nb_rx); + send_packets_multi(qconf, pkts_burst, dst_port, queueid, nb_rx); } /* diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c index 3dcf1fef18..8153150c37 100644 --- a/examples/l3fwd/l3fwd_lpm.c +++ b/examples/l3fwd/l3fwd_lpm.c @@ -243,7 +243,7 @@ lpm_main_loop(__rte_unused void *dummy) #if defined RTE_ARCH_X86 || defined __ARM_NEON \ || defined RTE_ARCH_PPC_64 l3fwd_lpm_send_packets(nb_rx, pkts_burst, - portid, qconf); + portid, queueid, qconf); #else l3fwd_lpm_no_opt_send_packets(nb_rx, pkts_burst, portid, qconf); diff --git a/examples/l3fwd/l3fwd_lpm_sse.h b/examples/l3fwd/l3fwd_lpm_sse.h index 3f637a23d1..cd68179b76 100644 --- a/examples/l3fwd/l3fwd_lpm_sse.h +++ b/examples/l3fwd/l3fwd_lpm_sse.h @@ -83,7 +83,8 @@ processx4_step2(const struct lcore_conf *qconf, */ static inline void l3fwd_lpm_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, - uint16_t portid, struct lcore_conf *qconf) + uint16_t portid, uint16_t queueid, + struct lcore_conf *qconf) { int32_t j; uint16_t dst_port[MAX_PKT_BURST]; @@ -114,7 +115,7 @@ l3fwd_lpm_send_packets(int nb_rx, struct rte_mbuf **pkts_burst, j++; } - send_packets_multi(qconf, pkts_burst, dst_port, nb_rx); + send_packets_multi(qconf, pkts_burst, dst_port, queueid, nb_rx); } #endif /* __L3FWD_LPM_SSE_H__ */ diff --git a/examples/l3fwd/l3fwd_sse.h b/examples/l3fwd/l3fwd_sse.h index bb565ed546..f91580a4ce 100644 --- a/examples/l3fwd/l3fwd_sse.h +++ b/examples/l3fwd/l3fwd_sse.h @@ -125,7 +125,7 @@ process_packet(struct rte_mbuf *pkt, uint16_t *dst_port) */ static __rte_always_inline void send_packets_multi(struct lcore_conf *qconf, struct rte_mbuf **pkts_burst, - uint16_t dst_port[MAX_PKT_BURST], int nb_rx) + uint16_t dst_port[MAX_PKT_BURST], uint16_t queueid, int nb_rx) { int32_t k; int j = 0; @@ -220,7 +220,7 @@ send_packets_multi(struct lcore_conf *qconf, struct rte_mbuf **pkts_burst, k = pnum[j]; if (likely(pn != BAD_PORT)) - send_packetsx4(qconf, pn, pkts_burst + j, k); + send_packetsx4(qconf, pn, queueid, pkts_burst + j, k); else for (m = j; m != j + k; m++) rte_pktmbuf_free(pkts_burst[m]); diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index d62dec434c..d3c8e5cb5d 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -935,7 +935,7 @@ l3fwd_poll_resource_setup(void) fflush(stdout); nb_rx_queue = get_port_n_rx_queues(portid); - n_tx_queue = nb_lcores; + n_tx_queue = nb_rx_queue; if (n_tx_queue > MAX_TX_QUEUE_PER_PORT) n_tx_queue = MAX_TX_QUEUE_PER_PORT; printf("Creating queues: nb_rxq=%d nb_txq=%u... ", @@ -1011,6 +1011,7 @@ l3fwd_poll_resource_setup(void) for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { if (rte_lcore_is_enabled(lcore_id) == 0) continue; + qconf = &lcore_conf[lcore_id]; if (numa_on) socketid = @@ -1018,21 +1019,25 @@ l3fwd_poll_resource_setup(void) else socketid = 0; - printf("txq=%u,%d,%d ", lcore_id, queueid, socketid); - fflush(stdout); - - txconf = &dev_info.default_txconf; - txconf->offloads = local_port_conf.txmode.offloads; - ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd, - socketid, txconf); - if (ret < 0) - rte_exit(EXIT_FAILURE, - "rte_eth_tx_queue_setup: err=%d, " - "port=%d\n", ret, portid); + for (queue = 0; queue < qconf->n_rx_queue; queue++) { + queueid = qconf->rx_queue_list[queue].queue_id; + printf("txq=%u,%d,%d ", + lcore_id, queueid, socketid); + fflush(stdout); + + txconf = &dev_info.default_txconf; + txconf->offloads = + local_port_conf.txmode.offloads; + ret = rte_eth_tx_queue_setup + (portid, queueid, nb_txd, + socketid, txconf); + if (ret < 0) + rte_exit(EXIT_FAILURE, + "rte_eth_tx_queue_setup: err=%d, " + "port=%d\n", ret, portid); + } - qconf = &lcore_conf[lcore_id]; qconf->tx_queue_id[portid] = queueid; - queueid++; qconf->tx_port_id[qconf->n_tx_port] = portid; qconf->n_tx_port++;