From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10047.outbound.protection.outlook.com [40.107.1.47]) by dpdk.org (Postfix) with ESMTP id 7AAF61B16F for ; Thu, 25 Jan 2018 09:07:36 +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=ttTqJ4fPUFdW53KJFO4EiuABB5f9Qo430jzCr5ZaN58=; b=nX3MuLpRAkxChVVY/rUIi66Z/EwttXoRiWhUhqqe+xI+Jccg0ccXU9JC8OHEz6abXt+tG9zEqO8bvo1TpFsvDXBZzaWGGrMR8bMMY5Thziju1XXuEg71NcCR2R0wcD6sonjmREYV/NhqRgHGsHGxNfdv9QTBWZ15aRu8ZnBz2IQ= 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:33 +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:14 +0200 Message-Id: <1516867635-67104-3-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: e0432cf1-c265-43b7-725e-08d563cab094 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:3Qygdj95k1zFuGg6Q9eGCMiQHPbG3vRU2w/QaTQQa8pSvkreeIA8X3uV55UGi48yyjS6oO1ww9eLutiLDI8Hp/yQovOU2Xvs34QD8PweG8PzeSRJh/VZT/ovNr2MEpkmExVtM6ZHEehwkUeCFT3Z+qDormw3yq39QYM4rSr08+HYMWq2sy2I1uNo/xC4O6pfp9wKw+YmgdY1j/GSqNO7gSJapCq9A1QaIiGilpCR7gAGyLETTmblRUCQcgy57Fr4; 25:E9p8KdHIa/eqdQPTzziFhPumc2w9YgXaNUoWwaEybX/YzBZ2UEKcdTXYgBGtCF3qC8+sELOFaSLtqzGXbU3nkKbUrW4CJ/yB5QTBI8LqH3yrlUNNJejQ9RTgL1erilYTIvF2s8DS6b1RL06gNV0sUt0V+AD3NvH1S0MPo9bI8fsTQ/fMvPUdmHGQAtcwW2fW9pWFdC1Ty3mVSekvVbeW1kb2/QHtHil+hhfAOYxO14iJiNRVsRuErYWnb5yMY+Nj46N+KNEbYzI3ZeScbiKiOffXVcC3pfEgKQVoV6vkmLbe0EF/APg0uf0LRXNDlwKzXooU4qGBA23kg18SH68DNQ==; 31:93BRBRJxe8cOZigdmweGz0oi5p3ifevXau/cYn3OaptLNZqQPS3B5ETyiawK74melSUmuBU4eORcXhrRjh7m0580cAjecBC5MaRtfb/BSk8mOHaFR+tDnXiWYB15z/qBhBqFjwdBdRRHBDKHpNcOdPMl1j6zYK5iDddGElAEeusA52+95qMQSRfUt5JnwjdsKVFJgO8Qi0bblna+828o2DVj5vrW0ZBEAbQN8+SvDRQ= X-MS-TrafficTypeDiagnostic: DB6PR05MB3206: X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 20:Wjtio6xWsKUAR4pZWVg/fc1OM5cnXZjaxmIjyMzaZxilG7gAt5sMD5J/BMkupfQKqEyrsq13NavhZXW834SsNp+s3ismfJWctJKlA/3YBcJ5c+/Vzm1VAjs1SzqOc+vqXjB42UppUA8P4cBLhIsqzlkLp0mNYiqnbkSpPTGwnYoRE5VBiXxSkh7LWOshiWeLkDuizs6xcv1lKBGakUg0FT1gh4ddUXawSlnqG4HF11vhJFw/Q2yTN/Ql/ZVyLJKsE31Ebw2nr69pLg9vMmuu1l3Mjw5PlB4gM774Wv+UfvyBbotXy6lV8KbXNIEkRCgR+3rgjhPoOcM+RFOtVlTvM4V3vkstl+zC1n/M+ZjQI3/8UMk6OYHTSB2PmPqSh4VX3+V0/3btFC9YP6RWXs9Hvo2k9OnZlvCXgepE7S9GKmdRQEcwGetNYsvVs6LN+9yUq6h+B9Fccz1vBe+BZ7s0h036BOn2QNgDJRDqYE+HMpe/GB1Nda3K7f9nZ8xXc5qQ; 4:NIPxD6GfavyoQAJlVdKGxLNroRd4SZDs9Yj2lwG0qKLHTZ0wvJW6L4BclB3Cuz/najjaobmiAJQfbhZ7AjdiWhUS4IpoGByvflGk4wW6xIlLmDDnkLs96gu3NvX/9ae2gBV/NEtVG2WkwuRAY7nTNrQhH/nqoAtjUL5auvGOBJdiBXWOuR3gdhUVNOqhLUzzUt15H9m7Q5kfiNPfrhub20NHOxXZ6Dy3vM+sri4V40WWlatvp+1F1oSaptbiGoJKAXdIe0Uv/Z4Z5smApa2CJA== 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)(575784001)(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:F5VrKEGJWDDGzZ683e+yTbPZ7xLP99LzrJWbCVh8I?= =?us-ascii?Q?MFiQIdTEKienAV3cGgoczGgKwfVZQbL/w/AU9WR/pgifTr5CCuZpUnovu9I2?= =?us-ascii?Q?90cgaASNuS9YvqvcVdynFATsQ+lEAroKA2SO3l2XXZ6RWntrMs0MnRX5H91c?= =?us-ascii?Q?2xnzHoWhT08DAmnP4UQi6sYZYf5rsMKmtf6NEFJmE6Ur5vdVxLwgl6qUrGAj?= =?us-ascii?Q?R4UsR85O14hlaj3OZJDf6IJsTjfqQbdwkzQt9p4jWHF4Ej5ZqL1In6P2/3Jw?= =?us-ascii?Q?pjH08m887wkkeqvwJTZoF38Xeqd97d3FuFWQWxwL0SmN3SUpX81VGg3uMEJC?= =?us-ascii?Q?Wx5I9XrgZdVFB6hM8ro4SoPEhu/2W/dfmfPMkcvG42iBeUdDyYBvsy86yKc1?= =?us-ascii?Q?m0qs2+pMJhy8Hmg/hNzyse5ZXYjY9X3wmoNHz+WC6/ha2W+Ro1k9u7cT8V5z?= =?us-ascii?Q?bi0Vj1iB9rE6CKnha5slwq+jdId41pWk3ADL4Wr0ljSLYQwdtLSYjnlR8hCa?= =?us-ascii?Q?DWiRINlmlVn6V7F1gfbJn8EH7gGbWzDq7KXbysBO0ls0YSIfag2s4RBqoGjo?= =?us-ascii?Q?xPNWHHFFZg8iru6todiOWVHeuJWEhRZbJVIDQxo/e/wSPuWGq8jrQHtRa7Uj?= =?us-ascii?Q?F30Pw2xnl1pH4hwrFCIwGbPgu7HmcXsnirdgZiYhyTMlnJZvSbxTTyuBPDVg?= =?us-ascii?Q?6Pt3orALjIEXejpBD3YMYBmDhCp+08yZ8LXhTO16tmHQcrjQZne4SV8oW5UG?= =?us-ascii?Q?S4PNFZ9qCMQZfpX7wYsm099gbIaxjZAnB79BjNspHAdVRYaaf3Xgyui5AvkP?= =?us-ascii?Q?gcvk4nljYqZsAJCN672LlC7NThUQ+aNINWiCs5l1G3dKV9Vgz/gHk2Xom5LV?= =?us-ascii?Q?UmIfO5mFG5cN8CwvoeABsOUwqA2OTO2w19t0Bv/kpqtb0A1oLfmuaCofx23m?= =?us-ascii?Q?sjbiymHdsgLOhBzskRWWdRudxdzhOsWNL9dDeFtJ/MrEnMKk4yxqoswfb+XN?= =?us-ascii?Q?fnsflvvgq6XDZGzwbEEbBLLeWO+0QskbhO9TIOpZP1LDJI45XnLFSiwaKSw+?= =?us-ascii?Q?x7hkIZrr5F/Mz8BGsiQgU2KbhO6QO8KcxS3/s3ezCBv/OGdRm1kN9UlNLsYv?= =?us-ascii?Q?qW6ajkbL53GN7WN8QMlZzTmrueiWE4r1sMOhB8xFiPkQukXzGQsFmPAD4GLR?= =?us-ascii?Q?NunjU5uFPmX6d9k95yITjOps6AxusI+3+EkdeGjNMTSR4N367aOflv96Q=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 6:5KNHmSlxNc/mqJ7UtRB02/VrLDsX5q/DcTn0AQHpnOiJ3mMnxn+tMQ1hcK7bvMjYzdw5zybfF1aM4aGjc4v+Hv4t8Uy7Bffsd492VmUWTrbcvN4FzDnU0CoV39cPTMqqVLTMSo6HnMYKXOkC/lh+Bchg1B5y2m6U3YOlCDyEg3nWiEcE9DcBhFuF7pYf1xQtm946TDyH9JEib5O/lyecrxXq9X5xfK2ryLt80uQ0txWBkpPSyGIHJUq5BFagJjz/dBg4LXTcH1kaj6U/wD9enCIu+yEdOVGPOmU9o3H7PXT0sJ7PnEouHVVwmS4lKyNicgl+uLie0DW4mUWTf2ZRN7OGHYOUA+bG1oMHB2Mq458=; 5:pP7KSvZBN3x1QOw1tMkqt4fpm5A+RsNGsaBFznFwntvjwMReObm87vT10Vy3gu2k2cBtqxOi6DJ5Y8y2ZINtkWQJHKDuyHDNP+Kp/vYaRrtf1PZlCaCDqqVrBNKqcQLEp1xaQgkpMq94ebs6cxeHgFjn9YAahEfDclC4yE1acgc=; 24:b6/Ng9sB0uu2mmdkuTzjTegXo9gf1AvJPn3U7BfRMVsMWnfZv5lA6jUeQ0/s8UYE7NNX7J/RByU0KSitturP97xH+bfB6o00KSEqVR8cMDo=; 7:gVO7yYw3WNZaRKzp0JDthkjiivcR4YzPR6+Q88gJ1aqtz01IOZOpQUhxXlCrr2xjUOpKPnyCtewhJQV1bJTeTmrvOzxH1HvMo5PQ8X/G3m4qDVzmbpYgy5/XjRy0HKv1UPeqETMfPu+3OxTMv02vo2wRag1W7CgBx6RM3RvlY4Jt3czxBG7uAHuIiP46n9KfwV9KpQ+0rzvXREKiS/uVwKLe7ERvykZepQgPuh0JQ+Uahf40LhcqbX5UccY5EQ9m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2018 08:07:33.1105 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0432cf1-c265-43b7-725e-08d563cab094 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 2/3] net/failsafe: slaves Rx interrupts registration 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:37 -0000 This commit adds the following functionality to failsafe PMD: * Register and unregister slaves Rx interrupts. * Enable and Disable slaves Rx interrupts. The interrupts events generated by the slaves are not handled in this commit. Signed-off-by: Moti Haimovsky --- V7: Fixed compilation errors in FreeBSD. See 1516810328-39383-3-git-send-email-motih@mellanox.com V6: Added a wrapper around epoll_create1 since it is not supported in FreeBSD. See: 1516193643-130838-1-git-send-email-motih@mellanox.com 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 --- drivers/net/failsafe/Makefile | 5 + drivers/net/failsafe/failsafe_epoll.h | 10 ++ drivers/net/failsafe/failsafe_epoll_bsdapp.c | 19 +++ drivers/net/failsafe/failsafe_epoll_linuxapp.c | 18 +++ drivers/net/failsafe/failsafe_ether.c | 1 + drivers/net/failsafe/failsafe_intr.c | 198 +++++++++++++++++++++++++ drivers/net/failsafe/failsafe_ops.c | 36 ++++- drivers/net/failsafe/failsafe_private.h | 16 ++ 8 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 drivers/net/failsafe/failsafe_epoll.h create mode 100644 drivers/net/failsafe/failsafe_epoll_bsdapp.c create mode 100644 drivers/net/failsafe/failsafe_epoll_linuxapp.c diff --git a/drivers/net/failsafe/Makefile b/drivers/net/failsafe/Makefile index 91a734b..4e6a983 100644 --- a/drivers/net/failsafe/Makefile +++ b/drivers/net/failsafe/Makefile @@ -47,6 +47,11 @@ 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 +ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y) +SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_epoll_linuxapp.c +else +SRCS-$(CONFIG_RTE_LIBRTE_PMD_FAILSAFE) += failsafe_epoll_bsdapp.c +endif # No exported include files diff --git a/drivers/net/failsafe/failsafe_epoll.h b/drivers/net/failsafe/failsafe_epoll.h new file mode 100644 index 0000000..8e6a1ec --- /dev/null +++ b/drivers/net/failsafe/failsafe_epoll.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 Mellanox Technologies, Ltd. + */ + +#ifndef _RTE_ETH_FAILSAFE_EPOLL_H_ +#define _RTE_ETH_FAILSAFE_EPOLL_H_ + +int failsafe_epoll_create1(int flags); + +#endif /* _RTE_ETH_FAILSAFE_EPOLL_H_*/ diff --git a/drivers/net/failsafe/failsafe_epoll_bsdapp.c b/drivers/net/failsafe/failsafe_epoll_bsdapp.c new file mode 100644 index 0000000..46c839b --- /dev/null +++ b/drivers/net/failsafe/failsafe_epoll_bsdapp.c @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 Mellanox Technologies, Ltd. + */ + +/** + * @file + * epoll wrapper for failsafe driver. + */ + +#include + +#include "failsafe_epoll.h" + +int +failsafe_epoll_create1(int flags) +{ + RTE_SET_USED(flags); + return -ENOTSUP; +} diff --git a/drivers/net/failsafe/failsafe_epoll_linuxapp.c b/drivers/net/failsafe/failsafe_epoll_linuxapp.c new file mode 100644 index 0000000..d82ee0a --- /dev/null +++ b/drivers/net/failsafe/failsafe_epoll_linuxapp.c @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 Mellanox Technologies, Ltd. + */ + +/** + * @file + * epoll wrapper for failsafe driver. + */ + +#include + +#include "failsafe_epoll.h" + +int +failsafe_epoll_create1(int flags) +{ + return epoll_create1(flags); +} diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 8a4cacf..0f1630e 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -283,6 +283,7 @@ return; switch (sdev->state) { case DEV_STARTED: + failsafe_rx_intr_uninstall_subdevice(sdev); rte_eth_dev_stop(PORT_ID(sdev)); sdev->state = DEV_ACTIVE; /* fallthrough */ diff --git a/drivers/net/failsafe/failsafe_intr.c b/drivers/net/failsafe/failsafe_intr.c index 54ef2f4..8f8f129 100644 --- a/drivers/net/failsafe/failsafe_intr.c +++ b/drivers/net/failsafe/failsafe_intr.c @@ -9,8 +9,198 @@ #include +#include "failsafe_epoll.h" #include "failsafe_private.h" +#define NUM_RX_PROXIES (FAILSAFE_MAX_ETHPORTS * RTE_MAX_RXTX_INTR_VEC_ID) + +/** + * Install failsafe Rx event proxy subsystem. + * This is the way the failsafe PMD generates Rx events on behalf of its + * subdevices. + * + * @param priv + * Pointer to failsafe private structure. + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +static int +fs_rx_event_proxy_install(struct fs_priv *priv) +{ + int rc = 0; + + /* + * Create the epoll fd and event vector for the proxy service to + * wait on for Rx events generated by the subdevices. + */ + priv->rxp.efd = failsafe_epoll_create1(0); + if (priv->rxp.efd < 0) { + rte_errno = errno; + ERROR("Failed to create epoll," + " Rx interrupts will not be supported"); + return -rte_errno; + } + priv->rxp.evec = calloc(NUM_RX_PROXIES, sizeof(*priv->rxp.evec)); + if (priv->rxp.evec == NULL) { + ERROR("Failed to allocate memory for event vectors," + " Rx interrupts will not be supported"); + rc = -ENOMEM; + goto error; + } + return 0; +error: + if (priv->rxp.efd >= 0) { + close(priv->rxp.efd); + priv->rxp.efd = -1; + } + if (priv->rxp.evec != NULL) { + free(priv->rxp.evec); + priv->rxp.evec = NULL; + } + rte_errno = -rc; + return rc; +} + +/** + * RX Interrupt control per subdevice. + * + * @param sdev + * Pointer to sub-device structure. + * @param op + * The operation be performed for the vector. + * Operation type of {RTE_INTR_EVENT_ADD, RTE_INTR_EVENT_DEL}. + * @return + * - On success, zero. + * - On failure, a negative value. + */ +static int +failsafe_eth_rx_intr_ctl_subdevice(struct sub_device *sdev, int op) +{ + struct rte_eth_dev *dev; + struct rte_eth_dev *fsdev; + int epfd; + uint16_t pid; + uint16_t qid; + struct rxq *fsrxq; + int rc; + int ret = 0; + + if (sdev == NULL || (ETH(sdev) == NULL) || + sdev->fs_dev == NULL || (PRIV(sdev->fs_dev) == NULL)) { + ERROR("Called with invalid arguments"); + return -EINVAL; + } + dev = ETH(sdev); + fsdev = sdev->fs_dev; + epfd = PRIV(sdev->fs_dev)->rxp.efd; + pid = PORT_ID(sdev); + + if (epfd <= 0) { + if (op == RTE_INTR_EVENT_ADD) { + ERROR("Proxy events are not initialized"); + return -EBADF; + } else { + return 0; + } + } + if (dev->data->nb_rx_queues > fsdev->data->nb_rx_queues) { + ERROR("subdevice has too many queues," + " Interrupts will not be enabled"); + return -E2BIG; + } + for (qid = 0; qid < dev->data->nb_rx_queues; qid++) { + fsrxq = fsdev->data->rx_queues[qid]; + rc = rte_eth_dev_rx_intr_ctl_q(pid, qid, epfd, + op, (void *)fsrxq); + if (rc) { + ERROR("rte_eth_dev_rx_intr_ctl_q failed for " + "port %d queue %d, epfd %d, error %d", + pid, qid, epfd, rc); + ret = rc; + } + } + return ret; +} + +/** + * Install Rx interrupts subsystem for a subdevice. + * This is a support for dynamically adding subdevices. + * + * @param sdev + * Pointer to subdevice structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +int failsafe_rx_intr_install_subdevice(struct sub_device *sdev) +{ + int rc; + int qid; + struct rte_eth_dev *fsdev; + struct rxq **rxq; + const struct rte_intr_conf *const intr_conf = + Ð(sdev)->data->dev_conf.intr_conf; + + fsdev = sdev->fs_dev; + rxq = (struct rxq **)fsdev->data->rx_queues; + if (intr_conf->rxq == 0) + return 0; + rc = failsafe_eth_rx_intr_ctl_subdevice(sdev, RTE_INTR_EVENT_ADD); + if (rc) + return rc; + /* enable interrupts on already-enabled queues */ + for (qid = 0; qid < ETH(sdev)->data->nb_rx_queues; qid++) { + if (rxq[qid]->enable_events) { + int ret = rte_eth_dev_rx_intr_enable(PORT_ID(sdev), + qid); + if (ret && (ret != -ENOTSUP)) { + ERROR("Failed to enable interrupts on " + "port %d queue %d", PORT_ID(sdev), qid); + rc = ret; + } + } + } + return rc; +} + +/** + * Uninstall Rx interrupts subsystem for a subdevice. + * This is a support for dynamically removing subdevices. + * + * @param sdev + * Pointer to subdevice structure. + * + * @return + * 0 on success, negative errno value otherwise and rte_errno is set. + */ +void failsafe_rx_intr_uninstall_subdevice(struct sub_device *sdev) +{ + int qid; + + for (qid = 0; qid < ETH(sdev)->data->nb_rx_queues; qid++) + rte_eth_dev_rx_intr_disable(PORT_ID(sdev), qid); + failsafe_eth_rx_intr_ctl_subdevice(sdev, RTE_INTR_EVENT_DEL); +} + +/** + * Uninstall failsafe Rx event proxy. + * + * @param priv + * Pointer to failsafe private structure. + */ +static void +fs_rx_event_proxy_uninstall(struct fs_priv *priv) +{ + if (priv->rxp.evec != NULL) { + free(priv->rxp.evec); + priv->rxp.evec = NULL; + } + if (priv->rxp.efd > 0) { + close(priv->rxp.efd); + priv->rxp.efd = -1; + } +} + /** * Uninstall failsafe interrupt vector. * @@ -107,8 +297,12 @@ failsafe_rx_intr_uninstall(struct rte_eth_dev *dev) { struct fs_priv *priv; + struct rte_intr_handle *intr_handle; priv = PRIV(dev); + intr_handle = &priv->intr_handle; + rte_intr_free_epoll_fd(intr_handle); + fs_rx_event_proxy_uninstall(priv); fs_rx_intr_vec_uninstall(priv); dev->intr_handle = NULL; } @@ -133,6 +327,10 @@ return 0; if (fs_rx_intr_vec_install(priv) < 0) return -rte_errno; + if (fs_rx_event_proxy_install(priv) < 0) { + fs_rx_intr_vec_uninstall(priv); + 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 d6a82b3..2ea9cdd 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -214,6 +214,13 @@ continue; return ret; } + ret = failsafe_rx_intr_install_subdevice(sdev); + if (ret) { + if (!fs_err(sdev, ret)) + continue; + rte_eth_dev_stop(PORT_ID(sdev)); + return ret; + } sdev->state = DEV_STARTED; } if (PRIV(dev)->state < DEV_STARTED) @@ -231,6 +238,7 @@ PRIV(dev)->state = DEV_STARTED - 1; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_STARTED) { rte_eth_dev_stop(PORT_ID(sdev)); + failsafe_rx_intr_uninstall_subdevice(sdev); sdev->state = DEV_STARTED - 1; } failsafe_rx_intr_uninstall(dev); @@ -413,6 +421,10 @@ fs_rx_intr_enable(struct rte_eth_dev *dev, uint16_t idx) { struct rxq *rxq; + struct sub_device *sdev; + uint8_t i; + int ret; + int rc = 0; if (idx >= dev->data->nb_rx_queues) { rte_errno = EINVAL; @@ -424,14 +436,26 @@ return -rte_errno; } rxq->enable_events = 1; - return 0; + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_dev_rx_intr_enable(PORT_ID(sdev), idx); + ret = fs_err(sdev, ret); + if (ret) + rc = ret; + } + if (rc) + rte_errno = -rc; + return rc; } static int fs_rx_intr_disable(struct rte_eth_dev *dev, uint16_t idx) { struct rxq *rxq; + struct sub_device *sdev; uint64_t u64; + uint8_t i; + int rc = 0; + int ret; if (idx >= dev->data->nb_rx_queues) { rte_errno = EINVAL; @@ -443,10 +467,18 @@ return -rte_errno; } rxq->enable_events = 0; + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { + ret = rte_eth_dev_rx_intr_disable(PORT_ID(sdev), idx); + ret = fs_err(sdev, ret); + if (ret) + rc = ret; + } /* Clear pending events */ while (read(rxq->event_fd, &u64, sizeof(uint64_t)) > 0) ; - return 0; + if (rc) + rte_errno = -rc; + return rc; } static bool diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 419e5e7..ff78b9f 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -63,6 +63,13 @@ /* TYPES */ +struct rx_proxy { + /* epoll file descriptor */ + int efd; + /* event vector to be used by epoll */ + struct rte_epoll_event *evec; +}; + struct rxq { struct fs_priv *priv; uint16_t qid; @@ -158,6 +165,13 @@ struct fs_priv { */ enum dev_state state; struct rte_eth_stats stats_accumulator; + /* + * Rx interrupts/events proxy. + * The PMD issues Rx events to the EAL on behalf of its subdevices, + * it does that by registering an event-fd for each of its queues with + * the EAL. + */ + struct rx_proxy rxp; unsigned int pending_alarm:1; /* An alarm is pending */ /* flow isolation state */ int flow_isolated:1; @@ -167,6 +181,8 @@ struct fs_priv { int failsafe_rx_intr_install(struct rte_eth_dev *dev); void failsafe_rx_intr_uninstall(struct rte_eth_dev *dev); +int failsafe_rx_intr_install_subdevice(struct sub_device *sdev); +void failsafe_rx_intr_uninstall_subdevice(struct sub_device *sdev); /* MISC */ -- 1.8.3.1