Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2395449rwb; Fri, 11 Nov 2022 08:44:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xFLeDV7nHFyBqUpBnIdYUnXGSkLL0FHbH8ltQgIba+3/0nwfZKqd8aDCuGNnXEdNJgK9O X-Received: by 2002:aa7:dd1a:0:b0:461:c2a4:c419 with SMTP id i26-20020aa7dd1a000000b00461c2a4c419mr2147079edv.399.1668185045391; Fri, 11 Nov 2022 08:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668185045; cv=none; d=google.com; s=arc-20160816; b=J3aVGJh4O74CCP2RbyEn6MdR1aFRnclGuTKKszAXVfeCsHlnO4rqauPjoO4aNeI+XD Nvcwja66eC3oaGi7wylZpPIXQJ5Y0ecMPpsWIxLN/c0QmdsPFVzD61ejeeZfB7wpb9Lk mDRnvlOUgY3OoMLHVbIG8twinfwRQ4728w8Ieaw8r7DFM5FV7LCrS3WWCKcngiE5JVeF WsRiES/vhYa7BP6wvzkBdVtPgrxnJv5wNljEFUGw9VwYE2qOMtIBeVwgC5QvnJr3f1u0 qihwq92GFPtaNzAfCcabvB2MQQbZUScLNpyKL6Vcwf5e2+ST1+hcZ9nEb3Engz61uaQW YiCA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=PPFK299nWfDr/V9J7p74DjQEhALYVf51OEuCFpbYSbM=; b=fg+geHHqbGpIJoIKDD2cQzLlqUXOsDXuKHV1bklLyX12+r+1j71tnnWspcokPZPmAb g9LVA2Ro6xP4AwHoPn19wtymyR7ob3o0Bfnb0uiDeXQuxjSjoRJBZcnTrqhQXGkRT5rs F+xCyfYKxeYaltzR9Sj+u9+bId6iX+k+EwfDtrXXwB+Jajm/nIrJFTCtgAOe+VzhOqEi oTIIcRQmlXPI/YtjHF2VQntFeJAT5+WMJOWJFfZmjkGRldL9TnRupjGrf3+NDq9VaRNQ sydx+FrlC6lmNkGZvuvQ/FUP/VEWHMeWUeV4shII6wAaw3SrjNKjTaoogz9d1mSs1K5H g3BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=KBU+AAvw; 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 jg8-20020a170907970800b007ade22f401bsi2578599ejc.759.2022.11.11.08.43.42; Fri, 11 Nov 2022 08:44:05 -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=KBU+AAvw; 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 S233651AbiKKQRl (ORCPT + 91 others); Fri, 11 Nov 2022 11:17:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbiKKQRk (ORCPT ); Fri, 11 Nov 2022 11:17:40 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54341658C for ; Fri, 11 Nov 2022 08:17:38 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id i21so8243292edj.10 for ; Fri, 11 Nov 2022 08:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PPFK299nWfDr/V9J7p74DjQEhALYVf51OEuCFpbYSbM=; b=KBU+AAvwge0Xr3lQE8QmWKlPSunFws73fRLUrfKBI3t0C7DwjZNxz9x1Rs/CD8AOg7 aACR3Djshp/4SGNH1bl3rM8whcVgrQwz8IpxNGkznbL+XM9X+u05meAx3yOmRGlMyEoe bXMuNxJrrrdXPC6j9kBN7+DChSccZwvS1fHmE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PPFK299nWfDr/V9J7p74DjQEhALYVf51OEuCFpbYSbM=; b=sJtv8NM4auKGtdB03/9UPjN62Lmf77oR7d1bPs0nIQW0lKYMB+rkpLwg4ZYqUkS2bb xsB9eQhiDFtpJcMsi6Jxz3GW/1N1CGpI+LPJqObm5AT6YI9d5eWUZPeXoS/Q4fxExZ/r 5ThgCUoesW6lJSd7BuCB5Tt3MChGO4QDiRy1s8gI5+kt56XVNcADr0EasgEkWywyaHDl dMgJJAf6uAzlMNo2ob/UnurS1VgYxDeO/uGO9bPSAyiM4XEtNarRjJWNgba52daQan2P qpiOKBX9By7leni/ZQEaKesyAoR9sOIqSdJsvUqJgXtcqa0WVyaOPaCxOSqtFkIDQs/d 3jRQ== X-Gm-Message-State: ANoB5pnFPzKz75pGHjnpA1ThYjUd3TB3lQqAwPtDKGafyZC327LAkzW1 bNvAoX8/qn77HH9yBIDrRte2pA== X-Received: by 2002:aa7:d4d3:0:b0:45f:b80f:1fe8 with SMTP id t19-20020aa7d4d3000000b0045fb80f1fe8mr2064057edr.118.1668183456903; Fri, 11 Nov 2022 08:17:36 -0800 (PST) Received: from prevas-ravi.tritech.se ([80.208.71.65]) by smtp.gmail.com with ESMTPSA id v2-20020a170906292200b007aacfce2a91sm1038990ejd.27.2022.11.11.08.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:17:35 -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] net: dsa: use NET_NAME_PREDICTABLE for user ports with name given in DT Date: Fri, 11 Nov 2022 17:17:28 +0100 Message-Id: <20221111161729.915233-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 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=ham 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. Signed-off-by: Rasmus Villemoes --- 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..dfefcc4a9ccf 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_UNKNOWN; + } + 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