[PATCH v2] lib/hash: new feature adding existing key

2023-10-23 Thread Abdullah Ömer Yamaç
From: Abdullah Ömer Yamaç 

In some use cases inserting data with the same key shouldn't be
overwritten. We use a new flag in this patch to disable overwriting
data for the same key.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 
Cc: David Marchand 
---
 lib/hash/rte_cuckoo_hash.c | 10 +-
 lib/hash/rte_cuckoo_hash.h |  2 ++
 lib/hash/rte_hash.h|  4 
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 19b23f2a97..fe8f21bee4 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -32,7 +32,8 @@
   RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \
   RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \
   RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \
-  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)
+  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | \
+  
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
 
 #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET)\
for (CURRENT_BKT = START_BUCKET;  \
@@ -148,6 +149,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
unsigned int readwrite_concur_support = 0;
unsigned int writer_takes_lock = 0;
unsigned int no_free_on_del = 0;
+   unsigned int no_update_data = 0;
uint32_t *ext_bkt_to_free = NULL;
uint32_t *tbl_chng_cnt = NULL;
struct lcore_cache *local_free_slots = NULL;
@@ -216,6 +218,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
no_free_on_del = 1;
}
 
+   if (params->extra_flag & 
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
+   no_update_data = 1;
+
/* Store all keys and leave the first entry as a dummy entry for 
lookup_bulk */
if (use_local_cache)
/*
@@ -428,6 +433,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
h->ext_table_support = ext_table_support;
h->writer_takes_lock = writer_takes_lock;
h->no_free_on_del = no_free_on_del;
+   h->no_update_data = no_update_data;
h->readwrite_concur_lf_support = readwrite_concur_lf_support;
 
 #if defined(RTE_ARCH_X86)
@@ -707,6 +713,8 @@ search_and_update(const struct rte_hash *h, void *data, 
const void *key,
k = (struct rte_hash_key *) ((char *)keys +
bkt->key_idx[i] * h->key_entry_size);
if (rte_hash_cmp_eq(key, k->key, h) == 0) {
+   if (h->no_update_data == 1)
+   return -EINVAL;
/* The store to application data at *data
 * should not leak after the store to pdata
 * in the key store. i.e. pdata is the guard
diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h
index eb2644f74b..e8b7283ec2 100644
--- a/lib/hash/rte_cuckoo_hash.h
+++ b/lib/hash/rte_cuckoo_hash.h
@@ -193,6 +193,8 @@ struct rte_hash {
/**< If read-write concurrency support is enabled */
uint8_t ext_table_support; /**< Enable extendable bucket table */
uint8_t no_free_on_del;
+   /**< If update is prohibited on adding same key */
+   uint8_t no_update_data;
/**< If key index should be freed on calling rte_hash_del_xxx APIs.
 * If this is set, rte_hash_free_key_with_position must be called to
 * free the key index associated with the deleted entry.
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..ca5b4841d2 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -55,6 +55,10 @@ extern "C" {
  */
 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
 
+/** Flag to disable updating data of existing key
+ */
+#define RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY 0x40
+
 /**
  * The type of hash value of a key.
  * It should be a value of at least 32bit with fully random pattern.
-- 
2.34.1



[PATCH v2] lib/hash: new feature adding existing key

2023-10-23 Thread Abdullah Ömer Yamaç
In some use cases inserting data with the same key shouldn't be
overwritten. We use a new flag in this patch to disable overwriting
data for the same key.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 
Cc: David Marchand 
---
 lib/hash/rte_cuckoo_hash.c | 10 +-
 lib/hash/rte_cuckoo_hash.h |  2 ++
 lib/hash/rte_hash.h|  4 
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 19b23f2a97..fe8f21bee4 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -32,7 +32,8 @@
   RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \
   RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \
   RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \
-  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)
+  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | \
+  
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
 
 #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET)\
for (CURRENT_BKT = START_BUCKET;  \
@@ -148,6 +149,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
unsigned int readwrite_concur_support = 0;
unsigned int writer_takes_lock = 0;
unsigned int no_free_on_del = 0;
+   unsigned int no_update_data = 0;
uint32_t *ext_bkt_to_free = NULL;
uint32_t *tbl_chng_cnt = NULL;
struct lcore_cache *local_free_slots = NULL;
@@ -216,6 +218,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
no_free_on_del = 1;
}
 
+   if (params->extra_flag & 
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
+   no_update_data = 1;
+
/* Store all keys and leave the first entry as a dummy entry for 
lookup_bulk */
if (use_local_cache)
/*
@@ -428,6 +433,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
h->ext_table_support = ext_table_support;
h->writer_takes_lock = writer_takes_lock;
h->no_free_on_del = no_free_on_del;
+   h->no_update_data = no_update_data;
h->readwrite_concur_lf_support = readwrite_concur_lf_support;
 
 #if defined(RTE_ARCH_X86)
@@ -707,6 +713,8 @@ search_and_update(const struct rte_hash *h, void *data, 
const void *key,
k = (struct rte_hash_key *) ((char *)keys +
bkt->key_idx[i] * h->key_entry_size);
if (rte_hash_cmp_eq(key, k->key, h) == 0) {
+   if (h->no_update_data == 1)
+   return -EINVAL;
/* The store to application data at *data
 * should not leak after the store to pdata
 * in the key store. i.e. pdata is the guard
diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h
index eb2644f74b..e8b7283ec2 100644
--- a/lib/hash/rte_cuckoo_hash.h
+++ b/lib/hash/rte_cuckoo_hash.h
@@ -193,6 +193,8 @@ struct rte_hash {
/**< If read-write concurrency support is enabled */
uint8_t ext_table_support; /**< Enable extendable bucket table */
uint8_t no_free_on_del;
+   /**< If update is prohibited on adding same key */
+   uint8_t no_update_data;
/**< If key index should be freed on calling rte_hash_del_xxx APIs.
 * If this is set, rte_hash_free_key_with_position must be called to
 * free the key index associated with the deleted entry.
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..ca5b4841d2 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -55,6 +55,10 @@ extern "C" {
  */
 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
 
+/** Flag to disable updating data of existing key
+ */
+#define RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY 0x40
+
 /**
  * The type of hash value of a key.
  * It should be a value of at least 32bit with fully random pattern.
-- 
2.34.1



[PATCH] examples/distributor: fix syntax on single core rx and distributor

2022-06-20 Thread Abdullah Ömer Yamaç
This patch fixes the syntax error when using the single-core
for both rx and distributor functions.

Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core")
Cc: sta...@dpdk.org

Signed-off-by: Abdullah Ömer Yamaç 
---
Cc: david.h...@intel.com
---
 examples/distributor/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 02bf91f555..8995806b4e 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -261,8 +261,8 @@ lcore_rx(struct lcore_params *p)
  * packets are then send straight to the tx core.
  */
 #if 0
-   rte_distributor_process(d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pktsd,
+   rte_distributor_process(p->d, bufs, nb_rx);
+   const uint16_t nb_ret = rte_distributor_returned_pkts(p->d,
bufs, BURST_SIZE*2);
 
app_stats.rx.returned_pkts += nb_ret;
-- 
2.27.0



[PATCH] examples/distributor: update dynamic configuration

2022-06-21 Thread Abdullah Ömer Yamaç
In this patch,
* It is possible to switch the running mode of the distributor
using the command line argument.
* With "-c" parameter, you can run RX and Distributor
on the same core.
* Without "-c" parameter, you can run RX and Distributor
on the different core.
* Syntax error of the single RX and distributor core is fixed.
* When "-c" parameter is active, the wasted distributor core is
also deactivated in the main function.

Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core")
Cc: sta...@dpdk.org

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: david.h...@intel.com
---
 doc/guides/sample_app_ug/dist_app.rst |   3 +-
 examples/distributor/main.c   | 205 +++---
 2 files changed, 152 insertions(+), 56 deletions(-)

diff --git a/doc/guides/sample_app_ug/dist_app.rst 
b/doc/guides/sample_app_ug/dist_app.rst
index 3bd03905c3..5c80561187 100644
--- a/doc/guides/sample_app_ug/dist_app.rst
+++ b/doc/guides/sample_app_ug/dist_app.rst
@@ -42,11 +42,12 @@ Running the Application
 
..  code-block:: console
 
-   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK
+   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK 
[-c]
 
where,
 
*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+   *   -c: Combines the RX core with distribution core
 
 #. To run the application in linux environment with 10 lcores, 4 ports,
issue the command:
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 02bf91f555..6e98f78054 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -39,6 +39,7 @@ volatile uint8_t quit_signal_rx;
 volatile uint8_t quit_signal_dist;
 volatile uint8_t quit_signal_work;
 unsigned int power_lib_initialised;
+bool enable_lcore_rx_distributor;
 
 static volatile struct app_stats {
struct {
@@ -256,14 +257,82 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-/*
- * You can run the distributor on the rx core with this code. Returned
- * packets are then send straight to the tx core.
- */
-#if 0
-   rte_distributor_process(d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pktsd,
-   bufs, BURST_SIZE*2);
+   /*
+* Swap the following two lines if you want the rx traffic
+* to go directly to tx, no distribution.
+*/
+   struct rte_ring *out_ring = p->rx_dist_ring;
+   /* struct rte_ring *out_ring = p->dist_tx_ring; */
+
+   uint16_t sent = rte_ring_enqueue_burst(out_ring,
+   (void *)bufs, nb_rx, NULL);
+
+   app_stats.rx.enqueued_pkts += sent;
+   if (unlikely(sent < nb_rx)) {
+   app_stats.rx.enqdrop_pkts +=  nb_rx - sent;
+   RTE_LOG_DP(DEBUG, DISTRAPP,
+   "%s:Packet loss due to full ring\n", __func__);
+   while (sent < nb_rx)
+   rte_pktmbuf_free(bufs[sent++]);
+   }
+   if (++port == nb_ports)
+   port = 0;
+   }
+   if (power_lib_initialised)
+   rte_power_exit(rte_lcore_id());
+   /* set worker & tx threads quit flag */
+   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   quit_signal = 1;
+   return 0;
+}
+
+static int
+lcore_rx_and_distributor(struct lcore_params *p)
+{
+   struct rte_distributor *d = p->d;
+   const uint16_t nb_ports = rte_eth_dev_count_avail();
+   const int socket_id = rte_socket_id();
+   uint16_t port;
+   struct rte_mbuf *bufs[BURST_SIZE*2];
+
+   RTE_ETH_FOREACH_DEV(port) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0)
+   continue;
+
+   if (rte_eth_dev_socket_id(port) > 0 &&
+   rte_eth_dev_socket_id(port) != socket_id)
+   printf("WARNING, port %u is on remote NUMA node to "
+   "RX thread.\n\tPerformance will not "
+   "be optimal.\n", port);
+   }
+
+   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   port = 0;
+   while (!quit_signal_rx) {
+
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0) {
+   if (++port == nb_ports)
+   port = 0;
+   continue;
+   }
+   const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs,
+   BURST_SIZE);
+   

[PATCH] examples/distributor: update dynamic configuration

2022-06-21 Thread Abdullah Ömer Yamaç
In this patch,
* It is possible to switch the running mode of the distributor
using the command line argument.
* With "-c" parameter, you can run RX and Distributor
on the same core.
* Without "-c" parameter, you can run RX and Distributor
on the different core.
* Syntax error of the single RX and distributor core is fixed.
* When "-c" parameter is active, the wasted distributor core is
also deactivated in the main function.

Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core")
Cc: sta...@dpdk.org

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: david.h...@intel.com
---
 doc/guides/sample_app_ug/dist_app.rst |   3 +-
 examples/distributor/main.c   | 205 +++---
 2 files changed, 152 insertions(+), 56 deletions(-)

diff --git a/doc/guides/sample_app_ug/dist_app.rst 
b/doc/guides/sample_app_ug/dist_app.rst
index 3bd03905c3..5c80561187 100644
--- a/doc/guides/sample_app_ug/dist_app.rst
+++ b/doc/guides/sample_app_ug/dist_app.rst
@@ -42,11 +42,12 @@ Running the Application
 
..  code-block:: console
 
-   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK
+   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK 
[-c]
 
where,
 
*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+   *   -c: Combines the RX core with distribution core
 
 #. To run the application in linux environment with 10 lcores, 4 ports,
issue the command:
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 02bf91f555..40b30021ca 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -39,6 +39,7 @@ volatile uint8_t quit_signal_rx;
 volatile uint8_t quit_signal_dist;
 volatile uint8_t quit_signal_work;
 unsigned int power_lib_initialised;
+bool enable_lcore_rx_distributor;
 
 static volatile struct app_stats {
struct {
@@ -256,14 +257,82 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-/*
- * You can run the distributor on the rx core with this code. Returned
- * packets are then send straight to the tx core.
- */
-#if 0
-   rte_distributor_process(d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pktsd,
-   bufs, BURST_SIZE*2);
+   /*
+* Swap the following two lines if you want the rx traffic
+* to go directly to tx, no distribution.
+*/
+   struct rte_ring *out_ring = p->rx_dist_ring;
+   /* struct rte_ring *out_ring = p->dist_tx_ring; */
+
+   uint16_t sent = rte_ring_enqueue_burst(out_ring,
+   (void *)bufs, nb_rx, NULL);
+
+   app_stats.rx.enqueued_pkts += sent;
+   if (unlikely(sent < nb_rx)) {
+   app_stats.rx.enqdrop_pkts +=  nb_rx - sent;
+   RTE_LOG_DP(DEBUG, DISTRAPP,
+   "%s:Packet loss due to full ring\n", __func__);
+   while (sent < nb_rx)
+   rte_pktmbuf_free(bufs[sent++]);
+   }
+   if (++port == nb_ports)
+   port = 0;
+   }
+   if (power_lib_initialised)
+   rte_power_exit(rte_lcore_id());
+   /* set worker & tx threads quit flag */
+   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   quit_signal = 1;
+   return 0;
+}
+
+static int
+lcore_rx_and_distributor(struct lcore_params *p)
+{
+   struct rte_distributor *d = p->d;
+   const uint16_t nb_ports = rte_eth_dev_count_avail();
+   const int socket_id = rte_socket_id();
+   uint16_t port;
+   struct rte_mbuf *bufs[BURST_SIZE*2];
+
+   RTE_ETH_FOREACH_DEV(port) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0)
+   continue;
+
+   if (rte_eth_dev_socket_id(port) > 0 &&
+   rte_eth_dev_socket_id(port) != socket_id)
+   printf("WARNING, port %u is on remote NUMA node to "
+   "RX thread.\n\tPerformance will not "
+   "be optimal.\n", port);
+   }
+
+   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   port = 0;
+   while (!quit_signal_rx) {
+
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0) {
+   if (++port == nb_ports)
+   port = 0;
+   continue;
+   }
+   const uint16_t nb_rx = rte_eth_rx_burst(port, 0, bufs,
+   BURST_SIZE);
+   

[PATCH v2] examples/distributor: update dynamic configuration

2022-06-28 Thread Abdullah Ömer Yamaç
In this patch,
* It is possible to switch the running mode of the distributor
using the command line argument.
* With "-c" parameter, you can run RX and Distributor
on the same core.
* Without "-c" parameter, you can run RX and Distributor
on the different core.
* Syntax error of the single RX and distributor core is fixed.
* Consecutive termination of the lcores fixed.
The termination order was wrong, and you couldn't terminate the
application while traffic was capturing. The current order is
RX -> Distributor -> TX -> Workers
* When "-c" parameter is active, the wasted distributor core is
also deactivated in the main function.

Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core")
Cc: sta...@dpdk.org

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: david.h...@intel.com
---
 doc/guides/sample_app_ug/dist_app.rst |   3 +-
 examples/distributor/main.c   | 222 ++
 2 files changed, 159 insertions(+), 66 deletions(-)

diff --git a/doc/guides/sample_app_ug/dist_app.rst 
b/doc/guides/sample_app_ug/dist_app.rst
index 3bd03905c3..5c80561187 100644
--- a/doc/guides/sample_app_ug/dist_app.rst
+++ b/doc/guides/sample_app_ug/dist_app.rst
@@ -42,11 +42,12 @@ Running the Application
 
..  code-block:: console
 
-   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK
+   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK 
[-c]
 
where,
 
*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+   *   -c: Combines the RX core with distribution core
 
 #. To run the application in linux environment with 10 lcores, 4 ports,
issue the command:
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 8995806b4e..632d5e5554 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -39,6 +39,8 @@ volatile uint8_t quit_signal_rx;
 volatile uint8_t quit_signal_dist;
 volatile uint8_t quit_signal_work;
 unsigned int power_lib_initialised;
