From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0088.outbound.protection.outlook.com [157.55.234.88]) by dpdk.org (Postfix) with ESMTP id E4BC33005 for ; Fri, 8 Jan 2016 15:30:47 +0100 (CET) Received: from AM4PR02CA0004.eurprd02.prod.outlook.com (2a01:111:e400:7a66::14) by AM3PR02MB1011.eurprd02.prod.outlook.com (2a01:111:e400:c404::21) with Microsoft SMTP Server (TLS) id 15.1.365.19; Fri, 8 Jan 2016 14:30:46 +0000 Received: from DB3FFO11FD055.protection.gbl (2a01:111:f400:7e04::159) by AM4PR02CA0004.outlook.office365.com (2a01:111:e400:7a66::14) with Microsoft SMTP Server (TLS) id 15.1.365.19 via Frontend Transport; Fri, 8 Jan 2016 14:30:46 +0000 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; ezchip.com; dkim=none (message not signed) header.d=none;ezchip.com; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 12.216.194.146 as permitted sender) receiver=protection.outlook.com; client-ip=12.216.194.146; helo=lab-14.internal.tilera.com; Received: from lab-14.internal.tilera.com (12.216.194.146) by DB3FFO11FD055.mail.protection.outlook.com (10.47.217.127) with Microsoft SMTP Server (TLS) id 15.1.355.15 via Frontend Transport; Fri, 8 Jan 2016 14:30:46 +0000 Received: (from lsun@localhost) by lab-14.internal.tilera.com (8.14.7/8.14.7/Submit) id u08EUjTV021681; Fri, 8 Jan 2016 09:30:45 -0500 From: Liming Sun To: Date: Fri, 8 Jan 2016 09:30:37 -0500 Message-ID: <1452263438-21634-2-git-send-email-lsun@ezchip.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1452263438-21634-1-git-send-email-lsun@ezchip.com> References: <1450193851-9100-4-git-send-email-lsun@ezchip.com> <1452263438-21634-1-git-send-email-lsun@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD055; 1:ekNpepdEGQsy9acIu0JUGl5AdhjoYTJvycnKaCUI7m0gaUOarm1u58IqQYGi/MYFOM8OcEwuFFNkgtat9BNKlH+QQ9we6Cuj/kG3qsQxaX/I6EZjndbJSP3UPl9jcWOeQTF/Hacbh11sXsyKBA32ONlvrG125g4qxdwvaJIBl4qs3p7sIJVrvV8eXGX/HB+MhgRM7/hfUX7UFgbtrmS9x8kXNplKTU3n4r5hPBkgJ22cUjpqcAaMGKq58d+GyLGIR/Unxvfq8KuTWaOn2sF8ZNVyUISCp8+DVXS+WMkWkwf6h4MeXI0wpTT1fXf4TcwydP9gf1ZGU6lj374rQNiTuwFyghDHC8uYMaotSvmSA+4Hga/gda1D7NXmCxUJ89w/ybADHREVxpR/bgDo8aGgLA== X-Forefront-Antispam-Report: CIP:12.216.194.146; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(6806005)(105606002)(85426001)(1096002)(5003940100001)(106466001)(1220700001)(36756003)(104016004)(92566002)(50226001)(586003)(5008740100001)(4326007)(4001430100002)(110136002)(19580405001)(2950100001)(19580395003)(5001970100001)(2351001)(229853001)(107886002)(47776003)(189998001)(11100500001)(33646002)(87936001)(86362001)(50466002)(48376002)(450100001)(76176999)(50986999)(2906002)(42186005); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR02MB1011; H:lab-14.internal.tilera.com; FPR:; SPF:Fail; PTR:wb-fw1.tilera.com; MX:1; A:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1; AM3PR02MB1011; 2:Ubse7fMZE/EEDMSJ58a/xhnYs8yMBIprSsJEmqeQbVTaf2uwQzzwBaxQiF6Mnre6tTMX6a5I74vNmfyqIrVE1CcEYh11Tte6kRNnaKotnWO4HK2bbbBWbo34cZNkuy0M7zyLgWmmtn4xuH6NPchxyw==; 3:Fw/4QrSXQDoRT9FnSq91FikjLEdUuntwbJbHUTG/wwf4Ns+wiY5AyFQsZnp95YrQuqN2oMU632Hg44xK76kiCBxFV8ZHZiI60i4UHwxvHpNE+R3rs8qFySxkRQ+3r4eXXPRup4qEgUPH05ABfuCswYOrbmPbW1pfyEF1nPhZBE3hRGBY34dPfPAdBPkbaVOLTvOTUksbzsBn7M6Oul3ksa72OKk9jVj/xLzP0Ry71Bo=; 25:1g92U0zLib1akp2gnnpQz4QMGbnojgk1jJjYt9EQjBYXjryMnZ0r4OOcq/pc0rl0f+hlkhY36PsePOUYtKMW6uz2u9ORnXvgIA/T5eerYDLI8j8PwkA89MD8L31e67hqtUQueH8ig973TJ77fjcu3butfGS89JgXBR+NEQl1hejHLk4O1g8ecG+pqkY7zLLUTmwg9OGnj0h2eULA8IHWYoDJJWcU16uQ8HR0MWRItoGHO0uBiKOzvfSrOHIaqrte; 20:T1OmGIHmTN202XFIK12Hr9iOiJtumxgdMpFpgpal1KkMFYwoQpugG66XRle2iqltcFktyU08/3CM8OSYJZjP6/WbLc6acv5hWLLrbDhvDMUzwEycuVHCElthEE9y8GDsxd32k9nxnRIIGhwU/VBIhuErHJ4VBdHUhZahGcW/QNk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR02MB1011; X-MS-Office365-Filtering-Correlation-Id: af775b8d-64b4-4177-4052-08d318384c5c X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13017025)(5005006)(13015025)(520078)(8121501046)(13018025)(3002001)(10201501046); SRVR:AM3PR02MB1011; BCL:0; PCL:0; RULEID:; SRVR:AM3PR02MB1011; X-Microsoft-Exchange-Diagnostics: 1; AM3PR02MB1011; 4:A0l3bCjw1n6nHK/+Hn3ffXEyKFqH4tJ9aKHwifwtsPujkypwrBL6i6H1CN5XXUx7NfWqdWb+Oi+BfCasCinSmK07nqPMcKAlukdsc8cwevsamgqhfdr/j+ntwexuB+dACXcjWxH5N+4/UadDRnnrRppBwsp3pU++/RwA8OHmxUJefCnmtl8Z7BTKCMntCpNQNyalIBmJnldSG2R4nP13xbO+evWTC8lXraBzQFUlLwv8bHHcCPzCb3nAborDPKZIIu8QANdZ5Cprt5UfdsH45/OJq6tIiY3H0Lqm1ApP4Zz/JtehMSO8WNTWxzB5mGvq7hm60uM4vBCYdqi7Nh6cjS1hmNeeY3Rai5mCdvby57KL0/bUzVwN4tFZW70wKQXQSQXj3WxfV1jnMafhRWFVKidJgys4R2CShk7DDlgp2sc9bsVD9VQjUeUkvXKw927S7w56SbbhpBr1N74oszO2odGZI9Adq0rEpnAmooY39YA= X-Forefront-PRVS: 0815F8251E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM3PR02MB1011; 23:3NC7KxdJFh0LNU2NGx1vjxEoQF2JwFu1vinjVm/pm?= =?us-ascii?Q?sN/oy0WxLv7W9BxTT5/vxOfZftyeM6CqF2DHAU/PY2fS9ZXPS1UsXblfDzn6?= =?us-ascii?Q?7fuwz/bHTDFkcbHIUU91zN4mbQHx6/j3Vn1sj3aAKcQISgNXq+C4k2s1lk58?= =?us-ascii?Q?5lRHMPqvQqgaVLYnkOkhTkCeE9gCuyhWPn0W6kjOPTw0uJh+d9fc50DxcI+s?= =?us-ascii?Q?LbcewVA7WDwiMQcSGxnHhfzMjWgsOYWOi17eo9S7GuOpppYyl+Yrmz/g5ilg?= =?us-ascii?Q?0hqUyIC8PBn5KqkynTQB7cDLrkyJNeRuoT4ngThpQ2/tnW2NYV4rLmN2NcCr?= =?us-ascii?Q?kHWC5HutOc4OoSppfi39qoDgofKl4vJl8LOrIoepoOm98n3ICFHg6iOdXP7C?= =?us-ascii?Q?W7yuPrVYWpuu2h1WWuAk2sko8CFiZlm418ns1px6v0+tsUNDYUClwc4SciQa?= =?us-ascii?Q?Mg1hNIPiWT2qn8WdOdi/dWzPgvUYiiwXgluZAf6XJTZtSEhnJ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8jiaBIslM3Cq0tuA8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2016 14:30:46.3197 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[12.216.194.146]; Helo=[lab-14.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR02MB1011 Subject: [dpdk-dev] [PATCH v2 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 14:30:48 -0000 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 Acked-by: Zhigang Lu --- drivers/net/mpipe/mpipe_tilegx.c | 50 ++++++++++++++++++++++++++++++++-------- 1 file 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.8.3.1