From patchwork Wed Nov 2 16:02:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13028341 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 8CE0BC433FE for ; Wed, 2 Nov 2022 16:02:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbiKBQCa (ORCPT ); Wed, 2 Nov 2022 12:02:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231128AbiKBQCT (ORCPT ); Wed, 2 Nov 2022 12:02:19 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA762BB33 for ; Wed, 2 Nov 2022 09:02:18 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id cl5so13582601wrb.9 for ; Wed, 02 Nov 2022 09:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I45FK7zcDRBB0Zgi/S0IlH6Urr75YvzqB/X8kS4wMAg=; b=Dc74jYC9LHWxvKGuw7BNL1LR4Ehfg/baudvcMA4RAD+A/OfdRQ0p2XjY7G4TME3SpM YbaFK7fpYN9pgW7x5m9owY/NBibe0CpT+SQBr/4gaCcechnIo6kY9wzyA525Rta7erv0 MhGs2hxfwqjeXjwB6ToLTU4PbfnAVZyAOTcbxuHKvqhYSwGonc2iXBf/hJMEUywEpSLU yFHmS9R5xMQDoWWMKP8IvPBc36dgPL89NGEY7Mf8GHGEi9ZKUU2s99YidzclkjJtm0Z3 sxv02l13RHWAtiUaX8TbTSRpfMXtNuJbG1KZVPEVwhzkEBI2w0t5OPJI82ILqpRHVZ0v M3iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I45FK7zcDRBB0Zgi/S0IlH6Urr75YvzqB/X8kS4wMAg=; b=QdxAT30hFObQCoNN5iSqtIeHlYgrMQhQwZLVgHTww3uRP6JEAfl/EF+HyophhUvMvv S/vgih8+pMmlML6qOTJTm7CIC8ity/51NNjJ4MGK30/YHHRAhhMYG7ObmJVvP4/+/P5E oPqR5t9/Dxm37FKb8SbSho01RWj6JwVT07CWYEeXgZS55SiQlfX7roiqs1XWbse48L9s bA4SxCDerHiAQihlwKJ5h3YAOvd5XX686lLXBUsaei4MPraGKPIotBDlQUBDNzj4R9i1 riGtn78yA2M/wG9aEbQzPhz8U9qlCLRyLkuQCyddAXv4Kpeq9pDrY7SAN0UX/gCUBwZY Cegw== X-Gm-Message-State: ACrzQf16yJv2KTnSE/U/rlJ4Ad4ZqRYiSAI7y44GuZv5HEsqwhOQGmiH LtcWpo9SFpKMfwNdKtvHmreAnQ== X-Google-Smtp-Source: AMsMyM55Kkqsrb5gps1B6nWrUx0HCWSipXZz0lRp30tsoEwU3SpkwpMuYh0hFjIeiXVbLQ0NaDCSsw== X-Received: by 2002:adf:de8d:0:b0:236:6087:e07e with SMTP id w13-20020adfde8d000000b002366087e07emr15766235wrl.533.1667404937429; Wed, 02 Nov 2022 09:02:17 -0700 (PDT) Received: from localhost ([86.61.181.4]) by smtp.gmail.com with ESMTPSA id bp21-20020a5d5a95000000b002302dc43d77sm13405951wrb.115.2022.11.02.09.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Nov 2022 09:02:16 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, tariqt@nvidia.com, moshe@nvidia.com, saeedm@nvidia.com, linux-rdma@vger.kernel.org Subject: [patch net-next v4 03/13] net: devlink: move port_type_netdev_checks() call to __devlink_port_type_set() Date: Wed, 2 Nov 2022 17:02:01 +0100 Message-Id: <20221102160211.662752-4-jiri@resnulli.us> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221102160211.662752-1-jiri@resnulli.us> References: <20221102160211.662752-1-jiri@resnulli.us> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Jiri Pirko As __devlink_port_type_set() is going to be called directly from netdevice notifier event handle in one of the follow-up patches, move the port_type_netdev_checks() call there. Signed-off-by: Jiri Pirko --- net/core/devlink.c | 63 ++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 3ba3435e2cd5..ff81a5a5087c 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -9994,33 +9994,6 @@ void devlink_port_unregister(struct devlink_port *devlink_port) } EXPORT_SYMBOL_GPL(devlink_port_unregister); -static void __devlink_port_type_set(struct devlink_port *devlink_port, - enum devlink_port_type type, - void *type_dev) -{ - ASSERT_DEVLINK_PORT_REGISTERED(devlink_port); - - if (type == DEVLINK_PORT_TYPE_NOTSET) - devlink_port_type_warn_schedule(devlink_port); - else - devlink_port_type_warn_cancel(devlink_port); - - spin_lock_bh(&devlink_port->type_lock); - devlink_port->type = type; - switch (type) { - case DEVLINK_PORT_TYPE_ETH: - devlink_port->type_eth.netdev = type_dev; - break; - case DEVLINK_PORT_TYPE_IB: - devlink_port->type_ib.ibdev = type_dev; - break; - default: - break; - } - spin_unlock_bh(&devlink_port->type_lock); - devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW); -} - static void devlink_port_type_netdev_checks(struct devlink_port *devlink_port, struct net_device *netdev) { @@ -10058,6 +10031,38 @@ static void devlink_port_type_netdev_checks(struct devlink_port *devlink_port, } } +static void __devlink_port_type_set(struct devlink_port *devlink_port, + enum devlink_port_type type, + void *type_dev) +{ + struct net_device *netdev = type_dev; + + ASSERT_DEVLINK_PORT_REGISTERED(devlink_port); + + if (type == DEVLINK_PORT_TYPE_NOTSET) { + devlink_port_type_warn_schedule(devlink_port); + } else { + devlink_port_type_warn_cancel(devlink_port); + if (type == DEVLINK_PORT_TYPE_ETH && netdev) + devlink_port_type_netdev_checks(devlink_port, netdev); + } + + spin_lock_bh(&devlink_port->type_lock); + devlink_port->type = type; + switch (type) { + case DEVLINK_PORT_TYPE_ETH: + devlink_port->type_eth.netdev = netdev; + break; + case DEVLINK_PORT_TYPE_IB: + devlink_port->type_ib.ibdev = type_dev; + break; + default: + break; + } + spin_unlock_bh(&devlink_port->type_lock); + devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW); +} + /** * devlink_port_type_eth_set - Set port type to Ethernet * @@ -10067,9 +10072,7 @@ static void devlink_port_type_netdev_checks(struct devlink_port *devlink_port, void devlink_port_type_eth_set(struct devlink_port *devlink_port, struct net_device *netdev) { - if (netdev) - devlink_port_type_netdev_checks(devlink_port, netdev); - else + if (!netdev) dev_warn(devlink_port->devlink->dev, "devlink port type for port %d set to Ethernet without a software interface reference, device type not supported by the kernel?\n", devlink_port->index);