+bool enable_lcore_rx_distributor;
+unsigned int num_workers;
 
 static volatile struct app_stats {
struct {
@@ -256,14 +258,82 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-/*
- * You can run the distributor on the rx core with this code. Returned
- * packets are then send straight to the tx core.
- */
-#if 0
-   rte_distributor_process(p->d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pkts(p->d,
-   bufs, BURST_SIZE*2);
+   /*
+* Swap the following two lines if you want the rx traffic
+* to go directly to tx, no distribution.
+*/
+   struct rte_ring *out_ring = p->rx_dist_ring;
+   /* struct rte_ring *out_ring = p->dist_tx_ring; */
+
+   uint16_t sent = rte_ring_enqueue_burst(out_ring,
+   (void *)bufs, nb_rx, NULL);
+
+   app_stats.rx.enqueued_pkts += sent;
+   if (unlikely(sent < nb_rx)) {
+   app_stats.rx.enqdrop_pkts +=  nb_rx - sent;
+   RTE_LOG_DP(DEBUG, DISTRAPP,
+   "%s:Packet loss due to full ring\n", __func__);
+   while (sent < nb_rx)
+   rte_pktmbuf_free(bufs[sent++]);
+   }
+   if (++port == nb_ports)
+   port = 0;
+   }
+   if (power_lib_initialised)
+   rte_power_exit(rte_lcore_id());
+   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   /* set distributor threads quit flag */
+   quit_signal_dist = 1;
+   return 0;
+}
+
+static int
+lcore_rx_and_distributor(struct lcore_params *p)
+{
+   struct rte_distributor *d = p->d;
+   const uint16_t nb_ports = rte_eth_dev_count_avail();
+   const int socket_id = rte_socket_id();
+   uint16_t port;
+   struct rte_mbuf *bufs[BURST_SIZE*2];
+
+   RTE_ETH_FOREACH_DEV(port) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0)
+   continue;
+
+   if (rte_eth_dev_socket_id(port) > 0 &&
+   rte_eth_dev_socket_id(port) != socket_id)
+   printf("WARNING, port %u is on remote NUMA node to "
+   "RX thread.\n\tPerformance will not "
+   "be optimal.\n", port);
+   }
+
+   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   port = 0;
+   while (!quit_signal_rx) {
+
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0) {
+   

[PATCH v2] examples/distributor: update dynamic configuration

2022-06-28 Thread Abdullah Ömer Yamaç
In this patch,
* It is possible to switch the running mode of the distributor
using the command line argument.
* With "-c" parameter, you can run RX and Distributor
on the same core.
* Without "-c" parameter, you can run RX and Distributor
on the different core.
* Syntax error of the single RX and distributor core is fixed.
* Consecutive termination of the lcores fixed.
The termination order was wrong, and you couldn't terminate the
application while traffic was capturing. The current order is
RX -> Distributor -> TX -> Workers
* When "-c" parameter is active, the wasted distributor core is
also deactivated in the main function.

Fixes: 4a7f40c0ff9a ("examples/distributor: add dedicated core")
Cc: sta...@dpdk.org

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: david.h...@intel.com
---
 doc/guides/sample_app_ug/dist_app.rst |   3 +-
 examples/distributor/main.c   | 222 ++
 2 files changed, 159 insertions(+), 66 deletions(-)

diff --git a/doc/guides/sample_app_ug/dist_app.rst 
b/doc/guides/sample_app_ug/dist_app.rst
index 3bd03905c3..5c80561187 100644
--- a/doc/guides/sample_app_ug/dist_app.rst
+++ b/doc/guides/sample_app_ug/dist_app.rst
@@ -42,11 +42,12 @@ Running the Application
 
..  code-block:: console
 
-   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK
+   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK 
[-c]
 
where,
 
*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+   *   -c: Combines the RX core with distribution core
 
 #. To run the application in linux environment with 10 lcores, 4 ports,
issue the command:
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 8995806b4e..632d5e5554 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -39,6 +39,8 @@ volatile uint8_t quit_signal_rx;
 volatile uint8_t quit_signal_dist;
 volatile uint8_t quit_signal_work;
 unsigned int power_lib_initialised;
+bool enable_lcore_rx_distributor;
+unsigned int num_workers;
 
 static volatile struct app_stats {
struct {
@@ -256,14 +258,82 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-/*
- * You can run the distributor on the rx core with this code. Returned
- * packets are then send straight to the tx core.
- */
-#if 0
-   rte_distributor_process(p->d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pkts(p->d,
-   bufs, BURST_SIZE*2);
+   /*
+* Swap the following two lines if you want the rx traffic
+* to go directly to tx, no distribution.
+*/
+   struct rte_ring *out_ring = p->rx_dist_ring;
+   /* struct rte_ring *out_ring = p->dist_tx_ring; */
+
+   uint16_t sent = rte_ring_enqueue_burst(out_ring,
+   (void *)bufs, nb_rx, NULL);
+
+   app_stats.rx.enqueued_pkts += sent;
+   if (unlikely(sent < nb_rx)) {
+   app_stats.rx.enqdrop_pkts +=  nb_rx - sent;
+   RTE_LOG_DP(DEBUG, DISTRAPP,
+   "%s:Packet loss due to full ring\n", __func__);
+   while (sent < nb_rx)
+   rte_pktmbuf_free(bufs[sent++]);
+   }
+   if (++port == nb_ports)
+   port = 0;
+   }
+   if (power_lib_initialised)
+   rte_power_exit(rte_lcore_id());
+   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   /* set distributor threads quit flag */
+   quit_signal_dist = 1;
+   return 0;
+}
+
+static int
+lcore_rx_and_distributor(struct lcore_params *p)
+{
+   struct rte_distributor *d = p->d;
+   const uint16_t nb_ports = rte_eth_dev_count_avail();
+   const int socket_id = rte_socket_id();
+   uint16_t port;
+   struct rte_mbuf *bufs[BURST_SIZE*2];
+
+   RTE_ETH_FOREACH_DEV(port) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0)
+   continue;
+
+   if (rte_eth_dev_socket_id(port) > 0 &&
+   rte_eth_dev_socket_id(port) != socket_id)
+   printf("WARNING, port %u is on remote NUMA node to "
+   "RX thread.\n\tPerformance will not "
+   "be optimal.\n", port);
+   }
+
+   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   port = 0;
+   while (!quit_signal_rx) {
+
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0) {
+   

[PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-07 Thread Abdullah Ömer Yamaç
This patch introduce a new API to get the hidden key count in the hash
table if the rcu qsbr is enabled. When using rte_hash_count with rcu
qsbr enabled, it will return the number of elements that are not in the
free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of
elements in the defer queue will not be counted and freed. Therefore I
added a new API to get the number of hidden (defer queue) elements
in the hash table. Then the user can calculate the total number of
elements that are available in the hash table.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: Honnappa Nagarahalli 
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 
---
 lib/hash/rte_cuckoo_hash.c |  9 +
 lib/hash/rte_hash.h| 13 +
 lib/hash/version.map   |  1 +
 lib/rcu/rte_rcu_qsbr.c |  8 
 lib/rcu/rte_rcu_qsbr.h | 11 +++
 lib/rcu/version.map|  1 +
 6 files changed, 43 insertions(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 70456754c4..3553f3efc7 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_hash *h)
return h->entries;
 }
 
+int32_t
+rte_hash_dq_count(const struct rte_hash *h)
+{
+   if (h->dq == NULL)
+   return -EINVAL;
+
+   return rte_rcu_qsbr_dq_count(h->dq);
+}
+
 int32_t
 rte_hash_count(const struct rte_hash *h)
 {
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..8ea97e297d 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -193,6 +193,19 @@ rte_hash_free(struct rte_hash *h);
 void
 rte_hash_reset(struct rte_hash *h);
 
+
+/**
+ * Return the number of records in the defer queue of the hash table 
+ * if RCU is enabled.
+ * @param h
+ *  Hash table to query from
+ * @return
+ *   - -EINVAL if parameters are invalid
+ *   - A value indicating how many records were inserted in the table.
+ */
+int32_t
+rte_hash_dq_count(const struct rte_hash *h);
+
 /**
  * Return the number of keys in the hash table
  * @param h
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..7f7b158cf1 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -9,6 +9,7 @@ DPDK_24 {
rte_hash_add_key_with_hash;
rte_hash_add_key_with_hash_data;
rte_hash_count;
+   rte_hash_dq_count;
rte_hash_crc32_alg;
rte_hash_crc_set_alg;
rte_hash_create;
diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c
index bd0b83be0c..89f8da4c4c 100644
--- a/lib/rcu/rte_rcu_qsbr.c
+++ b/lib/rcu/rte_rcu_qsbr.c
@@ -450,6 +450,14 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, 
unsigned int n,
return 0;
 }
 
+/**
+ * Return the number of entries in a defer queue.
+ */
+unsigned int rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq)
+{
+   return rte_ring_count(dq->r);
+}
+
 /* Delete a defer queue. */
 int
 rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
index 23c9f89805..ed5a590edd 100644
--- a/lib/rcu/rte_rcu_qsbr.h
+++ b/lib/rcu/rte_rcu_qsbr.h
@@ -794,6 +794,17 @@ int
 rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n,
unsigned int *freed, unsigned int *pending, unsigned int *available);
 
+/**
+ * Return the number of entries in a defer queue.
+ *
+ * @param dq
+ *   Defer queue.
+ * @return
+ *   The number of entries in the defer queue.
+ */
+unsigned int
+rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq);
+
 /**
  * Delete a defer queue.
  *
diff --git a/lib/rcu/version.map b/lib/rcu/version.map
index 982ffd59d9..f410ab41e7 100644
--- a/lib/rcu/version.map
+++ b/lib/rcu/version.map
@@ -5,6 +5,7 @@ DPDK_24 {
rte_rcu_qsbr_dq_create;
rte_rcu_qsbr_dq_delete;
rte_rcu_qsbr_dq_enqueue;
+   rte_rcu_qsbr_dq_count;
rte_rcu_qsbr_dq_reclaim;
rte_rcu_qsbr_dump;
rte_rcu_qsbr_get_memsize;
-- 
2.34.1



Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-19 Thread Abdullah Ömer Yamaç
Hello,

Let me explain a use case;

I have a hash table whose key value is IP addresses, and data (let's say
the username of the IP) is related to the IP address. The key point is
matching these data with flows. Flows are dynamic, and this hash table is
dynamic, as well; both can change anytime. For example, when a flow starts,
we look up the hash table with the corresponding IP and retrieve the
username. We need to hold this username until the flow terminates, although
we removed this IP key from the hash table (multithread). That's why we
have RCU and defer queue is necessary for high performance. In my
application, I need to know the number of IP-username entries. These
numbers can be calculated by rte_hash_count - defer queue size.

I think if you need a non-blocking and multithreaded hash table, an
RCU-enabled hash table is necessary. Also, this API is necessary if you
need to get the actual matchable size.





On Mon, Feb 19, 2024 at 8:36 PM Medvedkin, Vladimir <
vladimir.medved...@intel.com> wrote:

> Hi Abdullah,
>
> Could you please tell more about use cases where this API may be useful?
>
> >a new API to get the hidden key count in the hash table if the rcu qsbr
> is enabled
>
> Here in commit message and down below in doxygen comments, I think this
> statement should be more specific because rcu can be created with
> RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.
>
> Also, new API must be reflected in release notes
>
> On 07/02/2024 15:33, Abdullah Ömer Yamaç wrote:
> > This patch introduce a new API to get the hidden key count in the hash
> > table if the rcu qsbr is enabled. When using rte_hash_count with rcu
> > qsbr enabled, it will return the number of elements that are not in the
> > free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of
> > elements in the defer queue will not be counted and freed. Therefore I
> > added a new API to get the number of hidden (defer queue) elements
> > in the hash table. Then the user can calculate the total number of
> > elements that are available in the hash table.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> >
> > ---
> > Cc: Honnappa Nagarahalli 
> > Cc: Yipeng Wang 
> > Cc: Sameh Gobriel 
> > Cc: Bruce Richardson 
> > Cc: Vladimir Medvedkin 
> > ---
> >   lib/hash/rte_cuckoo_hash.c |  9 +
> >   lib/hash/rte_hash.h| 13 +
> >   lib/hash/version.map   |  1 +
> >   lib/rcu/rte_rcu_qsbr.c |  8 
> >   lib/rcu/rte_rcu_qsbr.h | 11 +++
> >   lib/rcu/version.map|  1 +
> >   6 files changed, 43 insertions(+)
> >
> > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> > index 70456754c4..3553f3efc7 100644
> > --- a/lib/hash/rte_cuckoo_hash.c
> > +++ b/lib/hash/rte_cuckoo_hash.c
> > @@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_hash *h)
> >   return h->entries;
> >   }
> >
> > +int32_t
> > +rte_hash_dq_count(const struct rte_hash *h)
> > +{
> > + if (h->dq == NULL)
> input arguments must be checked since this is a public API, the same is
> true for rte_rcu_qsbr_dq_count()
> > + return -EINVAL;
> why not just return 0?
> > +
> > + return rte_rcu_qsbr_dq_count(h->dq);
> > +}
> > +
> >   int32_t
> >   rte_hash_count(const struct rte_hash *h)
> >   {
> > diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
> > index 7ecc02..8ea97e297d 100644
> > --- a/lib/hash/rte_hash.h
> > +++ b/lib/hash/rte_hash.h
> > @@ -193,6 +193,19 @@ rte_hash_free(struct rte_hash *h);
> >   void
> >   rte_hash_reset(struct rte_hash *h);
> >
> > +
> > +/**
> > + * Return the number of records in the defer queue of the hash table
> > + * if RCU is enabled.
> > + * @param h
> > + *  Hash table to query from
> > + * @return
> > + *   - -EINVAL if parameters are invalid
> > + *   - A value indicating how many records were inserted in the table.
> did you mean how many records are kept in defer queue?
> > + */
> > +int32_t
> > +rte_hash_dq_count(const struct rte_hash *h);
> > +
> >   /**
> >* Return the number of keys in the hash table
> >* @param h
> > diff --git a/lib/hash/version.map b/lib/hash/version.map
> > index 6b2afebf6b..7f7b158cf1 100644
> > --- a/lib/hash/version.map
> > +++ b/lib/hash/version.map
> > @@ -9,6 +9,7 @@ DPDK_24 {
> >   rte_hash_add_key_with_hash;
> >   rte_hash_add_key_with_hash_data;
> >   rte_hash_count;
> > + rte_hash_dq_count;
> new API must 

Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-20 Thread Abdullah Ömer Yamaç
I appreciate that you gave me suggestions and comments. I will make changes
according to all your recommendations, but before that, I want to make
everyone's minds clear. Then, I will apply modifications.

On Tue, Feb 20, 2024 at 2:35 AM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

>
>
> > On Feb 19, 2024, at 3:28 PM, Abdullah Ömer Yamaç 
> wrote:
> >
> > Hello,
> >
> > Let me explain a use case;
> >
> > I have a hash table whose key value is IP addresses, and data (let's say
> the username of the IP) is related to the IP address. The key point is
> matching these data with flows. Flows are dynamic, and this hash table is
> dynamic, as well; both can change anytime. For example, when a flow starts,
> we look up the hash table with the corresponding IP and retrieve the
> username. We need to hold this username until the flow terminates, although
> we removed this IP key from the hash table (multithread). That's why we
> have RCU and defer queue is necessary for high performance. In my
> application, I need to know the number of IP-username entries. These
> numbers can be calculated by rte_hash_count - defer queue size.
> The entries in the defer queue are not reclaimed (there is a probability
> that all of them can be reclaimed) and hence they are not available for
> allocation. So, rte_hash_count - defer queue size might not give you the
> correct number you are expecting.
>
> Currently, there is no API in hash library that forces a reclaim. Does it
> makes sense to have an API that just does the reclaim (and returns the
> number of entries pending in the defer queue)? A call to rte_hash_count
> should provide the exact count you are looking for.

You are right; no API in the hash library forces a reclaim. In my
application, I periodically call rte_count to retrieve hash size, and this
data is shown in my GUI. So that means I need to call regularly reclaim. I
am trying to figure out which is better, calling reclaim or retrieving the
defer queue size. Any comment about this?

> >
> > I think if you need a non-blocking and multithreaded hash table, an
> RCU-enabled hash table is necessary. Also, this API is necessary if you
> need to get the actual matchable size.
> >
> >
> >
> >
> >
> > On Mon, Feb 19, 2024 at 8:36 PM Medvedkin, Vladimir <
> vladimir.medved...@intel.com> wrote:
> > Hi Abdullah,
> >
> > Could you please tell more about use cases where this API may be useful?
> >
> > >a new API to get the hidden key count in the hash table if the rcu qsbr
> is enabled
> >
> > Here in commit message and down below in doxygen comments, I think this
> > statement should be more specific because rcu can be created with
> > RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.
> >
> > Also, new API must be reflected in release notes
> >
> > On 07/02/2024 15:33, Abdullah Ömer Yamaç wrote:
> > > This patch introduce a new API to get the hidden key count in the hash
> > > table if the rcu qsbr is enabled. When using rte_hash_count with rcu
> > > qsbr enabled, it will return the number of elements that are not in the
> > > free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of
> > > elements in the defer queue will not be counted and freed. Therefore I
> > > added a new API to get the number of hidden (defer queue) elements
> > > in the hash table. Then the user can calculate the total number of
> > > elements that are available in the hash table.
> > >
> > > Signed-off-by: Abdullah Ömer Yamaç 
> > >
> > > ---
> > > Cc: Honnappa Nagarahalli 
> > > Cc: Yipeng Wang 
> > > Cc: Sameh Gobriel 
> > > Cc: Bruce Richardson 
> > > Cc: Vladimir Medvedkin 
> > > ---
> > >   lib/hash/rte_cuckoo_hash.c |  9 +
> > >   lib/hash/rte_hash.h| 13 +
> > >   lib/hash/version.map   |  1 +
> > >   lib/rcu/rte_rcu_qsbr.c |  8 
> > >   lib/rcu/rte_rcu_qsbr.h | 11 +++
> > >   lib/rcu/version.map|  1 +
> > >   6 files changed, 43 insertions(+)
> > >
> > > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> > > index 70456754c4..3553f3efc7 100644
> > > --- a/lib/hash/rte_cuckoo_hash.c
> > > +++ b/lib/hash/rte_cuckoo_hash.c
> > > @@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_hash *h)
> > >   return h->entries;
> > >   }
> > >
> > > +int32_t
> > > +rte_hash_dq_count(const struct rte_hash *h)
> > > +{
> > &

Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-21 Thread Abdullah Ömer Yamaç
On Wed, Feb 21, 2024 at 6:24 AM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

>
>
> > On Feb 20, 2024, at 12:58 PM, Abdullah Ömer Yamaç 
> wrote:
> >
> > I appreciate that you gave me suggestions and comments. I will make
> changes according to all your recommendations, but before that, I want to
> make everyone's minds clear. Then, I will apply modifications.
> >
> > On Tue, Feb 20, 2024 at 2:35 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> >
> >
> > > On Feb 19, 2024, at 3:28 PM, Abdullah Ömer Yamaç 
> wrote:
> > >
> > > Hello,
> > >
> > > Let me explain a use case;
> > >
> > > I have a hash table whose key value is IP addresses, and data (let's
> say the username of the IP) is related to the IP address. The key point is
> matching these data with flows. Flows are dynamic, and this hash table is
> dynamic, as well; both can change anytime. For example, when a flow starts,
> we look up the hash table with the corresponding IP and retrieve the
> username. We need to hold this username until the flow terminates, although
> we removed this IP key from the hash table (multithread). That's why we
> have RCU and defer queue is necessary for high performance. In my
> application, I need to know the number of IP-username entries. These
> numbers can be calculated by rte_hash_count - defer queue size.
> > The entries in the defer queue are not reclaimed (there is a probability
> that all of them can be reclaimed) and hence they are not available for
> allocation. So, rte_hash_count - defer queue size might not give you the
> correct number you are expecting.
> >
> > Currently, there is no API in hash library that forces a reclaim. Does
> it makes sense to have an API that just does the reclaim (and returns the
> number of entries pending in the defer queue)? A call to rte_hash_count
> should provide the exact count you are looking for.
> > You are right; no API in the hash library forces a reclaim. In my
> application, I periodically call rte_count to retrieve hash size, and this
> data is shown in my GUI. So that means I need to call regularly reclaim. I
> am trying to figure out which is better, calling reclaim or retrieving the
> defer queue size. Any comment about this?
> Retrieving the defer queue size will be cheaper. However, calling the
> reclaim API will ensure the entries are freed hence providing an accurate
> number. Calling the reclaim API on an empty defer queue does not consume
> many cycles. If needed we could add a check for empty defer queue in the
> reclaim API and return early.
>
> I am also wondering if a reclaim API in hash library is needed. Why not
> call rte_rcu_qsbr_dq_reclaim API from the application?
>
The reason is simple. struct rte_hash *h is an internal structure and we
cannot access the h->dq. So it is not possible to call reclaim.

>
>
> > >
> > > I think if you need a non-blocking and multithreaded hash table, an
> RCU-enabled hash table is necessary. Also, this API is necessary if you
> need to get the actual matchable size.
> > >
> > >
> > >
> > >
> > >
> > > On Mon, Feb 19, 2024 at 8:36 PM Medvedkin, Vladimir <
> vladimir.medved...@intel.com> wrote:
> > > Hi Abdullah,
> > >
> > > Could you please tell more about use cases where this API may be
> useful?
> > >
> > > >a new API to get the hidden key count in the hash table if the rcu
> qsbr is enabled
> > >
> > > Here in commit message and down below in doxygen comments, I think
> this
> > > statement should be more specific because rcu can be created with
> > > RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.
> > >
> > > Also, new API must be reflected in release notes
> > >
> > > On 07/02/2024 15:33, Abdullah Ömer Yamaç wrote:
> > > > This patch introduce a new API to get the hidden key count in the
> hash
> > > > table if the rcu qsbr is enabled. When using rte_hash_count with rcu
> > > > qsbr enabled, it will return the number of elements that are not in
> the
> > > > free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of
> > > > elements in the defer queue will not be counted and freed. Therefore
> I
> > > > added a new API to get the number of hidden (defer queue) elements
> > > > in the hash table. Then the user can calculate the total number of
> > > > elements that are available in the hash table.
> > > >
> > > > Signed-off-by: Abdullah Ömer Yamaç 
> >

Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-22 Thread Abdullah Ömer Yamaç
As a final decision, I will add a new hash API that forces the reclaim. Is
it ok for everyone?

On Thu, Feb 22, 2024 at 5:37 AM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

>
>
> > On Feb 21, 2024, at 3:51 PM, Abdullah Ömer Yamaç 
> wrote:
> >
> >
> >
> > On Wed, Feb 21, 2024 at 6:24 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> >
> >
> > > On Feb 20, 2024, at 12:58 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > >
> > > I appreciate that you gave me suggestions and comments. I will make
> changes according to all your recommendations, but before that, I want to
> make everyone's minds clear. Then, I will apply modifications.
> > >
> > > On Tue, Feb 20, 2024 at 2:35 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > >
> > >
> > > > On Feb 19, 2024, at 3:28 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > >
> > > > Hello,
> > > >
> > > > Let me explain a use case;
> > > >
> > > > I have a hash table whose key value is IP addresses, and data (let's
> say the username of the IP) is related to the IP address. The key point is
> matching these data with flows. Flows are dynamic, and this hash table is
> dynamic, as well; both can change anytime. For example, when a flow starts,
> we look up the hash table with the corresponding IP and retrieve the
> username. We need to hold this username until the flow terminates, although
> we removed this IP key from the hash table (multithread). That's why we
> have RCU and defer queue is necessary for high performance. In my
> application, I need to know the number of IP-username entries. These
> numbers can be calculated by rte_hash_count - defer queue size.
> > > The entries in the defer queue are not reclaimed (there is a
> probability that all of them can be reclaimed) and hence they are not
> available for allocation. So, rte_hash_count - defer queue size might not
> give you the correct number you are expecting.
> > >
> > > Currently, there is no API in hash library that forces a reclaim. Does
> it makes sense to have an API that just does the reclaim (and returns the
> number of entries pending in the defer queue)? A call to rte_hash_count
> should provide the exact count you are looking for.
> > > You are right; no API in the hash library forces a reclaim. In my
> application, I periodically call rte_count to retrieve hash size, and this
> data is shown in my GUI. So that means I need to call regularly reclaim. I
> am trying to figure out which is better, calling reclaim or retrieving the
> defer queue size. Any comment about this?
> > Retrieving the defer queue size will be cheaper. However, calling the
> reclaim API will ensure the entries are freed hence providing an accurate
> number. Calling the reclaim API on an empty defer queue does not consume
> many cycles. If needed we could add a check for empty defer queue in the
> reclaim API and return early.
> >
> > I am also wondering if a reclaim API in hash library is needed. Why not
> call rte_rcu_qsbr_dq_reclaim API from the application?
> > The reason is simple. struct rte_hash *h is an internal structure and we
> cannot access the h->dq. So it is not possible to call reclaim.
> Ack. This will be just a wrapper around the rte_rcu_qsbr_dq_reclaim.
>
> >
> >
> > > >
> > > > I think if you need a non-blocking and multithreaded hash table, an
> RCU-enabled hash table is necessary. Also, this API is necessary if you
> need to get the actual matchable size.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Mon, Feb 19, 2024 at 8:36 PM Medvedkin, Vladimir <
> vladimir.medved...@intel.com> wrote:
> > > > Hi Abdullah,
> > > >
> > > > Could you please tell more about use cases where this API may be
> useful?
> > > >
> > > > >a new API to get the hidden key count in the hash table if the rcu
> qsbr is enabled
> > > >
> > > > Here in commit message and down below in doxygen comments, I think
> this
> > > > statement should be more specific because rcu can be created with
> > > > RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.
> > > >
> > > > Also, new API must be reflected in release notes
> > > >
> > > > On 07/02/2024 15:33, Abdullah Ömer Yamaç wrote:
> > > > > This patch introduce a new API to get the hidden key count in the
>

Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-02-28 Thread Abdullah Ömer Yamaç
While I was implementing the new API, I realized one issue, and it would be
good to discuss it here. First of all rte_rcu_qsbr_dq_reclaim function
checks the state of the qsbr values. It means that all threads should
report the quiescent states. It conflicts with my aim.

Let's think about below scenario:
Eight threads use a hash table and periodically report their quiescent
states. One additional thread (main thread) periodically reports the hash
size. I implemented the reclaim function in that thread. I mean, the main
thread calls reclaim before the rte_hash_count.

Here is the exceptional case that I couldn't retrieve the correct hash size:
Assume that 6 of 8 threads reported quiescent states and 2 of them are
still working on some process and haven't reported quiescent states yet.
The main thread calls reclaim functions every time, but elements in dq will
not be freed because 2 of the worker threads haven't reported their states
(especially if they are waiting for some packets). So, my first proposed
method is more suitable for this case. Any idea?

On Thu, Feb 22, 2024 at 7:44 PM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

>
>
> > On Feb 22, 2024, at 6:39 AM, Abdullah Ömer Yamaç 
> wrote:
> >
> > As a final decision, I will add a new hash API that forces the reclaim.
> Is it ok for everyone?
> Ack from my side
>
> >
> > On Thu, Feb 22, 2024 at 5:37 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> >
> >
> > > On Feb 21, 2024, at 3:51 PM, Abdullah Ömer Yamaç 
> wrote:
> > >
> > >
> > >
> > > On Wed, Feb 21, 2024 at 6:24 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > >
> > >
> > > > On Feb 20, 2024, at 12:58 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > >
> > > > I appreciate that you gave me suggestions and comments. I will make
> changes according to all your recommendations, but before that, I want to
> make everyone's minds clear. Then, I will apply modifications.
> > > >
> > > > On Tue, Feb 20, 2024 at 2:35 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > > >
> > > >
> > > > > On Feb 19, 2024, at 3:28 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > > >
> > > > > Hello,
> > > > >
> > > > > Let me explain a use case;
> > > > >
> > > > > I have a hash table whose key value is IP addresses, and data
> (let's say the username of the IP) is related to the IP address. The key
> point is matching these data with flows. Flows are dynamic, and this hash
> table is dynamic, as well; both can change anytime. For example, when a
> flow starts, we look up the hash table with the corresponding IP and
> retrieve the username. We need to hold this username until the flow
> terminates, although we removed this IP key from the hash table
> (multithread). That's why we have RCU and defer queue is necessary for high
> performance. In my application, I need to know the number of IP-username
> entries. These numbers can be calculated by rte_hash_count - defer queue
> size.
> > > > The entries in the defer queue are not reclaimed (there is a
> probability that all of them can be reclaimed) and hence they are not
> available for allocation. So, rte_hash_count - defer queue size might not
> give you the correct number you are expecting.
> > > >
> > > > Currently, there is no API in hash library that forces a reclaim.
> Does it makes sense to have an API that just does the reclaim (and returns
> the number of entries pending in the defer queue)? A call to rte_hash_count
> should provide the exact count you are looking for.
> > > > You are right; no API in the hash library forces a reclaim. In my
> application, I periodically call rte_count to retrieve hash size, and this
> data is shown in my GUI. So that means I need to call regularly reclaim. I
> am trying to figure out which is better, calling reclaim or retrieving the
> defer queue size. Any comment about this?
> > > Retrieving the defer queue size will be cheaper. However, calling the
> reclaim API will ensure the entries are freed hence providing an accurate
> number. Calling the reclaim API on an empty defer queue does not consume
> many cycles. If needed we could add a check for empty defer queue in the
> reclaim API and return early.
> > >
> > > I am also wondering if a reclaim API in hash library is needed. Why
> not call rte_rcu_qsbr_dq_reclaim API from the application?
> > > The reason is si

Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash

2024-03-02 Thread Abdullah Ömer Yamaç
Sorry for the late reply. I understood what you mean. I will create only
the reclaim API for the hash library. Thanks for the explanation.

On Wed, Feb 28, 2024 at 5:51 PM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

>
>
> > On Feb 28, 2024, at 5:44 AM, Abdullah Ömer Yamaç 
> wrote:
> >
> > While I was implementing the new API, I realized one issue, and it would
> be good to discuss it here. First of all rte_rcu_qsbr_dq_reclaim function
> checks the state of the qsbr values. It means that all threads should
> report the quiescent states. It conflicts with my aim.
> >
> > Let's think about below scenario:
> > Eight threads use a hash table and periodically report their quiescent
> states. One additional thread (main thread) periodically reports the hash
> size. I implemented the reclaim function in that thread. I mean, the main
> thread calls reclaim before the rte_hash_count.
> >
> > Here is the exceptional case that I couldn't retrieve the correct hash
> size:
> > Assume that 6 of 8 threads reported quiescent states and 2 of them are
> still working on some process and haven't reported quiescent states yet.
> The main thread calls reclaim functions every time, but elements in dq will
> not be freed because 2 of the worker threads haven't reported their states
> (especially if they are waiting for some packets). So, my first proposed
> method is more suitable for this case. Any idea?
> If 2 out of 8 threads have not reported their quiescent state then the
> elements that have not been acknowledged by those 2 threads cannot be
> reclaimed and cannot be allocated for further use. Using this you can
> calculate the most accurate number of entries in the hash table available
> for allocation.
>
> >
> > On Thu, Feb 22, 2024 at 7:44 PM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> >
> >
> > > On Feb 22, 2024, at 6:39 AM, Abdullah Ömer Yamaç 
> wrote:
> > >
> > > As a final decision, I will add a new hash API that forces the
> reclaim. Is it ok for everyone?
> > Ack from my side
> >
> > >
> > > On Thu, Feb 22, 2024 at 5:37 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > >
> > >
> > > > On Feb 21, 2024, at 3:51 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > >
> > > >
> > > >
> > > > On Wed, Feb 21, 2024 at 6:24 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > > >
> > > >
> > > > > On Feb 20, 2024, at 12:58 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > > >
> > > > > I appreciate that you gave me suggestions and comments. I will
> make changes according to all your recommendations, but before that, I want
> to make everyone's minds clear. Then, I will apply modifications.
> > > > >
> > > > > On Tue, Feb 20, 2024 at 2:35 AM Honnappa Nagarahalli <
> honnappa.nagaraha...@arm.com> wrote:
> > > > >
> > > > >
> > > > > > On Feb 19, 2024, at 3:28 PM, Abdullah Ömer Yamaç <
> aomerya...@gmail.com> wrote:
> > > > > >
> > > > > > Hello,
> > > > > >
> > > > > > Let me explain a use case;
> > > > > >
> > > > > > I have a hash table whose key value is IP addresses, and data
> (let's say the username of the IP) is related to the IP address. The key
> point is matching these data with flows. Flows are dynamic, and this hash
> table is dynamic, as well; both can change anytime. For example, when a
> flow starts, we look up the hash table with the corresponding IP and
> retrieve the username. We need to hold this username until the flow
> terminates, although we removed this IP key from the hash table
> (multithread). That's why we have RCU and defer queue is necessary for high
> performance. In my application, I need to know the number of IP-username
> entries. These numbers can be calculated by rte_hash_count - defer queue
> size.
> > > > > The entries in the defer queue are not reclaimed (there is a
> probability that all of them can be reclaimed) and hence they are not
> available for allocation. So, rte_hash_count - defer queue size might not
> give you the correct number you are expecting.
> > > > >
> > > > > Currently, there is no API in hash library that forces a reclaim.
> Does it makes sense to have an API that just does the reclaim (and returns
> the number of entries pending in the defer qu

[PATCH v2] lib/hash: feature reclaim defer queue

2024-03-02 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
Acked-by: Honnappa Nagarahalli 
---
 lib/hash/rte_cuckoo_hash.c | 23 +++
 lib/hash/rte_hash.h| 14 ++
 lib/hash/version.map   |  7 +++
 3 files changed, 44 insertions(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..254fa80cc5 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h)
+{
+   int ret;
+
+   if (h->hash_rcu_cfg == NULL || h->dq == NULL) {
+   rte_errno = EINVAL;
+   return -1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size, 
NULL, NULL, NULL);
+   if (ret != 0) {
+   HASH_LOG(ERR,
+   "%s: could not reclaim the defer queue in hash table",
+   __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
 static inline void
 remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..c119477d50 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -674,6 +674,21 @@ rte_hash_iterate(const struct rte_hash *h, const void 
**key, void **data, uint32
  */
 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
 
+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.
+ *
+ * @param h
+ *   the hash object to reclaim resources
+ * @return
+ *   On success - 0
+ *   On error - 1 with error code set in rte_errno.
+ *   Possible rte_errno codes are:
+ *   - EINVAL - invalid pointer or invalid rcu mode
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..cec0e8fc67 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,10 @@ DPDK_24 {
 
local: *;
 };
+
+EXPERIMENTAL {
+   global:
+
+   #added in 24.1
+   rte_hash_rcu_qsbr_dq_reclaim;
+}
\ No newline at end of file
-- 
2.34.1



[PATCH v2] lib/hash: feature reclaim defer queue

2024-03-02 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
Acked-by: Honnappa Nagarahalli 
---
 lib/hash/rte_cuckoo_hash.c | 23 +++
 lib/hash/rte_hash.h| 14 ++
 lib/hash/version.map   |  7 +++
 3 files changed, 44 insertions(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..254fa80cc5 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h)
