From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10061.outbound.protection.outlook.com [40.107.1.61]) by dpdk.org (Postfix) with ESMTP id 4E3321B024 for ; Thu, 25 Jan 2018 09:07:34 +0100 (CET) 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; bh=upR6Rkpq3w2zA1OXL6bK1Tp5wikEn98PKwJE0YBLdwM=; b=B5VTyWw782h9wWJSux8NZQzBbjAlcXSIJ76Otnj0nGDNhXSe1Ys7Ry6Zg9tybkTP68Y4Ek9ovi5WzXsZPayye+WYuTL+a5pIEWCPY4S75yuTHbSXV1DiDLx7mtCALVT/9CsX3VdG02HvTbS4e5VaDkCTQYuaZNbtPhTYY+rf3kw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR05MB3206.eurprd05.prod.outlook.com (2603:10a6:6:1a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Thu, 25 Jan 2018 08:07:31 +0000 From: Moti Haimovsky To: gaetan.rivet@6wind.com, ferruh.yigit@intel.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 25 Jan 2018 10:07:13 +0200 Message-Id: <1516867635-67104-2-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1516867635-67104-1-git-send-email-motih@mellanox.com> References: <1516810328-39383-3-git-send-email-motih@mellanox.com> <1516867635-67104-1-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0102CA0036.eurprd01.prod.exchangelabs.com (2603:10a6:802::49) To DB6PR05MB3206.eurprd05.prod.outlook.com (2603:10a6:6:1a::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc37df66-0bf6-42d3-53c2-08d563caafd3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:DB6PR05MB3206; X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 3:ajuecgFDUubTpmV12loUtJS5jy2NuuB2r1mShz0dkw2j9U/26o0YbBuCNODfWQk3+B1E+IfsfpXO/dcJrRNdA/A2jGQf/m8x4z4DjzwTuSbNIoKBMt7suF8TfYNLVNaKN3ztVthA+UxdZxE0pXWWu2qDZB2xtzP/Z7K9cl3nHVm3ELCHpa3zR2j8DCAdEbR4X16O38xGbSDXv3s6ZsjPESzbr1oqVj8tX07uskhRdSm2bkYL3VQcGioQv8jFlSlK; 25:2gdWl/8DvQhKVYlbiftGwHHJqwR/8O7OKpik+UIH9TexgzdAyHAY91u/LTjqZ0J27cxhPhkm5Ppl1UQKJ8xkgv3rRY/ZZNC6Z8k7r5EsdpAniCAZru4JAxBLKXR0d5fNAIRVFY9U8fvGdhdZp6LJ9Yn/tgUsBAeryG4fT89/Te4cYoEGVptF7V0LVxlnorkhcLuRDgsVHPt3LH9wY60CkRN/SOPwe/FznKLDAwsF4hDLy4Ewm7JAqniGQTksVSGHr9d58X+1SQDCfRb8S6pQqzInJMo5skilqABLzUFfVEdXqaV2XJP620yzXhzca3goh01izizCFWLBmOefb98FLg==; 31:2RovWdcWjVv6dl7Iy8/b2C4Y0ialzEI9JBvfmyUfg4QNzD8kcETIqlRefVYu6fRMfFoX2IOteZg5is/DvtjB2RCsDneoDOxuGA5Bhb+US4jT/f3Gfe6MaT2804RCOMXtbED4g96KgPSl7arNyywGvm1u/f84wlbnTJ4CYFKnSEW+MmbUg/FRkJXuNpmJy1ipC8iPWMbmuEJ46mSI95Y84uLLtfV18qFpMHANiO0Sb3w= X-MS-TrafficTypeDiagnostic: DB6PR05MB3206: X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 20:t2a0PZTqSPeU+XJOl5YcbY40+YMKDDQ8r016CHOsR/O++6vv6YUaggG7qgbm3fd+arvm/j0sAzzS2IW5kaqY1zTXV+JUyKaTtF2eVG4OywbDH1XZId2UzV9f0apt4UYaTl+aPAPSsI9dHL00/I+n+ZhmdZ7TDtIKnkj6syGwNWzUtzGS8H/+uZY3/57Gr78l8r0Kq21OR3D09Sjxo2c/sHHy3uSuXWQdCAbJCVX1rV4oeeXE/7076EulSAI45DBWeASq/iMmf88cdHAfA9HXpHvQKvdWikyq/sg6n6U0sr6MGS3GvemqsU/Z4N3gJSAj0tJXP2MI6Imnz+CGl/Ct5swu3sXuVxKKaGDpxvU2JNv+LC4twfOtpQPEI9Kckji0Z/T+QJE1de3Qcsazro8oK5mAr3n7HyQwmb2XP+1y7lp+3eDQDU2NNzX7wdVEKIymfCAe3iOHFH7/NZKRCP4q+9AS6h9ECjWme1h0ODsmqbiTi6wbQAuQdQo0+ACn2/h+; 4:Au7SsG4cDFY+yZlhkGQMIckVrEbskKWzxE4qszMcpnXoxwuCE3W+sDiEre/PnhHStq0cX2Iw++wOirsHgfd07qC8kx7SZ0rvQs+rCR7bVoMterhFvmKJixbIqofQ1vIE1WmuvWjVWT0rw0nc9k/iH5N4YMjZ/jp3CPH2V5j4l/6ybkGSFx4hHeeAAX0oJLSEu6SnWCNsFhTlvSOhEDKa5xDgjw+lAW/iqMu/BudkRd3+wsu/HVIfcDhqzNUUsROYqtc7Gfa6PqIgo55TfTzPeQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(3231023)(2400081)(944501161)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041288)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DB6PR05MB3206; BCL:0; PCL:0; RULEID:; SRVR:DB6PR05MB3206; X-Forefront-PRVS: 0563F2E8B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(376002)(396003)(366004)(39860400002)(189003)(199004)(36756003)(26005)(69596002)(2906002)(305945005)(6116002)(7736002)(5660300001)(3846002)(76176011)(97736004)(7696005)(52116002)(16526018)(51416003)(316002)(59450400001)(386003)(86362001)(6666003)(16586007)(105586002)(4326008)(21086003)(107886003)(8936002)(50226002)(8676002)(81166006)(81156014)(2950100002)(106356001)(68736007)(33026002)(53936002)(66066001)(4720700003)(47776003)(48376002)(478600001)(50466002)(25786009)(55016002)(186003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR05MB3206; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR05MB3206; 23:WIfUAlZ/s/c1pMo4dAOJp2gWR4Zg2kLcelrZzJt4d?= =?us-ascii?Q?DH8j66CrpVVou7x4e9YhTZDh4fduFYDYkEYCGD9A+ImMdUv6teDZ0rW2EVE2?= =?us-ascii?Q?heRdYYGmfqa1WuuNgGr1DrZaKvW4za4BRgisxG3QLK97r3vH7ADdGnDYH0pL?= =?us-ascii?Q?EIE6GRzfRJzJhnmeYJVX4bCzBySQDpdhz2GbP3SxTwL7v7R/FHuM17+Wumgu?= =?us-ascii?Q?EMIkNiNpA/l6mif+g+DTICBsgNjhLJQ2C18i64oyvfPEGCTmMgObuWg9yxhT?= =?us-ascii?Q?4dKTaWxkm7tWskRmaGyp3Phs82KXNF4hlBT34WyH8V/9aRtKhBQIx9rzXJpy?= =?us-ascii?Q?ZLgNvqCMwEbonp+T5CHeKlAmCjWsZ7Jf027x8kHykDlpFTmxCX76GxtKxOxd?= =?us-ascii?Q?WYH2jJFyys28ndNFvKbBIheE/wZAzGxodDOhFj9e20+Cc5eiKTgr6YY59MDX?= =?us-ascii?Q?Bv9t38hA/dyu7KHWJyc4AvYi11AkABu3W9Z5OPpKRWvKVd23PL9QMTAka2x7?= =?us-ascii?Q?qsbmpAErzwHAKxirX6h2mfyc2NwIipDEnhOvjheHNefK0ws/ZgBzbAGJco1a?= =?us-ascii?Q?Xjqbqw1vLBZF+B70MA6fTgv7lRzfjRFDXMS/1FDLfieRRXTe511o2zeHYIqN?= =?us-ascii?Q?OuOwOUqhcn1I6/YbhSv8s8qg7Pw3TFSdZOFvPKS4huvRcXAb12pCKb5TTXA1?= =?us-ascii?Q?6ZNMrlXAIeA0HlRGbPKg7x2OA98dfFBrc61gof/OvUMCHcAWG7hOzfrWlpdX?= =?us-ascii?Q?0Av9N4fz8EZh5Oa18mX3Oy/DJU0D6HFHTdAme6vg1yszxi9fp+Y9Bwrp+hY6?= =?us-ascii?Q?CATBTUI+cPW/WggtTP++C9WWeng8WViVXXQqy3p2JxS5oVN14gWKDlJWMtxd?= =?us-ascii?Q?apG9+HRBRUxVj/7x+Ygw5ZXXuVQGhbvSfbecTCbYY1rd3juBbLe6Po2KCVPp?= =?us-ascii?Q?+iz2igTBFuuPcDtWUrq6DceRj3s/eQoz8y7vHmgzgjCt8XZzxsFfk2VqVXBM?= =?us-ascii?Q?hDl4HGpuJF2jgcJKq1rA9HQJyCikSFItt064obIW4+hwUHx3LwcXvgsImHP5?= =?us-ascii?Q?GpvrJRDwlBFGgZMsj57aOSy2J+nNTULIAv3bPTrbj3/VcGitrzLYfMccTwPw?= =?us-ascii?Q?fgpzloYRiFFjzlIuftoRTOGAqkTjPe4MBCvMx718z8WpzI+6HnOu8Mzm0oL5?= =?us-ascii?Q?zMoCZuVaWx2ds6mhFWWXULYPcxL8f8RHdEk?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 6:lENdI0hufY2WMx440DhOpQksNGcBH6syv7ypjBP2HWqgQxcs5QRXqdm20rNOkzCd4DOT7UOQl5szueTiwCKNmAyxZpgFbkQRmUs2KOV6wgZlQ3ZgcWA9UgKeEDshe5eJoIvn4k6KOQJ+HWrDyJTND8iO2OKPCmicK15tGTLM1cyuHKjjEmng+rksQ/3v3GBN6iWl8Uu2NyVBVDus13pYseNk6Fmid0F1ml2wIH3qI1C3mwAojlx+QK+YoeAurODxPyXB0OnEhoDsy4YbcH4d4g03eOXr/wqnJiU0UntSqkUoyQMOAd1VT6mIAXfl8cCfoA1s2LdW1IJsR5NC3lkD09o2XrVf5wmKASwGnfNVv+U=; 5:NHAvn0uJxXxs5gF2MTilmCraMkefoJYAsM32JvMo97dZaQYWITXIrZdGgWmTnnk6WYEvqZ6L6XnnTgHPC9vwTfKf76SBMxaw0q9ShYIGTa6+tRDRRQZPL+sPRpVU9WeRomacJQ4L6wr4gmsS7vjan73pz1LXqAY8+iJfrF81U80=; 24:jx6oiUNhcAzDNcs1c/cIk0ZgK9GW6JE5FHMJlUeZV68KtbL5v1JCGFzky6rptac6wJlwVR6KBBtMk8yeS5xq9aQUDsLSZshW4t6UTqmUOEA=; 7:kq2JzHhPuRjHw1EjrwYgQGy5G4LOxVa+VA9fQTafc973RYhwKwB1g6F1DfInjG7NFi/CeBD/ed88VcXZItF5SEie4ExbtpollhWmjlKsX43xfbiYlaODBw6c2iITorgRf0GpX9COo5zyS+l9Ux2P/wmDgYZR94Kh0YVE3kzNhlsSJyZOhAQZqF7wLnuxWX8TlQUd596c1VTT2Zhggzc9Vr2/yulUh036asJ4lipaM9e+Pg2ZVRhKNSetxDIvR4KP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2018 08:07:31.8449 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc37df66-0bf6-42d3-53c2-08d563caafd3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR05MB3206 Subject: [dpdk-dev] [PATCH v7 1/3] net/failsafe: register as an Rx interrupt mode PMD 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: , X-List-Received-Date: Thu, 25 Jan 2018 08:07:34 -0000 This patch adds registering the Rx queues of the failsafe PMD with EAL Rx interrupts subsystem. Each failsafe RX queue is assigned with a unique eventfd and an enable interrupts flag. The PMD creates an interrupt vector containing the above eventfds and Registers it with EAL. The PMD also implements the Rx interrupts enable and disable interface routines. This patch does not implement the generation of Rx interrupts, so an application can now wait for failsafe Rx interrupts but it will not receive one. Signed-off-by: Moti Haimovsky --- V6: Fixed typo in commit subject. V5: Initial version of this patch in accordance to inputs from Gaetan Rivet in reply to 1516354344-13495-2-git-send-email-motih@mellanox.com --- doc/guides/nics/features/failsafe.ini | 1 + drivers/net/failsafe/Makefile | 1 + drivers/net/failsafe/failsafe.c | 4 + drivers/net/failsafe/failsafe_intr.c | 138 ++++++++++++++++++++++++++++++++ drivers/net/failsafe/failsafe_ops.c | 64 +++++++++++++++ drivers/net/failsafe/failsafe_private.h | 9 +++ 6 files changed, 217 insertions(+) create mode 100644 drivers/net/failsafe/failsafe_intr.c diff --git a/doc/guides/nics/features/failsafe.ini b/doc/guides/nics/features/failsafe.ini index a42e344..39ee579 100644 --- a/doc/guides/nics/features/failsafe.ini +++ b/doc/guides/nics/features/failsafe.ini @@ -6,6 +6,7 @@ [Features] Link status = Y Link status event = Y +Rx interrupt = Y MTU update = Y Jumbo frame = Y Promiscuous mode = Y diff --git a/drivers/net/failsafe/Makefile b/drivers/net/failsafe/Makefile index ea2a8fe..91a734b 100644 --- a/drivers/net/failsafe/Makefile +++ b/drivers/net/failsafe/Makefile @@ -46,6 +46,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_ops.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_ether.c SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_flow.c +SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_intr.c # No exported include files diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index cb274eb..921e656 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -244,6 +244,10 @@ mac->addr_bytes[2], mac->addr_bytes[3], mac->addr_bytes[4], mac->addr_bytes[5]); dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; + PRIV(dev)->intr_handle = (struct rte_intr_handle){ + .fd = -1, + .type = RTE_INTR_HANDLE_EXT, + }; return 0; free_args: failsafe_args_free(dev); diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c new file mode 100644 index 0000000..54ef2f4 --- /dev/null +++ b/drivers/net/failsafe/failsafe_intr.c @@ -0,0 +1,138 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 Mellanox Technologies, Ltd. + */ + +/** + * @file + * Interrupts handling for failsafe driver. + */ + +#include + +#include "failsafe_private.h" + +/** + * Uninstall failsafe interrupt vector. + * + * @param priv + * Pointer to failsafe private structure. + */ +static void +fs_rx_intr_vec_uninstall(struct fs_priv *priv) +{ + struct rte_intr_handle *intr_handle; + + intr_handle = &priv->intr_handle; + if (intr_handle->intr_vec != NULL) { + free(intr_handle->intr_vec); + intr_handle->intr_vec = NULL; + } + intr_handle->nb_efd = 0; +} + +/** + * Installs failsafe interrupt vector to be registered with EAL later on. + * + * @param priv + * Pointer to failsafe private structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +static int +fs_rx_intr_vec_install(struct fs_priv *priv) +{ + unsigned int i; + unsigned int rxqs_n; + unsigned int n; + unsigned int count; + struct rte_intr_handle *intr_handle; + + rxqs_n = priv->dev->data->nb_rx_queues; + n = RTE_MIN(rxqs_n, (uint32_t)RTE_MAX_RXTX_INTR_VEC_ID); + count = 0; + intr_handle = &priv->intr_handle; + /* Allocate the interrupt vector of the failsafe Rx proxy interrupts */ + intr_handle->intr_vec = malloc(n * sizeof(intr_handle->intr_vec[0])); + if (intr_handle->intr_vec == NULL) { + fs_rx_intr_vec_uninstall(priv); + rte_errno = ENOMEM; + ERROR("Failed to allocate memory for interrupt vector," + " Rx interrupts will not be supported"); + return -rte_errno; + } + for (i = 0; i < n; i++) { + struct rxq *rxq = priv->dev->data->rx_queues[i]; + + /* Skip queues that cannot request interrupts. */ + if (rxq == NULL || rxq->event_fd < 0) { + /* Use invalid intr_vec[] index to disable entry. */ + intr_handle->intr_vec[i] = + RTE_INTR_VEC_RXTX_OFFSET + + RTE_MAX_RXTX_INTR_VEC_ID; + continue; + } + if (count >= RTE_MAX_RXTX_INTR_VEC_ID) { + rte_errno = E2BIG; + ERROR("Too many Rx queues for interrupt vector size" + " (%d), Rx interrupts cannot be enabled", + RTE_MAX_RXTX_INTR_VEC_ID); + fs_rx_intr_vec_uninstall(priv); + return -rte_errno; + } + intr_handle->intr_vec[i] = RTE_INTR_VEC_RXTX_OFFSET + count; + intr_handle->efds[count] = rxq->event_fd; + count++; + } + if (count == 0) { + fs_rx_intr_vec_uninstall(priv); + } else { + intr_handle->nb_efd = count; + intr_handle->efd_counter_size = sizeof(uint64_t); + } + return 0; +} + + +/** + * Uninstall failsafe Rx interrupts subsystem. + * + * @param priv + * Pointer to private structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +void +failsafe_rx_intr_uninstall(struct rte_eth_dev *dev) +{ + struct fs_priv *priv; + + priv = PRIV(dev); + fs_rx_intr_vec_uninstall(priv); + dev->intr_handle = NULL; +} + +/** + * Install failsafe Rx interrupts subsystem. + * + * @param priv + * Pointer to private structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +int +failsafe_rx_intr_install(struct rte_eth_dev *dev) +{ + struct fs_priv *priv = PRIV(dev); + const struct rte_intr_conf *const intr_conf = + &priv->dev->data->dev_conf.intr_conf; + + if (intr_conf->rxq == 0 || priv->intr_handle.intr_vec != NULL) + return 0; + if (fs_rx_intr_vec_install(priv) < 0) + return -rte_errno; + dev->intr_handle = &priv->intr_handle; + return 0; +} diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 946ac98..d6a82b3 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -199,6 +200,10 @@ uint8_t i; int ret; + ret = failsafe_rx_intr_install(dev); + if (ret) + return ret; + FOREACH_SUBDEV(sdev, i, dev) { if (sdev->state != DEV_ACTIVE) continue; @@ -228,6 +233,7 @@ rte_eth_dev_stop(PORT_ID(sdev)); sdev->state = DEV_STARTED - 1; } + failsafe_rx_intr_uninstall(dev); } static int @@ -317,6 +323,8 @@ if (queue == NULL) return; rxq = queue; + if (rxq->event_fd > 0) + close(rxq->event_fd); dev = rxq->priv->dev; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) SUBOPS(sdev, rx_queue_release) @@ -333,6 +341,16 @@ const struct rte_eth_rxconf *rx_conf, struct rte_mempool *mb_pool) { + /* + * FIXME: Add a proper interface in rte_eal_interrupts for + * allocating eventfd as an interrupt vector. + * For the time being, fake as if we are using MSIX interrupts, + * this will cause rte_intr_efd_enable to allocate an eventfd for us. + */ + struct rte_intr_handle intr_handle = { + .type = RTE_INTR_HANDLE_VFIO_MSIX, + .efds = {-1, }, + }; struct sub_device *sdev; struct rxq *rxq; uint8_t i; @@ -370,6 +388,10 @@ rxq->info.nb_desc = nb_rx_desc; rxq->priv = PRIV(dev); rxq->sdev = PRIV(dev)->subs; + ret = rte_intr_efd_enable(&intr_handle, 1); + if (ret < 0) + return ret; + rxq->event_fd = intr_handle.efds[0]; dev->data->rx_queues[rx_queue_id] = rxq; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { ret = rte_eth_rx_queue_setup(PORT_ID(sdev), @@ -387,6 +409,46 @@ return ret; } +static int +fs_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx) +{ + struct rxq *rxq; + + if (idx >= dev->data->nb_rx_queues) { + rte_errno = EINVAL; + return -rte_errno; + } + rxq = dev->data->rx_queues[idx]; + if (rxq == NULL || rxq->event_fd <= 0) { + rte_errno = EINVAL; + return -rte_errno; + } + rxq->enable_events = 1; + return 0; +} + +static int +fs_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx) +{ + struct rxq *rxq; + uint64_t u64; + + if (idx >= dev->data->nb_rx_queues) { + rte_errno = EINVAL; + return -rte_errno; + } + rxq = dev->data->rx_queues[idx]; + if (rxq == NULL || rxq->event_fd <= 0) { + rte_errno = EINVAL; + return -rte_errno; + } + rxq->enable_events = 0; + /* Clear pending events */ + while (read(rxq->event_fd, &u64, sizeof(uint64_t)) > 0) + ; + return 0; +} + static bool fs_txq_offloads_valid(struct rte_eth_dev *dev, uint64_t offloads) { @@ -888,6 +950,8 @@ .tx_queue_setup = fs_tx_queue_setup, .rx_queue_release = fs_rx_queue_release, .tx_queue_release = fs_tx_queue_release, + .rx_queue_intr_enable = fs_rx_intr_enable, + .rx_queue_intr_disable = fs_rx_intr_disable, .flow_ctrl_get = fs_flow_ctrl_get, .flow_ctrl_set = fs_flow_ctrl_set, .mac_addr_remove = fs_mac_addr_remove, diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 7754248..419e5e7 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -40,6 +40,7 @@ #include #include #include +#include #define FAILSAFE_DRIVER_NAME "Fail-safe PMD" @@ -68,6 +69,8 @@ struct rxq { /* next sub_device to poll */ struct sub_device *sdev; unsigned int socket_id; + int event_fd; + unsigned int enable_events:1; struct rte_eth_rxq_info info; rte_atomic64_t refcnt[]; }; @@ -145,6 +148,7 @@ struct fs_priv { uint32_t mac_addr_pool[FAILSAFE_MAX_ETHADDR]; /* current capabilities */ struct rte_eth_dev_info infos; + struct rte_intr_handle intr_handle; /* Port interrupt handle. */ /* * Fail-safe state machine. * This level will be tracking state of the EAL and eth @@ -159,6 +163,11 @@ struct fs_priv { int flow_isolated:1; }; +/* FAILSAFE_INTR */ + +int failsafe_rx_intr_install(struct rte_eth_dev *dev); +void failsafe_rx_intr_uninstall(struct rte_eth_dev *dev); + /* MISC */ int failsafe_hotplug_alarm_install(struct rte_eth_dev *dev); -- 1.8.3.1