From patchwork Tue Aug 26 04:49:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 382938 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 378C5140110 for ; Tue, 26 Aug 2014 14:51:09 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933760AbaHZEvE (ORCPT ); Tue, 26 Aug 2014 00:51:04 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:40579 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932434AbaHZEug (ORCPT ); Tue, 26 Aug 2014 00:50:36 -0400 Received: by mail-pd0-f181.google.com with SMTP id g10so21744995pdj.12 for ; Mon, 25 Aug 2014 21:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EptPzupEIGfgr/bAuFZ83K/ExW4H7fPV/yYf2FAcheo=; b=M/WoTiKSMHYCzvKtCPy2SjGg8DYGkW16ACEFjuM7ObZZvwCh/z+aEAEDsGiaTYh7Jd AKL1sii+Do4IbiqEvQoE8shi8l/WIsX0NjcAexYQB48HwPEEDYsMlUVF09xKSS9deW0U 5wuT3gq3FacMYRDQ1K0vFQ2ehzJOP6zp6rbVFCWmUfXe7Be4usMTq2427qs8PR33Kzv/ Xl2mtFROdj8qkZLiFq4qbVFz55yDXgwvikHGQbzhXMVcYTKPq8olMmqd3Or2Be2OxR3H zSPrJSXHCtcazHTUHmxTja75hvwtl18PQhmR/8B9fTYd9ahnDAVEPyUOFP17WfiJLeCk 8sdw== X-Received: by 10.70.45.97 with SMTP id l1mr16702860pdm.148.1409028636406; Mon, 25 Aug 2014 21:50:36 -0700 (PDT) Received: from fainelli-desktop.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id na5sm1291348pbc.22.2014.08.25.21.50.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Aug 2014 21:50:35 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , davem@davemloft.net, linville@tuxdriver.com, jhs@mojatatu.com, alexander.duyck@gmail.com Subject: [PATCH net-next v4 08/13] net: dsa: allow drivers to do link adjustment Date: Mon, 25 Aug 2014 21:49:36 -0700 Message-Id: <1409028581-17399-9-git-send-email-f.fainelli@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409028581-17399-1-git-send-email-f.fainelli@gmail.com> References: <1409028581-17399-1-git-send-email-f.fainelli@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Whenever libphy determines that the link status of a given PHY/port has changed, allow to call into the switch driver link adjustment callback so proper actions can be taken care of by the switch driver upon link notification. Signed-off-by: Florian Fainelli --- include/net/dsa.h | 7 +++++++ net/dsa/slave.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index 1035f6452d79..2d3835924dd2 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -16,6 +16,7 @@ #include #include #include +#include #define DSA_MAX_SWITCHES 4 #define DSA_MAX_PORTS 12 @@ -182,6 +183,12 @@ struct dsa_switch_driver { void (*poll_link)(struct dsa_switch *ds); /* + * Link state adjustment (called from libphy) + */ + void (*adjust_link)(struct dsa_switch *ds, int port, + struct phy_device *phydev); + + /* * ethtool hardware statistics. */ void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 241c2a1684cb..398d0663d3dd 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -333,6 +333,7 @@ static const struct dsa_device_ops notag_netdev_ops = { static void dsa_slave_adjust_link(struct net_device *dev) { struct dsa_slave_priv *p = netdev_priv(dev); + struct dsa_switch *ds = p->parent; unsigned int status_changed = 0; if (p->old_link != p->phy->link) { @@ -350,6 +351,9 @@ static void dsa_slave_adjust_link(struct net_device *dev) p->old_pause = p->phy->pause; } + if (ds->drv->adjust_link && status_changed) + ds->drv->adjust_link(ds, p->port, p->phy); + if (status_changed) phy_print_status(p->phy); }