From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 47D3FA04DB;
	Thu, 15 Oct 2020 15:24:38 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id B9D6A1E933;
	Thu, 15 Oct 2020 15:24:03 +0200 (CEST)
Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13])
 by dpdk.org (Postfix) with ESMTP id 28D7B1E8FA
 for <dev@dpdk.org>; Thu, 15 Oct 2020 15:23:58 +0200 (CEST)
Received: from inva020.nxp.com (localhost [127.0.0.1])
 by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 006171A07F7;
 Thu, 15 Oct 2020 15:23:57 +0200 (CEST)
Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com
 [165.114.16.14])
 by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 5EAA21A0807;
 Thu, 15 Oct 2020 15:23:52 +0200 (CEST)
Received: from lsv03273.swis.in-blr01.nxp.com (lsv03273.swis.in-blr01.nxp.com
 [92.120.147.113])
 by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 04D8C40310;
 Thu, 15 Oct 2020 15:23:46 +0200 (CEST)
From: nipun.gupta@nxp.com
To: dev@dpdk.org
Cc: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com,
 hemant.agrawal@nxp.com, sachin.saxena@nxp.com, rohit.raj@nxp.com,
 jerinjacobk@gmail.com, stephen@networkplumber.org, asafp@nvidia.com,
 Nipun Gupta <nipun.gupta@nxp.com>
Date: Thu, 15 Oct 2020 18:53:43 +0530
Message-Id: <20201015132343.4050-3-nipun.gupta@nxp.com>
X-Mailer: git-send-email 2.17.1
In-Reply-To: <20201015132343.4050-1-nipun.gupta@nxp.com>
References: <20200831075333.10135-1-nipun.gupta@nxp.com>
 <20201015132343.4050-1-nipun.gupta@nxp.com>
X-Virus-Scanned: ClamAV using ClamSMTP
Subject: [dpdk-dev] [PATCH 3/3 v4] app/testpmd: support hardware offload to
	drop error packets
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

From: Nipun Gupta <nipun.gupta@nxp.com>

With DEV_RX_OFFLOAD_ERR_PKT_DROP now defined as an offload
capability, and separate RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_ALL
capability to drop all error packets in hardware, testpmd
showcases this with a new added configuration option
'enable-hw-drop-err-all'.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 app/test-pmd/config.c                 | 35 +++++++++++++++++++++
 app/test-pmd/parameters.c             |  7 +++++
 app/test-pmd/testpmd.c                |  8 +++++
 app/test-pmd/testpmd.h                |  1 +
 doc/guides/nics/features.rst          | 44 +++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/run_app.rst |  4 +++
 6 files changed, 99 insertions(+)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index e73dc66c8..14ef4e468 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1027,6 +1027,41 @@ port_offload_cap_display(portid_t port_id)
 			printf("off\n");
 	}
 
