Skip to contentSkip to conversation

LPM changes

PATCH Superseded Ruifeng Wang 8 participants 42 messages Sep 7, 2020 – Oct 26, 2020

lore
Share & tools
lore
#0 lore raw

cover LPM changes

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Ruifeng Wang (2):
lpm: fix free of data structure
lpm: hide internal data

 lib/librte_lpm/rte_lpm.c | 154 +++++++++++++++++++++++----------------
 lib/librte_lpm/rte_lpm.h |   7 --
 2 files changed, 92 insertions(+), 69 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 lpm: fix free of data structure

The container structure should be freed instead of rte_lpm structure after wrapping rte_lpm into internal structure __rte_lpm.

Fixes 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
---
 lib/librte_lpm/rte_lpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/rte_lpm.c +1 -1
index 757436f49..51a0ae578 100644
@@ -268,7 +268,7 @@ rte_lpm_free(struct rte_lpm *lpm)
 		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
-	rte_free(lpm);
+	rte_free(internal_lpm);
 	rte_free(te);
 }
 
Signature · 1 line
2.17.1
Acked-by on v1 1/2
#2 lore raw

Re: [dpdk-dev] [PATCH 1/2] lpm: fix free of data structure

Quoted 18 lines · Ruifeng Wang

The container structure should be freed instead of rte_lpm structure after wrapping rte_lpm into internal structure __rte_lpm.

Fixes 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
---
 lib/librte_lpm/rte_lpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/rte_lpm.c +0 -0
index 757436f49..51a0ae578 100644

lib/librte_lpm/rte_lpm.c rte_lpm_free(struct rte_lpm *lpm) · line 274

Quoted 8 lines
lib/librte_lpm/rte_lpm.c +1 -1
@@ -268,7 +268,7 @@ rte_lpm_free(struct rte_lpm *lpm)
 		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
-	rte_free(lpm);
+	rte_free(internal_lpm);
 	rte_free(te);
 }
 
Acked-by on v1 1/2
#3 lore raw

Re: [dpdk-dev] [PATCH 1/2] lpm: fix free of data structure

In reply to Ruifeng Wang
Quoted 18 lines · Ruifeng Wang

The container structure should be freed instead of rte_lpm structure after wrapping rte_lpm into internal structure __rte_lpm.

Fixes 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
---
  lib/librte_lpm/rte_lpm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/rte_lpm.c +0 -0
index 757436f49..51a0ae578 100644

lib/librte_lpm/rte_lpm.c rte_lpm_free(struct rte_lpm *lpm) · line 274

Quoted 8 lines
lib/librte_lpm/rte_lpm.c +1 -1
@@ -268,7 +268,7 @@ rte_lpm_free(struct rte_lpm *lpm)
  		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
  	rte_free(lpm->tbl8);
  	rte_free(lpm->rules_tbl);
-	rte_free(lpm);
+	rte_free(internal_lpm);
  	rte_free(te);
  }
 
Signature · 2 lines
Regards,
Vladimir
#4 lore raw

PATCH 2/2 lpm: hide internal data

In reply to Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
 lib/librte_lpm/rte_lpm.c | 152 +++++++++++++++++++++++----------------
 lib/librte_lpm/rte_lpm.h |   7 --
 2 files changed, 91 insertions(+), 68 deletions(-)
lib/librte_lpm/rte_lpm.c +91 -61
index 51a0ae578..88d31df6d 100644
@@ -42,9 +42,17 @@ enum valid_flag {
 
 /** @internal LPM structure. */
 struct __rte_lpm {
-	/* LPM metadata. */
+	/* Exposed LPM data. */
 	struct rte_lpm lpm;
 
+	/* LPM metadata. */
+	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
+	uint32_t max_rules; /**< Max. balanced rules per lpm. */
+	uint32_t number_tbl8s; /**< Number of tbl8s. */
+	/**< Rule info table. */
+	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH];
+	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
+
 	/* RCU config. */
 	struct rte_rcu_qsbr *v;		/* RCU QSBR variable. */
 	enum rte_lpm_qsbr_mode rcu_mode;/* Blocking, defer queue. */
@@ -104,7 +112,7 @@ depth_to_range(uint8_t depth)
 struct rte_lpm *
 rte_lpm_find_existing(const char *name)
 {
-	struct rte_lpm *l = NULL;
+	struct __rte_lpm *l = NULL;
 	struct rte_tailq_entry *te;
 	struct rte_lpm_list *lpm_list;
 
@@ -123,7 +131,7 @@ rte_lpm_find_existing(const char *name)
 		return NULL;
 	}
 
-	return l;
+	return &l->lpm;
 }
 
 /*
@@ -157,8 +165,8 @@ rte_lpm_create(const char *name, int socket_id,
 
 	/* guarantee there's no existing */
 	TAILQ_FOREACH(te, lpm_list, next) {
-		lpm = te->data;
-		if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
+		internal_lpm = te->data;
+		if (strncmp(name, internal_lpm->name, RTE_LPM_NAMESIZE) == 0)
 			break;
 	}
 
@@ -193,10 +201,10 @@ rte_lpm_create(const char *name, int socket_id,
 	}
 
 	lpm = &internal_lpm->lpm;
