diff mbox series

[API-NEXT,v1,13/14] example: generator: add configuration option for csum support

Message ID 1513008012-9231-14-git-send-email-odpbot@yandex.ru
State New
Headers show
Series None | expand

Commit Message

Github ODP bot Dec. 11, 2017, 4 p.m. UTC
From: Bogdan Pricope <bogdan.pricope@linaro.org>


Add configuration option to enable platform checksum support
(if available) for calculation and validation. By default,
checksum calculation is performed in software and validation
is disabled.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 335 (muvarov:devel/api-next_master_merge)
 ** https://github.com/Linaro/odp/pull/335
 ** Patch: https://github.com/Linaro/odp/pull/335.patch
 ** Base sha: 630d8422564ebf4991b468cb38a29e9483fc2ec2
 ** Merge commit sha: 2de2af9eca01b713e51c66fee7a5c7e535502f85
 **/
 example/generator/odp_generator.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 47b91d6ef..0a81cdeb3 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -76,6 +76,7 @@  typedef struct {
 				     each packet */
 	int udp_tx_burst;	/**< number of udp packets to send with one
 				      API call */
+	odp_bool_t csum;	/**< use platform csum support if available */
 } appl_args_t;
 
 /**
@@ -516,14 +517,26 @@  static int create_pktio(const char *dev, odp_pool_t pool,
 		return -1;
 	}
 	odp_pktio_config_init(&itf->config);
-	itf->config.pktin.bit.ipv4_chksum = capa.config.pktin.bit.ipv4_chksum;
-	itf->config.pktin.bit.udp_chksum = capa.config.pktin.bit.udp_chksum;
-	itf->config.pktin.bit.drop_ipv4_err =
-		capa.config.pktin.bit.drop_ipv4_err;
-	itf->config.pktin.bit.drop_udp_err = capa.config.pktin.bit.drop_udp_err;
-
-	itf->config.pktout.bit.ipv4_chksum = capa.config.pktout.bit.ipv4_chksum;
-	itf->config.pktout.bit.udp_chksum = capa.config.pktout.bit.udp_chksum;
+	if (args->appl.csum) {
+		itf->config.pktin.bit.ipv4_chksum =
+			capa.config.pktin.bit.ipv4_chksum;
+		itf->config.pktin.bit.udp_chksum =
+			capa.config.pktin.bit.udp_chksum;
+		itf->config.pktin.bit.drop_ipv4_err =
+			capa.config.pktin.bit.drop_ipv4_err;
+		itf->config.pktin.bit.drop_udp_err =
+			capa.config.pktin.bit.drop_udp_err;
+
+		itf->config.pktout.bit.ipv4_chksum =
+			capa.config.pktout.bit.ipv4_chksum;
+		itf->config.pktout.bit.udp_chksum =
+			capa.config.pktout.bit.udp_chksum;
+	} else { /* explicit disable */
+		itf->config.pktin.bit.ipv4_chksum = 0;
+		itf->config.pktin.bit.udp_chksum = 0;
+		itf->config.pktout.bit.ipv4_chksum = 0;
+		itf->config.pktout.bit.udp_chksum = 0;
+	}
 
 	if (odp_pktio_config(itf->pktio, &itf->config)) {
 		EXAMPLE_ERR("Error: Failed to set interface configuration %s\n",
@@ -1299,10 +1312,11 @@  static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
 		{"interval", required_argument, NULL, 'i'},
 		{"help", no_argument, NULL, 'h'},
 		{"udp_tx_burst", required_argument, NULL, 'x'},
+		{"csum", no_argument, NULL, 'y'},
 		{NULL, 0, NULL, 0}
 	};
 
-	static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:";
+	static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:x:he:f:y";
 
 	/* let helper collect its own arguments (e.g. --odph_proc) */
 	odph_parse_options(argc, argv, shortopts, longopts);
@@ -1315,6 +1329,7 @@  static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
 	appl_args->udp_tx_burst = DEFAULT_UDP_TX_BURST;
 	appl_args->srcport = 0;
 	appl_args->dstport = 0;
+	appl_args->csum = 0;
 
 	opterr = 0; /* do not issue errors on helper options */
 
@@ -1455,6 +1470,9 @@  static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
 			}
 			break;
 
+		case 'y':
+			appl_args->csum = 1;
+			break;
 		case 'h':
 			usage(argv[0]);
 			exit(EXIT_SUCCESS);
@@ -1541,6 +1559,8 @@  static void usage(char *progname)
 	       "  -n, --count the number of packets to be send\n"
 	       "  -c, --cpumask to set on cores\n"
 	       "  -x, --udp_tx_burst size of UDP TX burst\n"
+	       "  -y, --csum use platform checksum support if available\n"
+	       "	         default is disabled\n"
 	       "\n", NO_PATH(progname), NO_PATH(progname)
 	      );
 }