DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shahed Shaikh <shshaikh@marvell.com>
To: <dev@dpdk.org>
Cc: <rmody@marvell.com>, <ferruh.yigit@intel.com>,
	<GR-Everest-DPDK-Dev@marvell.com>
Subject: [dpdk-dev] [PATCH 2/2] net/qede: implement rte_flow drop action
Date: Wed, 4 Sep 2019 04:30:46 -0700	[thread overview]
Message-ID: <20190904113046.2213-2-shshaikh@marvell.com> (raw)
In-Reply-To: <20190904113046.2213-1-shshaikh@marvell.com>

Add support to configure drop action in RTE_FLOW
infrastructure. Also, add statistics counter for dropped
packets due to this filter action "rx_gft_filter_drop"

Signed-off-by: Shahed Shaikh <shshaikh@marvell.com>
---
 drivers/net/qede/base/ecore_dev_api.h |  1 +
 drivers/net/qede/base/ecore_l2.c      | 50 +++++++++++++++------------
 drivers/net/qede/base/ecore_l2_api.h  | 39 ++++++++++++++-------
 drivers/net/qede/qede_ethdev.c        |  2 ++
 drivers/net/qede/qede_ethdev.h        |  1 +
 drivers/net/qede/qede_filter.c        | 22 ++++++++----
 6 files changed, 75 insertions(+), 40 deletions(-)

diff --git a/drivers/net/qede/base/ecore_dev_api.h b/drivers/net/qede/base/ecore_dev_api.h
index 730806321..a99888097 100644
--- a/drivers/net/qede/base/ecore_dev_api.h
+++ b/drivers/net/qede/base/ecore_dev_api.h
@@ -334,6 +334,7 @@ struct ecore_eth_stats_common {
 	u64 rx_bcast_pkts;
 	u64 mftag_filter_discards;
 	u64 mac_filter_discards;
+	u64 gft_filter_drop;
 	u64 tx_ucast_bytes;
 	u64 tx_mcast_bytes;
 	u64 tx_bcast_bytes;
diff --git a/drivers/net/qede/base/ecore_l2.c b/drivers/net/qede/base/ecore_l2.c
index 8b9817eb2..5dcdc84fc 100644
--- a/drivers/net/qede/base/ecore_l2.c
+++ b/drivers/net/qede/base/ecore_l2.c
@@ -1782,6 +1782,8 @@ static void __ecore_get_vport_tstats(struct ecore_hwfn *p_hwfn,
 		HILO_64_REGPAIR(tstats.mftag_filter_discard);
 	p_stats->common.mac_filter_discards +=
 		HILO_64_REGPAIR(tstats.eth_mac_filter_discard);
+	p_stats->common.gft_filter_drop +=
+		HILO_64_REGPAIR(tstats.eth_gft_drop_pkt);
 }
 
 static void __ecore_get_vport_ustats_addrlen(struct ecore_hwfn *p_hwfn,
@@ -2140,9 +2142,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 enum _ecore_status_t
 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
 				  struct ecore_spq_comp_cb *p_cb,
-				  dma_addr_t p_addr, u16 length,
-				  u16 qid, u8 vport_id,
-				  bool b_is_add)
+				  struct ecore_ntuple_filter_params *p_params)
 {
 	struct rx_update_gft_filter_data *p_ramrod = OSAL_NULL;
 	struct ecore_spq_entry *p_ent = OSAL_NULL;
@@ -2151,14 +2151,6 @@ ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
 	u8 abs_vport_id = 0;
 	enum _ecore_status_t rc = ECORE_NOTIMPL;
 
-	rc = ecore_fw_vport(p_hwfn, vport_id, &abs_vport_id);
-	if (rc != ECORE_SUCCESS)
-		return rc;
-
-	rc = ecore_fw_l2_queue(p_hwfn, qid, &abs_rx_q_id);
-	if (rc != ECORE_SUCCESS)
-		return rc;
-
 	/* Get SPQ entry */
 	OSAL_MEMSET(&init_data, 0, sizeof(init_data));
 	init_data.cid = ecore_spq_get_cid(p_hwfn);
@@ -2180,27 +2172,41 @@ ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
 
 	p_ramrod = &p_ent->ramrod.rx_update_gft;
 
-	DMA_REGPAIR_LE(p_ramrod->pkt_hdr_addr, p_addr);
-	p_ramrod->pkt_hdr_length = OSAL_CPU_TO_LE16(length);
+	DMA_REGPAIR_LE(p_ramrod->pkt_hdr_addr, p_params->addr);
+	p_ramrod->pkt_hdr_length = OSAL_CPU_TO_LE16(p_params->length);
 
-	p_ramrod->action_icid_valid = 0;
-	p_ramrod->action_icid = 0;
+	if (p_params->b_is_drop) {
+		p_ramrod->vport_id = OSAL_CPU_TO_LE16(ETH_GFT_TRASHCAN_VPORT);
+	} else {
+		rc = ecore_fw_vport(p_hwfn, p_params->vport_id,
+				    &abs_vport_id);
+		if (rc)
+			return rc;
+
+		if (p_params->qid != ECORE_RFS_NTUPLE_QID_RSS) {
+			rc = ecore_fw_l2_queue(p_hwfn, p_params->qid,
+					       &abs_rx_q_id);
+			if (rc)
+				return rc;
 
-	p_ramrod->rx_qid_valid = 1;
-	p_ramrod->rx_qid = OSAL_CPU_TO_LE16(abs_rx_q_id);
+			p_ramrod->rx_qid_valid = 1;
+			p_ramrod->rx_qid = OSAL_CPU_TO_LE16(abs_rx_q_id);
+		}
+
+		p_ramrod->vport_id = OSAL_CPU_TO_LE16((u16)abs_vport_id);
+	}
 
 	p_ramrod->flow_id_valid = 0;
 	p_ramrod->flow_id = 0;
 
-	p_ramrod->vport_id = OSAL_CPU_TO_LE16((u16)abs_vport_id);
-	p_ramrod->filter_action = b_is_add ? GFT_ADD_FILTER
-					   : GFT_DELETE_FILTER;
+	p_ramrod->filter_action = p_params->b_is_add ? GFT_ADD_FILTER
+						     : GFT_DELETE_FILTER;
 
 	DP_VERBOSE(p_hwfn, ECORE_MSG_SP,
 		   "V[%0x], Q[%04x] - %s filter from 0x%lx [length %04xb]\n",
 		   abs_vport_id, abs_rx_q_id,
-		   b_is_add ? "Adding" : "Removing",
-		   (unsigned long)p_addr, length);
+		   p_params->b_is_add ? "Adding" : "Removing",
+		   (unsigned long)p_params->addr, p_params->length);
 
 	return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL);
 }
