Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: team: Rename enablement functions and struct members to tx

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.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Marc Harvey <marcharvey@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260409-teaming-driver-internal-v7-6-f47e7589685d@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Marc Harvey and committed by
Paolo Abeni
fa6ed31d 10407eeb

+51 -47
+23 -21
drivers/net/team/team_core.c
··· 532 532 * correct ops are always set. 533 533 */ 534 534 535 - if (!team->en_port_count || !team_is_mode_set(team) || 535 + if (!team->tx_en_port_count || !team_is_mode_set(team) || 536 536 !team->mode->ops->transmit) 537 537 team->ops.transmit = team_dummy_transmit; 538 538 else 539 539 team->ops.transmit = team->mode->ops->transmit; 540 540 541 - if (!team->en_port_count || !team_is_mode_set(team) || 541 + if (!team->tx_en_port_count || !team_is_mode_set(team) || 542 542 !team->mode->ops->receive) 543 543 team->ops.receive = team_dummy_receive; 544 544 else ··· 831 831 return true; 832 832 if (port->priority > cur->priority) 833 833 return false; 834 - if (port->index < cur->index) 834 + if (port->tx_index < cur->tx_index) 835 835 return true; 836 836 return false; 837 837 } ··· 929 929 930 930 /* 931 931 * Enable/disable port by adding to enabled port hashlist and setting 932 - * port->index (Might be racy so reader could see incorrect ifindex when 932 + * port->tx_index (Might be racy so reader could see incorrect ifindex when 933 933 * processing a flying packet, but that is not a problem). Write guarded 934 934 * by RTNL. 935 935 */ ··· 938 938 { 939 939 if (team_port_enabled(port)) 940 940 return; 941 - WRITE_ONCE(port->index, team->en_port_count); 942 - WRITE_ONCE(team->en_port_count, team->en_port_count + 1); 943 - hlist_add_head_rcu(&port->hlist, 944 - team_port_index_hash(team, port->index)); 941 + WRITE_ONCE(port->tx_index, team->tx_en_port_count); 942 + WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count + 1); 943 + hlist_add_head_rcu(&port->tx_hlist, 944 + team_tx_port_index_hash(team, port->tx_index)); 945 945 team_adjust_ops(team); 946 946 team_queue_override_port_add(team, port); 947 947 team_notify_peers(team); ··· 951 951 952 952 static void __reconstruct_port_hlist(struct team *team, int rm_index) 953 953 { 954 - int i; 954 + struct hlist_head *tx_port_index_hash; 955 955 struct team_port *port; 956 + int i; 956 957 957 - for (i = rm_index + 1; i < team->en_port_count; i++) { 958 - port = team_get_port_by_index(team, i); 959 - hlist_del_rcu(&port->hlist); 960 - WRITE_ONCE(port->index, port->index - 1); 961 - hlist_add_head_rcu(&port->hlist, 962 - team_port_index_hash(team, port->index)); 958 + for (i = rm_index + 1; i < team->tx_en_port_count; i++) { 959 + port = team_get_port_by_tx_index(team, i); 960 + hlist_del_rcu(&port->tx_hlist); 961 + WRITE_ONCE(port->tx_index, port->tx_index - 1); 962 + tx_port_index_hash = team_tx_port_index_hash(team, 963 + port->tx_index); 964 + hlist_add_head_rcu(&port->tx_hlist, tx_port_index_hash); 963 965 } 964 966 } 965 967 ··· 972 970 return; 973 971 if (team->ops.port_tx_disabled) 974 972 team->ops.port_tx_disabled(team, port); 975 - hlist_del_rcu(&port->hlist); 976 - __reconstruct_port_hlist(team, port->index); 977 - WRITE_ONCE(port->index, -1); 978 - WRITE_ONCE(team->en_port_count, team->en_port_count - 1); 973 + hlist_del_rcu(&port->tx_hlist); 974 + __reconstruct_port_hlist(team, port->tx_index); 975 + WRITE_ONCE(port->tx_index, -1); 976 + WRITE_ONCE(team->tx_en_port_count, team->tx_en_port_count - 1); 979 977 team_queue_override_port_del(team, port); 980 978 team_adjust_ops(team); 981 979 team_lower_state_changed(port); ··· 1246 1244 netif_addr_unlock_bh(dev); 1247 1245 } 1248 1246 1249 - WRITE_ONCE(port->index, -1); 1247 + WRITE_ONCE(port->tx_index, -1); 1250 1248 list_add_tail_rcu(&port->list, &team->port_list); 1251 1249 team_port_enable(team, port); 1252 1250 netdev_compute_master_upper_features(dev, true); ··· 1597 1595 return -ENOMEM; 1598 1596 1599 1597 for (i = 0; i < TEAM_PORT_HASHENTRIES; i++) 1600 - INIT_HLIST_HEAD(&team->en_port_hlist[i]); 1598 + INIT_HLIST_HEAD(&team->tx_en_port_hlist[i]); 1601 1599 INIT_LIST_HEAD(&team->port_list); 1602 1600 err = team_queue_override_init(team); 1603 1601 if (err)
+1 -1
drivers/net/team/team_mode_loadbalance.c
··· 120 120 { 121 121 int port_index = team_num_to_port_index(team, hash); 122 122 123 - return team_get_port_by_index_rcu(team, port_index); 123 + return team_get_port_by_tx_index_rcu(team, port_index); 124 124 } 125 125 126 126 /* Hash to port mapping select tx port */
+2 -2
drivers/net/team/team_mode_random.c
··· 16 16 struct team_port *port; 17 17 int port_index; 18 18 19 - port_index = get_random_u32_below(READ_ONCE(team->en_port_count)); 20 - port = team_get_port_by_index_rcu(team, port_index); 19 + port_index = get_random_u32_below(READ_ONCE(team->tx_en_port_count)); 20 + port = team_get_port_by_tx_index_rcu(team, port_index); 21 21 if (unlikely(!port)) 22 22 goto drop; 23 23 port = team_get_first_port_txable_rcu(team, port);
+1 -1
drivers/net/team/team_mode_roundrobin.c
··· 27 27 28 28 port_index = team_num_to_port_index(team, 29 29 rr_priv(team)->sent_packets++); 30 - port = team_get_port_by_index_rcu(team, port_index); 30 + port = team_get_port_by_tx_index_rcu(team, port_index); 31 31 if (unlikely(!port)) 32 32 goto drop; 33 33 port = team_get_first_port_txable_rcu(team, port);
+24 -22
include/linux/if_team.h
··· 27 27 28 28 struct team_port { 29 29 struct net_device *dev; 30 - struct hlist_node hlist; /* node in enabled ports hash list */ 30 + struct hlist_node tx_hlist; /* node in tx-enabled ports hash list */ 31 31 struct list_head list; /* node in ordinary list */ 32 32 struct team *team; 33 - int index; /* index of enabled port. If disabled, it's set to -1 */ 33 + int tx_index; /* index of tx enabled port. If disabled, -1 */ 34 34 35 35 bool linkup; /* either state.linkup or user.linkup */ 36 36 ··· 77 77 78 78 static inline bool team_port_enabled(struct team_port *port) 79 79 { 80 - return READ_ONCE(port->index) != -1; 80 + return READ_ONCE(port->tx_index) != -1; 81 81 } 82 82 83 83 static inline bool team_port_txable(struct team_port *port) ··· 190 190 const struct header_ops *header_ops_cache; 191 191 192 192 /* 193 - * List of enabled ports and their count 193 + * List of tx-enabled ports and counts of rx and tx-enabled ports. 194 194 */ 195 - int en_port_count; 196 - struct hlist_head en_port_hlist[TEAM_PORT_HASHENTRIES]; 195 + int tx_en_port_count; 196 + struct hlist_head tx_en_port_hlist[TEAM_PORT_HASHENTRIES]; 197 197 198 198 struct list_head port_list; /* list of all ports */ 199 199 ··· 237 237 return dev_queue_xmit(skb); 238 238 } 239 239 240 - static inline struct hlist_head *team_port_index_hash(struct team *team, 241 - int port_index) 240 + static inline struct hlist_head *team_tx_port_index_hash(struct team *team, 241 + int tx_port_index) 242 242 { 243 - return &team->en_port_hlist[port_index & (TEAM_PORT_HASHENTRIES - 1)]; 243 + unsigned int list_entry = tx_port_index & (TEAM_PORT_HASHENTRIES - 1); 244 + 245 + return &team->tx_en_port_hlist[list_entry]; 244 246 } 245 247 246 - static inline struct team_port *team_get_port_by_index(struct team *team, 247 - int port_index) 248 + static inline struct team_port *team_get_port_by_tx_index(struct team *team, 249 + int tx_port_index) 248 250 { 251 + struct hlist_head *head = team_tx_port_index_hash(team, tx_port_index); 249 252 struct team_port *port; 250 - struct hlist_head *head = team_port_index_hash(team, port_index); 251 253 252 - hlist_for_each_entry(port, head, hlist) 253 - if (port->index == port_index) 254 + hlist_for_each_entry(port, head, tx_hlist) 255 + if (port->tx_index == tx_port_index) 254 256 return port; 255 257 return NULL; 256 258 } 257 259 258 260 static inline int team_num_to_port_index(struct team *team, unsigned int num) 259 261 { 260 - int en_port_count = READ_ONCE(team->en_port_count); 262 + int tx_en_port_count = READ_ONCE(team->tx_en_port_count); 261 263 262 - if (unlikely(!en_port_count)) 264 + if (unlikely(!tx_en_port_count)) 263 265 return 0; 264 - return num % en_port_count; 266 + return num % tx_en_port_count; 265 267 } 266 268 267 - static inline struct team_port *team_get_port_by_index_rcu(struct team *team, 268 - int port_index) 269 + static inline struct team_port *team_get_port_by_tx_index_rcu(struct team *team, 270 + int tx_port_index) 269 271 { 272 + struct hlist_head *head = team_tx_port_index_hash(team, tx_port_index); 270 273 struct team_port *port; 271 - struct hlist_head *head = team_port_index_hash(team, port_index); 272 274 273 - hlist_for_each_entry_rcu(port, head, hlist) 274 - if (READ_ONCE(port->index) == port_index) 275 + hlist_for_each_entry_rcu(port, head, tx_hlist) 276 + if (READ_ONCE(port->tx_index) == tx_port_index) 275 277 return port; 276 278 return NULL; 277 279 }