From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0083.outbound.protection.outlook.com [207.46.100.83]) by dpdk.org (Postfix) with ESMTP id AB1FFA252 for ; Tue, 14 Jun 2016 21:07:44 +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=JB4L53iTyf481euz3VDuOzL/TYgDV7jpsJ5e+7F7oaCPfQItXNhvYE+0ohUWq3hvoYefMRCOe6pnZsxcNWaQj4gAveEoGdLZTsUg3k1zg53hjzySJ3RlgQCVnz9qLKNJCr01q4Ob3Fruag4YjD7CsUJi6aUHUeqrEoCQicFJkgE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.caveonetworks.com (111.93.218.67) by BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) with Microsoft SMTP Server (TLS) id 15.1.511.8; Tue, 14 Jun 2016 19:07:40 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Wed, 15 Jun 2016 00:36:24 +0530 Message-ID: <1465931200-23912-10-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465931200-23912-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> <1465931200-23912-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: MA1PR01CA0040.INDPRD01.PROD.OUTLOOK.COM (10.164.116.140) To BY1PR0701MB1723.namprd07.prod.outlook.com (10.162.111.142) X-MS-Office365-Filtering-Correlation-Id: f12a9729-18ce-4ec4-48ba-08d3948729e0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 2:luJR4x3bCoQdbc1nKZovCUGdwlRfqdYVcl2vE6/6VCyZCIJozd2GfdpLhPlsER0iJ3DOAGelib5WEM7xUBCr9ZkzG32WJmqRQH/AV2v9VmGoW/aShlmc4cDj573gdY+VLZSlh1iLm9SuPh54POFn5AszD1l3gI4xyLgBRjyzZAK2PiktzdpTEqO7gE3oEQsM; 3:JkE6i+xJAlcrypY3JKNAnkVN4n7fFitWiVr8C3HagQlHYpIf6EJF/2kZP6i2qL1dxdHYkJ4UA3b7u9ZO0em2FNRWCGWzC02CpoP11iLQvcZn31qeyF0od5BFWuQopxtk; 25:vSHblPktklprOnUwUshO9BWeoVK94DGEKTEJZ1Gi0oJqBAGG52iFLABKWzpgDqu87FF9ClSOMwkRZ8pECKD22cpKY8XwH+zLHpsyEbrDlTr9ms5FnmmcJqnYhD2RTX5ArDnwV1LauvQGpmzZncwytJw83i95Vt5fuUjFB6AUqZWj3ri1xz/caPUu/s3yXoAgOqAnhC0scX/TFF4TcFheLPhaZswD00Bs5UOEMNt2JeRkE0ixISVs4au8ZNbYx6NPr3kLEX2z7eK6pfDbLZbDhyuhHgRDlP20GUQVbRiNf/7aeRUSL1sKupl6BpMfPVdkPPQLijb791w17FXjItjtT3SCvcVjbeJo+4lbrjoBnWLCxM7C4SpbTpApZHk89kKuoBO6EBzTtgAvwjjXK28Ljq/o1n1ACwpc+FNpjd2JRQw= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 20:dOj7DeoUERWqBdqu0jw1kWuyZZ6qN68vh+oVk8I0EB/Wa22WzqWujWfkHgj1Q8ts7AQkWJJXsGzUr87oTErCcU+V3J8b6T8Ic4yTCqu1uljUhzEPhovDegLOdr0idBrYKExBtuRgxEGc/MV2iu9Xb7QVn/S+hiaMHZsVtlOlxfTXzqWshqc0+Ku8ZXxZMaqQ7eQ5Sgk5dZLSXwfGECLoU5PBpQPkoaBzsDnGaiKk6u+fvPox1DubE4A9z4el4stgTySU09M70CCLjrxTSse2iIPTZ2vZBTpFmqJmB2NsuuHuONr1P/s1FtNYvopfsKgNqSxqgmqmTtGW6E/n/Jr1LwCfG8utfmQSbZ4qDU5jCcM8jIOR4/QlIyN16xmDvyslKnJRjRm0Svbr6FzB1eWjQIt+52BqoBeBpZ7xMo7MXEsjU6yPzc3I/ebwoYVb295ZNSI4qbmeyHEsqGJKFZ8+bE/LXH9rDYIuO4r8l4HjBvj35v+g4t+YKZXsHgvf0YJ89lnv86S/tGWWwUsLwCvnISkTeEAj0K1x0d5HAhSsU72rczxaomxGz/sgtjNmJCa6qoKzu+OoK3dHFZ78jZEPvLt+50US2fWu4zfWuTl/d58= 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:BY1PR0701MB1723; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0701MB1723; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 4:CqvhrDKL77Kqr3dvQvy8+7Gy1INCBXQmUMqyw5Pgu8Xrg8N1+LjNvrlsr1Bp6QBQ1HUWqf+TFEvOlLSmwGIvIzDMFf/3Hr6JDQ7fiQJ20D4kTPrEdVwqlQWQvj6c6MEGAORSoFFYzk3Zg1WkwdehvABh3+1Ozqno7bBlZpxyMOVj4zuE0Blx7uomcO8tSBHBo6uDff8FZGFQA55UL/MEYReaoIE5qZk7LGoPCJykjcRv3FJH3SqA0a6+hP0R8yoPEzqwv3c7dHVXzdJBmwiHR4NhR/uMt0BdZxGJlSYU18PnREgdbNrh01g/V2WGZ7c4AQ8htgydTnxHA3GuNnIk+eD4ZY2dsGUhL75kQohLVLz9nGzFzGxS2YIMiE5IyVMInveKBv6i9Z2brV2fG6CVEIzRdw9to+mxPHg3NaFBkMg= X-Forefront-PRVS: 09730BD177 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(69596002)(189998001)(2950100001)(48376002)(77096005)(36756003)(15650500001)(19580405001)(5004730100002)(19580395003)(76176999)(5009440100003)(50986999)(97736004)(5003940100001)(68736007)(110136002)(92566002)(101416001)(5008740100001)(81166006)(8676002)(229853001)(81156014)(66066001)(4326007)(50466002)(2906002)(105586002)(106356001)(2351001)(47776003)(53416004)(76506005)(42186005)(33646002)(586003)(3846002)(6116002)(50226002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY1PR0701MB1723; H:localhost.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BY1PR0701MB1723; 23:xdug+wcMMRx8AWhfv7DAgj/A7243Q8NW3zVJLG0?= =?us-ascii?Q?w/YcqXCoLW8R0DbQx1EEJnS780cjKXCXx2Y8vD6HDMpZ/lrl0g1XV2O4HF5k?= =?us-ascii?Q?65UOwkZkpC84Qztbxst0YmEmFbM6dduavtDh4r8H0j/zrAAF+aRf+/ABul9b?= =?us-ascii?Q?dWbJnEB0CYrl2r1Sl4iFbGPWF6et/Kug8XRmk1dc02qbQM8GbOmKN1FAwPRf?= =?us-ascii?Q?VBGAwBRvjyUxe5cVqJx60SV4jUlTmndT30mt96nIM1IS0TEcYjn92JIbSozT?= =?us-ascii?Q?3aM6PXBTQK/DTa9K6r8kJbqEpLW8pgAlV+MBZ8hbfAcd2KgXPULpIU73akJ6?= =?us-ascii?Q?g/9CWo30ern/ilpX6eJ99Czc+JOouH7J7BMWP0vgD7+nLWQH0D5966Zzi3bl?= =?us-ascii?Q?8CpRhdbpV5SyH9N0Blz3KtF3EOrJkUGYfyngo86uuVDoB/DcKPNIyO2cdxWn?= =?us-ascii?Q?gaBqXUKEA7l1LKLi9y1wyY0swTWALSyVuq9XMASZ65AeBYRSNdXkkvdtZ18H?= =?us-ascii?Q?eEcrcb2M/zhfYF+B5rNuCZNZwaBKPHk2ysmFjn41JLjBwbGqdmTtJkeD5t/J?= =?us-ascii?Q?FBPeupEW97QM80YjAJ0O3sYjSfhUzD/bRRQlxVPAile4eqLxbOQ9fE3mOWaq?= =?us-ascii?Q?AqGtB5x/BVqa8CmXHotJFyBeTFJ9auQ4hbaZUi2nOTWmVlgVhN+cjM7SGugh?= =?us-ascii?Q?NWxagVtWMg4NOwePBzwVsgApeU5/n7+SRzqrNeAYOySGxglISl/F9fnijsrH?= =?us-ascii?Q?FBIpCv1qJIVF0dj1NIxBC2YmXb5EgdBxNp304KptNE3EHoxXnAwnvCnlkUaQ?= =?us-ascii?Q?lVC4kuNIyb2ct+7A7AwJOBlK5uJU9T+674hO69tpymjDZw5sg5Obn72i/WVI?= =?us-ascii?Q?hcwEpb1QP4b87TNUGI4UVqnBdOC2We0l5XlVwasRbLc16q3q1RvQIBq/ukPq?= =?us-ascii?Q?3VB3miX7i1fbcZHYYdUoB2FMiLRu63Pwlu9aGNKPkAhsYAV220iR/IjQeX44?= =?us-ascii?Q?YTm56GlMqmjL5h+lhHPQpySuTzxsTCjMYqqyRpscYOGJz9cTDD4QjkJ73our?= =?us-ascii?Q?rcKvibcGt4GHUUSs06b6psVzVPotQceIIMWBxjBdaSurbQAJfBGdaAosY4om?= =?us-ascii?Q?ClOkuDQmFZftGoDJ6WYq+YISPtZPP1IfSTPNsPJHu3xr0MQTgPWpnL40Zy1A?= =?us-ascii?Q?JxmJl1Js07LlHr23LRloO5ZBljlhq2dT6Kv4e?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0701MB1723; 5:yErsutJqH5g8r0Er2rHRsMOXIRQUCvAmd7KJFyaKMeu45QS6C4scQo0ZFwtYSJQe/WjbPaM89R4+us2QCNkDMD17X4d8obapFqqOl71axrBHSXYYWUqJlReR8lk6eIsVgtsQYRyVbq1ss1ubKWfDbQ==; 24:boWr8GJ5whPHb0IzJC+BU+v6/ZGipe3V6uZmi5FcMe2VHdQbNwzsOh/RKS4I0Ehg020aoZQrtyD6bYAN1iEoJ86CM02+Ac0cOTFqUZ0f4p0=; 7:bAqs3q0d/f6Cy9s40KRrQNV1i84HJrOYH+FFWxjxePio402zqHBze8/HPBdu10TFE9i62C+Yeu7wFn2KBAGfXnZPGT1JI11Ua1hdoBBbWo3tDxId2fOYOdQdEHxwu84k1y9jqjORXVYZUXFUUPUVi2QIzC+n1eDrdyJsqD1zraz4AkDZWBtrnL5tLiIEXk+eYpgMYrk+E8e5kE9dZMtb/A== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2016 19:07:40.7337 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1723 Subject: [dpdk-dev] [PATCH v5 09/25] 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: Tue, 14 Jun 2016 19:07:45 -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