From patchwork Fri Feb 22 12:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 10825957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E53913B5 for ; Fri, 22 Feb 2019 12:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 395F332482 for ; Fri, 22 Feb 2019 12:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D75332498; Fri, 22 Feb 2019 12:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F5832482 for ; Fri, 22 Feb 2019 12:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbfBVM6j (ORCPT ); Fri, 22 Feb 2019 07:58:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:39092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbfBVM6j (ORCPT ); Fri, 22 Feb 2019 07:58:39 -0500 Received: from localhost.localdomain (unknown [117.99.84.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7EEF820823; Fri, 22 Feb 2019 12:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550840318; bh=qeRTyujybP4NM3oAD6Tl4q2Mq2qRpukAkyJ9ZA8Z/ak=; h=From:To:Cc:Subject:Date:From; b=HYQfFQh9XAEdwuQZYzEGqWz41vbUdrmSymGjeUW7HdCnd53V+4NP9ZKx1K3CFQsib KtBOQkEKmTToG5YdakqFbVlCGtdjk7h7Ddf9ZnQPx743ZCnKe19fWO/G7j9FinuNml gpow7TkYG5oQGKGYVeifA7PbibN9tr7TSLIl3aP4= From: Vinod Koul To: "David S. Miller" Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Xiaofei Shen , Andrew Lunn , Vivien Didelot , Florian Fainelli , Niklas Cassel , netdev@vger.kernel.org, Vinod Koul Subject: [PATCH] net: dsa: read mac address from DT for slave device Date: Fri, 22 Feb 2019 18:28:15 +0530 Message-Id: <20190222125815.12866-1-vkoul@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Xiaofei Shen Before creating a slave netdevice, get the mac address from DTS and apply in case it is valid. Signed-off-by: Xiaofei Shen Signed-off-by: Vinod Koul Signed-off-by: xiaofeis Reviewed-by: Vinod Koul --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 1 + net/dsa/slave.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index b3eefe8e18fd..aa24ce756679 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -198,6 +198,7 @@ struct dsa_port { unsigned int index; const char *name; const struct dsa_port *cpu_dp; + const char *mac; struct device_node *dn; unsigned int ageing_time; u8 stp_state; diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index a1917025e155..afb7d9fa42f6 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -261,6 +261,7 @@ static int dsa_port_setup(struct dsa_port *dp) int err = 0; memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); + dp->mac = of_get_mac_address(dp->dn); if (dp->type != DSA_PORT_TYPE_UNUSED) err = devlink_port_register(ds->devlink, &dp->devlink_port, diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a3fcc1d01615..8e64c4e947c6 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1308,7 +1308,10 @@ int dsa_slave_create(struct dsa_port *port) slave_dev->features = master->vlan_features | NETIF_F_HW_TC; slave_dev->hw_features |= NETIF_F_HW_TC; slave_dev->ethtool_ops = &dsa_slave_ethtool_ops; - eth_hw_addr_inherit(slave_dev, master); + if (port->mac && is_valid_ether_addr(port->mac)) + ether_addr_copy(slave_dev->dev_addr, port->mac); + else + eth_hw_addr_inherit(slave_dev, master); slave_dev->priv_flags |= IFF_NO_QUEUE; slave_dev->netdev_ops = &dsa_slave_netdev_ops; slave_dev->switchdev_ops = &dsa_slave_switchdev_ops;