Message ID | AMXPR04MB24719A223184635EB3AAD71F9FE0@AMXPR04MB247.eurprd04.prod.outlook.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 0087F58CD; Wed, 24 May 2017 09:28:24 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0070.outbound.protection.outlook.com [104.47.0.70]) by dpdk.org (Postfix) with ESMTP id 27523548B for <dev@dpdk.org>; Wed, 24 May 2017 09:28:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MlMc7mhsSvEJLrh5FdY+Rwz6DMmYwq+kEX2A2q7b7xk=; b=ayFOfVNvlxab55DHLXeP/bZTjV1ybG67UCoputPBw33scy3rLWMTTsnpONVDEWgBNJW7iPfljzZ5e4wH1wI7K/BV3BoG2WxJia/gIbZtn9W3XxrWCRYPao+lShxZ4IYqOwHJuvd2i/zPFM06u1z5vJ6QlYms5e+KifB1KxD6jx4= Received: from AMXPR04MB247.eurprd04.prod.outlook.com (10.242.72.18) by AMXPR04MB247.eurprd04.prod.outlook.com (10.242.72.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Wed, 24 May 2017 07:28:19 +0000 Received: from AMXPR04MB247.eurprd04.prod.outlook.com ([fe80::f921:4f84:e09d:9d3d]) by AMXPR04MB247.eurprd04.prod.outlook.com ([fe80::f921:4f84:e09d:9d3d%28]) with mapi id 15.01.1101.019; Wed, 24 May 2017 07:28:19 +0000 From: Ashish Jain <ashish.jain@nxp.com> To: "dev@dpdk.org" <dev@dpdk.org>, "konstantin.ananyev@intel.com" <konstantin.ananyev@intel.com> Thread-Topic: [dpdk-dev] [PATCH] examples/ip_fragmentation: add fragmentation size support Thread-Index: AQHSuaZrharJKCJ8yE+LH2TJOP8AAaIDSoGg Date: Wed, 24 May 2017 07:28:19 +0000 Message-ID: <AMXPR04MB24719A223184635EB3AAD71F9FE0@AMXPR04MB247.eurprd04.prod.outlook.com> References: <1492672688-3571-1-git-send-email-ashish.jain@nxp.com> In-Reply-To: <1492672688-3571-1-git-send-email-ashish.jain@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.169.1] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AMXPR04MB247; 7:oqARYP7kv+jHuYLIo0azrHpFrZSO/o/ZG1Itqd3bIlrcfLBuWhsvoX+dR5L+xxP7hN8DSioGWlryPOezitP2md1R8ySfbixMawh06aLx3ybYMx5BjN/vaCVraO5bqjBbkVJR97nB/KTpHKhohsa4k65z0z9uJwwA+QgYQZiz0vwKB7baOg7B/VePyO1HK/YfGjP26iNiOdE58b4IqB3pt0tczznO6qbnxQlpT5OBOu8aS56Zi7rHKXB2faaiICF2GmtRvvURIPHHPH4/UbiCjaUV75wlgJhlOe4Vx9jd8A5EDc5jOFTUwweWlC5x/rL6AY0sIizDcO2lV9a68ExKmw== x-ms-traffictypediagnostic: AMXPR04MB247: x-ms-office365-filtering-correlation-id: aa72b812-a6d5-4e4e-297e-08d4a2767380 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081); SRVR:AMXPR04MB247; x-microsoft-antispam-prvs: <AMXPR04MB24768DB3FC4BD0475DFD896F9FE0@AMXPR04MB247.eurprd04.prod.outlook.com> x-exchange-antispam-report-test: UriScan:(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:AMXPR04MB247; BCL:0; PCL:0; RULEID:; SRVR:AMXPR04MB247; x-forefront-prvs: 031763BCAF x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(39410400002)(39400400002)(39840400002)(39850400002)(39450400003)(377454003)(13464003)(38730400002)(6436002)(2501003)(6246003)(2906002)(7736002)(478600001)(66066001)(53936002)(229853002)(305945005)(5660300001)(189998001)(33656002)(86362001)(6116002)(9686003)(5250100002)(6506006)(74316002)(25786009)(53546009)(55016002)(2950100002)(102836003)(3280700002)(54356999)(76176999)(50986999)(3846002)(3660700001)(81166006)(99286003)(7696004)(8936002)(2900100001); DIR:OUT; SFP:1101; SCL:1; SRVR:AMXPR04MB247; H:AMXPR04MB247.eurprd04.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 24 May 2017 07:28:19.2932 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMXPR04MB247 Subject: Re: [dpdk-dev] [PATCH] examples/ip_fragmentation: add fragmentation size support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | warning | coding style issues |
ci/Intel-compilation | success | Compilation OK |
Commit Message
Ashish Jain
May 24, 2017, 7:28 a.m. UTC
Hi, -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ashish Jain Sent: Thursday, April 20, 2017 12:48 PM To: dev@dpdk.org; konstantin.ananyev@intel.com Subject: [dpdk-dev] [PATCH] examples/ip_fragmentation: add fragmentation size support Adding support for determining fragmentation size for both ipv4 and ipv6 traffic dynamically through command line. It is helpful in testing to configure different fragmentation sizes and validate the packets. Signed-off-by: Ashish Jain <ashish.jain@nxp.com> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com> --- examples/ip_fragmentation/main.c | 89 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 8 deletions(-) /* if we don't need to do any fragmentation */ - if (likely (IPV4_MTU_DEFAULT >= m->pkt_len)) { + if (likely (frag_size_v4 >= m->pkt_len)) { qconf->tx_mbufs[port_out].m_table[len] = m; len2 = 1; } else { len2 = rte_ipv4_fragment_packet(m, &qconf->tx_mbufs[port_out].m_table[len], (uint16_t)(MBUF_TABLE_SIZE - len), - IPV4_MTU_DEFAULT, + frag_size_v4, rxq->direct_pool, rxq->indirect_pool); /* Free input packet */ @@ -336,14 +346,14 @@ struct rte_lpm6_config lpm6_config = { } /* if we don't need to do any fragmentation */ - if (likely (IPV6_MTU_DEFAULT >= m->pkt_len)) { + if (likely (frag_size_v6 >= m->pkt_len)) { qconf->tx_mbufs[port_out].m_table[len] = m; len2 = 1; } else { len2 = rte_ipv6_fragment_packet(m, &qconf->tx_mbufs[port_out].m_table[len], (uint16_t)(MBUF_TABLE_SIZE - len), - IPV6_MTU_DEFAULT, + frag_size_v6, rxq->direct_pool, rxq->indirect_pool); /* Free input packet */ @@ -489,8 +499,14 @@ struct rte_lpm6_config lpm6_config = { { printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" " -p PORTMASK: hexadecimal bitmask of ports to configure\n" - " -q NQ: number of queue (=ports) per lcore (default is 1)\n", - prgname); + " -q NQ: number of queue (=ports) per lcore (default is 1)\n" + " --frag_size_v4=<num>:optional,IPv4 fragment size in decimal" + ",Condition:(frag_size_v4 - 20) should be a multiple of 8," + " default is %d \n" + " --frag_size_v6=<num>:optional,IPv6 fragment size in decimal" + ",Condition:(frag_size_v6 - 40) should be a multiple of 8," + " default is %d\n", + prgname, frag_size_v4, frag_size_v6); } static int @@ -528,6 +544,29 @@ struct rte_lpm6_config lpm6_config = { return n; } +static int +parse_frag_size(const char *str, uint32_t min, uint32_t max, + uint8_t hdr_size, uint32_t *val) { + char *end; + uint64_t v; + + /* parse decimal string */ + errno = 0; + v = strtoul(str, &end, 10); + if (errno != 0 || *end != '\0') + return -EINVAL; + + if (v < min || v > max) + return -EINVAL; + + if ((v - hdr_size) % 8) + return -EINVAL; + + *val = (uint32_t)v; + return 0; +} + /* Parse the argument given in the command line of the application */ static int parse_args(int argc, char **argv) @@ -537,6 +576,8 @@ struct rte_lpm6_config lpm6_config = { int option_index; char *prgname = argv[0]; static struct option lgopts[] = { + {"frag_size_v4", 1, 0, 0}, + {"frag_size_v6", 1, 0, 0}, {NULL, 0, 0, 0} }; @@ -568,8 +609,40 @@ struct rte_lpm6_config lpm6_config = { /* long options */ case 0: - print_usage(prgname); - return -1; + if (!strncmp(lgopts[option_index].name, + "frag_size_v4", 12)) { + ret = parse_frag_size(optarg, + MIN_IPV4_FRAG_SIZE, + MAX_IPV4_FRAG_SIZE, + sizeof(struct ipv4_hdr), + &frag_size_v4); + if (ret) { + printf("invalid value: \"%s\" for " + "parameter %s\n", + optarg, + lgopts[option_index].name); + print_usage(prgname); + return ret; + } + } + if (!strncmp(lgopts[option_index].name, + "frag_size_v6", 12)) { + ret = parse_frag_size(optarg, + MIN_IPV6_FRAG_SIZE, + MAX_IPV6_FRAG_SIZE, + sizeof(struct ipv6_hdr), + &frag_size_v6); + if (ret) { + printf("invalid value: \"%s\" for " + "parameter %s\n", + optarg, + lgopts[option_index].name); + print_usage(prgname); + return ret; + } + } + + break; default: print_usage(prgname); -- 1.9.1 Any comments on this patch? Cheers Ashish
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 815b225..436755b 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -94,6 +94,16 @@ #define IPV6_DEFAULT_PAYLOAD (IPV6_MTU_DEFAULT - sizeof(struct ipv6_hdr)) /* + * Configure fragmentation size for IPv4 and IPv6 packets */ static +uint32_t frag_size_v4 = IPV4_MTU_DEFAULT; static uint32_t frag_size_v6 += IPV6_MTU_DEFAULT; #define MIN_IPV4_FRAG_SIZE 64 #define +MAX_IPV4_FRAG_SIZE 9600 #define MIN_IPV6_FRAG_SIZE 1280 #define +MAX_IPV6_FRAG_SIZE 9600 + +/* * Max number of fragments per packet expected - defined by config file. */ #define MAX_PACKET_FRAG RTE_LIBRTE_IP_FRAG_MAX_FRAG @@ -299,14 +309,14 @@ struct rte_lpm6_config lpm6_config = { }