-	lpm->rules_tbl = rte_zmalloc_socket(NULL,
+	internal_lpm->rules_tbl = rte_zmalloc_socket(NULL,
 			(size_t)rules_size, RTE_CACHE_LINE_SIZE, socket_id);
 
-	if (lpm->rules_tbl == NULL) {
+	if (internal_lpm->rules_tbl == NULL) {
 		RTE_LOG(ERR, LPM, "LPM rules_tbl memory allocation failed\n");
 		rte_free(internal_lpm);
 		internal_lpm = NULL;
@@ -211,7 +219,7 @@ rte_lpm_create(const char *name, int socket_id,
 
 	if (lpm->tbl8 == NULL) {
 		RTE_LOG(ERR, LPM, "LPM tbl8 memory allocation failed\n");
-		rte_free(lpm->rules_tbl);
+		rte_free(internal_lpm->rules_tbl);
 		rte_free(internal_lpm);
 		internal_lpm = NULL;
 		lpm = NULL;
@@ -221,11 +229,11 @@ rte_lpm_create(const char *name, int socket_id,
 	}
 
 	/* Save user arguments. */
-	lpm->max_rules = config->max_rules;
-	lpm->number_tbl8s = config->number_tbl8s;
-	strlcpy(lpm->name, name, sizeof(lpm->name));
+	internal_lpm->max_rules = config->max_rules;
+	internal_lpm->number_tbl8s = config->number_tbl8s;
+	strlcpy(internal_lpm->name, name, sizeof(internal_lpm->name));
 
-	te->data = lpm;
+	te->data = internal_lpm;
 
 	TAILQ_INSERT_TAIL(lpm_list, te, next);
 
@@ -241,7 +249,7 @@ rte_lpm_create(const char *name, int socket_id,
 void
 rte_lpm_free(struct rte_lpm *lpm)
 {
-	struct __rte_lpm *internal_lpm;
+	struct __rte_lpm *internal_lpm = NULL;
 	struct rte_lpm_list *lpm_list;
 	struct rte_tailq_entry *te;
 
@@ -255,7 +263,8 @@ rte_lpm_free(struct rte_lpm *lpm)
 
 	/* find our tailq entry */
 	TAILQ_FOREACH(te, lpm_list, next) {
-		if (te->data == (void *) lpm)
+		internal_lpm = te->data;
+		if (&internal_lpm->lpm == lpm)
 			break;
 	}
 	if (te != NULL)
@@ -263,11 +272,10 @@ rte_lpm_free(struct rte_lpm *lpm)
 
 	rte_mcfg_tailq_write_unlock();
 
-	internal_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	if (internal_lpm->dq != NULL)
 		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
 	rte_free(lpm->tbl8);
-	rte_free(lpm->rules_tbl);
+	rte_free(internal_lpm->rules_tbl);
 	rte_free(internal_lpm);
 	rte_free(te);
 }
@@ -310,11 +318,11 @@ rte_lpm_rcu_qsbr_add(struct rte_lpm *lpm, struct rte_lpm_rcu_config *cfg)
 	} else if (cfg->mode == RTE_LPM_QSBR_MODE_DQ) {
 		/* Init QSBR defer queue. */
 		snprintf(rcu_dq_name, sizeof(rcu_dq_name),
-				"LPM_RCU_%s", lpm->name);
+				"LPM_RCU_%s", internal_lpm->name);
 		params.name = rcu_dq_name;
 		params.size = cfg->dq_size;
 		if (params.size == 0)
-			params.size = lpm->number_tbl8s;
+			params.size = internal_lpm->number_tbl8s;
 		params.trigger_reclaim_limit = cfg->reclaim_thd;
 		params.max_reclaim_size = cfg->reclaim_max;
 		if (params.max_reclaim_size == 0)
@@ -352,74 +360,79 @@ static int32_t
 rule_add(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth,
 	uint32_t next_hop)
 {
-	uint32_t rule_gindex, rule_index, last_rule;
+	uint32_t rule_gindex, rule_index, last_rule, first_index;
+	struct __rte_lpm *i_lpm;
 	int i;
 
 	VERIFY_DEPTH(depth);
 
+	i_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	/* Scan through rule group to see if rule already exists. */
-	if (lpm->rule_info[depth - 1].used_rules > 0) {
+	if (i_lpm->rule_info[depth - 1].used_rules > 0) {
 
 		/* rule_gindex stands for rule group index. */
-		rule_gindex = lpm->rule_info[depth - 1].first_rule;
+		rule_gindex = i_lpm->rule_info[depth - 1].first_rule;
 		/* Initialise rule_index to point to start of rule group. */
 		rule_index = rule_gindex;
 		/* Last rule = Last used rule in this rule group. */
-		last_rule = rule_gindex + lpm->rule_info[depth - 1].used_rules;
+		last_rule = rule_gindex
+				+ i_lpm->rule_info[depth - 1].used_rules;
 
 		for (; rule_index < last_rule; rule_index++) {
 
 			/* If rule already exists update next hop and return. */
-			if (lpm->rules_tbl[rule_index].ip == ip_masked) {
+			if (i_lpm->rules_tbl[rule_index].ip == ip_masked) {
 
-				if (lpm->rules_tbl[rule_index].next_hop
+				if (i_lpm->rules_tbl[rule_index].next_hop
 						== next_hop)
 					return -EEXIST;
-				lpm->rules_tbl[rule_index].next_hop = next_hop;
+				i_lpm->rules_tbl[rule_index].next_hop
+					= next_hop;
 
 				return rule_index;
 			}
 		}
 
-		if (rule_index == lpm->max_rules)
+		if (rule_index == i_lpm->max_rules)
 			return -ENOSPC;
 	} else {
 		/* Calculate the position in which the rule will be stored. */
 		rule_index = 0;
 
 		for (i = depth - 1; i > 0; i--) {
-			if (lpm->rule_info[i - 1].used_rules > 0) {
-				rule_index = lpm->rule_info[i - 1].first_rule
-						+ lpm->rule_info[i - 1].used_rules;
+			if (i_lpm->rule_info[i - 1].used_rules > 0) {
+				rule_index = i_lpm->rule_info[i - 1].first_rule
+					+ i_lpm->rule_info[i - 1].used_rules;
 				break;
 			}
 		}
-		if (rule_index == lpm->max_rules)
+		if (rule_index == i_lpm->max_rules)
 			return -ENOSPC;
 
-		lpm->rule_info[depth - 1].first_rule = rule_index;
+		i_lpm->rule_info[depth - 1].first_rule = rule_index;
 	}
 
 	/* Make room for the new rule in the array. */
 	for (i = RTE_LPM_MAX_DEPTH; i > depth; i--) {
-		if (lpm->rule_info[i - 1].first_rule
-				+ lpm->rule_info[i - 1].used_rules == lpm->max_rules)
+		first_index = i_lpm->rule_info[i - 1].first_rule;
+		if (first_index + i_lpm->rule_info[i - 1].used_rules
+				== i_lpm->max_rules)
 			return -ENOSPC;
 
-		if (lpm->rule_info[i - 1].used_rules > 0) {
-			lpm->rules_tbl[lpm->rule_info[i - 1].first_rule
-				+ lpm->rule_info[i - 1].used_rules]
-					= lpm->rules_tbl[lpm->rule_info[i - 1].first_rule];
-			lpm->rule_info[i - 1].first_rule++;
+		if (i_lpm->rule_info[i - 1].used_rules > 0) {
+			i_lpm->rules_tbl[first_index
+				+ i_lpm->rule_info[i - 1].used_rules]
+					= i_lpm->rules_tbl[first_index];
+			i_lpm->rule_info[i - 1].first_rule++;
 		}
 	}
 
 	/* Add the new rule. */
-	lpm->rules_tbl[rule_index].ip = ip_masked;
-	lpm->rules_tbl[rule_index].next_hop = next_hop;
+	i_lpm->rules_tbl[rule_index].ip = ip_masked;
+	i_lpm->rules_tbl[rule_index].next_hop = next_hop;
 
 	/* Increment the used rules counter for this rule group. */
-	lpm->rule_info[depth - 1].used_rules++;
+	i_lpm->rule_info[depth - 1].used_rules++;
 
 	return rule_index;
 }
@@ -432,23 +445,25 @@ static void
 rule_delete(struct rte_lpm *lpm, int32_t rule_index, uint8_t depth)
 {
 	int i;
+	struct __rte_lpm *i_lpm;
 
 	VERIFY_DEPTH(depth);
 
-	lpm->rules_tbl[rule_index] =
-			lpm->rules_tbl[lpm->rule_info[depth - 1].first_rule
-			+ lpm->rule_info[depth - 1].used_rules - 1];
+	i_lpm = container_of(lpm, struct __rte_lpm, lpm);
+	i_lpm->rules_tbl[rule_index] =
+			i_lpm->rules_tbl[i_lpm->rule_info[depth - 1].first_rule
+			+ i_lpm->rule_info[depth - 1].used_rules - 1];
 
 	for (i = depth; i < RTE_LPM_MAX_DEPTH; i++) {
-		if (lpm->rule_info[i].used_rules > 0) {
-			lpm->rules_tbl[lpm->rule_info[i].first_rule - 1] =
-					lpm->rules_tbl[lpm->rule_info[i].first_rule
-						+ lpm->rule_info[i].used_rules - 1];
-			lpm->rule_info[i].first_rule--;
+		if (i_lpm->rule_info[i].used_rules > 0) {
+			i_lpm->rules_tbl[i_lpm->rule_info[i].first_rule - 1] =
+				i_lpm->rules_tbl[i_lpm->rule_info[i].first_rule
+					+ i_lpm->rule_info[i].used_rules - 1];
+			i_lpm->rule_info[i].first_rule--;
 		}
 	}
 
-	lpm->rule_info[depth - 1].used_rules--;
+	i_lpm->rule_info[depth - 1].used_rules--;
 }
 
 /*
@@ -459,16 +474,18 @@ static int32_t
 rule_find(struct rte_lpm *lpm, uint32_t ip_masked, uint8_t depth)
 {
 	uint32_t rule_gindex, last_rule, rule_index;
+	struct __rte_lpm *internal_lpm;
 
 	VERIFY_DEPTH(depth);
 
-	rule_gindex = lpm->rule_info[depth - 1].first_rule;
-	last_rule = rule_gindex + lpm->rule_info[depth - 1].used_rules;
+	internal_lpm = container_of(lpm, struct __rte_lpm, lpm);
+	rule_gindex = internal_lpm->rule_info[depth - 1].first_rule;
+	last_rule = rule_gindex + internal_lpm->rule_info[depth - 1].used_rules;
 
 	/* Scan used rules at given depth to find rule. */
 	for (rule_index = rule_gindex; rule_index < last_rule; rule_index++) {
 		/* If rule is found return the rule index. */
-		if (lpm->rules_tbl[rule_index].ip == ip_masked)
+		if (internal_lpm->rules_tbl[rule_index].ip == ip_masked)
 			return rule_index;
 	}
 
@@ -484,9 +501,11 @@ _tbl8_alloc(struct rte_lpm *lpm)
 {
 	uint32_t group_idx; /* tbl8 group index. */
 	struct rte_lpm_tbl_entry *tbl8_entry;
+	struct __rte_lpm *i_lpm;
 
+	i_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	/* Scan through tbl8 to find a free (i.e. INVALID) tbl8 group. */
-	for (group_idx = 0; group_idx < lpm->number_tbl8s; group_idx++) {
+	for (group_idx = 0; group_idx < i_lpm->number_tbl8s; group_idx++) {
 		tbl8_entry = &lpm->tbl8[group_idx *
 					RTE_LPM_TBL8_GROUP_NUM_ENTRIES];
 		/* If a free tbl8 group is found clean it and set as VALID. */
@@ -844,6 +863,7 @@ uint32_t *next_hop)
 {
 	uint32_t ip_masked;
 	int32_t rule_index;
+	struct __rte_lpm *internal_lpm;
 
 	/* Check user arguments. */
 	if ((lpm == NULL) ||
@@ -855,8 +875,9 @@ uint32_t *next_hop)
 	ip_masked = ip & depth_to_mask(depth);
 	rule_index = rule_find(lpm, ip_masked, depth);
 
+	internal_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	if (rule_index >= 0) {
-		*next_hop = lpm->rules_tbl[rule_index].next_hop;
+		*next_hop = internal_lpm->rules_tbl[rule_index].next_hop;
 		return 1;
 	}
 
@@ -897,7 +918,9 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
 	tbl24_range = depth_to_range(depth);
 	tbl24_index = (ip_masked >> 8);
 	struct rte_lpm_tbl_entry zero_tbl24_entry = {0};
+	struct __rte_lpm *i_lpm;
 
+	i_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	/*
 	 * Firstly check the sub_rule_index. A -1 indicates no replacement rule
 	 * and a positive number indicates a sub_rule_index.
@@ -939,7 +962,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
 		 */
 
 		struct rte_lpm_tbl_entry new_tbl24_entry = {
-			.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
+			.next_hop = i_lpm->rules_tbl[sub_rule_index].next_hop,
 			.valid = VALID,
 			.valid_group = 0,
 			.depth = sub_rule_depth,
@@ -949,7 +972,7 @@ delete_depth_small(struct rte_lpm *lpm, uint32_t ip_masked,
 			.valid = VALID,
 			.valid_group = VALID,
 			.depth = sub_rule_depth,
-			.next_hop = lpm->rules_tbl
+			.next_hop = i_lpm->rules_tbl
 			[sub_rule_index].next_hop,
 		};
 
@@ -1048,6 +1071,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
 	uint32_t tbl24_index, tbl8_group_index, tbl8_group_start, tbl8_index,
 			tbl8_range, i;
 	int32_t tbl8_recycle_index, status = 0;
+	struct __rte_lpm *i_lpm;
 
 	/*
 	 * Calculate the index into tbl24 and range. Note: All depths larger
@@ -1061,6 +1085,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
 	tbl8_index = tbl8_group_start + (ip_masked & 0xFF);
 	tbl8_range = depth_to_range(depth);
 
+	i_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	if (sub_rule_index < 0) {
 		/*
 		 * Loop through the range of entries on tbl8 for which the
@@ -1076,7 +1101,7 @@ delete_depth_big(struct rte_lpm *lpm, uint32_t ip_masked,
 			.valid = VALID,
 			.depth = sub_rule_depth,
 			.valid_group = lpm->tbl8[tbl8_group_start].valid_group,
-			.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
+			.next_hop = i_lpm->rules_tbl[sub_rule_index].next_hop,
 		};
 
 		/*
@@ -1188,16 +1213,21 @@ rte_lpm_delete(struct rte_lpm *lpm, uint32_t ip, uint8_t depth)
 void
 rte_lpm_delete_all(struct rte_lpm *lpm)
 {
+	struct __rte_lpm *internal_lpm;
+
+	internal_lpm = container_of(lpm, struct __rte_lpm, lpm);
 	/* Zero rule information. */
-	memset(lpm->rule_info, 0, sizeof(lpm->rule_info));
+	memset(internal_lpm->rule_info, 0, sizeof(internal_lpm->rule_info));
 
 	/* Zero tbl24. */
 	memset(lpm->tbl24, 0, sizeof(lpm->tbl24));
 
 	/* Zero tbl8. */
 	memset(lpm->tbl8, 0, sizeof(lpm->tbl8[0])
-			* RTE_LPM_TBL8_GROUP_NUM_ENTRIES * lpm->number_tbl8s);
+			* RTE_LPM_TBL8_GROUP_NUM_ENTRIES
+			* internal_lpm->number_tbl8s);
 
 	/* Delete all rules form the rules table. */
-	memset(lpm->rules_tbl, 0, sizeof(lpm->rules_tbl[0]) * lpm->max_rules);
+	memset(internal_lpm->rules_tbl, 0,
+		sizeof(internal_lpm->rules_tbl[0]) * internal_lpm->max_rules);
 }
lib/librte_lpm/rte_lpm.h +0 -7
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
 /** @internal LPM structure. */
 struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**< Rule info table. */
-
 	/* LPM Tables. */
 	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
 			__rte_cache_aligned; /**< LPM tbl24 table. */
 	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
 };
 
 /** LPM RCU QSBR configuration structure. */
Signature · 1 line
2.17.1
#5 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 13 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
 lib/librte_lpm/rte_lpm.c | 152 +++++++++++++++++++++++----------------
 lib/librte_lpm/rte_lpm.h |   7 --
 2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 11 lines
lib/librte_lpm/rte_lpm.h +0 -3
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
 /** @internal LPM structure. */
 struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 10 lines
lib/librte_lpm/rte_lpm.h +0 -4
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**< Rule info table. */
-
 	/* LPM Tables. */
 	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
 			__rte_cache_aligned; /**< LPM tbl24 table. */
 	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
 };
 

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -0
 /** LPM RCU QSBR configuration structure. */
Signature · 1 line
2.17.1
#6 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 39 lines · Bruce Richardson
Quoted 13 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
  lib/librte_lpm/rte_lpm.c | 152 +++++++++++++++++++++++----------------
  lib/librte_lpm/rte_lpm.h |   7 --
  2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 11 lines
lib/librte_lpm/rte_lpm.h +0 -3
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
  /** @internal LPM structure. */
  struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 10 lines
lib/librte_lpm/rte_lpm.h +0 -4
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**< Rule info table. */
-
  	/* LPM Tables. */
  	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
  			__rte_cache_aligned; /**< LPM tbl24 table. */
  	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
  };
 

Since this changes the ABI, does it not need advance notice?

Quoted 4 lines

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -0
  /** LPM RCU QSBR configuration structure. */
Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
#7 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 54 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 11 lines · Bruce Richardson
Quoted 10 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
  lib/librte_lpm/rte_lpm.c | 152 +++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines
  lib/librte_lpm/rte_lpm.h |   7 --
  2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info {

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
  /** @internal LPM structure. */
  struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 11 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
-
  	/* LPM Tables. */
  	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
  			__rte_cache_aligned; /**< LPM tbl24 table. */
  	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
  };
 

Since this changes the ABI, does it not need advance notice?

Quoted 9 lines
Quoted 5 lines

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for next ABI update window.

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -1
  /** LPM RCU QSBR configuration structure. */
--

2.17.1

--
Regards,
Vladimir

#8 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 60 lines · Ruifeng Wang
Quoted 60 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 11 lines · Bruce Richardson
Quoted 10 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
  lib/librte_lpm/rte_lpm.c | 152 +++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines
  lib/librte_lpm/rte_lpm.h |   7 --
  2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info {

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
  /** @internal LPM structure. */
  struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 16 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
-
  	/* LPM Tables. */
  	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
  			__rte_cache_aligned; /**< LPM tbl24 table. */
  	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
  };
 

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Quoted 7 lines
Quoted 3 lines

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for next ABI update window.

Do you plan to extend? or is this just speculative?

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Quoted 10 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -1
  /** LPM RCU QSBR configuration structure. */
--

2.17.1

--
Regards,
Vladimir

#9 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines
---
  lib/librte_lpm/rte_lpm.c | 152

+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines
  lib/librte_lpm/rte_lpm.h |   7 --
  2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info {

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
  /** @internal LPM structure. */
  struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 11 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
-
  	/* LPM Tables. */
  	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
  			__rte_cache_aligned; /**< LPM tbl24 table. */
  	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
  };
 

Since this changes the ABI, does it not need advance notice?

Quoted 5 lines

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -1
  /** LPM RCU QSBR configuration structure. */
--

2.17.1

--
Regards,
Vladimir

#10 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 109 lines · Ruifeng Wang
Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines
---
  lib/librte_lpm/rte_lpm.c | 152

+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines
  lib/librte_lpm/rte_lpm.h |   7 --
  2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info {

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
  /** @internal LPM structure. */
  struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 11 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
-
  	/* LPM Tables. */
  	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
  			__rte_cache_aligned; /**< LPM tbl24 table. */
  	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
  };
 

Since this changes the ABI, does it not need advance notice?

Quoted 5 lines

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -1
  /** LPM RCU QSBR configuration structure. */
--

2.17.1

--
Regards,
Vladimir

#11 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hi Kevin,

We do need fields max_rules and number_tbl8s of struct rte_lpm, so
the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

Those fields are needed in Gatekeeper because we found a condition
in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

If there were a way to obtain the struct rte_lpm_config of a given
LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this
disscussion.

[ ]'s
Michel Machado

Quoted 129 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 109 lines · Ruifeng Wang
Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines
---
   lib/librte_lpm/rte_lpm.c | 152

+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines
   lib/librte_lpm/rte_lpm.h |   7 --
   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 139

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
   /** @internal LPM structure. */
   struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 11 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 140

Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
-
   	/* LPM Tables. */
   	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
   			__rte_cache_aligned; /**< LPM tbl24 table. */
   	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
   };
 

Since this changes the ABI, does it not need advance notice?

Quoted 5 lines

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_lpm/rte_lpm.h +0 -1
   /** LPM RCU QSBR configuration structure. */
--

2.17.1

--
Regards,
Vladimir

#12 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

Quoted 148 lines · Michel Machado

Hi Kevin,

   We do need fields max_rules and number_tbl8s of struct rte_lpm, so
the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

   Those fields are needed in Gatekeeper because we found a condition
in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

   If there were a way to obtain the struct rte_lpm_config of a given
LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

   PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this
disscussion.

[ ]'s
Michel Machado

Quoted 130 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 109 lines · Ruifeng Wang
Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines

---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --

   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 139

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
    /** @internal LPM structure. */
    struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm. */
-    uint32_t number_tbl8s; /**< Number of tbl8s. */
-    struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 9 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -1
-
        /* LPM Tables. */

       struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] __rte_cache_aligned; /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ -    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */ };

Quoted 7 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */

Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
Signature · 2 lines
Regards,
Vladimir
#13 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 3 lines · Vladimir

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

Consider this simple example, we need to add the following two
prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

We minimize the need of replacing a LPM table by allocating LPM
tables with the double of what we need (see example here https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698bfd06ad606674f1e07/lua/examples/policy.lua#L172-L183), but the code must be ready for unexpected needs that may arise in production.

Quoted 147 lines · Michel Machado
Quoted 144 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

    If there were a way to obtain the struct rte_lpm_config of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

    PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this disscussion.

[ ]'s
Michel Machado

Quoted 130 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 109 lines · Ruifeng Wang
Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines

---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --

   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 139

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
    /** @internal LPM structure. */
    struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm. */
-    uint32_t number_tbl8s; /**< Number of tbl8s. */
-    struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 9 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -1
-
        /* LPM Tables. */

       struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] __rte_cache_aligned; /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ -    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */ };

Quoted 7 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */

Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
#14 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 7 lines · Michel Machado
Quoted 3 lines · Vladimir

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

   Consider this simple example, we need to add the following two
prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 4 lines

   We minimize the need of replacing a LPM table by allocating LPM
tables with the double of what we need (see example here https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698bfd06ad606674f1e07/lua/examples/policy.lua#L172-L183), but the code must be ready for unexpected needs that may arise in production.

Usually, the table is initialized with a large enough number of entries, enough to add a possible number of routes. One tbl8 group takes up 1Kb of memory which is nothing comparing to the size of tbl24 which is 64Mb.

P.S. consider using rte_fib library, it has a number of advantages over LPM. You can replace the loop in __lookup_fib_bulk() with a bulk lookup call and this will probably increase the speed.

Quoted 147 lines
Quoted 147 lines · Michel Machado
Quoted 144 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

    If there were a way to obtain the struct rte_lpm_config of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

    PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this disscussion.

[ ]'s
Michel Machado

Quoted 130 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 109 lines · Ruifeng Wang
Quoted 76 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 64 lines · Ruifeng Wang
Quoted 64 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines

---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --

   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 7 lines

lib/librte_lpm/rte_lpm.h struct rte_lpm_rule_info { · line 139

Quoted 7 lines
lib/librte_lpm/rte_lpm.h +0 -5
    /** @internal LPM structure. */
    struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm. */
-    uint32_t number_tbl8s; /**< Number of tbl8s. */
-    struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 9 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -1
-
        /* LPM Tables. */

       struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] __rte_cache_aligned; /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ -    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */ };

Quoted 7 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */

Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
Signature · 2 lines
Regards,
Vladimir
#15 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 11 lines · Vladimir
Quoted 6 lines · Michel Machado
Quoted 3 lines · Vladimir

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

    Consider this simple example, we need to add the following two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

Yes.

Quoted 2 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Our code already deals with synchronization.

Quoted 4 lines
Quoted 2 lines

    We minimize the need of replacing a LPM table by allocating LPM tables with the double of what we need (see example here https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698bfd06ad606674f1e07/lua/examples/policy.lua#L172-L183), but the code must be ready for unexpected needs that may arise in production.

Usually, the table is initialized with a large enough number of entries, enough to add a possible number of routes. One tbl8 group takes up 1Kb of memory which is nothing comparing to the size of tbl24 which is 64Mb.

When the prefixes come from BGP, initializing a large enough table
is fine. But when prefixes come from threat intelligence, the number of prefixes can vary wildly and the number of prefixes above 24 bits are way more common.

Quoted 1 line

P.S. consider using rte_fib library, it has a number of advantages over LPM. You can replace the loop in __lookup_fib_bulk() with a bulk lookup call and this will probably increase the speed.

I'm not aware of the rte_fib library. The only documentation that I
found on Google was https://doc.dpdk.org/api/rte__fib_8h.html and it just says "FIB (Forwarding information base) implementation for IPv4 Longest Prefix Match".

Quoted 149 lines
Quoted 148 lines
Quoted 148 lines · Michel Machado
Quoted 145 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

    If there were a way to obtain the struct rte_lpm_config of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

    PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this disscussion.

[ ]'s
Michel Machado

Quoted 131 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 110 lines · Ruifeng Wang
Quoted 77 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 65 lines · Ruifeng Wang
Quoted 65 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines

---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --

   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 8 lines
Quoted 8 lines
lib/librte_lpm/rte_lpm.h +0 -2
    /** @internal LPM structure. */
    struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the 

lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm. */ -    uint32_t number_tbl8s; /**< Number of tbl8s. */
-    struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 9 lines
Quoted 8 lines

-
       /* LPM Tables. */
       struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] __rte_cache_aligned; /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ -    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */ };

Quoted 7 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */

Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
#16 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 11 lines · Michel Machado
Quoted 10 lines · Vladimir
Quoted 6 lines · Michel Machado
Quoted 3 lines · Vladimir

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

    Consider this simple example, we need to add the following two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Quoted 8 lines
Quoted 1 line

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 2 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

   Our code already deals with synchronization.

OK, so my suggestion here would be to add new routes to the shadow copy of the lpm, and if it returns -ENOSPC, than create a new LPM with double amount of tbl8's and add all the routes to it. Then switch the active-shadow LPM pointers. In this case you'll always add a bulk of routes atomically.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

    We minimize the need of replacing a LPM table by allocating LPM tables with the double of what we need (see example here https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698bfd06ad606674f1e07/lua/examples/policy.lua#L172-L183), but the code must be ready for unexpected needs that may arise in production.

Usually, the table is initialized with a large enough number of entries, enough to add a possible number of routes. One tbl8 group takes up 1Kb of memory which is nothing comparing to the size of tbl24 which is 64Mb.

Quoted 7 lines

   When the prefixes come from BGP, initializing a large enough table
is fine. But when prefixes come from threat intelligence, the number of prefixes can vary wildly and the number of prefixes above 24 bits are way more common.

Quoted 1 line

P.S. consider using rte_fib library, it has a number of advantages over LPM. You can replace the loop in __lookup_fib_bulk() with a bulk lookup call and this will probably increase the speed.

   I'm not aware of the rte_fib library. The only documentation that I
found on Google was https://doc.dpdk.org/api/rte__fib_8h.html and it just says "FIB (Forwarding information base) implementation for IPv4 Longest Prefix Match".

That's true, I'm going to add programmer's guide soon. Although the fib API is very similar to existing LPM.

Quoted 152 lines
Quoted 152 lines
Quoted 151 lines
Quoted 151 lines · Michel Machado
Quoted 147 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

    If there were a way to obtain the struct rte_lpm_config of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db26a78115cb8c8f). Thus, an IPv4 and IPv6 solution would be best.

    PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this disscussion.

[ ]'s
Michel Machado

Quoted 133 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/[email protected]/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]
https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c#L235-L248

Quoted 111 lines · Ruifeng Wang
Quoted 78 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin, Vladimir <[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 66 lines · Ruifeng Wang
Quoted 66 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 6 lines · Bruce Richardson
Quoted 5 lines · Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

Quoted 6 lines
Quoted 6 lines

---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 10 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --

   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 6 lines
lib/librte_lpm/rte_lpm.h +0 -0
index 03da2d37e..112d96f37 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
Quoted 9 lines
Quoted 9 lines
lib/librte_lpm/rte_lpm.h +0 -2
    /** @internal LPM structure. */
    struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the 

lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm. */ -    uint32_t number_tbl8s; /**< Number of tbl8s. */ -    struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**<

Rule info table. */

Quoted 9 lines
Quoted 8 lines

-
       /* LPM Tables. */
       struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES] __rte_cache_aligned; /**< LPM tbl24 table. */ struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */ -    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */ };

Quoted 7 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup() which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 7 lines
Quoted 3 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 8 lines

A quick scan and there seems to be several projects using some of these members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Not sure how much notice they'd need or if they update DPDK much, but I think it's worth having a closer look as to how they use lpm and what the impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 11 lines
Quoted 11 lines

Thanks.
Ruifeng

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */

Signature · 1 line
2.17.1
Signature · 2 lines
Regards,
Vladimir
Signature · 2 lines
Regards,
Vladimir
#17 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

<snip>

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines · Michel Machado
Quoted 6 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

    Consider this simple example, we need to add the following two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

max_rules and number_tbl8s in 'struct rte_lpm' contain the config information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

Quoted 14 lines
Quoted 14 lines
Quoted 3 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy.
Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

Quoted 57 lines

OK, so my suggestion here would be to add new routes to the shadow copy of the lpm, and if it returns -ENOSPC, than create a new LPM with double amount of tbl8's and add all the routes to it. Then switch the active-shadow LPM pointers. In this case you'll always add a bulk of routes atomically.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

    We minimize the need of replacing a LPM table by allocating LPM tables with the double of what we need (see example here

https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698

Quoted 15 lines
Quoted 9 lines
Quoted 4 lines

bfd06ad606674f1e07/lua/examples/policy.lua#L172-L183), but the code must be ready for unexpected needs that may arise in production.

Usually, the table is initialized with a large enough number of entries, enough to add a possible number of routes. One tbl8 group takes up 1Kb of memory which is nothing comparing to the size of tbl24 which is 64Mb.

   When the prefixes come from BGP, initializing a large enough table
is fine. But when prefixes come from threat intelligence, the number of prefixes can vary wildly and the number of prefixes above 24 bits are way more common.

Quoted 8 lines
Quoted 3 lines

P.S. consider using rte_fib library, it has a number of advantages over LPM. You can replace the loop in __lookup_fib_bulk() with a bulk lookup call and this will probably increase the speed.

   I'm not aware of the rte_fib library. The only documentation that
I found on Google was https://doc.dpdk.org/api/rte__fib_8h.html and it just says "FIB (Forwarding information base) implementation for IPv4 Longest Prefix Match".

That's true, I'm going to add programmer's guide soon. Although the fib API is very similar to existing LPM.

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines · Michel Machado
Quoted 16 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

    If there were a way to obtain the struct rte_lpm_config of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db
26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API). But, is there a possibility to store that info in the application as that data was passed to rte_lpm from the application?

Quoted 170 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

Thus, an IPv4 and IPv6 solution would be best.

    PS: I've added Qiaobin Fu, another Gatekeeper maintainer, to this disscussion.

[ ]'s
Michel Machado

Quoted 2 lines · Kevin Traynor

Hi Gatekeeper maintainers (I think),

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

fyi - there is a proposal to remove some members of a struct in DPDK LPM API that Gatekeeper is using [1]. It would be only from DPDK 20.11 but as it's an LTS I guess it would probably hit Debian in a few months.

The full thread is here:
http://inbox.dpdk.org/dev/20200907081518.46350-1-

ruifeng.wang@arm

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

.com/

Maybe you can take a look and tell us if they are needed in Gatekeeper or you can workaround it?

thanks,
Kevin.

[1]

https://github.com/AltraMayor/gatekeeper/blob/master/gt/lua_lpm.c

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

#L235-L248

Quoted 5 lines · Ruifeng Wang
Quoted 5 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Wednesday, September 30, 2020 4:46 PM
To: Ruifeng Wang <[email protected]>; Medvedkin,

Vladimir

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

<[email protected]>; Bruce Richardson <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 14 lines · Ruifeng Wang
Quoted 14 lines

-----Original Message-----
From: Medvedkin, Vladimir <[email protected]>
Sent: Wednesday, September 16, 2020 12:28 AM
To: Bruce Richardson <[email protected]>; Ruifeng Wang <[email protected]>
Cc: [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH 2/2] lpm: hide internal data

Hi Ruifeng,

Quoted 1 line · Bruce Richardson

On Mon, Sep 07, 2020 at 04:15:17PM +0800, Ruifeng Wang

Quoted 6 lines · wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Fields except tbl24 and tbl8 in rte_lpm structure have no
need to be exposed to the user.
Hide the unneeded exposure of structure fields for better
ABI maintainability.

Suggested-by: David Marchand

<[email protected]>

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
Quoted 5 lines

Signed-off-by: Ruifeng Wang <[email protected]>
Reviewed-by: Phil Yang <[email protected]>
---
   lib/librte_lpm/rte_lpm.c | 152
+++++++++++++++++++++++---------------

-

Quoted 11 lines
Quoted 3 lines

   lib/librte_lpm/rte_lpm.h |   7 --
   2 files changed, 91 insertions(+), 68 deletions(-)

<snip>

Quoted 7 lines

diff --git a/lib/librte_lpm/rte_lpm.h
b/lib/librte_lpm/rte_lpm.h index 03da2d37e..112d96f37
100644
--- a/lib/librte_lpm/rte_lpm.h
+++ b/lib/librte_lpm/rte_lpm.h
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

   /** @internal LPM structure. */
   struct rte_lpm {
-    /* LPM metadata. */
-    char name[RTE_LPM_NAMESIZE];        /**< Name of the
lpm. */
-    uint32_t max_rules; /**< Max. balanced rules per lpm.
*/
-    uint32_t number_tbl8s; /**< Number of tbl8s. */
-    struct rte_lpm_rule_info

rule_info[RTE_LPM_MAX_DEPTH];

Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 62 lines
Quoted 26 lines
Quoted 26 lines
Quoted 26 lines
Quoted 1 line
Quoted 1 line

/**<

Rule info table. */

Quoted 12 lines
Quoted 11 lines

-
       /* LPM Tables. */
       struct rte_lpm_tbl_entry
tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
               __rte_cache_aligned; /**< LPM tbl24 table.
*/
       struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table.
*/
-    struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
   };

Quoted 8 lines

Since this changes the ABI, does it not need advance notice?

[Basically the return value point from rte_lpm_create() will be different, and that return value could be used by rte_lpm_lookup()
which as a static inline function will be in the binary and using the old structure offsets.]

Agree with Bruce, this patch breaks ABI, so it can't be accepted without prior notice.

Quoted 8 lines
Quoted 4 lines

So if the change wants to happen in 20.11, a deprecation notice should have been added in 20.08.
I should have added a deprecation notice. This change will have to wait for

next ABI update window.

Quoted 1 line

Do you plan to extend? or is this just speculative?

It is speculative.

Quoted 7 lines

A quick scan and there seems to be several projects using some of these
members that you are proposing to hide. e.g. BESS, NFF-Go, DPVS, gatekeeper. I didn't look at the details to see if they are really needed.

Quoted 5 lines

Not sure how much notice they'd need or if they update DPDK much, but I
think it's worth having a closer look as to how they use lpm and what the
impact to them is.

Checked the projects listed above. BESS, NFF-Go and DPVS don't access the members to be hided.
They will not be impacted by this patch.
But Gatekeeper accesses the rte_lpm internal members that to be hided. Its compilation will be broken with this patch.

Quoted 8 lines
Quoted 8 lines

Thanks.
Ruifeng

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

   /** LPM RCU QSBR configuration structure. */
--
2.17.1

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

--
Regards,
Vladimir

--
Regards,
Vladimir

#18 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 7 lines · Honnappa Nagarahalli
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Michel Machado
Quoted 6 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

    Consider this simple example, we need to add the following two
prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

max_rules and number_tbl8s in 'struct rte_lpm' contain the config information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

We are aware that those fields hold the config information not a
status of the LPM table.

Before updating a LPM table that holds network prefixes derived from
threat intelligence, we compute the minimum values for max_rules and number_tbl8s. Here is an example of how we do it: https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698bfd06ad606674f1e07/lua/examples/policy.lua#L135-L166

Once these minimum values are available, we get the parameters of
the LPM table to be updated and check if we can update it, or have to recreate it.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy.
Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 2 lines
Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

The way the code is structured, this would require a significant
rewrite because the code assumes that it will succeed since the capacity of the LPM tables was already checked.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines · Michel Machado
Quoted 16 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct
rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a
condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

    If there were a way to obtain the struct rte_lpm_config of a
given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db
26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API). But, is there a possibility to store that info in the application as that data was passed to rte_lpm from the application?

A suggestion for what this API could look like:

void rte_lpm_get_config(const struct rte_lpm *lpm, struct rte_lpm_config *config); void rte_lpm6_get_config(const struct rte_lpm6 *lpm, struct rte_lpm6_config *config);

If the final choice is for not supporting a way to retrieve the
config information on the API, we'll look for a place to keep a copy of the parameters in our code.

#19 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

<snip>

Quoted 87 lines · Honnappa Nagarahalli
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Michel Machado
Quoted 6 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

    Consider this simple example, we need to add the following
two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

max_rules and number_tbl8s in 'struct rte_lpm' contain the config

information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

We are aware that those fields hold the config information not a status of
the LPM table.

Before updating a LPM table that holds network prefixes derived from
threat intelligence, we compute the minimum values for max_rules and number_tbl8s. Here is an example of how we do it:
https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698
bfd06ad606674f1e07/lua/examples/policy.lua#L135-L166

Once these minimum values are available, we get the parameters of the
LPM table to be updated and check if we can update it, or have to recreate it.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 2 lines
Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to

revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

The way the code is structured, this would require a significant rewrite
because the code assumes that it will succeed since the capacity of the LPM tables was already checked.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines · Michel Machado
Quoted 16 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct
rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a
condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

    If there were a way to obtain the struct rte_lpm_config of
a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db

Quoted 2 lines
Quoted 1 line

26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that

returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API).

Quoted 1 line

But, is there a possibility to store that info in the application as that data

was passed to rte_lpm from the application?

A suggestion for what this API could look like:

Quoted 7 lines

void rte_lpm_get_config(const struct rte_lpm *lpm, struct rte_lpm_config *config); void rte_lpm6_get_config(const struct rte_lpm6 *lpm, struct rte_lpm6_config *config);

If the final choice is for not supporting a way to retrieve the config
information on the API, we'll look for a place to keep a copy of the parameters in our code.

IMO, this is not a performance critical path and it is not a difficult solution to store these values in the application. My suggestion is to skip adding the API and store the values in the application. Vladimir, what's your opinion?

#20 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hello,

Quoted 16 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Honnappa Nagarahalli
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines · Michel Machado
Quoted 12 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

    Consider this simple example, we need to add the following
two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

max_rules and number_tbl8s in 'struct rte_lpm' contain the config

information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

Thanks Honnappa, agree, these two fields are read only after LPM initialization, I confused them with rte_fib's "rsvd_tbl8s" and "cur_tbl8s", so there is no need to read them directly from LPM after initialization. I'd suggest just keeping them as external variables outside of the LPM library (in kind of a global configuration I suppose?).

Quoted 72 lines
Quoted 72 lines

We are aware that those fields hold the config information not a status of
the LPM table.

Before updating a LPM table that holds network prefixes derived from
threat intelligence, we compute the minimum values for max_rules and number_tbl8s. Here is an example of how we do it:
https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698
bfd06ad606674f1e07/lua/examples/policy.lua#L135-L166

Once these minimum values are available, we get the parameters of the
LPM table to be updated and check if we can update it, or have to recreate it.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 2 lines
Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to

revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

The way the code is structured, this would require a significant rewrite
because the code assumes that it will succeed since the capacity of the LPM tables was already checked.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines · Michel Machado
Quoted 16 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct
rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock DPDK.

    Those fields are needed in Gatekeeper because we found a
condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy changes. To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries, and compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM table.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

    If there were a way to obtain the struct rte_lpm_config of
a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db

Quoted 2 lines
Quoted 1 line

26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that

returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API).

