From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 404893256 for ; Thu, 28 Feb 2019 20:42:05 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1SJZrZL007903; Thu, 28 Feb 2019 11:42:04 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=PPI3gXUzu1lYiN426bK7RAVJhYgp9S0J5lruqD/rl+Q=; b=h/HyEQ2wmagcXQOY/cKN/8wG9sYujT2EjxH2/mo5dA87ZCLKkTr9gsOtXALEBlSW7r99 10L36Mte/Sm7VuuhPy7MQn7ic4fT1n/4QnhkJE21hoTlZCUPeZi7TC4aIEiiR1BFzi+1 Ll47QFQtSGYOFV318EW0amG/scbtwccyLfIMZpwA4ADvIyXdTnSf9lUUx3KExx4ohbKb z2+lf6odxkG+E/WdrI7juiadds0fvLKOJSHE1mbBy7bx0XEUcC+uqLT9XtLoXPy4hhk6 u/XQiCttwZsW53UlWK2d5QW1VtS/ZgWaCBkByMVNLTN31fyaCtqOpEmkMVImxMvN+r+Q +A== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2qx4kmtvpt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 28 Feb 2019 11:42:04 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Feb 2019 11:42:03 -0800 Received: from NAM05-BY2-obe.outbound.protection.outlook.com (104.47.50.57) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 28 Feb 2019 11:42:03 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PPI3gXUzu1lYiN426bK7RAVJhYgp9S0J5lruqD/rl+Q=; b=tbSEOtQNskIOVp0QlEynvp5mt46PfGoHbLVgeTKN/i70jwlMa+mNg8ts9sCHyOZyVzfpHlUPwpp+PS4sQi+Ush5Lz/7dwYnC/E1ppCoPH5paielWZnamJO7Z3VN3N7i1rKRYMcw8xctmlT5MqYGKHYkF6yLYS0BE/kWXznN4UZY= Received: from CY4PR1801MB1863.namprd18.prod.outlook.com (10.171.255.14) by CY4PR1801MB1848.namprd18.prod.outlook.com (10.171.255.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.20; Thu, 28 Feb 2019 19:42:02 +0000 Received: from CY4PR1801MB1863.namprd18.prod.outlook.com ([fe80::51f1:659f:d799:d1ad]) by CY4PR1801MB1863.namprd18.prod.outlook.com ([fe80::51f1:659f:d799:d1ad%4]) with mapi id 15.20.1643.022; Thu, 28 Feb 2019 19:42:02 +0000 From: Pavan Nikhilesh Bhagavatula To: Jerin Jacob Kollanukkaran , "wenzhuo.lu@intel.com" , "bernard.iremonger@intel.com" CC: "dev@dpdk.org" , Pavan Nikhilesh Bhagavatula Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: use mempool bulk get for txonly mode Thread-Index: AQHUz52tRP2hj/yT2UKL2QkX+00QgA== Date: Thu, 28 Feb 2019 19:42:02 +0000 Message-ID: <20190228194128.14236-1-pbhagavatula@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0049.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:19::11) To CY4PR1801MB1863.namprd18.prod.outlook.com (2603:10b6:910:7a::14) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.21.0 x-originating-ip: [223.226.78.85] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 89a92fe5-cdf1-47e5-f6fb-08d69db4cf30 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:CY4PR1801MB1848; x-ms-traffictypediagnostic: CY4PR1801MB1848: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; CY4PR1801MB1848; 23:H2n86mrlS6RDBmmc3G4Ac0+vh7ttEBpRLlMSY?= =?iso-8859-1?Q?au0vyCF0q/NNrT9SKv/PYd0E96X/G4CAEEL+1PiZE5tIm8dcrHhVfpUHiA?= =?iso-8859-1?Q?CgK7Gcigaffr9uDy6HdaMneWks2WtZevPGyz4HA0iZA4o4SdDUVR8Y1X9H?= =?iso-8859-1?Q?t8aIW257pquFrHDDS+RpUwyCcJ/NUSIqNdFFHMoiC1YfV0D8GxHrS1+kO4?= =?iso-8859-1?Q?xFPld5uG0s2fRpYWZvoGdHLy/3+a2yKKv3oKdGV6UBWRQJB6o8f/+2mXzo?= =?iso-8859-1?Q?3aRilJOE5tQCYAa3iaTpUJC3Z47h3OGQ6d565TXyK3aLTy2WsfhvN3YT7C?= =?iso-8859-1?Q?mJnRaa+lbBmp159Ylvr9EI4ky+ikqGDUxiwKiSLcjY3vMHPYSmqC0ro101?= =?iso-8859-1?Q?moJmhUXXhgg6GYZrXnpz1ASqGgGKsluQOMCzrhnx7IJ+bg/EPsTlO1flFt?= =?iso-8859-1?Q?WcemkztOduL+4msYKrJjz/D879nu1IyuAHhdOXgELzwGpOsCaSlfD/tE43?= =?iso-8859-1?Q?tzZr10dpWSNvYFTNz4g+CjHFdKjLjC+/KPhLL4DnVi34MvIQXnfhM9K2OJ?= =?iso-8859-1?Q?UNP3xXUgpTrIGYLmFgSTWS3goWZIhaAvAsY1gJiEg4nhtzegudGYLcnm7w?= =?iso-8859-1?Q?GNCgaGYHH4cElXHhrYzFyM7D9Dts/Uhg0JTDOsUlHdcs6GgCXfg38vyyTe?= =?iso-8859-1?Q?j/LixACA9VPF/l23FBEaJVKVduk1dJclUBsf8KQR0N8YiF79P4rdG3Snbo?= =?iso-8859-1?Q?eacuM+c4F3Hwvwx7vCvZOT1Dlg1mZSO52XF4iXDHj4hXhWhbrrfZaflFaB?= =?iso-8859-1?Q?UG12BgstX4tZL1sQG3W6HGOlx3k1HxyL5+lQgtDtycrrn1ipROvX35JnFq?= =?iso-8859-1?Q?cPI9Glt5JC0+1AytxWjnG5kbiI6t8fcmdic4KrhWMrcbzpNhCX3Owav8iS?= =?iso-8859-1?Q?TDEjd50g3pC4IWonbnE/bBGOP3SPrLrQ9TWGK6z5eais564b00QOcoNxQ8?= =?iso-8859-1?Q?k3wDPHYpktvOLqApfeaKX0UCn1Qprr9PlATqP12oZFA1jbH7FRbqJM8ihG?= =?iso-8859-1?Q?ByZ1tDaAngOL5AyUBQJGQuItKkB+D/ZSRaBr0wVFHSsNO/vrU63GeRbgIk?= =?iso-8859-1?Q?/fTtC+j+HAGT4AQ8J061Nc0SSLfml784JRgpM+8zuNJdKnQFg2k62jljse?= =?iso-8859-1?Q?tlj7dHkkJkvrTd8FBEKvBGw6R64GlRCVd/0J/ljYzeB/b2HIhabsO22EvH?= =?iso-8859-1?Q?7cfTgqU6SkoOLTbY3mQRtjcQUULp8iWzh04hxQAhg=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(396003)(136003)(39860400002)(199004)(189003)(486006)(81166006)(316002)(81156014)(2501003)(8676002)(36756003)(106356001)(8936002)(68736007)(105586002)(186003)(50226002)(256004)(2616005)(66066001)(6506007)(55236004)(4326008)(52116002)(53936002)(25786009)(2201001)(26005)(305945005)(99286004)(1076003)(5660300002)(476003)(6436002)(7736002)(54906003)(107886003)(71190400001)(86362001)(71200400001)(110136005)(6116002)(3846002)(14454004)(102836004)(97736004)(386003)(478600001)(6512007)(6486002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR1801MB1848; H:CY4PR1801MB1863.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 7+U5UcPVn6cQ+HiBYjf5hPGjzm1yvUxLT+WRqipb0wfLMWNprCZdoOX0IEg9SlNsIEX+HtJ+lvbbYZ26iWt4UVWX6kFLl0aYqcu3EH5wsHbVhaJMNws+TdRTmjYNya7sGf1pMuAVWhOb6sDJ4j0OIDj9R7Hsk2Fl5oh8R7ydHXWvSEbjluQSzgliDqiBzw3Fx7HGS+qBMglJYNV5kaGDoYV30Do03awO330qaTg3gToI5unsKHdRV+MUX+vhVVc6uOfNYOi9ibBgBhNB3+kjmmalR0njXiRIlDKw92OyBpLkAnWIWY1ykCsubpOPliZAXzqqjfGB13yl+z7o3nsxQg/sYH1TsGUVlUN3hQcV5I02dp2JCBCrPsNBn9lPhzGnOgNGywI43X6BtDNT9sDz+7ZSN6dnympMeGZ2UZhJmCI= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 89a92fe5-cdf1-47e5-f6fb-08d69db4cf30 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 19:41:57.5072 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1801MB1848 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-28_11:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902280131 Subject: [dpdk-dev] [PATCH] app/testpmd: use mempool bulk get for txonly mode 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: , X-List-Received-Date: Thu, 28 Feb 2019 19:42:05 -0000 From: Pavan Nikhilesh Use mempool bulk get ops to alloc burst of packets and process them instead of calling pktalloc for every packet. Signed-off-by: Pavan Nikhilesh --- app/test-pmd/txonly.c | 139 +++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 1f08b6ed3..eef8b3a45 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -147,6 +147,61 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr, ip_hdr->hdr_checksum =3D (uint16_t) ip_cksum; } =20 +static inline bool +pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp, + struct ether_hdr *eth_hdr, const uint16_t vlan_tci, + const uint16_t vlan_tci_outer, const uint64_t ol_flags) +{ + uint32_t nb_segs, pkt_len =3D 0; + struct rte_mbuf *pkt_seg; + uint8_t i; + + if (unlikely(tx_pkt_split =3D=3D TX_PKT_SPLIT_RND)) + nb_segs =3D random() % tx_pkt_nb_segs + 1; + else + nb_segs =3D tx_pkt_nb_segs; + + rte_pktmbuf_reset_headroom(pkt); + pkt->data_len =3D tx_pkt_seg_lengths[0]; + pkt->ol_flags =3D ol_flags; + pkt->vlan_tci =3D vlan_tci; + pkt->vlan_tci_outer =3D vlan_tci_outer; + pkt->l2_len =3D sizeof(struct ether_hdr); + pkt->l3_len =3D sizeof(struct ipv4_hdr); + + pkt_seg =3D pkt; + for (i =3D 1; i < nb_segs; i++) { + pkt_seg->next =3D rte_mbuf_raw_alloc(mbp); + if (pkt_seg->next =3D=3D NULL) { + pkt->nb_segs =3D i; + rte_pktmbuf_free(pkt); + return false; + } + pkt_seg =3D pkt_seg->next; + pkt_seg->data_len =3D tx_pkt_seg_lengths[i]; + pkt_len +=3D pkt_seg->data_len; + } + pkt_seg->next =3D NULL; /* Last segment of packet. */ + /* + * Copy headers in first packet segment(s). + */ + copy_buf_to_pkt(eth_hdr, sizeof(eth_hdr), pkt, 0); + copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt, + sizeof(struct ether_hdr)); + copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, + sizeof(struct ether_hdr) + + sizeof(struct ipv4_hdr)); + + /* + * Complete first mbuf of packet and append it to the + * burst of packets to be transmitted. + */ + pkt->nb_segs =3D nb_segs; + pkt->pkt_len +=3D pkt_len; + + return true; +} + /* * Transmit a burst of multi-segments packets. */ @@ -155,8 +210,6 @@ pkt_burst_transmit(struct fwd_stream *fs) { struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; struct rte_port *txp; - struct rte_mbuf *pkt; - struct rte_mbuf *pkt_seg; struct rte_mempool *mbp; struct ether_hdr eth_hdr; uint16_t nb_tx; @@ -164,14 +217,12 @@ pkt_burst_transmit(struct fwd_stream *fs) uint16_t vlan_tci, vlan_tci_outer; uint32_t retry; uint64_t ol_flags =3D 0; - uint8_t i; uint64_t tx_offloads; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; uint64_t end_tsc; uint64_t core_cycles; #endif - uint32_t nb_segs, pkt_len; =20 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES start_tsc =3D rte_rdtsc(); @@ -188,72 +239,24 @@ pkt_burst_transmit(struct fwd_stream *fs) ol_flags |=3D PKT_TX_QINQ_PKT; if (tx_offloads & DEV_TX_OFFLOAD_MACSEC_INSERT) ol_flags |=3D PKT_TX_MACSEC; - for (nb_pkt =3D 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { - pkt =3D rte_mbuf_raw_alloc(mbp); - if (pkt =3D=3D NULL) { - nomore_mbuf: - if (nb_pkt =3D=3D 0) - return; - break; - } =20 - /* - * Using raw alloc is good to improve performance, - * but some consumers may use the headroom and so - * decrement data_off. We need to make sure it is - * reset to default value. - */ - rte_pktmbuf_reset_headroom(pkt); - pkt->data_len =3D tx_pkt_seg_lengths[0]; - pkt_seg =3D pkt; - if (tx_pkt_split =3D=3D TX_PKT_SPLIT_RND) - nb_segs =3D random() % tx_pkt_nb_segs + 1; - else - nb_segs =3D tx_pkt_nb_segs; - pkt_len =3D pkt->data_len; - for (i =3D 1; i < nb_segs; i++) { - pkt_seg->next =3D rte_mbuf_raw_alloc(mbp); - if (pkt_seg->next =3D=3D NULL) { - pkt->nb_segs =3D i; - rte_pktmbuf_free(pkt); - goto nomore_mbuf; - } - pkt_seg =3D pkt_seg->next; - pkt_seg->data_len =3D tx_pkt_seg_lengths[i]; - pkt_len +=3D pkt_seg->data_len; - } - pkt_seg->next =3D NULL; /* Last segment of packet. */ - - /* - * Initialize Ethernet header. - */ - ether_addr_copy(&peer_eth_addrs[fs->peer_addr],ð_hdr.d_addr); - ether_addr_copy(&ports[fs->tx_port].eth_addr, ð_hdr.s_addr); - eth_hdr.ether_type =3D rte_cpu_to_be_16(ETHER_TYPE_IPv4); - - /* - * Copy headers in first packet segment(s). - */ - copy_buf_to_pkt(ð_hdr, sizeof(eth_hdr), pkt, 0); - copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt, - sizeof(struct ether_hdr)); - copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, - sizeof(struct ether_hdr) + - sizeof(struct ipv4_hdr)); - - /* - * Complete first mbuf of packet and append it to the - * burst of packets to be transmitted. - */ - pkt->nb_segs =3D nb_segs; - pkt->pkt_len =3D pkt_len; - pkt->ol_flags =3D ol_flags; - pkt->vlan_tci =3D vlan_tci; - pkt->vlan_tci_outer =3D vlan_tci_outer; - pkt->l2_len =3D sizeof(struct ether_hdr); - pkt->l3_len =3D sizeof(struct ipv4_hdr); - pkts_burst[nb_pkt] =3D pkt; + /* + * Initialize Ethernet header. + */ + ether_addr_copy(&peer_eth_addrs[fs->peer_addr], ð_hdr.d_addr); + ether_addr_copy(&ports[fs->tx_port].eth_addr, ð_hdr.s_addr); + eth_hdr.ether_type =3D rte_cpu_to_be_16(ETHER_TYPE_IPv4); + + if (rte_mempool_get_bulk(mbp, (void **)pkts_burst, nb_pkt_per_burst)) + return; + + for (nb_pkt =3D 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { + if (unlikely(!pkt_burst_prepare(pkts_burst[nb_pkt], mbp, + ð_hdr, vlan_tci, vlan_tci_outer, ol_flags))) + goto tx_pkts; } +tx_pkts: + nb_tx =3D rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt)= ; /* * Retry if necessary --=20 2.21.0