Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6601298rwb; Tue, 15 Nov 2022 00:33:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6kLYW/lcMByFc2LIEt0tzAASnYL6Vc7DHW+5tEATH7l1e0pP3yzhWwM6jLgaYP6qv6C/Np X-Received: by 2002:a17:902:6ac5:b0:176:a880:6d72 with SMTP id i5-20020a1709026ac500b00176a8806d72mr2921849plt.127.1668501222537; Tue, 15 Nov 2022 00:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668501222; cv=none; d=google.com; s=arc-20160816; b=ptbg2kuN3HAxdCJR/NO9TKdG/zj3Fxbiglngbag7E1u6pLEAr6Kzb6GoyIF6xnAuJi ecBlW5X5s0u9iC7b1PmEBwrgUC42AgyCgqmGIck7Qj/+okisLoRF1/HGITA0xJOxk/sj IuJSBvs0VKnSRH6FmYCkfEzq4S8a38aXIZPboPC3B2usL+vy+GsL2bQkHHE5Wu9UJHjb kfr4+iqXeS9xg5EcbhBV3V2He6QuMcW6k+W01NHxkfK1LYUwzM4tiQN0wXYkJ5ocAg1m SZEuWl72sfkt7elVjf+ZeNkLvvfikfVHWgJMOJA/fu/ZeMYvGrWc+mWBOHEk4IV9zgx7 A9iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XrOEygdWi3pXEJQNDPsb806sEtq19Rqxin4IiMd3olc=; b=wr7aZEcdRKqmgN34hlLRRLLKteLa3mHR9O8qZ7NS+gYjli2+0hqfinbdrLCJUIvPv0 kU8PYPSGBgD1VKR6rBujlwVCSyhp6xa61zwMN8kU+L+AYiZ3ZiXRg+uNa6smsLaovhbs 44OgVklF3/K2npyH1M4jDDxkspyZjeU97YPienxMjLswnJ0/V2LDU1JO2acc+yShoEP/ wqh5d+UQuv56+pBft5YHfQmK54QY1l7LpEE4woCtCfmXErWTAE0+EZm3CyeFNuWTIjdO 9ho5Z7kmHfPLZObL7eixP01at7S/vOFHmVH6egH9T0ffwxLK6psvyGrvJ5BBN1PVSeo7 HDyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=aHw8ddTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu11-20020a17090b1b0b00b00212b9a2d735si11671305pjb.121.2022.11.15.00.33.30; Tue, 15 Nov 2022 00:33:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=aHw8ddTP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiKOHoE (ORCPT + 88 others); Tue, 15 Nov 2022 02:44:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbiKOHoD (ORCPT ); Tue, 15 Nov 2022 02:44:03 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 320011C93D for ; Mon, 14 Nov 2022 23:44:01 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id x21so16413331ljg.10 for ; Mon, 14 Nov 2022 23:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XrOEygdWi3pXEJQNDPsb806sEtq19Rqxin4IiMd3olc=; b=aHw8ddTPEpBYzI9XNrZBUhY7QEUdAqdwK+4DIhY5/ttzsxZHXagVnVZWwqbSsnR/L9 BAtWJEJ8HlDMOz1lFNo69MeWGGDA/mXbKhmo5RsHGZg+Of1ZN2snQqbQee0Tit1FOC/Q kS64xE0nlozCRV7MIF7KZMgdp+69c5/9FBIe0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XrOEygdWi3pXEJQNDPsb806sEtq19Rqxin4IiMd3olc=; b=BD/H8+BlcdSXSeAcM9m+awZSuO37YS/0J5xKQQVBwOAgi5ViNU2I6W2HXN24lbGkcK /H2VZcVPcc+Mkf1EA7I13qwZeKJoxRl9HUq2qOD/TP4QD9wiTFjR6svYvy1KkpBJGN7D OAuT7l/R1wvCCnu2/QYg8NviaxiVgmmpNhE3GZUMJ9ERm+HacReV1xpuUQDctDfccEdt DkYlO1ntVyHEAAkRX+SahpoXEVARQwQGIOVML2SrBsHPx8KqV4I53r43BBj4aA1RRPsk yfGfyIAJ7r3f7NBfg7jPonxzTvqAD3bBxqfH/qjkpqVx4VOPxYbSdPVHL0WLnSSD3c3Q QOrw== X-Gm-Message-State: ANoB5pmAR34ZuLyDjrAYLuvmEh5PTUHzRY4lF2eSrQbf4/7MQFM9tpqc J0CodTEAAhWoKZgTBQxJJQEqsQ== X-Received: by 2002:a2e:8544:0:b0:277:e01:610f with SMTP id u4-20020a2e8544000000b002770e01610fmr4948523ljj.60.1668498239466; Mon, 14 Nov 2022 23:43:59 -0800 (PST) Received: from prevas-ravi.prevas.se ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id m20-20020a056512359400b00498fc3d4cfdsm2119742lfr.189.2022.11.14.23.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 23:43:58 -0800 (PST) From: Rasmus Villemoes To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Rasmus Villemoes , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] net: dsa: use more appropriate NET_NAME_* constants for user ports Date: Tue, 15 Nov 2022 08:43:55 +0100 Message-Id: <20221115074356.998747-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221111161729.915233-1-linux@rasmusvillemoes.dk> References: <20221111161729.915233-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a user port has a label in device tree, the corresponding netdevice is "predictably named by the kernel". Expose that information properly for the benefit of userspace tools that make decisions based on the name_assign_type attribute, e.g. a systemd-udev rule with "kernel" in NamePolicy. Similarly, when we fall back to the eth%d scheme, the proper constant to use is NET_NAME_ENUM. See also commit e9f656b7a214 ("net: ethernet: set default assignment identifier to NET_NAME_ENUM"), which in turn quoted commit 685343fc3ba6 ("net: add name_assign_type netdev attribute"): ... when the kernel has given the interface a name using global device enumeration based on order of discovery (ethX, wlanY, etc) ... are labelled NET_NAME_ENUM. Signed-off-by: Rasmus Villemoes --- v2: switch to NET_NAME_ENUM in the eth%d case (Andrew, Jakub). Update commit message accordingly. net/dsa/dsa2.c | 3 --- net/dsa/slave.c | 13 +++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index e504a18fc125..522fc1b6e8c6 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -1364,9 +1364,6 @@ static struct dsa_port *dsa_port_touch(struct dsa_switch *ds, int index) static int dsa_port_parse_user(struct dsa_port *dp, const char *name) { - if (!name) - name = "eth%d"; - dp->type = DSA_PORT_TYPE_USER; dp->name = name; diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a9fde48cffd4..821ab79bb60a 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2374,16 +2374,25 @@ int dsa_slave_create(struct dsa_port *port) { struct net_device *master = dsa_port_to_master(port); struct dsa_switch *ds = port->ds; - const char *name = port->name; struct net_device *slave_dev; struct dsa_slave_priv *p; + const char *name; + int assign_type; int ret; if (!ds->num_tx_queues) ds->num_tx_queues = 1; + if (port->name) { + name = port->name; + assign_type = NET_NAME_PREDICTABLE; + } else { + name = "eth%d"; + assign_type = NET_NAME_ENUM; + } + slave_dev = alloc_netdev_mqs(sizeof(struct dsa_slave_priv), name, - NET_NAME_UNKNOWN, ether_setup, + assign_type, ether_setup, ds->num_tx_queues, 1); if (slave_dev == NULL) return -ENOMEM; -- 2.37.2