+{
+   int ret;
+
+   if (h->hash_rcu_cfg == NULL || h->dq == NULL) {
+   rte_errno = EINVAL;
+   return -1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size, 
NULL, NULL, NULL);
+   if (ret != 0) {
+   HASH_LOG(ERR,
+   "%s: could not reclaim the defer queue in hash table",
+   __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
 static inline void
 remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..c119477d50 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -674,6 +674,21 @@ rte_hash_iterate(const struct rte_hash *h, const void 
**key, void **data, uint32
  */
 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
 
+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.
+ *
+ * @param h
+ *   the hash object to reclaim resources
+ * @return
+ *   On success - 0
+ *   On error - 1 with error code set in rte_errno.
+ *   Possible rte_errno codes are:
+ *   - EINVAL - invalid pointer or invalid rcu mode
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..cec0e8fc67 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,9 @@ DPDK_24 {
 
local: *;
 };
+
+EXPERIMENTAL {
+   global:
+
+   rte_hash_rcu_qsbr_dq_reclaim;
+}
\ No newline at end of file
-- 
2.34.1



Re: [PATCH v4] lib/hash: add defer queue reclaim API

2024-04-23 Thread Abdullah Ömer Yamaç
Hello, is there any other comment on this patch? Thanks

On Mon, Apr 15, 2024 at 2:26 PM Abdullah Ömer Yamaç 
wrote:

> This patch adds a new feature to the hash library to allow the user to
> reclaim the defer queue. This is useful when the user wants to force
> reclaim resources that are not being used. This API is only available
> if the RCU is enabled.
>
> Signed-off-by: Abdullah Ömer Yamaç 
> ---
>  app/test/test_hash.c   | 97 ++
>  lib/hash/rte_cuckoo_hash.c | 23 +
>  lib/hash/rte_hash.h| 24 ++
>  lib/hash/version.map   |  7 +++
>  4 files changed, 151 insertions(+)
>
> diff --git a/app/test/test_hash.c b/app/test/test_hash.c
> index d586878a22..ebeda8c322 100644
> --- a/app/test/test_hash.c
> +++ b/app/test/test_hash.c
> @@ -2183,6 +2183,100 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
>
>  }
>
> +/*
> + * rte_hash_rcu_qsbr_dq_reclaim unit test.
> + */
> +static int
> +test_hash_rcu_qsbr_dq_reclaim(void)
> +{
> +   size_t sz;
> +   int32_t status;
> +   unsigned int total_entries = 8;
> +   unsigned int freed, pending, available;
> +   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
> +   struct rte_hash_rcu_config rcu_cfg = {0};
> +   struct rte_hash_parameters hash_params = {
> +   .name = "test_hash_rcu_qsbr_dq_reclaim",
> +   .entries = total_entries,
> +   .key_len = sizeof(uint32_t),
> +   .hash_func = NULL,
> +   .hash_func_init_val = 0,
> +   .socket_id = 0,
> +   };
> +
> +   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
> +
> +   g_qsv = NULL;
> +   g_handle = NULL;
> +
> +   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue
> functional test\n");
> +
> +   g_handle = rte_hash_create(&hash_params);
> +   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
> +
> +   /* Create RCU QSBR variable */
> +   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
> +   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
> +   RTE_CACHE_LINE_SIZE,
> SOCKET_ID_ANY);
> +   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL,
> +"RCU QSBR
> variable creation failed");
> +
> +   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0,
> +"RCU QSBR
> variable initialization failed");
> +
> +   rcu_cfg.v = g_qsv;
> +   rcu_cfg.dq_size = total_entries;
> +   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
> +
> +   /* Attach RCU QSBR to hash table */
> +   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0,
> +"Attach RCU QSBR
> to hash table failed");
> +
> +   /* Register pseudo reader */
> +   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0,
> +"RCU QSBR thread
> registration failed");
> +   rte_rcu_qsbr_thread_online(g_qsv, 0);
> +
> +   /* Fill half of the hash table */
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
> +
> +   /* Lookup inserted elements*/
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   rte_hash_lookup(g_handle, &reclaim_keys[i]);
> +
> +   /* Try to put these elements into the defer queue*/
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   rte_hash_del_key(g_handle, &reclaim_keys[i]);
> +
> +   /* Reader quiescent */
> +   rte_rcu_qsbr_quiescent(g_qsv, 0);
> +
> +   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
> +   RETURN_IF_ERROR_RCU_QSBR(status < 0,
> +"failed to add
> key (pos[%u]=%d)", 0,
> +status);
> +
> +   /* This should be (total_entries / 2) + 1 (last add) */
> +   unsigned int hash_size = rte_hash_count(g_handle);
> +
> +   /* Freed size should be (total_entries / 2) */
> +   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending,
> &available);
> +
> +   rte_hash_free(g_handle);
> +   rte_free(g_qsv);
> +
> +   if (hash_size !

Re: [PATCH] lib/hash: setting the maximum reclamation size

2024-04-23 Thread Abdullah Ömer Yamaç
Hello,
Any comment on this patch?

On Wed, Apr 17, 2024 at 4:39 PM Abdullah Ömer Yamaç 
wrote:

> In the previous implementation, the maximum reclamation size was set
> to RTE_HASH_RCU_DQ_RECLAIM_MAX and it was not configurable. This patch
> uses the configuration argument to set the maximum reclamation size.
>
> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
> Cc: dharmik.thak...@arm.com
> Cc: Honnappa Nagarahalli 
> Cc: Yipeng Wang 
> Cc: Sameh Gobriel 
> Cc: Bruce Richardson 
> Cc: Vladimir Medvedkin 
>
> Signed-off-by: Abdullah Ömer Yamaç 
> ---
>  lib/hash/rte_cuckoo_hash.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 4a44aadd9a..6d80793164 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
> rte_hash_rcu_config *cfg)
> if (params.size == 0)
> params.size = total_entries;
> params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
> +   params.max_reclaim_size = cfg->max_reclaim_size;
> if (params.max_reclaim_size == 0)
> params.max_reclaim_size =
> RTE_HASH_RCU_DQ_RECLAIM_MAX;
> params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
> --
> 2.34.1
>
>


Re: [PATCH v4] lib/hash: add defer queue reclaim API

2024-04-25 Thread Abdullah Ömer Yamaç
Thanks for the comments. This is due to the tab size, and I will fix them.

On Wed, Apr 24, 2024 at 12:24 AM Stephen Hemminger <
step...@networkplumber.org> wrote:

> On Mon, 15 Apr 2024 11:26:02 +
> Abdullah Ömer Yamaç  wrote:
>
> > + ret = rte_rcu_qsbr_dq_reclaim(h->dq,
> h->hash_rcu_cfg->max_reclaim_size,
> > +   freed,
> pending, available);
>
> Indention here is odd. I would expect "freed," to line up right under
> h->dq.
> Since rte_rcu_qsbrs_dq_reclaim logs error on invalid parameters, this
> function should as well.
>
> Total indent fixes:
>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 4a44aadd9a..e1ea810024 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -1590,21 +1590,20 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
> rte_hash_rcu_config *cfg)
>
>  int
>  rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
> -   unsigned int *pending, unsigned
> int *available)
> +unsigned int *pending, unsigned int
> *available)
>  {
> int ret;
>
> if (h == NULL || h->hash_rcu_cfg == NULL) {
> +   HASH_LOG(ERR, "Invalid input parameter");
> rte_errno = EINVAL;
> return 1;
> }
>
> ret = rte_rcu_qsbr_dq_reclaim(h->dq,
> h->hash_rcu_cfg->max_reclaim_size,
> - freed,
> pending, available);
> + freed, pending, available);
> if (ret != 0) {
> -   HASH_LOG(ERR,
> -"%s: could not reclaim the defer queue in
> hash table",
> -__func__);
> +   HASH_LOG(ERR, "%s: could not reclaim the defer queue in
> hash table", __func__);
> return 1;
> }
>
>


[PATCH v5] lib/hash: add defer queue reclaim API

2024-04-27 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 app/test/test_hash.c   | 90 ++
 lib/hash/rte_cuckoo_hash.c | 21 +
 lib/hash/rte_hash.h| 25 +++
 lib/hash/version.map   |  7 +++
 4 files changed, 143 insertions(+)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index d586878a22..e763d0503f 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -2183,6 +2183,93 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
 
 }
 
