Skip to contentSkip to conversation

net/mlx5: Improve tuple ID allocation

PATCH In review Matthew Wilcox 2 participants 2 messages Jun 3, 2020 – Jun 4, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx5: Improve tuple ID allocation

From: "Matthew Wilcox (Oracle)" <[email protected]>

There's no need to use a temporary variable; the XArray is designed to write directly into the object being allocated.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +3 -5
index 4eb305af0106..63d392a8043d 100644
@@ -57,7 +57,7 @@ struct mlx5_ct_flow {
 struct mlx5_ct_zone_rule {
 	struct mlx5_flow_handle *rule;
 	struct mlx5_esw_flow_attr attr;
-	int tupleid;
+	u32 tupleid;
 	bool nat;
 };
 
@@ -484,7 +484,6 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
 	struct mlx5_esw_flow_attr *attr = &zone_rule->attr;
 	struct mlx5_eswitch *esw = ct_priv->esw;
 	struct mlx5_flow_spec *spec = NULL;
-	u32 tupleid;
 	int err;
 
 	zone_rule->nat = nat;
@@ -494,17 +493,16 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
 		return -ENOMEM;
 
 	/* Get tuple unique id */
-	err = xa_alloc(&ct_priv->tuple_ids, &tupleid, zone_rule,
+	err = xa_alloc(&ct_priv->tuple_ids, &zone_rule->tupleid, zone_rule,
 		       XA_LIMIT(1, TUPLE_ID_MAX), GFP_KERNEL);
 	if (err) {
 		netdev_warn(ct_priv->netdev,
 			    "Failed to allocate tuple id, err: %d\n", err);
 		goto err_xa_alloc;
 	}
-	zone_rule->tupleid = tupleid;
 
 	err = mlx5_tc_ct_entry_create_mod_hdr(ct_priv, attr, flow_rule,
-					      tupleid, nat);
+					      zone_rule->tupleid, nat);
 	if (err) {
 		ct_dbg("Failed to create ct entry mod hdr");
 		goto err_mod_hdr;
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Matthew Wilcox

From: "Matthew Wilcox (Oracle)" <[email protected]>

There's no need to use a temporary variable; the XArray is designed to write directly into the object being allocated.

---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

t

Thanks,