From patchwork Tue Jul 21 14:24:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 74576 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 00429A0526; Tue, 21 Jul 2020 16:25:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 159C81BFFE; Tue, 21 Jul 2020 16:25:03 +0200 (CEST) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40082.outbound.protection.outlook.com [40.107.4.82]) by dpdk.org (Postfix) with ESMTP id D8F161BFEF for ; Tue, 21 Jul 2020 16:24:59 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V7p8vOchJV1CdZYtq5hdUvAPePZ+WxRqMPUGFVV/ZHzG5vVAiPXp4IdLVhIdWd+VsXEW01UIqFFepcJb0vv9pUJgmyInJs9qTvziL0EmFTB5lxy/CcFKZS8lkYtZsvR+NlNDVSrfuPBqSmrGXp1FZSQSLNC9SVcb5ImnSHMHxZ4gAC8WScHEhsZaUtiewEYN3KvadJmN26W/QX0haCGLNPKvoRFR4/0jhUHAqJMdLyswCFlqlb7h5kt2xeJ1NKiCLgoBBZJmtlOtduManG4w8dJ0Siwd0qPXZ3ukcGmPcCjcI9O2zhVNqDp1/qskSbvS3/Ou3NLGveZo+jZkfs00hA== 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=RwjfJrHV9g4naORrthaEpG8d+E8H1C6ohOcOqcHrV2g=; b=ZLE/v3wbq7BGUHe2GfFRm83B9ZUeF14tEed/BbMSTZNAQ3EJ/MXJQFz0wCtSxM7O2iuNYrfZzVpa+l5joYlzT801srPij5PROqtUywIycyF4LZ7B3jEvKjkzFyLQGdFQTzZOUFM7OKaWmlN4sgfbhUWhhWKtYyZCAmgLa0vDfjM7aS48WRiatyrKO95iROXvyqaDECA9S2HQG5DSKyCEBmF5GolVM2RTF3N9SPw9LUZoDgAZOY4qQdbmDuuaPacMBzGejgWduW2EP243/etXlGvOTJgdbr170BiKvSE7e5vtQ2bGcFvTWO6Vvjk/hKbmb7vB8N8m+35tn7Fi7sipKQ== 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=RwjfJrHV9g4naORrthaEpG8d+E8H1C6ohOcOqcHrV2g=; b=pbGbpTswNZQ5qEOtLluYixI1XKKAh4OZcd4yUKY4D0zm1mGA17Cd2vn891xfiib0IpmjQ0fH5wSlsY2GLrUQOsOytbZHB3pTy84b9+WA+ugYduyiMfme7DSGrMYhjKncZ1XwB06/mHa2nPzDhtlvYoNqO5a5m7ABb907ILwIpDY= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM6PR05MB4216.eurprd05.prod.outlook.com (2603:10a6:209:41::13) by AM6PR05MB5588.eurprd05.prod.outlook.com (2603:10a6:20b:5a::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.18; Tue, 21 Jul 2020 14:24:58 +0000 Received: from AM6PR05MB4216.eurprd05.prod.outlook.com ([fe80::b40f:4c0e:77de:a785]) by AM6PR05MB4216.eurprd05.prod.outlook.com ([fe80::b40f:4c0e:77de:a785%4]) with mapi id 15.20.3195.026; Tue, 21 Jul 2020 14:24:57 +0000 From: Ophir Munk To: dev@dpdk.org Cc: Raslan Darawsheh , Ophir Munk , Matan Azrad Date: Tue, 21 Jul 2020 14:24:49 +0000 Message-Id: <20200721142449.24767-2-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200721142449.24767-1-ophirmu@mellanox.com> References: <20200716053658.30453-1-ophirmu@mellanox.com> <20200721142449.24767-1-ophirmu@mellanox.com> X-ClientProxiedBy: AM3PR07CA0129.eurprd07.prod.outlook.com (2603:10a6:207:8::15) To AM6PR05MB4216.eurprd05.prod.outlook.com (2603:10a6:209:41::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM3PR07CA0129.eurprd07.prod.outlook.com (2603:10a6:207:8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.14 via Frontend Transport; Tue, 21 Jul 2020 14:24:57 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 8bfbd472-4254-471a-dec7-08d82d81d856 X-MS-TrafficTypeDiagnostic: AM6PR05MB5588: 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:923; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ox/Hl5nRptk02kMSBVZDrYfbeWyY0OUCekb1zescU4Sp7ShulxQZlWxGXKrT/j7oLbU/VD9cJh0Xp3/Q/yetnz1j13dwPxxWot86TE33xvCKJgHz5MuR+4x7nPH9J0o0T2u1BqOdE2EQUrAbl08mvh1BllDQvujPL/n19WvySAtqNFzhb3oAYeKVzuSHjKj0UHk/SF7zZEo4PwXbppgx41sSkc3JGMLeYfFPySNmN4nyIpEVgG2CRd8LVEsppkvNHPju0ekGBkYVtYxODBbHZD73hSRAvRJztuoWkv8VQRnUkOIqn5gjYoC4SCk6/sFc6v83uxmRVUBZhDaaRqh96g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR05MB4216.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(66946007)(5660300002)(66556008)(7696005)(52116002)(66476007)(86362001)(186003)(54906003)(16526019)(26005)(107886003)(8676002)(6916009)(8936002)(55016002)(498600001)(2906002)(1076003)(4326008)(956004)(8886007)(2616005)(6666004)(83380400001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: FsH6uJlXL2vFE63MWuIQosPz3IjFyDcvrinu8oIziwMJM1PQqhaJjz9NeUuEIvdC8qk0L4YxXs0/bP0FXN3dR25fh9YkHGjozWH7pzGu08D8Jpks3CYnjeseRrTX/1U8fxpqHqu4qXN9FoyhdsPbnDjgPLfZHJVOmrHDUQP/ai38xRVLc0hRdEXUoBA8+Lxplts+sfX3dpm82/aR2/d1O51TdHU+sqwSVsgwoSB01kJ2/FsrapDl4hTYHME/nJawTYTCSr4SA8XYrqynGzDoY15/cpRbQGaorRkwHTZPHSeE+9+YvEBXxmLfeZbwXp0GbFWmlhLlPyJLT52vPENxEnnsVZi8MlvZj5d+3o2YNclRtaJhOgQFbmor9IfXpLTXBaky+/Crs9kakytuq+qwmmZCbx+XOXOJM/vUEucZd/UWWVAuAQhyrkuEF9gH3ygvuyb82L5En7GY/QCYeJufKWwQrVsXSDWtRpupJYR3REYYle3RgaySpfRsBYihHtlL X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bfbd472-4254-471a-dec7-08d82d81d856 X-MS-Exchange-CrossTenant-AuthSource: AM6PR05MB4216.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jul 2020 14:24:57.8816 (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: w50bMeMS5tXSdEwbKgUTeVll8F2kp7Vdhgcr96ksu+Th4d7yYouavobAt66y+AApyotbwwNO/3IEErdVOF3Azw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR05MB5588 Subject: [dpdk-dev] [PATCH v2] net/mlx5: return EAGAIN on premature disable interrupt calls 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" RXQ interrupts under Linux are based on the epoll mechanism. An expected order of operations is as follows: 1. Call rte_eth_dev_rx_intr_enable(), to arm the CQ for receiving events on data input. 2. Block on rte_epoll_wait() with an array of file descriptors representing the CQ events. Upon data arrival the kernel will signal an input event on the corresponding CQ fd. 3. Call rte_eth_dev_rx_intr_disable() after the event was received and continue in polling mode. The mlx5 implementation of rte_eth_dev_rx_intr_disable() is to get the CQ event and ack it. In practice applications may wake up from rte_epoll_wait() due to timeout with no event to ack but still call rte_eth_dev_rx_intr_disable() unconditionally. In such cases the call should return EAGAIN (since the file descriptors are non-blocked), as opposed to EINVAL which indicates a real failure. In case of EAGAIN the PMD should not warn on "Unable to disable interrupt on Rx queue". This commit also fixes (1) where a 0 returned value from function devx_get_event() was considered an error. Fixes: 19e429e5c7c2 ("net/mlx5: implement CQ for RxQ using DevX API") Signed-off-by: Ophir Munk Acked-by: Viacheslav Ovsiienko Acked-by: Raslan Darawsheh --- drivers/net/mlx5/mlx5_rxq.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index e6dc5ac..c78e522 100644 --- a/drivers/net/mlx5/mlx5_rxq.c +++ b/drivers/net/mlx5/mlx5_rxq.c @@ -1188,10 +1188,8 @@ mlx5_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id) if (rxq_obj->type == MLX5_RXQ_OBJ_TYPE_IBV) { ret = mlx5_glue->get_cq_event(rxq_obj->ibv_channel, &ev_cq, &ev_ctx); - if (ret || ev_cq != rxq_obj->ibv_cq) { - rte_errno = EINVAL; + if (ret < 0 || ev_cq != rxq_obj->ibv_cq) goto exit; - } mlx5_glue->ack_cq_events(rxq_obj->ibv_cq, 1); } else if (rxq_obj->type == MLX5_RXQ_OBJ_TYPE_DEVX_RQ) { #ifdef HAVE_IBV_DEVX_EVENT @@ -1200,22 +1198,29 @@ mlx5_rx_intr_disable(struct rte_eth_dev *dev, uint16_t rx_queue_id) ret = mlx5_glue->devx_get_event (rxq_obj->devx_channel, event_data, sizeof(struct mlx5dv_devx_async_event_hdr)); - if (ret <= 0 || event_data->cookie != - (uint64_t)(uintptr_t)rxq_obj->devx_cq) { - rte_errno = EINVAL; + if (ret < 0 || event_data->cookie != + (uint64_t)(uintptr_t)rxq_obj->devx_cq) goto exit; - } #endif /* HAVE_IBV_DEVX_EVENT */ } rxq_data->cq_arm_sn++; mlx5_rxq_obj_release(rxq_obj); return 0; exit: + /** + * For ret < 0 save the errno (may be EAGAIN which means the get_event + * function was called before receiving one). + */ + if (ret < 0) + rte_errno = errno; + else + rte_errno = EINVAL; ret = rte_errno; /* Save rte_errno before cleanup. */ if (rxq_obj) mlx5_rxq_obj_release(rxq_obj); - DRV_LOG(WARNING, "port %u unable to disable interrupt on Rx queue %d", - dev->data->port_id, rx_queue_id); + if (ret != EAGAIN) + DRV_LOG(WARNING, "port %u unable to disable interrupt on Rx queue %d", + dev->data->port_id, rx_queue_id); rte_errno = ret; /* Restore rte_errno. */ return -rte_errno; }