From patchwork Mon Oct 31 12:42:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13025766 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 AB1DAECAAA1 for ; Mon, 31 Oct 2022 12:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbiJaMm5 (ORCPT ); Mon, 31 Oct 2022 08:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbiJaMmz (ORCPT ); Mon, 31 Oct 2022 08:42:55 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C24EDF03D for ; Mon, 31 Oct 2022 05:42:54 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id h9so15851096wrt.0 for ; Mon, 31 Oct 2022 05:42:54 -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=YKbUqwCgk8rRw9VnfIDT18etXKii/v8HDOECNkXs/oUxsf5cnz4xi/PH/1HH9WTbWy zmkmyDS6Sb9ee1Dzq/peG0E/CB+AUeWAtC9kO7De1HusYjlb3Ga2ejoqwt5QXU2Swc3S tu1lncLCS+SXaOB8ArPi63RwKeg89cwZoLvMhJicsRcOdcy0lf00Edw4e9n3i+IQwsI1 y3c/cg7MBEUCkRsoYNWDgKJbMmh3JqZGkZzB9aau4mAut7q2up8xGO9/9e7dtyHm7u+1 ldVZiQVxKn8/BMw7XwQYmeJuBrsD2OAbP6EkzYAi8yukjATK3ufkUHXwjx9D9/4UYwlj UkUA== 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=GqwPTbvXmAduYJP/vyWLFFybmKeNAC+OZESEiQOTRtIPAVLlzrxwGS62PtQz28oYf7 3cjr3pO4eGxZtqnApUk58Qjoi3OzhLuRwiTEQeIM6dmEN95it/wzd1ZI7VJEqMT99xFh ndUHvuOySTGmiW2muMuJe2f5JXLvHAMBW6MB+FVmM9gpXyOVPjMTdJ3Uil2ypE6rO9lL j9eoeSOQRVcg3lnsvC6IKjS2vBZxW2dMIt6aAs7AoC3a1ChZRwmwDbQ4iVTUBp9FeKV0 YLuAXVioE64AyDSvyeGz52Pk6Drg8IXDgFaEXUcWMyWsiOifSYUrDKbCGMJ731XygUIi tehg== X-Gm-Message-State: ACrzQf2wWBbCqWF2Vo0tVJ1CSYaPEFPsWyHnPmbESpL40hwir/L0FNDE rmCOBmDtrkrLkQ1ExPkkpTCGJQ== X-Google-Smtp-Source: AMsMyM7buebwdwXPxT87Z2iTSsM2hwy2rRybDfb1+BF55QuBz278qJHnvDodPdjod/Ge/rA5akm0SQ== X-Received: by 2002:a5d:484f:0:b0:236:9c97:6f85 with SMTP id n15-20020a5d484f000000b002369c976f85mr8107086wrs.636.1667220173345; Mon, 31 Oct 2022 05:42:53 -0700 (PDT) Received: from localhost ([86.61.181.4]) by smtp.gmail.com with ESMTPSA id az29-20020a05600c601d00b003cdf141f363sm7282279wmb.11.2022.10.31.05.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Oct 2022 05:42:52 -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 v3 03/13] net: devlink: move port_type_netdev_checks() call to __devlink_port_type_set() Date: Mon, 31 Oct 2022 13:42:38 +0100 Message-Id: <20221031124248.484405-4-jiri@resnulli.us> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221031124248.484405-1-jiri@resnulli.us> References: <20221031124248.484405-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);