From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A019A0547; Mon, 27 Sep 2021 10:34:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B014D41125; Mon, 27 Sep 2021 10:34:10 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2052.outbound.protection.outlook.com [40.107.95.52]) by mails.dpdk.org (Postfix) with ESMTP id 6F3E141125 for ; Mon, 27 Sep 2021 10:34:09 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BZckPiYVnSTQL8ywnjOoaSz9kWwiD3aCuSdq1nk+0+lo657C4NWXZ2H8KVEnc1hRqlBdZcDmTiCyHRcmNgkAQqoZHKxUc0ZApydlh6mVMz6w2E3Xuo6vZBokBsoO3KEEvQYdhj3qA3z+4YtV+JerqbncPKcdfwNVeFNu3WfBdPUX+Hd9PsZhDt95W1Fw/YdgxaCLBb46/1NuuTUlmxQCK2vAQQ82K3z8ygYh5pQ5F/9pXzcSbQb5AbZRSyJR4/VrBZyJNZ7rB6tFnBgKxoEO2oGVOvao0UR7+JNA/RDr6uwMSi5O/Uulm3PLGQAeRmOwxam+aFnHsNtM8SesuvhCIA== 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; bh=VSBQkafzsishw8HguMo1Y5fj7DXUBBYYaZZr1uKhpm8=; b=fh5O0pshcP8m4+EvP4lumLs2lltEeMs4BE4HDcEYPuYzcmKbgmoWvqf7eKH959n6tPLUr3mP2QdM6OKhN9UhgKXHyn2e9BcF47+ypb42Po/JJNTlbfo/MHiHeVdpfiV4q4K5VZQfRYfe8IKqcmMiQfPE028Na00wxYuYn5rXnQxI0VvMgMIquwIji5UTMQLsSMXqorUwJIR8JrudNhwJsRkX2wQKC4nmkaakel9zKZNJG9FKy1asDLUIZN8rvgzlgHZQHZlPY4OL0QpxpsnOQNFx3Mk2iQ0iUQjT8VGr65tECCItxTOCgQ4PkW5DzHNwxljiKbS6ASkKzSw60RVdfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=VSBQkafzsishw8HguMo1Y5fj7DXUBBYYaZZr1uKhpm8=; b=MN/sPBUyYGhslZydVZivowCON9oSBdCnhsIDqtfT2QdscyRZqBoWu9kFsZzhoH+QaBE7si3eVEwfZOHwrYyACoI43PAc0PSDhn+7XSnd3ngNFEdbPu9+XcaKqAv6i0eMyIUt/pJiwdxlFTAm4DHpMo3cvY/6PLbVo9bfqU7817y/K+Jo22qcNAQVfcPunFh+bSCFPZbubRePsEc/sLKutsm65Mnk9LkujXc0XmkG/gkotStueV2hLcl2i/lC3IAwYldInWdbGOz36JBiZrc+HcMU/hr/zU1GW1/1QCoH6AvH0bp6cEC4G0CdRR4RdQKrtbmwrPaqg/M7XmMhtDeVxw== Received: from BN9P220CA0025.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::30) by MWHPR12MB1262.namprd12.prod.outlook.com (2603:10b6:300:12::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Mon, 27 Sep 2021 08:34:07 +0000 Received: from BN8NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13e:cafe::68) by BN9P220CA0025.outlook.office365.com (2603:10b6:408:13e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 08:34:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by BN8NAM11FT009.mail.protection.outlook.com (10.13.176.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4544.13 via Frontend Transport; Mon, 27 Sep 2021 08:34:07 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 27 Sep 2021 01:34:05 -0700 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 27 Sep 2021 08:34:04 +0000 From: Xueming Li To: CC: , Matan Azrad , "Viacheslav Ovsiienko" Date: Mon, 27 Sep 2021 16:32:56 +0800 Message-ID: <20210927083256.337450-9-xuemingl@nvidia.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927083256.337450-1-xuemingl@nvidia.com> References: <20210927083256.337450-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fdfc7738-28fc-4cd9-c7d9-08d98191925f X-MS-TrafficTypeDiagnostic: MWHPR12MB1262: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0PkK2qY0sBjuzsKfAvjGaigkPoRxkBznwf+XxHPENqyd1kZl8UyLpeyfmurtzz1dLnUtBoHevysNNQJUK3Az6BEWnYK4te4Zva937KjMxi/98H6nHQ5WeYZ6PRoPweKw8/FsQuZ6b5CGNEE0uWz46QVexo6cAUvw0/1kO7NXL+pjtg4qNTo5rlkk1nEYuBcIrxnWp0Xjq37vNdZTb+cFC8vDqVF7bXh7QQVwx7YxmK+B01rNtrVAu/6RUq5xQxq64GbH1G91nH15C+ek9SYbBWic3x1obgl6L8lOqON2BKqaJXAjMojz6FNvpKpiOwmvZPT5sHwS79ZyLU6o437ZahLg1PSwEHy4j6ZbxSvrtEmgK2tyWVpzhLd1LaAQHAn4Bbf+6uQyF8EdR0MNvRWfascFYyJJDqmnCBQLWOTNja0CpxyTETXmWz65BiDr0Z8t3+tfE+YgXDyHb3tFnc3/HaSoqyFa/qY7L6lmNVCQSP9ZE+58XaryckzqJ9uFmVVJ6FO7/enWXioQLikW1568fCb6KsR31+Cj1wU1/UO/kfawoFdJTzvaKwssX7ULcBA1ryj4QMq5SYXBn8edN/O60Q6Elr0x1sYOre/0IlJekNe2WShQNo7Zu3s7uUg9wyEcpaCArt8jo+DBwbK4wx0kgfyn+hg1yn+ohf0ozdhT9Ead3L7XWy4WifkEUbHRosdfSkk2//kDKM6XPymKlI0tjg== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(508600001)(2906002)(26005)(186003)(336012)(6286002)(2616005)(83380400001)(107886003)(7636003)(4326008)(47076005)(55016002)(1076003)(316002)(36756003)(356005)(426003)(16526019)(7696005)(6916009)(70586007)(6666004)(70206006)(8936002)(5660300002)(36860700001)(54906003)(8676002)(82310400003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2021 08:34:07.3858 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fdfc7738-28fc-4cd9-c7d9-08d98191925f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1262 Subject: [dpdk-dev] [PATCH 8/8] net/mlx5: enable DevX Tx queue creation 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 Sender: "dev" Verbs API has limitation to support port number larger 255 by design. To support more representors on a single Verbs device, must enable DevX API. DevX SQ was disabled since all representors need a FDB default miss flow to redirect packets sent from CPU to peer port(SF, VF or HPF). Kernel creates representor default miss flow automatically for Verbs QP. For DevX sq, PMD must to create it manually. The default miss root flow matches esw-manager vport and sqn. Since root table flow created on kernel, vport redirect action is not supported, so split the default miss flow into: 1. per eswitch FDB root flow that matches ESW manager vport ID, jump to group 1. 2. per sq FDB flow in group 1 that matches ESW manager vport ID and sqn, redirect packet to peer vport. Signed-off-by: Xueming Li --- drivers/net/mlx5/linux/mlx5_os.c | 62 +------------------------- drivers/net/mlx5/mlx5.h | 2 + drivers/net/mlx5/mlx5_devx.c | 10 ++--- drivers/net/mlx5/mlx5_devx.h | 2 + drivers/net/mlx5/mlx5_flow.c | 74 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_trigger.c | 11 ++++- 6 files changed, 94 insertions(+), 67 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index e9256ad5245..bcf040a8524 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -697,56 +697,6 @@ mlx5_init_once(void) return ret; } -/** - * Create the Tx queue DevX/Verbs object. - * - * @param dev - * Pointer to Ethernet device. - * @param idx - * Queue index in DPDK Tx queue array. - * - * @return - * 0 on success, a negative errno value otherwise and rte_errno is set. - */ -static int -mlx5_os_txq_obj_new(struct rte_eth_dev *dev, uint16_t idx) -{ - struct mlx5_priv *priv = dev->data->dev_private; - struct mlx5_txq_data *txq_data = (*priv->txqs)[idx]; - struct mlx5_txq_ctrl *txq_ctrl = - container_of(txq_data, struct mlx5_txq_ctrl, txq); - - if (txq_ctrl->type == MLX5_TXQ_TYPE_HAIRPIN) - return mlx5_txq_devx_obj_new(dev, idx); -#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET - if (!priv->config.dv_esw_en) - return mlx5_txq_devx_obj_new(dev, idx); -#endif - return mlx5_txq_ibv_obj_new(dev, idx); -} - -/** - * Release an Tx DevX/verbs queue object. - * - * @param txq_obj - * DevX/Verbs Tx queue object. - */ -static void -mlx5_os_txq_obj_release(struct mlx5_txq_obj *txq_obj) -{ - if (txq_obj->txq_ctrl->type == MLX5_TXQ_TYPE_HAIRPIN) { - mlx5_txq_devx_obj_release(txq_obj); - return; - } -#ifdef HAVE_MLX5DV_DEVX_UAR_OFFSET - if (!txq_obj->txq_ctrl->priv->config.dv_esw_en) { - mlx5_txq_devx_obj_release(txq_obj); - return; - } -#endif - mlx5_txq_ibv_obj_release(txq_obj); -} - /** * DV flow counter mode detect and config. * @@ -1812,16 +1762,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, ibv_obj_ops.drop_action_create; priv->obj_ops.drop_action_destroy = ibv_obj_ops.drop_action_destroy; -#ifndef HAVE_MLX5DV_DEVX_UAR_OFFSET - priv->obj_ops.txq_obj_modify = ibv_obj_ops.txq_obj_modify; -#else - if (config->dv_esw_en) - priv->obj_ops.txq_obj_modify = - ibv_obj_ops.txq_obj_modify; -#endif - /* Use specific wrappers for Tx object. */ - priv->obj_ops.txq_obj_new = mlx5_os_txq_obj_new; - priv->obj_ops.txq_obj_release = mlx5_os_txq_obj_release; mlx5_queue_counter_id_prepare(eth_dev); priv->obj_ops.lb_dummy_queue_create = mlx5_rxq_ibv_obj_dummy_lb_create; @@ -1832,7 +1772,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } if (config->tx_pp && (priv->config.dv_esw_en || - priv->obj_ops.txq_obj_new != mlx5_os_txq_obj_new)) { + priv->obj_ops.txq_obj_new != mlx5_txq_devx_obj_new)) { /* * HAVE_MLX5DV_DEVX_UAR_OFFSET is required to support * packet pacing and already checked above. diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index e02714e2319..63737a1dafe 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1698,6 +1698,8 @@ int mlx5_ctrl_flow(struct rte_eth_dev *dev, struct rte_flow_item_eth *eth_mask); int mlx5_flow_lacp_miss(struct rte_eth_dev *dev); struct rte_flow *mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev); +uint32_t mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, + uint32_t txq); void mlx5_flow_async_pool_query_handle(struct mlx5_dev_ctx_shared *sh, uint64_t async_id, int status); void mlx5_set_query_alarm(struct mlx5_dev_ctx_shared *sh); diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index a1db53577a2..a49602cb957 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -102,9 +102,9 @@ mlx5_devx_modify_rq(struct mlx5_rxq_obj *rxq_obj, uint8_t type) * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */ -static int -mlx5_devx_modify_sq(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, - uint8_t dev_port) +int +mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, enum mlx5_txq_modify_type type, + uint8_t dev_port) { struct mlx5_devx_modify_sq_attr msq_attr = { 0 }; int ret; @@ -1118,7 +1118,7 @@ mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) *txq_data->qp_db = 0; txq_data->qp_num_8s = txq_obj->sq_obj.sq->id << 8; /* Change Send Queue state to Ready-to-Send. */ - ret = mlx5_devx_modify_sq(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0); + ret = mlx5_txq_devx_modify(txq_obj, MLX5_TXQ_MOD_RST2RDY, 0); if (ret) { rte_errno = errno; DRV_LOG(ERR, @@ -1187,7 +1187,7 @@ struct mlx5_obj_ops devx_obj_ops = { .drop_action_create = mlx5_devx_drop_action_create, .drop_action_destroy = mlx5_devx_drop_action_destroy, .txq_obj_new = mlx5_txq_devx_obj_new, - .txq_obj_modify = mlx5_devx_modify_sq, + .txq_obj_modify = mlx5_txq_devx_modify, .txq_obj_release = mlx5_txq_devx_obj_release, .lb_dummy_queue_create = NULL, .lb_dummy_queue_release = NULL, diff --git a/drivers/net/mlx5/mlx5_devx.h b/drivers/net/mlx5/mlx5_devx.h index bc8a8d6b73c..a95207a6b9a 100644 --- a/drivers/net/mlx5/mlx5_devx.h +++ b/drivers/net/mlx5/mlx5_devx.h @@ -8,6 +8,8 @@ #include "mlx5.h" int mlx5_txq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx); +int mlx5_txq_devx_modify(struct mlx5_txq_obj *obj, + enum mlx5_txq_modify_type type, uint8_t dev_port); void mlx5_txq_devx_obj_release(struct mlx5_txq_obj *txq_obj); extern struct mlx5_obj_ops devx_obj_ops; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 8dc79340f2d..71933e03772 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -6571,6 +6571,80 @@ mlx5_flow_create_esw_table_zero_flow(struct rte_eth_dev *dev) actions, false, &error); } +/** + * Create a dedicated flow rule on e-switch table 1, matches ESW manager + * and sq number, directs all packets to peer vport. + * + * @param dev + * Pointer to Ethernet device. + * @param txq + * Txq index. + * + * @return + * Flow ID on success, 0 otherwise and rte_errno is set. + */ +uint32_t +mlx5_flow_create_devx_sq_miss_flow(struct rte_eth_dev *dev, uint32_t txq) +{ + struct rte_flow_attr attr = { + .group = 0, + .priority = MLX5_FLOW_LOWEST_PRIO_INDICATOR, + .ingress = 1, + .egress = 0, + .transfer = 1, + }; + struct rte_flow_item_port_id port_spec = { + .id = MLX5_PORT_ESW_MGR, + }; + struct mlx5_rte_flow_item_tx_queue txq_spec = { + .queue = txq, + }; + struct rte_flow_item pattern[] = { + { + .type = RTE_FLOW_ITEM_TYPE_PORT_ID, + .spec = &port_spec, + }, + { + .type = (enum rte_flow_item_type) + MLX5_RTE_FLOW_ITEM_TYPE_TX_QUEUE, + .spec = &txq_spec, + }, + { + .type = RTE_FLOW_ITEM_TYPE_END, + }, + }; + struct rte_flow_action_jump jump = { + .group = 1, + }; + struct rte_flow_action_port_id port = { + .id = dev->data->port_id, + }; + struct rte_flow_action actions[] = { + { + .type = RTE_FLOW_ACTION_TYPE_JUMP, + .conf = &jump, + }, + { + .type = RTE_FLOW_ACTION_TYPE_END, + }, + }; + struct rte_flow_error error; + + /* + * Creates group 0, highest priority jump flow. + * Matches txq to bypass kernel packets. + */ + if (flow_list_create(dev, MLX5_FLOW_TYPE_CTL, &attr, pattern, actions, + false, &error) == 0) + return 0; + /* Create group 1, lowest priority redirect flow for txq. */ + attr.group = 1; + actions[0].conf = &port; + actions[0].type = RTE_FLOW_ACTION_TYPE_PORT_ID; + return flow_list_create(dev, MLX5_FLOW_TYPE_CTL, &attr, pattern, + actions, false, &error); +} + /** * Validate a flow supported by the NIC. * diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 54173bfacb2..42d8bb31128 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -1255,9 +1255,18 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) goto error; } } + if ((priv->representor || priv->master) && + priv->config.dv_esw_en) { + if (mlx5_flow_create_devx_sq_miss_flow(dev, i) == 0) { + DRV_LOG(ERR, + "Port %u Tx queue %u SQ create representor devx default miss rule failed.", + dev->data->port_id, i); + goto error; + } + } mlx5_txq_release(dev, i); } - if (priv->config.dv_esw_en && !priv->config.vf && !priv->config.sf) { + if ((priv->master || priv->representor) && priv->config.dv_esw_en) { if (mlx5_flow_create_esw_table_zero_flow(dev)) priv->fdb_def_rule = 1; else -- 2.33.0