From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0080.outbound.protection.outlook.com [65.55.169.80]) by dpdk.org (Postfix) with ESMTP id 9EB735A8F for ; Sun, 29 May 2016 18:48:22 +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=iYG5N0DxwfSJDXDb3tt0zVyp9qacZgvEKxDikZFcTZQ=; b=bAZHu8frcK/qWY0FaxRESNEKGoprTI+sbo7/+Hs+5MReLadogcpR3iMKAwPWoN5TgujVyWzTIOXRorJQfTqtcaZi3Gkb8uz/Sw30MttGgWw9Ai6akOgqrEYbatwDOXZymWMZjq9MGyld24NCd4US6UA2KnEVr2J3niwJAhJ0/Oc= 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.187.184) by CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) with Microsoft SMTP Server (TLS) id 15.1.506.9; Sun, 29 May 2016 16:48:16 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Sun, 29 May 2016 22:16:47 +0530 Message-ID: <1464540424-12631-4-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1462634198-2289-1-git-send-email-jerin.jacob@caviumnetworks.com> <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [122.167.187.184] X-ClientProxiedBy: BM1PR01CA0003.INDPRD01.PROD.OUTLOOK.COM (10.163.198.138) To CY1PR0701MB1725.namprd07.prod.outlook.com (10.163.21.14) X-MS-Office365-Filtering-Correlation-Id: 9ed18fe5-9050-4f18-cdfe-08d387e10a51 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 2:E91IOdYHdmvagSd4fzhhKr1ewNBs+Su2bLXB+6L29EhArLilwkk7RuY44vBS1v0X2L3Y1+WjRAB5F5AsHig9ElhObutSvk21dKAOQ1FuYERT5fIsDGhKFV2umFdxgcykaOV4LTy9akgdU/J0s9hnsegqIDEI8TMA9clMof4e6bnhkOs9ikLsE97dh0E7sPB6; 3:gSrkxg9+Ctcswkw92rvVZoRqZaEVfpYz6rLGtASxVZjappJxmIDeNZQgBitucMnILhDyVsFCi/bJuDYb2yGNNOJwhShDb+Mvug7mSTc6jnMCLoc5N+UWMjwFsx0b2ruI X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 25:wUuVCdrsN1UnO/bAqQYSjK+cU0qMDwjOyDmppROiw73wu5roS3OAa2CGB6R3sMOYNYNiCvS5SSLRHfHOjEWo1Dg3j06NwJJdCTnkS75P/N3Sz9fPc6tqlFyrG6DaDes/rGxYNaAWEe+kTfM6/RP2LYjSBBmpA7BuuC32upsspmWbDLl27S8TdKBoMm3K++lLTTNQPULdt+I9nGMZ3kvJtLXyTB4VN8tM8S6UR2XD/H7Jqh1QmPDrt91OI2eh8SikEdznr/P39h22/EpUUrazhtFflH35iLaTi7yIjzIRK5L4rsWv7nvQP/3sJoc3l/PHCgw6Zrl0Uro5WhVQzzb2uRnUObkjCl5Q1JC/523rRqYk+dNwhZl259aFsAMxLv7L0+CuHo+uMbXNNRrQ0m/ZaBm49CUTvBDib6FdXGKsFFaPDXmYLBX9Kf3r7JQrMfh3S/VG5Y8Xjn7YVb1gkSoiJx9mO/UeHa/OVLInHFMoWqLDM4FhUQjNaMtV9aR94eSPfr4QVcvttU3QfA/+oK6d77oR6Fmn7tfklY6Pdoc2K31h8unffpHGkIzeCVcsUO0gdsrOLNPKf+jp1dW13+BoqxVMmVtrsOowVx2knG+bEyJBhpkwWOfdgRcwaqPWRVnbHY92m+6TJdlYaMqchuO2t6DZlOKfQY+F23duX6f5Ogpj1Lhi8OjaQyRFxdn4A7OCDfCdRQY2iMCPSQEffaNZk20FGl6pdW7xOyCEni6Ot+2HG6YIClPnDjJr1loy5EUbKYcF3nIn9Vrn+3qCVSo6Ew== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 20:Jb+CAj+MJNA/pH0s34JwQM3WiI/9L62GJUrkwc7A/e3fTeLe3VK4yB5RkBe70Gitj2pQkeb+Um1l1t0A+LiosdEEsbFo78f/ivRhwmfefxUF3s1G1QrX8pW2UmhIfv4R52OYk4sp6MRAqgUHWkoGiMsJeV7U1Krh+KqSwBGvCjwsEKfvUeN7jgyP7zLhgNazJ4v38iJF8sCuUrmbUXAuD+yuLXOpfVRQEi8ciA6ZtlpdDdp4PPGTxIhAJ+/avqTCtk3UOt22YgdycNyOnWHDgJctQ6hw43nUe7l+XMCk/plqLRka+yxYVAy1ScjTM8OKawSnyJbCcEpQAU2ljw7L1VwzjlvmQJk81++YuGmVVAWP1enkXOHEzjWlM6wARhYQpyrVtK+UxFzCbdtVwTSxFBdbHk7fuPOshNIhQJm2aay/+sHmUOZJXY5iJy06kYGLcgDCw6AhM1o2dQV4+odkZuqRRw3woA41P3HTDY8ZDgZ2N071pBTobqGgx4mh6GnyHa4hRQlRgaggsYF3hY1wLHmjl2ZKwqBGO8omfnb3BmSW+AQddQs4A0C7YWc8YYqgrIbUquMMBAcOi/rCTrswg7apta+f22Y/nQaut55NZG0= 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)(10201501046)(3002001); SRVR:CY1PR0701MB1725; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1725; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 4:fKdpF/Zan5GwLoJloJP6dOmTcXivqOwYX0c8Ae7JNzczGYjj03BHK2MgUN0Cqt5c6nc7Rjcei0JWQkCWwMT9XvWsqsAyDkXfo7K+bR3KOxfme7JRXiN9wQQu/ZiBgUFoe5UnOgHChXw5Y2gmfAounJSNtt/eiAxkcb9w62gvqHN8PwOoEZm5VruoSd8cqFO6ftpJmXDdHMUP6VF5zo5MyzBdYMHBtXPhr90iQEx0DRNphKdxLHXdUkxlI1N4tEBb/nbJ8fTxqnut1qHOk8vz84v5eJzYKoIp7VQ3YWBa/b7/a6/3F0bIN47UOUv7skHRKihEgY4VKxtpIPK6cf6gMUFXyHACfC3Ibp+m16IqZEt6nJpCykXz+ZWLQeFTdLkQ X-Forefront-PRVS: 0957AD37A0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(4326007)(92566002)(189998001)(2351001)(15650500001)(81166006)(33646002)(76176999)(229853001)(2950100001)(50986999)(19580405001)(19580395003)(36756003)(50466002)(110136002)(8676002)(2906002)(586003)(3846002)(77096005)(5004730100002)(5003940100001)(50226002)(66066001)(47776003)(48376002)(42186005)(5008740100001)(6116002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1725; H:localhost.localdomain.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1725; 23:tLmTJMXvwm7Q89zpZdzVZcRJrrV8qfmpQHQDrJrdSL+jXNSVH+swYjoJm4Jih8viZXAp/HcSqLqE2MD4N51JbbbJ4Se/p6rBnZE0Bc35C3gZPJKm1qfHYLYvPxyaZAWmTPeYHNB/Hg7Trc1DQFArutF1MSLNuLPbzqiFsbSd2xx0xUgdxcZ2gP+rycbTTcQWZT5aDRZa8SErZP/AV+Fb5WwJKoF6MfbKbWAYTXn+XxkI3IiOgz8qRIt5KROfGeXG5qAUyK/MxPn0iY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8ABw9PWXtEIlRoLifMcaaRP5UrDGiIfdQB9dqvuKJzwHjXkL5bgsW/m5bAa4EIKuf8DsDE3KZPNER SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2016 16:48:16.3801 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1725 Subject: [dpdk-dev] [PATCH v2 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: Sun, 29 May 2016 16:48:23 -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 7b9b6f6..9f4ca65 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,8 +150,26 @@ 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); +} + /* 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