From nobody Mon Apr 13 20:06:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C4A8C433FE for ; Wed, 16 Nov 2022 11:06:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238613AbiKPLGW (ORCPT ); Wed, 16 Nov 2022 06:06:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238495AbiKPLFm (ORCPT ); Wed, 16 Nov 2022 06:05:42 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 790A026578 for ; Wed, 16 Nov 2022 02:52:11 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id b9so21327235ljr.5 for ; Wed, 16 Nov 2022 02:52:11 -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=v2xrQk2QoCyteNifyf752ChzTmEoJc0akwXN/7mZghA=; b=YfHd5X8Fm9dFTkqIZ5zqj5PM0vD9bQ8Yq2Mx8q76pWZYve8hTYVa2e9rHhRlXd/Kps yFrjC30R+XS6HIRd6w/l3CWK/zTudgPrGT9wX0HOz8+sQlPSSy66T4UNKZqpLq1pzITC iQDFkQDAT5keVT9YQOIZMsOReK9dc1UfVS7FY= 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=v2xrQk2QoCyteNifyf752ChzTmEoJc0akwXN/7mZghA=; b=KMi+AhRUDO/xycf4WpZdNywMLzNxH3AAsAeYk3kIkHHgIq4nYirueRcAF9E53x/DjL Jyurl6Q8EwZIKqOs2rYO6AkPnupt0hCSrSqmNqiMDXs6fs5C1q2ELEKIkQLC7rdCov2y yP+070YyCGM25kBHA5w1UsqZbJHRFiAK3cYXrPFdqsVIDhdCzbKka+Jbh/54Ue41dW8E UzxZxBZVxx+AIOvD/l8MMkTbm9auQivlciD3g0IiryKY9S6iNWXaVBpPEYl+D3JfpEZT HB4IT8nLkv5DzTaYXPDflSATTtPvIHrPNPgOAUHTud75hPko8jVhsPtk03As/Hdeuk6R 1agg== X-Gm-Message-State: ANoB5plDUJv1D5W+NQqkYlX4Ngum4yFlhgsbd71AYKMtMcKWvwEM9NV+ WN7Eb1z+sIHuW+6pQacu8lE67w== X-Google-Smtp-Source: AA0mqf4UqMmKuAqhLDlKz1ZS51zEl8c7CRymYZthgAknebgfsxHP6+A/Ts1VpueTwhK9ox6z9gdGww== X-Received: by 2002:a05:651c:905:b0:277:71e4:20a3 with SMTP id e5-20020a05651c090500b0027771e420a3mr7303564ljq.332.1668595929858; Wed, 16 Nov 2022 02:52:09 -0800 (PST) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id g42-20020a0565123baa00b004b094730074sm2547119lfv.267.2022.11.16.02.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:52:09 -0800 (PST) From: Rasmus Villemoes To: Andrew Lunn , 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 v3 1/3] net: dsa: refactor name assignment for user ports Date: Wed, 16 Nov 2022 11:52:02 +0100 Message-Id: <20221116105205.1127843-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221116105205.1127843-1-linux@rasmusvillemoes.dk> References: <20221115074356.998747-1-linux@rasmusvillemoes.dk> <20221116105205.1127843-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The following two patches each have a (small) chance of causing regressions for userspace and will in that case of course need to be reverted. In order to prepare for that and make those two patches independent and individually revertable, refactor the code which sets the names for user ports by moving the "fall back to eth%d if no label is given in device tree" to dsa_slave_create(). No functional change (at least none intended). Signed-off-by: Rasmus Villemoes Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- 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_swi= tch *ds, int index) =20 static int dsa_port_parse_user(struct dsa_port *dp, const char *name) { - if (!name) - name =3D "eth%d"; - dp->type =3D DSA_PORT_TYPE_USER; dp->name =3D name; =20 diff --git a/net/dsa/slave.c b/net/dsa/slave.c index a9fde48cffd4..d19e9a536b8f 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 =3D dsa_port_to_master(port); struct dsa_switch *ds =3D port->ds; - const char *name =3D port->name; struct net_device *slave_dev; struct dsa_slave_priv *p; + const char *name; + int assign_type; int ret; =20 if (!ds->num_tx_queues) ds->num_tx_queues =3D 1; =20 + if (port->name) { + name =3D port->name; + assign_type =3D NET_NAME_UNKNOWN; + } else { + name =3D "eth%d"; + assign_type =3D NET_NAME_UNKNOWN; + } + slave_dev =3D 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 =3D=3D NULL) return -ENOMEM; --=20 2.37.2 From nobody Mon Apr 13 20:06:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C11EFC4332F for ; Wed, 16 Nov 2022 11:06:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239027AbiKPLG1 (ORCPT ); Wed, 16 Nov 2022 06:06:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238608AbiKPLFm (ORCPT ); Wed, 16 Nov 2022 06:05:42 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B660F30541 for ; Wed, 16 Nov 2022 02:52:12 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id x21so21297756ljg.10 for ; Wed, 16 Nov 2022 02:52:12 -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=Plqwnup+7oIelGEONlO5qvIt8Tuu+/wT1TXFJs1u9Nk=; b=edTfsxl8lhPrR/gzCTwcVjVGe7HY9DcTsgM5PzvXupDXWAahISUX/t7qj7j6wsvZAB xJOrpZ0YJ3ZWOTnpV8q6t+UhgJeXGOdxhB/O69iyc8wumAieFnlZDVEk/SYXg//QMYZ8 Gc7lUQPoSqfuhGarWKYaGCE2rnkKC6QraGVDE= 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=Plqwnup+7oIelGEONlO5qvIt8Tuu+/wT1TXFJs1u9Nk=; b=V81lHzpJ+IUgKdgViiJikDVFFX96qOF3umG8nUmZ9/8e1UkKnltGQdWB1SU/RH6enI 7UiN07iMLBK+xTF2yQXZ1mMpR6J46X57fJpf+/H5FgNm6bt+B32mjt3HUNwVUrkbfxWQ LRUj2SD3/2R9KNgRiECdCH6uakgvV99vglVy52hzRm1yhW/Bf5oc/lRIoUhE8e46yXaJ /j8ZagtufAJr7Qvx9m0WURXaYUGA3w1uyKEn+0+bPaRqJY6E4jlWBVASBTaDYoKVVv1d KYXyX1nBJcMgNk81nRSvxXHgUnKz9XOqgkJbkSDUJfo5GzK1a3Jr+azi4h1uKMUGs2/X FodA== X-Gm-Message-State: ANoB5pmcYfULgc9MgBzikiT5h7+KL6iX2slKiCPsPFWUFKkFvj4hY92q 6mxRtMS91qmBKssxYvfnddgb6w== X-Google-Smtp-Source: AA0mqf7GqVixPSe1GHZcTqsttGWICrc1cPxMuhkyl4Mayvpq40evHv7BpGQP/tB/yoCrI99+z+LFhQ== X-Received: by 2002:a2e:b007:0:b0:276:ff14:7a4d with SMTP id y7-20020a2eb007000000b00276ff147a4dmr7197293ljk.490.1668595931072; Wed, 16 Nov 2022 02:52:11 -0800 (PST) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id g42-20020a0565123baa00b004b094730074sm2547119lfv.267.2022.11.16.02.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:52:10 -0800 (PST) From: Rasmus Villemoes To: Andrew Lunn , 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 v3 2/3] net: dsa: use NET_NAME_PREDICTABLE for user ports with name given in DT Date: Wed, 16 Nov 2022 11:52:03 +0100 Message-Id: <20221116105205.1127843-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221116105205.1127843-1-linux@rasmusvillemoes.dk> References: <20221115074356.998747-1-linux@rasmusvillemoes.dk> <20221116105205.1127843-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a user port has a label in device tree, the corresponding netdevice is, to quote include/uapi/linux/netdevice.h, "predictably named by the kernel". This is also explicitly one of the intended use cases for NET_NAME_PREDICTABLE, quoting 685343fc3ba6 ("net: add name_assign_type netdev attribute"): NET_NAME_PREDICTABLE: The ifname has been assigned by the kernel in a predictable way [...] Examples include [...] and names deduced from hardware properties (including being given explicitly by the firmware). 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 Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- net/dsa/slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index d19e9a536b8f..dfefcc4a9ccf 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2385,7 +2385,7 @@ int dsa_slave_create(struct dsa_port *port) =20 if (port->name) { name =3D port->name; - assign_type =3D NET_NAME_UNKNOWN; + assign_type =3D NET_NAME_PREDICTABLE; } else { name =3D "eth%d"; assign_type =3D NET_NAME_UNKNOWN; --=20 2.37.2 From nobody Mon Apr 13 20:06:17 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9202C433FE for ; Wed, 16 Nov 2022 11:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231974AbiKPLGb (ORCPT ); Wed, 16 Nov 2022 06:06:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238574AbiKPLFm (ORCPT ); Wed, 16 Nov 2022 06:05:42 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0DDC4C242 for ; Wed, 16 Nov 2022 02:52:13 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id x21so21297818ljg.10 for ; Wed, 16 Nov 2022 02:52:13 -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=boYFusMhw3G11i9yi3Rn2Pq4n201pIIehUv93eqtXLI=; b=b6CMlIjkEubLoLcx9mJZnlNO6idRQolGiSGIvdTA9Flqr4dN9fekRlUxaAN3w92fVL 5A65vna+64WnhQnZ3OJqTkWNW41pCRpAvaiaTRLaCvVe7T1tILdkNsZYfe3bReU6qrls rr6TjkCKGgTAP/gUpvVakr9JooYOULf3uN1rk= 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=boYFusMhw3G11i9yi3Rn2Pq4n201pIIehUv93eqtXLI=; b=7Ouwihm/C8XFe1EzpWrv1P1iGWCFL53CTgLGhdUpPr58znyF5tjAbsdYpfa2PSskH5 95J0pJ7qf8YJHaIXmMbKeptk4fq3F/Lgy31ex7gTxjACSUvyIx7gm/63bs0e16qWaaMb OjaSP/2egpywY87I/PttOUw2WccGFf4mESobcWzvMKQpJAWXgoPS1dOo6zd4L6UYF1uv Tzg9CiALTH9VIvt+xKmyYow6qUrjPixVuAkZnDF93FXeZ7KQ9PuqdyG2MEvo00/aowOC DfcV3N29WUGMsGLFNR0PMOVkwVcgY5MEa2agj0C8CsPCeAPHad45YDICSVWm6LBxt0iR g1dg== X-Gm-Message-State: ANoB5pkluF4r9sfMh6zT3ZDiGPQ+u2Jni/lO80TEv9JWGM+L5QwwmK/N jIzF3AE7pvjlSa1OqFHzbthRQw== X-Google-Smtp-Source: AA0mqf7yX6uhPbO4HWQ1vf40mIJbfBYIMAKSkfI3irFiFqkYer+kY5sE8ODw1zVz4ucTymYNsHywaw== X-Received: by 2002:a2e:871a:0:b0:277:766:b715 with SMTP id m26-20020a2e871a000000b002770766b715mr7096225lji.416.1668595932308; Wed, 16 Nov 2022 02:52:12 -0800 (PST) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id g42-20020a0565123baa00b004b094730074sm2547119lfv.267.2022.11.16.02.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:52:11 -0800 (PST) From: Rasmus Villemoes To: Andrew Lunn , 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 v3 3/3] net: dsa: set name_assign_type to NET_NAME_ENUM for enumerated user ports Date: Wed, 16 Nov 2022 11:52:04 +0100 Message-Id: <20221116105205.1127843-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221116105205.1127843-1-linux@rasmusvillemoes.dk> References: <20221115074356.998747-1-linux@rasmusvillemoes.dk> <20221116105205.1127843-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When a user port does not have a label in device tree, and we thus 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 Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli --- net/dsa/slave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index dfefcc4a9ccf..821ab79bb60a 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -2388,7 +2388,7 @@ int dsa_slave_create(struct dsa_port *port) assign_type =3D NET_NAME_PREDICTABLE; } else { name =3D "eth%d"; - assign_type =3D NET_NAME_UNKNOWN; + assign_type =3D NET_NAME_ENUM; } =20 slave_dev =3D alloc_netdev_mqs(sizeof(struct dsa_slave_priv), name, --=20 2.37.2