Quoted 1 line

But, is there a possibility to store that info in the application as that data

was passed to rte_lpm from the application?

A suggestion for what this API could look like:

void rte_lpm_get_config(const struct rte_lpm *lpm, struct rte_lpm_config *config); void rte_lpm6_get_config(const struct rte_lpm6 *lpm, struct rte_lpm6_config *config);

Quoted 5 lines
Quoted 3 lines

If the final choice is for not supporting a way to retrieve the config
information on the API, we'll look for a place to keep a copy of the parameters in our code.

IMO, this is not a performance critical path and it is not a difficult solution to store these values in the application. My suggestion is to skip adding the API and store the values in the application. Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Quoted 1 line
Signature · 2 lines
Regards,
Vladimir
#21 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

<snip>

Quoted 116 lines

Hello,

Quoted 16 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Honnappa Nagarahalli
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines · Michel Machado
Quoted 12 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

    Consider this simple example, we need to add the following
two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

max_rules and number_tbl8s in 'struct rte_lpm' contain the config

information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

Thanks Honnappa, agree, these two fields are read only after LPM initialization, I confused them with rte_fib's "rsvd_tbl8s" and "cur_tbl8s", so there is no need to read them directly from LPM after initialization. I'd suggest just keeping them as external variables outside of the LPM library (in kind of a global configuration I suppose?).

