From patchwork Thu Sep 22 19:03:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Vesker X-Patchwork-Id: 116665 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A0AF9A0543; Thu, 22 Sep 2022 21:05:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 972664282D; Thu, 22 Sep 2022 21:05:01 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by mails.dpdk.org (Postfix) with ESMTP id 895AD40E28 for ; Thu, 22 Sep 2022 21:04:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WCgiNJu10RAo+x1DOv8ny+9PTrwHkv1FLe6jqEBSk5v6pDj1g4YZX2g9+dtykwWifDmFutSHAxpg+cgMCfCNsZLOPwxnmgt1wSeFv8sy12f8PWbWdJA513xOoXySb/xVzIp4JH0YNJZ2KHEt0WXKN0D1Ezcgttm3RjOGVFlyRqw/B5lGpVO1KMZ89Zl2TNds1Rq4NCQ48aFRRFDDL4qIL9hKPpGT8KdHaBk4MT5hEWh0mBtmgta8IfeaBZCq7KgQXhEyCSjRxwujH03lVVuJvrrVSV48AGs62nBMPeuakuNn1DxwG4XwWgcCO7EAy8DfyuWuBHRwp6ad+GJuKeCySg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4TSrCcRx8IXprIeGYIs1C8NNXEetLK4dwqQzX1jMQiU=; b=RauDxwWKb8dm3bRxLFNBeau68xlo3IC4+SEtxCdk2u2wr9qkqEWmxJUHzJ9j9NmtsF4PGnBWdc3m+HJRLI+oCcKvDSApGd+2/cpCgoupvz0ZzY3i6AopZnv4ZRnWmMsgQkS0syxQBWEdyaGRfaI/2YBEBb/7kGRuZsWUlcQCE/81ImstNwUdrOIepky+obFscV+/+1gjiLOEkbcNC7M7a68aVfqbcqPUlMDEEKtfFXwlaTZS2IpWnvjp61ENMKAsVem0CyCdtD45mOSgo8kcyuOEJoHdEosi+2rfEG1b7XaFYSdzsE/V+/JuBH4q5L7mxSFhQoG0h7IWHLfGIF9hFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4TSrCcRx8IXprIeGYIs1C8NNXEetLK4dwqQzX1jMQiU=; b=e8huprp9VQw8dlK/eYOQivfLa2RlDaIZNy0JpKtaUKglG9lIVx4CbUjvsShybQjfB4owRE57NOpW/3/DDEQGiIOMLjSVi1frj1TU4QVirQZu5BWPs6SjqNSwlti2khCqKJ/xfjqg1fI9mPCMb99X1NhOQvRAwBw7ZhYHf7kygTSFPS4dXfbDaWkOVawxon2X566Ze/F9E/T3wJg4pCVspK60uxocVgc51UUcWymg6Fci6+SY/ppCKcRlT49egTxHxkal0T2F4JiTiXVCaHBjCin6PCWERJLNvSMJZR/rRHDvvet18aW4f9ZtnIN350HAOwK1PYkEDX/JP9O2uAWySg== Received: from MW4P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::11) by SJ1PR12MB6292.namprd12.prod.outlook.com (2603:10b6:a03:455::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5632.19; Thu, 22 Sep 2022 19:04:57 +0000 Received: from CO1NAM11FT098.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::e) by MW4P222CA0006.outlook.office365.com (2603:10b6:303:114::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 19:04:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT098.mail.protection.outlook.com (10.13.174.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Thu, 22 Sep 2022 19:04:57 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Thu, 22 Sep 2022 12:04:43 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Thu, 22 Sep 2022 12:04:40 -0700 From: Alex Vesker To: , , , , , Matan Azrad CC: , Subject: [v1 03/19] net/mlx5: add hardware steering item translation function Date: Thu, 22 Sep 2022 22:03:28 +0300 Message-ID: <20220922190345.394-4-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20220922190345.394-1-valex@nvidia.com> References: <20220922190345.394-1-valex@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT098:EE_|SJ1PR12MB6292:EE_ X-MS-Office365-Filtering-Correlation-Id: f80b3fdf-74ed-4f9c-e14f-08da9ccd5768 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3p2hjCxr5qUuvrLkyAWwg0K0/v+qhesabfASHOK4uHbVevZiYJnQielmHBYwL+jDyUoFjw1KRZ94q95R1cU/AgCTogU11GaVIEW6NW5sNlL8md8ppEujAcJBL11+N0NbaN5rym2GwHobnp9wnegIoEa6dnDV+ENcvfZCCpHdpy1GbAxqh2TRuAfuUjJfgP23L4osXTi4Cki6GdiciLEZuVjL6iEfnq2j41/c4VZ2hi4/kDDcCXqqg5RW0EZrSGFfn0iTKc36UzZD6hwT5KTLeg+1VQVsqVsebotzZ5yBOLN6bM7n/gjjkvNKy95OuMqI7hUkOLqOqmKqiMg0WB9uEbumhjLGa/d62e2u75RYEK3TLO8tLU1b3XA4+iQj3hIoUAMgNDim2gSnCFyUornY0eztEhvVZsAPW5oHDm96BPE7NgSCxCbXCslm1GZeaBpXWTP5S4fBaWK/FUoCBwrpYJAjHBp/NjFBxktxrm9YsMiI3qt2EOQc+aMiCwwVWsmMIBcxv7POGLGJWkt9EqZ4YUsnsfaO4JYJSZKXQlfRSPqnScsPL+IPmcEs27Qto8vU/mk+YsTYHyWmp74NPY4GJ3aGlLAzerF09FI+AkerGzgGJqU7P8gLHAEK1RCJwEbMTHK4f8OjJsC9RAycGkNd7dvWzOcyRL6YJra95+cBd6g2U6O0MgcspGzcJ7PW0uDrMUx3Gv2OUSa2KoEpNhnlSgD2WGWTZ4Sthz+4TwVSHXrXXRsApOztNzmZVs6bTf304yHbIYqQvVVidBUIcqqE8w== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(6286002)(7696005)(26005)(2616005)(6666004)(5660300002)(55016003)(356005)(2906002)(478600001)(86362001)(1076003)(8676002)(4326008)(82740400003)(82310400005)(40460700003)(36860700001)(36756003)(40480700001)(336012)(107886003)(426003)(70206006)(47076005)(41300700001)(70586007)(316002)(16526019)(7636003)(8936002)(6636002)(54906003)(186003)(110136005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2022 19:04:57.3504 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f80b3fdf-74ed-4f9c-e14f-08da9ccd5768 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT098.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6292 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Suanming Mou As hardware steering root table flows still work under FW steering mode. This commit provides shared item tranlsation code for hardware steering root table flows. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow.h | 17 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 93 +++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 2ebb8496f2..86a08074dc 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1006,6 +1006,18 @@ flow_items_to_tunnel(const struct rte_flow_item items[]) return items[0].spec; } +/* HW steering flow attributes. */ +struct mlx5_flow_attr { + uint32_t port_id; /* Port index. */ + uint32_t group; /* Flow group. */ + uint32_t priority; /* Original Priority. */ + /* rss level, used by priority adjustment. */ + uint32_t rss_level; + /* Action flags, used by priority adjustment. */ + uint32_t act_flags; + uint32_t tbl_type; /* Flow table type. */ +}; + /* Flow structure. */ struct rte_flow { uint32_t dev_handles; @@ -2122,4 +2134,9 @@ int mlx5_flow_get_item_vport_id(struct rte_eth_dev *dev, bool *all_ports, struct rte_flow_error *error); +int flow_dv_translate_items_hws(const struct rte_flow_item *items, + struct mlx5_flow_attr *attr, void *key, + uint32_t key_type, uint64_t *item_flags, + uint8_t *match_criteria, + struct rte_flow_error *error); #endif /* RTE_PMD_MLX5_FLOW_H_ */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index cea1aa3137..885b4c5588 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -13229,6 +13229,99 @@ flow_dv_translate_items(struct rte_eth_dev *dev, return 0; } +/** + * Fill the HW steering flow with DV spec. + * + * @param[in] items + * Pointer to the list of items. + * @param[in] attr + * Pointer to the flow attributes. + * @param[in] key + * Pointer to the flow matcher key. + * @param[in] key_type + * Key type. + * @param[in, out] item_flags + * Pointer to the flow item flags. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +int +flow_dv_translate_items_hws(const struct rte_flow_item *items, + struct mlx5_flow_attr *attr, void *key, + uint32_t key_type, uint64_t *item_flags, + uint8_t *match_criteria, + struct rte_flow_error *error) +{ + struct mlx5_flow_rss_desc rss_desc = { .level = attr->rss_level }; + struct rte_flow_attr rattr = { + .group = attr->group, + .priority = attr->priority, + .ingress = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_NIC_RX), + .egress = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_NIC_TX), + .transfer = !!(attr->tbl_type == MLX5DR_TABLE_TYPE_FDB), + }; + struct mlx5_dv_matcher_workspace wks = { + .action_flags = attr->act_flags, + .item_flags = item_flags ? *item_flags : 0, + .external = 0, + .next_protocol = 0xff, + .attr = &rattr, + .rss_desc = &rss_desc, + }; + int ret; + + for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) { + if (!mlx5_flow_os_item_supported(items->type)) + return rte_flow_error_set(error, ENOTSUP, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "item not supported"); + ret = flow_dv_translate_items(&rte_eth_devices[attr->port_id], + items, &wks, key, key_type, NULL); + if (ret) + return ret; + } + if (wks.item_flags & MLX5_FLOW_LAYER_VXLAN_GPE) { + flow_dv_translate_item_vxlan_gpe(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.item_flags & MLX5_FLOW_LAYER_GENEVE) { + flow_dv_translate_item_geneve(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.item_flags & MLX5_FLOW_LAYER_GRE) { + if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE) { + flow_dv_translate_item_gre(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_GRE_OPTION) { + flow_dv_translate_item_gre_option(key, + wks.tunnel_item, + wks.gre_item, + wks.item_flags, + key_type); + } else if (wks.tunnel_item->type == RTE_FLOW_ITEM_TYPE_NVGRE) { + flow_dv_translate_item_nvgre(key, + wks.tunnel_item, + wks.item_flags, + key_type); + } else { + MLX5_ASSERT(false); + } + } + + if (match_criteria) + *match_criteria = flow_dv_matcher_enable(key); + if (item_flags) + *item_flags = wks.item_flags; + return 0; +} + /** * Fill the SW steering flow with DV spec. *