IMO, this can be merged into 4/6.
> -----Original Message-----
> From: Ruifeng Wang <ruifeng.w...@arm.com>
> Sent: Thursday, July 11, 2019 10:09 PM
> To: vladimir.medved...@intel.com; bruce.richard...@intel.com
> Cc: dev@dpdk.org; Honnappa Nagarahalli <honnappa.nagaraha...@arm.com>;
> Gavin Hu (Arm Technology China) <gavin...@arm.com>; nd <n...@arm.com>;
> Ruifeng Wang (Arm Technology China) <ruifeng.w...@arm.com>
> Subject: [PATCH v5 5/6] lib/lpm: data update optimization for v1604
>
> The table entries were updated field by field. There were two issues:
> 1. bitwise operations are read-modify-write sequences and not atomic,
> nor efficient.
> 2. the above non-atomic operations causes entries out of synchronization
> and inconsistency.
> This patch combines the fields into a one-go 32bit entry update to avoid
> inconsistency and as a bonus save CPU cycles.
>
> Suggested-by: Gavin Hu <gavin...@arm.com>
> Signed-off-by: Ruifeng Wang <ruifeng.w...@arm.com>
> Reviewed-by: Gavin Hu <gavin...@arm.com>
> ---
> lib/librte_lpm/rte_lpm.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index
> d35d64448..d86248713 100644
> --- a/lib/librte_lpm/rte_lpm.c
> +++ b/lib/librte_lpm/rte_lpm.c
> @@ -1035,9 +1035,14 @@ add_depth_big_v1604(struct rte_lpm *lpm,
> uint32_t ip_masked, uint8_t depth,
>
> /* Set tbl8 entry. */
> for (i = tbl8_index; i < (tbl8_index + tbl8_range); i++) {
> - lpm->tbl8[i].depth = depth;
> - lpm->tbl8[i].next_hop = next_hop;
> - lpm->tbl8[i].valid = VALID;
> + struct rte_lpm_tbl_entry new_tbl8_entry = {
> + .valid = VALID,
> + .depth = depth,
> + .valid_group = lpm->tbl8[i].valid_group,
> + .next_hop = next_hop,
> + };
> + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry,
> + __ATOMIC_RELAXED);
> }
>
> /*
> @@ -1075,19 +1080,28 @@ add_depth_big_v1604(struct rte_lpm *lpm,
> uint32_t ip_masked, uint8_t depth,
>
> /* Populate new tbl8 with tbl24 value. */
> for (i = tbl8_group_start; i < tbl8_group_end; i++) {
> - lpm->tbl8[i].valid = VALID;
> - lpm->tbl8[i].depth = lpm->tbl24[tbl24_index].depth;
> - lpm->tbl8[i].next_hop =
> - lpm->tbl24[tbl24_index].next_hop;
> + struct rte_lpm_tbl_entry new_tbl8_entry = {
> + .valid = VALID,
> + .depth = lpm->tbl24[tbl24_index].depth,
> + .valid_group = lpm->tbl8[i].valid_group,
> + .next_hop = lpm-
> >tbl24[tbl24_index].next_hop,
> + };
> + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry,
> + __ATOMIC_RELAXED);
> }
>
> tbl8_index = tbl8_group_start + (ip_masked & 0xFF);
>
> /* Insert new rule into the tbl8 entry. */
> for (i = tbl8_index; i < tbl8_index + tbl8_range; i++) {
> - lpm->tbl8[i].valid = VALID;
> - lpm->tbl8[i].depth = depth;
> - lpm->tbl8[i].next_hop = next_hop;
> + struct rte_lpm_tbl_entry new_tbl8_entry = {
> + .valid = VALID,
> + .depth = depth,
> + .valid_group = lpm->tbl8[i].valid_group,
> + .next_hop = next_hop,
> + };
> + __atomic_store(&lpm->tbl8[i], &new_tbl8_entry,
> + __ATOMIC_RELAXED);
> }
>
> /*
> --
> 2.17.1