From patchwork Sun Oct 4 16:12:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 1376450 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=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lunn.ch Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4C480f0RJQz9sSC for ; Mon, 5 Oct 2020 03:13:22 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726127AbgJDQNO (ORCPT ); Sun, 4 Oct 2020 12:13:14 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:42532 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726077AbgJDQNM (ORCPT ); Sun, 4 Oct 2020 12:13:12 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94) (envelope-from ) id 1kP6dJ-0003eY-DK; Sun, 04 Oct 2020 18:13:09 +0200 From: Andrew Lunn To: David Miller Cc: netdev , Florian Fainelli , Vladimir Oltean , Jiri Pirko , Jakub Kicinski , Andrew Lunn Subject: [PATCH net-next v3 6/7] net: dsa: Add helper for converting devlink port to ds and port Date: Sun, 4 Oct 2020 18:12:56 +0200 Message-Id: <20201004161257.13945-7-andrew@lunn.ch> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201004161257.13945-1-andrew@lunn.ch> References: <20201004161257.13945-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hide away from DSA drivers how devlink works. Signed-off-by: Andrew Lunn Reviewed-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- include/net/dsa.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index ca426cf9927b..c0185660881c 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -701,6 +701,20 @@ static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl) return dl_priv->ds; } +static inline +struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port) +{ + struct devlink *dl = port->devlink; + struct dsa_devlink_priv *dl_priv = devlink_priv(dl); + + return dl_priv->ds; +} + +static inline int dsa_devlink_port_to_port(struct devlink_port *port) +{ + return port->index; +} + struct dsa_switch_driver { struct list_head list; const struct dsa_switch_ops *ops;