Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2329783pxb; Sat, 25 Sep 2021 04:27:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFjC3OptE28cWK9tOUNQm+RxU55kAS9xcCuAILt+nPxCSv7rqkANyAqWkHfkuFCPAZ7abE X-Received: by 2002:a50:da04:: with SMTP id z4mr10463034edj.52.1632569278839; Sat, 25 Sep 2021 04:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632569278; cv=none; d=google.com; s=arc-20160816; b=oNVy2DMLeJ/G+WAq8Df0b5RTA7C68fBmtJjzppOnh8+hpNa64cHS0b8fDLhfoBmVE6 2Bw38SxNz9Q3EWzNfrCpqDEA409DsbdgS0O1W74uabyDMNDWvLkzk8PZyvzge2DDcWHd oEPYrmqmTPjVOrPoyh+DWBwzfuDLXd295wi74+R9Z6kb2QE+ACOPX3jvsegppmWVxyF4 TNDilDN0x7xEQqf/x6nxm6tmhp0z1YfmMQGgiVJHGzSZ0idUKV+WTUa8EuIG9ZbIa+hs wfb40T+20xz0AQlnQFYHaaXVxpQrFQXLDo7UfBh9GwDF5x1cS/0NhQiF4UQl5FTgYtqf B6Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UfgWiNgdY+FzFXABhV8lQXPQlxg5PgICUiw3ZQpyo3I=; b=VtF8J0LdSKn3sN2AwDQarI8X2OqccNxT7Bumery1YhoHDnf7KW6aP9Y7c8YNoE24Fv 5br+VtCOL6guEOBsxNIr1+L+YpL26wOnah+d5SwRPcalfSwnuWuhwFMc7kdDJGwdmclu ID/M0QIYudtsu40M7iN4wXsEI5FzPZCTOFZYBT75UODeBhqpkpgwOS5ISiVhjFtgWi3S JCcm4sMNBZKJoqg4/iSGECVxkC7ZNJgbs210ExiqFwmHMccZ1rhQge9Ti27jOWT3lJpr 0+1RD6G/8/FT+sH6O4Iw1gtEm2h4Hk831ctoqqDRE2edtHdliRbrH9Rj3sZCbSB4BEuY exQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYVdSyk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id 31si10297901edo.634.2021.09.25.04.27.35; Sat, 25 Sep 2021 04:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XYVdSyk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S244971AbhIYLZW (ORCPT + 99 others); Sat, 25 Sep 2021 07:25:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:56016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245045AbhIYLZF (ORCPT ); Sat, 25 Sep 2021 07:25:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A281B6127C; Sat, 25 Sep 2021 11:23:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632569010; bh=pc8zwS3r8HsfwOxk/n265zyCXchtl5rU8VYtSBAYXS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYVdSyk4Nov6ULK/fPAslkGEtxWs0lZ0lQ/xfjQJBfscVFxRhWcOjoJwGYAe3satN 8otZtplAxDDhaNxERQKpq4F5wivWdImoSGdiUEjg4zXYIBpMRoa2bdDUpJGmNmgW71 hpwFL/LKTPg4zAqy+Vpi1KFY5mrg0eDX1+zEsBSyoYzlimYAkMM6nlCYEXnESWKD+5 hR7FPTAGNobhoUjByJKm8aaWrF0iFNv4F0o7emLxQvym3sK9pGu0/MhhTqiNbazSCD 5+t8qDq7tx8Mm/fxLtgCvBT4lUN+5qTi9rwAt7SWJcT5MuB7K5KAZ/tPg0jWvkOHAK F+PsGCvrkN1fA== From: Leon Romanovsky To: "David S . Miller" , Jakub Kicinski Cc: Leon Romanovsky , Alexandre Belloni , Andrew Lunn , Ariel Elior , Bin Luo , Claudiu Manoil , Coiby Xu , Derek Chickles , drivers@pensando.io, Felix Manlunas , Florian Fainelli , Geetha sowjanya , Greg Kroah-Hartman , GR-everest-linux-l2@marvell.com, GR-Linux-NIC-Dev@marvell.com, hariprasad , Ido Schimmel , Intel Corporation , intel-wired-lan@lists.osuosl.org, Ioana Ciornei , Jerin Jacob , Jesse Brandeburg , Jiri Pirko , Jonathan Lemon , Linu Cherian , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-rdma@vger.kernel.org, linux-staging@lists.linux.dev, Loic Poulain , Manish Chopra , M Chetan Kumar , Michael Chan , Michael Guralnik , netdev@vger.kernel.org, oss-drivers@corigine.com, Richard Cochran , Saeed Mahameed , Satanand Burla , Sergey Ryazanov , Shannon Nelson , Simon Horman , Subbaraya Sundeep , Sunil Goutham , Taras Chornyi , Tariq Toukan , Tony Nguyen , UNGLinuxDriver@microchip.com, Vadym Kochan , Vivien Didelot , Vladimir Oltean Subject: [PATCH net-next v1 08/21] net/prestera: Split devlink and traps registrations to separate routines Date: Sat, 25 Sep 2021 14:22:48 +0300 Message-Id: <0e3101259046a001c417415b84b834ca56d1bfd3.1632565508.git.leonro@nvidia.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky Separate devlink registrations and traps registrations so devlink will be registered when driver is fully initialized. Signed-off-by: Leon Romanovsky --- .../marvell/prestera/prestera_devlink.c | 29 ++++--------------- .../marvell/prestera/prestera_devlink.h | 4 ++- .../ethernet/marvell/prestera/prestera_main.c | 8 +++-- 3 files changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c index 5cca007a3e17..06279cd6da67 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_devlink.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_devlink.c @@ -345,8 +345,6 @@ static struct prestera_trap prestera_trap_items_arr[] = { }, }; -static void prestera_devlink_traps_fini(struct prestera_switch *sw); - static int prestera_drop_counter_get(struct devlink *devlink, const struct devlink_trap *trap, u64 *p_drops); @@ -381,8 +379,6 @@ static int prestera_trap_action_set(struct devlink *devlink, enum devlink_trap_action action, struct netlink_ext_ack *extack); -static int prestera_devlink_traps_register(struct prestera_switch *sw); - static const struct devlink_ops prestera_dl_ops = { .info_get = prestera_dl_info_get, .trap_init = prestera_trap_init, @@ -407,34 +403,18 @@ void prestera_devlink_free(struct prestera_switch *sw) devlink_free(dl); } -int prestera_devlink_register(struct prestera_switch *sw) +void prestera_devlink_register(struct prestera_switch *sw) { struct devlink *dl = priv_to_devlink(sw); - int err; devlink_register(dl); - - err = prestera_devlink_traps_register(sw); - if (err) { - devlink_unregister(dl); - dev_err(sw->dev->dev, "devlink_traps_register failed: %d\n", - err); - return err; - } - - return 0; } void prestera_devlink_unregister(struct prestera_switch *sw) { - struct prestera_trap_data *trap_data = sw->trap_data; struct devlink *dl = priv_to_devlink(sw); - prestera_devlink_traps_fini(sw); devlink_unregister(dl); - - kfree(trap_data->trap_items_arr); - kfree(trap_data); } int prestera_devlink_port_register(struct prestera_port *port) @@ -482,7 +462,7 @@ struct devlink_port *prestera_devlink_get_port(struct net_device *dev) return &port->dl_port; } -static int prestera_devlink_traps_register(struct prestera_switch *sw) +int prestera_devlink_traps_register(struct prestera_switch *sw) { const u32 groups_count = ARRAY_SIZE(prestera_trap_groups_arr); const u32 traps_count = ARRAY_SIZE(prestera_trap_items_arr); @@ -621,8 +601,9 @@ static int prestera_drop_counter_get(struct devlink *devlink, cpu_code_type, p_drops); } -static void prestera_devlink_traps_fini(struct prestera_switch *sw) +void prestera_devlink_traps_unregister(struct prestera_switch *sw) { + struct prestera_trap_data *trap_data = sw->trap_data; struct devlink *dl = priv_to_devlink(sw); const struct devlink_trap *trap; int i; @@ -634,4 +615,6 @@ static void prestera_devlink_traps_fini(struct prestera_switch *sw) devlink_trap_groups_unregister(dl, prestera_trap_groups_arr, ARRAY_SIZE(prestera_trap_groups_arr)); + kfree(trap_data->trap_items_arr); + kfree(trap_data); } diff --git a/drivers/net/ethernet/marvell/prestera/prestera_devlink.h b/drivers/net/ethernet/marvell/prestera/prestera_devlink.h index cc34c3db13a2..b322295bad3a 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_devlink.h +++ b/drivers/net/ethernet/marvell/prestera/prestera_devlink.h @@ -9,7 +9,7 @@ struct prestera_switch *prestera_devlink_alloc(struct prestera_device *dev); void prestera_devlink_free(struct prestera_switch *sw); -int prestera_devlink_register(struct prestera_switch *sw); +void prestera_devlink_register(struct prestera_switch *sw); void prestera_devlink_unregister(struct prestera_switch *sw); int prestera_devlink_port_register(struct prestera_port *port); @@ -22,5 +22,7 @@ struct devlink_port *prestera_devlink_get_port(struct net_device *dev); void prestera_devlink_trap_report(struct prestera_port *port, struct sk_buff *skb, u8 cpu_code); +int prestera_devlink_traps_register(struct prestera_switch *sw); +void prestera_devlink_traps_unregister(struct prestera_switch *sw); #endif /* _PRESTERA_DEVLINK_H_ */ diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c index 44c670807fb3..78a7a00bce22 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c @@ -851,7 +851,7 @@ static int prestera_switch_init(struct prestera_switch *sw) if (err) goto err_span_init; - err = prestera_devlink_register(sw); + err = prestera_devlink_traps_register(sw); if (err) goto err_dl_register; @@ -863,12 +863,13 @@ static int prestera_switch_init(struct prestera_switch *sw) if (err) goto err_ports_create; + prestera_devlink_register(sw); return 0; err_ports_create: prestera_lag_fini(sw); err_lag_init: - prestera_devlink_unregister(sw); + prestera_devlink_traps_unregister(sw); err_dl_register: prestera_span_fini(sw); err_span_init: @@ -888,9 +889,10 @@ static int prestera_switch_init(struct prestera_switch *sw) static void prestera_switch_fini(struct prestera_switch *sw) { + prestera_devlink_unregister(sw); prestera_destroy_ports(sw); prestera_lag_fini(sw); - prestera_devlink_unregister(sw); + prestera_devlink_traps_unregister(sw); prestera_span_fini(sw); prestera_acl_fini(sw); prestera_event_handlers_unregister(sw); -- 2.31.1