From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0085.outbound.protection.outlook.com [104.47.36.85]) by dpdk.org (Postfix) with ESMTP id C0526FAB5 for ; Tue, 21 Feb 2017 10:29:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AyczxuqIdB1zoHF9Ld9sgJXVkShysTIw61YUZniqvhk=; b=Z2A3dhX/DcGPqfr9xxtFZKHtRyxFeXhXzXXjtnWdSAMDhP1eDcdnEYVlmsXgp9nZGI0h31x/5NLIlB655DiBaR7VZ7jAkuNwFZCRYtY+ivLYlu7yICWVByifwYBUsVeK9hXbIw05l0OMoswN4tvdArHENmLssd9LZ+kXsZYsRIE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Shijith.Thotton@cavium.com; Received: from lio357.in.caveonetworks.com (14.140.2.178) by SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Tue, 21 Feb 2017 09:29:54 +0000 From: Shijith Thotton To: dev@dpdk.org Cc: Jerin Jacob , Derek Chickles , Venkat Koppula , Mallesham Jatharakonda Date: Tue, 21 Feb 2017 14:56:50 +0530 Message-Id: <1487669225-30091-36-git-send-email-shijith.thotton@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> References: <1487669225-30091-1-git-send-email-shijith.thotton@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: MA1PR01CA0089.INDPRD01.PROD.OUTLOOK.COM (10.174.56.29) To SN1PR07MB2285.namprd07.prod.outlook.com (10.164.47.155) X-MS-Office365-Filtering-Correlation-Id: bdf24d21-5f38-497e-6d08-08d45a3c32e7 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 3:cUCwPK9wgxxys0Ownl7YOszudAIoQDOCZTZ9hakzQZnBo0VVn7jzvedVoforuFY5jKgBSLkqzWp/Py0/wAHvXO7bq42DS5qD/oiICU6N2u7T0sh1nPODVxBSF8T0IA7txoDDiF/xpZDXnvNJjtWWaiXuLbgnGMPlyAWnqC8UQEycQyu+zbtTE+kD9W4HTFkvNi022TwxPzcpmnuUt1/LSHHNu93dg63ycVT3SoQMJcikseIzu8IS42hrOHlN8Mbosy0QKPyy1v5j82J4i5x8hw==; 25:JmqYeQf8tqE7DfFGPwHTmIf+hKqj9kXBRkjUYFr6Cws24ZZPHYU8bgsykzEKG4aYA2zu4gY3uWAF/TNBv+fDyOkuGg5Vk4ZCOeorByVFRPZFbgYPbp86OlOPIHmMW/M6cHu5hSDqOUv1s6Hrjs4tnJxOWkF4L9Pw7AXlLa4ZU/FInqPaFmenM/DDro2b3C3s2tEWL1veKJhea+VKDZqWAljXJEOGXbPbJk+tCaXI+5j82zoZPyFj8lhBQuRVT0MG8tASSJTYjlSWAcX4Hf4xkY/UlIOJ7HWzAjSxdNr5RBHHLRgyAkAq/9iz9YDf9DHHzJGvG+0DchMSFd5QIIwwT+45lMdO9X+CBiIlFUcRV2JZaxUhYFReZQppYCsn8BhpQkzLl2h+zBMCPAX9LKqjD6dDmsYoelV+JVoafe1ZDtFUtSjwkQtuSwkzUDWX93fr12SSfevBZVtmYpLsbahohA== X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 31:AtsQ8ntqW3BgP20+4JwBm0/hqO/FNn95YC+4zXc33AeLDKTgdCbeogbm8MNOiv8vAaYN8SsYRVC/yeAPQ8XseQvKcisCXgRmqlzpg5p1p/h1kIneeI7tvSPACa3q7ejptryr15b24uySJ4fFWRqK/H5i1/H823rppxZQR7y8P2cuSHKnRBG/HGRsXrfHZx1qaVW6pHdY8D9o/UmxHt4goTarADHbTQP0rHg5/UyMYhQ=; 20:rg8mVOzOZgqDIUk4GslmpYqSemNwjbwGvBR1Ps/oGOdrgWt5vGcU5e1LqUv+PXLR3yW8c88bdCeA+/eDXTwmFkHSqEF5s1bT3DzDjGoYo5y68XEwyjrhVZ9G6iZ2pAzzcB7QIRdO/6jfoXfoQTXnotF8VuaUxWsCJvjTQmTJ09ioD5mPnXIAIu5DOMc8zrLjrsDpPNUVfbLGdS/VTbxs/vwm5j5XWo/IWqSDEn4H/0DaigBcdbGKc6Sf/29xtjhGpqxuNqqvY+7D5ItQhF2E1tLSQXl71gEIDNQXhXLb/GCGAaE9fl6/pq5NXFcIVVH0b5XOrW851CvPVugwmNW2dY5E8TgD4Q/TpFX28cQHz0Ra8kPXL60jgKPrbG/Ixurkb58Lt9FQ2tELkrdyd8Ik2HN25hADLqa7qLkfV1orNNJ8YzjXzBh9blQuFApZtFOTiTX6lJ6s424bZqI6IdrP293WcA9HfylT/lH6LwG8/2J8a0ineGfGxD1+2flB1zWZ/zp+Glj6lTgqIhwI+uOmjKRZz5j6BHTeiwoKL6VL7DzkazUOJ74zXg9GnITd1dsyOfwDaNAXeU3qJDPg5LIw3MqCJw70XURdcTbVq/dGCtQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558025)(6072148); SRVR:SN1PR07MB2285; BCL:0; PCL:0; RULEID:; SRVR:SN1PR07MB2285; X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 4:sExUCsPfF7Vh5shNL+ppepAWmsWKpkuQISlxLCF58TTpMUSnETUDnajEp48P4M1l+9NSWMZDuKZUQzDMlji/bCByvvWnD7UFWrud0LTQhP4yynT/5Wmnh1GYAY1Mg3dFYMTONsqNxJBZUFXYRj7i7H7JefEpV3J6xVkYEP/AHaZfeR2Z5IutAAt11oS+qVSxCgFOJ/mJomcv75xGi/x/jv0tbQzVnM0t8S4zMH+GsQFfBljBmlvdsCiUuioXLsYG4M+mwwjcO3biWCHa36J+FK3NJc2Mw4wGEE4QvcIOn93GFyvJi64UA4u9gikLv+aN/Fk1SkuX4sgm7CZuMK1EISqTwTBFiHclR5b/nosKtrwl1GTKLmK3pfuzCrkk2FIsc2AAkzG+1E/y2PZog3K0oS1Li/3drUQ1adp5ZFqzmXcc2TIwlrwzW8yCUmNNhqW65LE+FMabXAjpLZNEjfG8pwJ0fn+od2NWVwwfvmUkrokbReWQidpMu2W/MwpH+QKpyL+qCDgmuaRP24vnqNlklPNuYZcWnAcd0VN+XcIzJ8ZUSzV1JD8/ALK5TI1K4NRwrOCNCq8i11tAEnmUlJSwxPXDXfof84rWo+xEhaYYyqQ= X-Forefront-PRVS: 0225B0D5BC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(39410400002)(39830400002)(189002)(199003)(50226002)(81166006)(42186005)(2361001)(101416001)(81156014)(305945005)(3846002)(6116002)(5009440100003)(8676002)(105586002)(7736002)(53936002)(36756003)(110136004)(106356001)(6506006)(25786008)(38730400002)(2351001)(92566002)(48376002)(6486002)(97736004)(50466002)(5003940100001)(189998001)(68736007)(2906002)(4326007)(33646002)(76176999)(54906002)(5660300001)(6666003)(6916009)(50986999)(2950100002)(6512007)(4720700003)(42882006)(66066001)(47776003)(7099028)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR07MB2285; H:lio357.in.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR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ynqjYGXp+8noT6uwd1bL3WsA6jvyofJz7/5pVX9i8p+5jyFgCzGvyDqrfXo5qItp5ng9DTx5zJu3Dg==; 24:wbjGXvOpxDntFXQQZtOHbhHuCCyLdyEVvfmbKpM9L83wsWkNl0dKqnaykIjapa7iX5aTx4Ao4Pwo8x9ytyPtguos38I919f/bOvSRWelqXc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR07MB2285; 7:E+L4CPpVatxooqaMDAFL7kp4J2dBHCloxmk7SieKOm60DSlsBtI3ZQt9CVCkk1UKh2ZukcbpVXERnW4NgxbS8ghrhc7s+Gy34ix6YFmFf0AgJNqdgYGq4UGXicI4ViM8/6+KDwh/eEiogRqq28sagxpgaISW1lGjvGGIJLDAljPv3X+52hfOwAQ5ks9Mn25IIlOkpX0ICtbY49JH6IPXwhZGqSqEJBu1tlTT4sfRU+2kDgUi8vmdtS+0j2p8KGnOJGbB7EX2ukn40nytmYi/ZBVZJQlB/y2Csw+mFdA1+pqBo7coYrX43f/h9L6awg+ijdeUyYMYXoYInKwABOAExQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Feb 2017 09:29:54.5897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2285 Subject: [dpdk-dev] [PATCH 35/50] net/liquidio: add API for link 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: Tue, 21 Feb 2017 09:29:58 -0000 Signed-off-by: Shijith Thotton Signed-off-by: Jerin Jacob Signed-off-by: Derek Chickles Signed-off-by: Venkat Koppula Signed-off-by: Mallesham Jatharakonda --- drivers/net/liquidio/lio_ethdev.c | 76 ++++++++++++++++++++++++++++++++++++++- drivers/net/liquidio/lio_ethdev.h | 5 +++ 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c index 256e6b8..299d28b 100644 --- a/drivers/net/liquidio/lio_ethdev.c +++ b/drivers/net/liquidio/lio_ethdev.c @@ -41,6 +41,32 @@ #include "lio_ethdev.h" #include "lio_rxtx.h" +/** + * Atomically writes the link status information into global + * structure rte_eth_dev. + * + * @param eth_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 +lio_dev_atomic_write_link_status(struct rte_eth_dev *eth_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 uint64_t lio_hweight64(uint64_t w) { @@ -55,6 +81,49 @@ return (res + (res >> 32)) & 0x00000000000000FFul; } +static int +lio_dev_link_update(struct rte_eth_dev *eth_dev, + int wait_to_complete __rte_unused) +{ + struct lio_device *lio_dev = LIO_DEV(eth_dev); + struct rte_eth_link link, old; + + /* Initialize */ + link.link_status = ETH_LINK_DOWN; + link.link_speed = ETH_SPEED_NUM_NONE; + link.link_duplex = ETH_LINK_HALF_DUPLEX; + memset(&old, 0, sizeof(old)); + + /* Return what we found */ + if (lio_dev->linfo.link.s.link_up == 0) { + /* Interface is down */ + if (lio_dev_atomic_write_link_status(eth_dev, &link)) + return -1; + if (link.link_status == old.link_status) + return -1; + return 0; + } + + link.link_status = ETH_LINK_UP; /* Interface is up */ + link.link_duplex = ETH_LINK_FULL_DUPLEX; + switch (lio_dev->linfo.link.s.speed) { + case LIO_LINK_SPEED_10000: + link.link_speed = ETH_SPEED_NUM_10G; + break; + default: + link.link_speed = ETH_SPEED_NUM_NONE; + link.link_duplex = ETH_LINK_HALF_DUPLEX; + } + + if (lio_dev_atomic_write_link_status(eth_dev, &link)) + return -1; + + if (link.link_status == old.link_status) + return -1; + + return 0; +} + /** * Setup our receive queue/ringbuffer. This is the * queue the Octeon uses to send us packets and @@ -289,8 +358,10 @@ lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3); - if (lio_dev->linfo.link.link_status64 != ls->link_status64) + if (lio_dev->linfo.link.link_status64 != ls->link_status64) { lio_dev->linfo.link.link_status64 = ls->link_status64; + lio_dev_link_update(eth_dev, 0); + } lio_free_soft_command(sc); @@ -495,6 +566,8 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) return -ENOMEM; } + lio_dev_link_update(eth_dev, 0); + lio_dev->port_configured = 1; lio_free_soft_command(sc); @@ -522,6 +595,7 @@ static int lio_dev_configure(struct rte_eth_dev *eth_dev) static const struct eth_dev_ops liovf_eth_dev_ops = { .dev_configure = lio_dev_configure, .dev_start = lio_dev_start, + .link_update = lio_dev_link_update, .rx_queue_setup = lio_dev_rx_queue_setup, .rx_queue_release = lio_dev_rx_queue_release, .tx_queue_setup = lio_dev_tx_queue_setup, diff --git a/drivers/net/liquidio/lio_ethdev.h b/drivers/net/liquidio/lio_ethdev.h index c7d3336..98ff493 100644 --- a/drivers/net/liquidio/lio_ethdev.h +++ b/drivers/net/liquidio/lio_ethdev.h @@ -44,6 +44,11 @@ #define LIO_DEV(_eth_dev) ((_eth_dev)->data->dev_private) +enum lio_bus_speed { + LIO_LINK_SPEED_UNKNOWN = 0, + LIO_LINK_SPEED_10000 = 10000 +}; + struct octeon_if_cfg_info { uint64_t iqmask; /** mask for IQs enabled for the port */ uint64_t oqmask; /** mask for OQs enabled for the port */ -- 1.8.3.1