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 9B673A0548; Thu, 4 Nov 2021 12:27:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9180F426DE; Thu, 4 Nov 2021 12:27:12 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2068.outbound.protection.outlook.com [40.107.243.68]) by mails.dpdk.org (Postfix) with ESMTP id 9CAEC426FA for ; Thu, 4 Nov 2021 12:27:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sa/Da5iKjM9TZXkymCHwOgOymabS9I31qtlxuO/ZJ+2YqiDs+ziRyPNH1eGQuZ/8bQ7ldD5LHnsDEKVmdJD4aQyS/T471dWX6oOmh97bJOkuO1W7An0y2XE8XdWCyw7OSEB0CN7CZZQ7iBSE7+Bn78ESX/NUCns5/2QK1x35RlOuP212+13u84ryq/9EApUWeVy8BjP9XDMS1kJzAShmuZxVwTRiR4ZZXoViNYoD4P9Urn0M+rylGMR66zRgwzcN6PKJ+4NjPzS2VM74Lq8g85OnztYp06thg8EXne/M3pZe3KKO0jwmrnn/AiXd/Mg2eXy9ddmfDZkxG3eBZkeG0Q== 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=i/z6F3uGX6MAvT5fXIAKLP/VIsEWQqoRcfzdUNc/slk=; b=gAJuQltx1VaqNiirW7eL1GfmwyvspVzR8Yda//wUU0BhMSuhqTowmdPN0MQvErJrvJkaIOvxuval8eweOjZSp3umSscs5xQHNkG7LuK+fYeJm66e9zlmcavYBPVdVxUK+hPJN7axjae14W5Xxj0ieKeNC24lt1x8pP+Uoocg46rH+PG2EPp7GuJTp1hwoVb/9sroW2+KukzEUaWLUTHKEtoPkXG4pd7XT2JW5ZnMybTiJWQ+QslM8TdJBc4r5beJT45txDp+zc2MzVgdXT5YJIgQkAKabLICGV1PS8QygIxgqTQ1a5JIh27RxMf5cnldzeZCtNoMTUr7e2m4v/7DOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine 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=i/z6F3uGX6MAvT5fXIAKLP/VIsEWQqoRcfzdUNc/slk=; b=GXSsIZwJDLRZsvm05rPB0pY7r71XxdXQgCnB8zvKigSfx94ngH3kB6Lom7sdFHzaM/c2yJJRa2D189XlgK5DZib/ulDqZ0iYWBcwLYxbDyBP4EIdncOflr+T7WbFecelvERn4j1FKET69zgl9I+F0HHl8xYRsydsvYO4973SxkI0teMhDit6ZsSh9YXAB0TSlaR0tEDqNVVskTjJaEe4KtjBpfrYoG++RejgAh93MhO/VwKZUBT3i/nDGVJ7oNtbfEspMevTrLJYT1uMsD6Hto3IZEUlALmmGZ6CmHbOnIJuSVfMYZUnLWY9mOMFKfLDIYh98lpd4wik7cj7ylkaeQ== Received: from MWHPR01CA0028.prod.exchangelabs.com (2603:10b6:300:101::14) by MN2PR12MB4424.namprd12.prod.outlook.com (2603:10b6:208:26a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Thu, 4 Nov 2021 11:27:08 +0000 Received: from CO1NAM11FT054.eop-nam11.prod.protection.outlook.com (2603:10b6:300:101:cafe::9) by MWHPR01CA0028.outlook.office365.com (2603:10b6:300:101::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.19 via Frontend Transport; Thu, 4 Nov 2021 11:27:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT054.mail.protection.outlook.com (10.13.174.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 11:27:07 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Thu, 4 Nov 2021 11:27:04 +0000 From: Bing Zhao To: , CC: , , , Date: Thu, 4 Nov 2021 13:26:42 +0200 Message-ID: <20211104112644.17278-3-bingz@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211104112644.17278-1-bingz@nvidia.com> References: <20211104112644.17278-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73121d1a-5a7f-4728-3fc4-08d99f8608f3 X-MS-TrafficTypeDiagnostic: MN2PR12MB4424: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lYADOo0YfS9ksOTVWjPPQJGx1hrN2ObF4yAvZ9JAGLPyWKpfgbOCr37w6ZqgH4ynRch3tjPaJiOjycugJbvPatvRGR7dhoYo2p+11+PUoTN7dfc4fqbHnDsAdsoP/XwSbQwj2W3C4wAO3wgu6ktKac+KVgUiUZG2b3xNO7E8FjC+J9G7pAYcPkQOOggoi+Ty7laRabgOxfPKMFYBoM50l0m9zXLbCC+i9nQZoFf/YMkqY6raxjmo27p1EUD8k+GCNCwv1rMaQWRYmPm4Ej+GWRpJDHQkoC/sxR1Yr9BvUMqQFm5qJjbbj6ZvgNCbnAo4Du/OFLmLL/3TolODIZdELI1zyCeohrDuh3FV8xqQge2BunISZnhVxE62OFxQCAhi6lgeeKspnv531NYvsbTULGoyiC/Bu2NBU0tIQffSOgUfwoQpahY73tktxsGqrU8ueqYStn0UE4sOx7CcElXlhRaMBR+4JZLZx7nxPFUFb8ECnZGlqZQRjkyS8IhLUrKq77pWOh4ulE8k4waoclQSHyy6GmahhkryEFnXWX6FkAzsKYdX6Kih671r/+L7WZdyDD66WnF5RcduVA9VRdHciYJhnKr73yBr/afxKJl/DoHrqOr4xLG1z1f5btHDeukFNv2Ch7YT9MmLsYOvB2F6R/3ImejjMg7HIr8e/Y6AMyKWkrtXRv53+ylEX2Om5R2oiLU0MdN5w/x/moXM9m3YcsL353wQx+FrFb7ShlWccO8= X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(83380400001)(7636003)(1076003)(7696005)(47076005)(82310400003)(4326008)(5660300002)(2906002)(8676002)(356005)(70586007)(508600001)(6666004)(70206006)(86362001)(6636002)(36860700001)(107886003)(26005)(316002)(110136005)(54906003)(6286002)(36756003)(16526019)(55016002)(186003)(426003)(2616005)(8936002)(336012)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 11:27:07.3049 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73121d1a-5a7f-4728-3fc4-08d99f8608f3 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.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT054.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4424 Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: add support for Rx queue delay drop 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" For an Ethernet RQ, packets received when receive WQEs are exhausted are dropped. This behavior prevents slow or malicious software entities at the host from affecting the network. While for hairpin cases, even if there is no software involved during the packet forwarding from Rx to Tx side, some hiccup in the hardware or back pressure from Tx side may still cause the WQEs to be exhausted. In certain scenarios it may be preferred to configure the device to avoid such packet drops, assuming the posting of WQEs will resume shortly. To support this, a new devarg "delay_drop_en" is introduced, by default, the delay drop is enabled for hairpin Rx queues and disabled for standard Rx queues. This value is used as a bit mask: - bit 0: enablement of standard Rx queue - bit 1: enablement of hairpin Rx queue And this attribute will be applied to all Rx queues of a device. If the hardware capabilities do not support this delay drop, all the Rx queues will still be created without this attribute, and the devarg setting will be ignored. Signed-off-by: Bing Zhao --- drivers/net/mlx5/linux/mlx5_os.c | 11 +++++++++++ drivers/net/mlx5/mlx5.c | 7 +++++++ drivers/net/mlx5/mlx5.h | 9 +++++++++ drivers/net/mlx5/mlx5_devx.c | 5 +++++ drivers/net/mlx5/mlx5_rx.h | 1 + 5 files changed, 33 insertions(+) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index f51da8c3a3..def2cca3cd 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1506,6 +1506,15 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, goto error; #endif } + if (config->std_delay_drop || config->hp_delay_drop) { + if (!config->hca_attr.rq_delay_drop) { + config->std_delay_drop = 0; + config->hp_delay_drop = 0; + DRV_LOG(WARNING, + "dev_port-%u: Rxq delay drop is not supported", + priv->dev_port); + } + } if (sh->devx) { uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; @@ -2075,6 +2084,8 @@ mlx5_os_config_default(struct mlx5_dev_config *config) config->decap_en = 1; config->log_hp_size = MLX5_ARG_UNSET; config->allow_duplicate_pattern = 1; + config->std_delay_drop = 0; + config->hp_delay_drop = 1; } /** diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index dc15688f21..80a6692b94 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -183,6 +183,9 @@ /* Device parameter to configure implicit registration of mempool memory. */ #define MLX5_MR_MEMPOOL_REG_EN "mr_mempool_reg_en" +/* Device parameter to configure the delay drop when creating Rxqs. */ +#define MLX5_DELAY_DROP_EN "delay_drop_en" + /* Shared memory between primary and secondary processes. */ struct mlx5_shared_data *mlx5_shared_data; @@ -2095,6 +2098,9 @@ mlx5_args_check(const char *key, const char *val, void *opaque) config->decap_en = !!tmp; } else if (strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) == 0) { config->allow_duplicate_pattern = !!tmp; + } else if (strcmp(MLX5_DELAY_DROP_EN, key) == 0) { + config->std_delay_drop = tmp & MLX5_DELAY_DROP_STANDARD; + config->hp_delay_drop = tmp & MLX5_DELAY_DROP_HAIRPIN; } else { DRV_LOG(WARNING, "%s: unknown parameter", key); rte_errno = EINVAL; @@ -2157,6 +2163,7 @@ mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs) MLX5_DECAP_EN, MLX5_ALLOW_DUPLICATE_PATTERN, MLX5_MR_MEMPOOL_REG_EN, + MLX5_DELAY_DROP_EN, NULL, }; struct rte_kvargs *kvlist; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 74af88ec19..8d32d55c9a 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -99,6 +99,13 @@ enum mlx5_flow_type { MLX5_FLOW_TYPE_MAXI, }; +/* The mode of delay drop for Rx queues. */ +enum mlx5_delay_drop_mode { + MLX5_DELAY_DROP_NONE = 0, /* All disabled. */ + MLX5_DELAY_DROP_STANDARD = RTE_BIT32(0), /* Standard queues enable. */ + MLX5_DELAY_DROP_HAIRPIN = RTE_BIT32(1), /* Hairpin queues enable. */ +}; + /* Hlist and list callback context. */ struct mlx5_flow_cb_ctx { struct rte_eth_dev *dev; @@ -264,6 +271,8 @@ struct mlx5_dev_config { unsigned int dv_miss_info:1; /* restore packet after partial hw miss */ unsigned int allow_duplicate_pattern:1; /* Allow/Prevent the duplicate rules pattern. */ + unsigned int std_delay_drop:1; /* Enable standard Rxq delay drop. */ + unsigned int hp_delay_drop:1; /* Enable hairpin Rxq delay drop. */ struct { unsigned int enabled:1; /* Whether MPRQ is enabled. */ unsigned int stride_num_n; /* Number of strides. */ diff --git a/drivers/net/mlx5/mlx5_devx.c b/drivers/net/mlx5/mlx5_devx.c index 424f77be79..2e1d849eab 100644 --- a/drivers/net/mlx5/mlx5_devx.c +++ b/drivers/net/mlx5/mlx5_devx.c @@ -280,6 +280,7 @@ mlx5_rxq_create_devx_rq_resources(struct rte_eth_dev *dev, MLX5_WQ_END_PAD_MODE_NONE; rq_attr.wq_attr.pd = cdev->pdn; rq_attr.counter_set_id = priv->counter_set_id; + rq_attr.delay_drop_en = rxq_data->delay_drop; /* Create RQ using DevX API. */ return mlx5_devx_rq_create(cdev->ctx, &rxq_ctrl->obj->rq_obj, wqe_size, log_desc_n, &rq_attr, rxq_ctrl->socket); @@ -443,6 +444,8 @@ mlx5_rxq_obj_hairpin_new(struct rte_eth_dev *dev, uint16_t idx) attr.wq_attr.log_hairpin_data_sz - MLX5_HAIRPIN_QUEUE_STRIDE; attr.counter_set_id = priv->counter_set_id; + rxq_data->delay_drop = priv->config.hp_delay_drop; + attr.delay_drop_en = priv->config.hp_delay_drop; tmpl->rq = mlx5_devx_cmd_create_rq(priv->sh->cdev->ctx, &attr, rxq_ctrl->socket); if (!tmpl->rq) { @@ -503,6 +506,7 @@ mlx5_rxq_devx_obj_new(struct rte_eth_dev *dev, uint16_t idx) DRV_LOG(ERR, "Failed to create CQ."); goto error; } + rxq_data->delay_drop = priv->config.std_delay_drop; /* Create RQ using DevX API. */ ret = mlx5_rxq_create_devx_rq_resources(dev, rxq_data); if (ret) { @@ -921,6 +925,7 @@ mlx5_rxq_devx_obj_drop_create(struct rte_eth_dev *dev) rxq_ctrl->priv = priv; rxq_ctrl->obj = rxq; rxq_data = &rxq_ctrl->rxq; + rxq_data->delay_drop = 0; /* Create CQ using DevX API. */ ret = mlx5_rxq_create_devx_cq_resources(dev, rxq_data); if (ret != 0) { diff --git a/drivers/net/mlx5/mlx5_rx.h b/drivers/net/mlx5/mlx5_rx.h index 69b1263339..05807764b8 100644 --- a/drivers/net/mlx5/mlx5_rx.h +++ b/drivers/net/mlx5/mlx5_rx.h @@ -92,6 +92,7 @@ struct mlx5_rxq_data { unsigned int lro:1; /* Enable LRO. */ unsigned int dynf_meta:1; /* Dynamic metadata is configured. */ unsigned int mcqe_format:3; /* CQE compression format. */ + unsigned int delay_drop:1; /* Enable delay drop. */ volatile uint32_t *rq_db; volatile uint32_t *cq_db; uint16_t port_id; -- 2.27.0