diff --git a/drivers/net/qede/base/ecore_l2_api.h b/drivers/net/qede/base/ecore_l2_api.h
index 004fb61ba..acde81fad 100644
--- a/drivers/net/qede/base/ecore_l2_api.h
+++ b/drivers/net/qede/base/ecore_l2_api.h
@@ -448,6 +448,31 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
 			       struct ecore_ptt *p_ptt,
 			       struct ecore_arfs_config_params *p_cfg_params);
 
+struct ecore_ntuple_filter_params {
+	/* Physically mapped address containing header of buffer to be used
+	 * as filter.
+	 */
+	dma_addr_t addr;
+
+	/* Length of header in bytes */
+	u16 length;
+
+	/* Relative queue-id to receive classified packet */
+	#define ECORE_RFS_NTUPLE_QID_RSS ((u16)-1)
+	u16 qid;
+
+	/* Identifier can either be according to vport-id or vfid */
+	bool b_is_vf;
+	u8 vport_id;
+	u8 vf_id;
+
+	/* true if this filter is to be added. Else to be removed */
+	bool b_is_add;
+
+	/* If packet needs to be dropped */
+	bool b_is_drop;
+};
+
 /**
  * @brief - ecore_configure_rfs_ntuple_filter
  *
@@ -457,22 +482,12 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
  * @params p_cb		Used for ECORE_SPQ_MODE_CB,where client would initialize
  *			it with cookie and callback function address, if not
  *			using this mode then client must pass NULL.
- * @params p_addr	p_addr is an actual packet header that needs to be
- *			filter. It has to mapped with IO to read prior to
- *			calling this, [contains 4 tuples- src ip, dest ip,
- *			src port, dest port].
- * @params length	length of p_addr header up to past the transport header.
- * @params qid		receive packet will be directed to this queue.
- * @params vport_id
- * @params b_is_add	flag to add or remove filter.
- *
+ * @params p_params
  */
 enum _ecore_status_t
 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
 				  struct ecore_spq_comp_cb *p_cb,
