From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0059.outbound.protection.outlook.com [157.55.234.59]) by dpdk.org (Postfix) with ESMTP id A924DADA7 for ; Fri, 8 Jan 2016 04:05:18 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=zlu@ezchip.com; Received: from zhigangTHINK (58.135.92.20) by DB5PR02MB1141.eurprd02.prod.outlook.com (10.162.163.11) with Microsoft SMTP Server (TLS) id 15.1.361.13; Fri, 8 Jan 2016 03:05:15 +0000 From: Tony Lu To: 'Liming Sun' , References: <1450193851-9100-1-git-send-email-lsun@ezchip.com> <1450193851-9100-3-git-send-email-lsun@ezchip.com> In-Reply-To: <1450193851-9100-3-git-send-email-lsun@ezchip.com> Date: Fri, 8 Jan 2016 11:04:53 +0800 Message-ID: <003101d149c1$687f3d20$397db760$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdE3TpbzMoDb0ikJQ6y+SicJHid6jwScrUrA Content-Language: zh-cn X-Originating-IP: [58.135.92.20] X-ClientProxiedBy: PS1PR06CA0006.apcprd06.prod.outlook.com (25.169.59.144) To DB5PR02MB1141.eurprd02.prod.outlook.com (25.162.163.11) X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1141; 2:D9VtKCO8Af9xQGxcf0ybUTD6NLl8dsWZmYBJ7tOwzs+xMLlo7or7aN5s3mQ31LY5QUUWoThzQll8gSE1I7j1KALsG7CrHlRXTGtieXeoudHQbIJpt+38qLVytR9zt/BJCmcZ99Q1FLYw3fGcqnupeQ==; 3:tdgspmoRaXCKw6A46s3PYoQ9Ao5EUv6VVi62tHBUjaLkK13Snm8JDX+SpEX/I6xuJ6S6jUvouB4rg3l+4fMH/247Id/vX4Wv5Y0Avtwu/V9hR/bQu5bNKRnF3plweLxR; 25:0SggX4Owqz3edzdESJLbhvve5lkCFQJUK1mksNR+esHimBXNZ6ZHdVbs7QdYNVlWU95070Mj1pm8W4b7nIrZOg7ahTgTJKtTzdPJHI3uSYd1/qfSY48mYq53TRXhVPwCTWbkxmLfS4F1SZ4iNtC64WVLO5fYxTSF/voTQ5NbDz3UL14EAoMHUi7zd3MBZcC4x4uOkDHpq1r/Nf5cGOS8t7gztsjHOsNDdPdnZNRZJAcpL9nLlyVzrVjPgeSXAjvg; 20:ErIdMEpa2Fz/nAoebu/ioEI3zITX19ctd363eqS7pkIgaVeXEMYw/L6szn80if6LdWh+wZ4K4yoxqxkkDtyt7ZTY48OESOPVGTKftp/hF1IQZEQvTpuR/0+S7HtEtgMNPCKW6hxTgD+xEQfFbqY/f8SQfN4mtFESj+dYAOHJkF0= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB1141; X-MS-Office365-Filtering-Correlation-Id: a8c94eb7-3eae-48f6-9150-08d317d888f1 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:DB5PR02MB1141; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB1141; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1141; 4:PQIUlIX2eZx9Gfp4Thws72mhnBSQi66sqwbokAGjZQ3ye9Pk00rE7cGUyPx5ERZilStajlOtfaPvHryjSf69alhlIsz/g0PLtY/cya8RG5U7YuRT0bUiYVTZlL8iHPygMqR2QVN54bKFdiMZ6hoKa77BpP9g5T6rtSJ6j1cuH62bgtKPvxllZEDqvcjeSz5CbTLYVekWbdRpKG8wbzRBL9v1DePl/fnf8hqsIWW/ZjpNVWbgfUGJRBZ4rM7bkjJxggW+T3QACPQxnN0HQe/JGTgdFcdpiE8225VNQlHMH5sHW/D8GJVrXIlYEP9XRShqJiNAfRLxVeCns4c4iuoIYD40CIvBMW6k4UhxC0tDAqZQQXizFU1VDekIiWBDLLG53BuwZjZc7YfPUc6wGAJAKGFunFFbv+XUDnjmzij88sMZQlKlftkj+gC0RCsoqEQa X-Forefront-PRVS: 0815F8251E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(377454003)(13464003)(199003)(97736004)(50466002)(5004730100002)(77096005)(19580405001)(107886002)(66066001)(84116002)(59696002)(5001960100002)(92566002)(23726003)(2906002)(230700001)(96836002)(102836003)(33716001)(86362001)(1420700001)(122386002)(97756001)(87976001)(50226001)(586003)(14726001)(50986999)(450100001)(19580395003)(1096002)(61296003)(46406003)(6116002)(5001770100001)(76176999)(105586002)(40100003)(47776003)(5008740100001)(81156007)(42186005)(33646002)(101416001)(3846002)(106356001)(189998001)(2950100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR02MB1141; H:zhigangTHINK; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: ezchip.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR02MB1141; 23:cmCTIF6hgACWIlAitwW5WUXQh13TvC6nw+eSs3Czo?= =?us-ascii?Q?JV2D+cFypdDI5O+60H6JyZFMgPTfeefbYETHHLd+vhdd/GckBLD2KoClqUKN?= =?us-ascii?Q?H+rEeB6k+DrAbLEF1o7PXvFzCQMuLhQwhPXS4coLgf4b/En41ME4gFH2t/V3?= =?us-ascii?Q?cVqbtCknnR5bvSacKB5ZF08vT1dudm5Mh8/YHg+th0wcaznTX3/xejsnB5ig?= =?us-ascii?Q?OXzXg7cmM/c+AJdVFeO1T9mor3DyPz6s/eV1/vVnsrnLZFsQabf8dtVInJwG?= =?us-ascii?Q?rksoompJpvZdfHFNes9HqNIyDaE8+GZ0h7/VYg5eMIMRPtIUToVO3aY1oGnY?= =?us-ascii?Q?bfubfvJP51jC/SDaRxAxxn9TnZEJsvnfgWPcNPzTzf0Hc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XDIdwLBK8CminV69rT8wKcYoOTth8AF13u4O8JeXI?= =?us-ascii?Q?EwUuDp7cCf8YUUN9dF0EiY=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1141; 5:+9m8XLQ4Wk1w06pajUd0nBPGdldeTQzyDZWrkEf12HU+73bQATFU6z2yfStZGhpnNGf5MRt8qPPAxyd4HcOvFxkAb5jxtmZZDvnOK7W1+WL92CgdeqAVKJDW9MwiY9OHoai/I5bpZ7PUI1KtM6+a2A==; 24:izScU9MIXRhDE64/245coHDwRn6nWvayKIl1njRQZbUwevGKT0Fhfr4R+jaVh4y1K0kyAUZaeP5Ya90cxhsKh0dYiyPaWsRmvkBODJIyeng= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2016 03:05:15.0560 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR02MB1141 Subject: Re: [dpdk-dev] [PATCH 2/3] driver/net/mpipe: optimize mpipe buffer return mechanism. X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2016 03:05:18 -0000 >-----Original Message----- >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Liming Sun >Sent: Tuesday, December 15, 2015 11:38 PM >To: dev@dpdk.org >Subject: [dpdk-dev] [PATCH 2/3] driver/net/mpipe: optimize mpipe buffer return >mechanism. > >This submit has changes to optimize the mpipe buffer return. When >a packet is received, instead of allocating and refilling the >buffer stack right away, it tracks the number of pending buffers, >and use HW buffer return as an optimization when the pending >number is below certain threshold, thus save two MMIO writes and >improves performance especially for bidirectional traffic case. > >Signed-off-by: Liming Sun >--- > drivers/net/mpipe/mpipe_tilegx.c | 50 >++++++++++++++++++++++++++++++------- > 1 files changed, 40 insertions(+), 10 deletions(-) > >diff --git a/drivers/net/mpipe/mpipe_tilegx.c >b/drivers/net/mpipe/mpipe_tilegx.c >index 35134ba..be7b6f2 100644 >--- a/drivers/net/mpipe/mpipe_tilegx.c >+++ b/drivers/net/mpipe/mpipe_tilegx.c >@@ -78,6 +78,13 @@ struct mpipe_context { > struct mpipe_channel_config channels[MPIPE_MAX_CHANNELS]; > }; > >+/* Per-core local data. */ >+struct mpipe_local { >+ int mbuf_push_debt[RTE_MAX_ETHPORTS]; /* Buffer push debt. */ >+} __rte_cache_aligned; >+ >+#define MPIPE_BUF_DEBT_THRESHOLD 32 >+static __thread struct mpipe_local mpipe_local; > static struct mpipe_context mpipe_contexts[GXIO_MPIPE_INSTANCE_MAX]; > static int mpipe_instances; > static const char *drivername = "MPIPE PMD"; >@@ -137,7 +144,7 @@ struct mpipe_dev_priv { > int first_bucket; /* mPIPE bucket start index. */ > int first_ring; /* mPIPE notif ring start index. */ > int notif_group; /* mPIPE notif group. */ >- rte_atomic32_t dp_count; /* Active datapath thread count. */ >+ rte_atomic32_t dp_count __rte_cache_aligned; /* DP Entry count. */ > int tx_stat_mapping[RTE_ETHDEV_QUEUE_STAT_CNTRS]; > int rx_stat_mapping[RTE_ETHDEV_QUEUE_STAT_CNTRS]; > }; >@@ -461,6 +468,14 @@ mpipe_dp_wait(struct mpipe_dev_priv *priv) > } > } > >+static inline int >+mpipe_mbuf_stack_index(struct mpipe_dev_priv *priv, struct rte_mbuf *mbuf) >+{ >+ return (mbuf->port < RTE_MAX_ETHPORTS)? >+ mpipe_priv(&rte_eth_devices[mbuf->port])->stack : >+ priv->stack; >+} >+ > static inline struct rte_mbuf * > mpipe_recv_mbuf(struct mpipe_dev_priv *priv, gxio_mpipe_idesc_t *idesc, > int in_port) >@@ -1267,6 +1282,7 @@ mpipe_do_xmit(struct mpipe_tx_queue *tx_queue, >struct rte_mbuf **tx_pkts, > unsigned nb_bytes = 0; > unsigned nb_sent = 0; > int nb_slots, i; >+ uint8_t port_id; > > PMD_DEBUG_TX("Trying to transmit %d packets on %s:%d.\n", > nb_pkts, mpipe_name(tx_queue->q.priv), >@@ -1315,14 +1331,23 @@ mpipe_do_xmit(struct mpipe_tx_queue *tx_queue, >struct rte_mbuf **tx_pkts, > if (priv->tx_comps[idx]) > rte_pktmbuf_free_seg(priv->tx_comps[idx]); > >+ port_id = (mbuf->port < RTE_MAX_ETHPORTS)? >+ mbuf->port : priv->port_id; > desc = (gxio_mpipe_edesc_t) { { > .va = rte_pktmbuf_mtod(mbuf, uintptr_t), > .xfer_size = rte_pktmbuf_data_len(mbuf), > .bound = next ? 0 : 1, >+ .stack_idx = mpipe_mbuf_stack_index(priv, mbuf), > } }; >+ if (mpipe_local.mbuf_push_debt[port_id] > 0) { >+ mpipe_local.mbuf_push_debt[port_id]--; >+ desc.hwb = 1; >+ priv->tx_comps[idx] = NULL; >+ } >+ else >+ priv->tx_comps[idx] = mbuf; > > nb_bytes += mbuf->data_len; >- priv->tx_comps[idx] = mbuf; > gxio_mpipe_equeue_put_at(equeue, desc, slot + i); > > PMD_DEBUG_TX("%s:%d: Sending packet %p, len %d\n", >@@ -1443,17 +1468,22 @@ mpipe_do_recv(struct mpipe_rx_queue *rx_queue, >struct rte_mbuf **rx_pkts, > continue; > } > >- mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool); >- if (unlikely(!mbuf)) { >- nb_nomem++; >- gxio_mpipe_iqueue_drop(iqueue, idesc); >- PMD_DEBUG_RX("%s:%d: RX alloc failure\n", >+ if (mpipe_local.mbuf_push_debt[in_port] < >+ MPIPE_BUF_DEBT_THRESHOLD) >+ mpipe_local.mbuf_push_debt[in_port]++; >+ else { >+ mbuf = __rte_mbuf_raw_alloc(priv->rx_mpool); >+ if (unlikely(!mbuf)) { >+ nb_nomem++; >+ gxio_mpipe_iqueue_drop(iqueue, idesc); >+ PMD_DEBUG_RX("%s:%d: alloc failure\n", > mpipe_name(rx_queue->q.priv), > rx_queue->q.queue_idx); >- continue; >- } >+ continue; >+ } > >- mpipe_recv_push(priv, mbuf); >+ mpipe_recv_push(priv, mbuf); >+ } > > /* Get and setup the mbuf for the received packet. */ > mbuf = mpipe_recv_mbuf(priv, idesc, in_port); >-- >1.7.1 Acked-by: Zhigang Lu