From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0092.outbound.protection.outlook.com [207.46.100.92]) by dpdk.org (Postfix) with ESMTP id 7BCD937AF for ; Mon, 13 Jun 2016 15:56:48 +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=57fQ4oik4wyH79bb/Elk4qeNWLSlCO/Vl6AZpJLd0oc=; b=bb4DDTp3nH/Ex2ZsHehmSfoO+81eXLiuUxj8QGQAM+bBNcbXmogZUxuq/rmUoAHZIrKzWpGjIyh3Nk2Pk8RNj/sQEQegvm1rq05XZZDEQCG/qYM5lPcbmkPDEijCxbyfQq8DQj6MPR0zQzUxBygIzZREbFANseurazo0whUh27A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.21.3) by BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 13:56:43 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Mon, 13 Jun 2016 19:25:27 +0530 Message-ID: <1465826143-22159-4-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465317632-11471-2-git-send-email-jerin.jacob@caviumnetworks.com> <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.21.3] X-ClientProxiedBy: BM1PR01CA0031.INDPRD01.PROD.OUTLOOK.COM (10.163.198.166) To BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) X-MS-Office365-Filtering-Correlation-Id: 2b9e0a23-97cd-410f-8a61-08d393928f57 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 2:jgZXy/b9FMl5K0v/m1h+YHxlag3CgyYDM4QGyvNdxgKRf6utlAD//urDtPsI3CstHf5Z7IHCjtZKn5SjJkxk1suzoJoM3GCCMZno+AZUkianR7JHTS8aDzdB0c5upf1WIryLWQ8wqZFX3njZVepQfmg4lW3HzpmxLp0X1NdqgrZL7N1uHJ4+lkeyn6L/gjvH; 3:fZsdJSmcQOZqRtO4ykDd2RPQyiQUaXDeqAjgkzDasrI5qS/yqDHK8johSxz1o3jTsFg2pE7KkBuiZ608CtJ6m8myLU12nh+0F3WnWvDvoajdXTx+e9VaykCNupCM/KuV; 25:jf3iRk3Mf+aDxLURPGK60TOGxsc2D52Xob/WyoQZw1AsnUHuX2jncdqpBaIUL8apcP8m6SDf8X5UpXg8txolf0CWEkUdbephrCsW/olLxqoFKS6WZO0H32F64Rn+m8XJuwL2VdL/gT8MCpkTAP/UFVjd/1ru2E4fJosgDUW1vlNbmZCurW+oV5flbmqy0IebBpbIAJ3/iJk6/HwMxZQjvYgme+XYfc+UljEXRC6ZxyVMCQDDS/p9SEilaZgQViZBSZcRLSvwTHLNdxNO4F9ndEDTORb0l4+ZYS0uGVpL1bIzR3q2T1hupzRqtPCxXcIKnImDGyqU145lCtkfRXxFx0h7lgG90WYBBEB5ugajDv/pVnnbQD8eRz2jpWiSjQDorv8yaZwZh+57DOkGMuPmQsCiRA5hE432VLT6tB9KcUc= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 20:GgwWPysMK8prn/JuxduGzwm6Rdw3kiKHL7s01Cbz026YQ+7hVPKkUObUuJD47iUAiWB0tw8QnOhohqMNyelIL1AI473tNRcdAYWQo4AfM9aLYPuh6ke8vG427EzkU2ks+jQdgHLA13VQc8Y9EnfGETgN6IIgDi4x/oDXMLADOl9jc9/RJMOSB7oHtj1ayCR9+UpZ96QDoNlcHLrvf7I1cfUb9KQ1dzLlaWzkO9ikADxSMh3ZwCnfKc2wlUJ/LjhCs4nMypirbK3lYje004CIF8B5ZTB//g0vc2/1hz0iXf0usD/sEII5C+W6lnFv21poI5uwzutmr8EWLHT62LaWmXTzhzSRTbEA7IwY4s3xNSTgw/S3NA/R3hff6wh/G4OLPUU2+3rl/Q2bjKf8KC8z5WBNAeJfR31rCEQrdf2xdIVYmjBj2oSEZhVgIUolK/3ixEiJB0D7Uu+QoSFX8dGhSRTRpPc9TEs6I9OfGHbLK57wBy0fh8c2dj1HLG+wP6SNlqVssUW9FcF9UZTIqwENjmoPpt+6ZzDVbewSaXQL8DHmO/029t/HhZediXNnL+hNsHGQUNPq1LGnOzlk6ee+SXIQZLswGaKluaCGVdgfDVA= 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:BN3PR0701MB1717; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 4:YHkm9Vs4vlQ+IyjhaZwrq+A/391M4fABFvcb1tPbCqxgBbyDzUGT2lZE4ppWkPS8oxRfzW2ASx3jsnIyVttejVxwHxdGWNsQ8WuYRHps7wvdf9x0Ka8YwgaoWHlnEjp0c2vRnhClIMAyRchfM9Gzw1wIqa0IVtCgmcutqV3WyTwleYGSxY1u3ncKSwLMSeH8e4+zLVbcCmfHJ38a7JPx/iCsGOWAi7pac+vXjVj2NJW4qx2uO4jf7dwKKRglar89mnqUGecTEYdqp7UA4BTrhhFUWVTA6u0iRT+mzp2nG+0pLU9AJhCcHDiTPWXCAyG0bSl+PQZeypqy8Str6Se4eD1BbryNezri5/zt89S/UxH6f+7yqbb9PEjRkTXbiS8SrDM1IaL7/s5ul68KUlRWIC+14IvusdBI6An6A/W15p8= X-Forefront-PRVS: 0972DEC1D9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(50466002)(48376002)(101416001)(42186005)(50986999)(92566002)(76176999)(105586002)(106356001)(33646002)(2351001)(5004730100002)(47776003)(66066001)(36756003)(586003)(3846002)(6116002)(19580405001)(19580395003)(77096005)(8676002)(2906002)(81156014)(81166006)(4326007)(189998001)(97736004)(2950100001)(110136002)(15650500001)(5008740100001)(229853001)(5003940100001)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1717; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BN3PR0701MB1717; 23:7Y9GHymteb1YeAamLCmvEWNJGdq9c+DzQKxMXLo?= =?us-ascii?Q?pKqIZUzvJWxkFW57AaCKns91dDitxTD0ddMMobodVM7PfkozuhKR7ZchFpFR?= =?us-ascii?Q?gMbeeVwzTQX+8jsl9x/kno/8g9JzeQXy9ERMq1/UHjecwQxX/+fnIHgSCPRA?= =?us-ascii?Q?vbm7IwpViiXy2Pa0ifewqWyevJEbnLMpdQ5gteYWCEvZE0mYEdfG+h6NVK5c?= =?us-ascii?Q?iJMsi5I6Jl0SgHfwfnJe7wX7Y056JeA5cKL1gnA3YKWbF8bcgIDkTgziKL+k?= =?us-ascii?Q?bb1+MWJroR2r6dXveHwP1KNchMe2JgGhAmgrSvC3WYSjfm/kgPY4Hdqfi1s/?= =?us-ascii?Q?xz050Henw3YfpSLarQt7HJW0Al3ii9CNuJjSux7DSXtMec11nq7GSD8AOM3J?= =?us-ascii?Q?8YYUNieJXhsx4K1cNyj/lXuYEBdCpWEWL37B/ic2TdCl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awXyiTQt4A64jatetUaEzwWhrib+GQ/BpcZhwhOvd69/yZFWTX4DNcyHq1Js6DgQzlYwH1Av/g0CtLH/EwzihafhHCywY=; 5:TsUEt4k24CRlDQjUlbNZq4N09BQKdt+bVn1rxOA3B8cIBahCGNB2NgOe8CCj1ckDRXGa2MGsk3IPJLcjZKEHhd14gSfBp+tNCnCTXRiQ2wmVJ7pq6V1igpHsnUliXX6JLmJctWaDJKtFwMvpLa8vnA==; 24:NJ872AKiCoWOIh3GKIKq5p+L1KvIGx6UEs98Rv6MWcxDo1uWm6KrIcMcv6ly5+9BipF3RLMDBJkhHpgKdOUVWN7wIjuFRCvlGiblnbYSEyU=; 7:sxbSH6ClJJr5KDdQItHrg9CS/6kUiTuD+OXRRMicZtwvs6Gq+lEjIO57ej02k1YmDTpo2sxxVyrrx84U9JEbkykv5vb46k7HM6/p+YYB/LvX7+gwz2XYLsfsAoVXh+Ae5Q8i8X+O9aUdpBQtFMplkAhdAtqP8JjTwEfeH3ubr0FAbxuoyU4bPD9C4Vq3upq3zf2Akq4BXBnbP9ftdoHxo0N5kkx5P0dml0ac6C7LuBY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2016 13:56:43.0698 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1717 Subject: [dpdk-dev] [PATCH v4 03/19] 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: Mon, 13 Jun 2016 13:56:49 -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 3ca5a2b..6fa486a 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