+	if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_ERR_PKT_DROP) {
+		if (dev_info.rx_err_drop_offload_capa &
+			RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L1_FCS) {
+			printf("RX L1 FCS Error pkt drop:      ");
+			if (ports[port_id].dev_conf.err_pkt_drop_conf.l1_fcs)
+				printf("on\n");
+			else
+				printf("off\n");
+		}
+		if (dev_info.rx_err_drop_offload_capa &
+			RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L3_CSUM) {
+			printf("RX L3 Csum Error pkt drop:     ");
+			if (ports[port_id].dev_conf.err_pkt_drop_conf.l3_csum)
+				printf("on\n");
+			else
+				printf("off\n");
+		}
+		if (dev_info.rx_err_drop_offload_capa &
+			RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L4_CSUM) {
+			printf("RX L4 Csum Error pkt drop:     ");
+			if (ports[port_id].dev_conf.err_pkt_drop_conf.l4_csum)
+				printf("on\n");
+			else
+				printf("off\n");
+		}
+		if (dev_info.rx_err_drop_offload_capa &
+			RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_ALL) {
+			printf("RX all Error pkt drop:         ");
+			if (ports[port_id].dev_conf.err_pkt_drop_conf.all)
+				printf("on\n");
+			else
+				printf("off\n");
+		}
+	}
+
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_VLAN_INSERT) {
 		printf("VLAN insert:                   ");
 		if (ports[port_id].dev_conf.txmode.offloads &
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index 1ead59579..508612426 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -142,6 +142,7 @@ usage(char* progname)
 	printf("  --enable-hw-vlan-strip: enable hardware vlan strip.\n");
 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
 	printf("  --enable-hw-qinq-strip: enable hardware qinq strip.\n");
+	printf("  --enable-hw-drop-err-all: enable hardware packet drop for all error packets.\n");
 	printf("  --enable-drop-en: enable per queue packet drop.\n");
 	printf("  --disable-rss: disable rss.\n");
 	printf("  --port-topology=<paired|chained|loop>: set port topology (paired "
@@ -631,6 +632,7 @@ launch_args_parse(int argc, char** argv)
 		{ "enable-hw-vlan-strip",       0, 0, 0 },
 		{ "enable-hw-vlan-extend",      0, 0, 0 },
 		{ "enable-hw-qinq-strip",       0, 0, 0 },
+		{ "enable-hw-drop-err-all",     0, 0, 0 },
 		{ "enable-drop-en",            0, 0, 0 },
 		{ "disable-rss",                0, 0, 0 },
 		{ "port-topology",              1, 0, 0 },
@@ -1283,6 +1285,11 @@ launch_args_parse(int argc, char** argv)
 				rmv_interrupt = 0;
 			if (!strcmp(lgopts[opt_idx].name, "flow-isolate-all"))
 				flow_isolate_all = 1;
+			if (!strcmp(lgopts[opt_idx].name,
+					"enable-hw-drop-err-all")) {
+				rx_err_pkt_drop_all = 1;
+			}
+
 			if (!strcmp(lgopts[opt_idx].name, "tx-offloads")) {
 				char *end = NULL;
 				n = strtoull(optarg, &end, 16);
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index ccba71c07..c9e7397e6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -359,6 +359,11 @@ uint8_t lsc_interrupt = 1; /* enabled by default */
  */
 uint8_t rmv_interrupt = 1; /* enabled by default */
 
+/*
+ * Drop all RX error packets on HW itself.
+ */
+uint8_t rx_err_pkt_drop_all = 0; /* disabled by default */
+
 uint8_t hot_plug = 0; /**< hotplug disabled by default. */
 
 /* After attach, port setup is called on event or by iterator */
@@ -3359,6 +3364,9 @@ init_port_config(void)
 		    (rte_eth_devices[pid].data->dev_flags &
 		     RTE_ETH_DEV_INTR_RMV))
 			port->dev_conf.intr_conf.rmv = 1;
+
+		if (rx_err_pkt_drop_all)
+			port->dev_conf.err_pkt_drop_conf.all = 1;
 	}
 }
 
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c7e7e41a9..eab154ed4 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -314,6 +314,7 @@ extern uint8_t no_device_start; /**<set by "--disable-device-start" parameter */
 extern volatile int test_done; /* stop packet forwarding when set to 1. */
 extern uint8_t lsc_interrupt; /**< disabled by "--no-lsc-interrupt" parameter */
 extern uint8_t rmv_interrupt; /**< disabled by "--no-rmv-interrupt" parameter */
+extern uint8_t rx_err_pkt_drop_all; /**< enabled by "--enable-hw-drop-err-all" parameter */
 extern uint32_t event_print_mask;
 /**< set by "--print-event xxxx" and "--mask-event xxxx parameters */
 extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */
diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst
index dd8c9555b..cb7fdfd8b 100644
--- a/doc/guides/nics/features.rst
+++ b/doc/guides/nics/features.rst
@@ -606,6 +606,50 @@ Supports inner packet L4 checksum.
   ``tx_offload_capa,tx_queue_offload_capa:DEV_TX_OFFLOAD_OUTER_UDP_CKSUM``.
 
 
+.. _nic_features_l1_fcs_rx_error_packet_drop:
+
+L1 FCS Error Packet drop on Rx
+------------------------------
+
+Supports dropping of packets having L1 FCS error on Rx.
+
+* **[uses]     user config**: ``dev_conf.err_pkt_drop_conf.l1_fcs``.
+* **[provides] rte_eth_dev_info**: ``rx_err_drop_offload_capa:RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L1_FCS``.
+
+
+.. _nic_features_l3_csum_rx_error_packet_drop:
+
+L3 checksum Error Packet drop on Rx
+-----------------------------------
+
+Supports dropping of packets having L3 Checksum error on Rx.
+
+* **[uses]     user config**: ``dev_conf.err_pkt_drop_conf.l3_csum``.
+* **[provides] rte_eth_dev_info**: ``rx_err_drop_offload_capa:RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L3_CSUM``.
+
+
+.. _nic_features_l4_csum_rx_error_packet_drop:
+
+L4 Checksum Error Packet drop on Rx
+-----------------------------------
+
+Supports dropping of packets having L1 FCS error on Rx.
+
+* **[uses]     user config**: ``dev_conf.err_pkt_drop_conf.l4_csum``.
+* **[provides] rte_eth_dev_info**: ``rx_err_drop_offload_capa:RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_L4_CSUM``.
+
+
+.. _nic_features_all_rx_error_packet_drop:
+
+All/any Error Packet drop on Rx
+-------------------------------
+
+Supports dropping of packets having any of the errors like L1 FSC, L3/L4 Checksum on Rx.
+
+* **[uses]     user config**: ``dev_conf.err_pkt_drop_conf.all``.
+* **[provides] rte_eth_dev_info**: ``rx_err_drop_offload_capa:RTE_DEV_RX_ERR_PKT_DROP_OFFLOAD_ALL``.
+
+
 .. _nic_features_packet_type_parsing:
 
 Packet type parsing
diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst
index e2539f693..20f2f8083 100644
--- a/doc/guides/testpmd_app_ug/run_app.rst
+++ b/doc/guides/testpmd_app_ug/run_app.rst
@@ -213,6 +213,10 @@ The command line options are:
 
     Enable hardware QINQ strip.
 
+*  ``--enable-hw-drop-err-all``
+
+    Enable hardware packet drop for any error packets
+
 *   ``--enable-drop-en``
 
     Enable per-queue packet drop for packets with no descriptors.
-- 
2.17.1