From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0083.outbound.protection.outlook.com [157.56.111.83]) by dpdk.org (Postfix) with ESMTP id 295B39AC2 for ; Tue, 7 Jun 2016 18:41:31 +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=1PHkEo7Obq7vPgZgrsDhGivvXiTiaFKWkOGMpvKRZWU=; b=JHPvfOLv9WBaTEBZ7/9QaBy6EK8EnMDZpz2F3qzaAWKre8yjWg+9r05sFBBefdSVSj5h1cosWlarjtpYyJ/U+U5aktbDdUpThBPOJ8tHLpO7Tn7vnVmCrB+Ic+DxC51P3DxbBgXAkpk3sxBvoJCjcBiaBIl7kZInsK+eQzagpSk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 7 Jun 2016 16:41:26 +0000 From: Jerin Jacob To: CC: , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Tue, 7 Jun 2016 22:10:15 +0530 Message-ID: <1465317632-11471-4-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1464540424-12631-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465317632-11471-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0054.INDPRD01.PROD.OUTLOOK.COM (10.164.146.154) To BN3PR0701MB1719.namprd07.prod.outlook.com (10.163.39.18) X-MS-Office365-Filtering-Correlation-Id: f66a940c-a4d7-4812-320b-08d38ef29364 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 2:00VVX3duDjr3P6xHYtyVmo+SROeZccOHQ7wKk7uMfXw56U4F0G2guHanGlOC4Z6gH2Tz6V7/1//WNIEzRz+CtatGK9wB9Ma/G/yy+9Yy4c6LLzoXWiVm7avRkc8auRgWOMdT77HeHtnAU864ZjgWtCzd1wBfQzXZ5Hr8JZHW1MLCa5JbSFXOZ/0nEj97cRKn; 3:4+EHDbxsynFCapPhEoG1g7hFCxIbjxfA2qYkb/I1KwmbDpVj/ZL0E2fV8YqexK71LvLYdr6A1g3dnOM0auzSdURJZRVpKK6uQYH1DucVEocsKB+CrIjSgx4riWvqDd7Q X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 25:BNhtENDHAKCvcNpKBzOwGlEQOt5HEFqJsiyYnAeIGQzYLAnkFFiEq14/mpKsR7aproq+VerjEptwDR6rCB82R5MizRwcrrALMEH+03d0uEeSU+TDUQsr5GGaDseivXclw5zhjHGj5gEuYVdm2ARFPQ5D3CShKXD+yPkGKGFPL7Hq232SCnvXV6wPRlBf+7dt66XU2ip9ZQ15piCB22LSqdaPIn+R+MjPN2dLjfRdEYmjhHCRjsf9rO3NjZ0FugHo0+sTZQux3W9De7/yW89El7xu+mJ/8WIXpaX8dqdzAtj+af5VvHjkcc3bwxdvlK/qWXKXrxcQSuUdFXOOsLWuNOTKQlVaMow4e/PvAMYHonCVJJkJrovVe2EbroClGqaocZOV7oDKgXCF2iVsl8OszzLH2BmOlswhqsgLSrzh0el2fl80TcIYYlJP6oDxqZQr7AhK7tkgU1ebSFTzbso8NXcf6DB1GmzdrDFOZD+54pRShgy0CgwbeCHOvPot5jZj4/4pF0zEuO9Mf9Zqu7zFIsFpsbO7hOhnHYylZ55giNSrOfVCDSNzwptXF0fZ9lHZdNT2GeRMuoh0KU3tb8qLMWIu3jnMY5h3i59W0Og8W1BVZXkl9yA/fg3sj1xLv/f7TA34OTeMcNxvZKtGaokl+NXOt3oqSiKKOJ3oLTUDW4y1FyZ1jjFkujiutwviiX5oSacD/mpsQ+h5fy1Shl5ruCgk0BTXy8/LdcFgC/+wcrH5dwEqrlpIgsbkA452VFMf X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 20:+RlIHRLqB19MWYDjUHAv88I4V7Jtok3BLGL/7RKtgLJtiAO/10Ijcd13Jx/CqR4b+zexZ+IqLR/dzui6DY4ou3h2FDGgKqQdmOLfdMyHNHvqlSXFLGnrQy/MAA8C3ZardMkYOigcUKGOQYE2GvRr/fiJ2OzOqwzpCNJvmgqWcZVUr8RqYDJko/qZNFtGwB1aHcMbxYQ5PBMocd4aAZSD6r3uX6EsMqzaxvGLpSplRgZaMFrwxwSW1N1zpIz3awgN/nyNL9Jk7iW2+Zk4QNqgXj3nPDBL62o+JJQzCM4b9qbWpTyMvhRoBMCmcYiXdvLs8/9tlKEsCJhC7E/6zB/RBYjBtPbkx8uIzRogp3t539ZY/PwZ8qpdfeDnbYmbD0YVjHoVzWee26Y17dmq/BXNkeq3JBwZddlJ8H2GCnVFnqeUi98uSXknIHy58LZwuWBUzpmlEokhgi3fuT/bZJSdwmESGc3MAR0Rhz0cTerdNh58yq4NH3x/2K2329avLhgg/aWgA3OtqhFNFgDZz/BfFhsSfRmDNIXaQAfNA76N4XbsKjv36Z/sG82cTbg655OsOhykStcdgOX1TD/X7rd+vihzFIjTJ4s7wZsuzuwfFE8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BN3PR0701MB1719; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1719; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 4:2zBQ7A8eWOhhIWlqetrilWETTssjPTAel5W9lR/EqMF2FGVkujUYf0njeCIBoaSNzYvx4Vh6fM/5VX+j7cBw0hbsYim2PlWMHDK1if58tYv5/SdPRmWraRGnnM1l7FqLCZ0K3CCXolYsepkc2fFmHWpqJNw1AlambhOJNdujeIWsvoBf8n6MiHO3V42Z5cChilqejyOUD0tdPK/5KpT/UhQgSQGyryTKQ4PQMW3phvUsedU0+JTYa86+U3QPANfLfeeeho4oVwF9Gm8sU3FFoL2gqLamIOpLYcFIHX322+ZX4upGJKYIZFCRpB7njZytXqMxMLr76E+AYieOE0fWfzjdazG3wzSUXTc3czT2mKgwf7wJ/6XkSr68OTQfhVew X-Forefront-PRVS: 09669DB681 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(199003)(189002)(81166006)(8676002)(81156014)(47776003)(66066001)(36756003)(92566002)(2950100001)(586003)(2351001)(48376002)(76506005)(42186005)(50466002)(4326007)(77096005)(3846002)(6116002)(5003940100001)(53416004)(5004730100002)(105586002)(97736004)(2906002)(5008740100001)(106356001)(189998001)(15650500001)(19580395003)(69596002)(101416001)(110136002)(19580405001)(68736007)(33646002)(76176999)(50986999)(229853001)(50226002)(5009440100003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1719; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; BN3PR0701MB1719; 23:tBqARdPa+/csH/N5WFTtEvznG9uLBXO8fcvsHxx?= =?us-ascii?Q?g1FmmbpVLQeWwgcWlB8XUGqAU0YONctF41d7Ebuh9i/QLRjobJhsXd/pT5Ik?= =?us-ascii?Q?U7b7vnkgxeyRt3XnTs3jbA7amItT5oVp31WgccQY1McL9ufZbpPuiDjDSsLP?= =?us-ascii?Q?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pIdFTIMNBrBd?= =?us-ascii?Q?WrgPvKNYYTEazlT0YLZ3jNC/rEp5G2wEsX16GlFTbvlEVxG6qiIJI4K/hzCU?= =?us-ascii?Q?g17Ox3rscvnltl+6gPNpOgPU3LSKpDFSYUSNDZBPfZBD+cJA7gLj8Qoxd3t9?= =?us-ascii?Q?hTQIfMMi65Pno3wc=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1719; 5:AnVBWBMdeayaD0rRRnRmM/oveLaOVbanSXdVCUSz7SeLQtp73ERXAFWSQbCgHE0h4mGCz5uVTtl1vPlm1FBYu03Qq8PRcGntOBqlPrfabjbWs1tZBThayV4HCkIQSXkHxMMRNJds8TQIMwb1+Go3XA==; 24:J4XAqFUwQtzSuFDvsmNWBeYemcM0fhhg4GHlBfU/01jYitUqy2fDqhXONwH15fkYYMXqwzhZEwoOHmIv10Z4LA1p9voMWeKI52t0RLq6Lto=; 7:nI5m+w6S1C5M3hhYHge+JDxlt0Up3iA96ly+EEMJEu3CPsUrBFZKsXOYOlMK82yRTwqaCEqVZ5McNpC8+ShwOKB2THCW1Ov2PA/94lNnALMVl8ERoLOvzhpopjSDyLY6CWkCwkpRrhx97BJkS2SFH8IrJQbdhaeAzmx5sw54G6Js2x41W4sKn2G9BXrXjfJ8Cq21QAfaydc6awtFPbQc0NvyhgaQfnQih2x7nfIRu1g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2016 16:41:26.6808 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1719 Subject: [dpdk-dev] [PATCH v3 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: Tue, 07 Jun 2016 16:41:31 -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 45bfc13..5d28eea 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -69,12 +69,47 @@ #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 void nicvf_interrupt(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); + } rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000, nicvf_interrupt, nic); @@ -93,8 +128,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