From patchwork Thu Mar 28 12:56:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 1068138 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="mcUZdn0C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44VPyd5DkVz9sP7 for ; Thu, 28 Mar 2019 23:56:57 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbfC1M44 (ORCPT ); Thu, 28 Mar 2019 08:56:56 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:54985 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbfC1M4y (ORCPT ); Thu, 28 Mar 2019 08:56:54 -0400 Received: by mail-wm1-f68.google.com with SMTP id f3so3497917wmj.4 for ; Thu, 28 Mar 2019 05:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I49Ds4qM5ZKYH618laQsxd17YPs7sPYff/WMd8vZDDQ=; b=mcUZdn0CQdMVAUkaW4Lzi1JGJaQ4Hn6ISZo5zAQro7NI+XXNrX7D/zGNkLbp2DCnSY A46nY4pF+Iu6Y7DoOFh4Jw3ieGKfIGBT/uXsa7RxJAfUT6c6l5InxHwhn6AH5T26s2FZ Xov9Z1kMgyZgZxFavmHsG7D2Ymy2lkDMKqxGXnhUyN3G80q3sU6TBvJU04F6EIJxl4bz nJoGRE+rT+1EnXYR55+hr7dbmzi45iL80yZjm+poIfheS4BiRDrJa5aWrCvdRAdanjQL 6lti06aqvWLPMun+9Ql5V9ny9yc5L5+Aw9qTMQVG0vPAww/MN8WkA0iEpNiuNQghKUCK w40g== 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=I49Ds4qM5ZKYH618laQsxd17YPs7sPYff/WMd8vZDDQ=; b=LcR1dQj0E5Wj9TH8JZp/jbV6szUsRDDn3VQulpMqJVZzaq6GKHUiH9hBG+aG588vWu ezygK137aUU6UxqBN5A7GnTuC6Va+V675qxJy73h5aUE0BnR91NRSnh1sPy5BzF6tFP6 G89nBhMJ+YiYbTCZg/lQTkA1wdKPrn3PUql0G7TtV9HVYc0XbjgbLVdPV3hC0S8MHBcN 5t24xtc8gzA//L1ioyG6RcaGgZqm5YWFDMdrhCySJ6lIhol5Sxe1Rv+6GxgQ07G9qhuM ipW7NrAqDaOmrFhn8dBe92N9fSEIAf+/M36orsWx7cS3PUqavmWAp8M3NzZRoZtSwBK9 G66g== X-Gm-Message-State: APjAAAUxOQSvVXWMA9zEd6qkrermNdBbjSYqVy0bjKEIlMVDk2Ps3QE5 Hy3TNyNMAn6Ct5DajAWTbLHnacZhG/Y= X-Google-Smtp-Source: APXvYqwHnhTIGJ9qRoKUtRZYzHoeM3Q5IsDVjbI5KcjkrblNSRK4KBGaxDVkL1U8pba40I/oHjF6rA== X-Received: by 2002:a1c:7211:: with SMTP id n17mr9340462wmc.32.1553777811807; Thu, 28 Mar 2019 05:56:51 -0700 (PDT) Received: from localhost (ip-94-113-223-73.net.upcbroadband.cz. [94.113.223.73]) by smtp.gmail.com with ESMTPSA id z11sm4252111wmf.12.2019.03.28.05.56.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Mar 2019 05:56:51 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, mlxsw@mellanox.com, idosch@mellanox.com, jakub.kicinski@netronome.com, f.fainelli@gmail.com, andrew@lunn.ch, vivien.didelot@gmail.com, michael.chan@broadcom.com Subject: [patch net-next v4 04/12] mlxsw: Implement ndo_get_devlink_port Date: Thu, 28 Mar 2019 13:56:38 +0100 Message-Id: <20190328125646.872-5-jiri@resnulli.us> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190328125646.872-1-jiri@resnulli.us> References: <20190328125646.872-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jiri Pirko In order for devlink compat functions to work, implement ndo_get_devlink_port. Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/core.c | 12 ++++++++++++ drivers/net/ethernet/mellanox/mlxsw/core.h | 3 +++ drivers/net/ethernet/mellanox/mlxsw/minimal.c | 11 +++++++++++ drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 11 +++++++++++ drivers/net/ethernet/mellanox/mlxsw/switchx2.c | 11 +++++++++++ 5 files changed, 48 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c index e70bb673eeec..aa71aeb44101 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c @@ -1807,6 +1807,18 @@ int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core, } EXPORT_SYMBOL(mlxsw_core_port_get_phys_port_name); +struct devlink_port * +mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, + u8 local_port) +{ + struct mlxsw_core_port *mlxsw_core_port = + &mlxsw_core->ports[local_port]; + struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port; + + return devlink_port; +} +EXPORT_SYMBOL(mlxsw_core_port_devlink_port_get); + static void mlxsw_core_buf_dump_dbg(struct mlxsw_core *mlxsw_core, const char *buf, size_t size) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index 74e95e943b24..cb870502f04c 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -178,6 +178,9 @@ enum devlink_port_type mlxsw_core_port_type_get(struct mlxsw_core *mlxsw_core, u8 local_port); int mlxsw_core_port_get_phys_port_name(struct mlxsw_core *mlxsw_core, u8 local_port, char *name, size_t len); +struct devlink_port * +mlxsw_core_port_devlink_port_get(struct mlxsw_core *mlxsw_core, + u8 local_port); int mlxsw_core_schedule_dw(struct delayed_work *dwork, unsigned long delay); bool mlxsw_core_schedule_work(struct work_struct *work); diff --git a/drivers/net/ethernet/mellanox/mlxsw/minimal.c b/drivers/net/ethernet/mellanox/mlxsw/minimal.c index 0ee1656609f5..d6e6042223f9 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/minimal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/minimal.c @@ -73,11 +73,22 @@ static int mlxsw_m_port_get_port_parent_id(struct net_device *dev, return 0; } +static struct devlink_port * +mlxsw_m_port_get_devlink_port(struct net_device *dev) +{ + struct mlxsw_m_port *mlxsw_m_port = netdev_priv(dev); + struct mlxsw_m *mlxsw_m = mlxsw_m_port->mlxsw_m; + + return mlxsw_core_port_devlink_port_get(mlxsw_m->core, + mlxsw_m_port->local_port); +} + static const struct net_device_ops mlxsw_m_port_netdev_ops = { .ndo_open = mlxsw_m_port_dummy_open_stop, .ndo_stop = mlxsw_m_port_dummy_open_stop, .ndo_get_phys_port_name = mlxsw_m_port_get_phys_port_name, .ndo_get_port_parent_id = mlxsw_m_port_get_port_parent_id, + .ndo_get_devlink_port = mlxsw_m_port_get_devlink_port, }; static int mlxsw_m_get_module_info(struct net_device *netdev, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index eaf86c4c2f6c..1225fa50f36f 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -1726,6 +1726,16 @@ static int mlxsw_sp_port_get_port_parent_id(struct net_device *dev, return 0; } +static struct devlink_port * +mlxsw_sp_port_get_devlink_port(struct net_device *dev) +{ + struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); + struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; + + return mlxsw_core_port_devlink_port_get(mlxsw_sp->core, + mlxsw_sp_port->local_port); +} + static const struct net_device_ops mlxsw_sp_port_netdev_ops = { .ndo_open = mlxsw_sp_port_open, .ndo_stop = mlxsw_sp_port_stop, @@ -1742,6 +1752,7 @@ static const struct net_device_ops mlxsw_sp_port_netdev_ops = { .ndo_get_phys_port_name = mlxsw_sp_port_get_phys_port_name, .ndo_set_features = mlxsw_sp_set_features, .ndo_get_port_parent_id = mlxsw_sp_port_get_port_parent_id, + .ndo_get_devlink_port = mlxsw_sp_port_get_devlink_port, }; static void mlxsw_sp_port_get_drvinfo(struct net_device *dev, diff --git a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c index 568883fc40df..696b8c8547bc 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/switchx2.c +++ b/drivers/net/ethernet/mellanox/mlxsw/switchx2.c @@ -401,6 +401,16 @@ static int mlxsw_sx_port_get_port_parent_id(struct net_device *dev, return 0; } +static struct devlink_port * +mlxsw_sx_port_get_devlink_port(struct net_device *dev) +{ + struct mlxsw_sx_port *mlxsw_sx_port = netdev_priv(dev); + struct mlxsw_sx *mlxsw_sx = mlxsw_sx_port->mlxsw_sx; + + return mlxsw_core_port_devlink_port_get(mlxsw_sx->core, + mlxsw_sx_port->local_port); +} + static const struct net_device_ops mlxsw_sx_port_netdev_ops = { .ndo_open = mlxsw_sx_port_open, .ndo_stop = mlxsw_sx_port_stop, @@ -409,6 +419,7 @@ static const struct net_device_ops mlxsw_sx_port_netdev_ops = { .ndo_get_stats64 = mlxsw_sx_port_get_stats64, .ndo_get_phys_port_name = mlxsw_sx_port_get_phys_port_name, .ndo_get_port_parent_id = mlxsw_sx_port_get_port_parent_id, + .ndo_get_devlink_port = mlxsw_sx_port_get_devlink_port, }; static void mlxsw_sx_port_get_drvinfo(struct net_device *dev,