From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <orika@mellanox.com>
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 78E941BA4D
 for <dev@dpdk.org>; Thu, 18 Apr 2019 15:16:20 +0200 (CEST)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 orika@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 18 Apr 2019 16:16:14 +0300
Received: from pegasus03.mtr.labs.mlnx (pegasus03.mtr.labs.mlnx
 [10.210.16.124])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x3IDGDSC003631;
 Thu, 18 Apr 2019 16:16:14 +0300
From: Ori Kam <orika@mellanox.com>
To: yskoh@mellanox.com, shahafs@mellanox.com, matan@mellanox.com,
 viacheslavo@mellanox.com, motih@mellanox.com
Cc: dev@dpdk.org, orika@mellanox.com
Date: Thu, 18 Apr 2019 13:16:04 +0000
Message-Id: <1555593367-144772-7-git-send-email-orika@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1555593367-144772-1-git-send-email-orika@mellanox.com>
References: <1555276357-4892-1-git-send-email-orika@mellanox.com>
 <1555593367-144772-1-git-send-email-orika@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 6/9] net/mlx5: add transfer attribute to
	matcher
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>
X-List-Received-Date: Thu, 18 Apr 2019 13:16:21 -0000

In current implementation the DV steering supported only NIC steering.
This commit adds the transfer attribute in order to create a matcher
on the FDB tabels.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c    |  1 +
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index b1effda..8afb966 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2095,6 +2095,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	flow = rte_calloc(__func__, 1, flow_size, 0);
 	flow->drv_type = flow_get_drv_type(dev, attr);
 	flow->ingress = attr->ingress;
+	flow->transfer = attr->transfer;
 	assert(flow->drv_type > MLX5_FLOW_TYPE_MIN &&
 	       flow->drv_type < MLX5_FLOW_TYPE_MAX);
 	flow->queue = (void *)(flow + 1);
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 85954c2..9d72024 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -210,6 +210,7 @@ struct mlx5_flow_dv_matcher {
 	uint16_t crc; /**< CRC of key. */
 	uint16_t priority; /**< Priority of matcher. */
 	uint8_t egress; /**< Egress matcher. */
+	uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
 	uint32_t group; /**< The matcher group. */
 	struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
 };
