Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp896633ima; Wed, 6 Feb 2019 10:05:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGMYzRBW4Iv5Wz/F4DFHn3UIPk9VYMD9dtfCN3Au/I5+oHBDGeWf0NzGMbU6921XhaYLB/ X-Received: by 2002:a17:902:2aa8:: with SMTP id j37mr11587199plb.226.1549476312025; Wed, 06 Feb 2019 10:05:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549476312; cv=none; d=google.com; s=arc-20160816; b=r93TCGYdu9l/dtYSSnz8dlfUEl8BsjqEhEaaluCI6YbK4B7WFLJSAxM1I8nsbI4LGO xQXwUp4qXG8LhBaF4nCpWew1m1p+LF5SHJb13leOunQn4Eko89NQAC+JsmjxlMCDM/u8 yH1M8sCHXVp8ODbzeHMIwBppPwnPW166o+BUgp0ktetVF3KIOOidCiI60sqHlWkqpdgP 4sMN5iyq69jHsbscGU8SVrQLDo0SHBF3yhfNmhLwi/QP2niYdNeOL31H7ll/+1ObYOsD M6Q5/af1ZTvNFAWN7lABSuAIlZwLOFMFA9nZ/98s+p7QudVC7XySB2kD0kCFf0WGQszv EVsg== 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=WvhLDrmdZVDiIsG2N5l3hvtM8l0zlUNLE53dWbT9Tio=; b=eSCkIlo+ijoaXrxzap3mhSUEbkh4TG1rVnYrGU6hZcc72sT80SnKnq2iQ4WHsklewt 8cJq9iVuF1iPls3Cca+BByaIXY8A01TZrBGbZnP2jJcxL/qrosfk9sgZ/Me2DA+Pwtwu MeX4HbcsXCxCpNf2H9zZUjwVtJwPAkXjn/bhF/3+C1OifF4XEqQX36/IT2YoMVUxEjIZ DTCo1WxkSCzWxQ0/simNfaOn3NzOi3kmR1rhX5OUHABMLopMfBsXs9v+nn8OCn6Yleln IhnXRO+Ny4W368+B+tX40rMT255T8uwFnlH0y1ACevIyGve5GYCgQsXZikBajyN3gnDW LraA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M4XvnYxC; 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 q14si6276739pgq.197.2019.02.06.10.04.46; Wed, 06 Feb 2019 10:05:11 -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=M4XvnYxC; 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 S1730657AbfBFRqX (ORCPT + 99 others); Wed, 6 Feb 2019 12:46:23 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:41635 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730599AbfBFRqR (ORCPT ); Wed, 6 Feb 2019 12:46:17 -0500 Received: by mail-pf1-f193.google.com with SMTP id b7so3399516pfi.8; Wed, 06 Feb 2019 09:46:16 -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=WvhLDrmdZVDiIsG2N5l3hvtM8l0zlUNLE53dWbT9Tio=; b=M4XvnYxCENkWxZP4bwYvz50RehYtXtHz0PlK+q047MPtBuQGJJV+iRZGoPU9qoeTN4 xal1WtYEzbXPFbnNIWqvhiLszhvKkHEi6R+3yFG81Gi1XwC6KHav+2yp5Nvd0KJERZbQ jc7bFUPJDj7nnCEFyd3q3Imogvy+6QbsIqOYehN8200Z+hJLU0eTq/RTzTbowfHDcOTo azISKb+qurIb/N4PWYjb0uaIHyxZuGHQJwGcS9DR3FjeGM3mEAhEkydG1y8G+w63CuiR iTWF0VWj6DsIo9W4BQBlV97kyP6Z9pgv77jMYjjPOEk19msM0k/fuiFmGQ+OQi6o2aXQ E9SQ== 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=WvhLDrmdZVDiIsG2N5l3hvtM8l0zlUNLE53dWbT9Tio=; b=KLs5/nOaIVesjcKSPQ4Q4ERz2VTO9QpVd3kV8uv8/hVlMrGwEhB/h1nnWZgNHcQR3l xqS+mZjO4xBd/zRaQtmePtO/E2tViE/9Y+e5ZQzpCzBTdmVTYzX0UcF0aTGR485Q950j bCVcMVaasZsrDcOqoVG3RdxatHmjyycKwxsE3RWPTyCFBkZTdfeBWGOMrwV5t3dywUfq fOwpP4/hXspJmfXwz7c7H17z09bQ//chUNnaRq3GG8Qm011x6a6l6cRY1TLsj17+bqWW b1kgtTOvL8w/1x+Y6uMSilY/3bDOJTNzpIrGxPLFpPX+1Q5CXjmKUJHEfeVvmpzy9L2+ 3seg== X-Gm-Message-State: AHQUAuaE+71+y9izcEQH8kM6F4J/DOJM/TZkGnvCB9cKgb2Jiba+Grk0 9lApC8js3DEii5aumuBcYX+yX7VT X-Received: by 2002:aa7:8759:: with SMTP id g25mr2608919pfo.248.1549475176009; Wed, 06 Feb 2019 09:46:16 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id 15sm10435313pfr.55.2019.02.06.09.46.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Feb 2019 09:46:15 -0800 (PST) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , "David S. Miller" , Ido Schimmel , 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), bridge@lists.linux-foundation.org (moderated list:ETHERNET BRIDGE) Subject: [PATCH net-next v4 07/12] nfp: Implement ndo_get_port_parent_id() Date: Wed, 6 Feb 2019 09:45:41 -0800 Message-Id: <20190206174546.23597-8-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190206174546.23597-1-f.fainelli@gmail.com> References: <20190206174546.23597-1-f.fainelli@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NFP only supports SWITCHDEV_ATTR_ID_PORT_PARENT_ID, which makes it a great candidate to be converted to use the ndo_get_port_parent_id() NDO instead of implementing switchdev_port_attr_get(). Since NFP uses switchdev_port_same_parent_id() convert it to use netdev_port_same_parent_id(). Acked-by: Jiri Pirko Signed-off-by: Florian Fainelli --- .../ethernet/netronome/nfp/flower/action.c | 3 +-- .../ethernet/netronome/nfp/nfp_net_common.c | 4 +--- .../net/ethernet/netronome/nfp/nfp_net_repr.c | 4 +--- drivers/net/ethernet/netronome/nfp/nfp_port.c | 22 +++++-------------- drivers/net/ethernet/netronome/nfp/nfp_port.h | 4 +++- 5 files changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c index 8d54b36afee8..7b217d7285c7 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/action.c +++ b/drivers/net/ethernet/netronome/nfp/flower/action.c @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -137,7 +136,7 @@ nfp_fl_output(struct nfp_app *app, struct nfp_fl_output *output, if (nfp_netdev_is_nfp_repr(in_dev)) { /* Confirm ingress and egress are on same device. */ - if (!switchdev_port_same_parent_id(in_dev, out_dev)) + if (!netdev_port_same_parent_id(in_dev, out_dev)) return -EOPNOTSUPP; } diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 7d2d4241498f..776f6c07701b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -36,7 +36,6 @@ #include #include -#include #include #include "nfpcore/nfp_nsp.h" @@ -3531,6 +3530,7 @@ const struct net_device_ops nfp_net_netdev_ops = { .ndo_udp_tunnel_add = nfp_net_add_vxlan_port, .ndo_udp_tunnel_del = nfp_net_del_vxlan_port, .ndo_bpf = nfp_net_xdp, + .ndo_get_port_parent_id = nfp_port_get_port_parent_id, }; /** @@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn) netdev->netdev_ops = &nfp_net_netdev_ops; netdev->watchdog_timeo = msecs_to_jiffies(5 * 1000); - SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops); - /* MTU range: 68 - hw-specific max */ netdev->min_mtu = ETH_MIN_MTU; netdev->max_mtu = nn->max_mtu; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c index 69d7aebda09b..62839807e21e 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "nfpcore/nfp_cpp.h" #include "nfpcore/nfp_nsp.h" @@ -273,6 +272,7 @@ const struct net_device_ops nfp_repr_netdev_ops = { .ndo_fix_features = nfp_repr_fix_features, .ndo_set_features = nfp_port_set_features, .ndo_set_mac_address = eth_mac_addr, + .ndo_get_port_parent_id = nfp_port_get_port_parent_id, }; void @@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, netdev->max_mtu = pf_netdev->max_mtu; - SWITCHDEV_SET_OPS(netdev, &nfp_port_switchdev_ops); - /* Set features the lower device can support with representors */ if (repr_cap & NFP_NET_CFG_CTRL_LIVE_ADDR) netdev->priv_flags |= IFF_LIVE_ADDR_CHANGE; diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c index 86bc149ca231..7e90880fa46b 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -31,34 +31,22 @@ struct nfp_port *nfp_port_from_netdev(struct net_device *netdev) return NULL; } -static int -nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr) +int nfp_port_get_port_parent_id(struct net_device *netdev, + struct netdev_phys_item_id *ppid) { struct nfp_port *port; + const u8 *serial; port = nfp_port_from_netdev(netdev); if (!port) return -EOPNOTSUPP; - switch (attr->id) { - case SWITCHDEV_ATTR_ID_PORT_PARENT_ID: { - const u8 *serial; - /* N.B: attr->u.ppid.id is binary data */ - attr->u.ppid.id_len = nfp_cpp_serial(port->app->cpp, &serial); - memcpy(&attr->u.ppid.id, serial, attr->u.ppid.id_len); - break; - } - default: - return -EOPNOTSUPP; - } + ppid->id_len = nfp_cpp_serial(port->app->cpp, &serial); + memcpy(&ppid->id, serial, ppid->id_len); return 0; } -const struct switchdev_ops nfp_port_switchdev_ops = { - .switchdev_port_attr_get = nfp_port_attr_get, -}; - int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type, void *type_data) { diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h index b2479a2a49e5..90ae053f5c07 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h @@ -7,6 +7,7 @@ #include struct net_device; +struct netdev_phys_item_id; struct nfp_app; struct nfp_pf; struct nfp_port; @@ -90,7 +91,6 @@ struct nfp_port { }; extern const struct ethtool_ops nfp_port_ethtool_ops; -extern const struct switchdev_ops nfp_port_switchdev_ops; __printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...); @@ -106,6 +106,8 @@ int nfp_port_set_features(struct net_device *netdev, netdev_features_t features); struct nfp_port *nfp_port_from_netdev(struct net_device *netdev); +int nfp_port_get_port_parent_id(struct net_device *netdev, + struct netdev_phys_item_id *ppid); struct nfp_port * nfp_port_from_id(struct nfp_pf *pf, enum nfp_port_type type, unsigned int id); struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port); -- 2.17.1