Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5651810ima; Tue, 5 Feb 2019 15:58:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IbC5lb+O0brqRGB/XPPjMxF7ZxNdWO2Ho/VsjtkNKEuUN9gkC39JZR4dpyB/jZAJ7CE7XV4 X-Received: by 2002:a65:62da:: with SMTP id m26mr6963657pgv.278.1549411111738; Tue, 05 Feb 2019 15:58:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549411111; cv=none; d=google.com; s=arc-20160816; b=aTIpt653vWq7iD3P5sE5/ZfPPanm50613Czp1JBM++XmQUn+jhtSqXTTiQtmnNnHjW au1uZDxqo3DiMkQZQqwQU+qySGI8nX+9KzFAWHbY9aZlTxIGtRVNK8AkWYfQovLsgAgm CCLoSfaqmV4/0O6OgFnEExe0sNC3cFGqYNBtJPJ1JGaf8h/n9KoRVq6qOlGXv6FeH9Ra 4gfGU/9YUAB42FGWEiWm9rYN0iRtSq8ooiK+513qL/rb2ziT1kQ0cJBOm9lXounsdxUD s+eiq4yI6shLwsXypvqoz0GaTN0jE4oMJQoyfcFuH624vOgEsOHtz3G//KksM1ifOe5V iTUQ== 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=oyGcqq3vNf4NfzWL6hDTHMnLb9w/nExhE/06etL99lw=; b=crLKOctO+y4m4d0k31qZViEic2rUiwLnrxaJVPqTZkDQYMnCDiZAIw4QkZoDE5ydef 955xy0hew+1cs5uSWZOtnM4+V5KtFz9lMojGTcl17LdYxivc+KBiCjIIYSKR+X8cmbTV F/w0uMl37j+6W6D6y4HheFw0l89Dycw3LKFG1KHf+C6Rov4AhppmUgT0L0kKI2sV/s7p 1BX3svEaAsezCLyX9WVV7IqBT5GQwnYzH3I7s7gddJBssO6ZT+lpB08B2C5Je2S6LgFT mJa+a3LTvloHgCBsrmALgnABeuODF+SUW8iNMQduiDNwHtRq5qI5etPfPd1fWK5ZPzMI drbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="UF/1zaoA"; 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 x34si4178351pgl.491.2019.02.05.15.58.16; Tue, 05 Feb 2019 15:58:31 -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="UF/1zaoA"; 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 S1728667AbfBEXz4 (ORCPT + 99 others); Tue, 5 Feb 2019 18:55:56 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41774 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728452AbfBEXzx (ORCPT ); Tue, 5 Feb 2019 18:55:53 -0500 Received: by mail-pl1-f193.google.com with SMTP id k15so2253505pls.8; Tue, 05 Feb 2019 15:55:52 -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=oyGcqq3vNf4NfzWL6hDTHMnLb9w/nExhE/06etL99lw=; b=UF/1zaoAWojjarZBylCv0sgNH/FWKQTodW/ze5QIwvpJinvF6egBEUzBeVmngJfPRI yhfG2+yFjNgz7oMdcbMLvUMPH129hk+o/sK05bwftlHGoqGbAqD5uwr7BmJbAPRzOxDH WiLx6Rbc6lOLpqeoQ5Orag9zmXG5rBSQndZ7nZGRxRQ7Ho/tKBpbnU8/WgOaYnlkJmhc 8BUd/H8nIfrtkS8CbSOQEz3r9FA7yKvE48tyzuAOIV+QXPcvn/eX4zcJguGv/YJSSb4U adz/kIPjlbvxcvy27SXj3LoYqviKys2T3FPdKr3z5owz0h2hp5mqoYv6V2+g//4eg0fG sa+g== 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=oyGcqq3vNf4NfzWL6hDTHMnLb9w/nExhE/06etL99lw=; b=Qnf2k81FWKSue5Ny/HKsrbnTf+8waxzFspbQVe8Sl+47HWNZBYYZiGJabqdwlCB6bJ 3YKiKuXduCEK/YjlxikkxP4MQM+AutC8Ssy6GotKPQLQznkj/hdTuoYBvEgnNnaDWwIB pLiidH/ooNYKDK4Q+/X6cdxY5BdAAKXHQdau6bhrDRN3+y4yrUntp/klM8ovZjhwB0O7 vmj6mqphZsO/T+luKm74dZ3d3LvWwwsHVq/XLhZv906LDTAkLlZJArxoguPu8CsP42cn twIgVBS7MfSPrPky5VZSb7ndpwg7SUsNO98xbt3VKDqzPf5G9Sj2+hPEr+wTJo7cSKiC +b8w== X-Gm-Message-State: AHQUAuZIMYDTmTTLjlTFPfbOeZeyyd+Fls7L4MNduuHdyATyTustqfb3 WwByYk4bsh5uZfw5iHN5PAj0STik X-Received: by 2002:a17:902:f01:: with SMTP id 1mr7516475ply.143.1549410951767; Tue, 05 Feb 2019 15:55:51 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.250]) by smtp.gmail.com with ESMTPSA id v184sm6770197pfb.182.2019.02.05.15.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 15:55:50 -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 v3 07/12] nfp: Implement ndo_get_port_parent_id() Date: Tue, 5 Feb 2019 15:53:21 -0800 Message-Id: <20190205235326.14600-8-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190205235326.14600-1-f.fainelli@gmail.com> References: <20190205235326.14600-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(). 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 | 23 +++++-------------- drivers/net/ethernet/netronome/nfp/nfp_port.h | 4 +++- 5 files changed, 12 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..b9aa7eb99067 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_port.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c @@ -31,34 +31,23 @@ 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; - } + /* N.B: attr->u.ppid.id is binary data */ + 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