Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1692486img; Wed, 27 Feb 2019 03:54:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IbFx7kO4WswyiTVgOGk8HCNqqD9djK6Vk7x9G9/ibdkd+L7fMngL8PSjlGFdnuTNJrJyi9b X-Received: by 2002:a65:60c2:: with SMTP id r2mr2613780pgv.319.1551268494371; Wed, 27 Feb 2019 03:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551268494; cv=none; d=google.com; s=arc-20160816; b=GIisdwN/ME3bNb7q3w1ORRz2dZ5Xrsfs2wt+MGYaRkO6FG1Mt2fNT9YhQGXGHpqvoH S8ZmLjhYn/IZTITc5xLmH4NAQThGS5DZzA1KaZI9bwzEJGoLTuyggaAIwFYNSLnWJMeP EtHWx82IJ246qwxWWS+yCnpabs6Dr0T4AnaUxStTdR/NF/fIxiYElZeZxPXp1tfxycmr DkHnsA1/tQuKCIliyWrPuT7AcWYzzTxtwxjJshn6uen94fui2G+oY9S3zBHPsAO59+1G TzNEP4sHHHJoLYWK8VZRkw+5Xabog//b5Vvw5QwO6wrvR1ClrivWmq4F4bu0h3iNTTkl ZXog== 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:cc:to:subject :message-id:date:from:mime-version; bh=aVGs+eLRhr1aRdVyCK/3bU/6sS9ma7B4pS1Lf+pwYBE=; b=f/oYAaVJXWJpz45djEBoFG8xM5A9tOSEJ22TWWG3pDyvGcVexs2sl/AT8X7knvD2DG TkfvvbKxZKET+nFKtz0hDYA2oUDks3efFeGp/LYJvEZNb9dgr59KnBvb9xOHmu94IEjf REMohU4lejFEWZhRnapNlheXZdvk6utHpNmZJ/4TquNh2MjomycS+YMsrU2/2C5VBune 1nhc6fEhY0Yv96UMcxSANJXY6JgGBuKz/J8v8R5cwDcEZkYe+5ZGS0+6NDZdC7IVUu0W zdWHqCauLo0JqJBAB6k2K6f9EiVDtbEfWSjdVnsrho/+O9tsRcfyBBe49JnZQ/5P5LaR awnA== ARC-Authentication-Results: i=1; mx.google.com; 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 t11si14144081pgp.209.2019.02.27.03.54.37; Wed, 27 Feb 2019 03:54:54 -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; 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 S1729784AbfB0LyP convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Feb 2019 06:54:15 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:45363 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbfB0LyP (ORCPT ); Wed, 27 Feb 2019 06:54:15 -0500 Received: by mail-ot1-f68.google.com with SMTP id w26so739346otp.12; Wed, 27 Feb 2019 03:54:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-transfer-encoding; bh=2LxEjR3G2n0l98DT4cTFD+bn75tx4VrgpL+4Cuot5VM=; b=pTnECgqrc+MNBddM4GVcAfrKV7D+5THkf+QHJ92oh/m8Q1RkClpjchjZF1RxFcw77L Y7TVKuaAhOyg9PIaC3nejvAKknJx1bXizCtO9WWDByFE0yHKF1wIIU27IQuOjPEUkKa2 Y+93wuhKJ1zee0eLepzxZ6xrHcPlxNN4m/6wi47yyLT/fVNPuy9NuQ6TnJLy9SybZmGo NhQcykZXFajwjZwkg81V4itVNau673R43/EJDiBzXQin8gqhxUGi217XMh9fi8cHmrdq q42qpLsvX+YP3AU0nGCtv4ln350BEljQ5om57w99whhQjvil5sm5+YNwyaqMEx1dzlZr ctww== X-Gm-Message-State: AHQUAub5jgow28GUcWIdcyudTF9mbK61C6LotDACQb05mB3C1YpTKTR/ izBt6WVxvepcVUSDZlIdRjRbhzKm+tMe5lOcGgFblGQC X-Received: by 2002:a9d:58c6:: with SMTP id s6mr1981834oth.122.1551268454099; Wed, 27 Feb 2019 03:54:14 -0800 (PST) MIME-Version: 1.0 From: Harini Katakam Date: Wed, 27 Feb 2019 17:24:03 +0530 Message-ID: Subject: Request for suggestion on net device re-naming/re-ordering based on DT alias To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Ferre , David Miller Cc: Michal Simek , Harini Katakam , Harini Katakam Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, 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. 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 = &mac1; ethernet1 = &mac0; }; Driver probe: + /* Read ethernet DT alias id and assign to right device name*/ + id = 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); + These three drivers seem to have something similar for mdio/phy bus IDs: drivers/net/ethernet/broadcom/genet/bcmmii.c:409: id = of_alias_get_id(dn, "eth"); drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c:43: plat->bus_id = of_alias_get_id(np, "ethernet"); drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:404: plat->bus_id = of_alias_get_id(np, "ethernet"); 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? 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= , , eth0 netdev=, , eth1 Could you please suggest any alternatives? Thanks! Regards, Harini