Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp451337rwb; Wed, 16 Nov 2022 03:09:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7aEfbUKNlAO+u4q7DpALCICiJRcAY4b5hCyLa9uK7N/cMvSNLIlzpMgQdmBXcy7rIh8kxF X-Received: by 2002:a17:907:cca7:b0:7ae:3b9e:1d8a with SMTP id up39-20020a170907cca700b007ae3b9e1d8amr16468230ejc.581.1668596973983; Wed, 16 Nov 2022 03:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668596973; cv=none; d=google.com; s=arc-20160816; b=UH+OE/bNA9Q6CCAy4jujAcHlAYB0+S9j2glpRJ61nKP+x4nhgSfY9TNNehxKqKBIYl iouc/TzJJki05ycLc8wjmosqql7Sbid1QMUSWUECa1f357Z15QZRU52RX7AgRymN07Tg xf/2A+RIqLOhVZ3fgUG0eSVJQeGNzNApjn5DdPX9y8jeVVi0M6/55tqUUD6id/agyTC2 E82PmPvkFWbn5HOsI6mWzjPVZRLh5vjjaU4i1S6+wWhWIKzQzzxC9tmAji8baJJWO6fk lT2jCUj2ML0hSqHwNwhudPJkzEEgK51s8upC3kfC1GxTnoIO1MXXfFTIJaqm5ttMHCW1 41bw== 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=v2xrQk2QoCyteNifyf752ChzTmEoJc0akwXN/7mZghA=; b=LSV3a9ZwKOT4vCMmbD/NH7EccPW6kp2K9cqPSjoR2Q8puUut5FKqzYOKCJ3zRPBtpz uMuRTI0WuvqXfxISXD6kPU6PnHFoBF2SeXy0kHrJvTQxZW4LbLx5/wMucf8ESfxglvbP ZhciDFBTxP04A3FMk+e4WP07nsuNo8/CHXETNr4Sz+KHo/X0SR2dRkXA/BueJ1sdTI5T x2chzKMPOyM0gKyzV583P5oOmmZXkSReWkkF4ZEAITRHQayU9+8pD187miLnEnbDHPiO E6JtB6Y5rqFKsCDydvEfDlTGc6b/lNSSNpgf7/cwdYa7y3SMI1uki1simvyDN2cE5sZE goLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=YfHd5X8F; 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 ho40-20020a1709070ea800b007836227b96fsi14188571ejc.888.2022.11.16.03.09.09; Wed, 16 Nov 2022 03:09:33 -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=YfHd5X8F; 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 S239021AbiKPLGW (ORCPT + 92 others); 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-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: 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 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 --- 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..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 = 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_UNKNOWN; + } 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