Quoted 8 lines
Quoted 8 lines

We are aware that those fields hold the config information not a
status of the LPM table.

Before updating a LPM table that holds network prefixes derived
from threat intelligence, we compute the minimum values for max_rules and number_tbl8s. Here is an example of how we do it:

https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698

Quoted 4 lines
Quoted 4 lines

bfd06ad606674f1e07/lua/examples/policy.lua#L135-L166

Once these minimum values are available, we get the parameters
of the LPM table to be updated and check if we can update it, or have to

recreate it.

Quoted 24 lines
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 3 lines
Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to

revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

The way the code is structured, this would require a significant
rewrite because the code assumes that it will succeed since the capacity of the LPM tables was already checked.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Michel Machado
Quoted 6 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct
rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock

DPDK.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

    Those fields are needed in Gatekeeper because we found a
condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy

changes.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries,

and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM

table.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

    If there were a way to obtain the struct rte_lpm_config
of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db

Quoted 18 lines
Quoted 18 lines
Quoted 3 lines
Quoted 1 line

26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that

returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API).

Quoted 2 lines

But, is there a possibility to store that info in the application as that data

was passed to rte_lpm from the application?

A suggestion for what this API could look like:

void rte_lpm_get_config(const struct rte_lpm *lpm, struct rte_lpm_config *config); void rte_lpm6_get_config(const struct rte_lpm6 *lpm, struct rte_lpm6_config *config);

