From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0088.outbound.protection.outlook.com [104.47.36.88]) by dpdk.org (Postfix) with ESMTP id 7F2741B231 for ; Sun, 8 Oct 2017 14:46:00 +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=mMT8CTrdg9IUB1nANY5k0KQ+WZ5A2gb0BNdvUbl7D+0=; b=CY9XnS/OonZGXU858U3BrAoqj4yQ5N29UhxATdwpRM6I1I/MyCNnJtdb7COKFTcdfAZFIj0bOCFSjTYpC3EQKW62xZYz1hVkEe/zL7Jz4q9MPF1QN3d87XS/Q8mj/Ggph4rmi6hFVL8hxjkx7KzVeK5ttRuBUa9z2z3ve+/anv8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Sun, 8 Oct 2017 12:45:57 +0000 From: Santosh Shukla To: dev@dpdk.org Cc: ferruh.yigit@intel.com, jerin.jacob@caviumnetworks.com, Santosh Shukla Date: Sun, 8 Oct 2017 18:14:19 +0530 Message-Id: <20171008124430.1866-16-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: MA1PR01CA0113.INDPRD01.PROD.OUTLOOK.COM (10.174.56.157) To BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4172a09f-6ea1-4510-b05b-08d50e4a86af X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR07MB3089; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 3:MP3btPeglmDOCS6UXUY41tmuCR2DlGbHHcVClVfDAcP42ly/O3XDiZR6RKESXy75VtGdWdVr4P/JNSiylYuBwiWEkNG+GdXM0JbfEwnnXv0Lqd7p0YjIhw8WJCg5uDQrGRf2967OYbIReK+YlXHcCAkccjx2chyc9y4mBCt6uhD0lll5Eaw7rI6dYlD34InjgQ25+8kIFf5t/lHascdW76gZLhyhR6K9OU8HvzeP0P/Q8ZodTnyIJVUwA1DgNYHn; 25:UOFUnM8ujXa/wujAuQQW0ntru7wHcu/9yK+WO80nmNZ5VFEKVPHYufKf+0vcFQGnUZOxXUpnz0Vrhh751Cj6vy3HJz11GtDCFqUUmUfEp6ZWFkV8aIHtqZwi8exp7bbQR6ht5HzimEBurihPoaXXhsx/Sc393HyrmAuKxEE3NXguZAwrsO5+HnXbeOID6Bi6gqPcVL2Ha+xfXcxeynRwBgf+WoePUgLFqXLC1dkyRG80mbg0diWibV7ml9V2AzUIwXqCHm6VuT7PYgqCIHIVhn36vT2ADP1gp9CGfZaBT80sBbVVYhx5eurC9vKBtovO4kuMb8HkuoFEW2TZx9ISrg==; 31:SQWT5rFj/nz4k6fIRSUtoIS6N3PSB8u6fFZMYG3Zr4aG3MK3YnNA8Zj1jj35wOwDQmYS7Xe3vjXGmWSfoGl584BJhm8ZEhAEP730TTJ2xAGjGOtmorHTdYNp7lQw4ICsoWBP5qsV5FnAAb6b5SuNH9sCXx8d4V+S53s/kXuIj5H76jXLjyQqkwzuhA9yUhCfYhkPYCeXWvRL0XU5oWI+Lw4S/t+dYiv7QRfeGAtkRsY= X-MS-TrafficTypeDiagnostic: BN6PR07MB3089: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 20:8Gf2HrEBGA4JSSO0EHvQA1XXddbCGLP5L8aHc79ontyF+RwvIrApyuSK515kTxSG/1h352/HCMsZDzNqynAK+ca6sYaFiYg0NFKlMNOfRPRgyvW9FT5fRmQRoL+SIlzJ4TJpMExHMgHoboEbVwxKQMIW5NJu5MdmBdSYsAAeWgkMso9wr7zrCjSlDQQGnvmH1IpJlQZaALrFi+ab4ryNjyktMWjILJyQhGfeRHflLk5kseZmCuhlM/KTlgTgmVOrr8N3Et1Hfbb+iukxhPwvxKd5Lo1RK7Z9t0xtldRNj3IAL82v1OA+eW1q0CjM5n3Jx1jwglto2CFLXFTnNFhp2YTEk975kyeWxVl3pC9m0cEyebc57fkUcwIqNVGLAyxxWwJ8oKO3yyGgSPufiIGk60raD+50ez7qVwSOxYSnmeUlnydcIa5QK9TwtAK0c+729UWXB7lGmvAbHjgtyY4doXubpviW+EDq8wzIfp2jVNk7AoscDxsjSaiDapiR720hZJgcH2F788I3jRtBzkP9Da2ksr+1T2UBpp4X1OVzPm0vWYkud71OZZgWoeOqqNRzYj9KfAJuNpssQWlyT5J/pwC8K6sBlzrSxJ86ZXLeW4s=; 4:A4+ytgfvrci3JO35LHb+ly+1OzIzEm01NfRCglObmjhtDfZcRmO9tAkOL777lctdwh9C1/kUMU6SzjlTOc7U769pKffWysQuDRa4qkW/uzEgDZkdNyl6sc3EY0Mc5hqmdtaI8YneQKZ+B4ewmz7/V/fBGtMtU6SXOlzfStp6WpPI6rCnq1DxgibB8cLekU2eH+yDTvcqDjQ80yN293bXCMJk4TnjMhbEf0jOwBn++wH0b1teuZIj9kbw9qDS9f7C X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(6041248)(20161123562025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3089; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3089; X-Forefront-PRVS: 0454444834 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(376002)(346002)(199003)(189002)(6916009)(42882006)(81166006)(2950100002)(81156014)(8936002)(50226002)(6486002)(16526018)(6666003)(189998001)(16586007)(316002)(6116002)(1076002)(6506006)(3846002)(7736002)(305945005)(8676002)(106356001)(105586002)(5009440100003)(53936002)(4326008)(66066001)(107886003)(47776003)(2906002)(5660300001)(6512007)(76176999)(5003940100001)(50986999)(97736004)(25786009)(101416001)(68736007)(48376002)(50466002)(478600001)(72206003)(2351001)(2361001)(33646002)(36756003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3089; H:localhost.localdomain; 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; BN6PR07MB3089; 23:7EEXItJURRKiH/T4psqHFQPA+KEdbtP83DPdU+5pr?= =?us-ascii?Q?lokf+1krVSSFYWOaWhoAh0cOkitOmlgr7WzUvoUcdc5bG82XUXMT4ZTc6J6A?= =?us-ascii?Q?MYDEtzVhxuhsIvjGXQGkZ7NhL2TiDHJnbmJ4M9ptr4jBmrkp6/vutuWE/x7m?= =?us-ascii?Q?NJgG/JoTVP3xP0uvRLYxHM4+6o00VFvu+L/iCgsI4s0bLWSLP3HQsVfkhCvc?= =?us-ascii?Q?prOJ+jrDP9L6zm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ata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2017 12:45:57.4267 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3089 Subject: [dpdk-dev] [PATCH v2 15/26] net/octeontx: add link update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Oct 2017 12:46:01 -0000 From: Jerin Jacob Mark Link status in features. Signed-off-by: Jerin Jacob Co-authored-by: Santosh Shukla Signed-off-by: Santosh Shukla --- doc/guides/nics/features/octeontx.ini | 1 + drivers/net/octeontx/octeontx_ethdev.c | 100 +++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/doc/guides/nics/features/octeontx.ini b/doc/guides/nics/features/octeontx.ini index 259daccb8..56b135060 100644 --- a/doc/guides/nics/features/octeontx.ini +++ b/doc/guides/nics/features/octeontx.ini @@ -5,6 +5,7 @@ ; [Features] Speed capabilities = Y +Link status = Y Lock-free Tx queue = Y Jumbo frame = Y CRC offload = Y diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index fde52b444..9c6e7ec83 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -53,6 +53,17 @@ struct octeontx_vdev_init_params { uint8_t nr_port; }; +enum octeontx_link_speed { + OCTEONTX_LINK_SPEED_SGMII, + OCTEONTX_LINK_SPEED_XAUI, + OCTEONTX_LINK_SPEED_RXAUI, + OCTEONTX_LINK_SPEED_10G_R, + OCTEONTX_LINK_SPEED_40G_R, + OCTEONTX_LINK_SPEED_RESERVE1, + OCTEONTX_LINK_SPEED_QSGMII, + OCTEONTX_LINK_SPEED_RESERVE2 +}; + /* Parse integer from integer argument */ static int parse_integer_arg(const char *key __rte_unused, @@ -262,6 +273,94 @@ octeontx_dev_configure(struct rte_eth_dev *dev) return 0; } +static inline int +octeontx_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 int +octeontx_port_link_status(struct octeontx_nic *nic) +{ + int res; + + PMD_INIT_FUNC_TRACE(); + res = octeontx_bgx_port_link_status(nic->port_id); + if (res < 0) { + octeontx_log_err("failed to get port %d link status", + nic->port_id); + return res; + } + + nic->link_up = (uint8_t)res; + octeontx_log_dbg("port %d link status %d", nic->port_id, nic->link_up); + + return res; +} + +/* + * Return 0 means link status changed, -1 means not changed + */ +static int +octeontx_dev_link_update(struct rte_eth_dev *dev, + int wait_to_complete __rte_unused) +{ + struct octeontx_nic *nic = octeontx_pmd_priv(dev); + struct rte_eth_link link; + int res; + + res = 0; + PMD_INIT_FUNC_TRACE(); + + res = octeontx_port_link_status(nic); + if (res < 0) { + octeontx_log_err("failed to request link status %d", res); + return res; + } + + link.link_status = nic->link_up; + + switch (nic->speed) { + case OCTEONTX_LINK_SPEED_SGMII: + link.link_speed = ETH_SPEED_NUM_1G; + break; + + case OCTEONTX_LINK_SPEED_XAUI: + link.link_speed = ETH_SPEED_NUM_10G; + break; + + case OCTEONTX_LINK_SPEED_RXAUI: + case OCTEONTX_LINK_SPEED_10G_R: + link.link_speed = ETH_SPEED_NUM_10G; + break; + case OCTEONTX_LINK_SPEED_QSGMII: + link.link_speed = ETH_SPEED_NUM_5G; + break; + case OCTEONTX_LINK_SPEED_40G_R: + link.link_speed = ETH_SPEED_NUM_40G; + break; + + case OCTEONTX_LINK_SPEED_RESERVE1: + case OCTEONTX_LINK_SPEED_RESERVE2: + default: + octeontx_log_err("incorrect link speed %d", nic->speed); + break; + } + + link.link_duplex = ETH_LINK_AUTONEG; + link.link_autoneg = ETH_LINK_SPEED_AUTONEG; + + return octeontx_atomic_write_link_status(dev, &link); +} + static void octeontx_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) @@ -302,6 +401,7 @@ octeontx_dev_info(struct rte_eth_dev *dev, static const struct eth_dev_ops octeontx_dev_ops = { .dev_configure = octeontx_dev_configure, .dev_infos_get = octeontx_dev_info, + .link_update = octeontx_dev_link_update, }; /* Create Ethdev interface per BGX LMAC ports */ -- 2.14.1