+/*
+ * rte_hash_rcu_qsbr_dq_reclaim unit test.
+ */
+static int test_hash_rcu_qsbr_dq_reclaim(void)
+{
+   size_t sz;
+   int32_t status;
+   unsigned int total_entries = 8;
+   unsigned int freed, pending, available;
+   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
+   struct rte_hash_rcu_config rcu_cfg = {0};
+   struct rte_hash_parameters hash_params = {
+   .name = "test_hash_rcu_qsbr_dq_reclaim",
+   .entries = total_entries,
+   .key_len = sizeof(uint32_t),
+   .hash_func = NULL,
+   .hash_func_init_val = 0,
+   .socket_id = 0,
+   };
+
+   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
+
+   g_qsv = NULL;
+   g_handle = NULL;
+
+   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue functional 
test\n");
+
+   g_handle = rte_hash_create(&hash_params);
+   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
+
+   /* Create RCU QSBR variable */
+   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
+   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz, 
RTE_CACHE_LINE_SIZE,
+ SOCKET_ID_ANY);
+   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL, "RCU QSBR variable creation 
failed");
+
+   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR variable initialization 
failed");
+
+   rcu_cfg.v = g_qsv;
+   rcu_cfg.dq_size = total_entries;
+   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
+
+   /* Attach RCU QSBR to hash table */
+   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "Attach RCU QSBR to hash table 
failed");
+
+   /* Register pseudo reader */
+   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR thread registration 
failed");
+   rte_rcu_qsbr_thread_online(g_qsv, 0);
+
+   /* Fill half of the hash table */
+   for (size_t i = 0; i < total_entries / 2; i++)
+   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
+
+   /* Lookup inserted elements*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_lookup(g_handle, &reclaim_keys[i]);
+
+   /* Try to put these elements into the defer queue*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_del_key(g_handle, &reclaim_keys[i]);
+
+   /* Reader quiescent */
+   rte_rcu_qsbr_quiescent(g_qsv, 0);
+
+   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
+   RETURN_IF_ERROR_RCU_QSBR(status < 0, "failed to add key (pos[%u]=%d)", 
0, status);
+
+   /* This should be (total_entries / 2) + 1 (last add) */
+   unsigned int hash_size = rte_hash_count(g_handle);
+
+   /* Freed size should be (total_entries / 2) */
+   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending, &available);
+
+   rte_hash_free(g_handle);
+   rte_free(g_qsv);
+
+   if (hash_size != (total_entries / 2 + 1) || freed != (total_entries / 
2)) {
+   printf("Failed to reclaim defer queue\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 /*
  * Do all unit and performance tests.
  */
@@ -2261,6 +2348,9 @@ test_hash(void)
if (test_hash_rcu_qsbr_sync_mode(1) < 0)
return -1;
 
+   if (test_hash_rcu_qsbr_dq_reclaim() < 0)
+   return -1;
+
return 0;
 }
 
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..52ccada12a 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed, 
unsigned int *pending,
+unsigned int *available)
+{
+   int ret;
+
+   if (h == NULL || h->hash_rcu_cfg == NULL) {
+   HASH_LOG(ERR, &

[PATCH] devtools: add .clang-format file

2024-04-29 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 30 ++
 1 file changed, 30 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..8ac10c0c09
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,30 @@
+---
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: true
+AfterControlStatement: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+EndOfLine: lf
+
+# Specify style options for the entire file
+File:
+# Insert a final newline character at the end of the file
+EndOfFile: true
+
+IndentWidth: 8
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Specify whitespace-related style options
+Whitespace:
+# Trim trailing whitespace at the end of each line
+TrimTrailingWhitespace: true
-- 
2.34.1



Re: [PATCH] devtools: add .clang-format file

2024-04-30 Thread Abdullah Ömer Yamaç
> ...
>
> 1. Some options are failing for me [1], I don't know if it requires a
> specific version of clang-format
>
I fixed these errors, and the clang-format version should be 17. I will
send them after some discussions, as I've shared below.

>
> 2. Current options are not fully aligned with coding convention, it is
> easier to see what is not compatible by running the tool on an existing
> file [2].
> we need to fix them.
>
> There are some cases that we need to discuss. First of all, I applied the
latest clang format that I created.
- In default cases for clang-format, include headers are sorted
alphabetically. It improves the readability of code, and it breaks the
codebase. These changes do not affect code maintenance because they are
only headers.
- Second question about the column width. In the definition of
.editorconfig, the column width is set as 100, but the previous commits
violate this. Here is the sample code:
 struct rte_eth_dev rte_eth_devices[RTE_MAX_ETHPORTS];
@@ -61,8 +61,7 @@ static const struct rte_eth_xstats_name_off
eth_dev_stats_strings[] = {
{"rx_missed_errors", offsetof(struct rte_eth_stats, imissed)},
{"rx_errors", offsetof(struct rte_eth_stats, ierrors)},
{"tx_errors", offsetof(struct rte_eth_stats, oerrors)},
-   {"rx_mbuf_allocation_errors", offsetof(struct rte_eth_stats,
-   rx_nombuf)},
+   {"rx_mbuf_allocation_errors", offsetof(struct rte_eth_stats,
rx_nombuf)},
 };

We could use this clang-format file only for the new patches and newly
inserted lines. I am using VSCode IDE for development, and after some
modification, I can select the modified lines and apply formatting. It is
very useful for these cases. Otherwise, we need to handle so many things.

By the way, I am still working on macros. If you have any comments on this,
I would be very happy to discuss it.


> ...


Re: [PATCH] devtools: add .clang-format file

2024-05-04 Thread Abdullah Ömer Yamaç
Hello,
I am facing a problem while creating the configuration. I am trying to make
a clang-format that formats codes without changing any codebases. Here is
the question:

clang-format related config:
...
BraceWrapping:
AfterFunction: true
...

If the configuration supports braces after function, then MACRO's formats
fail.

An example of the formatted MACRO is given below:
...
#define RTE_RX_OFFLOAD_BIT2STR(_name)  \
{  \
...

If the AfterFunction is false, the functions' formats fail; here is a
formatted example.
...
 if (devargs_str == NULL) {
...

I will send the current configuration as v2. You can test it.



On Mon, Apr 29, 2024 at 6:43 PM Stephen Hemminger <
step...@networkplumber.org> wrote:

> On Mon, 29 Apr 2024 14:32:43 +0100
> Ferruh Yigit  wrote:
>
> > On 4/29/2024 2:04 PM, Abdullah Ömer Yamaç wrote:
> > > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > > to reformat code to match a given coding style, or to ensure that code
> > > adheres to a specific coding style. It helps to maintain a consistent
> > > coding style across the DPDK codebase.
> > >
> > > .clang-format file overrides the default style options provided by
> > > clang-format and large set of IDEs and text editors support it.
> > >
> > > Signed-off-by: Abdullah Ömer Yamaç 
> > >
> >
> > Overall +1 to have a format file, specially to help non-frequent
> > contributors.
> >
> > 1. Some options are failing for me [1], I don't know if it requires a
> > specific version of clang-format
> >
> > 2. Current options are not fully aligned with coding convention, it is
> > easier to see what is not compatible by running the tool on an existing
> > file [2].
> > we need to fix them.
> >
> >
> >
> > [1]
> > `clang-format -i ./lib/ethdev/rte_ethdev.c`
> > a.
> > /home/amd/development/dpdk-next-net/./.clang-format:28:1: error: unknown
> > key 'Whitespace'
> > Whitespace:
> > ^~
> > Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> > Invalid argument
> >
> > b.
> > /home/amd/development/dpdk-next-net/./.clang-format:12:1: error: unknown
> > key 'EndOfLine'
> > EndOfLine: lf
> > ^
> > Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> > Invalid argument
> >
> > c.
> > /home/amd/development/dpdk-next-net/./.clang-format:15:1: error: unknown
> > key 'File'
> > File:
> > ^~~~
> > Error reading /home/amd/development/dpdk-next-net/./.clang-format:
> > Invalid argument
> >
> >
> >
> > [2]
> > `clang-format -i ./lib/ethdev/rte_ethdev.c` (with failing part commented
> > out)
> > `git diff`
> >
> > A few diff samples to fix at first glance:
> > ```
> >  static const struct rte_eth_xstats_name_off eth_dev_txq_stats_strings[]
> = {
> >  -   {"packets", offsetof(struct rte_eth_stats, q_opackets)},
> >  -   {"bytes", offsetof(struct rte_eth_stats, q_obytes)},
> >  +{"packets", offsetof(struct rte_eth_stats, q_opackets)},
> >  +{"bytes", offsetof(struct rte_eth_stats, q_obytes)},
> >  };
> > ```
> >
> > ```
> >  -enum {
> >  -   STAT_QMAP_TX = 0,
> >  -   STAT_QMAP_RX
> >  -};
> >  +enum { STAT_QMAP_TX = 0, STAT_QMAP_RX };
> > ```
> >
> > ```
> >  -int
> >  -rte_eth_iterator_init(struct rte_dev_iterator *iter, const char
> > *devargs_str)
> >  +int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char
> > *devargs_str)
> > ```
> >
> > ```
> >  RTE_ETH_FOREACH_DEV(p)
>
> Add this
>
> # Take from
> #
> # git grep -h '^#define [^[:space:]]*FOREACH[^[:space:]]*(' lib/ \
> #  | sed "s,^#define \([^[:space:]]*FOREACH[^[:space:]]*\)(.*$,  - '\1'," \
> #  | LC_ALL=C sort -u
> ForeachMacros:
>  - 'CIRBUF_FOREACH'
>   - 'RTE_BBDEV_FOREACH'
>   - 'RTE_DEV_FOREACH'
>   - 'RTE_DMA_FOREACH_DEV'
>   - 'RTE_EAL_DEVARGS_FOREACH'
>   - 'RTE_ETH_FOREACH_DEV'
>   - 'RTE_ETH_FOREACH_DEV_OF'
>   - 'RTE_ETH_FOREACH_DEV_OWNED_BY'
>   - 'RTE_ETH_FOREACH_DEV_SIBLING'
>   - 'RTE_ETH_FOREACH_MATCHING_DEV'
>   - 'RTE_ETH_FOREACH_VALID_DEV'
>   - 'RTE_GPU_FOREACH'
>   - 'RTE_GPU_FOREACH_CHILD'
>   - 'RTE_GPU_FOREACH_PARENT'
>   - 'RTE_LCORE_FOREACH'
>   - 'RTE_LCORE_FOREACH_WORKER'
>   - 'RTE_TAILQ_FOREACH'
>   - 'RTE_TAILQ_FOREACH_SAFE'
>
>
>


[PATCH v2] devtools: add .clang-format file

2024-05-04 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 42 ++
 1 file changed, 42 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..480beaca20
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,42 @@
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: false
+AfterControlStatement: false
+AfterEnum: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 8 spaces
+ContinuationIndentWidth: 8
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
-- 
2.34.1



Re: [PATCH v2] devtools: add .clang-format file

2024-05-04 Thread Abdullah Ömer Yamaç
I was confused about the kernel functions. I didn't understand what you
meant at first, but now I understand.  I will send a new patch with all
DPDK-related foreach macros.

On Sat, May 4, 2024 at 7:27 PM Stephen Hemminger 
wrote:

> On Sat,  4 May 2024 13:41:35 +
> Abdullah Ömer Yamaç  wrote:
>
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
>
> You need to add the ForEachMacros: I sent in earlier email
>
>


[PATCH v3] devtools: add .clang-format file

2024-05-04 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 138 ++
 1 file changed, 138 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..16164ef1de
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,138 @@
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: false
+AfterControlStatement: false
+AfterEnum: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 8 spaces
+ContinuationIndentWidth: 8
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros: [
+"CIRBUF_FOREACH",
+"DLB2_LIST_FOR_EACH",
+"DLB2_LIST_FOR_EACH_SAFE",
+"ECORE_LIST_FOR_EACH_ENTRY",
+"ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+"FOR_EACH",
+"FOR_EACH_BUCKET",
+"FOR_EACH_CNIC_QUEUE",
+"FOR_EACH_COS_IN_TX_QUEUE",
+"FOR_EACH_ETH_QUEUE",
+"FOR_EACH_MEMBER",
+"FOR_EACH_NONDEFAULT_ETH_QUEUE",
+"FOR_EACH_NONDEFAULT_QUEUE",
+"FOR_EACH_PORT",
+"FOR_EACH_PORT_IF",
+"FOR_EACH_QUEUE",
+"FOR_EACH_SUITE_TESTCASE",
+"FOR_EACH_SUITE_TESTSUITE",
+"FOREACH_ABS_FUNC_IN_PORT",
+"FOREACH_DEVICE_ON_AUXILIARY_BUS",
+"FOREACH_DEVICE_ON_CDXBUS",
+"FOREACH_DEVICE_ON_PCIBUS",
+"FOREACH_DEVICE_ON_PLATFORM_BUS",
+"FOREACH_DEVICE_ON_UACCEBUS",
+"FOREACH_DEVICE_ON_VMBUS",
+"FOREACH_DRIVER_ON_AUXILIARY_BUS",
+"FOREACH_DRIVER_ON_CDXBUS",
+"FOREACH_DRIVER_ON_PCIBUS",
+"FOREACH_DRIVER_ON_PLATFORM_BUS",
+"FOREACH_DRIVER_ON_UACCEBUS",
+"FOREACH_DRIVER_ON_VMBUS",
+"FOREACH_SUBDEV",
+"FOREACH_SUBDEV_STATE",
+"HLIST_FOR_EACH_ENTRY",
+"ILIST_FOREACH",
+"LIST_FOR_EACH_ENTRY",
+"LIST_FOR_EACH_ENTRY_SAFE",
+"LIST_FOREACH",
+"LIST_FOREACH_FROM",
+"LIST_FOREACH_FROM_SAFE",
+"LIST_FOREACH_SAFE",
+"ML_AVG_FOREACH_QP",
+"ML_AVG_FOREACH_QP_MVTVM",
+"ML_AVG_RESET_FOREACH_QP",
+"ML_MAX_FOREACH_QP",
+"ML_MAX_FOREACH_QP_MVTVM",
+"ML_MAX_RESET_FOREACH_QP",
+"ML_MIN_FOREACH_QP",
+"ML_MIN_FOREACH_QP_MVTVM",
+"ML_MIN_RESET_FOREACH_QP",
+"MLX5_ETH_FOREACH_DEV",
+"MLX5_IPOOL_FOREACH",
+"MLX5_L3T_FOREACH",
+"OSAL_LIST_FOR_EACH_ENTRY",
+"OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+"PLT_TAILQ_FOREACH_SAFE",
+"RTE_BBDEV_FOREACH",
+"RTE_DEV_FOREACH",
+"RTE_DMA_FOREACH_DEV",
+"RTE_EAL_DEVARGS_FOREACH",
+"RTE_ETH_FOREACH_DEV",
+"RTE_ETH_FOREACH_DEV_OF",
+"RTE_ETH_FOREACH_DEV_OWNED_BY",
+"RTE_ETH_FOREACH_DEV_SIBLING",
+"RTE_ETH_FOREACH_MATCHING_DEV",
+"RTE_ETH_FOREACH_VALID_DEV",
+"RTE_GPU_FOREACH",
+"RTE_GPU_FOREACH_CHILD",
+"RTE_GPU_FOREACH_PARENT",
+"RTE_LCORE_FOREACH",
+"RTE_LCORE_FOREACH_WORKER",
+"RTE_TAILQ_FOREACH",
+"RTE_TAILQ_FOREACH_SAFE",
+"SILIST_FOREACH",
+"SLIST_FOREACH",
+"SLIST_FOREACH_FROM",
+"SLIST_FOREACH_FROM_SAFE",
+"SLIST_FOREACH_PREVPTR",
+"SLIST_FOREACH_SAFE",
+"STAILQ_FOREACH",
+"STAILQ_FOREACH_FROM",
+"STAILQ_FOREACH_FROM_SAFE",
+"STAILQ_FOREACH_SAFE",
+"TAILQ_FOREACH",
+"TAILQ_FOREACH_ENTRY",
+"TAILQ_FOREACH_ENTRY_SAFE",
+"TAILQ_FOREACH_FROM",
+"TAILQ_FOREACH_FROM_SAFE",
+"TAILQ_FOREACH_REVERSE",
+"TAILQ_FOREACH_REVERSE_FROM",
+"TAILQ_FOREACH_REVERSE_FROM_SAFE",
+"TAILQ_FOREACH_REVERSE_SAFE",
+"TAILQ_FOREACH_SAFE", ]
-- 
2.34.1



Re: [PATCH v3] devtools: add .clang-format file

2024-05-05 Thread Abdullah Ömer Yamaç
On Sun, May 5, 2024 at 7:18 PM Stephen Hemminger 
wrote:

> On Sat,  4 May 2024 19:18:37 +
> Abdullah Ömer Yamaç  wrote:
>
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> > ---
> >  .clang-format | 138 ++
> >  1 file changed, 138 insertions(+)
> >  create mode 100644 .clang-format
>
> Tried this, but it needs some change to how braces at start of function
> are handled.  For example, this is not how DPDK should look:
>
Are the changes below ok? When I fix these cases, some macros are also
formatted in the same manner.

-#define RTE_RX_OFFLOAD_BIT2STR(_name) \
- { RTE_ETH_RX_OFFLOAD_##_name, #_name }
+#define RTE_RX_OFFLOAD_BIT2STR(_name)  \
+ {  \
+ RTE_ETH_RX_OFFLOAD_##_name, #_name \
+ }


>
>  static int
> -rte_pmd_tap_remove(struct rte_vdev_device *dev)
> -{
> +rte_pmd_tap_remove(struct rte_vdev_device *dev) {
> struct rte_eth_dev *eth_dev = NULL;
>
> /* find the ethdev entry */
>


Re: [PATCH v3] devtools: add .clang-format file

2024-05-05 Thread Abdullah Ömer Yamaç
On Sun, May 5, 2024 at 7:21 PM Stephen Hemminger 
wrote:

> On Sat,  4 May 2024 19:18:37 +
> Abdullah Ömer Yamaç  wrote:
>
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
>
> Also, this looks wrong.  The initialized arrays looked better before.
>
>
> -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
> -   "UNKNOWN", "TUN", "TAP"
> -};
> +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN", "TUN",
> "TAP"};
>
> -static const char *valid_arguments[] = {
> -   ETH_TAP_IFACE_ARG,
> -   ETH_TAP_REMOTE_ARG,
> -   ETH_TAP_MAC_ARG,
> -   ETH_TAP_PERSIST_ARG,
> -   NULL
> -};
> +static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG,
> ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
> +   ETH_TAP_PERSIST_ARG, NULL};
>

I am confused about these variables.  tuntap_types list values in a single
line, but valid_arguments' values are listed separately.
So, it is getting more complex to handle both of them. What should we do,
do you have any idea?


Re: [PATCH v3] devtools: add .clang-format file

2024-05-06 Thread Abdullah Ömer Yamaç
On Sun, May 5, 2024 at 11:38 PM Stephen Hemminger <
step...@networkplumber.org> wrote:

> On Sun, 5 May 2024 22:42:57 +0300
> Abdullah Ömer Yamaç  wrote:
>
> > > Also, this looks wrong.  The initialized arrays looked better before.
> > >
> > >
> > > -static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
> > > -   "UNKNOWN", "TUN", "TAP"
> > > -};
> > > +static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {"UNKNOWN",
> "TUN",
> > > "TAP"};
> > >
> > > -static const char *valid_arguments[] = {
> > > -   ETH_TAP_IFACE_ARG,
> > > -   ETH_TAP_REMOTE_ARG,
> > > -   ETH_TAP_MAC_ARG,
> > > -   ETH_TAP_PERSIST_ARG,
> > > -   NULL
> > > -};
> > > +static const char *valid_arguments[] = {ETH_TAP_IFACE_ARG,
> > > ETH_TAP_REMOTE_ARG, ETH_TAP_MAC_ARG,
> > > +   ETH_TAP_PERSIST_ARG, NULL};
> > >
> >
> > I am confused about these variables.  tuntap_types list values in a
> single
> > line, but valid_arguments' values are listed separately.
> > So, it is getting more complex to handle both of them. What should we do,
> > do you have any idea?
>
> Ignore the initialized lists for now. It should be possible to have it
> generate something
> like
>
> static const char *tuntap_types[ETH_TUNTAP_TYPE_MAX] = {
>   "UNKNOWN", "TUN", "TAP"
> };
>
> With the following changes result looks better. You got the format wrong
> for the ForEach list.
>
> diff --git a/.clang-format b/.clang-format
> index 16164ef1de..d16185c049 100644
> --- a/.clang-format
> +++ b/.clang-format
> @@ -1,12 +1,20 @@
>  ---
>  BasedOnStyle: LLVM
>
> +AttributeMacros:
> +  - __rte_aligned
> +  - __rte_packed
> +  - __rte_may_alias
> +  - __rte_deprecated
> +  - __rte_weak
> +  - __rte_unused
> +  - __rte_restrict
> +
>  # Place opening and closing parentheses on the same line for control
> statements
>  BreakBeforeBraces: Custom
>  BraceWrapping:
> -AfterFunction: false
> +AfterFunction: true
>  AfterControlStatement: false
> -AfterEnum: false
>
> These are ok for me.

>  # Set maximum line length to 100 characters
>  ColumnLimit: 100
> @@ -41,98 +49,117 @@ AlwaysBreakAfterReturnType: TopLevelDefinitions
>  # Always break before multiline string literals
>  AlignEscapedNewlines: Left
>
> -# Foreach macros
>
In the clang documentation, it says "ForEachMacros (List of Strings)" and
gives an example: "ForEachMacros: ['RANGES_FOR', 'FOREACH']"

> ...
> +ObjCSpaceAfterProperty: true
> +IndentGotoLabels: false
>
These are also ok for me.

If you agree on the for-each part, then I will send the new patch.
Thanks


[PATCH v4] devtools: add .clang-format file

2024-05-08 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 141 ++
 1 file changed, 141 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..6d270524f7
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,141 @@
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: true
+AfterControlStatement: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 8 spaces
+ContinuationIndentWidth: 8
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros:
+[
+"CIRBUF_FOREACH",
+"DLB2_LIST_FOR_EACH",
+"DLB2_LIST_FOR_EACH_SAFE",
+"ECORE_LIST_FOR_EACH_ENTRY",
+"ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+"FOR_EACH",
+"FOR_EACH_BUCKET",
+"FOR_EACH_CNIC_QUEUE",
+"FOR_EACH_COS_IN_TX_QUEUE",
+"FOR_EACH_ETH_QUEUE",
+"FOR_EACH_MEMBER",
+"FOR_EACH_NONDEFAULT_ETH_QUEUE",
+"FOR_EACH_NONDEFAULT_QUEUE",
+"FOR_EACH_PORT",
+"FOR_EACH_PORT_IF",
+"FOR_EACH_QUEUE",
+"FOR_EACH_SUITE_TESTCASE",
+"FOR_EACH_SUITE_TESTSUITE",
+"FOREACH_ABS_FUNC_IN_PORT",
+"FOREACH_DEVICE_ON_AUXILIARY_BUS",
+"FOREACH_DEVICE_ON_CDXBUS",
+"FOREACH_DEVICE_ON_PCIBUS",
+"FOREACH_DEVICE_ON_PLATFORM_BUS",
+"FOREACH_DEVICE_ON_UACCEBUS",
+"FOREACH_DEVICE_ON_VMBUS",
+"FOREACH_DRIVER_ON_AUXILIARY_BUS",
+"FOREACH_DRIVER_ON_CDXBUS",
+"FOREACH_DRIVER_ON_PCIBUS",
+"FOREACH_DRIVER_ON_PLATFORM_BUS",
+"FOREACH_DRIVER_ON_UACCEBUS",
+"FOREACH_DRIVER_ON_VMBUS",
+"FOREACH_SUBDEV",
+"FOREACH_SUBDEV_STATE",
+"HLIST_FOR_EACH_ENTRY",
+"ILIST_FOREACH",
+"LIST_FOR_EACH_ENTRY",
+"LIST_FOR_EACH_ENTRY_SAFE",
+"LIST_FOREACH",
+"LIST_FOREACH_FROM",
+"LIST_FOREACH_FROM_SAFE",
+"LIST_FOREACH_SAFE",
+"ML_AVG_FOREACH_QP",
+"ML_AVG_FOREACH_QP_MVTVM",
+"ML_AVG_RESET_FOREACH_QP",
+"ML_MAX_FOREACH_QP",
+"ML_MAX_FOREACH_QP_MVTVM",
+"ML_MAX_RESET_FOREACH_QP",
+"ML_MIN_FOREACH_QP",
+"ML_MIN_FOREACH_QP_MVTVM",
+"ML_MIN_RESET_FOREACH_QP",
+"MLX5_ETH_FOREACH_DEV",
+"MLX5_IPOOL_FOREACH",
+"MLX5_L3T_FOREACH",
+"OSAL_LIST_FOR_EACH_ENTRY",
+"OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+"PLT_TAILQ_FOREACH_SAFE",
+"RTE_BBDEV_FOREACH",
+"RTE_DEV_FOREACH",
+"RTE_DMA_FOREACH_DEV",
+"RTE_EAL_DEVARGS_FOREACH",
+"RTE_ETH_FOREACH_DEV",
+"RTE_ETH_FOREACH_DEV_OF",
+"RTE_ETH_FOREACH_DEV_OWNED

Re: [PATCH v5] lib/hash: add defer queue reclaim API

2024-05-09 Thread Abdullah Ömer Yamaç
Hello,

Any other comments?

On Sat, Apr 27, 2024 at 10:54 PM Abdullah Ömer Yamaç 
wrote:

> This patch adds a new feature to the hash library to allow the user to
> reclaim the defer queue. This is useful when the user wants to force
> reclaim resources that are not being used. This API is only available
> if the RCU is enabled.
>
> Signed-off-by: Abdullah Ömer Yamaç 
> ---
>  app/test/test_hash.c   | 90 ++
>  lib/hash/rte_cuckoo_hash.c | 21 +
>  lib/hash/rte_hash.h| 25 +++
>  lib/hash/version.map   |  7 +++
>  4 files changed, 143 insertions(+)
>
> diff --git a/app/test/test_hash.c b/app/test/test_hash.c
> index d586878a22..e763d0503f 100644
> --- a/app/test/test_hash.c
> +++ b/app/test/test_hash.c
> @@ -2183,6 +2183,93 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
>
>  }
>
> +/*
> + * rte_hash_rcu_qsbr_dq_reclaim unit test.
> + */
> +static int test_hash_rcu_qsbr_dq_reclaim(void)
> +{
> +   size_t sz;
> +   int32_t status;
> +   unsigned int total_entries = 8;
> +   unsigned int freed, pending, available;
> +   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
> +   struct rte_hash_rcu_config rcu_cfg = {0};
> +   struct rte_hash_parameters hash_params = {
> +   .name = "test_hash_rcu_qsbr_dq_reclaim",
> +   .entries = total_entries,
> +   .key_len = sizeof(uint32_t),
> +   .hash_func = NULL,
> +   .hash_func_init_val = 0,
> +   .socket_id = 0,
> +   };
> +
> +   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
> +
> +   g_qsv = NULL;
> +   g_handle = NULL;
> +
> +   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue
> functional test\n");
> +
> +   g_handle = rte_hash_create(&hash_params);
> +   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
> +
> +   /* Create RCU QSBR variable */
> +   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
> +   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
> RTE_CACHE_LINE_SIZE,
> + SOCKET_ID_ANY);
> +   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL, "RCU QSBR variable
> creation failed");
> +
> +   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR variable
> initialization failed");
> +
> +   rcu_cfg.v = g_qsv;
> +   rcu_cfg.dq_size = total_entries;
> +   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
> +
> +   /* Attach RCU QSBR to hash table */
> +   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0, "Attach RCU QSBR to hash
> table failed");
> +
> +   /* Register pseudo reader */
> +   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
> +   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR thread
> registration failed");
> +   rte_rcu_qsbr_thread_online(g_qsv, 0);
> +
> +   /* Fill half of the hash table */
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
> +
> +   /* Lookup inserted elements*/
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   rte_hash_lookup(g_handle, &reclaim_keys[i]);
> +
> +   /* Try to put these elements into the defer queue*/
> +   for (size_t i = 0; i < total_entries / 2; i++)
> +   rte_hash_del_key(g_handle, &reclaim_keys[i]);
> +
> +   /* Reader quiescent */
> +   rte_rcu_qsbr_quiescent(g_qsv, 0);
> +
> +   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
> +   RETURN_IF_ERROR_RCU_QSBR(status < 0, "failed to add key
> (pos[%u]=%d)", 0, status);
> +
> +   /* This should be (total_entries / 2) + 1 (last add) */
> +   unsigned int hash_size = rte_hash_count(g_handle);
> +
> +   /* Freed size should be (total_entries / 2) */
> +   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending,
> &available);
> +
> +   rte_hash_free(g_handle);
> +   rte_free(g_qsv);
> +
> +   if (hash_size != (total_entries / 2 + 1) || freed !=
> (total_entries / 2)) {
> +   printf("Failed to reclaim defer queue\n");
> +   return -1;
> +   }
> +
> +   return 0;
> +}
> +
>  /*
>   * Do all unit and performance tests.
>   */
> @@ -2261,6 +2348,9 @@ test_hash(void)
> if (test_hash_rcu_qsbr_sync_mode(1) < 0)
>   

Re: [PATCH] lib/hash: setting the maximum reclamation size

2024-05-09 Thread Abdullah Ömer Yamaç
Hello,
Is there any comment on this patch?

On Tue, Apr 23, 2024 at 4:51 PM Abdullah Ömer Yamaç 
wrote:

> Hello,
> Any comment on this patch?
>
> On Wed, Apr 17, 2024 at 4:39 PM Abdullah Ömer Yamaç 
> wrote:
>
>> In the previous implementation, the maximum reclamation size was set
>> to RTE_HASH_RCU_DQ_RECLAIM_MAX and it was not configurable. This patch
>> uses the configuration argument to set the maximum reclamation size.
>>
>> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
>> Cc: dharmik.thak...@arm.com
>> Cc: Honnappa Nagarahalli 
>> Cc: Yipeng Wang 
>> Cc: Sameh Gobriel 
>> Cc: Bruce Richardson 
>> Cc: Vladimir Medvedkin 
>>
>> Signed-off-by: Abdullah Ömer Yamaç 
>> ---
>>  lib/hash/rte_cuckoo_hash.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
>> index 4a44aadd9a..6d80793164 100644
>> --- a/lib/hash/rte_cuckoo_hash.c
>> +++ b/lib/hash/rte_cuckoo_hash.c
>> @@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
>> rte_hash_rcu_config *cfg)
>> if (params.size == 0)
>> params.size = total_entries;
>> params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
>> +   params.max_reclaim_size = cfg->max_reclaim_size;
>> if (params.max_reclaim_size == 0)
>> params.max_reclaim_size =
>> RTE_HASH_RCU_DQ_RECLAIM_MAX;
>> params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
>> --
>> 2.34.1
>>
>>


[PATCH v2] lib/hash: Set the maximum reclamation size to user provided value

2024-05-13 Thread Abdullah Ömer Yamaç
In the previous implementation, the maximum reclamation size was set
to RTE_HASH_RCU_DQ_RECLAIM_MAX and it was not configurable. This patch
uses the configuration argument to set the maximum reclamation size.

Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
Cc: dharmik.thak...@arm.com
Cc: Honnappa Nagarahalli 
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..f7f0fdfd21 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
if (params.size == 0)
params.size = total_entries;
params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
+   params.max_reclaim_size = cfg->max_reclaim_size;
if (params.max_reclaim_size == 0)
params.max_reclaim_size = RTE_HASH_RCU_DQ_RECLAIM_MAX;
params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
-- 
2.34.1



Re: [PATCH v2] lib/hash: Set the maximum reclamation size to user provided value

2024-05-13 Thread Abdullah Ömer Yamaç
Hello,
I saw two comments, and the first one
" Please add:
sta...@dpdk.org to the Cc list" then I added sta...@dpdk.org to Cc. Would
you like me to add it to the commit?

Second one :
“Set the maximum reclamation size to user provided value”  I set this
comment to the header. I thought it was more meaningful in the header. If
you want also, I can insert it in the description part.

Do I miss something else?


On Mon, May 13, 2024 at 5:34 PM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

> Hi Abdullah,
> I do not see the changes I suggested in this version.
>
> > On May 13, 2024, at 5:00 AM, Abdullah Ömer Yamaç 
> wrote:
> >
> > In the previous implementation, the maximum reclamation size was set
> > to RTE_HASH_RCU_DQ_RECLAIM_MAX and it was not configurable. This patch
> > uses the configuration argument to set the maximum reclamation size.
> >
> > Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
> > Cc: dharmik.thak...@arm.com
> > Cc: Honnappa Nagarahalli 
> > Cc: Yipeng Wang 
> > Cc: Sameh Gobriel 
> > Cc: Bruce Richardson 
> > Cc: Vladimir Medvedkin 
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> > ---
> > lib/hash/rte_cuckoo_hash.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> > index 9cf94645f6..f7f0fdfd21 100644
> > --- a/lib/hash/rte_cuckoo_hash.c
> > +++ b/lib/hash/rte_cuckoo_hash.c
> > @@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
> rte_hash_rcu_config *cfg)
> > if (params.size == 0)
> > params.size = total_entries;
> > params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
> > + params.max_reclaim_size = cfg->max_reclaim_size;
> > if (params.max_reclaim_size == 0)
> > params.max_reclaim_size = RTE_HASH_RCU_DQ_RECLAIM_MAX;
> > params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
> > --
> > 2.34.1
> >
>
>


Re: [PATCH v5] lib/hash: add defer queue reclaim API

2024-05-13 Thread Abdullah Ömer Yamaç
Hello,
That's my mistake and I will discard the lookup part. While I was
implementing these parts, I thought that readers should not be in a
quiescent state, and I just wanted to make sure that these values were in
use and the reader was in the critical section.

Thanks I will fix ASAP

On Mon, May 13, 2024 at 8:25 AM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

> Hi Abdullah,
> This looks good, except for one comment inline.
>
> > On Apr 27, 2024, at 2:54 PM, Abdullah Ömer Yamaç 
> wrote:
> >
> > This patch adds a new feature to the hash library to allow the user to
> > reclaim the defer queue. This is useful when the user wants to force
> > reclaim resources that are not being used. This API is only available
> > if the RCU is enabled.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> > ---
> > app/test/test_hash.c   | 90 ++
> > lib/hash/rte_cuckoo_hash.c | 21 +
> > lib/hash/rte_hash.h| 25 +++
> > lib/hash/version.map   |  7 +++
> > 4 files changed, 143 insertions(+)
> >
> > diff --git a/app/test/test_hash.c b/app/test/test_hash.c
> > index d586878a22..e763d0503f 100644
> > --- a/app/test/test_hash.c
> > +++ b/app/test/test_hash.c
> > @@ -2183,6 +2183,93 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
> >
> > }
> >
> > +/*
> > + * rte_hash_rcu_qsbr_dq_reclaim unit test.
> > + */
> > +static int test_hash_rcu_qsbr_dq_reclaim(void)
> > +{
> > + size_t sz;
> > + int32_t status;
> > + unsigned int total_entries = 8;
> > + unsigned int freed, pending, available;
> > + uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
> > + struct rte_hash_rcu_config rcu_cfg = {0};
> > + struct rte_hash_parameters hash_params = {
> > +.name = "test_hash_rcu_qsbr_dq_reclaim",
> > +.entries = total_entries,
> > +.key_len = sizeof(uint32_t),
> > +.hash_func = NULL,
> > +.hash_func_init_val = 0,
> > +.socket_id = 0,
> > + };
> > +
> > + hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
> > +
> > + g_qsv = NULL;
> > + g_handle = NULL;
> > +
> > + printf("\n# Running RCU QSBR DQ mode, reclaim defer queue functional
> test\n");
> > +
> > + g_handle = rte_hash_create(&hash_params);
> > + RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
> > +
> > + /* Create RCU QSBR variable */
> > + sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
> > + g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
> RTE_CACHE_LINE_SIZE,
> > +  SOCKET_ID_ANY);
> > + RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL, "RCU QSBR variable creation
> failed");
> > +
> > + status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
> > + RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR variable
> initialization failed");
> > +
> > + rcu_cfg.v = g_qsv;
> > + rcu_cfg.dq_size = total_entries;
> > + rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
> > +
> > + /* Attach RCU QSBR to hash table */
> > + status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
> > + RETURN_IF_ERROR_RCU_QSBR(status != 0, "Attach RCU QSBR to hash table
> failed");
> > +
> > + /* Register pseudo reader */
> > + status = rte_rcu_qsbr_thread_register(g_qsv, 0);
> > + RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR thread registration
> failed");
> > + rte_rcu_qsbr_thread_online(g_qsv, 0);
> > +
> > + /* Fill half of the hash table */
> > + for (size_t i = 0; i < total_entries / 2; i++)
> > + status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
> > +
> > + /* Lookup inserted elements*/
> > + for (size_t i = 0; i < total_entries / 2; i++)
> > + rte_hash_lookup(g_handle, &reclaim_keys[i]);
> Why do we need to lookup the entries?
>
> > +
> > + /* Try to put these elements into the defer queue*/
> > + for (size_t i = 0; i < total_entries / 2; i++)
> > + rte_hash_del_key(g_handle, &reclaim_keys[i]);
> > +
> > + /* Reader quiescent */
> > + rte_rcu_qsbr_quiescent(g_qsv, 0);
> > +
> > + status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
> > + RETURN_IF_ERROR_RCU_QSBR(status < 0, "failed to add key (pos[%u]=%d)",
> 0, status);
> > +
> > + /* This should be (total_entries / 2) + 1 (last add) */
> > + unsigned int hash_size = rte_hash_count(g_handle);
> > +
> > + /* Freed size should be (total_entries / 2) */
> > + rte_hash_rcu_qsb

[PATCH v3] lib/hash: setting the maximum reclamation size

2024-05-13 Thread Abdullah Ömer Yamaç
Set the maximum reclamation size to user provided value

Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
Cc: sta...@dpdk.org
Cc: dharmik.thak...@arm.com
Cc: Honnappa Nagarahalli 
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..f7f0fdfd21 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
if (params.size == 0)
params.size = total_entries;
params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
+   params.max_reclaim_size = cfg->max_reclaim_size;
if (params.max_reclaim_size == 0)
params.max_reclaim_size = RTE_HASH_RCU_DQ_RECLAIM_MAX;
params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
-- 
2.34.1



Re: [PATCH v4] devtools: add .clang-format file

2024-05-15 Thread Abdullah Ömer Yamaç
I want to update you.

On Mon, May 13, 2024 at 4:08 PM Ferruh Yigit  wrote:

> On 5/8/2024 10:19 PM, Abdullah Ömer Yamaç wrote:
> > clang-format is a tool to format C/C++/Objective-C code. It can be used
> > to reformat code to match a given coding style, or to ensure that code
> > adheres to a specific coding style. It helps to maintain a consistent
> > coding style across the DPDK codebase.
> >
> > .clang-format file overrides the default style options provided by
> > clang-format and large set of IDEs and text editors support it.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> >
>
> Hi Omer,
>
> I tried on ethdev.c (clang-format -i ./lib/ethdev/rte_ethdev.c), I will
> highlight a few issues below (not all of them), I hope it is OK to
> continue step by step, fixing these issues.
>
> 1. clang format failed for following options, not sure why, am I using a
> wrong version:
> LineEnding: LF
> InsertNewlineAtEOF: true
>
> I commented them out to continue the test.
>
> And for 'ColumnLimit', I prefer default 80 with the flexibility to go
> 100 when makes sense, so I will got with 'ColumnLimit: 80'; but I don't
> want to start this discussion.
>
> In the .editorconfig file, 100 is stated as a max_line_length. That's why
I prefer 100.

>
> 2. Double tab indentation vs parenthesis align
>  if (iter->bus != NULL &&
>  -   /* not in middle of rte_eth_dev iteration, */
>  -   iter->class_device == NULL) {
>  +   /* not in middle of rte_eth_dev iteration, */
>  +   iter->class_device == NULL) {
>
> DPDK coding guide suggests double tab, but also accepts alignment by
> spaces. But as far as I can see most of code has double tab.
> Majority of the diff caused because of this rule.
>
> Still, some discussions are going on

>
> 3. enum merged into single line
>  -enum {
>  -   STAT_QMAP_TX = 0,
>  -   STAT_QMAP_RX
>  -};
>  +enum { STAT_QMAP_TX = 0, STAT_QMAP_RX };
>
> This is ok; I will send a new patch for it.

>
> 4. split message strings
>  - RTE_ETHDEV_LOG_LINE(ERR,
>  - "Cannot initialize iterator from NULL device description
> string");
>  + RTE_ETHDEV_LOG_LINE(ERR, "Cannot initialize iterator from NULL "
>  +  "device description string");
>
>
> 5. Empty open parenthesis
>  -   RTE_ETHDEV_LOG_LINE(ERR,
>  -   "Cannot get next device from NULL iterator");
>  +   RTE_ETHDEV_LOG_LINE(
>  +   ERR, "Cannot get next device from NULL iterator");
>
> I couldn't find a solution, so I am still working on it.

>
> 6. space before macro arguments
> -   RTE_ETH_FOREACH_DEV(p)
> +   RTE_ETH_FOREACH_DEV (p)
>
> This is ok. The fix will be in the next patch.

>
> 7. some lists get merged (this seems similar to 3.)
>  -   RTE_PTYPE_L2_MASK,
>  -   RTE_PTYPE_L3_MASK,
>  -   RTE_PTYPE_L4_MASK,
>  -   RTE_PTYPE_TUNNEL_MASK,
>  -   RTE_PTYPE_INNER_L2_MASK,
>  -   RTE_PTYPE_INNER_L3_MASK,
>  +   RTE_PTYPE_L2_MASK,   RTE_PTYPE_L3_MASK,
>  +   RTE_PTYPE_L4_MASK,   RTE_PTYPE_TUNNEL_MASK,
>  +   RTE_PTYPE_INNER_L2_MASK, RTE_PTYPE_INNER_L3_MASK,
>
> I couldn't find a configuration that aligns with array initialization.

>
>
> Thanks,
> ferruh
>


Re: [PATCH v4] devtools: add .clang-format file

2024-05-15 Thread Abdullah Ömer Yamaç
On Wed, May 15, 2024 at 11:43 AM Bruce Richardson <
bruce.richard...@intel.com> wrote:

> On Wed, May 15, 2024 at 11:28:33AM +0300, Abdullah Ömer Yamaç wrote:
> >I want to update you.
> >On Mon, May 13, 2024 at 4:08 PM Ferruh Yigit <[1]ferruh.yi...@amd.com
> >
> >wrote:
> >
> >  On 5/8/2024 10:19 PM, Abdullah Ömer Yamaç wrote:
> >  > clang-format is a tool to format C/C++/Objective-C code. It can be
> >  used
> >  > to reformat code to match a given coding style, or to ensure that
> >  code
> >  > adheres to a specific coding style. It helps to maintain a
> >  consistent
> >  > coding style across the DPDK codebase.
> >  >
> >  > .clang-format file overrides the default style options provided by
> >  > clang-format and large set of IDEs and text editors support it.
> >  >
> >  > Signed-off-by: Abdullah Ömer Yamaç <[2]aomerya...@gmail.com>
> >  >
> >  Hi Omer,
> >  I tried on ethdev.c (clang-format -i ./lib/ethdev/rte_ethdev.c), I
> >  will
> >  highlight a few issues below (not all of them), I hope it is OK to
> >  continue step by step, fixing these issues.
> >  1. clang format failed for following options, not sure why, am I
> >  using a
> >  wrong version:
> >  LineEnding: LF
> >  InsertNewlineAtEOF: true
> >  I commented them out to continue the test.
> >  And for 'ColumnLimit', I prefer default 80 with the flexibility to
> >  go
> >  100 when makes sense, so I will got with 'ColumnLimit: 80'; but I
> >  don't
> >  want to start this discussion.
> >
> >In the .editorconfig file, 100 is stated as a max_line_length. That's
> >why I prefer 100.
> >
>
> +1 for keeping as 100
>
> >  2. Double tab indentation vs parenthesis align
> >   if (iter->bus != NULL &&
> >   -   /* not in middle of rte_eth_dev iteration,
> >  */
> >   -   iter->class_device == NULL) {
> >   +   /* not in middle of rte_eth_dev iteration, */
> >   +   iter->class_device == NULL) {
> >  DPDK coding guide suggests double tab, but also accepts alignment by
> >  spaces. But as far as I can see most of code has double tab.
> >  Majority of the diff caused because of this rule.
> >
> >Still, some discussions are going on
> >
>
> This is one where I don't think we will were reach a consensus, and even if
> we did, it would mean massive churn to DPDK. Can we have clang-format NOT
> adjust line-continuations in a file?
>
> I am not an expert on clang, but it seems we don't have such a
configuration.
There is an option called "AlignAfterOpenBracket" which horizontally aligns
arguments after an open bracket.
if I set it to "DontAlign" then "ContinuationIndentWidth" will be active.
Depending on the value of ContinuationIndentWidth, two tabs, single tabs,
or spaces will be acceptable.

> Thanks,
> /Bruce
>


[PATCH v5] lib/hash: add defer queue reclaim API

2024-05-15 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 app/test/test_hash.c   | 88 ++
 lib/hash/rte_cuckoo_hash.c | 23 ++
 lib/hash/rte_hash.h| 24 +++
 lib/hash/version.map   |  7 +++
 4 files changed, 142 insertions(+)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index d586878a22..b8e4e76c46 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -2183,6 +2183,91 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
 
 }
 
+/*
+ * rte_hash_rcu_qsbr_dq_reclaim unit test.
+ */
+static int
+test_hash_rcu_qsbr_dq_reclaim(void)
+{
+   size_t sz;
+   int32_t status;
+   unsigned int total_entries = 8;
+   unsigned int freed, pending, available;
+   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
+   struct rte_hash_rcu_config rcu_cfg = {0};
+   struct rte_hash_parameters hash_params = {
+   .name = "test_hash_rcu_qsbr_dq_reclaim",
+   .entries = total_entries,
+   .key_len = sizeof(uint32_t),
+   .hash_func = NULL,
+   .hash_func_init_val = 0,
+   .socket_id = 0,
+   };
+
+   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
+
+   g_qsv = NULL;
+   g_handle = NULL;
+
+   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue functional 
test\n");
+
+   g_handle = rte_hash_create(&hash_params);
+   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
+
+   /* Create RCU QSBR variable */
+   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
+   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(
+   NULL, sz, RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
+   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL, "RCU QSBR variable creation 
failed");
+
+   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR variable initialization 
failed");
+
+   rcu_cfg.v = g_qsv;
+   rcu_cfg.dq_size = total_entries;
+   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
+
+   /* Attach RCU QSBR to hash table */
+   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "Attach RCU QSBR to hash table 
failed");
+
+   /* Register pseudo reader */
+   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR thread registration 
failed");
+   rte_rcu_qsbr_thread_online(g_qsv, 0);
+
+   /* Fill half of the hash table */
+   for (size_t i = 0; i < total_entries / 2; i++)
+   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
+
+   /* Try to put these elements into the defer queue*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_del_key(g_handle, &reclaim_keys[i]);
+
+   /* Reader quiescent */
+   rte_rcu_qsbr_quiescent(g_qsv, 0);
+
+   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
+   RETURN_IF_ERROR_RCU_QSBR(status < 0, "failed to add key (pos[%u]=%d)", 
0, status);
+
+   /* This should be (total_entries / 2) + 1 (last add) */
+   unsigned int hash_size = rte_hash_count(g_handle);
+
+   /* Freed size should be (total_entries / 2) */
+   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending, &available);
+
+   rte_hash_free(g_handle);
+   rte_free(g_qsv);
+
+   if (hash_size != (total_entries / 2 + 1) || freed != (total_entries / 
2)) {
+   printf("Failed to reclaim defer queue\n");
+   return -1;
+   }
+
+   return 0;
+}
+
+
 /*
  * Do all unit and performance tests.
  */
@@ -2261,6 +2346,9 @@ test_hash(void)
if (test_hash_rcu_qsbr_sync_mode(1) < 0)
return -1;
 
+   if (test_hash_rcu_qsbr_dq_reclaim() < 0)
+   return -1;
+
return 0;
 }
 
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..4a44aadd9a 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int 
*available)
+{
+   int ret;
+
+   if (h == NULL || h->hash_rcu_cfg == NULL) {
+   rte_errno = EINVAL;
+   return 1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_

[PATCH v6] lib/hash: add defer queue reclaim API

2024-05-15 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 app/test/test_hash.c   | 87 ++
 lib/hash/rte_cuckoo_hash.c | 21 +
 lib/hash/rte_hash.h| 25 +++
 lib/hash/version.map   |  7 +++
 4 files changed, 140 insertions(+)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index d586878a22..24d3b547ad 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -2183,6 +2183,90 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
 
 }
 
+/*
+ * rte_hash_rcu_qsbr_dq_reclaim unit test.
+ */
+static int
+test_hash_rcu_qsbr_dq_reclaim(void)
+{
+   size_t sz;
+   int32_t status;
+   unsigned int total_entries = 8;
+   unsigned int freed, pending, available;
+   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
+   struct rte_hash_rcu_config rcu_cfg = {0};
+   struct rte_hash_parameters hash_params = {
+   .name = "test_hash_rcu_qsbr_dq_reclaim",
+   .entries = total_entries,
+   .key_len = sizeof(uint32_t),
+   .hash_func = NULL,
+   .hash_func_init_val = 0,
+   .socket_id = 0,
+   };
+
+   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
+
+   g_qsv = NULL;
+   g_handle = NULL;
+
+   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue functional 
test\n");
+
+   g_handle = rte_hash_create(&hash_params);
+   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
+
+   /* Create RCU QSBR variable */
+   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
+   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(
+   NULL, sz, RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
+   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL, "RCU QSBR variable creation 
failed");
+
+   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR variable initialization 
failed");
+
+   rcu_cfg.v = g_qsv;
+   rcu_cfg.dq_size = total_entries;
+   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
+
+   /* Attach RCU QSBR to hash table */
+   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "Attach RCU QSBR to hash table 
failed");
+
+   /* Register pseudo reader */
+   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0, "RCU QSBR thread registration 
failed");
+   rte_rcu_qsbr_thread_online(g_qsv, 0);
+
+   /* Fill half of the hash table */
+   for (size_t i = 0; i < total_entries / 2; i++)
+   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
+
+   /* Try to put these elements into the defer queue*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_del_key(g_handle, &reclaim_keys[i]);
+
+   /* Reader quiescent */
+   rte_rcu_qsbr_quiescent(g_qsv, 0);
+
+   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
+   RETURN_IF_ERROR_RCU_QSBR(status < 0, "failed to add key (pos[%u]=%d)", 
0, status);
+
+   /* This should be (total_entries / 2) + 1 (last add) */
+   unsigned int hash_size = rte_hash_count(g_handle);
+
+   /* Freed size should be (total_entries / 2) */
+   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending, &available);
+
+   rte_hash_free(g_handle);
+   rte_free(g_qsv);
+
+   if (hash_size != (total_entries / 2 + 1) || freed != (total_entries / 
2)) {
+   printf("Failed to reclaim defer queue\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 /*
  * Do all unit and performance tests.
  */
@@ -2261,6 +2345,9 @@ test_hash(void)
if (test_hash_rcu_qsbr_sync_mode(1) < 0)
return -1;
 
+   if (test_hash_rcu_qsbr_dq_reclaim() < 0)
+   return -1;
+
return 0;
 }
 
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..52ccada12a 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed, 
unsigned int *pending,
+unsigned int *available)
+{
+   int ret;
+
+   if (h == NULL || h->hash_rcu_cfg == NULL) {
+   HASH_LOG(ERR, "Invalid input parameter");
+   rte_errno = EINVAL;
+   return 1;
+   }
+
+   ret = rte

Re: [PATCH v4] devtools: add .clang-format file

2024-05-15 Thread Abdullah Ömer Yamaç
On Wed, May 15, 2024 at 6:07 PM Stephen Hemminger <
step...@networkplumber.org> wrote:

> On Wed, 15 May 2024 09:43:22 +0100
> Bruce Richardson  wrote:
>
> > On Wed, May 15, 2024 at 11:28:33AM +0300, Abdullah Ömer Yamaç wrote:
> > >I want to update you.
> > >On Mon, May 13, 2024 at 4:08 PM Ferruh Yigit <[1]
> ferruh.yi...@amd.com>
> > >    wrote:
> > >
> > >  On 5/8/2024 10:19 PM, Abdullah Ömer Yamaç wrote:
> > >  > clang-format is a tool to format C/C++/Objective-C code. It can
> be
> > >  used
> > >  > to reformat code to match a given coding style, or to ensure
> that
> > >  code
> > >  > adheres to a specific coding style. It helps to maintain a
> > >  consistent
> > >  > coding style across the DPDK codebase.
> > >  >
> > >  > .clang-format file overrides the default style options provided
> by
> > >  > clang-format and large set of IDEs and text editors support it.
> > >  >
> > >  > Signed-off-by: Abdullah Ömer Yamaç <[2]aomerya...@gmail.com>
> > >  >
> > >  Hi Omer,
> > >  I tried on ethdev.c (clang-format -i ./lib/ethdev/rte_ethdev.c), I
> > >  will
> > >  highlight a few issues below (not all of them), I hope it is OK to
> > >  continue step by step, fixing these issues.
> > >  1. clang format failed for following options, not sure why, am I
> > >  using a
> > >  wrong version:
> > >  LineEnding: LF
> > >  InsertNewlineAtEOF: true
> > >  I commented them out to continue the test.
> > >  And for 'ColumnLimit', I prefer default 80 with the flexibility to
> > >  go
> > >  100 when makes sense, so I will got with 'ColumnLimit: 80'; but I
> > >  don't
> > >  want to start this discussion.
> > >
> > >In the .editorconfig file, 100 is stated as a max_line_length.
> That's
> > >why I prefer 100.
> > >
> >
> > +1 for keeping as 100
> >
> > >  2. Double tab indentation vs parenthesis align
> > >   if (iter->bus != NULL &&
> > >   -   /* not in middle of rte_eth_dev
> iteration,
> > >  */
> > >   -   iter->class_device == NULL) {
> > >   +   /* not in middle of rte_eth_dev iteration, */
> > >   +   iter->class_device == NULL) {
> > >  DPDK coding guide suggests double tab, but also accepts alignment
> by
> > >  spaces. But as far as I can see most of code has double tab.
> > >  Majority of the diff caused because of this rule.
> > >
> > >Still, some discussions are going on
> > >
> >
> > This is one where I don't think we will were reach a consensus, and even
> if
> > we did, it would mean massive churn to DPDK. Can we have clang-format NOT
> > adjust line-continuations in a file?
>
>
> Clang format is useful on new and seriously broken code.
> Do not want to do it automatically or accept patches across all the
> current code.
>
> For indentation, can we get some setting that matches what DPDK double tab
> does?
>
It seems possible. If there is no objection, I will send a new patch with
the previous notes Ferruh stated.

> If not is there something close. Often useful to look at the other clang
> format
> pre-set styles in source.
>


[PATCH v5] devtools: add .clang-format file

2024-05-16 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 149 ++
 1 file changed, 149 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..5f86e1be79
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,149 @@
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: true
+AfterControlStatement: false
+
+AllowShortEnumsOnASingleLine: false
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+AfterForeachMacros: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 16 spaces (2 tabs)
+AlignAfterOpenBracket: DontAlign
+ContinuationIndentWidth: 16
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros:
+[
+"CIRBUF_FOREACH",
+"DLB2_LIST_FOR_EACH",
+"DLB2_LIST_FOR_EACH_SAFE",
+"ECORE_LIST_FOR_EACH_ENTRY",
+"ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+"FOR_EACH",
+"FOR_EACH_BUCKET",
+"FOR_EACH_CNIC_QUEUE",
+"FOR_EACH_COS_IN_TX_QUEUE",
+"FOR_EACH_ETH_QUEUE",
+"FOR_EACH_MEMBER",
+"FOR_EACH_NONDEFAULT_ETH_QUEUE",
+"FOR_EACH_NONDEFAULT_QUEUE",
+"FOR_EACH_PORT",
+"FOR_EACH_PORT_IF",
+"FOR_EACH_QUEUE",
+"FOR_EACH_SUITE_TESTCASE",
+"FOR_EACH_SUITE_TESTSUITE",
+"FOREACH_ABS_FUNC_IN_PORT",
+"FOREACH_DEVICE_ON_AUXILIARY_BUS",
+"FOREACH_DEVICE_ON_CDXBUS",
+"FOREACH_DEVICE_ON_PCIBUS",
+"FOREACH_DEVICE_ON_PLATFORM_BUS",
+"FOREACH_DEVICE_ON_UACCEBUS",
+"FOREACH_DEVICE_ON_VMBUS",
+"FOREACH_DRIVER_ON_AUXILIARY_BUS",
+"FOREACH_DRIVER_ON_CDXBUS",
+"FOREACH_DRIVER_ON_PCIBUS",
+"FOREACH_DRIVER_ON_PLATFORM_BUS",
+"FOREACH_DRIVER_ON_UACCEBUS",
+"FOREACH_DRIVER_ON_VMBUS",
+"FOREACH_SUBDEV",
+"FOREACH_SUBDEV_STATE",
+"HLIST_FOR_EACH_ENTRY",
+"ILIST_FOREACH",
+"LIST_FOR_EACH_ENTRY",
+"LIST_FOR_EACH_ENTRY_SAFE",
+"LIST_FOREACH",
+"LIST_FOREACH_FROM",
+"LIST_FOREACH_FROM_SAFE",
+"LIST_FOREACH_SAFE",
+"ML_AVG_FOREACH_QP",
+"ML_AVG_FOREACH_QP_MVTVM",
+"ML_AVG_RESET_FOREACH_QP",
+"ML_MAX_FOREACH_QP",
+"ML_MAX_FOREACH_QP_MVTVM",
+"ML_MAX_RESET_FOREACH_QP",
+"ML_MIN_FOREACH_QP",
+"ML_MIN_FOREACH_QP_MVTVM",
+"ML_MIN_RESET_FOREACH_QP",
+"MLX5_ETH_FOREACH_DEV",
+"MLX5_IPOOL_FOREACH",
+"MLX5_L3T_FOREACH",
+"OSAL_LIST_FOR_EACH_ENTRY",
+"OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+"PLT_TAILQ_FOREACH_SAFE",
+"RTE_BBDEV_FOREACH",
+"RTE_DEV_FOREACH",
+"RTE_DMA_FOREACH_DEV",
+  

Re: [PATCH v2] lib/hash: feature reclaim defer queue

2024-03-04 Thread Abdullah Ömer Yamaç
Just one more question.

On Sun, Mar 3, 2024 at 10:14 PM Honnappa Nagarahalli <
honnappa.nagaraha...@arm.com> wrote:

> Hello Abdullah,
> Thank you for the patch, few comments inline.
>
> The short commit log could be changed as follows:
>
> "lib/hash: add defer queue reclaim API”
>
> > On Mar 2, 2024, at 3:27 PM, Abdullah Ömer Yamaç 
> wrote:
> >
> > This patch adds a new feature to the hash library to allow the user to
> > reclaim the defer queue. This is useful when the user wants to force
> > reclaim resources that are not being used. This API is only available
> > if the RCU is enabled.
> >
> > Signed-off-by: Abdullah Ömer Yamaç 
> > Acked-by: Honnappa Nagarahalli 
> Please add this only after you get an explicit Ack on the patch.
>
> > ---
> > lib/hash/rte_cuckoo_hash.c | 23 +++
> > lib/hash/rte_hash.h| 14 ++
> > lib/hash/version.map   |  7 +++
> > 3 files changed, 44 insertions(+)
> >
> > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> > index 9cf94645f6..254fa80cc5 100644
> > --- a/lib/hash/rte_cuckoo_hash.c
> > +++ b/lib/hash/rte_cuckoo_hash.c
> > @@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
> rte_hash_rcu_config *cfg)
> > return 0;
> > }
> >
> > +int
> > +rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h)
> We need to add freed, pending and available parameters to this API. I
> think this information will be helpful for the users. For ex: in your use
> case, you could use the pending value to calculate the available hash
> entries.
>
> The second parameter, "Maximum number of resources to free.", should be
available also? I set this value to " h->hash_rcu_cfg->max_reclaim_size",
but it can be a parameter in addition to the above parameters

> > +{
> > + int ret;
> > +
> > + if (h->hash_rcu_cfg == NULL || h->dq == NULL) {
> We can skip NULL check for h->dq as the RCU reclaim API makes the same
> check.
>
> > + rte_errno = EINVAL;
> > + return -1;
> > + }
> > +
> > + ret = rte_rcu_qsbr_dq_reclaim(h->dq,
> h->hash_rcu_cfg->max_reclaim_size, NULL, NULL, NULL);
> > + if (ret != 0) {
> > + HASH_LOG(ERR,
> > + "%s: could not reclaim the defer queue in hash table",
> > + __func__);
> > + return -1;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > static inline void
> > remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
> > unsigned int i)
> > diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
> > index 7ecc02..c119477d50 100644
> > --- a/lib/hash/rte_hash.h
> > +++ b/lib/hash/rte_hash.h
> > @@ -674,6 +674,21 @@ rte_hash_iterate(const struct rte_hash *h, const
> void **key, void **data, uint32
> >  */
> > int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config
> *cfg);
> >
> > +/**
> > + * Reclaim resources from the defer queue.
> > + * This API reclaim the resources from the defer queue if rcu is
> enabled.
> > + *
> > + * @param h
> > + *   the hash object to reclaim resources
> > + * @return
> > + *   On success - 0
> > + *   On error - 1 with error code set in rte_errno.
> > + *   Possible rte_errno codes are:
> > + *   - EINVAL - invalid pointer or invalid rcu mode
> We can remove the ‘invalid rcd mode’.
>
> > + */
> > +__rte_experimental
> > +int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h);
> > +
> > #ifdef __cplusplus
> > }
> > #endif
> > diff --git a/lib/hash/version.map b/lib/hash/version.map
> > index 6b2afebf6b..cec0e8fc67 100644
> > --- a/lib/hash/version.map
> > +++ b/lib/hash/version.map
> > @@ -48,3 +48,9 @@ DPDK_24 {
> >
> > local: *;
> > };
> > +
> > +EXPERIMENTAL {
> > + global:
> > +
> > + rte_hash_rcu_qsbr_dq_reclaim;
> > +}
> > \ No newline at end of file
> > --
> > 2.34.1
> >
>
>


[PATCH v3] lib/hash: add defer queue reclaim API

2024-03-06 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 23 +++
 lib/hash/rte_hash.h| 28 +++-
 lib/hash/version.map   |  6 ++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..ecc124f1fc 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available)
+{
+   int ret;
+
+   if (h->hash_rcu_cfg == NULL) {
+   rte_errno = EINVAL;
+   return -1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size,
+   freed, pending, 
available);
+   if (ret != 0) {
+   HASH_LOG(ERR,
+   "%s: could not reclaim the defer queue in hash table",
+   __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
 static inline void
 remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..ad13792dbb 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -631,7 +631,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash 
*h,
  */
 int
 rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys,
- uint32_t num_keys, int32_t *positions);
+   uint32_t num_keys, int32_t *positions);
 
 /**
  * Iterate through the hash table, returning key-value pairs.
@@ -674,6 +674,32 @@ rte_hash_iterate(const struct rte_hash *h, const void 
**key, void **data, uint32
  */
 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
 
+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.
+ *
+ * @param h
+ *   The hash object to reclaim resources.
+ * @param n
+ *   Maximum number of resources to free.
+ * @param freed
+ *   Number of resources that were freed.
+ * @param pending
+ *   Number of resources pending on the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @param available
+ *   Number of resources that can be added to the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @return
+ *   On success - 0
+ *   On error - 1 with error code set in rte_errno.
+ *   Possible rte_errno codes are:
+ *   - EINVAL - invalid pointer
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..fac7f81e6f 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,9 @@ DPDK_24 {
 
local: *;
 };
+
+EXPERIMENTAL {
+   global:
+
+   rte_hash_rcu_qsbr_dq_reclaim;
+};
\ No newline at end of file
-- 
2.34.1



[PATCH v3] lib/hash: add defer queue reclaim API

2024-03-06 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 23 +++
 lib/hash/rte_hash.h| 28 +++-
 lib/hash/version.map   |  6 ++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..ecc124f1fc 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available)
+{
+   int ret;
+
+   if (h->hash_rcu_cfg == NULL) {
+   rte_errno = EINVAL;
+   return -1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size,
+   freed, pending, 
available);
+   if (ret != 0) {
+   HASH_LOG(ERR,
+   "%s: could not reclaim the defer queue in hash table",
+   __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
 static inline void
 remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..ad13792dbb 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -674,6 +674,32 @@ rte_hash_iterate(const struct rte_hash *h, const void 
**key, void **data, uint32
  */
 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
 
+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.
+ *
+ * @param h
+ *   The hash object to reclaim resources.
+ * @param n
+ *   Maximum number of resources to free.
+ * @param freed
+ *   Number of resources that were freed.
+ * @param pending
+ *   Number of resources pending on the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @param available
+ *   Number of resources that can be added to the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @return
+ *   On success - 0
+ *   On error - 1 with error code set in rte_errno.
+ *   Possible rte_errno codes are:
+ *   - EINVAL - invalid pointer
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..fac7f81e6f 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,9 @@ DPDK_24 {
 
local: *;
 };
+
+EXPERIMENTAL {
+   global:
+
+   rte_hash_rcu_qsbr_dq_reclaim;
+};
\ No newline at end of file
-- 
2.34.1



[PATCH v3] lib/hash: add defer queue reclaim API

2024-03-06 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 23 +++
 lib/hash/rte_hash.h| 24 
 lib/hash/version.map   |  6 ++
 3 files changed, 53 insertions(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..1c360fa38b 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
return 0;
 }
 
+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available)
+{
+   int ret;
+
+   if (h->hash_rcu_cfg == NULL) {
+   rte_errno = EINVAL;
+   return -1;
+   }
+
+   ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size,
+   freed, pending, 
available);
+   if (ret != 0) {
+   HASH_LOG(ERR,
+   "%s: could not reclaim the defer queue in hash table",
+   __func__);
+   return -1;
+   }
+
+   return 0;
+}
+
 static inline void
 remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc02..edfa262aca 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -674,6 +674,30 @@ rte_hash_iterate(const struct rte_hash *h, const void 
**key, void **data, uint32
  */
 int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);
 
+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.
+ *
+ * @param h
+ *   The hash object to reclaim resources.
+ * @param freed
+ *   Number of resources that were freed.
+ * @param pending
+ *   Number of resources pending on the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @param available
+ *   Number of resources that can be added to the defer queue.
+ *   This number might not be accurate if multi-thread safety is configured.
+ * @return
+ *   On success - 0
+ *   On error - 1 with error code set in rte_errno.
+ *   Possible rte_errno codes are:
+ *   - EINVAL - invalid pointer
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+   unsigned int *pending, unsigned int *available);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..fac7f81e6f 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,9 @@ DPDK_24 {
 
local: *;
 };
+
+EXPERIMENTAL {
+   global:
+
+   rte_hash_rcu_qsbr_dq_reclaim;
+};
\ No newline at end of file
-- 
2.34.1



Re: [PATCH v3] lib/hash: add defer queue reclaim API

2024-03-14 Thread Abdullah Ömer Yamaç
Hello,
Is there any other comment on this?

On Wed, Mar 6, 2024 at 1:13 PM Abdullah Ömer Yamaç 
wrote:

> This patch adds a new feature to the hash library to allow the user to
> reclaim the defer queue. This is useful when the user wants to force
> reclaim resources that are not being used. This API is only available
> if the RCU is enabled.
>
> Signed-off-by: Abdullah Ömer Yamaç 
> ---
>  lib/hash/rte_cuckoo_hash.c | 23 +++
>  lib/hash/rte_hash.h| 24 
>  lib/hash/version.map   |  6 ++
>  3 files changed, 53 insertions(+)
>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 9cf94645f6..1c360fa38b 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
> rte_hash_rcu_config *cfg)
> return 0;
>  }
>
> +int
> +rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
> +   unsigned int *pending, unsigned int *available)
> +{
> +   int ret;
> +
> +   if (h->hash_rcu_cfg == NULL) {
> +   rte_errno = EINVAL;
> +   return -1;
> +   }
> +
> +   ret = rte_rcu_qsbr_dq_reclaim(h->dq,
> h->hash_rcu_cfg->max_reclaim_size,
> +   freed, pending,
> available);
> +   if (ret != 0) {
> +   HASH_LOG(ERR,
> +   "%s: could not reclaim the defer queue in hash
> table",
> +   __func__);
> +   return -1;
> +   }
> +
> +   return 0;
> +}
> +
>  static inline void
>  remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
> unsigned int i)
> diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
> index 7ecc02..edfa262aca 100644
> --- a/lib/hash/rte_hash.h
> +++ b/lib/hash/rte_hash.h
> @@ -674,6 +674,30 @@ rte_hash_iterate(const struct rte_hash *h, const void
> **key, void **data, uint32
>   */
>  int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config
> *cfg);
>
> +/**
> + * Reclaim resources from the defer queue.
> + * This API reclaim the resources from the defer queue if rcu is enabled.
> + *
> + * @param h
> + *   The hash object to reclaim resources.
> + * @param freed
> + *   Number of resources that were freed.
> + * @param pending
> + *   Number of resources pending on the defer queue.
> + *   This number might not be accurate if multi-thread safety is
> configured.
> + * @param available
> + *   Number of resources that can be added to the defer queue.
> + *   This number might not be accurate if multi-thread safety is
> configured.
> + * @return
> + *   On success - 0
> + *   On error - 1 with error code set in rte_errno.
> + *   Possible rte_errno codes are:
> + *   - EINVAL - invalid pointer
> + */
> +__rte_experimental
> +int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
> +   unsigned int *pending, unsigned int *available);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> diff --git a/lib/hash/version.map b/lib/hash/version.map
> index 6b2afebf6b..fac7f81e6f 100644
> --- a/lib/hash/version.map
> +++ b/lib/hash/version.map
> @@ -48,3 +48,9 @@ DPDK_24 {
>
> local: *;
>  };
> +
> +EXPERIMENTAL {
> +   global:
> +
> +   rte_hash_rcu_qsbr_dq_reclaim;
> +};
> \ No newline at end of file
> --
> 2.34.1
>
>


Re: [PATCH v3] lib/hash: add defer queue reclaim API

2024-04-04 Thread Abdullah Ömer Yamaç
Hello,
Could you check the last commit?
Thanks

On Thu, Mar 14, 2024 at 10:04 AM Abdullah Ömer Yamaç 
wrote:

> Hello,
> Is there any other comment on this?
>
> On Wed, Mar 6, 2024 at 1:13 PM Abdullah Ömer Yamaç 
> wrote:
>
>> This patch adds a new feature to the hash library to allow the user to
>> reclaim the defer queue. This is useful when the user wants to force
>> reclaim resources that are not being used. This API is only available
>> if the RCU is enabled.
>>
>> Signed-off-by: Abdullah Ömer Yamaç 
>> ---
>>  lib/hash/rte_cuckoo_hash.c | 23 +++
>>  lib/hash/rte_hash.h| 24 
>>  lib/hash/version.map   |  6 ++
>>  3 files changed, 53 insertions(+)
>>
>> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
>> index 9cf94645f6..1c360fa38b 100644
>> --- a/lib/hash/rte_cuckoo_hash.c
>> +++ b/lib/hash/rte_cuckoo_hash.c
>> @@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct
>> rte_hash_rcu_config *cfg)
>> return 0;
>>  }
>>
>> +int
>> +rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
>> +   unsigned int *pending, unsigned int *available)
>> +{
>> +   int ret;
>> +
>> +   if (h->hash_rcu_cfg == NULL) {
>> +   rte_errno = EINVAL;
>> +   return -1;
>> +   }
>> +
>> +   ret = rte_rcu_qsbr_dq_reclaim(h->dq,
>> h->hash_rcu_cfg->max_reclaim_size,
>> +   freed, pending,
>> available);
>> +   if (ret != 0) {
>> +   HASH_LOG(ERR,
>> +   "%s: could not reclaim the defer queue in hash
>> table",
>> +   __func__);
>> +   return -1;
>> +   }
>> +
>> +   return 0;
>> +}
>> +
>>  static inline void
>>  remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,
>> unsigned int i)
>> diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
>> index 7ecc02..edfa262aca 100644
>> --- a/lib/hash/rte_hash.h
>> +++ b/lib/hash/rte_hash.h
>> @@ -674,6 +674,30 @@ rte_hash_iterate(const struct rte_hash *h, const
>> void **key, void **data, uint32
>>   */
>>  int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config
>> *cfg);
>>
>> +/**
>> + * Reclaim resources from the defer queue.
>> + * This API reclaim the resources from the defer queue if rcu is enabled.
>> + *
>> + * @param h
>> + *   The hash object to reclaim resources.
>> + * @param freed
>> + *   Number of resources that were freed.
>> + * @param pending
>> + *   Number of resources pending on the defer queue.
>> + *   This number might not be accurate if multi-thread safety is
>> configured.
>> + * @param available
>> + *   Number of resources that can be added to the defer queue.
>> + *   This number might not be accurate if multi-thread safety is
>> configured.
>> + * @return
>> + *   On success - 0
>> + *   On error - 1 with error code set in rte_errno.
>> + *   Possible rte_errno codes are:
>> + *   - EINVAL - invalid pointer
>> + */
>> +__rte_experimental
>> +int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
>> +   unsigned int *pending, unsigned int *available);
>> +
>>  #ifdef __cplusplus
>>  }
>>  #endif
>> diff --git a/lib/hash/version.map b/lib/hash/version.map
>> index 6b2afebf6b..fac7f81e6f 100644
>> --- a/lib/hash/version.map
>> +++ b/lib/hash/version.map
>> @@ -48,3 +48,9 @@ DPDK_24 {
>>
>> local: *;
>>  };
>> +
>> +EXPERIMENTAL {
>> +   global:
>> +
>> +   rte_hash_rcu_qsbr_dq_reclaim;
>> +};
>> \ No newline at end of file
>> --
>> 2.34.1
>>
>>


[PATCH v4] lib/hash: add defer queue reclaim API

2024-04-15 Thread Abdullah Ömer Yamaç
This patch adds a new feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah Ömer Yamaç 
---
 app/test/test_hash.c   | 97 ++
 lib/hash/rte_cuckoo_hash.c | 23 +
 lib/hash/rte_hash.h| 24 ++
 lib/hash/version.map   |  7 +++
 4 files changed, 151 insertions(+)

diff --git a/app/test/test_hash.c b/app/test/test_hash.c
index d586878a22..ebeda8c322 100644
--- a/app/test/test_hash.c
+++ b/app/test/test_hash.c
@@ -2183,6 +2183,100 @@ test_hash_rcu_qsbr_sync_mode(uint8_t ext_bkt)
 
 }
 
+/*
+ * rte_hash_rcu_qsbr_dq_reclaim unit test.
+ */
+static int
+test_hash_rcu_qsbr_dq_reclaim(void)
+{
+   size_t sz;
+   int32_t status;
+   unsigned int total_entries = 8;
+   unsigned int freed, pending, available;
+   uint32_t reclaim_keys[8] = {10, 11, 12, 13, 14, 15, 16, 17};
+   struct rte_hash_rcu_config rcu_cfg = {0};
+   struct rte_hash_parameters hash_params = {
+   .name = "test_hash_rcu_qsbr_dq_reclaim",
+   .entries = total_entries,
+   .key_len = sizeof(uint32_t),
+   .hash_func = NULL,
+   .hash_func_init_val = 0,
+   .socket_id = 0,
+   };
+
+   hash_params.extra_flag = RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF;
+
+   g_qsv = NULL;
+   g_handle = NULL;
+
+   printf("\n# Running RCU QSBR DQ mode, reclaim defer queue functional 
test\n");
+
+   g_handle = rte_hash_create(&hash_params);
+   RETURN_IF_ERROR_RCU_QSBR(g_handle == NULL, "Hash creation failed");
+
+   /* Create RCU QSBR variable */
+   sz = rte_rcu_qsbr_get_memsize(RTE_MAX_LCORE);
+   g_qsv = (struct rte_rcu_qsbr *)rte_zmalloc_socket(NULL, sz,
+   RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
+   RETURN_IF_ERROR_RCU_QSBR(g_qsv == NULL,
+"RCU QSBR variable 
creation failed");
+
+   status = rte_rcu_qsbr_init(g_qsv, RTE_MAX_LCORE);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0,
+"RCU QSBR variable 
initialization failed");
+
+   rcu_cfg.v = g_qsv;
+   rcu_cfg.dq_size = total_entries;
+   rcu_cfg.mode = RTE_HASH_QSBR_MODE_DQ;
+
+   /* Attach RCU QSBR to hash table */
+   status = rte_hash_rcu_qsbr_add(g_handle, &rcu_cfg);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0,
+"Attach RCU QSBR to 
hash table failed");
+
+   /* Register pseudo reader */
+   status = rte_rcu_qsbr_thread_register(g_qsv, 0);
+   RETURN_IF_ERROR_RCU_QSBR(status != 0,
+"RCU QSBR thread 
registration failed");
+   rte_rcu_qsbr_thread_online(g_qsv, 0);
+
+   /* Fill half of the hash table */
+   for (size_t i = 0; i < total_entries / 2; i++)
+   status = rte_hash_add_key(g_handle, &reclaim_keys[i]);
+
+   /* Lookup inserted elements*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_lookup(g_handle, &reclaim_keys[i]);
+
+   /* Try to put these elements into the defer queue*/
+   for (size_t i = 0; i < total_entries / 2; i++)
+   rte_hash_del_key(g_handle, &reclaim_keys[i]);
+
+   /* Reader quiescent */
+   rte_rcu_qsbr_quiescent(g_qsv, 0);
+
+   status = rte_hash_add_key(g_handle, &reclaim_keys[0]);
+   RETURN_IF_ERROR_RCU_QSBR(status < 0,
+"failed to add key 
(pos[%u]=%d)", 0,
+status);
+
+   /* This should be (total_entries / 2) + 1 (last add) */
+   unsigned int hash_size = rte_hash_count(g_handle);
+
+   /* Freed size should be (total_entries / 2) */
+   rte_hash_rcu_qsbr_dq_reclaim(g_handle, &freed, &pending, &available);
+
+   rte_hash_free(g_handle);
+   rte_free(g_qsv);
+
+   if (hash_size != (total_entries / 2 + 1) || freed != (total_entries / 
2)) {
+   printf("Failed to reclaim defer queue\n");
+   return -1;
+   }
+
+   return 0;
+}
+
 /*
  * Do all unit and performance tests.
  */
@@ -2261,6 +2355,9 @@ test_hash(void)
if (test_hash_rcu_qsbr_sync_mode(1) < 0)
return -1;
 
+   if (test_hash_rcu_qsbr_dq_reclaim() < 0)
+   return -1;
+
return 0;
 }
 
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..4a44aadd9a 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct 

[PATCH] lib/hash: setting the maximum reclamation size

2024-04-17 Thread Abdullah Ömer Yamaç
In the previous implementation, the maximum reclamation size was set
to RTE_HASH_RCU_DQ_RECLAIM_MAX and it was not configurable. This patch
uses the configuration argument to set the maximum reclamation size.

Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
Cc: dharmik.thak...@arm.com
Cc: Honnappa Nagarahalli 
Cc: Yipeng Wang 
Cc: Sameh Gobriel 
Cc: Bruce Richardson 
Cc: Vladimir Medvedkin 

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/hash/rte_cuckoo_hash.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 4a44aadd9a..6d80793164 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1557,6 +1557,7 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct 
rte_hash_rcu_config *cfg)
if (params.size == 0)
params.size = total_entries;
params.trigger_reclaim_limit = cfg->trigger_reclaim_limit;
+   params.max_reclaim_size = cfg->max_reclaim_size;
if (params.max_reclaim_size == 0)
params.max_reclaim_size = RTE_HASH_RCU_DQ_RECLAIM_MAX;
params.esize = sizeof(struct __rte_hash_rcu_dq_entry);
-- 
2.34.1



[PATCH] lib/hash: new feature adding existing key

2023-03-13 Thread Abdullah Ömer Yamaç
In some use cases inserting data with the same key shouldn't be
overwritten. We use a new flag in this patch to disable overwriting
data for the same key.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: Yipeng Wang 
---
 lib/hash/rte_cuckoo_hash.c | 10 +-
 lib/hash/rte_cuckoo_hash.h |  2 ++
 lib/hash/rte_hash.h|  4 
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a..cd87d6e4cd 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -32,7 +32,8 @@
   RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \
   RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \
   RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \
-  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)
+  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | \
+  
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
 
 #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET)\
for (CURRENT_BKT = START_BUCKET;  \
@@ -148,6 +149,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
unsigned int readwrite_concur_support = 0;
unsigned int writer_takes_lock = 0;
unsigned int no_free_on_del = 0;
+   unsigned int no_update_data = 0;
uint32_t *ext_bkt_to_free = NULL;
uint32_t *tbl_chng_cnt = NULL;
struct lcore_cache *local_free_slots = NULL;
@@ -216,6 +218,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
no_free_on_del = 1;
}
 
+   if (params->extra_flag & 
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
+   no_update_data = 1;
+
/* Store all keys and leave the first entry as a dummy entry for 
lookup_bulk */
if (use_local_cache)
/*
@@ -428,6 +433,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
h->ext_table_support = ext_table_support;
h->writer_takes_lock = writer_takes_lock;
h->no_free_on_del = no_free_on_del;
+   h->no_update_data = no_update_data;
h->readwrite_concur_lf_support = readwrite_concur_lf_support;
 
 #if defined(RTE_ARCH_X86)
@@ -699,6 +705,8 @@ search_and_update(const struct rte_hash *h, void *data, 
const void *key,
k = (struct rte_hash_key *) ((char *)keys +
bkt->key_idx[i] * h->key_entry_size);
if (rte_hash_cmp_eq(key, k->key, h) == 0) {
+   if (h->no_update_data == 1)
+   return -EALRDY;
/* The store to application data at *data
 * should not leak after the store to pdata
 * in the key store. i.e. pdata is the guard
diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h
index eb2644f74b..e8b7283ec2 100644
--- a/lib/hash/rte_cuckoo_hash.h
+++ b/lib/hash/rte_cuckoo_hash.h
@@ -193,6 +193,8 @@ struct rte_hash {
/**< If read-write concurrency support is enabled */
uint8_t ext_table_support; /**< Enable extendable bucket table */
uint8_t no_free_on_del;
+   /**< If update is prohibited on adding same key */
+   uint8_t no_update_data;
/**< If key index should be freed on calling rte_hash_del_xxx APIs.
 * If this is set, rte_hash_free_key_with_position must be called to
 * free the key index associated with the deleted entry.
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index a399346d02..f8afb4e06d 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -55,6 +55,10 @@ extern "C" {
  */
 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
 
+/** Flag to disable updating data of existing key
+ */
+#define RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY 0x40
+
 /**
  * The type of hash value of a key.
  * It should be a value of at least 32bit with fully random pattern.
-- 
2.34.1



[PATCH] lib/hash: new feature adding existing key

2023-03-13 Thread Abdullah Ömer Yamaç
In some use cases inserting data with the same key shouldn't be
overwritten. We use a new flag in this patch to disable overwriting
data for the same key.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: Yipeng Wang 
---
 lib/hash/rte_cuckoo_hash.c | 10 +-
 lib/hash/rte_cuckoo_hash.h |  2 ++
 lib/hash/rte_hash.h|  4 
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 829b79c89a..cd87d6e4cd 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -32,7 +32,8 @@
   RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \
   RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \
   RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \
-  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF)
+  RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | \
+  
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
 
 #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET)\
for (CURRENT_BKT = START_BUCKET;  \
@@ -148,6 +149,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
unsigned int readwrite_concur_support = 0;
unsigned int writer_takes_lock = 0;
unsigned int no_free_on_del = 0;
+   unsigned int no_update_data = 0;
uint32_t *ext_bkt_to_free = NULL;
uint32_t *tbl_chng_cnt = NULL;
struct lcore_cache *local_free_slots = NULL;
@@ -216,6 +218,9 @@ rte_hash_create(const struct rte_hash_parameters *params)
no_free_on_del = 1;
}
 
+   if (params->extra_flag & 
RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY)
+   no_update_data = 1;
+
/* Store all keys and leave the first entry as a dummy entry for 
lookup_bulk */
if (use_local_cache)
/*
@@ -428,6 +433,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
h->ext_table_support = ext_table_support;
h->writer_takes_lock = writer_takes_lock;
h->no_free_on_del = no_free_on_del;
+   h->no_update_data = no_update_data;
h->readwrite_concur_lf_support = readwrite_concur_lf_support;
 
 #if defined(RTE_ARCH_X86)
@@ -699,6 +705,8 @@ search_and_update(const struct rte_hash *h, void *data, 
const void *key,
k = (struct rte_hash_key *) ((char *)keys +
bkt->key_idx[i] * h->key_entry_size);
if (rte_hash_cmp_eq(key, k->key, h) == 0) {
+   if (h->no_update_data == 1)
+   return -EINVAL;
/* The store to application data at *data
 * should not leak after the store to pdata
 * in the key store. i.e. pdata is the guard
diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h
index eb2644f74b..e8b7283ec2 100644
--- a/lib/hash/rte_cuckoo_hash.h
+++ b/lib/hash/rte_cuckoo_hash.h
@@ -193,6 +193,8 @@ struct rte_hash {
/**< If read-write concurrency support is enabled */
uint8_t ext_table_support; /**< Enable extendable bucket table */
uint8_t no_free_on_del;
+   /**< If update is prohibited on adding same key */
+   uint8_t no_update_data;
/**< If key index should be freed on calling rte_hash_del_xxx APIs.
 * If this is set, rte_hash_free_key_with_position must be called to
 * free the key index associated with the deleted entry.
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index a399346d02..f8afb4e06d 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -55,6 +55,10 @@ extern "C" {
  */
 #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20
 
+/** Flag to disable updating data of existing key
+ */
+#define RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY 0x40
+
 /**
  * The type of hash value of a key.
  * It should be a value of at least 32bit with fully random pattern.
-- 
2.34.1



[PATCH] Update lcore-worker name due to high number of cores

2022-09-22 Thread Abdullah Ömer Yamaç
In this patch we suggest a new name for lcore-worker.
In case of more than 99 logical cores, name is truncated
(length is restricted to 16 characters, including the
terminating null byte ('\0')) and it makes hard to follow threads.

Signed-off-by: Abdullah Ömer Yamaç 
---
 lib/eal/linux/eal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 46bf52cef0..9a168b7773 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1248,7 +1248,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
-- 
2.27.0



[PATCH v2] lib/eal/linux: update lcore-worker name due to high number of cores

2022-09-22 Thread Abdullah Ömer Yamaç
In this patch we suggest a new name for lcore-worker.
In case of more than 99 logical cores, name is truncated
(length is restricted to 16 characters, including the
terminating null byte ('\0')) and it makes hard to follow threads.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: David Marchand 
---
 lib/eal/linux/eal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 46bf52cef0..9a168b7773 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1248,7 +1248,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
-- 
2.27.0



[PATCH v3] eal: update lcore-worker name due to high number of cores

2022-09-23 Thread Abdullah Ömer Yamaç
In this patch we suggest a new name for lcore-worker.
In case of more than 99 logical cores, name is truncated
(length is restricted to 16 characters, including the
terminating null byte ('\0')) and it makes hard to follow threads.

Signed-off-by: Abdullah Ömer Yamaç 

Acked-by: Stephen Hemminger 

---
Cc: David Marchand 
---
 lib/eal/freebsd/eal.c | 2 +-
 lib/eal/linux/eal.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index ee5c929da8..a1bb5363b1 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -817,7 +817,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
rte_thread_setname(lcore_config[i].thread_id, thread_name);
 
ret = pthread_setaffinity_np(lcore_config[i].thread_id,
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 46bf52cef0..9a168b7773 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1248,7 +1248,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
-- 
2.27.0



[PATCH v4] eal: fix thread names for high order lcores

2022-09-26 Thread Abdullah Ömer Yamaç
In this patch we suggest a new name for lcore-worker.
In case of more than 99 logical cores, name is truncated
(length is restricted to 16 characters, including the
terminating null byte ('\0')) and it makes hard to follow threads.

Signed-off-by: Abdullah Ömer Yamaç 

Acked-by: Stephen Hemminger 

---
Cc: David Marchand 
---
 lib/eal/freebsd/eal.c | 2 +-
 lib/eal/linux/eal.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index ee5c929da8..a1bb5363b1 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -817,7 +817,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
rte_thread_setname(lcore_config[i].thread_id, thread_name);
 
ret = pthread_setaffinity_np(lcore_config[i].thread_id,
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 46bf52cef0..9a168b7773 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1248,7 +1248,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
-- 
2.27.0



[PATCH v5] eal: fix thread names for high order lcores

2022-09-26 Thread Abdullah Ömer Yamaç
In this patch we suggest a new name for lcore-worker.
In case of higher order (greater than 99) logical cores, name is truncated
(length is restricted to 16 characters, including the
terminating null byte ('\0')) and it makes hard to follow threads.

Ex: This issue can be generated using following arguments:
--lcores=0,10@1,100@2
Then we have;
lcore-worker-10
lcore-worker-10

Signed-off-by: Abdullah Ömer Yamaç 

Acked-by: Stephen Hemminger 

---
Cc: David Marchand 
---
 lib/eal/freebsd/eal.c | 2 +-
 lib/eal/linux/eal.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index ee5c929da8..a1bb5363b1 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -817,7 +817,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
rte_thread_setname(lcore_config[i].thread_id, thread_name);
 
ret = pthread_setaffinity_np(lcore_config[i].thread_id,
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index 46bf52cef0..9a168b7773 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c
@@ -1248,7 +1248,7 @@ rte_eal_init(int argc, char **argv)
 
/* Set thread_name for aid in debugging. */
snprintf(thread_name, sizeof(thread_name),
-   "lcore-worker-%d", i);
+   "rte-worker-%d", i);
ret = rte_thread_setname(lcore_config[i].thread_id,
thread_name);
if (ret != 0)
-- 
2.27.0



[PATCH] drivers: suggestion on removing empty version.map files

2022-10-02 Thread Abdullah Ömer Yamaç
In this patch, we remove all version.map files which include
only the below part:
`DPDK_23 {
local: *;
};`

Then we modify the meson.build to be able to compile without version.map

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 
---
 drivers/baseband/la12xx/version.map   |  3 --
 drivers/baseband/null/version.map |  3 --
 drivers/baseband/turbo_sw/version.map |  3 --
 drivers/common/qat/version.map|  3 --
 drivers/compress/isal/version.map |  3 --
 drivers/compress/mlx5/version.map |  3 --
 drivers/compress/octeontx/version.map |  3 --
 drivers/compress/zlib/version.map |  3 --
 drivers/crypto/armv8/version.map  |  3 --
 drivers/crypto/bcmfs/version.map  |  3 --
 drivers/crypto/caam_jr/version.map|  3 --
 drivers/crypto/ccp/version.map|  3 --
 drivers/crypto/ipsec_mb/version.map   |  3 --
 drivers/crypto/mlx5/version.map   |  3 --
 drivers/crypto/mvsam/version.map  |  3 --
 drivers/crypto/nitrox/version.map |  3 --
 drivers/crypto/null/version.map   |  3 --
 drivers/crypto/openssl/version.map|  3 --
 drivers/crypto/virtio/version.map |  3 --
 drivers/dma/cnxk/version.map  |  3 --
 drivers/dma/dpaa/version.map  |  3 --
 drivers/dma/hisilicon/version.map |  3 --
 drivers/dma/idxd/version.map  |  3 --
 drivers/dma/ioat/version.map  |  3 --
 drivers/dma/skeleton/version.map  |  3 --
 drivers/event/cnxk/version.map|  3 --
 drivers/event/dpaa/version.map|  3 --
 drivers/event/dpaa2/version.map   |  3 --
 drivers/event/dsw/version.map |  3 --
 drivers/event/octeontx/version.map|  3 --
 drivers/event/opdl/version.map|  3 --
 drivers/event/skeleton/version.map|  3 --
 drivers/event/sw/version.map  |  3 --
 drivers/gpu/cuda/version.map  |  3 --
 drivers/mempool/bucket/version.map|  3 --
 drivers/mempool/cnxk/version.map  |  3 --
 drivers/mempool/octeontx/version.map  |  3 --
 drivers/mempool/ring/version.map  |  3 --
 drivers/mempool/stack/version.map |  3 --
 drivers/meson.build   | 63 +++
 drivers/net/af_packet/version.map |  3 --
 drivers/net/af_xdp/version.map|  3 --
 drivers/net/ark/version.map   |  3 --
 drivers/net/avp/version.map   |  3 --
 drivers/net/axgbe/version.map |  3 --
 drivers/net/bnx2x/version.map |  3 --
 drivers/net/cxgbe/version.map |  3 --
 drivers/net/e1000/version.map |  3 --
 drivers/net/ena/version.map   |  3 --
 drivers/net/enetc/version.map |  3 --
 drivers/net/enetfec/version.map   |  3 --
 drivers/net/enic/version.map  |  3 --
 drivers/net/failsafe/version.map  |  3 --
 drivers/net/fm10k/version.map |  3 --
 drivers/net/hinic/version.map |  3 --
 drivers/net/hns3/version.map  |  3 --
 drivers/net/igc/version.map   |  3 --
 drivers/net/ionic/version.map |  3 --
 drivers/net/kni/version.map   |  3 --
 drivers/net/liquidio/version.map  |  3 --
 drivers/net/memif/version.map |  3 --
 drivers/net/mlx4/version.map  |  3 --
 drivers/net/mvneta/version.map|  3 --
 drivers/net/mvpp2/version.map |  3 --
 drivers/net/netvsc/version.map|  3 --
 drivers/net/nfb/version.map   |  3 --
 drivers/net/nfp/version.map   |  3 --
 drivers/net/ngbe/version.map  |  3 --
 drivers/net/null/version.map  |  3 --
 drivers/net/octeon_ep/version.map |  3 --
 drivers/net/pcap/version.map  |  3 --
 drivers/net/pfe/version.map   |  3 --
 drivers/net/qede/version.map  |  3 --
 drivers/net/sfc/version.map   |  3 --
 drivers/net/tap/version.map   |  3 --
 drivers/net/thunderx/version.map  |  3 --
 drivers/net/txgbe/version.map |  3 --
 drivers/net/vdev_netvsc/version.map   |  3 --
 drivers/net/virtio/version.map|  3 --
 drivers/net/vmxnet3/version.map   |  3 --
 drivers/raw/cnxk_bphy/version.map |  3 --
 drivers/raw/cnxk_gpio/version.map |  3 --
 drivers/raw/dpaa2_cmdif/version.map   |  3 --
 drivers/raw/ntb/version.map   |  3 --
 drivers/raw/skeleton/version.map  |  3 --
 drivers/regex/cn9k/version.map|  3 --
 drivers/regex/mlx5/version.map|  3 --
 drivers/vdpa/ifc/version.map  |  3 --
 drivers/vdpa/mlx5/version.map |  3 --
 drivers/vdpa/sfc/version.map  |  3 --
 90 files changed, 34 insertions(+), 296 deletions(-)
 delete mode 100644 drivers/baseband/la12xx/version.map
 delete mode 100644 drivers/baseband/null/version.map
 delete mode 100644 drivers/baseband/turbo_sw/version.map
 delete mode 100644 drivers/common/qat/version.map
 delete mode 100644 drivers/compress/isal/version.map
 delete mode 100644 drivers/compress/mlx5/version.map
 delete mode 100644 drivers/compress/octeontx/version.map
 delete mode 100644 drivers/compress/zlib

[PATCH 1/2] drivers: suggestion on meson without version file

2022-10-06 Thread Abdullah Ömer Yamaç
Most of the drivers don't have a special version.map file. They just
included due to the compilation issue and needs to be updated for each
release.

These version.map files include:
DPDK_23 {
  local: *;
};

In this patch, we removed the necessity of the version files and
you don't need to update these files for each release, you can just
remove them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 

---
Depends on: patch-116222 ("build: increase minimum meson version to 0.53")
---
 drivers/meson.build | 63 -
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/drivers/meson.build b/drivers/meson.build
index f6ba5ba4fb..6ef03e14c7 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+fs = import('fs')
+
 # Defines the order of dependencies evaluation
 subdirs = [
 'common',
@@ -193,38 +195,41 @@ foreach subpath:subdirs
 version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), 
drv_path)
 implib = 'lib' + lib_name + '.dll.a'
 
-def_file = custom_target(lib_name + '_def',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_exports.def'.format(lib_name))
-
-mingw_map = custom_target(lib_name + '_mingw',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_mingw.map'.format(lib_name))
-
-lk_deps = [version_map, def_file, mingw_map]
-if is_windows
-if is_ms_linker
-lk_args = ['-Wl,/def:' + def_file.full_path()]
-if meson.version().version_compare('<0.54.0')
-lk_args += ['-Wl,/implib:drivers\\' + implib]
+if fs.is_file(version_map)
+def_file = custom_target(lib_name + '_def',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_exports.def'.format(lib_name))
+
+mingw_map = custom_target(lib_name + '_mingw',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_mingw.map'.format(lib_name))
+
+lk_deps = [version_map, def_file, mingw_map]
+if is_windows
+if is_ms_linker
+lk_args = ['-Wl,/def:' + def_file.full_path()]
+if meson.version().version_compare('<0.54.0')
+lk_args += ['-Wl,/implib:drivers\\' + implib]
+endif
+else
+lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
 endif
 else
-lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
-endif
-else
-lk_args = ['-Wl,--version-script=' + version_map]
-if developer_mode
-# on unix systems check the output of the
-# check-symbols.sh script, using it as a
-# dependency of the .so build
-lk_deps += custom_target(lib_name + '.sym_chk',
-command: [check_symbols, version_map, '@INPUT@'],
-capture: true,
-input: static_lib,
-output: lib_name + '.sym_chk')
+lk_args = ['-Wl,--version-script=' + version_map]
+if developer_mode
+# on unix systems check the output of the
+# check-symbols.sh script, using it as a
+# dependency of the .so build
+lk_deps += custom_target(lib_name + '.sym_chk',
+command: [check_symbols, version_map, '@INPUT@'],
+capture: true,
+input: static_lib,
+output: lib_name + '.sym_chk')
+endif
 endif
+
 endif
 
 shared_lib = shared_library(lib_name, sources,
-- 
2.27.0



[PATCH 2/2] drivers: remove the unnecessary version.map

2022-10-06 Thread Abdullah Ömer Yamaç
With the previous patch, some version.map files are not necessary.
In this patch, we removed them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 

---
Depends on: patch-116222 ("build: increase minimum meson version to 0.53")
---
 drivers/baseband/la12xx/version.map   | 3 ---
 drivers/baseband/null/version.map | 3 ---
 drivers/baseband/turbo_sw/version.map | 3 ---
 drivers/common/qat/version.map| 3 ---
 drivers/compress/isal/version.map | 3 ---
 drivers/compress/mlx5/version.map | 3 ---
 drivers/compress/octeontx/version.map | 3 ---
 drivers/compress/zlib/version.map | 3 ---
 drivers/crypto/armv8/version.map  | 3 ---
 drivers/crypto/bcmfs/version.map  | 3 ---
 drivers/crypto/caam_jr/version.map| 3 ---
 drivers/crypto/ccp/version.map| 3 ---
 drivers/crypto/ipsec_mb/version.map   | 3 ---
 drivers/crypto/mlx5/version.map   | 3 ---
 drivers/crypto/mvsam/version.map  | 3 ---
 drivers/crypto/nitrox/version.map | 3 ---
 drivers/crypto/null/version.map   | 3 ---
 drivers/crypto/openssl/version.map| 3 ---
 drivers/crypto/virtio/version.map | 3 ---
 drivers/dma/cnxk/version.map  | 3 ---
 drivers/dma/dpaa/version.map  | 3 ---
 drivers/dma/hisilicon/version.map | 3 ---
 drivers/dma/idxd/version.map  | 3 ---
 drivers/dma/ioat/version.map  | 3 ---
 drivers/dma/skeleton/version.map  | 3 ---
 drivers/event/cnxk/version.map| 3 ---
 drivers/event/dpaa/version.map| 3 ---
 drivers/event/dpaa2/version.map   | 3 ---
 drivers/event/dsw/version.map | 3 ---
 drivers/event/octeontx/version.map| 3 ---
 drivers/event/opdl/version.map| 3 ---
 drivers/event/skeleton/version.map| 3 ---
 drivers/event/sw/version.map  | 3 ---
 drivers/gpu/cuda/version.map  | 3 ---
 drivers/mempool/bucket/version.map| 3 ---
 drivers/mempool/cnxk/version.map  | 3 ---
 drivers/mempool/octeontx/version.map  | 3 ---
 drivers/mempool/ring/version.map  | 3 ---
 drivers/mempool/stack/version.map | 3 ---
 drivers/net/af_packet/version.map | 3 ---
 drivers/net/af_xdp/version.map| 3 ---
 drivers/net/ark/version.map   | 3 ---
 drivers/net/avp/version.map   | 3 ---
 drivers/net/axgbe/version.map | 3 ---
 drivers/net/bnx2x/version.map | 3 ---
 drivers/net/cxgbe/version.map | 3 ---
 drivers/net/e1000/version.map | 3 ---
 drivers/net/ena/version.map   | 3 ---
 drivers/net/enetc/version.map | 3 ---
 drivers/net/enetfec/version.map   | 3 ---
 drivers/net/enic/version.map  | 3 ---
 drivers/net/failsafe/version.map  | 3 ---
 drivers/net/fm10k/version.map | 3 ---
 drivers/net/hinic/version.map | 3 ---
 drivers/net/hns3/version.map  | 3 ---
 drivers/net/igc/version.map   | 3 ---
 drivers/net/ionic/version.map | 3 ---
 drivers/net/kni/version.map   | 3 ---
 drivers/net/liquidio/version.map  | 3 ---
 drivers/net/memif/version.map | 3 ---
 drivers/net/mlx4/version.map  | 3 ---
 drivers/net/mvneta/version.map| 3 ---
 drivers/net/mvpp2/version.map | 3 ---
 drivers/net/netvsc/version.map| 3 ---
 drivers/net/nfb/version.map   | 3 ---
 drivers/net/nfp/version.map   | 3 ---
 drivers/net/ngbe/version.map  | 3 ---
 drivers/net/null/version.map  | 3 ---
 drivers/net/octeon_ep/version.map | 3 ---
 drivers/net/pcap/version.map  | 3 ---
 drivers/net/pfe/version.map   | 3 ---
 drivers/net/qede/version.map  | 3 ---
 drivers/net/sfc/version.map   | 3 ---
 drivers/net/tap/version.map   | 3 ---
 drivers/net/thunderx/version.map  | 3 ---
 drivers/net/txgbe/version.map | 3 ---
 drivers/net/vdev_netvsc/version.map   | 3 ---
 drivers/net/virtio/version.map| 3 ---
 drivers/net/vmxnet3/version.map   | 3 ---
 drivers/raw/cnxk_bphy/version.map | 3 ---
 drivers/raw/cnxk_gpio/version.map | 3 ---
 drivers/raw/dpaa2_cmdif/version.map   | 3 ---
 drivers/raw/ntb/version.map   | 3 ---
 drivers/raw/skeleton/version.map  | 3 ---
 drivers/regex/cn9k/version.map| 3 ---
 drivers/regex/mlx5/version.map| 3 ---
 drivers/vdpa/ifc/version.map  | 3 ---
 drivers/vdpa/mlx5/version.map | 3 ---
 drivers/vdpa/sfc/version.map  | 3 ---
 89 files changed, 267 deletions(-)
 delete mode 100644 drivers/baseband/la12xx/version.map
 delete mode 100644 drivers/baseband/null/version.map
 delete mode 100644 drivers/baseband/turbo_sw/version.map
 delete mode 100644 drivers/common/qat/version.map
 delete mode 100644 drivers/compress/isal/version.map
 delete mode 100644 drivers/compress/mlx5/version.map
 delete mode 100644 drivers/compress/octeontx/version.map
 delete mode 100644 drivers/compress/zlib/version.map
 delete mode 100644 drivers/crypto/armv8/version.map
 delete mode 100644 driv

[PATCH v2 2/2] drivers: remove the unnecessary version.map

2022-10-11 Thread Abdullah Ömer Yamaç
With the previous patch, some version.map files are not necessary.
In this patch, we removed them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 

---
Depends on: patch-116222 ("build: increase minimum meson version to 0.53")
---
 drivers/baseband/la12xx/version.map   | 3 ---
 drivers/baseband/null/version.map | 3 ---
 drivers/baseband/turbo_sw/version.map | 3 ---
 drivers/common/qat/version.map| 3 ---
 drivers/compress/isal/version.map | 3 ---
 drivers/compress/mlx5/version.map | 3 ---
 drivers/compress/octeontx/version.map | 3 ---
 drivers/compress/zlib/version.map | 3 ---
 drivers/crypto/armv8/version.map  | 3 ---
 drivers/crypto/bcmfs/version.map  | 3 ---
 drivers/crypto/caam_jr/version.map| 3 ---
 drivers/crypto/ccp/version.map| 3 ---
 drivers/crypto/ipsec_mb/version.map   | 3 ---
 drivers/crypto/mlx5/version.map   | 3 ---
 drivers/crypto/mvsam/version.map  | 3 ---
 drivers/crypto/nitrox/version.map | 3 ---
 drivers/crypto/null/version.map   | 3 ---
 drivers/crypto/openssl/version.map| 3 ---
 drivers/crypto/virtio/version.map | 3 ---
 drivers/dma/cnxk/version.map  | 3 ---
 drivers/dma/dpaa/version.map  | 3 ---
 drivers/dma/hisilicon/version.map | 3 ---
 drivers/dma/idxd/version.map  | 3 ---
 drivers/dma/ioat/version.map  | 3 ---
 drivers/dma/skeleton/version.map  | 3 ---
 drivers/event/cnxk/version.map| 3 ---
 drivers/event/dpaa/version.map| 3 ---
 drivers/event/dpaa2/version.map   | 3 ---
 drivers/event/dsw/version.map | 3 ---
 drivers/event/octeontx/version.map| 3 ---
 drivers/event/opdl/version.map| 3 ---
 drivers/event/skeleton/version.map| 3 ---
 drivers/event/sw/version.map  | 3 ---
 drivers/gpu/cuda/version.map  | 3 ---
 drivers/mempool/bucket/version.map| 3 ---
 drivers/mempool/cnxk/version.map  | 3 ---
 drivers/mempool/octeontx/version.map  | 3 ---
 drivers/mempool/ring/version.map  | 3 ---
 drivers/mempool/stack/version.map | 3 ---
 drivers/net/af_packet/version.map | 3 ---
 drivers/net/af_xdp/version.map| 3 ---
 drivers/net/ark/version.map   | 3 ---
 drivers/net/avp/version.map   | 3 ---
 drivers/net/axgbe/version.map | 3 ---
 drivers/net/bnx2x/version.map | 3 ---
 drivers/net/cxgbe/version.map | 3 ---
 drivers/net/e1000/version.map | 3 ---
 drivers/net/ena/version.map   | 3 ---
 drivers/net/enetc/version.map | 3 ---
 drivers/net/enetfec/version.map   | 3 ---
 drivers/net/enic/version.map  | 3 ---
 drivers/net/failsafe/version.map  | 3 ---
 drivers/net/fm10k/version.map | 3 ---
 drivers/net/hinic/version.map | 3 ---
 drivers/net/hns3/version.map  | 3 ---
 drivers/net/igc/version.map   | 3 ---
 drivers/net/ionic/version.map | 3 ---
 drivers/net/kni/version.map   | 3 ---
 drivers/net/liquidio/version.map  | 3 ---
 drivers/net/memif/version.map | 3 ---
 drivers/net/mlx4/version.map  | 3 ---
 drivers/net/mvneta/version.map| 3 ---
 drivers/net/mvpp2/version.map | 3 ---
 drivers/net/netvsc/version.map| 3 ---
 drivers/net/nfb/version.map   | 3 ---
 drivers/net/nfp/version.map   | 3 ---
 drivers/net/ngbe/version.map  | 3 ---
 drivers/net/null/version.map  | 3 ---
 drivers/net/octeon_ep/version.map | 3 ---
 drivers/net/pcap/version.map  | 3 ---
 drivers/net/pfe/version.map   | 3 ---
 drivers/net/qede/version.map  | 3 ---
 drivers/net/sfc/version.map   | 3 ---
 drivers/net/tap/version.map   | 3 ---
 drivers/net/thunderx/version.map  | 3 ---
 drivers/net/txgbe/version.map | 3 ---
 drivers/net/vdev_netvsc/version.map   | 3 ---
 drivers/net/virtio/version.map| 3 ---
 drivers/net/vmxnet3/version.map   | 3 ---
 drivers/raw/cnxk_bphy/version.map | 3 ---
 drivers/raw/cnxk_gpio/version.map | 3 ---
 drivers/raw/dpaa2_cmdif/version.map   | 3 ---
 drivers/raw/ntb/version.map   | 3 ---
 drivers/raw/skeleton/version.map  | 3 ---
 drivers/regex/cn9k/version.map| 3 ---
 drivers/regex/mlx5/version.map| 3 ---
 drivers/vdpa/ifc/version.map  | 3 ---
 drivers/vdpa/mlx5/version.map | 3 ---
 drivers/vdpa/sfc/version.map  | 3 ---
 89 files changed, 267 deletions(-)
 delete mode 100644 drivers/baseband/la12xx/version.map
 delete mode 100644 drivers/baseband/null/version.map
 delete mode 100644 drivers/baseband/turbo_sw/version.map
 delete mode 100644 drivers/common/qat/version.map
 delete mode 100644 drivers/compress/isal/version.map
 delete mode 100644 drivers/compress/mlx5/version.map
 delete mode 100644 drivers/compress/octeontx/version.map
 delete mode 100644 drivers/compress/zlib/version.map
 delete mode 100644 drivers/crypto/armv8/version.map
 delete mode 100644 driv

[PATCH v2 1/2] build: make version file optional for drivers

2022-10-11 Thread Abdullah Ömer Yamaç
In this patch, we removed the necessity of the version files and
you don't need to update these files for each release, you can just
remove them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 

---
Depends on: patch-116222 ("build: increase minimum meson version to 0.53")
---
 drivers/meson.build | 67 +
 1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/meson.build b/drivers/meson.build
index 216971f4e2..b5856b963b 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+fs = import('fs')
+
 # Defines the order of dependencies evaluation
 subdirs = [
 'common',
@@ -201,39 +203,44 @@ foreach subpath:subdirs
 # now build the shared driver
 version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), 
drv_path)
 implib = 'lib' + lib_name + '.dll.a'
-
-def_file = custom_target(lib_name + '_def',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_exports.def'.format(lib_name))
-
-mingw_map = custom_target(lib_name + '_mingw',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_mingw.map'.format(lib_name))
-
-lk_deps = [version_map, def_file, mingw_map]
-if is_windows
-if is_ms_linker
-lk_args = ['-Wl,/def:' + def_file.full_path()]
-if meson.version().version_compare('<0.54.0')
-lk_args += ['-Wl,/implib:drivers\\' + implib]
+
+lk_deps = []
+lk_args = []
+if fs.is_file(version_map)
+def_file = custom_target(lib_name + '_def',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_exports.def'.format(lib_name))
+
+mingw_map = custom_target(lib_name + '_mingw',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_mingw.map'.format(lib_name))
+
+lk_deps = [version_map, def_file, mingw_map]
+if is_windows
+if is_ms_linker
+lk_args = ['-Wl,/def:' + def_file.full_path()]
+if meson.version().version_compare('<0.54.0')
+lk_args += ['-Wl,/implib:drivers\\' + implib]
+endif
+else
+lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
 endif
 else
-lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
-endif
-else
-lk_args = ['-Wl,--version-script=' + version_map]
-if developer_mode
-# on unix systems check the output of the
-# check-symbols.sh script, using it as a
-# dependency of the .so build
-lk_deps += custom_target(lib_name + '.sym_chk',
-command: [check_symbols, version_map, '@INPUT@'],
-capture: true,
-input: static_lib,
-output: lib_name + '.sym_chk')
+lk_args = ['-Wl,--version-script=' + version_map]
+if developer_mode
+# on unix systems check the output of the
+# check-symbols.sh script, using it as a
+# dependency of the .so build
+lk_deps += custom_target(lib_name + '.sym_chk',
+command: [check_symbols, version_map, '@INPUT@'],
+capture: true,
+input: static_lib,
+output: lib_name + '.sym_chk')
+endif
 endif
+
 endif
 
 shared_lib = shared_library(lib_name, sources,
-- 
2.27.0



[PATCH v3 2/2] build: make version file optional for drivers

2022-10-12 Thread Abdullah Ömer Yamaç
In this patch, we removed the necessity of the version files and
you don't need to update these files for each release, you can just
remove them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 
Series-acked-by: Bruce Richardson 
---
 drivers/baseband/la12xx/version.map   | 3 ---
 drivers/baseband/null/version.map | 3 ---
 drivers/baseband/turbo_sw/version.map | 3 ---
 drivers/common/qat/version.map| 3 ---
 drivers/compress/isal/version.map | 3 ---
 drivers/compress/mlx5/version.map | 3 ---
 drivers/compress/octeontx/version.map | 3 ---
 drivers/compress/zlib/version.map | 3 ---
 drivers/crypto/armv8/version.map  | 3 ---
 drivers/crypto/bcmfs/version.map  | 3 ---
 drivers/crypto/caam_jr/version.map| 3 ---
 drivers/crypto/ccp/version.map| 3 ---
 drivers/crypto/ipsec_mb/version.map   | 3 ---
 drivers/crypto/mlx5/version.map   | 3 ---
 drivers/crypto/mvsam/version.map  | 3 ---
 drivers/crypto/nitrox/version.map | 3 ---
 drivers/crypto/null/version.map   | 3 ---
 drivers/crypto/openssl/version.map| 3 ---
 drivers/crypto/virtio/version.map | 3 ---
 drivers/dma/cnxk/version.map  | 3 ---
 drivers/dma/dpaa/version.map  | 3 ---
 drivers/dma/hisilicon/version.map | 3 ---
 drivers/dma/idxd/version.map  | 3 ---
 drivers/dma/ioat/version.map  | 3 ---
 drivers/dma/skeleton/version.map  | 3 ---
 drivers/event/cnxk/version.map| 3 ---
 drivers/event/dpaa/version.map| 3 ---
 drivers/event/dpaa2/version.map   | 3 ---
 drivers/event/dsw/version.map | 3 ---
 drivers/event/octeontx/version.map| 3 ---
 drivers/event/opdl/version.map| 3 ---
 drivers/event/skeleton/version.map| 3 ---
 drivers/event/sw/version.map  | 3 ---
 drivers/gpu/cuda/version.map  | 3 ---
 drivers/mempool/bucket/version.map| 3 ---
 drivers/mempool/cnxk/version.map  | 3 ---
 drivers/mempool/octeontx/version.map  | 3 ---
 drivers/mempool/ring/version.map  | 3 ---
 drivers/mempool/stack/version.map | 3 ---
 drivers/net/af_packet/version.map | 3 ---
 drivers/net/af_xdp/version.map| 3 ---
 drivers/net/ark/version.map   | 3 ---
 drivers/net/avp/version.map   | 3 ---
 drivers/net/axgbe/version.map | 3 ---
 drivers/net/bnx2x/version.map | 3 ---
 drivers/net/cxgbe/version.map | 3 ---
 drivers/net/e1000/version.map | 3 ---
 drivers/net/ena/version.map   | 3 ---
 drivers/net/enetc/version.map | 3 ---
 drivers/net/enetfec/version.map   | 3 ---
 drivers/net/enic/version.map  | 3 ---
 drivers/net/failsafe/version.map  | 3 ---
 drivers/net/fm10k/version.map | 3 ---
 drivers/net/hinic/version.map | 3 ---
 drivers/net/hns3/version.map  | 3 ---
 drivers/net/igc/version.map   | 3 ---
 drivers/net/ionic/version.map | 3 ---
 drivers/net/kni/version.map   | 3 ---
 drivers/net/liquidio/version.map  | 3 ---
 drivers/net/mana/version.map  | 3 ---
 drivers/net/memif/version.map | 3 ---
 drivers/net/mlx4/version.map  | 3 ---
 drivers/net/mvneta/version.map| 3 ---
 drivers/net/mvpp2/version.map | 3 ---
 drivers/net/netvsc/version.map| 3 ---
 drivers/net/nfb/version.map   | 3 ---
 drivers/net/nfp/version.map   | 3 ---
 drivers/net/ngbe/version.map  | 3 ---
 drivers/net/null/version.map  | 3 ---
 drivers/net/octeon_ep/version.map | 3 ---
 drivers/net/pcap/version.map  | 3 ---
 drivers/net/pfe/version.map   | 3 ---
 drivers/net/qede/version.map  | 3 ---
 drivers/net/sfc/version.map   | 3 ---
 drivers/net/tap/version.map   | 3 ---
 drivers/net/thunderx/version.map  | 3 ---
 drivers/net/txgbe/version.map | 3 ---
 drivers/net/vdev_netvsc/version.map   | 3 ---
 drivers/net/virtio/version.map| 3 ---
 drivers/net/vmxnet3/version.map   | 3 ---
 drivers/raw/cnxk_bphy/version.map | 3 ---
 drivers/raw/cnxk_gpio/version.map | 3 ---
 drivers/raw/dpaa2_cmdif/version.map   | 3 ---
 drivers/raw/ntb/version.map   | 3 ---
 drivers/raw/skeleton/version.map  | 3 ---
 drivers/regex/cn9k/version.map| 3 ---
 drivers/regex/mlx5/version.map| 3 ---
 drivers/vdpa/ifc/version.map  | 3 ---
 drivers/vdpa/mlx5/version.map | 3 ---
 drivers/vdpa/sfc/version.map  | 3 ---
 90 files changed, 270 deletions(-)
 delete mode 100644 drivers/baseband/la12xx/version.map
 delete mode 100644 drivers/baseband/null/version.map
 delete mode 100644 drivers/baseband/turbo_sw/version.map
 delete mode 100644 drivers/common/qat/version.map
 delete mode 100644 drivers/compress/isal/version.map
 delete mode 100644 drivers/compress/mlx5/version.map
 delete mode 100644 drivers/compress/octeontx/version.map
 delete mode 100644 drivers/compress/zlib/version.map
 delete mode 100644 drivers/crypto/

[PATCH v3 1/2] build: make version file optional for drivers

2022-10-12 Thread Abdullah Ömer Yamaç
In this patch, we removed the necessity of the version files and
you don't need to update these files for each release, you can just
remove them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 
Series-acked-by: Bruce Richardson 
---
 drivers/meson.build | 65 +
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/meson.build b/drivers/meson.build
index 216971f4e2..c0f3ec4037 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+fs = import('fs')
+
 # Defines the order of dependencies evaluation
 subdirs = [
 'common',
@@ -202,38 +204,43 @@ foreach subpath:subdirs
 version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), 
drv_path)
 implib = 'lib' + lib_name + '.dll.a'
 
-def_file = custom_target(lib_name + '_def',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_exports.def'.format(lib_name))
-
-mingw_map = custom_target(lib_name + '_mingw',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_mingw.map'.format(lib_name))
-
-lk_deps = [version_map, def_file, mingw_map]
-if is_windows
-if is_ms_linker
-lk_args = ['-Wl,/def:' + def_file.full_path()]
-if meson.version().version_compare('<0.54.0')
-lk_args += ['-Wl,/implib:drivers\\' + implib]
+lk_deps = []
+lk_args = []
+if fs.is_file(version_map)
+def_file = custom_target(lib_name + '_def',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_exports.def'.format(lib_name))
+
+mingw_map = custom_target(lib_name + '_mingw',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_mingw.map'.format(lib_name))
+
+lk_deps = [version_map, def_file, mingw_map]
+if is_windows
+if is_ms_linker
+lk_args = ['-Wl,/def:' + def_file.full_path()]
+if meson.version().version_compare('<0.54.0')
+lk_args += ['-Wl,/implib:drivers\\' + implib]
+endif
+else
+lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
 endif
 else
-lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
-endif
-else
-lk_args = ['-Wl,--version-script=' + version_map]
-if developer_mode
-# on unix systems check the output of the
-# check-symbols.sh script, using it as a
-# dependency of the .so build
-lk_deps += custom_target(lib_name + '.sym_chk',
-command: [check_symbols, version_map, '@INPUT@'],
-capture: true,
-input: static_lib,
-output: lib_name + '.sym_chk')
+lk_args = ['-Wl,--version-script=' + version_map]
+if developer_mode
+# on unix systems check the output of the
+# check-symbols.sh script, using it as a
+# dependency of the .so build
+lk_deps += custom_target(lib_name + '.sym_chk',
+command: [check_symbols, version_map, '@INPUT@'],
+capture: true,
+input: static_lib,
+output: lib_name + '.sym_chk')
+endif
 endif
+
 endif
 
 shared_lib = shared_library(lib_name, sources,
-- 
2.27.0



[PATCH v4 1/2] build: make version file optional for drivers

2022-10-12 Thread Abdullah Ömer Yamaç
In this patch, we removed the necessity of the version files and
you don't need to update these files for each release, you can just
remove them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 
Series-acked-by: Bruce Richardson 
---
 drivers/meson.build | 65 +
 1 file changed, 36 insertions(+), 29 deletions(-)

diff --git a/drivers/meson.build b/drivers/meson.build
index 216971f4e2..c0f3ec4037 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+fs = import('fs')
+
 # Defines the order of dependencies evaluation
 subdirs = [
 'common',
@@ -202,38 +204,43 @@ foreach subpath:subdirs
 version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), 
drv_path)
 implib = 'lib' + lib_name + '.dll.a'
 
-def_file = custom_target(lib_name + '_def',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_exports.def'.format(lib_name))
-
-mingw_map = custom_target(lib_name + '_mingw',
-command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
-input: version_map,
-output: '@0@_mingw.map'.format(lib_name))
-
-lk_deps = [version_map, def_file, mingw_map]
-if is_windows
-if is_ms_linker
-lk_args = ['-Wl,/def:' + def_file.full_path()]
-if meson.version().version_compare('<0.54.0')
-lk_args += ['-Wl,/implib:drivers\\' + implib]
+lk_deps = []
+lk_args = []
+if fs.is_file(version_map)
+def_file = custom_target(lib_name + '_def',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_exports.def'.format(lib_name))
+
+mingw_map = custom_target(lib_name + '_mingw',
+command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+input: version_map,
+output: '@0@_mingw.map'.format(lib_name))
+
+lk_deps = [version_map, def_file, mingw_map]
+if is_windows
+if is_ms_linker
+lk_args = ['-Wl,/def:' + def_file.full_path()]
+if meson.version().version_compare('<0.54.0')
+lk_args += ['-Wl,/implib:drivers\\' + implib]
+endif
+else
+lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
 endif
 else
-lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
-endif
-else
-lk_args = ['-Wl,--version-script=' + version_map]
-if developer_mode
-# on unix systems check the output of the
-# check-symbols.sh script, using it as a
-# dependency of the .so build
-lk_deps += custom_target(lib_name + '.sym_chk',
-command: [check_symbols, version_map, '@INPUT@'],
-capture: true,
-input: static_lib,
-output: lib_name + '.sym_chk')
+lk_args = ['-Wl,--version-script=' + version_map]
+if developer_mode
+# on unix systems check the output of the
+# check-symbols.sh script, using it as a
+# dependency of the .so build
+lk_deps += custom_target(lib_name + '.sym_chk',
+command: [check_symbols, version_map, '@INPUT@'],
+capture: true,
+input: static_lib,
+output: lib_name + '.sym_chk')
+endif
 endif
+
 endif
 
 shared_lib = shared_library(lib_name, sources,
-- 
2.27.0



[PATCH v4 2/2] drivers: remove the unnecessary

2022-10-12 Thread Abdullah Ömer Yamaç
With the previous patch, some version.map files are not necessary.
In this patch, we removed them.

Signed-off-by: Abdullah Ömer Yamaç 
Suggested-by: Ferruh Yigit 
Series-acked-by: Bruce Richardson 
---
 drivers/baseband/la12xx/version.map   | 3 ---
 drivers/baseband/null/version.map | 3 ---
 drivers/baseband/turbo_sw/version.map | 3 ---
 drivers/common/qat/version.map| 3 ---
 drivers/compress/isal/version.map | 3 ---
 drivers/compress/mlx5/version.map | 3 ---
 drivers/compress/octeontx/version.map | 3 ---
 drivers/compress/zlib/version.map | 3 ---
 drivers/crypto/armv8/version.map  | 3 ---
 drivers/crypto/bcmfs/version.map  | 3 ---
 drivers/crypto/caam_jr/version.map| 3 ---
 drivers/crypto/ccp/version.map| 3 ---
 drivers/crypto/ipsec_mb/version.map   | 3 ---
 drivers/crypto/mlx5/version.map   | 3 ---
 drivers/crypto/mvsam/version.map  | 3 ---
 drivers/crypto/nitrox/version.map | 3 ---
 drivers/crypto/null/version.map   | 3 ---
 drivers/crypto/openssl/version.map| 3 ---
 drivers/crypto/virtio/version.map | 3 ---
 drivers/dma/cnxk/version.map  | 3 ---
 drivers/dma/dpaa/version.map  | 3 ---
 drivers/dma/hisilicon/version.map | 3 ---
 drivers/dma/idxd/version.map  | 3 ---
 drivers/dma/ioat/version.map  | 3 ---
 drivers/dma/skeleton/version.map  | 3 ---
 drivers/event/cnxk/version.map| 3 ---
 drivers/event/dpaa/version.map| 3 ---
 drivers/event/dpaa2/version.map   | 3 ---
 drivers/event/dsw/version.map | 3 ---
 drivers/event/octeontx/version.map| 3 ---
 drivers/event/opdl/version.map| 3 ---
 drivers/event/skeleton/version.map| 3 ---
 drivers/event/sw/version.map  | 3 ---
 drivers/gpu/cuda/version.map  | 3 ---
 drivers/mempool/bucket/version.map| 3 ---
 drivers/mempool/cnxk/version.map  | 3 ---
 drivers/mempool/octeontx/version.map  | 3 ---
 drivers/mempool/ring/version.map  | 3 ---
 drivers/mempool/stack/version.map | 3 ---
 drivers/net/af_packet/version.map | 3 ---
 drivers/net/af_xdp/version.map| 3 ---
 drivers/net/ark/version.map   | 3 ---
 drivers/net/avp/version.map   | 3 ---
 drivers/net/axgbe/version.map | 3 ---
 drivers/net/bnx2x/version.map | 3 ---
 drivers/net/cxgbe/version.map | 3 ---
 drivers/net/e1000/version.map | 3 ---
 drivers/net/ena/version.map   | 3 ---
 drivers/net/enetc/version.map | 3 ---
 drivers/net/enetfec/version.map   | 3 ---
 drivers/net/enic/version.map  | 3 ---
 drivers/net/failsafe/version.map  | 3 ---
 drivers/net/fm10k/version.map | 3 ---
 drivers/net/hinic/version.map | 3 ---
 drivers/net/hns3/version.map  | 3 ---
 drivers/net/igc/version.map   | 3 ---
 drivers/net/ionic/version.map | 3 ---
 drivers/net/kni/version.map   | 3 ---
 drivers/net/liquidio/version.map  | 3 ---
 drivers/net/mana/version.map  | 3 ---
 drivers/net/memif/version.map | 3 ---
 drivers/net/mlx4/version.map  | 3 ---
 drivers/net/mvneta/version.map| 3 ---
 drivers/net/mvpp2/version.map | 3 ---
 drivers/net/netvsc/version.map| 3 ---
 drivers/net/nfb/version.map   | 3 ---
 drivers/net/nfp/version.map   | 3 ---
 drivers/net/ngbe/version.map  | 3 ---
 drivers/net/null/version.map  | 3 ---
 drivers/net/octeon_ep/version.map | 3 ---
 drivers/net/pcap/version.map  | 3 ---
 drivers/net/pfe/version.map   | 3 ---
 drivers/net/qede/version.map  | 3 ---
 drivers/net/sfc/version.map   | 3 ---
 drivers/net/tap/version.map   | 3 ---
 drivers/net/thunderx/version.map  | 3 ---
 drivers/net/txgbe/version.map | 3 ---
 drivers/net/vdev_netvsc/version.map   | 3 ---
 drivers/net/virtio/version.map| 3 ---
 drivers/net/vmxnet3/version.map   | 3 ---
 drivers/raw/cnxk_bphy/version.map | 3 ---
 drivers/raw/cnxk_gpio/version.map | 3 ---
 drivers/raw/dpaa2_cmdif/version.map   | 3 ---
 drivers/raw/ntb/version.map   | 3 ---
 drivers/raw/skeleton/version.map  | 3 ---
 drivers/regex/cn9k/version.map| 3 ---
 drivers/regex/mlx5/version.map| 3 ---
 drivers/vdpa/ifc/version.map  | 3 ---
 drivers/vdpa/mlx5/version.map | 3 ---
 drivers/vdpa/sfc/version.map  | 3 ---
 90 files changed, 270 deletions(-)
 delete mode 100644 drivers/baseband/la12xx/version.map
 delete mode 100644 drivers/baseband/null/version.map
 delete mode 100644 drivers/baseband/turbo_sw/version.map
 delete mode 100644 drivers/common/qat/version.map
 delete mode 100644 drivers/compress/isal/version.map
 delete mode 100644 drivers/compress/mlx5/version.map
 delete mode 100644 drivers/compress/octeontx/version.map
 delete mode 100644 drivers/compress/zlib/version.map
 delete mode 100644 drivers/crypto/armv8/version.map
 delete mode 100644 drivers/crypto

[PATCH v4] examples/distributor: remove dead code and renaming Rx,Tx

2022-11-24 Thread Abdullah Ömer Yamaç
One line of commented code was dead code, this line and releated
comments are removed. Naming of rx,RX and tx,TX are replaced by Rx and
Tx.

Signed-off-by: Abdullah Ömer Yamaç 
---
CC: Thomas Monjalon 
---
 examples/distributor/main.c | 51 +
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d6618..d54e241110 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -104,7 +104,7 @@ struct output_buffer {
 static void print_stats(void);
 
 /*
- * Initialises a given port using global settings and with the rx buffers
+ * Initialises a given port using global settings and with the Rx buffers
  * coming from the mbuf_pool passed as parameter
  */
 static inline int
@@ -259,12 +259,7 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-   /*
-* Swap the following two lines if you want the rx traffic
-* to go directly to tx, no distribution.
-*/
struct rte_ring *out_ring = p->rx_dist_ring;
-   /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
uint16_t sent = rte_ring_enqueue_burst(out_ring,
(void *)bufs, nb_rx, NULL);
@@ -282,7 +277,7 @@ lcore_rx(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
/* set distributor threads quit flag */
quit_signal_dist = 1;
return 0;
@@ -305,11 +300,11 @@ lcore_rx_and_distributor(struct lcore_params *p)
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
-   "RX thread.\n\tPerformance will not "
+   "Rx thread.\n\tPerformance will not "
"be optimal.\n", port);
}
 
-   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   printf("\nCore %u doing packet Rx and Distributor.\n", rte_lcore_id());
port = 0;
while (!quit_signal_rx) {
 
@@ -329,8 +324,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
app_stats.rx.rx_pkts += nb_rx;
 
/*
-* Run the distributor on the rx core. Returned
-* packets are then send straight to the tx core.
+* Run the distributor on the Rx core. Returned
+* packets are then send straight to the Tx core.
 */
rte_distributor_process(d, bufs, nb_rx);
const uint16_t nb_ret = rte_distributor_returned_pkts(d,
@@ -360,8 +355,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -448,7 +443,7 @@ lcore_distributor(struct lcore_params *p)
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
printf("\nCore %u exiting distributor task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -524,7 +519,7 @@ lcore_tx(struct rte_ring *in_r)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting tx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Tx task.\n", rte_lcore_id());
return 0;
 }
 
@@ -532,7 +527,7 @@ static void
 int_handler(int sig_num)
 {
printf("Exiting on signal %d\n", sig_num);
-   /* set quit flag for rx thread to exit */
+   /* set quit flag for Rx thread to exit */
quit_signal_rx = 1;
 }
 
@@ -698,7 +693,7 @@ print_usage(const char *prgname)
 {
printf("%s [EAL options] -- -p PORTMASK [-c]\n"
"  -p PORTMASK: hexadecimal bitmask of ports to 
configure\n"
-   "  -c: Combines the RX core with the distribution 
core\n",
+   "  -c: Combines the Rx core with the distribution 
core\n",
prgname

[PATCH v5] examples/distributor: remove dead code and renaming Rx,Tx

2022-11-24 Thread Abdullah Ömer Yamaç
One line of commented code was dead code, this line and related
comments are removed. Naming of rx,RX and tx,TX are replaced by Rx and
Tx.

Signed-off-by: Abdullah Ömer Yamaç 
---
CC: Thomas Monjalon 
---
 examples/distributor/main.c | 51 +
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d6618..d54e241110 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -104,7 +104,7 @@ struct output_buffer {
 static void print_stats(void);
 
 /*
- * Initialises a given port using global settings and with the rx buffers
+ * Initialises a given port using global settings and with the Rx buffers
  * coming from the mbuf_pool passed as parameter
  */
 static inline int
@@ -259,12 +259,7 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-   /*
-* Swap the following two lines if you want the rx traffic
-* to go directly to tx, no distribution.
-*/
struct rte_ring *out_ring = p->rx_dist_ring;
-   /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
uint16_t sent = rte_ring_enqueue_burst(out_ring,
(void *)bufs, nb_rx, NULL);
@@ -282,7 +277,7 @@ lcore_rx(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
/* set distributor threads quit flag */
quit_signal_dist = 1;
return 0;
@@ -305,11 +300,11 @@ lcore_rx_and_distributor(struct lcore_params *p)
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
-   "RX thread.\n\tPerformance will not "
+   "Rx thread.\n\tPerformance will not "
"be optimal.\n", port);
}
 
-   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   printf("\nCore %u doing packet Rx and Distributor.\n", rte_lcore_id());
port = 0;
while (!quit_signal_rx) {
 
@@ -329,8 +324,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
app_stats.rx.rx_pkts += nb_rx;
 
/*
-* Run the distributor on the rx core. Returned
-* packets are then send straight to the tx core.
+* Run the distributor on the Rx core. Returned
+* packets are then send straight to the Tx core.
 */
rte_distributor_process(d, bufs, nb_rx);
const uint16_t nb_ret = rte_distributor_returned_pkts(d,
@@ -360,8 +355,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -448,7 +443,7 @@ lcore_distributor(struct lcore_params *p)
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
printf("\nCore %u exiting distributor task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -524,7 +519,7 @@ lcore_tx(struct rte_ring *in_r)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting tx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Tx task.\n", rte_lcore_id());
return 0;
 }
 
@@ -532,7 +527,7 @@ static void
 int_handler(int sig_num)
 {
printf("Exiting on signal %d\n", sig_num);
-   /* set quit flag for rx thread to exit */
+   /* set quit flag for Rx thread to exit */
quit_signal_rx = 1;
 }
 
@@ -698,7 +693,7 @@ print_usage(const char *prgname)
 {
printf("%s [EAL options] -- -p PORTMASK [-c]\n"
"  -p PORTMASK: hexadecimal bitmask of ports to 
configure\n"
-   "  -c: Combines the RX core with the distribution 
core\n",
+   "  -c: Combines the Rx core with the distribution 
core\n",
prgname

[PATCH v6] examples/distributor: remove dead code and renaming Rx,Tx

2022-11-24 Thread Abdullah Ömer Yamaç
One line of commented code was dead code, this line and related
comments are removed. Naming of rx,RX and tx,TX are replaced by Rx and
Tx.

Signed-off-by: Abdullah Ömer Yamaç 
---
CC: Thomas Monjalon 
---
 examples/distributor/main.c | 53 +
 1 file changed, 24 insertions(+), 29 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d6618..e12cd5760c 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -104,7 +104,7 @@ struct output_buffer {
 static void print_stats(void);
 
 /*
- * Initialises a given port using global settings and with the rx buffers
+ * Initialises a given port using global settings and with the Rx buffers
  * coming from the mbuf_pool passed as parameter
  */
 static inline int
@@ -259,12 +259,7 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-   /*
-* Swap the following two lines if you want the rx traffic
-* to go directly to tx, no distribution.
-*/
struct rte_ring *out_ring = p->rx_dist_ring;
-   /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
uint16_t sent = rte_ring_enqueue_burst(out_ring,
(void *)bufs, nb_rx, NULL);
@@ -282,7 +277,7 @@ lcore_rx(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
/* set distributor threads quit flag */
quit_signal_dist = 1;
return 0;
@@ -305,11 +300,11 @@ lcore_rx_and_distributor(struct lcore_params *p)
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
-   "RX thread.\n\tPerformance will not "
+   "Rx thread.\n\tPerformance will not "
"be optimal.\n", port);
}
 
-   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   printf("\nCore %u doing packet Rx and Distributor.\n", rte_lcore_id());
port = 0;
while (!quit_signal_rx) {
 
@@ -329,8 +324,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
app_stats.rx.rx_pkts += nb_rx;
 
/*
-* Run the distributor on the rx core. Returned
-* packets are then send straight to the tx core.
+* Run the distributor on the Rx core. Returned
+* packets are then send straight to the Tx core.
 */
rte_distributor_process(d, bufs, nb_rx);
const uint16_t nb_ret = rte_distributor_returned_pkts(d,
@@ -360,8 +355,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -448,7 +443,7 @@ lcore_distributor(struct lcore_params *p)
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
printf("\nCore %u exiting distributor task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -524,7 +519,7 @@ lcore_tx(struct rte_ring *in_r)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting tx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Tx task.\n", rte_lcore_id());
return 0;
 }
 
@@ -532,7 +527,7 @@ static void
 int_handler(int sig_num)
 {
printf("Exiting on signal %d\n", sig_num);
-   /* set quit flag for rx thread to exit */
+   /* set quit flag for Rx thread to exit */
quit_signal_rx = 1;
 }
 
@@ -698,7 +693,7 @@ print_usage(const char *prgname)
 {
printf("%s [EAL options] -- -p PORTMASK [-c]\n"
"  -p PORTMASK: hexadecimal bitmask of ports to 
configure\n"
-   "  -c: Combines the RX core with the distribution 
core\n",
+   "  -c: Combines the Rx core with the distribution 
core\n",
prgname

[PATCH v7] examples/distributor: remove dead code and renaming Rx,Tx

2022-11-24 Thread Abdullah Ömer Yamaç
One line of commented code was dead code, this line and related
comments are removed. Naming of rx,RX and tx,TX are replaced by Rx and
Tx.

Signed-off-by: Abdullah Ömer Yamaç 
---
CC: Thomas Monjalon 
---
 examples/distributor/main.c | 55 +
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 21304d6618..9280a2694e 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -104,7 +104,7 @@ struct output_buffer {
 static void print_stats(void);
 
 /*
- * Initialises a given port using global settings and with the rx buffers
+ * Initialises a given port using global settings and with the Rx buffers
  * coming from the mbuf_pool passed as parameter
  */
 static inline int
@@ -259,12 +259,7 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-   /*
-* Swap the following two lines if you want the rx traffic
-* to go directly to tx, no distribution.
-*/
struct rte_ring *out_ring = p->rx_dist_ring;
-   /* struct rte_ring *out_ring = p->dist_tx_ring; */
 
uint16_t sent = rte_ring_enqueue_burst(out_ring,
(void *)bufs, nb_rx, NULL);
@@ -282,7 +277,7 @@ lcore_rx(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
/* set distributor threads quit flag */
quit_signal_dist = 1;
return 0;
@@ -305,11 +300,11 @@ lcore_rx_and_distributor(struct lcore_params *p)
if (rte_eth_dev_socket_id(port) > 0 &&
rte_eth_dev_socket_id(port) != socket_id)
printf("WARNING, port %u is on remote NUMA node to "
-   "RX thread.\n\tPerformance will not "
+   "Rx thread.\n\tPerformance will not "
"be optimal.\n", port);
}
 
-   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   printf("\nCore %u doing packet Rx and Distributor.\n", rte_lcore_id());
port = 0;
while (!quit_signal_rx) {
 
@@ -329,8 +324,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
app_stats.rx.rx_pkts += nb_rx;
 
/*
-* Run the distributor on the rx core. Returned
-* packets are then send straight to the tx core.
+* Run the distributor on the Rx core. Returned
+* packets are then send straight to the Tx core.
 */
rte_distributor_process(d, bufs, nb_rx);
const uint16_t nb_ret = rte_distributor_returned_pkts(d,
@@ -360,8 +355,8 @@ lcore_rx_and_distributor(struct lcore_params *p)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   printf("\nCore %u exiting Rx task.\n", rte_lcore_id());
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -448,7 +443,7 @@ lcore_distributor(struct lcore_params *p)
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
printf("\nCore %u exiting distributor task.\n", rte_lcore_id());
-   /* set tx threads quit flag */
+   /* set Tx threads quit flag */
quit_signal = 1;
/* set worker threads quit flag */
quit_signal_work = 1;
@@ -478,7 +473,7 @@ lcore_tx(struct rte_ring *in_r)
"be optimal.\n", port);
}
 
-   printf("\nCore %u doing packet TX.\n", rte_lcore_id());
+   printf("\nCore %u doing packet Tx.\n", rte_lcore_id());
while (!quit_signal) {
 
RTE_ETH_FOREACH_DEV(port) {
@@ -524,7 +519,7 @@ lcore_tx(struct rte_ring *in_r)
}
if (power_lib_initialised)
rte_power_exit(rte_lcore_id());
-   printf("\nCore %u exiting tx task.\n", rte_lcore_id());
+   printf("\nCore %u exiting Tx task.\n", rte_lcore_id());
return 0;
 }
 
@@ -532,7 +527,7 @@ static void
 int_handler(int sig_num)
 {
printf("Exiting on signal %d\n", sig_num);
-   /* set quit flag for rx thread to exit */
+   /* set quit flag for Rx thread to exit */
quit_signal_rx = 1;
 }
 
@@ -698,7 +693,7 @@ print_usage(const char *prgname)
 {
printf(

[PATCH v3] examples/distributor: update dynamic configuration

2022-09-01 Thread Abdullah Ömer Yamaç
In this patch,
* It is possible to switch the running mode of the distributor
using the command line argument.
* With "-c" parameter, you can run RX and Distributor
on the same core.
* Without "-c" parameter, you can run RX and Distributor
on the different core.
* Consecutive termination of the lcores fixed.
The termination order was wrong, and you couldn't terminate the
application while traffic was capturing. The current order is
RX -> Distributor -> TX -> Workers
* When "-c" parameter is active, the wasted distributor core is
also deactivated in the main function.

Signed-off-by: Abdullah Ömer Yamaç 

---
Cc: david.h...@intel.com
---
 doc/guides/sample_app_ug/dist_app.rst |   3 +-
 examples/distributor/main.c   | 222 ++
 2 files changed, 159 insertions(+), 66 deletions(-)

diff --git a/doc/guides/sample_app_ug/dist_app.rst 
b/doc/guides/sample_app_ug/dist_app.rst
index 3bd03905c3..5c80561187 100644
--- a/doc/guides/sample_app_ug/dist_app.rst
+++ b/doc/guides/sample_app_ug/dist_app.rst
@@ -42,11 +42,12 @@ Running the Application
 
..  code-block:: console
 
-   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK
+   .//examples/dpdk-distributor [EAL options] -- -p PORTMASK 
[-c]
 
where,
 
*   -p PORTMASK: Hexadecimal bitmask of ports to configure
+   *   -c: Combines the RX core with distribution core
 
 #. To run the application in linux environment with 10 lcores, 4 ports,
issue the command:
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 8995806b4e..fc9a75f695 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -39,6 +39,8 @@ volatile uint8_t quit_signal_rx;
 volatile uint8_t quit_signal_dist;
 volatile uint8_t quit_signal_work;
 unsigned int power_lib_initialised;
+bool enable_lcore_rx_distributor;
+unsigned int num_workers;
 
 static volatile struct app_stats {
struct {
@@ -256,14 +258,82 @@ lcore_rx(struct lcore_params *p)
}
app_stats.rx.rx_pkts += nb_rx;
 
-/*
- * You can run the distributor on the rx core with this code. Returned
- * packets are then send straight to the tx core.
- */
-#if 0
-   rte_distributor_process(p->d, bufs, nb_rx);
-   const uint16_t nb_ret = rte_distributor_returned_pkts(p->d,
-   bufs, BURST_SIZE*2);
+   /*
+* Swap the following two lines if you want the rx traffic
+* to go directly to tx, no distribution.
+*/
+   struct rte_ring *out_ring = p->rx_dist_ring;
+   /* struct rte_ring *out_ring = p->dist_tx_ring; */
+
+   uint16_t sent = rte_ring_enqueue_burst(out_ring,
+   (void *)bufs, nb_rx, NULL);
+
+   app_stats.rx.enqueued_pkts += sent;
+   if (unlikely(sent < nb_rx)) {
+   app_stats.rx.enqdrop_pkts +=  nb_rx - sent;
+   RTE_LOG_DP(DEBUG, DISTRAPP,
+   "%s:Packet loss due to full ring\n", __func__);
+   while (sent < nb_rx)
+   rte_pktmbuf_free(bufs[sent++]);
+   }
+   if (++port == nb_ports)
+   port = 0;
+   }
+   if (power_lib_initialised)
+   rte_power_exit(rte_lcore_id());
+   printf("\nCore %u exiting rx task.\n", rte_lcore_id());
+   /* set distributor threads quit flag */
+   quit_signal_dist = 1;
+   return 0;
+}
+
+static int
+lcore_rx_and_distributor(struct lcore_params *p)
+{
+   struct rte_distributor *d = p->d;
+   const uint16_t nb_ports = rte_eth_dev_count_avail();
+   const int socket_id = rte_socket_id();
+   uint16_t port;
+   struct rte_mbuf *bufs[BURST_SIZE*2];
+
+   RTE_ETH_FOREACH_DEV(port) {
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0)
+   continue;
+
+   if (rte_eth_dev_socket_id(port) > 0 &&
+   rte_eth_dev_socket_id(port) != socket_id)
+   printf("WARNING, port %u is on remote NUMA node to "
+   "RX thread.\n\tPerformance will not "
+   "be optimal.\n", port);
+   }
+
+   printf("\nCore %u doing packet RX and Distributor.\n", rte_lcore_id());
+   port = 0;
+   while (!quit_signal_rx) {
+
+   /* skip ports that are not enabled */
+   if ((enabled_port_mask & (1 << port)) == 0) {
+   if (++port == nb_ports)
+   port = 0;
+   continue;
+   }
+   const uint16_t

[PATCH v6] devtools: add .clang-format file

2024-10-14 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 153 ++
 1 file changed, 153 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..805c08da1d
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2023 Abdullah Ömer Yamaç.
+#
+
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: true
+AfterControlStatement: false
+
+AllowShortEnumsOnASingleLine: false
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+AfterForeachMacros: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 16 spaces (2 tabs)
+AlignAfterOpenBracket: DontAlign
+ContinuationIndentWidth: 16
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros:
+[
+"CIRBUF_FOREACH",
+"DLB2_LIST_FOR_EACH",
+"DLB2_LIST_FOR_EACH_SAFE",
+"ECORE_LIST_FOR_EACH_ENTRY",
+"ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+"FOR_EACH",
+"FOR_EACH_BUCKET",
+"FOR_EACH_CNIC_QUEUE",
+"FOR_EACH_COS_IN_TX_QUEUE",
+"FOR_EACH_ETH_QUEUE",
+"FOR_EACH_MEMBER",
+"FOR_EACH_NONDEFAULT_ETH_QUEUE",
+"FOR_EACH_NONDEFAULT_QUEUE",
+"FOR_EACH_PORT",
+"FOR_EACH_PORT_IF",
+"FOR_EACH_QUEUE",
+"FOR_EACH_SUITE_TESTCASE",
+"FOR_EACH_SUITE_TESTSUITE",
+"FOREACH_ABS_FUNC_IN_PORT",
+"FOREACH_DEVICE_ON_AUXILIARY_BUS",
+"FOREACH_DEVICE_ON_CDXBUS",
+"FOREACH_DEVICE_ON_PCIBUS",
+"FOREACH_DEVICE_ON_PLATFORM_BUS",
+"FOREACH_DEVICE_ON_UACCEBUS",
+"FOREACH_DEVICE_ON_VMBUS",
+"FOREACH_DRIVER_ON_AUXILIARY_BUS",
+"FOREACH_DRIVER_ON_CDXBUS",
+"FOREACH_DRIVER_ON_PCIBUS",
+"FOREACH_DRIVER_ON_PLATFORM_BUS",
+"FOREACH_DRIVER_ON_UACCEBUS",
+"FOREACH_DRIVER_ON_VMBUS",
+"FOREACH_SUBDEV",
+"FOREACH_SUBDEV_STATE",
+"HLIST_FOR_EACH_ENTRY",
+"ILIST_FOREACH",
+"LIST_FOR_EACH_ENTRY",
+"LIST_FOR_EACH_ENTRY_SAFE",
+"LIST_FOREACH",
+"LIST_FOREACH_FROM",
+"LIST_FOREACH_FROM_SAFE",
+"LIST_FOREACH_SAFE",
+"ML_AVG_FOREACH_QP",
+"ML_AVG_FOREACH_QP_MVTVM",
+"ML_AVG_RESET_FOREACH_QP",
+"ML_MAX_FOREACH_QP",
+"ML_MAX_FOREACH_QP_MVTVM",
+"ML_MAX_RESET_FOREACH_QP",
+"ML_MIN_FOREACH_QP",
+"ML_MIN_FOREACH_QP_MVTVM",
+"ML_MIN_RESET_FOREACH_QP",
+"MLX5_ETH_FOREACH_DEV",
+"MLX5_IPOOL_FOREACH",
+"MLX5_L3T_FOREACH",
+"OSAL_LIST_FOR_EACH_ENTRY",
+"OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+"PLT_TAILQ_FOREACH_SAFE",
+"RTE_BB

[PATCH v6] devtools: add .clang-format file

2024-10-14 Thread Abdullah Ömer Yamaç
clang-format is a tool to format C/C++/Objective-C code. It can be used
to reformat code to match a given coding style, or to ensure that code
adheres to a specific coding style. It helps to maintain a consistent
coding style across the DPDK codebase.

.clang-format file overrides the default style options provided by
clang-format and large set of IDEs and text editors support it.

Signed-off-by: Abdullah Ömer Yamaç 
---
 .clang-format | 153 ++
 1 file changed, 153 insertions(+)
 create mode 100644 .clang-format

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00..805c08da1d
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2024 Abdullah Ömer Yamaç.
+#
+
+---
+BasedOnStyle: LLVM
+
+# Place opening and closing parentheses on the same line for control statements
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterFunction: true
+AfterControlStatement: false
+
+AllowShortEnumsOnASingleLine: false
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+AfterForeachMacros: false
+
+# Set maximum line length to 100 characters
+ColumnLimit: 100
+
+# Use LF (line feed) as the end-of-line character
+LineEnding: LF
+
+# Insert a newline at the end of the file
+InsertNewlineAtEOF: true
+
+# Set indentation width to 8 spaces
+IndentWidth: 8
+
+# Set continuation indentation width to 16 spaces (2 tabs)
+AlignAfterOpenBracket: DontAlign
+ContinuationIndentWidth: 16
+
+# Set tab width to 8 spaces
+TabWidth: 8
+
+# Use tabs for indentation
+UseTab: Always
+
+# Preserve include blocks as they are
+IncludeBlocks: Preserve
+
+# Never sort includes
+SortIncludes: Never
+
+# Always break after return type for top-level definitions
+AlwaysBreakAfterReturnType: TopLevelDefinitions
+
+# Always break before multiline string literals
+AlignEscapedNewlines: Left
+
+# Foreach macros
+ForEachMacros:
+[
+"CIRBUF_FOREACH",
+"DLB2_LIST_FOR_EACH",
+"DLB2_LIST_FOR_EACH_SAFE",
+"ECORE_LIST_FOR_EACH_ENTRY",
+"ECORE_LIST_FOR_EACH_ENTRY_SAFE",
+"FOR_EACH",
+"FOR_EACH_BUCKET",
+"FOR_EACH_CNIC_QUEUE",
+"FOR_EACH_COS_IN_TX_QUEUE",
+"FOR_EACH_ETH_QUEUE",
+"FOR_EACH_MEMBER",
+"FOR_EACH_NONDEFAULT_ETH_QUEUE",
+"FOR_EACH_NONDEFAULT_QUEUE",
+"FOR_EACH_PORT",
+"FOR_EACH_PORT_IF",
+"FOR_EACH_QUEUE",
+"FOR_EACH_SUITE_TESTCASE",
+"FOR_EACH_SUITE_TESTSUITE",
+"FOREACH_ABS_FUNC_IN_PORT",
+"FOREACH_DEVICE_ON_AUXILIARY_BUS",
+"FOREACH_DEVICE_ON_CDXBUS",
+"FOREACH_DEVICE_ON_PCIBUS",
+"FOREACH_DEVICE_ON_PLATFORM_BUS",
+"FOREACH_DEVICE_ON_UACCEBUS",
+"FOREACH_DEVICE_ON_VMBUS",
+"FOREACH_DRIVER_ON_AUXILIARY_BUS",
+"FOREACH_DRIVER_ON_CDXBUS",
+"FOREACH_DRIVER_ON_PCIBUS",
+"FOREACH_DRIVER_ON_PLATFORM_BUS",
+"FOREACH_DRIVER_ON_UACCEBUS",
+"FOREACH_DRIVER_ON_VMBUS",
+"FOREACH_SUBDEV",
+"FOREACH_SUBDEV_STATE",
+"HLIST_FOR_EACH_ENTRY",
+"ILIST_FOREACH",
+"LIST_FOR_EACH_ENTRY",
+"LIST_FOR_EACH_ENTRY_SAFE",
+"LIST_FOREACH",
+"LIST_FOREACH_FROM",
+"LIST_FOREACH_FROM_SAFE",
+"LIST_FOREACH_SAFE",
+"ML_AVG_FOREACH_QP",
+"ML_AVG_FOREACH_QP_MVTVM",
+"ML_AVG_RESET_FOREACH_QP",
+"ML_MAX_FOREACH_QP",
+"ML_MAX_FOREACH_QP_MVTVM",
+"ML_MAX_RESET_FOREACH_QP",
+"ML_MIN_FOREACH_QP",
+"ML_MIN_FOREACH_QP_MVTVM",
+"ML_MIN_RESET_FOREACH_QP",
+"MLX5_ETH_FOREACH_DEV",
+"MLX5_IPOOL_FOREACH",
+"MLX5_L3T_FOREACH",
+"OSAL_LIST_FOR_EACH_ENTRY",
+"OSAL_LIST_FOR_EACH_ENTRY_SAFE",
+"PLT_TAILQ_FOREACH_SAFE",
+"RTE_BB