If the final choice is for not supporting a way to retrieve the
config information on the API, we'll look for a place to keep a copy of the parameters in our code.

Quoted 6 lines
Quoted 1 line

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 1 line

Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

Quoted 6 lines
Quoted 2 lines

--
Regards,
Vladimir

#22 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 117 lines · Honnappa Nagarahalli

<snip>

Quoted 116 lines

Hello,

Quoted 16 lines · Honnappa Nagarahalli

<snip>

Quoted 15 lines · Honnappa Nagarahalli
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines · Michel Machado
Quoted 12 lines · Vladimir
Quoted 4 lines

Hi Michel,

Could you please describe a condition when LPM gets inconsistent? As I can see if there is no free tbl8 it will return -ENOSPC.

    Consider this simple example, we need to add the following
two prefixes with different next hops: 10.99.0.0/16, 18.99.99.128/25. If the LPM table is out of tbl8s, the second prefix is not added and Gatekeeper will make decisions in violation of the policy. The data structure of the LPM table is consistent, but its content inconsistent with the policy.

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

max_rules and number_tbl8s in 'struct rte_lpm' contain the config

information. These 2 fields do not change based on the routes added and do not indicate the amount of space left. So, you cannot use this information to decide if there is enough space to add more routes.

Thanks Honnappa, agree, these two fields are read only after LPM initialization, I confused them with rte_fib's "rsvd_tbl8s" and "cur_tbl8s", so there is no need to read them directly from LPM after initialization. I'd suggest just keeping them as external variables outside of the LPM library (in kind of a global configuration I suppose?).

