Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp978366ima; Fri, 1 Feb 2019 14:11:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IZE0+WK9esvz/IjcnOvJ4pmRzwqWeWWhPcw7aY3a6s4OjinlQAttwn2PQF0p3B16BLnmvK/ X-Received: by 2002:a65:6542:: with SMTP id a2mr3945740pgw.389.1549059070164; Fri, 01 Feb 2019 14:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549059070; cv=none; d=google.com; s=arc-20160816; b=xl2+IIksoA+5tU0gRoOlxkzFwZQ6C+9vqfvdZ9Zj6UG7byLJieW2eIS3IRlGhbqmUZ q1uk6qIkC6vKn4gOD/ijICRQgMt7OfVjZ922QvzggW/oHng0ci1z6f94KFcLedEDodJk ZzQNoXSpo11Kp2e3wT6hPQ1EaYB7jar6zeSyEKMzQfqu5tuux2TGULZZE2E5I1g63qg9 B3XN+hpp39W6bu0wfghVbrl0f/9fiG6y5MtB/u4TlAQArHsEN8cvSj2mmGiuDQXa/9lf ZMfh/wNE6XwRz/SAg5H6WoLYQzHu5uiaInzTraC4F5JPUieZVSW5hotx/+CfsV+U8aMx G01A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ADHtnf2Pyj7Bb3/Osgn+6/bvWFlSO/mVEntxDCFTFHg=; b=AaBK9c2YF0NoyO6P8uwUUn51FJGKe9C1Ej2W4rLsMEm3RKbmHlzk9K4m7MY78ngk1X ZEEnNxTbjLn15VvxbmwkdQynSTDFCubugZ2PnvxkRz29DjEt8vGtDcYt8WeIlDxgOHCF 0qFVPhzvyELiP6FIEwD9auwzDxkpbuAMUA7QyM9BjPgea0cs0rSnrHttjVGyyiFAuzAK YKWHqrQe5teXZreqDXCl+SnknbFHTmSLJJrrEg/MilwwtTEKuX28+hMxp6QrZuBzgARL WQ+K23JmAoGcYpy+sMkufBeqIG59elgOxeZG0f1WukyQmEUMEFuOdpqPgzcZ/5XtKdWT kpKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aEnvDuZf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si7729465pgj.59.2019.02.01.14.10.55; Fri, 01 Feb 2019 14:11:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aEnvDuZf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727395AbfBAWIX (ORCPT + 99 others); Fri, 1 Feb 2019 17:08:23 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33749 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727312AbfBAWIV (ORCPT ); Fri, 1 Feb 2019 17:08:21 -0500 Received: by mail-pf1-f196.google.com with SMTP id c123so3897994pfb.0; Fri, 01 Feb 2019 14:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ADHtnf2Pyj7Bb3/Osgn+6/bvWFlSO/mVEntxDCFTFHg=; b=aEnvDuZf2q2uToeKMG64FV2JZJmWkZU58TMfGpEQ2A489Od1iGs9Qt5g4k8DgKmVCM xKqGXnqKfUV1LXYlAp2/gd00E/L0eTTIZ/F2Yytlvm/9VUykbtIs3ONkMf6KPVoir4Pw Jyq/FlGUCtXm3wg39JKQV5yxn/4x+R9Z7i1nxGPYnF3OBZhNj4fkqp9PxIGlQ/MMLQ8c Z/YdlwuC+2KVvJNhap/EcK/MNYgoBOi4lCwGU4OFDV344DdR+ptLuIlfhNPeHmWonFMQ 5U5u+DaYrBKRfLeKHDjRFw4TqYwqfiAmp7Gbb3pFW+2m1k0ZHyKzO9v39jkaPRKPauMa Os0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ADHtnf2Pyj7Bb3/Osgn+6/bvWFlSO/mVEntxDCFTFHg=; b=P1paGSbf3r6y6U5YRJ4KB8nDuS850mI74TTN1IMlO7cf0QbAtzb9gmdOG0D3iq2h6i vyXffT9Nz08O5rr+zwbSKCv1KMSOPlQg2MWAnsS/rtDQH21SiTSBF8ggBQsOjjRnloap I4yZ6dxIQ21G9VM6ipKBFFm4btrPe1LPza2gWmnusU+oJGYrG9DOLpSO7smC5HV1VAr8 nFa1YE1G4mkk3yMyuuNcMLSEti+u3odNO++YvGp7e9Bk+sJGgZAeeKZ1+O7AEjlDCdri CdZEtxVErojGfnv/gyLQuM+PynSWBe7rDf0G8r84D6BjCKH3Ak7P0dU7rzzVqARRCRBD PsWw== X-Gm-Message-State: AHQUAuYhUorPfSChyeYuNoNIP1wWj2QIMyit/kFROGXhnP0kNArEKSZu lnwmCk3GiCZdvWzKlGi6UKSLsYxO X-Received: by 2002:a65:49cd:: with SMTP id t13mr4016431pgs.376.1549058899738; Fri, 01 Feb 2019 14:08:19 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id 78sm11142208pft.184.2019.02.01.14.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 14:08:18 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Michael Chan , "David S. Miller" , Derek Chickles , Satanand Burla , Felix Manlunas , Saeed Mahameed , Leon Romanovsky , Jiri Pirko , Ido Schimmel , Alexandre Belloni , Microchip Linux Driver Support , Jakub Kicinski , Ioana Radulescu , Ioana Ciornei , Greg Kroah-Hartman , Ivan Vecera , Andrew Lunn , Vivien Didelot , Dirk van der Merwe , "Francois H. Theron" , Simon Horman , Quentin Monnet , Daniel Borkmann , Eric Dumazet , John Hurley , Edwin Peer , linux-kernel@vger.kernel.org (open list), linux-rdma@vger.kernel.org (open list:MELLANOX MLX5 core VPI driver), oss-drivers@netronome.com (open list:NETRONOME ETHERNET DRIVERS), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM) Subject: [RFC net-next 08/13] liquidio: Handle SWITCHDEV_PORT_ATTR_GET event Date: Fri, 1 Feb 2019 14:06:52 -0800 Message-Id: <20190201220657.30170-9-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190201220657.30170-1-f.fainelli@gmail.com> References: <20190201220657.30170-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Following patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks. Prepare bnxt to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation. We register a single blocking switchdev notifier for the PF part of the driver, and we register another blocking switchdev notifier, following what was done with the existing netdevice notifier within the VF representor driver. Signed-off-by: Florian Fainelli --- .../net/ethernet/cavium/liquidio/lio_main.c | 48 ++++++++++++++++++- .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 45 ++++++++++++++++- 2 files changed, 91 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 3d24133e5e49..b9d48e4181fc 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -162,6 +162,8 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx, static struct handshake handshake[MAX_OCTEON_DEVICES]; static struct completion first_stage; +static int liquidio_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr); static void octeon_droq_bh(unsigned long pdev) { @@ -469,12 +471,25 @@ static struct pci_driver liquidio_pci_driver = { #endif }; +static struct notifier_block liquidio_blocking_nb = { + .notifier_call = liquidio_switchdev_blocking_event, +}; + /** * \brief register PCI driver */ static int liquidio_init_pci(void) { - return pci_register_driver(&liquidio_pci_driver); + int rc; + + rc = register_switchdev_blocking_notifier(&liquidio_blocking_nb); + if (rc) + return rc; + rc = pci_register_driver(&liquidio_pci_driver); + if (rc) + unregister_switchdev_blocking_notifier(&liquidio_blocking_nb); + + return rc; } /** @@ -483,6 +498,7 @@ static int liquidio_init_pci(void) static void liquidio_deinit_pci(void) { pci_unregister_driver(&liquidio_pci_driver); + unregister_switchdev_blocking_notifier(&liquidio_blocking_nb); } /** @@ -3261,6 +3277,36 @@ static const struct net_device_ops lionetdevops = { .ndo_get_vf_stats = liquidio_get_vf_stats, }; +static int lio_pf_attr_event(unsigned long event, struct net_device *dev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int rc; + + if (event != SWITCHDEV_PORT_ATTR_GET) + return NOTIFY_DONE; + + rc = lio_pf_switchdev_attr_get(dev, port_attr_info->attr); + + port_attr_info->handled = true; + return notifier_from_errno(rc); +} + +static int liquidio_switchdev_blocking_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *dev = switchdev_notifier_info_to_dev(ptr); + + if (dev->netdev_ops != &lionetdevops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return lio_pf_attr_event(event, dev, ptr); + } + + return NOTIFY_DONE; +} + /** \brief Entry point for the liquidio module */ static int __init liquidio_init(void) diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c index de61060721c4..d396c004c1be 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c @@ -468,6 +468,21 @@ static const struct switchdev_ops lio_vf_rep_switchdev_ops = { .switchdev_port_attr_get = lio_vf_rep_attr_get, }; +static int lio_vf_rep_swdev_port_attr_event(unsigned long event, + struct net_device *dev, + struct switchdev_notifier_port_attr_info *port_attr_info) +{ + int rc; + + if (event != SWITCHDEV_PORT_ATTR_GET) + return NOTIFY_DONE; + + rc = lio_vf_rep_attr_get(dev, port_attr_info->attr); + port_attr_info->handled = true; + + return notifier_from_errno(rc); +} + static void lio_vf_rep_fetch_stats(struct work_struct *work) { @@ -538,7 +553,6 @@ lio_vf_rep_create(struct octeon_device *oct) if (register_netdev(ndev)) { dev_err(&oct->pci_dev->dev, "VF rep nerdev registration failed\n"); - free_netdev(ndev); goto cleanup; } @@ -664,20 +678,49 @@ static struct notifier_block lio_vf_rep_netdev_notifier = { .notifier_call = lio_vf_rep_netdev_event, }; +static int lio_vf_rep_swdev_event(struct notifier_block *nb, + unsigned long event, void *ptr) +{ + struct net_device *ndev = switchdev_notifier_info_to_dev(ptr); + + if (ndev->netdev_ops != &lio_vf_rep_ndev_ops) + return NOTIFY_DONE; + + switch (event) { + case SWITCHDEV_PORT_ATTR_GET: + return lio_vf_rep_swdev_port_attr_event(event, ndev, ptr); + } + + return NOTIFY_DONE; +} + +static struct notifier_block lio_vf_rep_swdev_nb = { + .notifier_call = lio_vf_rep_swdev_event, +}; + int lio_vf_rep_modinit(void) { + int rc; + if (register_netdevice_notifier(&lio_vf_rep_netdev_notifier)) { pr_err("netdev notifier registration failed\n"); return -EFAULT; } + rc = register_switchdev_blocking_notifier(&lio_vf_rep_swdev_nb); + if (rc) { + unregister_netdevice_notifier(&lio_vf_rep_netdev_notifier); + return rc; + } + return 0; } void lio_vf_rep_modexit(void) { + unregister_switchdev_blocking_notifier(&lio_vf_rep_swdev_nb); if (unregister_netdevice_notifier(&lio_vf_rep_netdev_notifier)) pr_err("netdev notifier unregister failed\n"); } -- 2.17.1