From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0080.outbound.protection.outlook.com [104.47.33.80]) by dpdk.org (Postfix) with ESMTP id AB613FA84 for ; Fri, 3 Mar 2017 08:14:55 +0100 (CET) Received: from BLUPR0301CA0017.namprd03.prod.outlook.com (10.162.113.155) by CY1PR0301MB0730.namprd03.prod.outlook.com (10.160.159.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Fri, 3 Mar 2017 07:14:54 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::148) by BLUPR0301CA0017.outlook.office365.com (2a01:111:e400:5259::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12 via Frontend Transport; Fri, 3 Mar 2017 07:14:53 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; caviumnetworks.com; dkim=none (message not signed) header.d=none; caviumnetworks.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Fri, 3 Mar 2017 07:14:53 +0000 Received: from bf-netperf1.idc ([10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v237D50c005035; Fri, 3 Mar 2017 00:14:50 -0700 From: Hemant Agrawal To: CC: , , , , , Date: Fri, 3 Mar 2017 18:16:52 +0530 Message-ID: <1488545223-25739-36-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1488545223-25739-1-git-send-email-hemant.agrawal@nxp.com> References: <1487205586-6785-1-git-send-email-hemant.agrawal@nxp.com> <1488545223-25739-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131329988937978509; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(336005)(39840400002)(39850400002)(39860400002)(39380400002)(39400400002)(39410400002)(39450400003)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(626004)(104016004)(105606002)(4326008)(50466002)(48376002)(5003940100001)(110136004)(85426001)(2351001)(86362001)(38730400002)(54906002)(53936002)(81166006)(92566002)(106466001)(8676002)(15650500001)(33646002)(305945005)(50986999)(189998001)(8656002)(36756003)(6916009)(2950100002)(2906002)(76176999)(77096006)(356003)(50226002)(47776003)(8936002)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0730; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:DqAQ3f3iR8F5l04L7VeO/qj8NTDt9DlDL974kcc4Qny7COqYSJ72T9PB/nOE0rGo7kH3R5GaNaDDscDHGek9EZDpoOEmhLN6qWZv6pfYvzoegC2A0uJ8NnHlAywNekHa2nbSEg7ZjnvvdSVPLLGBfyVy8khsJbZHNOGZP3/oOnsGT3ou/nMy2iWEP+r9TnjmPzm1avEiut36tcdWyNDqVojbxg1gNGQjdPXELLZK5Uls8TEtlGxlI5G7ZxzkmiEWtyMUawTeA8kGC431DbhuMfJ9oI+X41evJSvyQ3cmJdIvsCvBZ0xK4bZP6B7/x2xpPV8GUkT6/3cnA9o7s7SmxiF/YuHB8TAB7FrZZ0KAbZhYVPthUnRCHwc/m6SCaHN+miqPpMTfksOeLB92s2Tv0Ah6ozdY5ZK+nD8PZ5JW5y1dwDZcQP2rYUxr2FB3d7AzpxAmrjthsFi3sPx/BYl0w9bD4QrI7Xj2kjdRYD1laM07Vn1p4b2kni2K68MTFnN74BA+e/JnntZiT9GxmvL8IVqQtILlSmzPT8rddiJyIhfv9iWQCgGbyYVZPGSGoVtX7AXn12A1Z0iY6yYHwFxyD+odv6IqFpQJebcCs5yd1aYD8mMm/91WNsuVxBwnmkCu2BVUqM+5Ddr4rrur1ldGmg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 6d811e17-64a4-4b40-b13e-08d46204fd75 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY1PR0301MB0730; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0730; 3:Jn05JkJu9E7QklVLbMveNEL9A9jMzwMbMRUZsbTfFLeI96opJ12USQnpDrb8DChF1/zW08kAXO2PysWwpiLfjhI+tpuZewOxIMVXmJ0uQ9j2sRJkV08VUgAkai2KmRuF5MYpN5Jv6a8S88vnoJnLkyUzWKMyU1LIQibKy/FE3yux+7dwCd6tFx0mfFvDUV0hGNgtJxxd2G/JPlk6uEy9EPhxR2j/cr5u+0le7BpdIaJx6xP5jRxPts070U9OKdH677+dYKhA8ul1XrO3GD4TfCvNS0uUtKzrT+VYNz+t1pzut20GwDT2LZA7T+XAp5X0u0dgAtWlMAV0iY3Vuvi87ecW4LlhhyvsBEBT26zY7fWNs0K1GESXjNgM/dQgLjRG; 25:DKYoNHfRnCa1nUA5l/jIc0Y3uDA8MlRkzMYOWfyPpsv/ZF8MxanYpG3WiL/B9cCKPDYlpwoAFTLAC0QP7JdplcIR/9tSsatqNVJ0+kfcYXLCmjKMeEwVc9EiwnVaqUAqkuNG4oxHJkMYF5NkoTZtnhNDO+R0dFThTSykjOkZBBPaYJGReYoUQC2sadoubj/pTI3taR+4998rcWgXngxs1fPgMR2WzYAxuZVGZ//0fti4HPwbYCgOPKFeDwPEsVAgg6WL6yxWPRZqqfqxJ7HVcZXMimZwAJ/eKHl8LE1HGJ6D441Ter3RnVUh16xNAqL3W2QmGoflf7nFoeDyKBuQoFFQzyz4aklIeWi7At5+7HY5yLMd1+FS5vggTabXQ8ZeO8pGhCZrnvHetBxvWrhBqqIHU//s8J0tEjvyCCSsJFkse8BknqacDQyLd+YLDxPJpXFwaFEZgjY9K/oalfsuOA== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0730; 31:w6bPQhrU2s9vv+k+q9/G5oK3r+9kVKrmx8WpXrNtHSmknJP1CrkQbt7jTyMJ6rBTzCjTeyLKYQnLoJyO+G0GpE1qkV8xeuJHmXccTWNvHtl9K5n6AOjnZtCboXCCoOat01MmBhJ95r9q5asoEHZMonUG+KaEVt3uop5udPZpSN4t2Cvf7UNFPyjaf+6IDr2BEhJ/JGaza0jnxf02OcJtNZ/vew7PY20BwbnnrIm0p0pznnXH/vjVT3ahk8kuh9FBWcjbDaEX63duUe5e9xynOw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13015025)(13017025)(13024025)(13018025)(13023025)(10201501046)(3002001)(6055026)(6096035)(20161123559025)(20161123565025)(20161123561025)(20161123556025)(20161123563025); SRVR:CY1PR0301MB0730; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0730; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0730; 4:MFHwGUAUVrikXEcqYb0AZN8pJa2QzcaLCqevoEyrMOxGZOq+SH0CZKBgymq8tU+AmvxlvmnhpdEBdkT46VJDMkoA71WUnYXNZh2nQDR+IshbAWXA+yF090+vRoEPcOExiyBC+cWq2tq6rHazAs0UwiW033hPZ1J3T28QQoMSx7IMGgjmn/Z8RZ7KBtdMWdKaHn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yPzI2ldPyk?= =?us-ascii?Q?7RWnvL2og63wiWmElnsIXNB1HF5/svzJZanuyXie/?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0730; 6:TWc4/tyFWGGT8kMVjoYcEA/F5Yo9LtSfMz/v9PefFe5gR6fiioOeIOlber8K6qIclq8oruVAt30Eo6hJb5FSVrU4TCjSb5+1Rx3RnJDGU8bd04+WgeQMJ1EhQ3dDDaq8815IsNS4QKt/jZoFJJmG8/bCU2zPrHOLwGzlNPQX1Mf8fjtKLlO/u/J2SNfyzNFnr265V46Vk4unh2QQ8ETki+BPqADt2HSKj+Kh12pRDPYBa0k3qIR6XUhxYVyUGmT/pQA3jMkL0k51bTSdTAMtqC0TwwZxeDhCuE7sqelmQ/8gtlVH8I6rfPyVyk9EiFONeQlfO1hhN9zxZLolnByNn7nwzxzuEZe8Roc93RfMT2nl8cWvt7qC9uROqU5TE2vv3Zo3B4YiaxJze1++E2eKi1IK2a53Il8N/I6X+JySGjM=; 5:FHywj5Y8MMq0rswOh7UAVTM+sy0U6Bw7N1Ma0zSk96NdXazGJukwcoP9GvdXV6pjo9QMohKin7IXKCzR40lpq+p+uuLn7Roey2EY0SoBHQBSV6u99mIWnYfyEUaK26mTcxGBN2ibg51zx4WS/xpjXWbLZC5BF80MbW5ftg3/4jx3QeZS9aXvwECWkc4QXtDB; 24:jti4jpcA2NdFktszdERhTsDE3Y7pCo5zZx2ICIa6kctokc47SUJrAJkz46tSoFz3wSvJ09LNdwSrkwhHawplX1cfp+Oxq6okh1QybGb4Abs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0730; 7:mNB/LQVZRA2lCJpDelJfXm0x7pIKCMk3zd2AIcpP4UKMW3eryDeMb74TC851Ze7DsYyg676tXxAVOq1eNZwojDszymm03rhzw8PauqaWQpRCgomNQgIFCF5igu4bV7baoVgiZ48xD2uzQmhGZ8jGaXuFggfdw1fZFBbKuOmSndTMXOUQwt9jsZ/GfaVG42LFMThu6QRlPHu4wi3+eUaJZBsEahYwbJ1Ii/kAMjnwD+BVPH7C9u/7+cUsfhehFVmsRz4NZZFA3PwUgIIjt/35XiF5p5guxBvt7nicO0GfTNCKcgF1bb8fDVv1wKO8hoRXbuoMPq33WmDSx093hKhDlA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 07:14:53.6106 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0730 Subject: [dpdk-dev] [PATCHv8 35/46] net/dpaa2: link status update 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: Fri, 03 Mar 2017 07:14:56 -0000 Signed-off-by: Hemant Agrawal --- doc/guides/nics/features/dpaa2.ini | 1 + drivers/net/dpaa2/dpaa2_ethdev.c | 107 +++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/doc/guides/nics/features/dpaa2.ini b/doc/guides/nics/features/dpaa2.ini index 0746d4b..0660cab 100644 --- a/doc/guides/nics/features/dpaa2.ini +++ b/doc/guides/nics/features/dpaa2.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +Link status = Y Queue start/stop = Y MTU update = Y Promiscuous mode = Y diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c index c4131e1..14b9654 100644 --- a/drivers/net/dpaa2/dpaa2_ethdev.c +++ b/drivers/net/dpaa2/dpaa2_ethdev.c @@ -54,6 +54,58 @@ static struct rte_dpaa2_driver rte_dpaa2_pmd; +/** + * Atomically reads the link status information from global + * structure rte_eth_dev. + * + * @param dev + * - Pointer to the structure rte_eth_dev to read from. + * - Pointer to the buffer to be saved with the link status. + * + * @return + * - On success, zero. + * - On failure, negative value. + */ +static inline int +dpaa2_dev_atomic_read_link_status(struct rte_eth_dev *dev, + struct rte_eth_link *link) +{ + struct rte_eth_link *dst = link; + struct rte_eth_link *src = &dev->data->dev_link; + + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) == 0) + return -1; + + return 0; +} + +/** + * Atomically writes the link status information into global + * structure rte_eth_dev. + * + * @param dev + * - Pointer to the structure rte_eth_dev to read from. + * - Pointer to the buffer to be saved with the link status. + * + * @return + * - On success, zero. + * - On failure, negative value. + */ +static inline int +dpaa2_dev_atomic_write_link_status(struct rte_eth_dev *dev, + struct rte_eth_link *link) +{ + struct rte_eth_link *dst = &dev->data->dev_link; + struct rte_eth_link *src = link; + + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst, + *(uint64_t *)src) == 0) + return -1; + + return 0; +} + static void dpaa2_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) { @@ -430,6 +482,7 @@ struct dpaa2_dev_priv *priv = dev->data->dev_private; struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; int ret; + struct rte_eth_link link; PMD_INIT_FUNC_TRACE(); @@ -439,6 +492,10 @@ ret, priv->hw_id); return; } + + /* clear the recorded link status */ + memset(&link, 0, sizeof(link)); + dpaa2_dev_atomic_write_link_status(dev, &link); } static void @@ -531,6 +588,55 @@ return 0; } +/* return 0 means link status changed, -1 means not changed */ +static int +dpaa2_dev_link_update(struct rte_eth_dev *dev, + int wait_to_complete __rte_unused) +{ + int ret; + struct dpaa2_dev_priv *priv = dev->data->dev_private; + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw; + struct rte_eth_link link, old; + struct dpni_link_state state = {0}; + + PMD_INIT_FUNC_TRACE(); + + if (dpni == NULL) { + RTE_LOG(ERR, PMD, "error : dpni is NULL"); + return 0; + } + memset(&old, 0, sizeof(old)); + dpaa2_dev_atomic_read_link_status(dev, &old); + + ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state); + if (ret < 0) { + RTE_LOG(ERR, PMD, "error: dpni_get_link_state %d", ret); + return -1; + } + + if ((old.link_status == state.up) && (old.link_speed == state.rate)) { + RTE_LOG(DEBUG, PMD, "No change in status\n"); + return -1; + } + + memset(&link, 0, sizeof(struct rte_eth_link)); + link.link_status = state.up; + link.link_speed = state.rate; + + if (state.options & DPNI_LINK_OPT_HALF_DUPLEX) + link.link_duplex = ETH_LINK_HALF_DUPLEX; + else + link.link_duplex = ETH_LINK_FULL_DUPLEX; + + dpaa2_dev_atomic_write_link_status(dev, &link); + + if (link.link_status) + PMD_DRV_LOG(INFO, "Port %d Link is Up\n", dev->data->port_id); + else + PMD_DRV_LOG(INFO, "Port %d Link is Down\n", dev->data->port_id); + return 0; +} + static struct eth_dev_ops dpaa2_ethdev_ops = { .dev_configure = dpaa2_eth_dev_configure, .dev_start = dpaa2_dev_start, @@ -538,6 +644,7 @@ .dev_close = dpaa2_dev_close, .promiscuous_enable = dpaa2_dev_promiscuous_enable, .promiscuous_disable = dpaa2_dev_promiscuous_disable, + .link_update = dpaa2_dev_link_update, .dev_infos_get = dpaa2_dev_info_get, .dev_supported_ptypes_get = dpaa2_supported_ptypes_get, .mtu_set = dpaa2_dev_mtu_set, -- 1.9.1