From patchwork Thu Dec 8 07:52:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13068064 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C18F1C3A5A7 for ; Thu, 8 Dec 2022 07:53:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbiLHHxM (ORCPT ); Thu, 8 Dec 2022 02:53:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229810AbiLHHxK (ORCPT ); Thu, 8 Dec 2022 02:53:10 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DD6E2F028 for ; Wed, 7 Dec 2022 23:53:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 72AC861D3E for ; Thu, 8 Dec 2022 07:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58442C433C1; Thu, 8 Dec 2022 07:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670485986; bh=QlwY3FKepiz3BEO99zQtXjW27RIpgBgDb3kaUUm7j7Y=; h=From:To:Cc:Subject:Date:From; b=Fbp97HSfTR8rCOFwfsyC27ECZVV1A/hNoskvwaonuycKAwJB0zMfwpQrG+Zjl2bUR fGX8UlbcJP7YncV9o3BsOag3MR+B2Jz6zy4cwLf6vAJlU4tzCIkkZ26dofWCVHjthW kmR7+un4eaL5WhVogI92Z9GAHnPUmlYAE6iDU0iCLfKNXj0KnzHzWr/PTotWferaba nOLp6ZG0Xzz/maHSzlEFDNj1oxLPPiKRhXaikZxC6yw5l5G+9XbLDaba0ujSrS1Th0 rklOF9Nj/uoQeFL4+Kl1+gfdreG6BkgS2VPiNF7PjFzXh+pSo2Elmp1aPQ7Ps2jdZm e0Q5PtjTMy4qw== From: Leon Romanovsky To: Jason Gunthorpe Cc: Dragos Tatulea , "David S. Miller" , Erez Shitrit , linux-rdma@vger.kernel.org, Or Gerlitz Subject: [PATCH rdma-next] IB/IPoIB: Fix queue count inconsistency for PKEY child interfaces Date: Thu, 8 Dec 2022 09:52:54 +0200 Message-Id: X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Dragos Tatulea There are 2 ways to create IPoIB PKEY child interfaces: 1) Writing a PKEY to /sys/class/net//create_child. 2) Using netlink with iproute. While with sysfs the child interface has the same number of tx and rx queues as the parent, with netlink there will always be 1 tx and 1 rx queue for the child interface. That's because the get_num_tx/rx_queues() netlink ops are missing and the default value of 1 is taken for the number of queues (in rtnl_create_link()). This change adds the get_num_tx/rx_queues() ops which allows for interfaces with multiple queues to be created over netlink. This constant only represents the max number of tx and rx queues on that net device. Fixes: 9baa0b036410 ("IB/ipoib: Add rtnl_link_ops support") Signed-off-by: Dragos Tatulea Signed-off-by: Leon Romanovsky --- drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c index ea16ba5d8da6..9ad8d9856275 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c @@ -41,6 +41,11 @@ static const struct nla_policy ipoib_policy[IFLA_IPOIB_MAX + 1] = { [IFLA_IPOIB_UMCAST] = { .type = NLA_U16 }, }; +static unsigned int ipoib_get_max_num_queues(void) +{ + return min_t(unsigned int, num_possible_cpus(), 128); +} + static int ipoib_fill_info(struct sk_buff *skb, const struct net_device *dev) { struct ipoib_dev_priv *priv = ipoib_priv(dev); @@ -172,6 +177,8 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info, + .get_num_rx_queues = ipoib_get_max_num_queues, + .get_num_tx_queues = ipoib_get_max_num_queues, }; struct rtnl_link_ops *ipoib_get_link_ops(void)