From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 67479235 for ; Fri, 30 Jun 2017 14:34:47 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP; 30 Jun 2017 05:34:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,286,1496127600"; d="scan'208";a="1166611728" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga001.fm.intel.com with ESMTP; 30 Jun 2017 05:34:45 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX109.ger.corp.intel.com (163.33.3.23) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 30 Jun 2017 13:34:44 +0100 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.115]) by irsmsx155.ger.corp.intel.com ([169.254.14.182]) with mapi id 14.03.0319.002; Fri, 30 Jun 2017 13:34:44 +0100 From: "Ananyev, Konstantin" To: Ashish Jain , "dev@dpdk.org" CC: Hemant Agrawal Thread-Topic: [PATCH v2] example/ip_fragmentation: add fragmentation size support Thread-Index: AQHS8Zr0EDiugWr66ky6QFx/X5Y3p6I9Vu/w Date: Fri, 30 Jun 2017 12:34:43 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772583FB18610@IRSMSX109.ger.corp.intel.com> References: <1492672688-3571-1-git-send-email-ashish.jain@nxp.com> <1498825083-21117-1-git-send-email-ashish.jain@nxp.com> In-Reply-To: <1498825083-21117-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.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] example/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: Fri, 30 Jun 2017 12:34:48 -0000 > -----Original Message----- > From: Ashish Jain [mailto:ashish.jain@nxp.com] > Sent: Friday, June 30, 2017 1:18 PM > To: Ananyev, Konstantin ; dev@dpdk.org > Cc: Ashish Jain ; Hemant Agrawal > Subject: [PATCH v2] example/ip_fragmentation: add fragmentation size supp= ort >=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 > --- > Changes in v2: > * used strncmp while associating long options with short ones > * added detailed usage for new added params >=20 > examples/ip_fragmentation/main.c | 96 ++++++++++++++++++++++++++++++++++= ++---- > 1 file changed, 88 insertions(+), 8 deletions(-) >=20 > diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation= /main.c > index 2f45264..c0b36cd 100644 > --- a/examples/ip_fragmentation/main.c > +++ b/examples/ip_fragmentation/main.c > @@ -95,6 +95,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 > @@ -139,6 +149,9 @@ static struct ether_addr ports_eth_addr[RTE_MAX_ETHPO= RTS]; >=20 > #define IPV6_ADDR_LEN 16 >=20 > +#define CMD_LINE_OPT_IPV4_FRAG_SIZE "frag_size_v4" > +#define CMD_LINE_OPT_IPV6_FRAG_SIZE "frag_size_v6" > + > /* mask of enabled ports */ > static int enabled_port_mask =3D 0; >=20 > @@ -300,14 +313,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lco= re_queue_conf *qconf, > } >=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 +349,14 @@ l3fwd_simple_forward(struct rte_mbuf *m, struct lco= re_queue_conf *qconf, > } >=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 +502,16 @@ print_usage(const char *prgname) > { > 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 deci= mal,\n" > + "\t Condition:(frag_size_v4 - 20) should be a multiple of 8\n" > + "\t Min value: %d , Max value: %d, default is %d \n" > + " --frag_size_v6=3D: optional, IPv6 fragment size in deci= mal,\n" > + "\t Condition:(frag_size_v6 - 40) should be a multiple of 8\n" > + "\t Min value: %d , Max value: %d, default is %d \n", > + prgname, MIN_IPV4_FRAG_SIZE, MAX_IPV4_FRAG_SIZE, > + IPV4_MTU_DEFAULT, MIN_IPV6_FRAG_SIZE, MAX_IPV6_FRAG_SIZE, > + IPV6_MTU_DEFAULT); > } >=20 > static int > @@ -528,6 +549,29 @@ parse_nqueue(const char *q_arg) > 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 +581,8 @@ parse_args(int argc, char **argv) > 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 +614,42 @@ parse_args(int argc, char **argv) >=20 > /* long options */ > case 0: > - print_usage(prgname); > - return -1; > + if (!strncmp(lgopts[option_index].name, > + CMD_LINE_OPT_IPV4_FRAG_SIZE, > + sizeof(CMD_LINE_OPT_IPV4_FRAG_SIZE))) { > + 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, > + CMD_LINE_OPT_IPV6_FRAG_SIZE, > + sizeof(CMD_LINE_OPT_IPV6_FRAG_SIZE))) { > + 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; Seems you ignored my comments for v1? Konstantin >=20 > default: > print_usage(prgname); > -- > 2.7.4