From patchwork Thu Feb 3 00:44:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1587835 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qaLN4ek1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=HIGToWWs; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jq0RL6PQkz9sCD for ; Thu, 3 Feb 2022 11:49:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=znXgXDiIh1cn4gM/V4i6EiBd+skXO+TeMQYMYlsW95Q=; b=qaLN4ek1E6Gfpi q/MBQy9lzIRcDdfMoCbVoMNXzAGf2IUJvVI+2lLEq+blJW/KAx/QldgQC7DD3JvdKVWwDGYBEgft9 NH0k/4nA0iJio++rzXxohKU+3IB4uuqglsGhwn3XgnGbpC0Z54sV2zXW9FRXRPvrMDw9m61dLq6Io 2y4wWem1TkahICAr1ui1zlFV2svk8vNgZAXJwOAYsxUJZjxXYebZiCx2CQuYt5gIK8uIVcnfuH0T6 fVLB0vYSEst8vmqTA/3QtOsdz3C0Z8rJz4OwT9PwjMYgBMJDYufyYZI9IOvjIA+7oo5iIl0YUkhRV cwnI920jtadqPpwsahBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFQEk-00HEbF-VJ; Thu, 03 Feb 2022 00:44:35 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFQEW-00HEZ4-8p for openwrt-devel@lists.openwrt.org; Thu, 03 Feb 2022 00:44:22 +0000 Received: by mail-wm1-x332.google.com with SMTP id v123so656979wme.2 for ; Wed, 02 Feb 2022 16:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ycbPYBJ4a2wbG5Q3x1idCWUxi3jay7blFSkSjjg8srw=; b=HIGToWWsE0TsnkIklvzzi7oxVV/+B1q9vRdtvlDJqzNPr0mI92/SslDEroH24t2CS5 WKX7Fhhd4TEj8neU/nw32yLIw0TdV4X3CNKALRo6xKpe7EDdE92FeNZb7QNO7wnjd8iY 9+66j+RSkRODpcOeYl1A6jY/M4NDxksjhnqBPdoHHyCgxCm4JrJERpfWRaCEHo9hw/+z FhxMPo5d6qTrHEZlUnBeVQJbJxoJP8aeA3KsXPtvU5Vgp3+h/s/FOmx7bo9HrmoVHsFD 3Ukpfs6B5V/F3BTjKw9Wo0alp+4Hd8o0gw8vBieTL5UscohvaWS32/gdFlcV+3/DA231 /gyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ycbPYBJ4a2wbG5Q3x1idCWUxi3jay7blFSkSjjg8srw=; b=vNHCpsVSZSmomt+8WLtMl3/71HaRrP/hUQ7z/mB9RS9fcU1p7UnVMlEOrfBFnDz88b loLxWzJDHTh8KeuLhFJE7OVZhvx7+w7+yxPSD2u6JrvvkHSjRqWtZxc3vLb+n+Ag7MIO O2+GIL9ZAUve4Essn1lP+RpRbm4BPpBgIKuo4Kh93o0QcvGeMV9BuCzeBm5dGqU4hMOl ocdSGFJ6TwQwchcXDbEdrPHa17kE2QYSj9K9eAUSjws4gNrfB0zLf47ZBaLjHU0XSjiP J0D+b5jGbHtpTsvlHyNHWS40oylF5u0MJnLPExR/eFKwWLBzLFf0U4O8dGVOzOXnzaDY aw0g== X-Gm-Message-State: AOAM531T9Yuk/qpRA+215xPkxrGdrm1xtJSmtm5P/6NXVUPk+K8zEwF6 aFzge2qPxg1ov2gdqM/CXcc4hl/oEag= X-Google-Smtp-Source: ABdhPJzCyEPirmOCGVLa+RCgdgyXZdqHFxxrRYkKZEgfd7Y0Ckg7itLQ6gtWWZEtWAtZEZvvun/Gng== X-Received: by 2002:a05:600c:1c18:: with SMTP id j24mr8240464wms.106.1643849057942; Wed, 02 Feb 2022 16:44:17 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id e10sm21981592wrq.53.2022.02.02.16.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 16:44:17 -0800 (PST) From: Ansuel Smith To: OpenWrt Development List Cc: Ansuel Smith Subject: [PATCH v3 1/2] linux: introduce multi-cpu dsa patch Date: Thu, 3 Feb 2022 01:44:11 +0100 Message-Id: <20220203004412.19866-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203004412.19866-1-ansuelsmth@gmail.com> References: <20220203004412.19866-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220202_164420_349358_A25B7046 X-CRM114-Status: GOOD ( 31.94 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add support for multi-cpu dsa. This is a reworked version of the RFC patch proposed some time ago. By default every dsa port is connected to the first cpu port and the command 'ip link set PORT cpu CP [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:332 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add support for multi-cpu dsa. This is a reworked version of the RFC patch proposed some time ago. By default every dsa port is connected to the first cpu port and the command 'ip link set PORT cpu CPU_PORT' can be used to change the used cpu port at runtime. A specific function port_change_cpu_port is required to correctly setup the port on cpu change request. Signed-off-by: Ansuel Smith --- ...net-dsa-allow-for-multiple-CPU-ports.patch | 97 +++++++++++++++ ...add-ndo-for-setting-the-cpu-proprety.patch | 113 ++++++++++++++++++ ...t-ndo_set_cpu-for-changing-DSA-port-.patch | 100 ++++++++++++++++ ...clude-net-add-dsa_cpu_ports-function.patch | 39 ++++++ 4 files changed, 349 insertions(+) create mode 100644 target/linux/generic/hack-5.10/780-1-net-dsa-allow-for-multiple-CPU-ports.patch create mode 100644 target/linux/generic/hack-5.10/780-2-net-add-ndo-for-setting-the-cpu-proprety.patch create mode 100644 target/linux/generic/hack-5.10/780-3-net-dsa-implement-ndo_set_cpu-for-changing-DSA-port-.patch create mode 100644 target/linux/generic/hack-5.10/780-4-include-net-add-dsa_cpu_ports-function.patch diff --git a/target/linux/generic/hack-5.10/780-1-net-dsa-allow-for-multiple-CPU-ports.patch b/target/linux/generic/hack-5.10/780-1-net-dsa-allow-for-multiple-CPU-ports.patch new file mode 100644 index 00000000..9b4a57c6 --- /dev/null +++ b/target/linux/generic/hack-5.10/780-1-net-dsa-allow-for-multiple-CPU-ports.patch @@ -0,0 +1,97 @@ +From 48d1e9543273c7670ebef15a4d27b13023895a28 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= +Date: Sat, 24 Aug 2019 04:42:48 +0200 +Subject: [PATCH 1/4] net: dsa: allow for multiple CPU ports +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Allow for multiple CPU ports in a DSA switch tree. The default assing +logic is still used where the first defined CPU port is selected for all +the user ports. The CPU port has to be changed at runtime. + +Signed-off-by: Marek BehĂșn +--- + net/dsa/dsa2.c | 22 ++++++++++++++-------- + 1 file changed, 14 insertions(+), 8 deletions(-) + +diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c +index 183003e45762..4a8de5e2f0f5 100644 +--- a/net/dsa/dsa2.c ++++ b/net/dsa/dsa2.c +@@ -240,7 +240,7 @@ static int dsa_tree_setup_default_cpu(struct dsa_switch_tree *dst) + return 0; + } + +-static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) ++static void dsa_tree_teardown_default_cpus(struct dsa_switch_tree *dst) + { + struct dsa_port *dp; + +@@ -553,7 +553,7 @@ static void dsa_tree_teardown_switches(struct dsa_switch_tree *dst) + dsa_switch_teardown(dp->ds); + } + +-static int dsa_tree_setup_master(struct dsa_switch_tree *dst) ++static int dsa_tree_setup_masters(struct dsa_switch_tree *dst) + { + struct dsa_port *dp; + int err; +@@ -562,14 +562,20 @@ static int dsa_tree_setup_master(struct dsa_switch_tree *dst) + if (dsa_port_is_cpu(dp)) { + err = dsa_master_setup(dp->master, dp); + if (err) +- return err; ++ goto teardown; + } + } + + return 0; ++teardown: ++ list_for_each_entry(dp, &dst->ports, list) ++ if (dsa_port_is_cpu(dp)) ++ dsa_master_teardown(dp->master); ++ ++ return err; + } + +-static void dsa_tree_teardown_master(struct dsa_switch_tree *dst) ++static void dsa_tree_teardown_masters(struct dsa_switch_tree *dst) + { + struct dsa_port *dp; + +@@ -601,7 +607,7 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) + if (err) + goto teardown_default_cpu; + +- err = dsa_tree_setup_master(dst); ++ err = dsa_tree_setup_masters(dst); + if (err) + goto teardown_switches; + +@@ -614,7 +620,7 @@ static int dsa_tree_setup(struct dsa_switch_tree *dst) + teardown_switches: + dsa_tree_teardown_switches(dst); + teardown_default_cpu: +- dsa_tree_teardown_default_cpu(dst); ++ dsa_tree_teardown_default_cpus(dst); + + return err; + } +@@ -626,11 +632,11 @@ static void dsa_tree_teardown(struct dsa_switch_tree *dst) + if (!dst->setup) + return; + +- dsa_tree_teardown_master(dst); ++ dsa_tree_teardown_masters(dst); + + dsa_tree_teardown_switches(dst); + +- dsa_tree_teardown_default_cpu(dst); ++ dsa_tree_teardown_default_cpus(dst); + + list_for_each_entry_safe(dl, next, &dst->rtable, list) { + list_del(&dl->list); +-- +2.34.1 + diff --git a/target/linux/generic/hack-5.10/780-2-net-add-ndo-for-setting-the-cpu-proprety.patch b/target/linux/generic/hack-5.10/780-2-net-add-ndo-for-setting-the-cpu-proprety.patch new file mode 100644 index 00000000..d9441feb --- /dev/null +++ b/target/linux/generic/hack-5.10/780-2-net-add-ndo-for-setting-the-cpu-proprety.patch @@ -0,0 +1,113 @@ +From 07ad275393f991d29aff1e9951e01e0a1f1582b4 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Sun, 23 Jan 2022 00:49:10 +0100 +Subject: [PATCH 2/4] net: add ndo for setting the cpu proprety + +In DSA the cpu value is used to report to which CPU port a given switch +port is connected to. Since we want to support multi-CPU DSA, we want +the user to be able to change this value. + +Add ndo_set_cpu method into the ndo structure and also create +dev_set_cpu and call this from the netlink code, so that userspace can +change the cpu value. + +Signed-off-by: Ansuel Smith +--- + include/linux/netdevice.h | 5 +++++ + include/uapi/linux/if_link.h | 1 + + net/core/dev.c | 18 ++++++++++++++++++ + net/core/rtnetlink.c | 7 +++++++ + 4 files changed, 31 insertions(+) + +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index 7c3da0e1ea9d..c59181a116fd 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1237,6 +1237,8 @@ struct netdev_net_notifier { + * TX queue. + * int (*ndo_get_iflink)(const struct net_device *dev); + * Called to get the iflink value of this device. ++ * int (*ndo_set_cpu)(struct net_device *dev, int cpu); ++ * Called to set the cpu value of this device. + * void (*ndo_change_proto_down)(struct net_device *dev, + * bool proto_down); + * This function is used to pass protocol port error state information +@@ -1470,6 +1472,8 @@ struct net_device_ops { + int queue_index, + u32 maxrate); + int (*ndo_get_iflink)(const struct net_device *dev); ++ int (*ndo_set_cpu)(struct net_device *dev, ++ int cpu); + int (*ndo_change_proto_down)(struct net_device *dev, + bool proto_down); + int (*ndo_fill_metadata_dst)(struct net_device *dev, +@@ -2797,6 +2801,7 @@ void dev_add_offload(struct packet_offload *po); + void dev_remove_offload(struct packet_offload *po); + + int dev_get_iflink(const struct net_device *dev); ++int dev_set_cpu(struct net_device *dev, int cpu); + int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb); + struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags, + unsigned short mask); +diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h +index c4b23f06f69e..b035c911eadc 100644 +--- a/include/uapi/linux/if_link.h ++++ b/include/uapi/linux/if_link.h +@@ -340,6 +340,7 @@ enum { + IFLA_ALT_IFNAME, /* Alternative ifname */ + IFLA_PERM_ADDRESS, + IFLA_PROTO_DOWN_REASON, ++ IFLA_CPU, + __IFLA_MAX + }; + +diff --git a/net/core/dev.c b/net/core/dev.c +index 38412e70f761..a213719a11ed 100644 +--- a/net/core/dev.c ++++ b/net/core/dev.c +@@ -820,6 +820,24 @@ int dev_get_iflink(const struct net_device *dev) + } + EXPORT_SYMBOL(dev_get_iflink); + ++/** ++ * dev_set_cpu - set 'cpu' value of a dsa interface ++ * @dev: target interface ++ * @cpu: new value ++ * ++ * Change the cpu port to which this dsa interface is linked to. ++ */ ++int dev_set_cpu(struct net_device *dev, int cpu) ++{ ++ if (!dev->dsa_ptr) ++ return -EOPNOTSUPP; ++ ++ if (dev->netdev_ops && dev->netdev_ops->ndo_set_cpu) ++ return dev->netdev_ops->ndo_set_cpu(dev, cpu); ++ ++ return -EOPNOTSUPP; ++} ++ + /** + * dev_fill_metadata_dst - Retrieve tunnel egress information. + * @dev: targeted interface +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index 7d7223691783..767ac3bf6358 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -2716,6 +2716,13 @@ static int do_setlink(const struct sk_buff *skb, + status |= DO_SETLINK_MODIFIED; + } + ++ if (tb[IFLA_CPU]) { ++ err = dev_set_cpu(dev, nla_get_u32(tb[IFLA_CPU])); ++ if (err) ++ goto errout; ++ status |= DO_SETLINK_MODIFIED; ++ } ++ + if (tb[IFLA_CARRIER]) { + err = dev_change_carrier(dev, nla_get_u8(tb[IFLA_CARRIER])); + if (err) +-- +2.34.1 + diff --git a/target/linux/generic/hack-5.10/780-3-net-dsa-implement-ndo_set_cpu-for-changing-DSA-port-.patch b/target/linux/generic/hack-5.10/780-3-net-dsa-implement-ndo_set_cpu-for-changing-DSA-port-.patch new file mode 100644 index 00000000..b6f454bf --- /dev/null +++ b/target/linux/generic/hack-5.10/780-3-net-dsa-implement-ndo_set_cpu-for-changing-DSA-port-.patch @@ -0,0 +1,100 @@ +From 96d426097d16234a5c0f7bf30a87a381fb7821e8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marek=20Beh=C3=BAn?= +Date: Sat, 24 Aug 2019 04:42:50 +0200 +Subject: [PATCH 3/4] net: dsa: implement ndo_set_cpu for changing DSA port's + CPU port +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Implement ndo_set_cpu for DSA slave device. In multi-CPU port setup +this should be used to change to which CPU destination port a given port +should be connected. + +This adds a new operation into the DSA switch operations structure, +port_change_cpu_port. A driver implementing this function has the +ability to change CPU destination port of a given port. + +Signed-off-by: Marek BehĂșn +--- + include/net/dsa.h | 6 ++++++ + net/dsa/slave.c | 39 +++++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+) + +diff --git a/include/net/dsa.h b/include/net/dsa.h +index 35429a140dfa..70bd07c4ea15 100644 +--- a/include/net/dsa.h ++++ b/include/net/dsa.h +@@ -647,6 +647,12 @@ struct dsa_switch_ops { + int (*port_change_mtu)(struct dsa_switch *ds, int port, + int new_mtu); + int (*port_max_mtu)(struct dsa_switch *ds, int port); ++ ++ /* ++ * Multi-CPU port support ++ */ ++ int (*port_change_cpu_port)(struct dsa_switch *ds, int port, ++ struct dsa_port *new_cpu_dp); + }; + + #define DSA_DEVLINK_PARAM_DRIVER(_id, _name, _type, _cmodes) \ +diff --git a/net/dsa/slave.c b/net/dsa/slave.c +index 3bc5ca40c9fb..8f871d2699c2 100644 +--- a/net/dsa/slave.c ++++ b/net/dsa/slave.c +@@ -62,6 +62,44 @@ static int dsa_slave_get_iflink(const struct net_device *dev) + return dsa_slave_to_master(dev)->ifindex; + } + ++static int dsa_slave_set_cpu(struct net_device *dev, int cpu) ++{ ++ struct net_device *master = dsa_slave_to_master(dev); ++ struct dsa_port *dp = dsa_slave_to_port(dev); ++ struct dsa_slave_priv *p = netdev_priv(dev); ++ struct net_device *new_cpu_dev; ++ struct dsa_port *new_cpu_dp; ++ int err; ++ ++ if (!dp->ds->ops->port_change_cpu_port) ++ return -EOPNOTSUPP; ++ ++ new_cpu_dev = dev_get_by_index(dev_net(dev), cpu); ++ if (!new_cpu_dev) ++ return -ENODEV; ++ ++ new_cpu_dp = new_cpu_dev->dsa_ptr; ++ if (!new_cpu_dp) ++ return -EINVAL; ++ ++ /* new CPU port has to be on the same switch tree */ ++ if (new_cpu_dp->dst != dp->cpu_dp->dst) ++ return -EINVAL; ++ ++ err = dp->ds->ops->port_change_cpu_port(dp->ds, dp->index, new_cpu_dp); ++ if (err) ++ return err; ++ ++ if (ether_addr_equal(dev->dev_addr, master->dev_addr)) ++ eth_hw_addr_inherit(dev, new_cpu_dev); ++ ++ /* should this be done atomically? */ ++ dp->cpu_dp = new_cpu_dp; ++ p->xmit = new_cpu_dp->tag_ops->xmit; ++ ++ return 0; ++} ++ + static int dsa_slave_open(struct net_device *dev) + { + struct net_device *master = dsa_slave_to_master(dev); +@@ -1594,6 +1632,7 @@ static const struct net_device_ops dsa_slave_netdev_ops = { + .ndo_fdb_dump = dsa_slave_fdb_dump, + .ndo_do_ioctl = dsa_slave_ioctl, + .ndo_get_iflink = dsa_slave_get_iflink, ++ .ndo_set_cpu = dsa_slave_set_cpu, + #ifdef CONFIG_NET_POLL_CONTROLLER + .ndo_netpoll_setup = dsa_slave_netpoll_setup, + .ndo_netpoll_cleanup = dsa_slave_netpoll_cleanup, +-- +2.34.1 + diff --git a/target/linux/generic/hack-5.10/780-4-include-net-add-dsa_cpu_ports-function.patch b/target/linux/generic/hack-5.10/780-4-include-net-add-dsa_cpu_ports-function.patch new file mode 100644 index 00000000..22f85bca --- /dev/null +++ b/target/linux/generic/hack-5.10/780-4-include-net-add-dsa_cpu_ports-function.patch @@ -0,0 +1,39 @@ +From 7085cfadfc26f4483c544790c80b3fc6acf1bdb3 Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Sun, 4 Apr 2021 12:58:50 +0200 +Subject: [PATCH 4/4] include: net: add dsa_cpu_ports function + +dsa_cpu_ports can be useful for switch that has multiple cpu port to +retrieve the cpu mask for ACL and bridge table. + +Signed-off-by: Ansuel Smith +--- + include/net/dsa.h | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/include/net/dsa.h b/include/net/dsa.h +index 70bd07c4ea15..06aa0d9912ee 100644 +--- a/include/net/dsa.h ++++ b/include/net/dsa.h +@@ -380,6 +380,18 @@ static inline u32 dsa_user_ports(struct dsa_switch *ds) + return mask; + } + ++static inline u32 dsa_cpu_ports(struct dsa_switch *ds) ++{ ++ u32 mask = 0; ++ int p; ++ ++ for (p = 0; p < ds->num_ports; p++) ++ if (dsa_is_cpu_port(ds, p)) ++ mask |= BIT(p); ++ ++ return mask; ++} ++ + /* Return the local port used to reach an arbitrary switch device */ + static inline unsigned int dsa_routing_port(struct dsa_switch *ds, int device) + { +-- +2.34.1 + From patchwork Thu Feb 3 00:44:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1587833 X-Patchwork-Delegate: ansuelsmth@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qwFG/bIU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=jQXH7sw3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jq0QW6Srrz9sCD for ; Thu, 3 Feb 2022 11:48:19 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VhTvy7KAU5RMSjb1BBbrur7yssPc7mInhRJVpGko82E=; b=qwFG/bIUmWYEjV +C1gcTZTKV8dKm6HU9lzYbg/s8evdHmrQ4/D3vAzNlPEB/Y9tMiPAENMRqQbM1JjkeJD3Y4iy984O rQba5ce7dplUNGoxM9OZdfNi+B/G43GZD/2I+Y97s/QS1g0sCCH5yz4FwMbAoWgI1swI/w0junWCu MWmFP1PhGpZ5KmaHD06QSJzLuaIO0NU0V/kmCVa0j/0oPs2U0hllVWQ7EDdj69LhBP4qEFhRMPFg+ 40aCnDI4jyVGyTFrs60c4m/2yz9zSj3dm180/2u5iUVhSdO/gddgMW0RDyrJwmA6Rx54xYPRj3ZPr 07G9lNgbMcsBxjwo6dxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFQEx-00HEcc-Du; Thu, 03 Feb 2022 00:44:47 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFQEX-00HEZK-EL for openwrt-devel@lists.openwrt.org; Thu, 03 Feb 2022 00:44:22 +0000 Received: by mail-wr1-x432.google.com with SMTP id l25so1660051wrb.13 for ; Wed, 02 Feb 2022 16:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GVjJ/kcVzm/PtYmPe7f3gcYwSdZTAHeDVf1xeRQMFG4=; b=jQXH7sw3if1ygJqY/U42+QvREp4E9eR8pWgvEulls6QGr/eFluqrVuDUbzjtvqpqwy ZcsxZdoLAVGG3oe6JWUFsS5X/0LjJws9xy07DEE2P5a18QbJoZOhIJYh/mZ1eJR7aftS KIt9QytKXSSyg2xdUJam4H7WRVg378tEqZx/5pBGwU3orBaC8joGb0KG5JlmkJdlRgYk HtkLrxxA1sJGJeKWdQ16ZNqeRuhK93bDP0Ulu2HEbC8wz3Q4Bl/eyZQerdpELnxosD1g 0UHn9wGXl5xvwFd14Xx3RQISdJeFommyNz9MBjc4Sy8+2+Mk7qAM/iueDEbYBNt4wdgL TvBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GVjJ/kcVzm/PtYmPe7f3gcYwSdZTAHeDVf1xeRQMFG4=; b=oYzJHmvE0KUM19GM3A9Nki+tQ+ESyENIK7+I5Gh6RIyDOkVvnkTu4P/fCzgatWzH7r OO7t+oOqi8349ilEwYFWnWTp30zzrXullu8OblQrUgoe4+AYFr/dKK12ArZ74eAxM48l 8+XB0YT3eBLlFe9pprJQcRpOO1glR6atz9lnFFgxMBC2m8nC/zeMozMvVvWYklRQjpqy vVg8Ute3iVjdsi9HzXYV9I3ZPQPNVaNnOZ7z2wgb3QO8B2jYud71AVhd0ZSIMcNCrY2W IInfC2DsFNSF5T8mTYsC7oIvEkxsH9Jfdf8O+bWoPOu7J6jXmX8VUU+9TuiOnEuOxAC7 VvDA== X-Gm-Message-State: AOAM531rg1MAZcUyuiJEbT9T6s4rWI+lY7fpDyayYqKAUMnMhtS7/bVs gf/rKWk37Uv5m8acSxQUKX5aH25MKRY= X-Google-Smtp-Source: ABdhPJyZW5y8DS7IZBUOhp5iMJwk7YwNcg+pu6NVuRNKzLvqL/7jDjXafBZ3mCK7hmWD9EYkAUZ4Kw== X-Received: by 2002:adf:f984:: with SMTP id f4mr27670595wrr.510.1643849059295; Wed, 02 Feb 2022 16:44:19 -0800 (PST) Received: from Ansuel-xps.localdomain (93-42-71-246.ip85.fastwebnet.it. [93.42.71.246]) by smtp.googlemail.com with ESMTPSA id e10sm21981592wrq.53.2022.02.02.16.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Feb 2022 16:44:18 -0800 (PST) From: Ansuel Smith To: OpenWrt Development List Cc: Ansuel Smith Subject: [PATCH v3 2/2] iproute2: add support for cpu set Date: Thu, 3 Feb 2022 01:44:12 +0100 Message-Id: <20220203004412.19866-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203004412.19866-1-ansuelsmth@gmail.com> References: <20220203004412.19866-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220202_164421_504087_9A7F942A X-CRM114-Status: GOOD ( 19.30 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Add support for cpu set useful to set CPU port for dsa devices. Signed-off-by: Ansuel Smith --- ...101-iplink_allow_to_change_cpu_value.patch | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 package/network/utils/iproute2/patches/101- [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:432 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add support for cpu set useful to set CPU port for dsa devices. Signed-off-by: Ansuel Smith --- ...101-iplink_allow_to_change_cpu_value.patch | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 package/network/utils/iproute2/patches/101-iplink_allow_to_change_cpu_value.patch diff --git a/package/network/utils/iproute2/patches/101-iplink_allow_to_change_cpu_value.patch b/package/network/utils/iproute2/patches/101-iplink_allow_to_change_cpu_value.patch new file mode 100644 index 00000000..1bb2bb1f --- /dev/null +++ b/package/network/utils/iproute2/patches/101-iplink_allow_to_change_cpu_value.patch @@ -0,0 +1,81 @@ +From 8642516618b60a2827215f2bed54d4d0aa1da48a Mon Sep 17 00:00:00 2001 +From: Ansuel Smith +Date: Sun, 23 Jan 2022 00:31:49 +0100 +Subject: [PATCH] iplink: allow to change cpu of dsa device + +Allow to change the cpu port linked to a given dsa interface. +This is useful in the case of multi-CPU port DSA to assign the correct +port to the different user ports. + +Signed-off-by: Ansuel Smith +--- + include/uapi/linux/if_link.h | 1 + + ip/iplink.c | 7 +++++++ + man/man8/ip-link.8.in | 7 +++++++ + 3 files changed, 15 insertions(+) + +diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h +index 41708e26..901b5544 100644 +--- a/include/uapi/linux/if_link.h ++++ b/include/uapi/linux/if_link.h +@@ -341,6 +341,7 @@ enum { + IFLA_ALT_IFNAME, /* Alternative ifname */ + IFLA_PERM_ADDRESS, + IFLA_PROTO_DOWN_REASON, ++ IFLA_CPU, + + /* device (sysfs) name as parent, used instead + * of IFLA_LINK where there's no parent netdev +diff --git a/ip/iplink.c b/ip/iplink.c +index a3ea775d..254c35c5 100644 +--- a/ip/iplink.c ++++ b/ip/iplink.c +@@ -595,6 +595,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) + int index = 0; + int group = -1; + int addr_len = 0; ++ int cpu = -1; + int err; + + ret = argc; +@@ -625,6 +626,12 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) + } else if (matches(*argv, "link") == 0) { + NEXT_ARG(); + link = *argv; ++ } else if (matches(*argv, "cpu") == 0) { ++ NEXT_ARG(); ++ cpu = ll_name_to_index(*argv); ++ if (!cpu) ++ return nodev(*argv); ++ addattr32(&req->n, sizeof(*req), IFLA_CPU, cpu); + } else if (matches(*argv, "address") == 0) { + NEXT_ARG(); + addr_len = ll_addr_a2n(abuf, sizeof(abuf), *argv); +diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in +index 19a0c9ca..406db8ad 100644 +--- a/man/man8/ip-link.8.in ++++ b/man/man8/ip-link.8.in +@@ -152,6 +152,9 @@ ip-link \- network device configuration + .br + .RB "[ " nomaster " ]" + .br ++.RB "[ " cpu ++.IR DEVICE " ]" ++.br + .RB "[ " vrf + .IR NAME " ]" + .br +@@ -2299,6 +2302,10 @@ set master device of the device (enslave device). + .BI nomaster + unset master device of the device (release device). + ++.TP ++.BI cpu " DEVICE" ++set cpu device of the dsa device. ++ + .TP + .BI addrgenmode " eui64|none|stable_secret|random" + set the IPv6 address generation mode +-- +2.33.1 +