From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10123.outbound.protection.outlook.com [40.107.1.123]) by dpdk.org (Postfix) with ESMTP id 805F81F28 for ; Wed, 20 Feb 2019 22:05:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b0ZdAfxrWPsFTxerJtSyw0AjLqE2wCsSJPl2ta5HMgM=; b=N7sgAO57tLnTHIberi+Yf3LBQo4ZovTLMwd9aNq/lRAwi9j68UZ9us/iwZ88r7veYAw7pg/J28A4whm+mlNPSrCPQBE3nz2eSVMFGoDv1xL7sudds3TyTcZTABebQmaYTEvrufizMnrZsMq3+m7ln7h0f9zPnoZXierGXTOUP5E= Received: from VI1PR0701CA0043.eurprd07.prod.outlook.com (2603:10a6:800:90::29) by DB6PR07MB3303.eurprd07.prod.outlook.com (2603:10a6:6:21::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.11; Wed, 20 Feb 2019 21:05:34 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::203) by VI1PR0701CA0043.outlook.office365.com (2603:10a6:800:90::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.10 via Frontend Transport; Wed, 20 Feb 2019 21:05:34 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.240 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.240; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.240) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.11 via Frontend Transport; Wed, 20 Feb 2019 21:05:34 +0000 Received: from lfs-up-04.localdomain ([10.157.84.234]) by fihe3nok0734.emea.nsn-net.net (GMO) with ESMTP id x1KL5XNF019123; Wed, 20 Feb 2019 21:05:33 GMT Received: by lfs-up-04.localdomain (Postfix, from userid 62146483) id F0D569FCD; Wed, 20 Feb 2019 23:05:32 +0200 (EET) From: Julien Meunier To: , , Wenzhuo Lu , Konstantin Ananyev CC: Date: Wed, 20 Feb 2019 23:05:29 +0200 Message-ID: <20190220210531.48322-1-julien.meunier@nokia.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20190102160055.30301-1-julien.meunier@nokia.com> References: <20190102160055.30301-1-julien.meunier@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.240; IPV:CAL; SCL:-1; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(136003)(396003)(2980300002)(3190300001)(189003)(199004)(8936002)(81166006)(76176011)(51416003)(81156014)(16586007)(8676002)(106002)(6666004)(36756003)(106466001)(42186006)(356004)(26826003)(53936002)(1076003)(6266002)(26005)(186003)(4326008)(478600001)(6346003)(44832011)(50466002)(316002)(48376002)(476003)(336012)(110136005)(486006)(2616005)(126002)(446003)(11346002)(2906002)(5660300002)(97736004)(305945005)(50226002)(103686004)(68736007)(52956003)(86362001)(47776003)(14444005); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR07MB3303; H:fihe3nok0734.emea.nsn-net.net; FPR:; SPF:Pass; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a61dcf3d-fceb-44d2-9991-08d6977727c1 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4608103)(4709054)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328); SRVR:DB6PR07MB3303; X-MS-TrafficTypeDiagnostic: DB6PR07MB3303: X-Microsoft-Exchange-Diagnostics: 1; DB6PR07MB3303; 20:yLo+Ri3FurtQ0JqIzcQyDlO/c2u30OW/J1gW01TkXRzqNgOWG/Q+a9bPg0/xTKQDHn25UL23CinNjQu1pJWzZptivPsQBnhRLBy1k5cNVIsZe6+KQnUeXtc4rGWEpEcTH1zBsYRpaXQlamjyjQqkM7oecx0s5da56dTN5F8PHtXkTUZOrlSHBjRmdvd97MxZkUvPPWmdeMmFW6VsyTwvp6wNgyG77wAn7XH3EZ+QT0MXyx1KrffHbaKM4e7oboUVW7r3RtKz6iz1CnXMXRCyOrD2XiNGbkm6DAoKdx7RkInoCd8fh+XT6gE7CAVlhcCGPZOGKu53mY8pYProwuB/a8I7fHsVjd+Yb/33RtdncDO53Wd+X7FYiyIHkG2uczqXz0hywyuJsL8QtOZ/iPs2DyE63HIFdagW6oYwOfTOhY4nT0QzzM9vt1WLizsol5TZ7z3a8GrbJjNHRvEabwGhTrdxFcmlxx5DSx71VirGAvlcE37p7qsvbNzaO7kihLVfimCJfi4fn6nI9ASkPDQgVeCBiX8/s9rJTVciywLhXgRsyOd18RYbYqHbLcMy6AHQazi3MhVe2OpNd5SVcMvkmWyeb0YmSnJBgODjBuhR5wk= X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0954EE4910 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR07MB3303; 23:HeCpuRE7dk3ZfBCJgc4b+HJN3K9Q29mH5vyq7V8ZX?= =?us-ascii?Q?NYHpiv/oA16en55wGENyA1ZvdlohJGkJ0wGYo8H2ZmXIS690schc/cwUlRuf?= =?us-ascii?Q?oF4X6tdtVo4BnubUvymWrd0xUERV196eHt9Tx1gr5Nu5gbTszbxxiBquQCTg?= =?us-ascii?Q?PJfqLhG+Db61zGLbcshK6K5GD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q?IH37Jcd8Zg99DaamejhlRUJrGpW3M1XqHrQBPG7KIiAW8u3xMsuvIdjxKes/?= =?us-ascii?Q?DDZt5oK+LR6TAVcI0CsTqQjWgk0V+LHZDip3U77EKwJF7Hv60PfCAC01ohhe?= =?us-ascii?Q?juWwt7k3K3ztYcLxgcgBWZMz/6+oKmG+bZ6?= X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: C+EfVH5DeEEStPMJRn30Q4DRjCTIijAuruSeP10psaa6kRAf0rnOd0OWnl4MHeytXk8CWMrbISnrtBZAkADNTnWuOdvuAIdPo+myUxF/C5j4cW1h0pR5GBjsMD9l+JQNAX+lWekGaDcMg7P3UxvnSktHrhmWtoUdN6m+hncOvGhcpCecOtTFxstzYJoQXdIXGPM0vBlrGpz6QOxDpFitvWbWcvSGNqxsmzJoCAqJaTydLc733a++58xgYme0D7Doy077gww/ejHDCh7447Ag0z9VagH9WREV3prBIBt2qlyCK4RsoE4Ol1K7SkCFwPtWNjz3OnWu4C6LSyZaxFiNhAg6ismxPLRxvYCuac9FHOeCC8yqH8wf6S0I8Cn5dqAFtXCXx3l50hjwCgMuCObwjOKD8rj7Tl1CYuoMDxq8WRQ= X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Feb 2019 21:05:34.1583 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a61dcf3d-fceb-44d2-9991-08d6977727c1 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.240]; Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR07MB3303 Subject: [dpdk-dev] [PATCH v3 1/2] net/ixgbe: do not start on unsupported loopback mode 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: Wed, 20 Feb 2019 21:05:36 -0000 Only TX->RX loopback is supported currently on 82599EB. If a user wants to apply an another loopback configuration (!= IXGBE_LPBK_82599_TX_RX), ixgbe PMD ignores it and continues the configuration without raising any error. Let's robustify this part by checking if the requested loopback mode is correct for the current device, before starting it. If it is not valid, PMD will refuse to start. Signed-off-by: Julien Meunier --- v3: - code style + checkpatch compliance v2: - factorize code - check if loopback is really supported --- drivers/net/ixgbe/ixgbe_ethdev.c | 14 ++++++++++---- drivers/net/ixgbe/ixgbe_rxtx.c | 37 +++++++++++++++++++++++++++++-------- drivers/net/ixgbe/ixgbe_rxtx.h | 1 + 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 7493110..4deedb0 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2652,10 +2652,16 @@ ixgbe_dev_start(struct rte_eth_dev *dev) goto error; } - /* Skip link setup if loopback mode is enabled for 82599. */ - if (hw->mac.type == ixgbe_mac_82599EB && - dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX) - goto skip_link_setup; + /* Skip link setup if loopback mode is enabled. */ + if (dev->data->dev_conf.lpbk_mode != 0) { + err = ixgbe_check_supported_loopback_mode(dev); + if (err < 0) { + PMD_INIT_LOG(ERR, "Unsupported loopback mode"); + goto error; + } else { + goto skip_link_setup; + } + } if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) { err = hw->mac.ops.setup_sfp(hw); diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index 9a79d18..c9a70a8 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -4879,13 +4879,18 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev) hlreg0 &= ~IXGBE_HLREG0_JUMBOEN; /* - * If loopback mode is configured for 82599, set LPBK bit. + * If loopback mode is configured, set LPBK bit. */ - if (hw->mac.type == ixgbe_mac_82599EB && - dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX) + if (dev->data->dev_conf.lpbk_mode != 0) { + rc = ixgbe_check_supported_loopback_mode(dev); + if (rc < 0) { + PMD_INIT_LOG(ERR, "Unsupported loopback mode"); + return rc; + } hlreg0 |= IXGBE_HLREG0_LPBK; - else + } else { hlreg0 &= ~IXGBE_HLREG0_LPBK; + } IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); @@ -5062,6 +5067,21 @@ ixgbe_dev_tx_init(struct rte_eth_dev *dev) } /* + * Check if requested loopback mode is supported + */ +int +ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev) +{ + struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); + + if (dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX) + if (hw->mac.type == ixgbe_mac_82599EB) + return 0; + + return -ENOTSUP; +} + +/* * Set up link for 82599 loopback mode Tx->Rx. */ static inline void __attribute__((cold)) @@ -5148,10 +5168,11 @@ ixgbe_dev_rxtx_start(struct rte_eth_dev *dev) rxctrl |= IXGBE_RXCTRL_RXEN; hw->mac.ops.enable_rx_dma(hw, rxctrl); - /* If loopback mode is enabled for 82599, set up the link accordingly */ - if (hw->mac.type == ixgbe_mac_82599EB && - dev->data->dev_conf.lpbk_mode == IXGBE_LPBK_82599_TX_RX) - ixgbe_setup_loopback_link_82599(hw); + /* If loopback mode is enabled, set up the link accordingly */ + if (dev->data->dev_conf.lpbk_mode != 0) { + if (hw->mac.type == ixgbe_mac_82599EB) + ixgbe_setup_loopback_link_82599(hw); + } #ifdef RTE_LIBRTE_SECURITY if ((dev->data->dev_conf.rxmode.offloads & diff --git a/drivers/net/ixgbe/ixgbe_rxtx.h b/drivers/net/ixgbe/ixgbe_rxtx.h index 39378f7..505d344 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.h +++ b/drivers/net/ixgbe/ixgbe_rxtx.h @@ -276,6 +276,7 @@ void ixgbe_set_tx_function(struct rte_eth_dev *dev, struct ixgbe_tx_queue *txq); */ void ixgbe_set_rx_function(struct rte_eth_dev *dev); +int ixgbe_check_supported_loopback_mode(struct rte_eth_dev *dev); uint16_t ixgbe_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts); uint16_t ixgbe_recv_scattered_pkts_vec(void *rx_queue, -- 2.10.2