From patchwork Mon Jul 30 12:45:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10549029 X-Patchwork-Delegate: idosch@idosch.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4AA9A755 for ; Mon, 30 Jul 2018 12:45:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D42D5296A7 for ; Mon, 30 Jul 2018 12:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8976296EC; Mon, 30 Jul 2018 12:45:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,MAILING_LIST_MULTI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19666296A7 for ; Mon, 30 Jul 2018 12:45:51 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41fK706wgNzF0xv for ; Mon, 30 Jul 2018 22:45:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="CW524RBb"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=104.47.2.71; helo=eur01-db5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="CW524RBb"; dkim-atps=neutral Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0071.outbound.protection.outlook.com [104.47.2.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41fK6Z35mnzF153 for ; Mon, 30 Jul 2018 22:45:25 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MIwL2zxLm2r7QE2NAU+Di5Rqo8F5O+WbJgokPRYxJxc=; b=CW524RBbIoAbrfDtVfMTUy2KhAQybRb/b9CU8vwS224WA7Rm2IxKJvUgnHj7hc9vmC28avPBSzRWloPEA75xAy0r/Ji+kksSCZEDfArSxYo25x28bEd7ri8ZZaTxrsbDMQfe/5ELHKrFl/aSx1Xsk9Z1G0LLIzzgarP47o4c2R0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.20; Mon, 30 Jul 2018 12:45:19 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw v3 3/7] mlxsw: spectrum: Extract work-scheduling into a new function In-Reply-To: References: Message-Id: Date: Mon, 30 Jul 2018 14:45:12 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: HE1PR0701CA0048.eurprd07.prod.outlook.com (2603:10a6:3:9e::16) To DB7PR05MB4186.eurprd05.prod.outlook.com (2603:10a6:5:18::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fc311da-7fa2-4d58-78be-08d5f61a4ef3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB7PR05MB4186; X-Microsoft-Exchange-Diagnostics: 1; DB7PR05MB4186; 3:C1U2BFP8y717g4ai18W77j55AeSIO7ti+2YOVP/n766eCdIIAkc8ZtbnCq2mMU1qBMJ+kjx8iD6R505VL6OLbUJlOacudMkreByA0gmxAU7jiZHNHcj6RzuYpxYTVlegSzbUR4CW+q1JtqJsT7xf77RMEdoDKB+aGn3MWEcw1mVnyrsAyy4vLpe840mRLWm1FNmwjqXltp+AjQvF3x2Taz8OixQ7XpUCmjZX4+kbbEolYLT3jsVDSn/qpvHZOG89; 25:BAsQgTdI07wsMmwk6tWwZ025yTT/qtDP2xgdL3mBB/TiV1dJ+n1WrvDYP7DSHd+vptKL1be9f9Ty0Dhi014hKD0npqptlDpJar8UwMBuOVpRTn1/EZ5ExWXObIJhkB+9+QOvNPvwzM6swElGW3dFjBAzDXB+kjS5/xodED46I7rUyU20rpjh4By+TKrUk43VvnJDH/m3jsHh6pd6b6fReTo726LXBe+p4+14Bj9ulvoD2bAffOufsJH54STOroTuDPaQ3t+kU0haJTvzbDTEp46b81J59u6nP9GagoVQF+WTG9wl+2ny7XRoSFxhB9+pvEwm/kAvkKMrqlate5uFiQ==; 31:h8HuHg0D0gg+XOqHIgSXyyG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TlZAUQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:DB7PR05MB4186; BCL:0; PCL:0; RULEID:; SRVR:DB7PR05MB4186; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(136003)(376002)(39860400002)(366004)(346002)(199004)(189003)(478600001)(50466002)(2351001)(48376002)(305945005)(7736002)(8676002)(81156014)(47776003)(66066001)(8936002)(105586002)(25786009)(106356001)(81166006)(2616005)(476003)(3846002)(486006)(956004)(97736004)(118296001)(6486002)(36756003)(53936002)(68736007)(5660300001)(2906002)(16526019)(14444005)(6862004)(446003)(11346002)(6116002)(86362001)(37006003)(58126008)(316002)(26005)(6666003)(76176011)(186003)(6496006)(51416003)(16586007)(52116002)(386003)(6636002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR05MB4186; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB7PR05MB4186; 23:p6J7LlT2//W/Z/S4hELFUNfgpkPyzniuqZHBPDnNk?= 0bMH2BvjwoCGSF7JNbPWOi0/Kuc5u5m59mIX+E1R44JVZipThQTOXgz70QtZE/Xz7zOJuGXZ4ka8eoKrhc4nWIRbtx/W4P3IpX3R9FcodSKDZty3Op732ieVd5fS3Kf8HbXmpLk4g57inBi1RPD/nqMYpV4JO3SyySMJYX+FV0ctBqAUQrPpu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Sfb2PU2rzaORidKhQ/60850SpvopY0xLEU3Pc5eM/pGDeG3a6px4htJqqyrvUjcssk0UA9msWwhEgyHsDA853q/vwG5jbwNCuqPr3kbQXtfK98PGDgXpvSthzf4UJTfoAQ8d0ZnuWC4+bkGFr5XhREOReU4bC81PjuJ8uIkmhhXq51Ix+wlTS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 12:45:19.2251 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fc311da-7fa2-4d58-78be-08d5f61a4ef3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR05MB4186 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP The boilerplate to schedule NETEVENT_IPV4_MPATH_HASH_UPDATE and NETEVENT_IPV6_MPATH_HASH_UPDATE handling is almost equivalent to that of NETEVENT_IPV4_FWD_UPDATE_PRIORITY_UPDATE that's coming in the next patch. The only difference is which actual worker function should be called. Extract this boilerplate into a named function in order to allow reuse. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index 1d4c02a36432..08b105bfb65d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c @@ -2402,17 +2402,36 @@ static void mlxsw_sp_router_mp_hash_event_work(struct work_struct *work) kfree(net_work); } +static int mlxsw_sp_router_schedule_work(struct net *net, + struct notifier_block *nb, + void (*cb)(struct work_struct *)) +{ + struct mlxsw_sp_netevent_work *net_work; + struct mlxsw_sp_router *router; + + if (!net_eq(net, &init_net)) + return NOTIFY_DONE; + + net_work = kzalloc(sizeof(*net_work), GFP_ATOMIC); + if (!net_work) + return NOTIFY_BAD; + + router = container_of(nb, struct mlxsw_sp_router, netevent_nb); + INIT_WORK(&net_work->work, cb); + net_work->mlxsw_sp = router->mlxsw_sp; + mlxsw_core_schedule_work(&net_work->work); + return NOTIFY_DONE; +} + static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, unsigned long event, void *ptr) { struct mlxsw_sp_netevent_work *net_work; struct mlxsw_sp_port *mlxsw_sp_port; - struct mlxsw_sp_router *router; struct mlxsw_sp *mlxsw_sp; unsigned long interval; struct neigh_parms *p; struct neighbour *n; - struct net *net; switch (event) { case NETEVENT_DELAY_PROBE_TIME_UPDATE: @@ -2466,20 +2485,9 @@ static int mlxsw_sp_router_netevent_event(struct notifier_block *nb, break; case NETEVENT_IPV4_MPATH_HASH_UPDATE: case NETEVENT_IPV6_MPATH_HASH_UPDATE: - net = ptr; + return mlxsw_sp_router_schedule_work(ptr, nb, + mlxsw_sp_router_mp_hash_event_work); - if (!net_eq(net, &init_net)) - return NOTIFY_DONE; - - net_work = kzalloc(sizeof(*net_work), GFP_ATOMIC); - if (!net_work) - return NOTIFY_BAD; - - router = container_of(nb, struct mlxsw_sp_router, netevent_nb); - INIT_WORK(&net_work->work, mlxsw_sp_router_mp_hash_event_work); - net_work->mlxsw_sp = router->mlxsw_sp; - mlxsw_core_schedule_work(&net_work->work); - break; } return NOTIFY_DONE;