Quoted 8 lines
Quoted 8 lines

We are aware that those fields hold the config information not a
status of the LPM table.

Before updating a LPM table that holds network prefixes derived
from threat intelligence, we compute the minimum values for max_rules and number_tbl8s. Here is an example of how we do it:

https://github.com/AltraMayor/gatekeeper/blob/95d1d6e8201861a0d0c698

Quoted 4 lines
Quoted 4 lines

bfd06ad606674f1e07/lua/examples/policy.lua#L135-L166

Once these minimum values are available, we get the parameters
of the LPM table to be updated and check if we can update it, or have to

recreate it.

Quoted 24 lines
Quoted 24 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines

Aha, thanks. So do I understand correctly that you need to add a set of routes atomically (either the entire set is installed or nothing)?

   Yes.

Quoted 7 lines

If so, then I would suggest having 2 lpm and switching them atomically after a successful addition. As for now, even if you have enough tbl8's, routes are installed non atomically, i.e. there will be a time gap between adding two routes, so in this time interval the table will be inconsistent with the policy. Also, if new lpm algorithms are added to the DPDK, they won't have such a thing as tbl8.

Quoted 3 lines
Quoted 1 line
Quoted 1 line

   Our code already deals with synchronization.

If the application code already deals with synchronization, is it possible to

revert back (i.e. delete the routes that got added so far) when the addition of the route-set fails?

The way the code is structured, this would require a significant
rewrite because the code assumes that it will succeed since the capacity of the LPM tables was already checked.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines · Michel Machado
Quoted 6 lines

Hi Kevin,

    We do need fields max_rules and number_tbl8s of struct
rte_lpm, so the removal would force us to have another patch to our local copy of DPDK. We'd rather avoid this new local patch because we wish to eventually be in sync with the stock

DPDK.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

    Those fields are needed in Gatekeeper because we found a
condition in an ongoing deployment in which the entries of some LPM tables may suddenly change a lot to reflect policy

changes.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

To avoid getting into a state in which the LPM table is inconsistent because it cannot fit all the new entries, we compute the needed parameters to support the new entries,

and

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

compare with the current parameters. If the current table doesn't fit everything, we have to replace it with a new LPM

table.

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

    If there were a way to obtain the struct rte_lpm_config
of a given LPM table, it would cleanly address our need. We have the same need in IPv6 and have a local patch to work around it (see

https://github.com/cjdoucette/dpdk/commit/3eaf124a781349b8ec8cd880db

Quoted 18 lines
Quoted 18 lines
Quoted 3 lines
Quoted 1 line

26a78115cb8c8f).

I do not see why such an API is not possible, we could add one API that

returns max_rules and number_tbl8s (essentially, the config that was passed to rte_lpm_create API).

Quoted 2 lines

But, is there a possibility to store that info in the application as that data

was passed to rte_lpm from the application?

A suggestion for what this API could look like:

void rte_lpm_get_config(const struct rte_lpm *lpm, struct rte_lpm_config *config); void rte_lpm6_get_config(const struct rte_lpm6 *lpm, struct rte_lpm6_config *config);

If the final choice is for not supporting a way to retrieve the
config information on the API, we'll look for a place to keep a copy of the parameters in our code.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 1 line

Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

Michel, I know it's a bit of churn so not zero effort, but is that solution workable for you? The change in DPDK would not be backported, so gatekeeper code would only need an update on updating to use DPDK 20.11.

Kevin.

P.S. As you are using DPDK 19.08, we should talk about DPDK LTS but let's leave that for another thread :-)

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

--
Regards,
Vladimir

#23 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

If the final choice is for not supporting a way to retrieve the
config information on the API, we'll look for a place to keep a copy of the parameters in our code.

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 1 line

Vladimir, what's your opinion?

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

Michel, I know it's a bit of churn so not zero effort, but is that solution workable for you? The change in DPDK would not be backported, so gatekeeper code would only need an update on updating to use DPDK 20.11.

It's workable.

Thank you for organizing this discussion, Kevin.

Quoted 2 lines

P.S. As you are using DPDK 19.08, we should talk about DPDK LTS but let's leave that for another thread :-)

Sure.

#24 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

In reply to Honnappa Nagarahalli
Quoted 7 lines · Honnappa Nagarahalli
Quoted 6 lines
Quoted 1 line

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 1 line

Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

I saw Honnappa and Kevin acks, are other techboard members aware and okay with this change?
Thanks.

Signature · 1 line
David Marchand
#25 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

19/10/2020 16:53, David Marchand:

Quoted 5 lines
Quoted 3 lines · Honnappa Nagarahalli
Quoted 3 lines
Quoted 1 line

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

I saw Honnappa and Kevin acks, are other techboard members aware and okay with this change?

This is an API change for better maintenance. I'm not sure the benefit is big enough,
but the cost for the applications is said to be workable. Better to do it now than later, so

(at the condition it is added in release notes)

What others think?

#26 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

Hi,

Quoted 19 lines · Thomas Monjalon

19/10/2020 16:53, David Marchand:

