From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D4D0B7CDA for ; Sun, 4 Jun 2017 17:44:19 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2017 08:44:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,296,1493708400"; d="scan'208";a="270048708" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga004.fm.intel.com with ESMTP; 04 Jun 2017 08:44:17 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.250]) by IRSMSX102.ger.corp.intel.com ([169.254.2.87]) with mapi id 14.03.0319.002; Sun, 4 Jun 2017 16:44:17 +0100 From: "Ananyev, Konstantin" To: Ashish Jain , "dev@dpdk.org" Thread-Topic: [PATCH] examples/ip_fragmentation: add fragmentation size support Thread-Index: AQHSuaZT710LpZVa9keXgYsJ7u1SqaIVHzvg Date: Sun, 4 Jun 2017 15:44:15 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583FB0589E@IRSMSX109.ger.corp.intel.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-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jun 2017 15:44:20 -0000 Hi,=20 > -----Original Message----- > From: Ashish Jain [mailto:ashish.jain@nxp.com] > Sent: Thursday, April 20, 2017 8:18 AM > To: dev@dpdk.org; Ananyev, Konstantin > Subject: [PATCH] examples/ip_fragmentation: add fragmentation size suppor= t >=20 > 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. >=20 > Signed-off-by: Ashish Jain > Signed-off-by: Hemant Agrawal > --- > examples/ip_fragmentation/main.c | 89 ++++++++++++++++++++++++++++++++++= ++---- > 1 file changed, 81 insertions(+), 8 deletions(-) >=20 > 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)= ) >=20 > /* > + * Configure fragmentation size for IPv4 and IPv6 packets > + */ > +static uint32_t frag_size_v4 =3D IPV4_MTU_DEFAULT; > +static uint32_t frag_size_v6 =3D 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 =3D { > } >=20 > /* if we don't need to do any fragmentation */ > - if (likely (IPV4_MTU_DEFAULT >=3D m->pkt_len)) { > + if (likely (frag_size_v4 >=3D m->pkt_len)) { > qconf->tx_mbufs[port_out].m_table[len] =3D m; > len2 =3D 1; > } else { > len2 =3D 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); >=20 > /* Free input packet */ > @@ -336,14 +346,14 @@ struct rte_lpm6_config lpm6_config =3D { > } >=20 > /* if we don't need to do any fragmentation */ > - if (likely (IPV6_MTU_DEFAULT >=3D m->pkt_len)) { > + if (likely (frag_size_v6 >=3D m->pkt_len)) { > qconf->tx_mbufs[port_out].m_table[len] =3D m; > len2 =3D 1; > } else { > len2 =3D 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); >=20 > /* Free input packet */ > @@ -489,8 +499,14 @@ struct rte_lpm6_config lpm6_config =3D { > { > printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" > " -p PORTMASK: hexadecimal bitmask of ports to configure\n" > - " -q NQ: number of queue (=3Dports) per lcore (default is 1)\n"= , > - prgname); > + " -q NQ: number of queue (=3Dports) per lcore (default is 1)\n" > + " --frag_size_v4=3D:optional,IPv4 fragment size in decimal= " > + ",Condition:(frag_size_v4 - 20) should be a multiple of 8," > + " default is %d \n" > + " --frag_size_v6=3D: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); > } >=20 > static int > @@ -528,6 +544,29 @@ struct rte_lpm6_config lpm6_config =3D { > return n; > } >=20 > +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 =3D 0; > + v =3D strtoul(str, &end, 10); > + if (errno !=3D 0 || *end !=3D '\0') > + return -EINVAL; > + > + if (v < min || v > max) > + return -EINVAL; > + > + if ((v - hdr_size) % 8) > + return -EINVAL; > + > + *val =3D (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 =3D { > int option_index; > char *prgname =3D argv[0]; > static struct option lgopts[] =3D { > + {"frag_size_v4", 1, 0, 0}, > + {"frag_size_v6", 1, 0, 0}, > {NULL, 0, 0, 0} > }; >=20 > @@ -568,8 +609,40 @@ struct rte_lpm6_config lpm6_config =3D { >=20 > /* long options */ > case 0: > - print_usage(prgname); > - return -1; > + if (!strncmp(lgopts[option_index].name, > + "frag_size_v4", 12)) { Why just not strcmp() here? > + ret =3D 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 =3D 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; Hmm, why do we need that break here? Konstantin >=20 > default: > print_usage(prgname); > -- > 1.9.1