Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp2119556img; Wed, 27 Feb 2019 10:41:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IYGlR9lOzP2zeZMEAWAgwEMhRoZKpFV3uACN6wV/xPxtFjFzqBe8haLMfP4wF/3YCqOScPv X-Received: by 2002:a62:69c3:: with SMTP id e186mr3013098pfc.169.1551292869921; Wed, 27 Feb 2019 10:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551292869; cv=none; d=google.com; s=arc-20160816; b=y48HD8O5PiJQoZzDOI0oFQVzqabXnLkhTQ3ghoCLrHlpGRwtNaIVB2CHl7EpEzRzp/ RH0htlcQIkAvshk2vrgl3oPvT6nj4b1syAqwq/Zd59NgNcwo3a04Qe/WLmLE+JOQHtXB ZiiOMBsf4IfmoOyhNB0XOznJUYpmLEnpxFNZHOuxC4v9xrxPudyRQJzH8WjXhYSBhfQV Yehi48n40ORRb6Fiw28N/JAKiSN7yY+GlNukOI1Hnx9pe7ycoDnKUFKnKy8lWS9raSXX 1yezuYahPznlzUD1bwuwOBxK1nXNxlyAq5eHDkmzwjqlY+DXzR61eidN3Jr0Wtn/tW8G eR4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=MgxCH2yRcy0/a3sHAu7Y7l4oM3URGcXqPS7a9ORZj6I=; b=Q9u//s+TlORLKvj4/srOyRNVxHikQrhpj2n2vBgwi4z+6YNr/I6YMYTSC3PP3wU4WA Jf5fJp1t7if8wxHZraFVicXGuWqZB7IvRdShTpySkuQaEbt1NTRk5hghtV4/zTXCDnX5 VVfWCqdxL99tw/e81eRs/K4U6BEVqBalwfUEWmY5RKLwiKQ7Gw42B81s4MON397u8bx4 WMg+SIQ7VY33t88t6zknIUQx5GqrJogVTeXRR9vWfs6xcle/H/rxsG9zxMVFw5hJQ4JB cQVQXim5aItB9wS5NuW6/XMhtZqolu/KzKeKERNdq5aAlYnZPML3gGdbpk3Op6g7QtgG YheA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b="D/h6eaaX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y185si14802235pgd.117.2019.02.27.10.40.56; Wed, 27 Feb 2019 10:41:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b="D/h6eaaX"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbfB0Ske (ORCPT + 99 others); Wed, 27 Feb 2019 13:40:34 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42335 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726594AbfB0Skd (ORCPT ); Wed, 27 Feb 2019 13:40:33 -0500 Received: by mail-pg1-f196.google.com with SMTP id b2so8364572pgl.9 for ; Wed, 27 Feb 2019 10:40:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MgxCH2yRcy0/a3sHAu7Y7l4oM3URGcXqPS7a9ORZj6I=; b=D/h6eaaXsN7UGubF6KL/3De6CYDXG1FruFU9VYgpCfUu+Oykaa76hkqE1Q9CUShPqd u9vv6+eGUJg9iUQueo2lpNXZ0XmLmDyLg955NAmgU4K6IoLIUGfsERTKZePwvcPiMtkU LhMKEQPT665BGXs2ORygAyvj/PGYz9fhy9Fk2c9tahwXzFtHjCdcbIy4IdulBohSzGaY gKF8nco/o+e5E8FUJHBwh5oFdntHsa37r312sisitFV33Afletht17enGpgBhAwWi/cL 1IVqdORhSvSqB2KBVai/CYfmYszb1Oy1+FnyYuvTmfACD3Zs78zTfq9hVRJtcGt+vaWX X5Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MgxCH2yRcy0/a3sHAu7Y7l4oM3URGcXqPS7a9ORZj6I=; b=UeRusWsVE12LCUMXydJvKToXCTWFOVy36oPhWEN3D6jiOhX7H6OyY/ZVe5nTP/bLfv /xkQdJ5bsY0x1b5ls3YeCTHQ4S7RnQLepQxiYKVKLUsHBCVxHn2s2xE0dl97ybPrcsyP xEjq45RxibplxhI+UG/oQFP8Bw4kLrEJ5o6S9KW4O2Wj6iRuys4oSbf8LKNXq8pZVFuP /XWvJkd2oCQ2Qhaqm5JfeDnN2rWceCKYQWA+JHtX6A8PfJYuL/cW78tBMimfczI7vlcY IREiurMTs8qnqa3iqsIZXnyH9jQYkLdixHB1T0ag43ztPH9695Gct/8fdMb0NFTFzCwS vN0g== X-Gm-Message-State: AHQUAuZYbYsMTQ8ZSzCLdDoS1Hi69bs2r19mjaflm1ZeLvegFGjr3X9n lf1PoLJO1Mn8b1B7BT/ibE5ceQ== X-Received: by 2002:a62:11ca:: with SMTP id 71mr3106395pfr.18.1551292832821; Wed, 27 Feb 2019 10:40:32 -0800 (PST) Received: from shemminger-XPS-13-9360 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id b26sm21393089pfo.33.2019.02.27.10.40.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 10:40:32 -0800 (PST) Date: Wed, 27 Feb 2019 10:40:28 -0800 From: Stephen Hemminger To: Harini Katakam Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Ferre , David Miller , Michal Simek , Harini Katakam , Harini Katakam Subject: Re: Request for suggestion on net device re-naming/re-ordering based on DT alias Message-ID: <20190227104028.707a75e2@shemminger-XPS-13-9360> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Feb 2019 17:24:03 +0530 Harini Katakam wrote: > Hi, >=20 > We've had some users requesting control over net device name order > when multiple ethernet devices are present on a system. I've tried a > few solutions to this and looked it up on forums. But I apologize if > I have missed something. >=20 > I know that the current system allocates eth as per probe order > but that is obviously not stably controlled by user (tried DT > re-ordering and defer probe). One solution is to use DT alias names > to write to (net_device)->name as follows: > Devicetree: > aliases { > ethernet0 =3D &mac1; > ethernet1 =3D &mac0; > }; > Driver probe: > + /* Read ethernet DT alias id and assign to right device name*/ > + id =3D of_alias_get_id(np, "ethernet"); > + if (id < 0) { > + dev_warn(&pdev->dev, "failed to get alias id (%u)\n", id); > + return id; > + } > + snprintf(dev->name, sizeof(dev->name), "eth%d", id); > + >=20 > These three drivers seem to have something similar for mdio/phy bus IDs: > drivers/net/ethernet/broadcom/genet/bcmmii.c:409: id =3D > of_alias_get_id(dn, "eth"); > drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c:43: plat->bus_id =3D > of_alias_get_id(np, "ethernet"); > drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:404: > plat->bus_id =3D of_alias_get_id(np, "ethernet"); >=20 > Drawback: This approach will break if alias is not provided for one > of the interfaces on board. Not to mention, there could be systems > with multiple ethernet makes (for ex. Cadence macb and Xilinx axienet) > If one of the drivers does not have an alias read mechanism, it is > possible to have clashing ID assignments. Is there any way this > solution can be changed to be stable/acceptable? >=20 > One other alternative I've tried is netdev kernel bootargs but this > device name was not being picked by the kernel: > https://www.kernel.org/doc/html/v4.19/admin-guide/kernel-parameters.html > netdev=3D , , e= th0 > netdev=3D, , et= h1 >=20 > Could you please suggest any alternatives? > Thanks! >=20 > Regards, > Harini Device naming is a hard problem, and there is no perfect solution. Device tree should be providing hints to userspace policy for naming, not trying to do it in the kernel.=20 See: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkIn= terfaceNames/