From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 55B4EA0532; Tue, 4 Feb 2020 12:34:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB7811C193; Tue, 4 Feb 2020 12:33:48 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id D4EE01C1C2 for ; Tue, 4 Feb 2020 12:33:47 +0100 (CET) From: Bing Zhao To: orika@mellanox.com, viacheslavo@mellanox.com, rasland@mellanox.com, matan@mellanox.com Cc: dev@dpdk.org Date: Tue, 4 Feb 2020 13:33:22 +0200 Message-Id: <1580816002-159035-7-git-send-email-bingz@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1580816002-159035-1-git-send-email-bingz@mellanox.com> References: <1580736735-19472-1-git-send-email-bingz@mellanox.com> <1580816002-159035-1-git-send-email-bingz@mellanox.com> Subject: [dpdk-dev] [PATCH v2 6/6] net/mlx5: do not save device flow matcher value X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The matcher value is a series of bits with specified format that defined by the hardware interface. PMD driver needs to translate the packet header into the matcher format and then used to create the flow with the lower layer driver. And this matcher value is only used when creating a flow, and when destroying it, only the lower layer driver object related to the matcher needs to be released. So there is no need to save such huge block information of a device flow. Signed-off-by: Bing Zhao --- drivers/net/mlx5/mlx5_flow.h | 2 -- drivers/net/mlx5/mlx5_flow_dv.c | 28 ++++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 5e517c3..af30438 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -513,8 +513,6 @@ struct mlx5_flow_dv { struct mlx5_hrxq *hrxq; /**< Hash Rx queues. */ /* Flow DV api: */ struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */ - struct mlx5_flow_dv_match_params value; - /**< Holds the value that the packet is compared to. */ struct mlx5_flow_dv_encap_decap_resource *encap_decap; /**< Pointer to encap/decap resource in cache. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 33a3d70..111b01d 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -56,7 +56,7 @@ #define MLX5_ENCAPSULATION_DECISION_SIZE (sizeof(struct rte_flow_item_eth) + \ sizeof(struct rte_flow_item_ipv4)) -/* VLAN header definitions */ +/* VLAN header definitions. */ #define MLX5DV_FLOW_VLAN_PCP_SHIFT 13 #define MLX5DV_FLOW_VLAN_PCP_MASK (0x7 << MLX5DV_FLOW_VLAN_PCP_SHIFT) #define MLX5DV_FLOW_VLAN_VID_MASK 0x0fff @@ -75,15 +75,23 @@ uint32_t attr; }; +/* Maximal number of global temporary device flow. */ +#define MLX5DV_FLOW_HANDLE_MAX_NUM 8 /* Global temporary device flow. */ struct mlx5_flow sflow; /* Global subsidiary device flows actions' list. */ struct { void *actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS]; + /**< Action list. */ uint64_t hash_fields; + /**< Verbs hash Rx queue hash fields. */ + struct mlx5_flow_dv_match_params value; + /**< Holds the value that the packet is compared to. */ int actions_n; - uint8_t transfer; /**< 1 if the flow is E-Switch flow. */ -} sflow_act[8]; + /**< number of actions. */ + uint8_t transfer; + /**< 1 if the flow is E-Switch flow. */ +} sflow_act[MLX5DV_FLOW_HANDLE_MAX_NUM]; /** * Initialize flow attributes structure according to flow items' types. @@ -5127,7 +5135,6 @@ struct field_modify_info modify_tcp[] = { } dev_flow->ingress = attr->ingress; dev_flow->transfer = attr->transfer; - dv_handle->value.size = MLX5_ST_SZ_BYTES(fte_match_param); /* DV support already defined, compiler will happy for inbox driver. */ dev_flow->dv_handle = dv_handle; return dev_flow; @@ -7097,7 +7104,7 @@ struct field_modify_info modify_tcp[] = { union mlx5_flow_tbl_key tbl_key; uint32_t modify_action_pos = UINT32_MAX; void *match_mask = matcher.mask.buf; - void *match_value = dev_flow->dv_handle->value.buf; + void *match_value = &sflow_act[sidx].value.buf; uint8_t next_protocol = 0xff; struct rte_vlan_hdr vlan = { 0 }; uint32_t table; @@ -7539,6 +7546,11 @@ struct field_modify_info modify_tcp[] = { sflow_act[sidx].actions_n = actions_n; sflow_act[sidx].transfer = dev_flow->transfer; dev_flow->dv_handle->action_flags = action_flags; + /* Matcher size is fixed right now. */ + sflow_act[sidx].value.size = MLX5_ST_SZ_BYTES(fte_match_param); + /* Clear buffer in case of dirty content. */ + memset(&sflow_act[sidx].value.buf, 0, + MLX5_ST_SZ_BYTES(fte_match_param)); for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) { int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL); int item_type = items->type; @@ -7723,7 +7735,7 @@ struct field_modify_info modify_tcp[] = { } #ifdef RTE_LIBRTE_MLX5_DEBUG MLX5_ASSERT(!flow_dv_check_valid_spec(matcher.mask.buf, - dev_flow->dv_handle->value.buf)); + sflow_act[sidx].value.buf)); #endif dev_flow->dv_handle->layers = item_flags; if (action_flags & MLX5_FLOW_ACTION_RSS) @@ -7820,8 +7832,8 @@ struct field_modify_info modify_tcp[] = { matcher_obj = dv_handle->matcher->matcher_object; dv_handle->flow = mlx5_glue->dv_create_flow(matcher_obj, - (void *)&dv_handle->value, - n, sflow_act[sidx].actions); + &sflow_act[sidx].value, n, + sflow_act[sidx].actions); if (!dv_handle->flow) { rte_flow_error_set(error, errno, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, -- 1.8.3.1