Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp179792imd; Wed, 31 Oct 2018 16:56:09 -0700 (PDT) X-Google-Smtp-Source: AJdET5eCAOlzmnClj8xLcd6YBe6XMLsVTWy0ja+45+vhzdjHYshosbrSE4aPpe6rnOuSJe0G530J X-Received: by 2002:a63:a401:: with SMTP id c1mr5026513pgf.403.1541030169187; Wed, 31 Oct 2018 16:56:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030169; cv=none; d=google.com; s=arc-20160816; b=v3sixn7N3crACHJ4FX0KRVssbYgFg59fVmz/FvT3P9pr9dTwrugi8qwYzuyG/uG4tc 2K2iAO3Uo1c7UzVJmJhgaOi1CWmPPtQFTdqn8dLw/24HJfUl2O14dhsE9SnX1Z0K+mDw MvmIKN6WElDVeVUJMSeWOYDDHrJrXVVxVp/ekr5Z+ZCLeXOOiUaiLSkaTb3sPK962BxN Ow6ezO8yLZM7F8YyYhlcmcttLna5g/gAto5qSogSqXtA1tJzQViEoIYhuC8mO9qnhwys zkAUxw6uiUYzvU9fkPUWcm04WaQdNMEg4I+Ph2lMfl8UOqEtleCuWXLR5WkfhN+rNsP+ byLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=7uZt2KxfOyqlsGHgu948bg8Ki6Dtd3773/3jVn7gKZA=; b=uizvOoTOBPHuZ8KSZiGDA1qw6rqfzEVAInny6RVNpf5AhAI9UECNc5fkFzdszBqZi3 cRWsLBCcINgHVWVZDAyK7rEngWzlySCy6CiEDHxTnAbO6j/Lgkr/zvB2nQfjaMUGjOXS CkM1TgYqzGVyJ5oKBtp7BJlfPWvPccj4Q5RJEMiB7WqdXjSu2Qail7vZH/1R5YlYu8vJ vV4P+XPbkjIDvpgiAJuZvtQGNYGxq/kXES+mqSgVJ32tynwDORu3CIdLgwvdhhj3kPJ4 yx0+MMl6hlgtOaIZTZHmCCwnLCCaei8bipcoawGTmMH5JEw1Dm411nGGvN+54V4cWYfe EH1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T9N+IX8f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h20-v6si1875310plr.343.2018.10.31.16.55.54; Wed, 31 Oct 2018 16:56:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T9N+IX8f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727369AbeKAIGE (ORCPT + 99 others); Thu, 1 Nov 2018 04:06:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:52622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbeKAIGC (ORCPT ); Thu, 1 Nov 2018 04:06:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6CFF20823; Wed, 31 Oct 2018 23:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027152; bh=sRHdMLuRL0azgA1ZgiD0C1h/NEZIHaVdZ+3wxv0vcdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9N+IX8fb7pX0yR9oCxFg82wTQkrUuo/rcrZ+oKA/c+dAZ9Es9Ftt1TNJ5UMt/oqx 6TG13am9vynrJazrpQZ0pf3mGYXpauskBet8rJCJgMlMcYv6gywfmEA9vSkXJ5Y4UW XiZu+zleMKcSWB+g80P+5026bIJK0XNplwfvxG5Y= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ryan C Goodfellow , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 010/146] nfp: devlink port split support for 1x100G CXP NIC Date: Wed, 31 Oct 2018 19:03:25 -0400 Message-Id: <20181031230541.28822-10-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ryan C Goodfellow [ Upstream commit 5948185b97fa1f83d7855e638a72982a1073ebf5 ] This commit makes it possible to use devlink to split the 100G CXP Netronome into two 40G interfaces. Currently when you ask for 2 interfaces, the math in src/nfp_devlink.c:nfp_devlink_port_split calculates that you want 5 lanes per port because for some reason eth_port.port_lanes=10 (shouldn't this be 12 for CXP?). What we really want when asking for 2 breakout interfaces is 4 lanes per port. This commit makes that happen by calculating based on 8 lanes if 10 are present. Signed-off-by: Ryan C Goodfellow Reviewed-by: Jakub Kicinski Reviewed-by: Greg Weeks Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/netronome/nfp/nfp_devlink.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c index db463e20a876..e9a4179e7e48 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c @@ -96,6 +96,7 @@ nfp_devlink_port_split(struct devlink *devlink, unsigned int port_index, { struct nfp_pf *pf = devlink_priv(devlink); struct nfp_eth_table_port eth_port; + unsigned int lanes; int ret; if (count < 2) @@ -114,8 +115,12 @@ nfp_devlink_port_split(struct devlink *devlink, unsigned int port_index, goto out; } - ret = nfp_devlink_set_lanes(pf, eth_port.index, - eth_port.port_lanes / count); + /* Special case the 100G CXP -> 2x40G split */ + lanes = eth_port.port_lanes / count; + if (eth_port.lanes == 10 && count == 2) + lanes = 8 / count; + + ret = nfp_devlink_set_lanes(pf, eth_port.index, lanes); out: mutex_unlock(&pf->lock); @@ -128,6 +133,7 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index, { struct nfp_pf *pf = devlink_priv(devlink); struct nfp_eth_table_port eth_port; + unsigned int lanes; int ret; mutex_lock(&pf->lock); @@ -143,7 +149,12 @@ nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index, goto out; } - ret = nfp_devlink_set_lanes(pf, eth_port.index, eth_port.port_lanes); + /* Special case the 100G CXP -> 2x40G unsplit */ + lanes = eth_port.port_lanes; + if (eth_port.port_lanes == 8) + lanes = 10; + + ret = nfp_devlink_set_lanes(pf, eth_port.index, lanes); out: mutex_unlock(&pf->lock); -- 2.17.1