From nobody Fri Apr 3 16:08:33 2026 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C53938239E for ; Fri, 3 Apr 2026 07:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200482; cv=none; b=SYoK7B38dtep1Ho2LmbgC5A4KOp8HFQofpf33a8g69lwaRkhrL2PlLCmkIt2zplh3rD9If7S9+DlnluJsnPz+tScs96V/BS57Dr5xBDa/UvMzpaxesLmaEZ4KWx3bfwM8yhdd727/oq/njbg8JdRBGgwZ8WZQmr5h9Vnt4qkLkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775200482; c=relaxed/simple; bh=4PUls2oj7ppWeKiHoSHVX2Wv6E8OBa71oEbXDoIg5IM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lNlnZ8cRFw5fODuhAjv2fhDPV/MmSt09c44qkcl1Q6a0L8OWRsNQ7XqaF8NiXQ2GVsDz05+f2BwrSZspMWXXuTTils4qPFwsDlyfKWxeVxFc5SvLwsbilQGlTwbot+fggJ91k4XKR+FoCnsdpt7kbVv50545KGAMkiXdyCALBMU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=U+xLo7pN; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="U+xLo7pN" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1279caef718so2790969c88.1 for ; Fri, 03 Apr 2026 00:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775200479; x=1775805279; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=uE0XUNqqove55/a0CwAGts/FuLqGmOy8m8bmvEm3lok=; b=U+xLo7pNJv4vr3M6zlarl6TzuhJBF3aqM5XGV0SrNGaR4H+hBMxOZmSNv7Nm3QT26G 2HebBvu4js5+TdHX6BCghmz8B8Tx4OL5Y/k+jUx+jO+cCTree5AXLtN5wdkWy8CHKzVv w2v1FAjp54TaaI/QDilyCBJRWDqB2Fq+cvpdGRzsNfiEO6xkuBiAVUUuloyAq7nM/GMx yOSb6HWkuCJVm7WUnbP/05GbVkWuMDf5ic6QTsyjRUIB0byiFSP24uSOa5A5z8cVN9MO Sxdyq/agpRfiQnpnLE+to5yMugQqE2kbPwSt52UIO29ALOXliEDx5Rhl/vaUiJFSuJLC CJhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775200479; x=1775805279; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uE0XUNqqove55/a0CwAGts/FuLqGmOy8m8bmvEm3lok=; b=LW/PwVXKkODHstTw1tEWY8PoOaPO/oDxLU84kA3DSiOFrvQ2duLJdOwJnsjLgzq0iQ EbfKwptaDJqlUpBrW3hi/whIhW83fQ68JL9dSXphGIqWUUpUwhCupiXj+IfMF8jcu33V VhQQ0i/u/Hh2slVoD/7IPkpN/xs2nhmsVoU8ON+Q0lGpfPup5OLWIcup17hgfODdEW8R VZzXLwGNtlu2/ZnrbRo2BVdIaLvganF0b7nTG4FVXEMa4QjqzAfIDSBEstlHkSENin5G PbmlicMp3toT2hmy9kUqk5g4z6WtZMdwB34KQF4zSq4akjhoQfZ8r/oWMRvRmkfGe3I2 BZxg== X-Forwarded-Encrypted: i=1; AJvYcCV5FO/n/0q+2nOTwBYSGiLkZEO5YxDt62RfjX6TDsW+tYGnRP5yn/H96y0OAe09YohxpFmBtSmvN22MKq0=@vger.kernel.org X-Gm-Message-State: AOJu0YywAp4KZohrNWHFc0s2Edp6MUe+hRCci3RdCWFXJcMeFmt4XSfc 1eVf1aeBfak8H3M7jryyhj/P9lQ9L9jWJNzYZqZbDbjrCr5IZEsRoxKkKoJUdrdT/p3CN8fBvBh HX696B45G7JlKI7Ovrp1yfg== X-Received: from dlbrl13.prod.google.com ([2002:a05:7022:f50d:b0:12a:6c32:ffd2]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:4386:b0:11b:9e5e:1a40 with SMTP id a92af1059eb24-12bfb70eb13mr897206c88.15.1775200479082; Fri, 03 Apr 2026 00:14:39 -0700 (PDT) Date: Fri, 03 Apr 2026 07:14:27 +0000 In-Reply-To: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260403-teaming-driver-internal-v4-0-d3032f33ca25@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775200467; l=10710; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=4PUls2oj7ppWeKiHoSHVX2Wv6E8OBa71oEbXDoIg5IM=; b=xRJ/9M7NSbsYBgx1A8enBQLWj3QWAZn9v0s0cAbsAKR30hP4ENVcFwLGgJHDc6iFIyQibixgv hEbQaxiF7m1CCxbdni4m6zcRTQkrYf4X07NxS7XmmMyS6BO21cHYch+ X-Mailer: b4 0.14.3 Message-ID: <20260403-teaming-driver-internal-v4-6-d3032f33ca25@google.com> Subject: [PATCH net-next v4 06/10] net: team: Rename enablement functions and struct members to tx From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add no functional changes, but rename enablement functions, variables etc. that are used in teaming driver transmit decisions. Since rx and tx enablement are still coupled, some of the variables renamed in this patch are still used for the rx path, but that will change in a follow-up patch. Signed-off-by: Marc Harvey --- Changes in v4: - New patch: split from the original monolithic v3 patch "net: team: Decouple rx and tx enablement in the team driver". - Link to v3: https://lore.kernel.org/netdev/20260402-teaming-driver-intern= al-v3-6-e8cfdec3b5c2@google.com/ --- drivers/net/team/team_core.c | 44 +++++++++++++++-------------= -- drivers/net/team/team_mode_loadbalance.c | 2 +- drivers/net/team/team_mode_random.c | 4 +-- drivers/net/team/team_mode_roundrobin.c | 2 +- include/linux/if_team.h | 46 +++++++++++++++++-----------= ---- 5 files changed, 51 insertions(+), 47 deletions(-) diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c index 2ce31999c99f..826769473878 100644 --- a/drivers/net/team/team_core.c +++ b/drivers/net/team/team_core.c @@ -532,13 +532,13 @@ static void team_adjust_ops(struct team *team) * correct ops are always set. */ =20 - if (!team->en_port_count || !team_is_mode_set(team) || + if (!team->tx_en_port_count || !team_is_mode_set(team) || !team->mode->ops->transmit) team->ops.transmit =3D team_dummy_transmit; else team->ops.transmit =3D team->mode->ops->transmit; =20 - if (!team->en_port_count || !team_is_mode_set(team) || + if (!team->tx_en_port_count || !team_is_mode_set(team) || !team->mode->ops->receive) team->ops.receive =3D team_dummy_receive; else @@ -831,7 +831,7 @@ static bool team_queue_override_port_has_gt_prio_than(s= truct team_port *port, return true; if (port->priority > cur->priority) return false; - if (port->index < cur->index) + if (port->tx_index < cur->tx_index) return true; return false; } @@ -929,7 +929,7 @@ static bool team_port_find(const struct team *team, =20 /* * Enable/disable port by adding to enabled port hashlist and setting - * port->index (Might be racy so reader could see incorrect ifindex when + * port->tx_index (Might be racy so reader could see incorrect ifindex when * processing a flying packet, but that is not a problem). Write guarded * by RTNL. */ @@ -938,10 +938,10 @@ static void team_port_enable(struct team *team, { if (team_port_enabled(port)) return; - WRITE_ONCE(port->index, team->en_port_count); - WRITE_ONCE(team->en_port_count, team->en_port_count + 1); - hlist_add_head_rcu(&port->hlist, - team_port_index_hash(team, port->index)); + WRITE_ONCE(port->tx_index, team->tx_en_port_count); + WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count + 1); + hlist_add_head_rcu(&port->tx_hlist, + team_tx_port_index_hash(team, port->tx_index)); team_adjust_ops(team); team_queue_override_port_add(team, port); team_notify_peers(team); @@ -951,15 +951,17 @@ static void team_port_enable(struct team *team, =20 static void __reconstruct_port_hlist(struct team *team, int rm_index) { - int i; + struct hlist_head *tx_port_index_hash; struct team_port *port; + int i; =20 - for (i =3D rm_index + 1; i < team->en_port_count; i++) { - port =3D team_get_port_by_index(team, i); - hlist_del_rcu(&port->hlist); - WRITE_ONCE(port->index, port->index - 1); - hlist_add_head_rcu(&port->hlist, - team_port_index_hash(team, port->index)); + for (i =3D rm_index + 1; i < team->tx_en_port_count; i++) { + port =3D team_get_port_by_tx_index(team, i); + hlist_del_rcu(&port->tx_hlist); + WRITE_ONCE(port->tx_index, port->tx_index - 1); + tx_port_index_hash =3D team_tx_port_index_hash(team, + port->tx_index); + hlist_add_head_rcu(&port->tx_hlist, tx_port_index_hash); } } =20 @@ -970,10 +972,10 @@ static void team_port_disable(struct team *team, return; if (team->ops.port_tx_disabled) team->ops.port_tx_disabled(team, port); - hlist_del_rcu(&port->hlist); - __reconstruct_port_hlist(team, port->index); - WRITE_ONCE(port->index, -1); - WRITE_ONCE(team->en_port_count, team->en_port_count - 1); + hlist_del_rcu(&port->tx_hlist); + __reconstruct_port_hlist(team, port->tx_index); + WRITE_ONCE(port->tx_index, -1); + WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count - 1); team_queue_override_port_del(team, port); team_adjust_ops(team); team_lower_state_changed(port); @@ -1244,7 +1246,7 @@ static int team_port_add(struct team *team, struct ne= t_device *port_dev, netif_addr_unlock_bh(dev); } =20 - WRITE_ONCE(port->index, -1); + WRITE_ONCE(port->tx_index, -1); list_add_tail_rcu(&port->list, &team->port_list); team_port_enable(team, port); netdev_compute_master_upper_features(dev, true); @@ -1595,7 +1597,7 @@ static int team_init(struct net_device *dev) return -ENOMEM; =20 for (i =3D 0; i < TEAM_PORT_HASHENTRIES; i++) - INIT_HLIST_HEAD(&team->en_port_hlist[i]); + INIT_HLIST_HEAD(&team->tx_en_port_hlist[i]); INIT_LIST_HEAD(&team->port_list); err =3D team_queue_override_init(team); if (err) diff --git a/drivers/net/team/team_mode_loadbalance.c b/drivers/net/team/te= am_mode_loadbalance.c index 840f409d250b..4833fbfe241e 100644 --- a/drivers/net/team/team_mode_loadbalance.c +++ b/drivers/net/team/team_mode_loadbalance.c @@ -120,7 +120,7 @@ static struct team_port *lb_hash_select_tx_port(struct = team *team, { int port_index =3D team_num_to_port_index(team, hash); =20 - return team_get_port_by_index_rcu(team, port_index); + return team_get_port_by_tx_index_rcu(team, port_index); } =20 /* Hash to port mapping select tx port */ diff --git a/drivers/net/team/team_mode_random.c b/drivers/net/team/team_mo= de_random.c index 169a7bc865b2..370e974f3dca 100644 --- a/drivers/net/team/team_mode_random.c +++ b/drivers/net/team/team_mode_random.c @@ -16,8 +16,8 @@ static bool rnd_transmit(struct team *team, struct sk_buf= f *skb) struct team_port *port; int port_index; =20 - port_index =3D get_random_u32_below(READ_ONCE(team->en_port_count)); - port =3D team_get_port_by_index_rcu(team, port_index); + port_index =3D get_random_u32_below(READ_ONCE(team->tx_en_port_count)); + port =3D team_get_port_by_tx_index_rcu(team, port_index); if (unlikely(!port)) goto drop; port =3D team_get_first_port_txable_rcu(team, port); diff --git a/drivers/net/team/team_mode_roundrobin.c b/drivers/net/team/tea= m_mode_roundrobin.c index dd405d82c6ac..ecbeef28c221 100644 --- a/drivers/net/team/team_mode_roundrobin.c +++ b/drivers/net/team/team_mode_roundrobin.c @@ -27,7 +27,7 @@ static bool rr_transmit(struct team *team, struct sk_buff= *skb) =20 port_index =3D team_num_to_port_index(team, rr_priv(team)->sent_packets++); - port =3D team_get_port_by_index_rcu(team, port_index); + port =3D team_get_port_by_tx_index_rcu(team, port_index); if (unlikely(!port)) goto drop; port =3D team_get_first_port_txable_rcu(team, port); diff --git a/include/linux/if_team.h b/include/linux/if_team.h index 740cb3100dfc..c777170ef552 100644 --- a/include/linux/if_team.h +++ b/include/linux/if_team.h @@ -27,10 +27,10 @@ struct team; =20 struct team_port { struct net_device *dev; - struct hlist_node hlist; /* node in enabled ports hash list */ + struct hlist_node tx_hlist; /* node in tx-enabled ports hash list */ struct list_head list; /* node in ordinary list */ struct team *team; - int index; /* index of enabled port. If disabled, it's set to -1 */ + int tx_index; /* index of tx enabled port. If disabled, -1 */ =20 bool linkup; /* either state.linkup or user.linkup */ =20 @@ -77,7 +77,7 @@ static inline struct team_port *team_port_get_rcu(const s= truct net_device *dev) =20 static inline bool team_port_enabled(struct team_port *port) { - return READ_ONCE(port->index) !=3D -1; + return READ_ONCE(port->tx_index) !=3D -1; } =20 static inline bool team_port_txable(struct team_port *port) @@ -190,10 +190,10 @@ struct team { const struct header_ops *header_ops_cache; =20 /* - * List of enabled ports and their count + * List of tx-enabled ports and counts of rx and tx-enabled ports. */ - int en_port_count; - struct hlist_head en_port_hlist[TEAM_PORT_HASHENTRIES]; + int tx_en_port_count; + struct hlist_head tx_en_port_hlist[TEAM_PORT_HASHENTRIES]; =20 struct list_head port_list; /* list of all ports */ =20 @@ -237,41 +237,43 @@ static inline int team_dev_queue_xmit(struct team *te= am, struct team_port *port, return dev_queue_xmit(skb); } =20 -static inline struct hlist_head *team_port_index_hash(struct team *team, - int port_index) +static inline struct hlist_head *team_tx_port_index_hash(struct team *team, + int tx_port_index) { - return &team->en_port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; + unsigned int list_entry =3D tx_port_index & (TEAM_PORT_HASHENTRIES - 1); + + return &team->tx_en_port_hlist[list_entry]; } =20 -static inline struct team_port *team_get_port_by_index(struct team *team, - int port_index) +static inline struct team_port *team_get_port_by_tx_index(struct team *tea= m, + int tx_port_index) { + struct hlist_head *head =3D team_tx_port_index_hash(team, tx_port_index); struct team_port *port; - struct hlist_head *head =3D team_port_index_hash(team, port_index); =20 - hlist_for_each_entry(port, head, hlist) - if (port->index =3D=3D port_index) + hlist_for_each_entry(port, head, tx_hlist) + if (port->tx_index =3D=3D tx_port_index) return port; return NULL; } =20 static inline int team_num_to_port_index(struct team *team, unsigned int n= um) { - int en_port_count =3D READ_ONCE(team->en_port_count); + int tx_en_port_count =3D READ_ONCE(team->tx_en_port_count); =20 - if (unlikely(!en_port_count)) + if (unlikely(!tx_en_port_count)) return 0; - return num % en_port_count; + return num % tx_en_port_count; } =20 -static inline struct team_port *team_get_port_by_index_rcu(struct team *te= am, - int port_index) +static inline struct team_port *team_get_port_by_tx_index_rcu(struct team = *team, + int tx_port_index) { + struct hlist_head *head =3D team_tx_port_index_hash(team, tx_port_index); struct team_port *port; - struct hlist_head *head =3D team_port_index_hash(team, port_index); =20 - hlist_for_each_entry_rcu(port, head, hlist) - if (READ_ONCE(port->index) =3D=3D port_index) + hlist_for_each_entry_rcu(port, head, tx_hlist) + if (READ_ONCE(port->tx_index) =3D=3D tx_port_index) return port; return NULL; } --=20 2.53.0.1185.g05d4b7b318-goog