Quoted 5 lines
Quoted 3 lines · Honnappa Nagarahalli
Quoted 3 lines
Quoted 1 line

IMO, this is not a performance critical path and it is not a difficult solution to

store these values in the application. My suggestion is to skip adding the API and store the values in the application.

Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Vladimir, what's your opinion?

Agree. Global vars or part of a global configuration could be used here.

Thank you. I think we are fine to go ahead with merging this patch.

I saw Honnappa and Kevin acks, are other techboard members aware and okay with this change?

This is an API change for better maintenance. I'm not sure the benefit is big enough,
but the cost for the applications is said to be workable. Better to do it now than later, so

Quoted 5 lines

(at the condition it is added in release notes)

What others think?

This changes LGTM (agree with Thomas about release notes).

Quoted 1 line
Signature · 2 lines
Regards,
Vladimir
#27 lore raw

Re: [dpdk-dev] [PATCH 2/2] lpm: hide internal data

In reply to Ruifeng Wang

<snip>

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

Hi Ruifeng,

Quoted 1 line · Bruce Richardson

On Mon, Sep 07, 2020 at 04:15:17PM +0800, Ruifeng Wang wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

<snip>

#28 lore raw
In reply to Ruifeng Wang
Quoted 8 lines · Ruifeng Wang

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Quoted 7 lines

Ruifeng Wang (2):
lpm: fix free of data structure
lpm: hide internal data

 lib/librte_lpm/rte_lpm.c | 154 +++++++++++++++++++++++----------------
 lib/librte_lpm/rte_lpm.h |   7 --
 2 files changed, 92 insertions(+), 69 deletions(-)
Cc maintainers.

Those changes look good to me.
Opinions?

Thanks.

Signature · 1 line
David Marchand
Acked-by
#29 lore raw
Quoted 13 lines · David Marchand
Quoted 12 lines · Ruifeng Wang

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Ruifeng Wang (2):
lpm: fix free of data structure
lpm: hide internal data

Quoted 10 lines
Quoted 3 lines
 lib/librte_lpm/rte_lpm.c | 154 +++++++++++++++++++++++----------------
 lib/librte_lpm/rte_lpm.h |   7 --
 2 files changed, 92 insertions(+), 69 deletions(-)
Cc maintainers.

Those changes look good to me.
Opinions?

LGTM, Gatekeeper confirmed they can handle this change.

Quoted 2 lines

Thanks.

#30 lore raw

v2 cover LPM changes

In reply to Ruifeng Wang

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Ruifeng Wang (2):
lpm: fix free of data structure
lpm: hide internal data

 doc/guides/rel_notes/release_20_11.rst |   2 +
 lib/librte_lpm/rte_lpm.c               | 154 +++++++++++++++----------
 lib/librte_lpm/rte_lpm.h               |   7 --
 3 files changed, 94 insertions(+), 69 deletions(-)
Signature · 1 line
2.20.1
#31 lore raw

PATCH v2 1/2 lpm: fix free of data structure

The container structure should be freed instead of rte_lpm structure after wrapping rte_lpm into internal structure __rte_lpm.

Fixes 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
---
 lib/librte_lpm/rte_lpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/rte_lpm.c +1 -1
index 757436f49..51a0ae578 100644
@@ -268,7 +268,7 @@ rte_lpm_free(struct rte_lpm *lpm)
 		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
-	rte_free(lpm);
+	rte_free(internal_lpm);
 	rte_free(te);
 }
 
Signature · 1 line
2.20.1
#32 lore raw

PATCH v2 2/2 lpm: hide internal data

In reply to Ruifeng Wang

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
v2:
Added release notes.

 doc/guides/rel_notes/release_20_11.rst |   2 +
 lib/librte_lpm/rte_lpm.c               | 152 +++++++++++++++----------
 lib/librte_lpm/rte_lpm.h               |   7 --
 3 files changed, 93 insertions(+), 68 deletions(-)
doc/guides/rel_notes/release_20_11.rst +2 -0
index 0d45b5003..3b5034ce5 100644
@@ -602,6 +602,8 @@ ABI Changes
 
 * sched: Added new fields to ``struct rte_sched_subport_port_params``.
 
+* lpm: Removed fields other than ``tbl24`` and ``tbl8`` from the struct ``rte_lpm``.
+  The removed fields were made internal.
 
 Known Issues
 ------------
lib/librte_lpm/rte_lpm.c +91 -61

378 lines not on this page · raw message

lib/librte_lpm/rte_lpm.h +0 -7
index 5b3b7b5b5..9a0ac97ab 100644
@@ -132,17 +132,10 @@ struct rte_lpm_rule_info {
 
 /** @internal LPM structure. */
 struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**< Rule info table. */
-
 	/* LPM Tables. */
 	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
 			__rte_cache_aligned; /**< LPM tbl24 table. */
 	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
 };
 
 /** LPM RCU QSBR configuration structure. */
Signature · 1 line
2.20.1
#33 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] lpm: hide internal data

21/10/2020 05:02, Ruifeng Wang:

doc/guides/rel_notes/release_20_11.rst ABI Changes · line 609

Quoted 11 lines
doc/guides/rel_notes/release_20_11.rst +2 -0
@@ -602,6 +602,8 @@ ABI Changes
 
 * sched: Added new fields to ``struct rte_sched_subport_port_params``.
 
+* lpm: Removed fields other than ``tbl24`` and ``tbl8`` from the struct ``rte_lpm``.
+  The removed fields were made internal.
 
 Known Issues
 ------------

Can be changed on apply, but please note when adding a new paragraph, that you should add a new blank line, keeping 2 blank lines before the next section as it was before your patch.

PS: having this kind of minor comment means you are a regular contributor, so we expect perfect patches :)

Thanks

#34 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] lpm: hide internal data

Quoted 25 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 21, 2020 3:59 PM
To: Ruifeng Wang <[email protected]>
Cc: Bruce Richardson <[email protected]>; Vladimir Medvedkin <[email protected]>; [email protected]; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>; David Marchand <[email protected]>; Kevin Traynor <[email protected]>
Subject: Re: [PATCH v2 2/2] lpm: hide internal data

21/10/2020 05:02, Ruifeng Wang:

doc/guides/rel_notes/release_20_11.rst ABI Changes · line 605

Quoted 7 lines
doc/guides/rel_notes/release_20_11.rst +1 -0
@@ -602,6 +602,8 @@ ABI Changes
 
 * sched: Added new fields to ``struct rte_sched_subport_port_params``.
 
+* lpm: Removed fields other than ``tbl24`` and ``tbl8`` from the struct

``rte_lpm``.

doc/guides/rel_notes/release_20_11.rst ABI Changes · line 609

Quoted 4 lines
doc/guides/rel_notes/release_20_11.rst +1 -0
+  The removed fields were made internal.
 
 Known Issues
 ------------
Quoted 7 lines

Can be changed on apply, but please note when adding a new paragraph, that you should add a new blank line, keeping 2 blank lines before the next section as it was before your patch.

PS: having this kind of minor comment means you are a regular contributor, so we expect perfect patches :)

Sorry for the extra burden added to merge. Will pay more attention on format and other details.

Thanks.

Quoted 2 lines

Thanks

#35 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] lpm: hide internal data

