From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0054.outbound.protection.outlook.com [157.56.112.54]) by dpdk.org (Postfix) with ESMTP id 6C9E65A9D for ; Tue, 15 Dec 2015 16:37:47 +0100 (CET) Received: from AM2PR02CA0029.eurprd02.prod.outlook.com (10.160.28.167) by HE1PR02MB1018.eurprd02.prod.outlook.com (10.163.172.148) with Microsoft SMTP Server (TLS) id 15.1.355.16; Tue, 15 Dec 2015 15:37:45 +0000 Received: from DB3FFO11FD044.protection.gbl (2a01:111:f400:7e04::138) by AM2PR02CA0029.outlook.office365.com (2a01:111:e400:8400::39) with Microsoft SMTP Server (TLS) id 15.1.355.16 via Frontend Transport; Tue, 15 Dec 2015 15:37:45 +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-43.internal.tilera.com; Received: from lab-43.internal.tilera.com (12.216.194.146) by DB3FFO11FD044.mail.protection.outlook.com (10.47.217.75) with Microsoft SMTP Server (TLS) id 15.1.346.13 via Frontend Transport; Tue, 15 Dec 2015 15:37:44 +0000 Received: (from lsun@localhost) by lab-43.internal.tilera.com (8.14.4/8.14.4/Submit) id tBFFbhus009243; Tue, 15 Dec 2015 10:37:43 -0500 From: Liming Sun To: Date: Tue, 15 Dec 2015 10:37:30 -0500 Message-ID: <1450193851-9100-3-git-send-email-lsun@ezchip.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1450193851-9100-1-git-send-email-lsun@ezchip.com> References: <1450193851-9100-1-git-send-email-lsun@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD044; 1:NUZoIBq0wMdRasgO49EByYpFRkh/NTfrXw8+yroDOOWIEtCPFZSltUuAeSu7Ngon6fffhSvMZUYoEcKWX11BFDDuE7oT3xERi5Tq/SBhREW+O/WYkkziRHjlw//lZnV2QwpBJNx3nmgaOmm9NlgyXUj8npX+VFCNu/DG2OrAc4ilbbMPX3VC3MrkvLp+qC3X+pxnNLNlphHKOj/4wMCQ1uwjo+fz/XQi/CXreDDKU1HYtTuMbbUNfBDUUW7xIX7yocfYi0dWiNQG5/6TVyVfC1pKmax/hYh9JZ1g8Crqogvvb998fyzJKblmXB/RG5lan5onVA6QTCP6pWS65pcejpIqLCbemH9j+2K746UwZghTyKplYgu73eMb1OPBvGz/F60rDdM2I8yGuCpPjU9UDxsFNNQcMBwp8nJy8KJiDkc= X-Forefront-Antispam-Report: CIP:12.216.194.146; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(92566002)(50986999)(36756003)(47776003)(6806005)(87936001)(4001430100002)(586003)(1096002)(450100001)(1220700001)(76176999)(11100500001)(50226001)(105606002)(2950100001)(85426001)(19580405001)(189998001)(5001970100001)(33646002)(48376002)(5008740100001)(5003940100001)(50466002)(107886002)(229853001)(2351001)(42186005)(106466001)(104016004)(86362001)(19580395003)(110136002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR02MB1018; H:lab-43.internal.tilera.com; FPR:; SPF:Fail; PTR:wb-fw1.tilera.com; A:1; MX:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1018; 2:lo7K1MPMH8Txdt1BjfVJVmvWnviBXouAN6+Gtmlm58QC3MES8g716vDhsv4ST3m57+8NqWeUTItoeW3aLADEXQarXX3F03tZJiYtfsgS1KfmEuphg5+MgVGoQ9rVx8ClJ+6U/IcPfU9ncUwry4NFqQ==; 3:nDjJE+/V2cLdnlwsa295E/vg0Mzv4NOHf21Gy9f0D2PBjUYDDyj465cTmQNoSXwJuqb2ktAi8e/lSbx4cWMOjwhEqk2XGEnwpXcfCigCnWlSvQ18Ts5p62iR/bcAxR/l5/vrJdPGhse9m7jXfjYqackGPMBWLQTIDrPa5If3qkwH8P7i+p6LgaC0FKs/5Y99clfu8vFYIiOp+nu1khN5q11mLCMedz6y2fAGJ/3NtkU=; 25:8s/bXzbyGry0ytSi2Y46LHerlfxltMCeruSXBcGgPIY17sP3t3ZSr6+vi5ohDHK2l5bYDvGUf6zBwW3n5+jUZ9zwIb14AWvXyy8Iagb5Yu7tmoKFuML5xAHMi9AD9+gKsQDI67nbrtsvl17W7mAi/rIyLUGlt0kEDRWthbyEkTuUUg+PnwxlaNaCmmBbEAxuSUI36If2YI3M2VNF3BamK6ek2FwNlJRRTcSyqptQULTijRni6i/MQ6gUBb9OadDmU74Fl6wQCSwZuvPrKn/+gw==; 20:z9l5+FfjISYYgO9WuAF5jZGMs60wpeD99x9FpQ/fYX6WbBkmNe0iCSgnvigiiwKZXcXa6OxKlZPcjRO3JOyl2eChrFM/WROULY97Yram7uDrt9CcFwdZVmU9mYhp4ta/as9uVQeGygZOwMe+0F6l9ctRlfYBV6aHvHOcbS7hH0s= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB1018; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046); SRVR:HE1PR02MB1018; BCL:0; PCL:0; RULEID:; SRVR:HE1PR02MB1018; X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1018; 4:2XsA3/GVpCEdhlTFIUgaNKUnF4iszPsx2tdzYW8g1p0kIaPxx8EdMlHwgNdV4SoFw6ASzicWSpRLw2B1u5uhp7qU9IMcBZb+8Whbmtv6MgX9TRvSsS/f8NK9+gRkXAsS3m6ks3gJF0O4GmOUgmG2AdPVyg2s/MVzQPYP14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?Q?xUnbkgADN7Py8EkXgciJBBWilgZx674s/lKn5BpLG4dwIrWfhqvKNtjZwtyt?= =?us-ascii?Q?8H2idEawvfocF1Lddx4STLBnUiSpZYj/HvKFq1Uho/0ciITT61jjewRnciQr?= =?us-ascii?Q?UWgPGmVGflpR7Tod0mBPOJTPoh5gWsc0DCUtX1Cnk2HML/+oLb2KFe1q1SSW?= =?us-ascii?Q?lHuouXebv1sji/yImqU8iwjs6GterZV95mBLwP25uqyiFwuSYoo8+O/SmvRm?= =?us-ascii?Q?JgbsYnxK/NolIenRDuigOQXzEb+dGSE3Tn45ZTh1ygflylVlQvPzP2ifO6tW?= =?us-ascii?Q?dSTzGOLuUE31LdIPVxUQtNC2lIfp9qbtGRoIH2uqmXJsYAwRPjwTPYK7fhCn?= =?us-ascii?Q?JbOyHPtsDa79Oh6nsDVUdoyq8DN1LeSzQPuk0EaPq4A8DpsyWPzVFH7H0RSI?= =?us-ascii?Q?97Y4D+PAjF+znH1w9sez0vCMF4roM2USACCirccfHM153LVP9oEkdwGLMhfH?= =?us-ascii?Q?4fGZMbZfM1nggHSOVMdKI5xZzimnkM+0bmX+J8tEw/0mci+rA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1018; 5:ce7KyBSFvh01xJb99N3M0QqBRH9pV03zN3sbmqBeT1DpJQWmUXvmlAFRrwJCR1nnqJCnAXWthml2LhJbokQUuAuWrFmD18oQjZNw+q9BPSIIHYDGFI1Oq0Z7rCDO+kum3CHT+6e/reo6J2v1dsL1mg==; 24:1eOAGNf8Emh5ETq86+JkgtmCZGfKamukhFW8AKk/dEzXJMC11WqKvqD8YHNNEgWJjruVCr+QeBjzB4b1lFj8TwXogZxIbyh7aB2vwH8ouB0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2015 15:37:44.4460 (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-43.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR02MB1018 Subject: [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: Tue, 15 Dec 2015 15:37:47 -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 --- 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