@@ -382,6 +383,7 @@ struct rte_flow {
 	struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */
 	uint8_t ingress; /**< 1 if the flow is ingress. */
 	uint32_t group; /**< The group index. */
+	uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
 };
 
 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index e3d9aa2..182abb3 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -3192,6 +3192,8 @@ struct field_modify_info modify_tcp[] = {
  *   Table id to use.
  * @param[in] egress
  *   Direction of the table.
+ * @param[in] transfer
+ *   E-Switch or NIC flow.
  * @param[out] error
  *   pointer to error structure.
  *
@@ -3201,6 +3203,7 @@ struct field_modify_info modify_tcp[] = {
 static struct mlx5_flow_tbl_resource *
 flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
 			 uint32_t table_id, uint8_t egress,
+			 uint8_t transfer,
 			 struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -3208,7 +3211,12 @@ struct field_modify_info modify_tcp[] = {
 	struct mlx5_flow_tbl_resource *tbl;
 
 #ifdef HAVE_MLX5DV_DR
-	if (egress) {
+	if (transfer) {
+		tbl = &sh->fdb_tbl[table_id];
+		if (!tbl->obj)
+			tbl->obj = mlx5_glue->dr_create_flow_tbl
+				(sh->fdb_ns, table_id);
+	} else if (egress) {
 		tbl = &sh->tx_tbl[table_id];
 		if (!tbl->obj)
 			tbl->obj = mlx5_glue->dr_create_flow_tbl
@@ -3230,7 +3238,9 @@ struct field_modify_info modify_tcp[] = {
 #else
 	(void)error;
 	(void)tbl;
-	if (egress)
+	if (transfer)
+		return &sh->fdb_tbl[table_id];
+	else if (egress)
 		return &sh->tx_tbl[table_id];
 	else
 		return &sh->rx_tbl[table_id];
@@ -3295,6 +3305,7 @@ struct field_modify_info modify_tcp[] = {
 		    matcher->priority == cache_matcher->priority &&
 		    matcher->egress == cache_matcher->egress &&
 		    matcher->group == cache_matcher->group &&
+		    matcher->transfer == cache_matcher->transfer &&
 		    !memcmp((const void *)matcher->mask.buf,
 			    (const void *)cache_matcher->mask.buf,
 			    cache_matcher->mask.size)) {
@@ -3316,7 +3327,8 @@ struct field_modify_info modify_tcp[] = {
 					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 					  "cannot allocate matcher memory");
 	tbl = flow_dv_tbl_resource_get(dev, matcher->group * MLX5_GROUP_FACTOR,
-				       matcher->egress, error);
+				       matcher->egress, matcher->transfer,
+				       error);
 	if (!tbl) {
 		rte_free(cache_matcher);
 		return rte_flow_error_set(error, ENOMEM,
@@ -3643,7 +3655,8 @@ struct field_modify_info modify_tcp[] = {
 			jump_data = action->conf;
 			tbl = flow_dv_tbl_resource_get(dev, jump_data->group *
 						       MLX5_GROUP_FACTOR,
-						       attr->egress, error);
+						       attr->egress,
+						       attr->transfer, error);
 			if (!tbl)
 				return rte_flow_error_set
 						(error, errno,
@@ -3871,6 +3884,7 @@ struct field_modify_info modify_tcp[] = {
 						     matcher.priority);
 	matcher.egress = attr->egress;
 	matcher.group = attr->group;
+	matcher.transfer = attr->transfer;
 	if (flow_dv_matcher_register(dev, &matcher, dev_flow, error))
 		return -rte_errno;
 	return 0;
-- 
1.8.3.1

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 dpdk.space (Postfix) with ESMTP id 7F48EA00E6
	for <public@inbox.dpdk.org>; Thu, 18 Apr 2019 15:16:51 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id A02A11BA90;
	Thu, 18 Apr 2019 15:16:29 +0200 (CEST)
Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129])
 by dpdk.org (Postfix) with ESMTP id 78E941BA4D
 for <dev@dpdk.org>; Thu, 18 Apr 2019 15:16:20 +0200 (CEST)
Received: from Internal Mail-Server by MTLPINE1 (envelope-from
 orika@mellanox.com)
 with ESMTPS (AES256-SHA encrypted); 18 Apr 2019 16:16:14 +0300
Received: from pegasus03.mtr.labs.mlnx (pegasus03.mtr.labs.mlnx
 [10.210.16.124])
 by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x3IDGDSC003631;
 Thu, 18 Apr 2019 16:16:14 +0300
From: Ori Kam <orika@mellanox.com>
To: yskoh@mellanox.com, shahafs@mellanox.com, matan@mellanox.com,
 viacheslavo@mellanox.com, motih@mellanox.com
Cc: dev@dpdk.org, orika@mellanox.com
Date: Thu, 18 Apr 2019 13:16:04 +0000
Message-Id: <1555593367-144772-7-git-send-email-orika@mellanox.com>
X-Mailer: git-send-email 1.8.3.1
In-Reply-To: <1555593367-144772-1-git-send-email-orika@mellanox.com>
References: <1555276357-4892-1-git-send-email-orika@mellanox.com>
 <1555593367-144772-1-git-send-email-orika@mellanox.com>
Subject: [dpdk-dev] [PATCH v3 6/9] net/mlx5: add transfer attribute to
	matcher
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>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190418131604.OVSw4p3xhKnky5hI35Cw0JxAJuGr8JFYFJ2MO60ygdw@z>

In current implementation the DV steering supported only NIC steering.
This commit adds the transfer attribute in order to create a matcher
on the FDB tabels.

Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Yongseok Koh <yskoh@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c    |  1 +
 drivers/net/mlx5/mlx5_flow.h    |  2 ++
 drivers/net/mlx5/mlx5_flow_dv.c | 22 ++++++++++++++++++----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index b1effda..8afb966 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -2095,6 +2095,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority,
 	flow = rte_calloc(__func__, 1, flow_size, 0);
 	flow->drv_type = flow_get_drv_type(dev, attr);
 	flow->ingress = attr->ingress;
+	flow->transfer = attr->transfer;
 	assert(flow->drv_type > MLX5_FLOW_TYPE_MIN &&
 	       flow->drv_type < MLX5_FLOW_TYPE_MAX);
 	flow->queue = (void *)(flow + 1);
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 85954c2..9d72024 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -210,6 +210,7 @@ struct mlx5_flow_dv_matcher {
 	uint16_t crc; /**< CRC of key. */
 	uint16_t priority; /**< Priority of matcher. */
 	uint8_t egress; /**< Egress matcher. */
+	uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
 	uint32_t group; /**< The matcher group. */
 	struct mlx5_flow_dv_match_params mask; /**< Matcher mask. */
 };
@@ -382,6 +383,7 @@ struct rte_flow {
 	struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */
 	uint8_t ingress; /**< 1 if the flow is ingress. */
 	uint32_t group; /**< The group index. */
+	uint8_t transfer; /**< 1 if the flow is E-Switch flow. */
 };
 
 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index e3d9aa2..182abb3 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -3192,6 +3192,8 @@ struct field_modify_info modify_tcp[] = {
  *   Table id to use.
  * @param[in] egress
  *   Direction of the table.
+ * @param[in] transfer
+ *   E-Switch or NIC flow.
  * @param[out] error
  *   pointer to error structure.
  *
@@ -3201,6 +3203,7 @@ struct field_modify_info modify_tcp[] = {
 static struct mlx5_flow_tbl_resource *
 flow_dv_tbl_resource_get(struct rte_eth_dev *dev,
 			 uint32_t table_id, uint8_t egress,
+			 uint8_t transfer,
 			 struct rte_flow_error *error)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
@@ -3208,7 +3211,12 @@ struct field_modify_info modify_tcp[] = {
 	struct mlx5_flow_tbl_resource *tbl;
 
 #ifdef HAVE_MLX5DV_DR
-	if (egress) {
+	if (transfer) {
+		tbl = &sh->fdb_tbl[table_id];
+		if (!tbl->obj)
+			tbl->obj = mlx5_glue->dr_create_flow_tbl
+				(sh->fdb_ns, table_id);
+	} else if (egress) {
 		tbl = &sh->tx_tbl[table_id];
 		if (!tbl->obj)
 			tbl->obj = mlx5_glue->dr_create_flow_tbl
@@ -3230,7 +3238,9 @@ struct field_modify_info modify_tcp[] = {
 #else
 	(void)error;
 	(void)tbl;
-	if (egress)
+	if (transfer)
+		return &sh->fdb_tbl[table_id];
+	else if (egress)
 		return &sh->tx_tbl[table_id];
 	else
 		return &sh->rx_tbl[table_id];
@@ -3295,6 +3305,7 @@ struct field_modify_info modify_tcp[] = {
 		    matcher->priority == cache_matcher->priority &&
 		    matcher->egress == cache_matcher->egress &&
 		    matcher->group == cache_matcher->group &&
+		    matcher->transfer == cache_matcher->transfer &&
 		    !memcmp((const void *)matcher->mask.buf,
 			    (const void *)cache_matcher->mask.buf,
 			    cache_matcher->mask.size)) {
@@ -3316,7 +3327,8 @@ struct field_modify_info modify_tcp[] = {
 					  RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL,
 					  "cannot allocate matcher memory");
 	tbl = flow_dv_tbl_resource_get(dev, matcher->group * MLX5_GROUP_FACTOR,
-				       matcher->egress, error);
+				       matcher->egress, matcher->transfer,
+				       error);
 	if (!tbl) {
 		rte_free(cache_matcher);
 		return rte_flow_error_set(error, ENOMEM,
@@ -3643,7 +3655,8 @@ struct field_modify_info modify_tcp[] = {
 			jump_data = action->conf;
 			tbl = flow_dv_tbl_resource_get(dev, jump_data->group *
 						       MLX5_GROUP_FACTOR,
-						       attr->egress, error);
+						       attr->egress,
+						       attr->transfer, error);
 			if (!tbl)
 				return rte_flow_error_set
 						(error, errno,
@@ -3871,6 +3884,7 @@ struct field_modify_info modify_tcp[] = {
 						     matcher.priority);
 	matcher.egress = attr->egress;
 	matcher.group = attr->group;
+	matcher.transfer = attr->transfer;
 	if (flow_dv_matcher_register(dev, &matcher, dev_flow, error))
 		return -rte_errno;
 	return 0;
-- 
1.8.3.1