From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0084.outbound.protection.outlook.com [104.47.36.84]) by dpdk.org (Postfix) with ESMTP id 8A5C57D7A for ; Thu, 31 Aug 2017 16:55:58 +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=gfwAbQ59uj7OXI7KV94dMEWibcGhxbvjh0dy12nTy4Y=; b=ZDI6fsRWQ6NsUWYJ1uRobdI/cytZv/UmJ/MR45YxDpx8AvG3I8wkU4bDVATi+eh7xIm5v6CJyxo2yf3bPGMKZN72tipWEQq0s5MXMdNb5Zry/C1BMz9IZG7miFxQxK/4kAWNeeNze1rG2N58EkmoNsUEORtIGvj5BHcwf6QrnWY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin.domain.name (171.76.126.71) by SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 31 Aug 2017 14:55:53 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: ferruh.yigit@intel.com, santosh.shukla@caviumnetworks.com, Jerin Jacob Date: Thu, 31 Aug 2017 20:24:25 +0530 Message-Id: <20170831145436.5397-16-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.76.126.71] X-ClientProxiedBy: MA1PR01CA0109.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::25) To SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce0d4585-c7b6-40f0-11aa-08d4f0806187 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN2PR07MB2526; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 3:OO8NhrK+i37jCIpyc4IZYmkInWf521sYhKcL7jwilasRYAivjUW6+SwwEoMw6WZPtz63sHcbSgF18QuYLDwDAksRQb3RTw/bc+k53ccvtQ8YrD0OSCv9aZU4nB0F+n55+Cr91bdTbpghcKCTI/kmki46asZic1HxpE8T3ofY0k4GDVYSkN/iQLf5bib0GUv8QPBBCt7E/2yxZep6kYh5j503zuBbAdZgmLI2l4vUaIQ1jACkSlskampTYW2CcIco; 25:e09Yx6exjczgSneMNsLgtZ9tbdzy53hqGy+3c1G0FSHnUWmgG99OqjxIefGeHiTGHIjEhz8cPZvUFaWI+OTLXLYti5bT+YoL4sa4i1jtghem+KLoXhmMhz7JiUyScBrojS5G1RZ/VNVE4DRXMK4iniXzmA7mUg7MtfEx1/Txhwt6gkB5F/G+ps+4FmMGIa6exQeX6mQrCdmbVa84ztlnQunJwj4/gAPqqRU4pHacYoRt/8Cqk/GB3YFxDdMA6TXrMWaTA7ceplP30Eu+aZc63vfRyQ4PHqu48Fcrs/nI0jGasSET4ETOfLHlgXX2ELpFdpOaz40dfRCqMbC/ZCAzSQ==; 31:nghDp0ZflB7Bx3+d+7OL1hyg0QfrICh2PZl+K5n3ZRu/+M99tqMWFtN8PvSWeEyeQgX8i/wZA6aavDi/H+qfVQCsFuXwZ3dEuugiN2GyZ83NZ3pA3Puk1TjhH2l8vgS8ycQP5zC+Slvfo1Bp9gvvtLnlSa0LgRlv3tr69A1mTbdmrV65z23DI0Jw423EtQOpMN29TKeenTIa0JajZWgbBNyWesLirR+uw3KpVs//yIE= X-MS-TrafficTypeDiagnostic: SN2PR07MB2526: X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 20:J7okU5R3CFD2Pve7tuKDUk8vYVW+D/2+JtcEnXJ3uL1Klh0vNCnEdE1gjfLtXCT0G+msQ+Djx9pOzP9oHwUJ7HVd1TLfy5NrKkI0XznaKGbcPMdNUg2Fre0lWHBJ5/wlcI3DCTT/a7+vr+rmW+zFgeJePDmBRunlfgrhQJDoSuf5mY2etfiCMbAzaT1qXE50PywKz2tJCKft7cJ0z+vJHxl/VR7BBvIgBLidAGYvN/1GqGogA98jv8/u003HotBLz0EOWN5hQ2AR1X3lqLd7BMMvNn7rN/KfMSiAvvhsfBpTyPVHzisTZ8b5godlsPlW0eKD4sGNY+qGH8YZ29imf6rmyCSliRtVxK4Rf8wT4WDzwAh9LRA4V4XFkjOwvK0bmSF833gRZSOOWuWwaHznL9Y+wIpv1gWFyIybLZM/2CEOepHSuhHfCqeWS+VWdAdniVfOJoYt1egueUhgdoE/aDiPTssYZ0zOb76NbJynsMeGCVr7UrC7OhSQBxelKSOscdoRK1UvQe47QTiUEWsXtWtGCxZaINdbaVZf+xKiihUUCYEYyXMBx7iSsfDAXnRloiwxxaeNEEJc/BA0y0MVGS7WPOwjHonHn7/McAeHVFA=; 4:eb1cxyCOYHm9h9JQNXCGOrzYJzPUHikxNCpvbX9hb4gSdHQLUfoaKq7nEUeQE95xaXwgmyZ5x2xeIFKOEqP6P9M3YypoSNrbcdO5huWsrEhGaSWy+BrmK54wGjL4n+M0r2JaU8hq3TtyyrlwwyYH/KNdBGNMLf3/we+VGIOYWE7RDzgwWGgbaJD1WQ2i/snCb76XlCSAgMWmdqRwvP6gksRW1n3h5d/hXWMb8PAIUMbTQYyy7U4lsD9k5kJiZuAm 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)(601004)(2401047)(5005006)(8121501046)(93006095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR07MB2526; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR07MB2526; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(25786009)(1076002)(53936002)(3846002)(6116002)(478600001)(110136004)(72206003)(7736002)(6666003)(107886003)(6512007)(305945005)(6506006)(36756003)(6486002)(68736007)(5003940100001)(189998001)(50986999)(42882006)(106356001)(101416001)(76176999)(2950100002)(6916009)(5660300001)(2361001)(33646002)(2351001)(2906002)(4326008)(97736004)(105586002)(48376002)(50466002)(81166006)(66066001)(69596002)(8936002)(47776003)(53416004)(8676002)(50226002)(81156014)(42186005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB2526; H:jerin.domain.name; 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; SN2PR07MB2526; 23:jkaN0/1+nMoH9z9AdsRWLTCGjqPBhf9UEN5pYK7bU?= =?us-ascii?Q?EZqnSWA/tmbjfGnnYD0dR1CDdxlDXGHyEx2Stp9Ch4WwTZYb+1Esn3vrGmPF?= =?us-ascii?Q?9aZsoaWZdDK09s27TwO9TCGMNSVYCbFPhqiLP2Dt+8NDh2G0eL/M0mROif7A?= =?us-ascii?Q?cDIHmkOkgnuVrASFT+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g: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 14:55:53.0054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2526 Subject: [dpdk-dev] [PATCH 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: Thu, 31 Aug 2017 14:55:59 -0000 Mark Link status in features. Signed-off-by: Jerin Jacob Co-authored-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