From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0097.outbound.protection.outlook.com [65.55.169.97]) by dpdk.org (Postfix) with ESMTP id 7E3775A5C for ; Sat, 7 May 2016 17:17:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=od4rbu1uK3F81oSdKMQo3sG3kQSAL+elk6J2A5ZdIHc=; b=Be+Q/i8Y+DUfbHw/5A5vM9EHlFfLRqOIdzGUeHfFaKO/a4dkN6MEBPZ3eq+gLNG87k3mnp9v1SQKQ2aggIKo/XEar7AFyS7a7Ojcvmw6/ckgkdf50g/dYAqRP1kNOVFhy/C4nol6Fexx4FtUUL97u4+8UVtQkbHSGTd8G8+Xyh8= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost.localdomain.localdomain (122.167.10.92) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.492.11; Sat, 7 May 2016 15:17:46 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sat, 7 May 2016 20:46:21 +0530 Message-ID: <1462634198-2289-4-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.10.92] X-ClientProxiedBy: PN1PR01CA0050.INDPRD01.PROD.OUTLOOK.COM (10.164.136.150) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: 05ac279e-57ff-40a1-4a4d-08d3768ac179 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:XiXdmp5eX+36X5FIXhgf0R7QySiPtfoSgQCarNEJYJwS86Kv9DOdXItnoYcgaZLFSAc+Uue/KVOAcbq1gEcm051iE4a5Fg8XIjnDqJPbgR8yBx9XpfwNzkEIxiYqohLpFH0Jxp5Jb0QHXMVLs2QNmY6PJCkrl/hNyQmPVPVA2ilDtflfN7Ij7PL5G7yD+sv3; 3:rapA2nXZuaDR/bnZi0HjqnETuhEpa5P2fRYd7QhfpWHL+BYw/JJOAqNbCPx4Xo5HI1pLrDPQFqAOpmsxAEILiDjAn1duUD4zxMJbKvCvGyIw93Xlmz5XDoByPYYH+URT X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 25:1xK7CegJLY7EB0/aiIxkP9dPpslEbMVCL4AFdj94xyAVsEJ0L9n5L3S2npJxXP512PgGsuSHRHODJJF4Ei0DqfA7D1nwI0SuzBMgPKlC0TFXEA0k9hsbC2zWkjHRXZjPQRtPPxRdeUPcS8FuF5iL7jwXwdHgyrokcNMmTrCgSqG7YGCv5nXBPX++5RzYxNagKd0yFmqoIzbzZN2Zbmbb9ckf4L7KIIfMAHfFygvYJhRA41kBZOFxntQTB0knGABe2T/HU8doPgGaTUWeQX3WbXYyikZ7B0nm21jPg/qLzRaqaSRvpYZ3Ro9XZew0MB6tgA60tiTi06hJ/ctoxydsKjeCdjIoLuyxsjRNQS73HQyY69YsyXvlaAV3vl9mwd/oQimuEPK3AfirqXU4ugfgP3gCyxaae26r2sPnCFOvqbpqMTR/uHucHIpsR24X4geezirpC7BRDNs07XSMZtR5hKaa0R8ysc1O9WOOBWJmQVMYLr3P19lyclLF48bxByQkJ1jiCZ9k8qjDqUDB8hHO4IVNifgi5prKjFyhbFKp+AAbMYzKdg3OYccF4qXQDs/mLZRkTyJMwxZz3pUiH6OG96qtclTpu0VFOkD1X+DbNRtJcNTXhSTuYKy9IUYDCSVDBYelgel0S2HXsGSV65ttaNHROixKhb8PvqezFOVam016yKGEo+412vbN5dzeiOTfffkVNJ8PA6SQiE0Db5AyuTS8U7+zOlJRlID3Twoxv5spShYfC8lvcsRuTac1gXiz X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:PvOrKovicw/wJeqT2seOhD+XY/UODq6FywxT9EOnwP+9U0Q9yJHV42LkzXRjjpv4nMXGqg7/X/EzZqo4hiVlJUMSDtY8gNAag9KzidxMaVGy3hzatcYpO5FHMqfugNK5eNJXacX1Z37Atzi0kLSPB86zeCe1KRr4kgPR2R0zPfY/6hVK6Yn+m65vrVHkuG9HscHS4Y2kOxHz+ZRLkzZpvCajmJEmrV2c7yLjXsHxx81tQ3xL8f6CqojC8MESJWXCxltxiZFv4R17BDAE+ZcRjl/66LlhL0qrjcSoWNT0aN+WNg/u5PzmkcJMwXxKiEteovgOBnau32MgQREm6vta8Sw/Y150Y/ay8CEhq7PNjXx1YNzMwEnaZyxB50YN0bH5JvGBcIqHsjsvkzq2jCv9DXp24e2KstSsNqZgSKaQkzpHyryhau2zdnXB/+VCnWNru8bNZgwpCOoJfH2mdPrjO727mNHITTpORKswg7S7wCMVVTX0/gLYm93vFO4YY/cno3TXNktsYBB3CRKcPw5KuTrF5ZEYUFphRyRwvV5MlDLeKW8ueJZS4cVNLTkRQh6C+7h3mEcQWS8ORA9bT0LF+xQf5C5cw05XAgTIs+gw3Xc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1718; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 4:/NZYZQLysWia5bJsE19R6uGlPUHDTuZBykE8Mzibdi99JtX1W2BpiE2+4Q880eYyurZU4iMEiCf7XKd8Y9H2zaNIdhG0YUGmnU2rqaD3BL3kadkETEdfR2qcEL02oi6SxmD4AbW8by+SS01REH26c9U18dSaSzS7sGeoLT9uY6R+jfMipge8vLhNaCw8hqc8zkRIbONl6p4E5QhXN0a1A5+E2LYsgWlPM0YmagkBvlYw14Pf60EojqGe7x/BboMYIHb1u99lMieph9PAC9gK1FrEwVI8Qou94/e/Foa6lqx3mXnhlZwEz4K4M5EcBYKXWJNgAeLtTf7DxsYGBCp5bz107L1+BJ8poMx8hawVwLa5+lDBL8K8vbam5flrj5GH X-Forefront-PRVS: 09352FD734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(50226002)(77096005)(2950100001)(48376002)(81166005)(50466002)(66066001)(47776003)(15650500001)(92566002)(5003940100001)(4326007)(2906002)(110136002)(50986999)(2351001)(33646002)(586003)(3846002)(6116002)(229853001)(5004730100002)(76176999)(19580395003)(19580405001)(189998001)(5008740100001)(42186005)(36756003)(575784001)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 23:U0icNvAWN/owCKczNr1wAd7kAENqy+lJeK8oaHxEsRa/RnoMfDeJsXQB4N/HgsYkKLdKQtmHrP541aQeGwOcnJuluFb5ZGQ3398Tv2DGJk7ddlmfgQR/yUhmVZTDBEj6KOyxyLKBqCwbd2wLHSSxiLlxOegYZuXa6xIpTVrFN0nGsmV4Mtr0KrRGxX3cdmf1OHUt+24jhR49z6FhFQtFgIP68VPs4i5EGQhe8kiP/M1E3B40QGYYPUGK1VDkWWrye3rSKPL8z5/ZqtW6/BKj06jdYPrAHc9E6/cTAYZf1ntea/Gp8CZp4Yy9KHe308J/5AykYTaRUWx0vTDb+WFFvm0Mt3RlsO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RK8PPsAp9FrAEL4mHdITROz SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2016 15:17:46.8667 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH 03/20] thunderx/nicvf: add link status and link update support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 May 2016 15:17:52 -0000 Extended the nicvf_interrupt function to respond NIC_MBOX_MSG_BGX_LINK_CHANGE mbox message from PF and update struct rte_eth_link accordingly. Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki --- drivers/net/thunderx/nicvf_ethdev.c | 55 ++++++++++++++++++++++++++++++++++++- drivers/net/thunderx/nicvf_ethdev.h | 4 +++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 3c545b4..e6f0b3e 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -69,6 +69,35 @@ #include "nicvf_logs.h" +static int nicvf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); + +static inline int +nicvf_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 inline void +nicvf_set_eth_link_status(struct nicvf *nic, struct rte_eth_link *link) +{ + link->link_status = nic->link_up; + link->link_duplex = ETH_LINK_AUTONEG; + if (nic->duplex == NICVF_HALF_DUPLEX) + link->link_duplex = ETH_LINK_HALF_DUPLEX; + else if (nic->duplex == NICVF_FULL_DUPLEX) + link->link_duplex = ETH_LINK_FULL_DUPLEX; + link->link_speed = nic->speed; + link->link_autoneg = ETH_LINK_SPEED_AUTONEG; +} + static struct itimerspec alarm_time = { .it_interval = { .tv_sec = 0, @@ -85,7 +114,13 @@ nicvf_interrupt(struct rte_intr_handle *hdl __rte_unused, void *arg) { struct nicvf *nic = (struct nicvf *)arg; - nicvf_reg_poll_interrupts(nic); + if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) { + if (nic->eth_dev->data->dev_conf.intr_conf.lsc) + nicvf_set_eth_link_status(nic, + &nic->eth_dev->data->dev_link); + _rte_eth_dev_callback_process(nic->eth_dev, + RTE_ETH_EVENT_INTR_LSC); + } } static int @@ -115,9 +150,27 @@ nicvf_periodic_alarm_stop(struct nicvf *nic) return ret; } +/* + * Return 0 means link status changed, -1 means not changed + */ +static int +nicvf_dev_link_update(struct rte_eth_dev *dev, + int wait_to_complete __rte_unused) +{ + struct rte_eth_link link; + struct nicvf *nic = nicvf_pmd_priv(dev); + + PMD_INIT_FUNC_TRACE(); + + memset(&link, 0, sizeof(link)); + nicvf_set_eth_link_status(nic, &link); + return nicvf_atomic_write_link_status(dev, &link); +} + /* Initialise and register driver with DPDK Application */ static const struct eth_dev_ops nicvf_eth_dev_ops = { + .link_update = nicvf_dev_link_update, }; static int diff --git a/drivers/net/thunderx/nicvf_ethdev.h b/drivers/net/thunderx/nicvf_ethdev.h index 6431329..cc19da5 100644 --- a/drivers/net/thunderx/nicvf_ethdev.h +++ b/drivers/net/thunderx/nicvf_ethdev.h @@ -38,6 +38,10 @@ #define THUNDERX_NICVF_PMD_VERSION "1.0" #define NICVF_INTR_POLL_INTERVAL_MS 50 +#define NICVF_HALF_DUPLEX 0x00 +#define NICVF_FULL_DUPLEX 0x01 +#define NICVF_UNKNOWN_DUPLEX 0xff + static inline struct nicvf* nicvf_pmd_priv(struct rte_eth_dev *eth_dev) -- 2.1.0