DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
To: dev@dpdk.org
Cc: shaguna@chelsio.com, indranil@chelsio.com, nirranjan@chelsio.com
Subject: [dpdk-dev] [PATCH 8/9] net/cxgbe: add support to match on ingress physical port
Date: Fri, 29 Jun 2018 23:42:23 +0530	[thread overview]
Message-ID: <165fc0f3fa15ce2728f0a425531964c7063e1c28.1530295732.git.rahul.lakkireddy@chelsio.com> (raw)
In-Reply-To: <cover.1530295732.git.rahul.lakkireddy@chelsio.com>
In-Reply-To: <cover.1530295732.git.rahul.lakkireddy@chelsio.com>

From: Shagun Agrawal <shaguna@chelsio.com>

Add support to match packets based on ingress physical port.

Signed-off-by: Shagun Agrawal <shaguna@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 drivers/net/cxgbe/cxgbe_filter.c | 16 +++++++++++++++-
 drivers/net/cxgbe/cxgbe_flow.c   | 30 ++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c
index ff43488b5..8c5890ea8 100644
--- a/drivers/net/cxgbe/cxgbe_filter.c
+++ b/drivers/net/cxgbe/cxgbe_filter.c
@@ -65,11 +65,19 @@ int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs)
 #define U(_mask, _field) \
 	(!(fconf & (_mask)) && S(_field))
 
-	if (U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto))
+	if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto))
 		return -EOPNOTSUPP;
 
 #undef S
 #undef U
+
+	/*
+	 * Don't allow various trivially obvious bogus out-of-range
+	 * values ...
+	 */
+	if (fs->val.iport >= adapter->params.nports)
+		return -ERANGE;
+
 	return 0;
 }
 
@@ -228,6 +236,9 @@ static u64 hash_filter_ntuple(const struct filter_entry *f)
 	u64 ntuple = 0;
 	u16 tcp_proto = IPPROTO_TCP; /* TCP Protocol Number */
 
+	if (tp->port_shift >= 0)
+		ntuple |= (u64)f->fs.mask.iport << tp->port_shift;
+
 	if (tp->protocol_shift >= 0) {
 		if (!f->fs.val.proto)
 			ntuple |= (u64)tcp_proto << tp->protocol_shift;
@@ -664,6 +675,9 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
 		cpu_to_be16(V_FW_FILTER_WR_RX_CHAN(0) |
 			    V_FW_FILTER_WR_RX_RPL_IQ(adapter->sge.fw_evtq.abs_id
 						     ));
+	fwr->maci_to_matchtypem =
+		cpu_to_be32(V_FW_FILTER_WR_PORT(f->fs.val.iport) |
+			    V_FW_FILTER_WR_PORTM(f->fs.mask.iport));
 	fwr->ptcl = f->fs.val.proto;
 	fwr->ptclm = f->fs.mask.proto;
 	rte_memcpy(fwr->lip, f->fs.val.lip, sizeof(fwr->lip));
diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c
index 4f00ac4c6..823bc720c 100644
--- a/drivers/net/cxgbe/cxgbe_flow.c
+++ b/drivers/net/cxgbe/cxgbe_flow.c
@@ -93,6 +93,8 @@ cxgbe_fill_filter_region(struct adapter *adap,
 		ntuple_mask |= (u64)fs->mask.proto << tp->protocol_shift;
 	if (tp->ethertype_shift >= 0)
 		ntuple_mask |= (u64)fs->mask.ethtype << tp->ethertype_shift;
+	if (tp->port_shift >= 0)
+		ntuple_mask |= (u64)fs->mask.iport << tp->port_shift;
 
 	if (ntuple_mask != hash_filter_mask)
 		return;
@@ -100,6 +102,27 @@ cxgbe_fill_filter_region(struct adapter *adap,
 	fs->cap = 1;	/* use hash region */
 }
 
+static int
+ch_rte_parsetype_port(const void *dmask, const struct rte_flow_item *item,
+		      struct ch_filter_specification *fs,
+		      struct rte_flow_error *e)
+{
+	const struct rte_flow_item_phy_port *val = item->spec;
+	const struct rte_flow_item_phy_port *umask = item->mask;
+	const struct rte_flow_item_phy_port *mask;
+
+	mask = umask ? umask : (const struct rte_flow_item_phy_port *)dmask;
+
+	if (val->index > 0x7)
+		return rte_flow_error_set(e, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
+					  item,
+					  "port index upto 0x7 is supported");
+
+	CXGBE_FILL_FS(val->index, mask->index, iport);
+
+	return 0;
+}
+
 static int
 ch_rte_parsetype_udp(const void *dmask, const struct rte_flow_item *item,
 		     struct ch_filter_specification *fs,
@@ -357,6 +380,13 @@ cxgbe_rtef_parse_actions(struct rte_flow *flow,
 }
 
 struct chrte_fparse parseitem[] = {
+		[RTE_FLOW_ITEM_TYPE_PHY_PORT] = {
+		.fptr = ch_rte_parsetype_port,
+		.dmask = &(const struct rte_flow_item_phy_port){
+			.index = 0x7,
+		}
+	},
+
 	[RTE_FLOW_ITEM_TYPE_IPV4] = {
 		.fptr  = ch_rte_parsetype_ipv4,
 		.dmask = &rte_flow_item_ipv4_mask,
-- 
2.14.1

  parent reply	other threads:[~2018-06-29 18:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 18:12 [dpdk-dev] [PATCH 0/9] net/cxgbe: add support for offloading flows to HASH region Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 1/9] net/cxgbe: query firmware for HASH filter resources Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 2/9] net/cxgbe: validate flows offloaded to HASH region Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 3/9] net/cxgbe: add Compressed Local IP region Rahul Lakkireddy
2018-07-04 19:22   ` Ferruh Yigit
2018-06-29 18:12 ` [dpdk-dev] [PATCH 4/9] net/cxgbe: add support to offload flows to HASH region Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 5/9] net/cxgbe: add support to delete flows in " Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 6/9] net/cxgbe: add support to query hit counters for " Rahul Lakkireddy
2018-06-29 18:12 ` [dpdk-dev] [PATCH 7/9] net/cxgbe: add support to flush " Rahul Lakkireddy
2018-06-29 18:12 ` Rahul Lakkireddy [this message]
2018-06-29 18:12 ` [dpdk-dev] [PATCH 9/9] net/cxgbe: add support to redirect packets to egress physical port Rahul Lakkireddy
2018-07-04 19:16 ` [dpdk-dev] [PATCH 0/9] net/cxgbe: add support for offloading flows to HASH region Ferruh Yigit
2018-07-04 19:51   ` Ferruh Yigit

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=165fc0f3fa15ce2728f0a425531964c7063e1c28.1530295732.git.rahul.lakkireddy@chelsio.com \
    --to=rahul.lakkireddy@chelsio.com \
    --cc=dev@dpdk.org \
    --cc=indranil@chelsio.com \
    --cc=nirranjan@chelsio.com \
    --cc=shaguna@chelsio.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).