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 B8279A04EF; Tue, 2 Jun 2020 11:38:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFFE11BF98; Tue, 2 Jun 2020 11:38:54 +0200 (CEST) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70041.outbound.protection.outlook.com [40.107.7.41]) by dpdk.org (Postfix) with ESMTP id 712CC1BF87 for ; Tue, 2 Jun 2020 11:38:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d1TSdU2rqv51/FdLeqd6ihqJKSjb02zZvQN/Y5LsQQOLj43NTgxM+9QNf0KylOR77IJG2vV456sIsUasqkYWW/mKKdpw4OzEBgja7FiXhpwCLCBl+SWi+DS1CJ0hBqlozX45dplNSoqzldt/KE1YAwNncILA5q1pMLJ5F8PMQZFIaMOLPovVNbooCMmlwWTH/vm8tz480q+bQDey4TptTTEpcXPQLWVXyqDaxiLjHGDbahoRPTsk7oq5yW8zG2CvlRak/ST0QHbvAjzTB/SO7/On2ToQHNgEXt/8E+NWXZVYEBQAgrZwWZNeRx+xccsxQ6G9Zn3W+1O3DjBcei2LuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SvFEw1dAd1YIoy+pMPlAVVlN7WPDysUz81aRAiT+VMg=; b=JVKTf7lYJRhdMwApIoT0jL/MTgzpQkxRJlfQy23xz7LZhPiidPeenjupU5wH/ZWUMysY34DnfnxBww23d0c6f7snh8efLIAaR5PbetyZOrvBIhMIszzpVD8b1MKjFeBe+if4jpsWqmjg3UFb6dj+F+WR9G4V7FWrvShdY1+D+MttGFf4yf97Xvuf3KHlt60jm6Q/5k1BxPFDnw8DAmLTWhiQ87i23KL46wQshdZIP3y3t2b5Nad5zCL8HI0LHBSGpHLsv5U5d+W0xGhfCtQgQaamd1nRqXhefVVAgtPHqjwpaR/hgvohJ4kAFJO0wpGL5QVIoxWHwvuxjz9A9vCk/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SvFEw1dAd1YIoy+pMPlAVVlN7WPDysUz81aRAiT+VMg=; b=OGGS2QeJ25Qk8+dnykRrIpKHG9Pt4p5Ad6IwBnajyx6NT4poQYMF6D8FkRjzPvmRqvFDpoDD6ZAidA1WYItlz1t4VSYRkLaVu9c480ps7f9kHl3Q8G3XyhIuq2o6fPwq59+KVg2DrRT7WTE80E4tVMbd7dbt+lGvpDzrMe00O+g= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR0502MB3874.eurprd05.prod.outlook.com (2603:10a6:208:1a::29) by AM0PR0502MB3650.eurprd05.prod.outlook.com (2603:10a6:208:1c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.22; Tue, 2 Jun 2020 09:38:52 +0000 Received: from AM0PR0502MB3874.eurprd05.prod.outlook.com ([fe80::2cea:8f0a:cb2f:2a85]) by AM0PR0502MB3874.eurprd05.prod.outlook.com ([fe80::2cea:8f0a:cb2f:2a85%6]) with mapi id 15.20.3045.022; Tue, 2 Jun 2020 09:38:51 +0000 From: Shiri Kuzin To: dev@dpdk.org Cc: matan@mellanox.com, rasland@mellanox.com, viacheslavo@mellanox.com Date: Tue, 2 Jun 2020 12:38:10 +0300 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: Content-Type: text/plain X-ClientProxiedBy: AM0PR02CA0098.eurprd02.prod.outlook.com (2603:10a6:208:154::39) To AM0PR0502MB3874.eurprd05.prod.outlook.com (2603:10a6:208:1a::29) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (94.188.199.18) by AM0PR02CA0098.eurprd02.prod.outlook.com (2603:10a6:208:154::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.18 via Frontend Transport; Tue, 2 Jun 2020 09:38:51 +0000 X-Mailer: git-send-email 1.8.3.1 X-Originating-IP: [94.188.199.18] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 61f841c1-3316-4b3e-dac5-08d806d8c25b X-MS-TrafficTypeDiagnostic: AM0PR0502MB3650: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-Forefront-PRVS: 0422860ED4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UPOJf0AUZcX71zLzaAkg0LLeylssMSsVhpaRmcmDGnOOvh2g2TKACEdW10J5egWb+4qWYQBFVDTpWq06pCS/cwAp7EihbYXa+mtfnGcSwPccyigmjIGAQfRG2V6iCUHPoc6inP2l0KAOkdAaLQcZNRooUYWGRCWclnKf41gdj+UVDlHN62ZP+dsE8BqAj7ZPzNeWK6QQSZ+Z607lB/1CaJ/PZttsW4d5XhlAm25rG4U/Iyivil0yQG6uZLRFgelMkYbN5pl9RcmflitQ/Y4c0CFMjvSTzRS3CIsYu2lnyx+HLo1Kyc05+YEUqHvG9Z8M X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR0502MB3874.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(396003)(39860400002)(136003)(346002)(376002)(366004)(83380400001)(55016002)(66476007)(66946007)(66556008)(8676002)(956004)(2616005)(6916009)(2906002)(26005)(186003)(16526019)(8886007)(316002)(86362001)(52116002)(36756003)(6666004)(4326008)(8936002)(107886003)(5660300002)(478600001)(7696005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: M6dOg/+Rdcv1WH7VenCrAn56syDf/F9VmilYvU6RQFsXr23KIEb1DIrbKBDXsn+CA2P1wu8R4GWaHItChzfc1ZpfAt4NjGoZRF/daydGkrSCFFfS31Ngsp9XxzZDwWCZpDmNL9cW79SXuGPqhppsLEAJpJxP3B3v9+DJXX0XLS92HqoO7uGDP0WsfrxBEES4A0J0mhvpatsjusEv5avDmJaU8rG4Oy9yj8zWqh8wCM2byU20lcYJbtsVM6eXpsDr+clGyuGZHaN8mzNIcqakAgCQF/Uqe56EYhOI+aO1NY3vK3p7/MnRWKKFJBvu55ikuXCw//af9PBTG/CHyIQR65C4kmVQtbEZ0Ledc4ct0cTTDYDc3slPGvL0kx+am0O7idp30M3GI1aJlinxkdzj1VefDDDcggjTpHLLgd3dDT1CzpNtW8RbR6d6CWYLLFW8JJR7DDUobg3aXSPYsQoCE5OAg51PK0ar9p72VJQ324Y= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61f841c1-3316-4b3e-dac5-08d806d8c25b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2020 09:38:51.7846 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QHcWKp4FiiBVYdc+I+nAU7bVsKZufsMHiTlDQ7tFIZmcDc9gNNJublqtXf0BVSpkL4O42hvIL2jVQgLJoY+Npg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0502MB3650 Subject: [dpdk-dev] [RFC 2/3] net/mlx5: add default miss action to flow engine 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 new action is an internal mlx5 action that will call the rdma-core function MLX5DV_FLOW_ACTION_DEFAULT_MISS. The default miss action will be used when a bond is configured to allow traffic realted to the bond to be managed in the kernel. Signed-off-by: Shiri Kuzin --- drivers/net/mlx5/mlx5.h | 5 +++ drivers/net/mlx5/mlx5_flow.c | 72 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow.h | 10 ++++- drivers/net/mlx5/mlx5_flow_dv.c | 91 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 175 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 2908c8b..bc57fb5 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -509,6 +509,9 @@ struct mlx5_ibv_shared { uint32_t port_id_action_list; /* List of port ID actions. */ uint32_t push_vlan_action_list; /* List of push VLAN actions. */ struct mlx5_flow_counter_mng cmng; /* Counters management structure. */ + void *default_miss_action; /* Pointer to the rdma-core action. */ + rte_atomic32_t default_miss_refcnt; + /* Default miss action reference counter. */ struct mlx5_indexed_pool *ipool[MLX5_IPOOL_MAX]; /* Memory Pool for mlx5 flow resources. */ /* Shared interrupt handler section. */ @@ -801,6 +804,8 @@ int mlx5_ctrl_flow_vlan(struct rte_eth_dev *dev, int mlx5_ctrl_flow(struct rte_eth_dev *dev, struct rte_flow_item_eth *eth_spec, struct rte_flow_item_eth *eth_mask); +int mlx5_flow_default_miss(struct rte_eth_dev *dev, + struct rte_flow_item_eth *eth_spec); struct rte_flow *mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev); int mlx5_flow_create_drop_queue(struct rte_eth_dev *dev); void mlx5_flow_delete_drop_queue(struct rte_eth_dev *dev); diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index f2c3cf9..d3eb42e 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1242,6 +1242,30 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, } /* + * Validate the default miss action. + * + * @param[in] action_flags + * Bit-fields that holds the actions detected until now. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_validate_action_default_miss(uint64_t action_flags, + struct rte_flow_error *error) +{ + + if (action_flags & MLX5_FLOW_FATE_ACTIONS) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, NULL, + "can't have 2 fate actions in" + " same flow"); + return 0; +} + +/* * Validate the count action. * * @param[in] dev @@ -4988,6 +5012,54 @@ struct rte_flow * } /** + * Deafult miss flow + * + * @param dev + * Pointer to Ethernet device. + * @param eth_spec + * An Ethernet flow spec to apply. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +mlx5_flow_default_miss(struct rte_eth_dev *dev, + struct rte_flow_item_eth *eth_spec) +{ + struct mlx5_priv *priv = dev->data->dev_private; + const struct rte_flow_attr attr = { + .ingress = 1, + .priority = 0, + }; + struct rte_flow_item items[] = { + { + .type = RTE_FLOW_ITEM_TYPE_ETH, + .spec = eth_spec, + }, + { + .type = RTE_FLOW_ITEM_TYPE_END, + }, + }; + struct rte_flow_action actions[] = { + { + .type = MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS, + }, + { + .type = RTE_FLOW_ACTION_TYPE_END, + }, + }; + + struct rte_flow_error error; + uint32_t flow_idx; + + flow_idx = flow_list_create(dev, &priv->ctrl_flows, + &attr, items, actions, false, &error); + if (!flow_idx) + return -rte_errno; + return 0; +} + +/** * Destroy a flow. * * @see rte_flow_destroy() diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 2c96677..d489f64 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -43,6 +43,7 @@ enum mlx5_rte_flow_action_type { MLX5_RTE_FLOW_ACTION_TYPE_TAG, MLX5_RTE_FLOW_ACTION_TYPE_MARK, MLX5_RTE_FLOW_ACTION_TYPE_COPY_MREG, + MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS, }; /* Matches on selected register. */ @@ -200,10 +201,12 @@ enum mlx5_feature_name { #define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 32) #define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 33) #define MLX5_FLOW_ACTION_AGE (1ull << 34) +#define MLX5_FLOW_ACTION_DEFAULT_MISS (1ull << 35) #define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ - MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP) + MLX5_FLOW_ACTION_RSS | MLX5_FLOW_ACTION_JUMP | \ + MLX5_FLOW_ACTION_DEFAULT_MISS) #define MLX5_FLOW_FATE_ESWITCH_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_PORT_ID | \ @@ -365,6 +368,7 @@ enum mlx5_flow_fate_type { MLX5_FLOW_FATE_PORT_ID, MLX5_FLOW_FATE_DROP, MLX5_FLOW_FATE_MAX, + MLX5_FLOW_FATE_DEFAULT_MISS }; /* Matcher PRM representation */ @@ -537,7 +541,7 @@ struct mlx5_flow_handle { void *ib_flow; /**< Verbs flow pointer. */ uint32_t split_flow_id:28; /**< Sub flow unique match flow id. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ - uint32_t fate_action:3; /**< Fate action type. */ + uint32_t fate_action:4; /**< Fate action type. */ union { uint32_t rix_hrxq; /**< Hash Rx queue object index. */ uint32_t rix_jump; /**< Index to the jump action resource. */ @@ -946,6 +950,8 @@ int mlx5_flow_validate_action_rss(const struct rte_flow_action *action, const struct rte_flow_attr *attr, uint64_t item_flags, struct rte_flow_error *error); +int mlx5_flow_validate_action_default_miss(uint64_t action_flags, + struct rte_flow_error *error); int mlx5_flow_validate_attributes(struct rte_eth_dev *dev, const struct rte_flow_attr *attributes, struct rte_flow_error *error); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index e481831..70d9cc3 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2675,6 +2675,44 @@ struct field_modify_info modify_tcp[] = { } /** + * Find existing default miss resource or create and register a new one. + * + * @param[in, out] dev + * Pointer to rte_eth_dev structure. + * @param[in, out] tbl + * Pointer to flow table resource. + * @parm[in, out] dev_flow + * Pointer to the dev_flow. + * @param[out] error + * pointer to error structure. + * + * @return + * 0 on success otherwise -errno and errno is set. + */ +static int +flow_dv_default_miss_resource_register(struct rte_eth_dev *dev, + struct rte_flow_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_ibv_shared *sh = priv->sh; + int cnt; + + cnt = rte_atomic32_read(&sh->default_miss_refcnt); + if (!cnt){ + sh->default_miss_action = + mlx5_glue->dr_create_flow_action_default_miss; + if (sh->default_miss_action) + return rte_flow_error_set(error, ENOMEM, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, "cannot create default miss action"); + DRV_LOG(DEBUG, "new default miss resource %p: refcnt %d++", + (void *)sh->default_miss_action, cnt); + } + rte_atomic32_inc(&sh->default_miss_refcnt); + return 0; +} + +/** * Find existing table port ID resource or create and register a new one. * * @param[in, out] dev @@ -5215,6 +5253,15 @@ struct field_modify_info modify_tcp[] = { action_flags |= MLX5_FLOW_ACTION_RSS; ++actions_n; break; + case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS: + ret = + mlx5_flow_validate_action_default_miss(action_flags, + error); + if (ret < 0) + return ret; + action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; + ++actions_n; + break; case RTE_FLOW_ACTION_TYPE_COUNT: ret = flow_dv_validate_action_count(dev, error); if (ret < 0) @@ -8178,6 +8225,14 @@ struct field_modify_info modify_tcp[] = { return -rte_errno; action_flags |= MLX5_FLOW_ACTION_SET_TAG; break; + case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS: + if (flow_dv_default_miss_resource_register + (dev, error)) + return -rte_errno; + action_flags |= MLX5_FLOW_ACTION_DEFAULT_MISS; + dev_flow->handle->fate_action = + MLX5_FLOW_FATE_DEFAULT_MISS; + break; case RTE_FLOW_ACTION_TYPE_METER: mtr = actions->conf; if (!flow->meter) { @@ -8270,7 +8325,11 @@ struct field_modify_info modify_tcp[] = { flow_dv_translate_item_eth(match_mask, match_value, items, tunnel, dev_flow->dv.group); - matcher.priority = MLX5_PRIORITY_MAP_L2; + matcher.priority = + ((action_flags & MLX5_FLOW_ACTION_DEFAULT_MISS) & + (!dev_flow->external)) ? + MLX5_PRIORITY_MAP_L3 : + MLX5_PRIORITY_MAP_L2; last_item = tunnel ? MLX5_FLOW_LAYER_INNER_L2 : MLX5_FLOW_LAYER_OUTER_L2; break; @@ -8732,6 +8791,34 @@ struct field_modify_info modify_tcp[] = { } /** + * Release a default miss resource. + * + * @param dev + * Pointer to Ethernet device. + * @return + * 1 while a reference on it exists, 0 when freed. + */ +static int +flow_dv_default_miss_resource_release(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_ibv_shared *sh = priv->sh; + + MLX5_ASSERT(sh->default_miss_action); + DRV_LOG(DEBUG, "default miss resource %p: refcnt %d--", + (void *)sh->default_miss_action, + rte_atomic32_read(&sh->default_miss_refcnt)); + if (rte_atomic32_dec_and_test(&sh->default_miss_refcnt)){ + claim_zero(mlx5_glue->destroy_flow_action + (sh->default_miss_action)); + DRV_LOG(DEBUG, "default miss resource %p: removed", + (void *)sh->default_miss_action); + return 0; + } + return 1; +} + +/** * Release a modify-header resource. * * @param handle @@ -8866,6 +8953,8 @@ struct field_modify_info modify_tcp[] = { flow_dv_jump_tbl_resource_release(dev, handle); else if (handle->fate_action == MLX5_FLOW_FATE_PORT_ID) flow_dv_port_id_action_resource_release(dev, handle); + else if (handle->fate_action == MLX5_FLOW_FATE_DEFAULT_MISS) + flow_dv_default_miss_resource_release(dev); else DRV_LOG(DEBUG, "Incorrect fate action:%d", handle->fate_action); handle->rix_fate = 0; -- 1.8.3.1