From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26308C43381 for ; Fri, 22 Feb 2019 15:43:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E88052070B for ; Fri, 22 Feb 2019 15:43:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JjNExQdx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbfBVPno (ORCPT ); Fri, 22 Feb 2019 10:43:44 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:36170 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfBVPnn (ORCPT ); Fri, 22 Feb 2019 10:43:43 -0500 Received: by mail-pg1-f193.google.com with SMTP id r124so1305761pgr.3; Fri, 22 Feb 2019 07:43:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=jLwy46dxddHBCiaDWFTU2TpO/ztpEjqMNz56ULM6W9Y=; b=JjNExQdxArt3L4hazudZiujJg6PCrK+jlkbh+I2Vi+If7LHpiJz4l+M5Z+UZaMEiO+ MnKomTQK0LhkkpzQ35htW91SyFMqQ9hed1LKNDXQ/Er4PI4ZC42Ai+6jOmaDXUUnWwxj qYXa9yFdqJk4oDs66tanIQFyJSyEdulSyb5RP7J9+WLraE9oGalJBCvj6O4GsFNmnhP2 z+9/21M0TlE8UCe76J+ahfL2GpdybemNTSKBsldxGC43h8UXf46ezQdZuBDgsjoAzCue /mkr36DerSmw4a8qLmLasueIaKw9U8a/LRIE8KxBeeBGBsf33y+nZ0aSWhm6Tkzf7UXt QrqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=jLwy46dxddHBCiaDWFTU2TpO/ztpEjqMNz56ULM6W9Y=; b=sIjXJ4Aug3yomrnaQBe2Ndgi332DtfoV0a8Oiq8ccPzymHWRo95qZNN+yf83pwsOWM 6QJwHoovDezwXgrZbm5SenC+CIXg3wgjo/DvBWp0qinXBzYZJUTL263hAGf5EmEpDVP7 4txPgSVZfRmVtmkCT72qYIxlmAMp3aKprSkMSQFCL04/+KnH/8IcMtn85q7cE4Ldf+VI JtB1GxO9UxwoFNniqY+uJ8jnja4mg1tJk3b2otBtduthwjeCLm3DLktaxFyvKM3892eS 5Neu2zP1D+Zo2b7/2My0/qtsbr/s7h3mF7xjBS9NZ53XY2pMIY6puQ1LmRDx1EUwpige I8LQ== X-Gm-Message-State: AHQUAubOaHR+YwB0/jHLz2KMGjxqQ8F4wtz+qtho9Y1cv+U52nPuI3Tj fTP8m4NHbD4jqyLO3m6L+1XFJ7Oo X-Google-Smtp-Source: AHgI3IYT2bXJiGKo73pEBfJc2nNp3YG/J6lShj+lUFLsaQR1ruZ8IbpkgVVvJ1cIFLRCeOT3NP3Jlg== X-Received: by 2002:a63:6184:: with SMTP id v126mr4518496pgb.277.1550850221858; Fri, 22 Feb 2019 07:43:41 -0800 (PST) Received: from [10.0.2.15] (ip68-228-73-187.oc.oc.cox.net. [68.228.73.187]) by smtp.gmail.com with ESMTPSA id f67sm2880049pff.29.2019.02.22.07.43.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 07:43:40 -0800 (PST) Subject: Re: [PATCH] net: dsa: read mac address from DT for slave device To: Vinod Koul , "David S. Miller" Cc: linux-arm-msm@vger.kernel.org, Bjorn Andersson , Xiaofei Shen , Andrew Lunn , Vivien Didelot , Niklas Cassel , netdev@vger.kernel.org References: <20190222125815.12866-1-vkoul@kernel.org> From: Florian Fainelli Message-ID: <9baf097f-37ea-2bef-92dd-25a7040a16ed@gmail.com> Date: Fri, 22 Feb 2019 07:43:36 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190222125815.12866-1-vkoul@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2/22/19 4:58 AM, Vinod Koul wrote: > From: Xiaofei Shen > > Before creating a slave netdevice, get the mac address from DTS and > apply in case it is valid. Can you explain your use case in details? Assigning a MAC address to a network device that represents a switch port does not quite make sense in general. The switch port is really representing one end of a pipe, so one side you have stations and on the other side, you have the CPU/management Ethernet MAC controller's MAC address which constitutes a station as well. The DSA slave network devices are just software constructs meant to steer traffic towards specific ports of the switch, but they are all from the perpsective of traffic reaching the CPU Port in the first place, therefore traffic that is generally a known unicast Ethernet frame with the CPU's MAC address as MAC DA (and of course all types of unknown MC, management traffic etc.) By default, DSA switch need to come up in a configuration where all ports (except CPU/management) must be strictly separate from every other port such that we can achieve what a standalone Ethernet NIC would do. This works because all ports are isolated from one another, so there is no cross talk and so having the same MAC address (the one from the CPU) on the DSA slave network devices just works, each port is a separate broadcast domain. Once you start bridging one or ore ports, the bridge root port will have a MAC address, most likely the one the CPU/management Ethernet MAC, but similarly, this is not an issue and that's exactly how a software bridge would work as well. > > Signed-off-by: Xiaofei Shen > Signed-off-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; > -- Florian