-				  dma_addr_t p_addr, u16 length,
-				  u16 qid, u8 vport_id,
-				  bool b_is_add);
+				  struct ecore_ntuple_filter_params *p_params);
 
 /**
  * @brief - ecore_update_eth_rss_ind_table_entry
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index a033807e7..0e5d39c9a 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -125,6 +125,8 @@ static const struct rte_qede_xstats_name_off qede_xstats_strings[] = {
 		offsetof(struct ecore_eth_stats_common, mftag_filter_discards)},
 	{"rx_mac_filter_discards",
 		offsetof(struct ecore_eth_stats_common, mac_filter_discards)},
+	{"rx_gft_filter_drop",
+		offsetof(struct ecore_eth_stats_common, gft_filter_drop)},
 	{"rx_hw_buffer_truncates",
 		offsetof(struct ecore_eth_stats_common, brb_truncates)},
 	{"rx_hw_buffer_discards",
diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h
index 5549d0bf3..b5f93e9fa 100644
--- a/drivers/net/qede/qede_ethdev.h
+++ b/drivers/net/qede/qede_ethdev.h
@@ -179,6 +179,7 @@ struct qede_arfs_entry {
 	uint32_t soft_id; /* unused for now */
 	uint16_t pkt_len; /* actual packet length to match */
 	uint16_t rx_queue; /* queue to be steered to */
+	bool is_drop; /* drop action */
 	const struct rte_memzone *mz; /* mz used to hold L2 frame */
 	struct qede_arfs_tuple tuple;
 	SLIST_ENTRY(qede_arfs_entry) list;
diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c
index 81509f04b..b7ad59ad6 100644
--- a/drivers/net/qede/qede_filter.c
+++ b/drivers/net/qede/qede_filter.c
@@ -272,6 +272,7 @@ qede_config_arfs_filter(struct rte_eth_dev *eth_dev,
 {
 	struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
 	struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
+	struct ecore_ntuple_filter_params params;
 	char mz_name[RTE_MEMZONE_NAMESIZE] = {0};
 	struct qede_arfs_entry *tmp = NULL;
 	const struct rte_memzone *mz;
@@ -344,12 +345,18 @@ qede_config_arfs_filter(struct rte_eth_dev *eth_dev,
 		ecore_arfs_mode_configure(p_hwfn, p_hwfn->p_arfs_ptt,
 					  &qdev->arfs_info.arfs);
 	}
+
+	memset(&params, 0, sizeof(params));
+	params.addr = (dma_addr_t)mz->iova;
+	params.length = pkt_len;
+	params.qid = arfs->rx_queue;
+	params.vport_id = 0;
+	params.b_is_add = add;
+	params.b_is_drop = arfs->is_drop;
+
 	/* configure filter with ECORE_SPQ_MODE_EBLOCK */
 	rc = ecore_configure_rfs_ntuple_filter(p_hwfn, NULL,
-					       (dma_addr_t)mz->iova,
-					       pkt_len,
-					       arfs->rx_queue,
-					       0, add);
+					       &params);
 	if (rc == ECORE_SUCCESS) {
 		if (add) {
 			arfs->pkt_len = pkt_len;
@@ -1371,12 +1378,15 @@ qede_flow_parse_actions(struct rte_eth_dev *dev,
 				flow->entry.rx_queue = queue->index;
 
 			break;
-
+		case RTE_FLOW_ACTION_TYPE_DROP:
+			if (flow)
+				flow->entry.is_drop = true;
+			break;
 		default:
 			rte_flow_error_set(error, ENOTSUP,
 					   RTE_FLOW_ERROR_TYPE_ACTION,
 					   actions,
-					   "Action is not supported - only ACTION_TYPE_QUEUE supported");
+					   "Action is not supported - only ACTION_TYPE_QUEUE and ACTION_TYPE_DROP supported");
 			return -rte_errno;
 		}
 	}
-- 
2.17.1


  reply	other threads:[~2019-09-04 11:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04 11:30 [dpdk-dev] [PATCH 1/2] net/qede: fix ovs-dpdk failure when using odd number of queues on 100Gb mode Shahed Shaikh
2019-09-04 11:30 ` Shahed Shaikh [this message]
2019-09-04 13:28   ` [dpdk-dev] [PATCH 2/2] net/qede: implement rte_flow drop action Jerin Jacob Kollanukkaran
2019-09-04 13:30 ` [dpdk-dev] [PATCH 1/2] net/qede: fix ovs-dpdk failure when using odd number of queues on 100Gb mode Jerin Jacob Kollanukkaran
2019-09-04 17:52   ` Shahed Shaikh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190904113046.2213-2-shshaikh@marvell.com \
    --to=shshaikh@marvell.com \
    --cc=GR-Everest-DPDK-Dev@marvell.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=rmody@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).