From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0090.outbound.protection.outlook.com [157.56.111.90]) by dpdk.org (Postfix) with ESMTP id E5EA3D05F for ; Fri, 17 Jun 2016 15:31:20 +0200 (CEST) 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=8GNTtEEvDB/L044pWdCBejjJURZQEl8W/7hKXu1bPxo=; b=GFQfXlETWdyUoZg9HNb9IwlZC62mfezEb/oq3uDdgi8pIsss/FchZo3yIPeW9A0BKt2wtWSlqNpxyRcfwCFwtER5cTLZf3/q6wuslt010DE1XZkavwaaBvDyF9iyTFp/LNx5SZohpYdGrRh943wrKBlGXsWZgAh8aK0yv8NI4PM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.17.70) by BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) with Microsoft SMTP Server (TLS) id 15.1.517.8; Fri, 17 Jun 2016 13:31:15 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Fri, 17 Jun 2016 18:59:36 +0530 Message-ID: <1466170194-28393-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> <1466170194-28393-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.17.70] X-ClientProxiedBy: BM1PR01CA0028.INDPRD01.PROD.OUTLOOK.COM (10.163.198.163) To BN3PR0701MB1718.namprd07.prod.outlook.com (10.163.39.17) X-MS-Office365-Filtering-Correlation-Id: dcf113e7-c813-4563-0c41-08d396b3aabe X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 2:VBKGodx2xB57kibiJyHcL6JS2iShjB5PsndY/xVNJ+mbStp/QqfqDJE08feXGfG5p6iJATZTvlTs9eJQnqqICUbI78pr/S60slI6gXRq1nQP7fy0s0+kzAGesLdm6vVJRqi5hEMKUzopFzEznXxEDjor1bi+HlMeSEbtpfcpOnk3OdYjSxvBn6p4U+aZnW9j; 3:YyrajFEsVDG5sJCj/L9mq005aE/u3Js5YtORB2WiK65plQswi2lV37ulESsKlCTyvhmRnUPwtIFhYHiiQILQ+x3OF0ROgMtFlIZYsFubn6fCrIzuxPaXvYpOGcdF7uqE; 25:oLjL4RmnCICH+j80sCvtY0gVB1HYVWCdbKXvLykKUpX66nylH+IV9d5bVMpbmKiBkWWMBha1avsFfAl1MhE7E/fQ3Xne9YXZzYrKTQxnewMcgpZcTiyPYtda1PUDVemv+ce4xsNHD+ILxW0dazhchlpiWhaASbPH2uN8P131W306O22BaUv1NChZaT2YG0Yf3Xw/bKzXjv35kjlUUbHf6cZyaPxMWeu0B0hYSwiIAygozMixM2dIhymNct8obGpb6s41FWQCj51P2NYPg1vrTPjNVqMTQ+rTZgXlG3XQyIIUvT4rsjklMsrcKYO2ggSGdVYJSpomTyuTEMnWngdFpCZ0d/HGDfp6F7kJWWydeWXbKl4/Ng+TBBEqt5OeqdCyFNIQNhWRUX5rsaE0Uu9iian9HxrUl5JJZ+cSCFUlyjc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1718; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1718; 20:AAImtdC6OiRt/HrXi+Z7J2sQ2A61J8ldNEHj18oBTCG3uhuQLQ7IWB09wrh6b4u07QUS9p9qkyAV1seu+BWFa7bXtqWykD34peay1CzqV+j34rGEGVNymJ8i91xZET4Gj3xDAfyN1HVJe7tQoC5J+ufnpqDp/Ex73V51NI9eI5MJwYkRSe8yOfvhp5HhY/Jc05lmvEx6LuN+SwiQjXoZhqMYWpndkTNVuPfzMqekPw49CJ97/qRlv7HhJIv4JRElkZ9Ocbs4sex6dIk76166WGVwPEEfEJY2sPgGIln4cBeYqcXFrICyjibO91SMRprZCKvnB3qSkqbl67Qf8Uo9H3mx2cVjI0odpmUBN/DmIpTyHj9EbtkDBOvwwUHBkruv8C6OmCRBq/ErmZ9683ggr5ogjkkTWI+SHv5ifb+gGBg0ckNhi/OVd3wkzBlVJvsqopknktJLoZJUNL/RHrhm3Z5dCGLxhK8b7AGsoT1aQnmRQpWWddKP11AriiKA5MAxkFKMvr4WABJZ8G70W8s/QfbuqAPAQt6rPB5PcLPPo/8xobYw4w0t8/w3Xlw+v9biCV8LfcOr8V8gqodKlLOGr38GBsqKE//9wplFCJcxcDQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); 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:il6tGTyIAD5u2xfV0/KFpRSldIyE9VyrYrr5qdtxof9Hy1+4lb6u/K35AFJQyXbVIavlfHSDeeXwe77g24UTq6ax1Lcz2aw6hhgINjYSRLbbuVx3qCycCybbea+MhBUwdvx1GmCFvMKk+aGFAY2x7nuoxwcfErX5Ety0y1BbrPeO6zVvBw6yWi8x7DzFbuaiVKFIk0uH2/8DpQcco/jg4vLp2I7A/hHEXXjQJPbbuWk7L5ByPZO3xrcg8pNgAlWcXd/nfFAlBG3h37SVfTcTZFJTR8s4VPt8c+If9nifqLlczmTyKiG3kve/gn0t8HekYjjgYgbyFzUwVS5Mg39RPgD1ma6khcIU83236/4/Nj/fhx6KmcZ2zrTwmNXPfuLYWnSyzg4ZkQ5DX66AjpZkxJdLTV3SmgYozk3q9cV/KPY= X-Forefront-PRVS: 09760A0505 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(199003)(189002)(48376002)(19580395003)(68736007)(2351001)(47776003)(229853001)(97736004)(19580405001)(586003)(50986999)(110136002)(15650500001)(36756003)(3846002)(66066001)(92566002)(105586002)(189998001)(76176999)(33646002)(42186005)(81156014)(5004730100002)(101416001)(50466002)(2950100001)(5003940100001)(4326007)(5008740100001)(50226002)(2906002)(6116002)(77096005)(81166006)(8676002)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1718; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1718; 23:L6Ko0BLnYlIQayjTm42cVVGJSiOy8RhHuO5K8su?= =?us-ascii?Q?9EkaiP0/4l7jeBZo7ByGVnr0cRKVM+2OuutW+34WOrra5C7W0rieCXC7ttb6?= =?us-ascii?Q?kIt1PObJp/q9NbhL4UQDHBfOcL07xW+RLbPfsxJudFJLD0a8e9kT8D7dEu2o?= =?us-ascii?Q?G3PEU6QMjfLi4Hu47diWo75UchygjsP4HmBZeaYnGObcPK1F1SVqoH9L1WU2?= =?us-ascii?Q?GMAqocdJieTn341frOfm41YavchkIprrfm/sZE0lYHf+sSEAsovDRyqkTyS0?= =?us-ascii?Q?BlX97+VNo9C1cUKen4gi33KFIUSVNS98CXvGLg7I8CZ6+LiMYFHNCQP5trMq?= =?us-ascii?Q?DA9xah/zT9Kluf5nyntDzI3cVSu4TQe4l+eMPHvaPX6OqtfkYgNsJNEeKQ1Z?= =?us-ascii?Q?CY6E0VisbUGRO6cRuXnZN62MnhBJhuHd/iTK8GvFEdolCEtEmOWNczovBexr?= =?us-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HdnxcoZc6AS4IvLTriuC5jP2KUxBNsY5Nofg03MyGobbw0nluA63EFSD6E0YWmDHocI=; 5:cPulZxif27knjmribsL4/SueVvZjAgyhBYsRJeNx0LQ+WdMa1sulamM3fYRZiGHkkajcxjdb7gZDHJ6THsw7lifDuYwUxQutFXFOk3svzdo2TBtrUaXeyf0w2NRharYctYKtIFx0pyOKASPzV0wVPw==; 24:cbhOpWsQonDAMvcKZwWhoMjO5AB3B678zu4LdjowVwYdtUVyRvgwtFmSMgBJ6BxgWlQQb6JQ70H04PvJBGMJONmX0rVE7v8hKKWi48gPclo=; 7:aX7JvfDTUnJ/I6vuzi+0ky0sCqbB+VGrWzCbSscuh6FIVMf5v8WHiN3pZzU4jCyrMQjg9wR9zCdHCibkWKip5l8HNMSo4ATsVKNX1w4bNnfsBC2nhF0uOl8qKqNMC1e13PfZ/ZHT9trXznvTzqgR6AY6WqrXwdI7tP6jOng7FTo6mX6q/oDG7RqrjiqcOXJD/DW1yn+lWWZoB5rGRZJ59Q== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2016 13:31:15.7889 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1718 Subject: [dpdk-dev] [PATCH v6 09/27] net/thunderx: 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: Fri, 17 Jun 2016 13:31:21 -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 Reviewed-by: Ferruh Yigit --- drivers/net/thunderx/nicvf_ethdev.c | 53 ++++++++++++++++++++++++++++++++++++- drivers/net/thunderx/nicvf_ethdev.h | 4 +++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index ba78ff2..ec5407b 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -69,12 +69,45 @@ #include "nicvf_logs.h" +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 void nicvf_interrupt(void *arg) { struct nicvf *nic = 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); + } rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, nicvf_interrupt, nic); @@ -93,8 +126,26 @@ nicvf_periodic_alarm_stop(struct nicvf *nic) return rte_eal_alarm_cancel(nicvf_interrupt, nic); } +/* + * 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); +} + /* Initialize 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 d4d2071..8189856 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.5.5