In reply to Ruifeng Wang
Quoted 9 lines · Ruifeng Wang
lib/librte_lpm/rte_lpm.c +0 -1
index 51a0ae578..88d31df6d 100644
@@ -42,9 +42,17 @@ enum valid_flag {
 
 /** @internal LPM structure. */
 struct __rte_lpm {
-       /* LPM metadata. */

lib/librte_lpm/rte_lpm.c enum valid_flag { · line 54

Quoted 10 lines
lib/librte_lpm/rte_lpm.c +8 -0
+       /* Exposed LPM data. */
        struct rte_lpm lpm;
 
+       /* LPM metadata. */
+       char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
+       uint32_t max_rules; /**< Max. balanced rules per lpm. */
+       uint32_t number_tbl8s; /**< Number of tbl8s. */
+       /**< Rule info table. */
+       struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH];
+       struct rte_lpm_rule *rules_tbl; /**< LPM rules. */

- We hide the rules, is there a reason to keep struct rte_lpm_rule_info and struct rte_lpm_rule exposed?

- Rather than have translations lpm -> i_lpm, in many places of this library, we should translate only in the functions exposed to the user.
Besides, it is a bit hard to read between internal_lpm and i_lpm, I would adopt a single i_lpm convention for the whole file. I went and tried to do it (big search and replace + build tests, no runtime check though).
This results in:
https://github.com/david-marchand/dpdk/commit/4e61f0ce7cf2ac472565d3c6aa5bb78ffb8f70c9

What do you think?

Signature · 1 line
David Marchand
#36 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] lpm: hide internal data

Quoted 25 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, October 22, 2020 11:14 PM
To: Ruifeng Wang <[email protected]>
Cc: Bruce Richardson <[email protected]>; Vladimir Medvedkin <[email protected]>; dev <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>; Kevin Traynor <[email protected]>; [email protected]
Subject: Re: [PATCH v2 2/2] lpm: hide internal data

Quoted 12 lines · Ruifeng Wang
lib/librte_lpm/rte_lpm.c index renamed from lib/librte_lpm/rte_lpm.c +0 -0

51a0ae578..88d31df6d 100644

lib/librte_lpm/rte_lpm.c +1 -1
@@ -42,9 +42,17 @@ enum valid_flag {
 
 /** @internal LPM structure. */
 struct __rte_lpm {
-       /* LPM metadata. */
+       /* Exposed LPM data. */
        struct rte_lpm lpm;
 
Quoted 11 lines

lib/librte_lpm/rte_lpm.c enum valid_flag { · line 54

Quoted 7 lines
lib/librte_lpm/rte_lpm.c +7 -0
+       /* LPM metadata. */
+       char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
+       uint32_t max_rules; /**< Max. balanced rules per lpm. */
+       uint32_t number_tbl8s; /**< Number of tbl8s. */
+       /**< Rule info table. */
+       struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH];
+       struct rte_lpm_rule *rules_tbl; /**< LPM rules. */

- We hide the rules, is there a reason to keep struct rte_lpm_rule_info and struct rte_lpm_rule exposed?

These structs can be moved into rte_lpm.c and made internal too.

Quoted 10 lines

- Rather than have translations lpm -> i_lpm, in many places of this library, we should translate only in the functions exposed to the user. Besides, it is a bit hard to read between internal_lpm and i_lpm, I would adopt a single i_lpm convention for the whole file.
I went and tried to do it (big search and replace + build tests, no runtime check though).
This results in:
https://github.com/david-
marchand/dpdk/commit/4e61f0ce7cf2ac472565d3c6aa5bb78ffb8f70c9

Quoted 2 lines

What do you think?

I'm fine with the change. It looks good.
I checked unit test is passing.

Thanks.
/Ruifeng

Quoted 3 lines

--
David Marchand

#37 lore raw

Re: [dpdk-dev] [PATCH v2 2/2] lpm: hide internal data

Hello,

Quoted 36 lines · Ruifeng Wang
Quoted 25 lines

-----Original Message-----
From: David Marchand <[email protected]>
Sent: Thursday, October 22, 2020 11:14 PM
To: Ruifeng Wang <[email protected]>
Cc: Bruce Richardson <[email protected]>; Vladimir Medvedkin <[email protected]>; dev <[email protected]>; Honnappa Nagarahalli <[email protected]>; nd <[email protected]>; Kevin Traynor <[email protected]>; [email protected]
Subject: Re: [PATCH v2 2/2] lpm: hide internal data

Quoted 12 lines · Ruifeng Wang
lib/librte_lpm/rte_lpm.c index renamed from lib/librte_lpm/rte_lpm.c +0 -0

51a0ae578..88d31df6d 100644

lib/librte_lpm/rte_lpm.c +1 -1
@@ -42,9 +42,17 @@ enum valid_flag {
 
  /** @internal LPM structure. */
  struct __rte_lpm {
-       /* LPM metadata. */
+       /* Exposed LPM data. */
         struct rte_lpm lpm;
 
Quoted 11 lines

lib/librte_lpm/rte_lpm.c enum valid_flag { · line 54

Quoted 7 lines
lib/librte_lpm/rte_lpm.c +7 -0
+       /* LPM metadata. */
+       char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
+       uint32_t max_rules; /**< Max. balanced rules per lpm. */
+       uint32_t number_tbl8s; /**< Number of tbl8s. */
+       /**< Rule info table. */
+       struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH];
+       struct rte_lpm_rule *rules_tbl; /**< LPM rules. */

- We hide the rules, is there a reason to keep struct rte_lpm_rule_info and struct rte_lpm_rule exposed?

Quoted 1 line

These structs can be moved into rte_lpm.c and made internal too.

Agree, these structs are control plane related and could be moved from public struct.

Quoted 11 lines
Quoted 11 lines

- Rather than have translations lpm -> i_lpm, in many places of this library, we should translate only in the functions exposed to the user. Besides, it is a bit hard to read between internal_lpm and i_lpm, I would adopt a single i_lpm convention for the whole file.
I went and tried to do it (big search and replace + build tests, no runtime check though).
This results in:
https://github.com/david-
marchand/dpdk/commit/4e61f0ce7cf2ac472565d3c6aa5bb78ffb8f70c9

Quoted 5 lines
Quoted 2 lines

What do you think?

I'm fine with the change. It looks good.
I checked unit test is passing.

Also checked with testfib app with "-c -a" args, FIB and LPM lookup returns same values.

Quoted 6 lines

Thanks.
/Ruifeng

Quoted 3 lines

--
David Marchand

Signature · 2 lines
Regards,
Vladimir
#38 lore raw

v3 cover LPM changes

In reply to Ruifeng Wang

From Ruifeng Wang:

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Changelog since v2:
- hid now internal structures,
- changed code so that everything is done on internal representation of the lpm object and translation only happens at public API boundaries,

Signature · 13 lines
David Marchand

Ruifeng Wang (2):
  lpm: fix free of data structure
  lpm: hide internal data

 doc/guides/rel_notes/release_20_11.rst |   3 +
 lib/librte_lpm/rte_lpm.c               | 388 +++++++++++++------------
 lib/librte_lpm/rte_lpm.h               |  19 --
 3 files changed, 208 insertions(+), 202 deletions(-)

-- 
2.23.0
#39 lore raw

PATCH v3 1/2 lpm: fix free of data structure

From: Ruifeng Wang <[email protected]>

The container structure should be freed instead of rte_lpm structure after wrapping rte_lpm into internal structure __rte_lpm.

Fixes 8a9f8564e9f9 ("lpm: implement RCU rule reclamation")
---
 lib/librte_lpm/rte_lpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_lpm/rte_lpm.c +1 -1
index 757436f492..51a0ae5780 100644
@@ -268,7 +268,7 @@ rte_lpm_free(struct rte_lpm *lpm)
 		rte_rcu_qsbr_dq_delete(internal_lpm->dq);
 	rte_free(lpm->tbl8);
 	rte_free(lpm->rules_tbl);
-	rte_free(lpm);
+	rte_free(internal_lpm);
 	rte_free(te);
 }
 
Signature · 1 line
2.23.0
#40 lore raw

PATCH v3 2/2 lpm: hide internal data

In reply to David Marchand

From: Ruifeng Wang <[email protected]>

Fields except tbl24 and tbl8 in rte_lpm structure have no need to be exposed to the user.
Hide the unneeded exposure of structure fields for better ABI maintainability.

---
Changes since v2:
- hid rte_lpm_rule and rte_lpm_rule_info,
- used i_lpm as the preferred variable name,
- moved lpm <-> i_lpm at public API boundaries, all internal functions deal with __rte_lpm object,

---
 doc/guides/rel_notes/release_20_11.rst |   3 +
 lib/librte_lpm/rte_lpm.c               | 388 +++++++++++++------------
 lib/librte_lpm/rte_lpm.h               |  19 --
 3 files changed, 208 insertions(+), 202 deletions(-)
doc/guides/rel_notes/release_20_11.rst +3 -0
index d8ac359e51..dca8d41eb6 100644
@@ -606,6 +606,9 @@ ABI Changes
 
 * sched: Added new fields to ``struct rte_sched_subport_port_params``.
 
+* lpm: Removed fields other than ``tbl24`` and ``tbl8`` from the struct
+  ``rte_lpm``. The removed fields were made internal.
+
 
 Known Issues
 ------------
lib/librte_lpm/rte_lpm.c +205 -183

977 lines not on this page · raw message

lib/librte_lpm/rte_lpm.h +0 -19
index 5b3b7b5b58..1afe55cdcb 100644
@@ -118,31 +118,12 @@ struct rte_lpm_config {
 	int flags;               /**< This field is currently unused. */
 };
 
-/** @internal Rule structure. */
-struct rte_lpm_rule {
-	uint32_t ip; /**< Rule IP address. */
-	uint32_t next_hop; /**< Rule next hop. */
-};
-
-/** @internal Contains metadata about the rules table. */
-struct rte_lpm_rule_info {
-	uint32_t used_rules; /**< Used rules so far. */
-	uint32_t first_rule; /**< Indexes the first rule of a given depth. */
-};
-
 /** @internal LPM structure. */
 struct rte_lpm {
-	/* LPM metadata. */
-	char name[RTE_LPM_NAMESIZE];        /**< Name of the lpm. */
-	uint32_t max_rules; /**< Max. balanced rules per lpm. */
-	uint32_t number_tbl8s; /**< Number of tbl8s. */
-	struct rte_lpm_rule_info rule_info[RTE_LPM_MAX_DEPTH]; /**< Rule info table. */
-
 	/* LPM Tables. */
 	struct rte_lpm_tbl_entry tbl24[RTE_LPM_TBL24_NUM_ENTRIES]
 			__rte_cache_aligned; /**< LPM tbl24 table. */
 	struct rte_lpm_tbl_entry *tbl8; /**< LPM tbl8 table. */
-	struct rte_lpm_rule *rules_tbl; /**< LPM rules. */
 };
 
 /** LPM RCU QSBR configuration structure. */
Signature · 1 line
2.23.0
#41 lore raw
In reply to David Marchand
Quoted 9 lines · David Marchand

From Ruifeng Wang:

The rte_lpm structure is exported because lookup API is inlined. But most of the structure can be hidden.
Discussion at: http://patches.dpdk.org/patch/72403/
This patch set aimed to hide the rte_lpm structure as much as possible.

A data free issue was identified and fixed.

Series applied.
Thanks Ruifeng.

Signature · 1 line
David Marchand