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 29049A054D; Tue, 7 Jun 2022 15:00:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16772427EE; Tue, 7 Jun 2022 15:00:22 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2059.outbound.protection.outlook.com [40.107.223.59]) by mails.dpdk.org (Postfix) with ESMTP id 785D940689 for ; Tue, 7 Jun 2022 15:00:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X+uLEa44fEJH5BJoeqtBxis7WQWIHoonNuMxrTJbYKJCSTvVepQ9N7UO4MRA7Q/XgkDp+TibfNkRCNzn7/5LkbR9Sns5sDGI1T42wiyLKaZyLds8+y78MYhX53bqtfwZ2UemRO8oq3c5iSgfs/TzL6VmFf2GAaymfI5L61FFKE0OW8C+nwG+MCdmdJaGTkGjyLMYe3FkvC2+XMnUOZxefrFaY3ZZGweC8wPWRq2p8b0lobnR97vTshGDQrk77j+dXjss21tZRBPOvKAyB1M7YdPCuV2MyTrglXz7KQG+MQkZqOjSSavlDDFFsHa+AxKIFl+6T0QwEkRtO5Ur5cvZYA== 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=BXsDZyph7O0+Lbj8Nv1uiaVUxept8MQRmAVpIoPKggA=; b=m7lBzFuIIC+oQjBXWDhOOhX1l4G7jBJLFklPiNykT8s0ZRV7IwQ4Y3A/RDI/+69TtLtRyAUCTKhRL0vMQpc2BScoGaxvBa8m6zXM7Jx2w2bxyU5Y+MzooRk8kFD58UnwWrgC7yKfIcYnSky4OUmHN2Vp3QhP7lU8PNIJ+0JvInm7sGT8p47TVnZYuawQjfCce+S5m+mDpRnlfJ8NLJ97dod0h6GoS2TBgcyY85Kx0AADtylVN2yH5pltKXCEr9YlsU1LzuG6tc7dGEf3BMDCrZ7NNi8yKbfOXrpgqoyh056V4+4cf7H+cVo/lfMyVFWZAawHBhb8Xx2ynwIJL9lXzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=ashroe.eu 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=BXsDZyph7O0+Lbj8Nv1uiaVUxept8MQRmAVpIoPKggA=; b=Z1cNTNPTvlCH1sKFW67Ei8tzT/BTudVjvMuTb1KYYK6Qyym3l20gHxK8zDmDcIGcSHc5z6vkz01ybra0dR0ZNyDdlfJbfEsoKRzAfyQm7qwpMY02nUYlldLhA4gYIVHwGIw5Oh6eBExUHUTmUrThmSUuxlrOeVre7TcPpyr0DTcTk93GEHIEITqyHWLy8pJ/h6hDy1er6bNIv9E87tpy4hI+7/4opdYJF/BDu92IgO1LOdIxlb0gWKvUDqq5FQtFzcXkZJoYxYq546v6ViVFdWz81ZLUKjRw2m2DeVBDDAqDOFrds7rTnfFYDaVRpXAYC1oow+pjn+xmBACQZYXpfQ== Received: from MWHPR11CA0005.namprd11.prod.outlook.com (2603:10b6:301:1::15) by BYAPR12MB4693.namprd12.prod.outlook.com (2603:10b6:a03:98::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Tue, 7 Jun 2022 13:00:18 +0000 Received: from CO1NAM11FT030.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::89) by MWHPR11CA0005.outlook.office365.com (2603:10b6:301:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13 via Frontend Transport; Tue, 7 Jun 2022 13:00:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT030.mail.protection.outlook.com (10.13.174.125) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 7 Jun 2022 13:00:17 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Tue, 7 Jun 2022 13:00:10 +0000 Received: from nvidia.com (10.126.231.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.22; Tue, 7 Jun 2022 06:00:06 -0700 From: Spike Du To: , , , , Xiaoyun Li , Aman Singh , Yuying Zhang , "Ferruh Yigit" , Andrew Rybchenko , Ray Kinsella CC: , , , Subject: [PATCH v5 3/7] ethdev: introduce Rx queue based available descriptor threshold Date: Tue, 7 Jun 2022 15:59:38 +0300 Message-ID: <20220607125942.241379-4-spiked@nvidia.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220607125942.241379-1-spiked@nvidia.com> References: <20220603124821.1148119-1-spiked@nvidia.com> <20220607125942.241379-1-spiked@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.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-Office365-Filtering-Correlation-Id: 1a61aaac-1754-4c1f-52d8-08da4885abf8 X-MS-TrafficTypeDiagnostic: BYAPR12MB4693:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oamLfrlgNMA+Fdpa7Nrzhba5Ew5pROrzR3HjYPsDhAA/BW8vgJWKQymvVqAqmIODtIG3HVG4f0r/IVI6M/KucXpm6QfAg6a1tGlQ3lVopGCrvLqrA7zXQuh+SiVfZGgiYrgr4XWazdme0Fjex7r6gpm31xhzva/nuEtzMm8KAFBGRRP1LgQSlpewoE4/ma7nUC0Y9RJN2fz9GPsMZQADhj+YV0AzXqMsKASZOlbwUtDg7XagxutI4CYmDqUXA1KGcPmaOb5Mc4mwLVMoM9kaVS/ds1blRfEjLyUW8yAeBLqVU+S2z8amqaNcxp1EJWOO+1oicZzJR3mEJd9eN+sPsQdIKW9KCDI4qLzZXwErTJ1ZvdtzGNeeKDZufa60+BfZM+KcavMT2jUk6CVWoXH2REBnEG3T+zUMgRDEbGeZMvEfh4zVph0P85feR3ISsw/eDAWE3b+3TM4oThAoC2Iujjaq6Y7CygPjf79wxptR0g09ZwIgzOSAmvxn9MUAH/W0/d314dDq4cIqrjin/h3EpwsNtChmRQ798FiuNkpLewrFTf64wOQdsSnskXSibeaAUunEmvZPTx70JHMfgruUhnX7ZJMXWHjG2KBvTMn851N0nVtNkfhTrGrxQiuycrTcwpo48jzB0MCxNFG56cgyL/yRUsa9JUXALJ/XIvfqJ+rsFzdJfT8QKDN7wbq33bLupmcWeZumcPEEQg/xyY+WWohfpf0KyVp/5E7QEPqMopI= X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(36756003)(40460700003)(2906002)(6666004)(26005)(110136005)(6286002)(7696005)(86362001)(54906003)(316002)(508600001)(70206006)(921005)(30864003)(47076005)(356005)(55016003)(70586007)(426003)(7416002)(16526019)(336012)(186003)(8936002)(81166007)(2616005)(83380400001)(82310400005)(1076003)(8676002)(107886003)(5660300002)(4326008)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2022 13:00:17.8281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a61aaac-1754-4c1f-52d8-08da4885abf8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT030.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4693 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 available descriptor threshold describes the availability of a Rx queue for hardware. If the availability is below the threshold, the device will trigger the event RTE_ETH_EVENT_RX_AVAIL_THRESH. available descriptor threshold is defined as a percentage of Rx queue size with valid value of [0,99]. Setting available descriptor threshold to 0 means disable it, which is the default. Add available descriptor threshold configuration and query driver callbacks in eth_dev_ops. Add command line options to support avail_thresh per-rxq configure. - Command syntax: set port rxq avail_thresh - Example commands: To configure avail_thresh as 30% of rxq size on port 1 rxq 0: testpmd> set port 1 rxq 0 avail_thresh 30 To disable avail_thresh on port 1 rxq 0: testpmd> set port 1 rxq 0 avail_thresh 0 Signed-off-by: Spike Du --- app/test-pmd/cmdline.c | 68 ++++++++++++++++++++++++++++++++++++++++++ app/test-pmd/config.c | 20 +++++++++++++ app/test-pmd/testpmd.c | 14 +++++++++ app/test-pmd/testpmd.h | 2 ++ lib/ethdev/ethdev_driver.h | 22 ++++++++++++++ lib/ethdev/rte_ethdev.c | 44 ++++++++++++++++++++++++++++ lib/ethdev/rte_ethdev.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++ lib/ethdev/version.map | 2 ++ 8 files changed, 245 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0410bad..bbf5835 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -17823,6 +17823,73 @@ struct cmd_show_port_flow_transfer_proxy_result { } }; +/* *** SET AVAIL THRESHOLD FOR A RXQ OF A PORT *** */ +struct cmd_rxq_avail_thresh_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + uint16_t port_num; + cmdline_fixed_string_t rxq; + uint16_t rxq_num; + cmdline_fixed_string_t avail_thresh; + uint8_t avail_thresh_num; +}; + +static void cmd_rxq_avail_thresh_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_rxq_avail_thresh_result *res = parsed_result; + int ret = 0; + + if ((strcmp(res->set, "set") == 0) && (strcmp(res->port, "port") == 0) + && (strcmp(res->rxq, "rxq") == 0) + && (strcmp(res->avail_thresh, "avail_thresh") == 0)) + ret = set_rxq_avail_thresh(res->port_num, res->rxq_num, + res->avail_thresh_num); + if (ret < 0) + printf("rxq_avail_thresh_cmd error: (%s)\n", strerror(-ret)); + +} + +static cmdline_parse_token_string_t cmd_rxq_avail_thresh_set = + TOKEN_STRING_INITIALIZER(struct cmd_rxq_avail_thresh_result, + set, "set"); +static cmdline_parse_token_string_t cmd_rxq_avail_thresh_port = + TOKEN_STRING_INITIALIZER(struct cmd_rxq_avail_thresh_result, + port, "port"); +static cmdline_parse_token_num_t cmd_rxq_avail_thresh_portnum = + TOKEN_NUM_INITIALIZER(struct cmd_rxq_avail_thresh_result, + port_num, RTE_UINT16); +static cmdline_parse_token_string_t cmd_rxq_avail_thresh_rxq = + TOKEN_STRING_INITIALIZER(struct cmd_rxq_avail_thresh_result, + rxq, "rxq"); +static cmdline_parse_token_num_t cmd_rxq_avail_thresh_rxqnum = + TOKEN_NUM_INITIALIZER(struct cmd_rxq_avail_thresh_result, + rxq_num, RTE_UINT16); +static cmdline_parse_token_string_t cmd_rxq_avail_thresh_avail_thresh = + TOKEN_STRING_INITIALIZER(struct cmd_rxq_avail_thresh_result, + avail_thresh, "avail_thresh"); +static cmdline_parse_token_num_t cmd_rxq_avail_thresh_avail_threshnum = + TOKEN_NUM_INITIALIZER(struct cmd_rxq_avail_thresh_result, + avail_thresh_num, RTE_UINT8); + +static cmdline_parse_inst_t cmd_rxq_avail_thresh = { + .f = cmd_rxq_avail_thresh_parsed, + .data = (void *)0, + .help_str = "set port rxq avail_thresh " + "Set avail_thresh for rxq on port_id", + .tokens = { + (void *)&cmd_rxq_avail_thresh_set, + (void *)&cmd_rxq_avail_thresh_port, + (void *)&cmd_rxq_avail_thresh_portnum, + (void *)&cmd_rxq_avail_thresh_rxq, + (void *)&cmd_rxq_avail_thresh_rxqnum, + (void *)&cmd_rxq_avail_thresh_avail_thresh, + (void *)&cmd_rxq_avail_thresh_avail_threshnum, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -18110,6 +18177,7 @@ struct cmd_show_port_flow_transfer_proxy_result { (cmdline_parse_inst_t *)&cmd_show_capability, (cmdline_parse_inst_t *)&cmd_set_flex_is_pattern, (cmdline_parse_inst_t *)&cmd_set_flex_spec_pattern, + (cmdline_parse_inst_t *)&cmd_rxq_avail_thresh, NULL, }; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 1b1e738..b754091 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -6342,3 +6342,23 @@ struct igb_ring_desc_16_bytes { printf(" %s\n", buf); } } + +int +set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id, uint8_t avail_thresh) +{ + struct rte_eth_link link; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return -EINVAL; + ret = eth_link_get_nowait_print_err(port_id, &link); + if (ret < 0) + return -EINVAL; + if (avail_thresh > 99) + return -EINVAL; + ret = rte_eth_rx_avail_thresh_set(port_id, queue_id, avail_thresh); + if (ret != 0) + return ret; + return 0; +} + diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 767765d..33d9b85 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -420,6 +420,7 @@ struct fwd_engine * fwd_engines[] = { [RTE_ETH_EVENT_NEW] = "device probed", [RTE_ETH_EVENT_DESTROY] = "device released", [RTE_ETH_EVENT_FLOW_AGED] = "flow aged", + [RTE_ETH_EVENT_RX_AVAIL_THRESH] = "rxq available threshold reached", [RTE_ETH_EVENT_MAX] = NULL, }; @@ -3616,6 +3617,9 @@ struct pmd_test_command { eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, void *ret_param) { + uint16_t rxq_id; + uint8_t avail_thresh; + int ret; RTE_SET_USED(param); RTE_SET_USED(ret_param); @@ -3647,6 +3651,16 @@ struct pmd_test_command { ports[port_id].port_status = RTE_PORT_CLOSED; printf("Port %u is closed\n", port_id); break; + case RTE_ETH_EVENT_RX_AVAIL_THRESH: + /* avail_thresh query API rewinds rxq_id, no need to check max rxq num. */ + for (rxq_id = 0; ; rxq_id++) { + ret = rte_eth_rx_avail_thresh_query(port_id, &rxq_id, &avail_thresh); + if (ret <= 0) + break; + printf("Received avail_thresh event, port:%d rxq_id:%d\n", + port_id, rxq_id); + } + break; default: break; } diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 78a5f4e..5b268f4 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -1173,6 +1173,8 @@ uint16_t tx_pkt_set_dynf(uint16_t port_id, __rte_unused uint16_t queue, void flex_item_create(portid_t port_id, uint16_t flex_id, const char *filename); void flex_item_destroy(portid_t port_id, uint16_t flex_id); void port_flex_item_flush(portid_t port_id); +int set_rxq_avail_thresh(portid_t port_id, uint16_t queue_id, + uint8_t avail_thresh); extern int flow_parse(const char *src, void *result, unsigned int size, struct rte_flow_attr **attr, diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 69d9dc2..847f86a 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -1074,6 +1074,23 @@ typedef int (*eth_ip_reassembly_conf_set_t)(struct rte_eth_dev *dev, typedef int (*eth_dev_priv_dump_t)(struct rte_eth_dev *dev, FILE *file); /** + * @internal Set Rx queue available descriptor threshold. + * @see rte_eth_rx_avail_thresh_set() + */ +typedef int (*eth_rx_queue_avail_thresh_set_t)(struct rte_eth_dev *dev, + uint16_t rx_queue_id, + uint8_t avail_thresh); + +/** + * @internal Query queue available descriptor threshold event. + * @see rte_eth_rx_avail_thresh_query() + */ + +typedef int (*eth_rx_queue_avail_thresh_query_t)(struct rte_eth_dev *dev, + uint16_t *rx_queue_id, + uint8_t *avail_thresh); + +/** * @internal A structure containing the functions exported by an Ethernet driver. */ struct eth_dev_ops { @@ -1283,6 +1300,11 @@ struct eth_dev_ops { /** Dump private info from device */ eth_dev_priv_dump_t eth_dev_priv_dump; + + /** Set Rx queue available descriptor threshold. */ + eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set; + /** Query Rx queue available descriptor threshold event. */ + eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query; }; /** diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index a175867..92fb282 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -4424,6 +4424,50 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx, queue_idx, tx_rate)); } +int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id, + uint8_t avail_thresh) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (queue_id > dev->data->nb_rx_queues) { + RTE_ETHDEV_LOG(ERR, + "Set queue avail thresh: port %u: invalid queue ID=%u.\n", + port_id, queue_id); + return -EINVAL; + } + + if (avail_thresh > 99) { + RTE_ETHDEV_LOG(ERR, + "Set queue avail thresh: port %u: threshold should be <= 99.\n", + port_id); + return -EINVAL; + } + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_avail_thresh_set, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->rx_queue_avail_thresh_set)(dev, + queue_id, avail_thresh)); +} + +int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id, + uint8_t *avail_thresh) +{ + struct rte_eth_dev *dev; + + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); + dev = &rte_eth_devices[port_id]; + + if (queue_id == NULL) + return -EINVAL; + if (*queue_id >= dev->data->nb_rx_queues) + *queue_id = 0; + + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_avail_thresh_query, -ENOTSUP); + return eth_err(port_id, (*dev->dev_ops->rx_queue_avail_thresh_query)(dev, + queue_id, avail_thresh)); +} + RTE_INIT(eth_dev_init_fp_ops) { uint32_t i; diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 04225bb..d01bfe4 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -1931,6 +1931,14 @@ struct rte_eth_rxq_info { uint8_t queue_state; /**< one of RTE_ETH_QUEUE_STATE_*. */ uint16_t nb_desc; /**< configured number of RXDs. */ uint16_t rx_buf_size; /**< hardware receive buffer size. */ + /** + * Per-queue Rx available descriptor threshold defined as percentage + * of Rx queue size. If Rx queue available descriptor is lower than + * this percentage, the event RTE_ETH_EVENT_RX_AVAIL_THESH is triggered. + * Value 0 means threshold monitoring is disabled, no event is + * triggered. + */ + uint8_t avail_thresh; } __rte_cache_min_aligned; /** @@ -3672,6 +3680,66 @@ int rte_eth_dev_set_vlan_ether_type(uint16_t port_id, */ int rte_eth_dev_set_vlan_pvid(uint16_t port_id, uint16_t pvid, int on); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Set Rx queue based available descriptor threshold. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The index of the receive queue. + * @param avail_thresh + * The available descriptor threshold is percentage of Rx queue size which + * describes the availability of Rx queue for hardware. If the Rx queue + * availability is below it, the device will trigger the event + * RTE_ETH_EVENT_RX_AVAIL_THRESH. + * [1-99] to set a new available descriptor threshold. + * 0 to disable thresold monitoring. + * + * @return + * - 0 if successful. + * - negative if failed. + */ +__rte_experimental +int rte_eth_rx_avail_thresh_set(uint16_t port_id, uint16_t queue_id, + uint8_t avail_thresh); + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Query Rx queue based available descriptor threshold event. + * The function queries all queues in the port circularly until one + * pending avail_thresh event is found or no pending avail_thresh event is found. + * + * @param port_id + * The port identifier of the Ethernet device. + * @param queue_id + * The API caller sets the starting Rx queue id in the pointer. + * If the queue_id is bigger than maximum queue id of the port, + * it's rewinded to 0 so that application can keep calling + * this function to handle all pending avail_thresh events in the queues + * with a simple increment between calls. + * If a Rx queue has pending avail_thresh event, the pointer is updated + * with this Rx queue id; otherwise this pointer's content is + * unchanged. + * @param avail_thresh + * The pointer to the available descriptor threshold percentage of Rx queue. + * If Rx queue with pending avail_thresh event is found, the queue's avail_thresh + * percentage is stored in this pointer, otherwise the pointer's + * content is unchanged. + * + * @return + * - 1 if a Rx queue with pending avail_thresh event is found. + * - 0 if no Rx queue with pending avail_thresh event is found. + * - -EINVAL if queue_id is NULL. + */ +__rte_experimental +int rte_eth_rx_avail_thresh_query(uint16_t port_id, uint16_t *queue_id, + uint8_t *avail_thresh); + typedef void (*buffer_tx_error_fn)(struct rte_mbuf **unsent, uint16_t count, void *userdata); @@ -3877,6 +3945,11 @@ enum rte_eth_event_type { RTE_ETH_EVENT_DESTROY, /**< port is released */ RTE_ETH_EVENT_IPSEC, /**< IPsec offload related event */ RTE_ETH_EVENT_FLOW_AGED,/**< New aged-out flows is detected */ + /** + * Available threshold value is exceeded in a queue. + * @see rte_eth_rx_avail_thresh_set() + */ + RTE_ETH_EVENT_RX_AVAIL_THRESH, RTE_ETH_EVENT_MAX /**< max value of this enum */ }; diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index daca785..2fd928f 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -285,6 +285,8 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + rte_eth_rx_avail_thresh_set; + rte_eth_rx_avail_thresh_query; }; INTERNAL { -- 1.8.3.1