Skip to content

Commit

Permalink
New ZC API calls to check if a queue is locked and in use
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Dec 19, 2024
1 parent 860d63d commit 0c04f72
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 4 deletions.
12 changes: 8 additions & 4 deletions userland/examples_zc/zbalance_ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ void print_stats() {
char stats_buf[1024];
char time_buf[128];
double duration;
int i;
int b;
int i, b, in_use;

if (start_time.tv_sec == 0)
gettimeofday(&start_time, NULL);
Expand Down Expand Up @@ -394,10 +393,12 @@ void print_stats() {
for (b = 0; b < num_balancers; b++) {
for (i = 0; i < num_consumer_queues; i++) {
if (pfring_zc_stats(balancer[b].outzqs[i], &stats) == 0) {
in_use = pfring_zc_ipc_queue_in_use_from_queue(balancer[b].outzqs[i], rx_only);
if (!daemon_mode && !proc_stats_only) {
trace(TRACE_INFO, " Balancer %2u Queue %2u: RX %lu pkts Dropped %lu pkts (%.1f %%)\n",
trace(TRACE_INFO, " Balancer %2u Queue %2u: RX %lu pkts Dropped %lu pkts (%.1f %%) %s\n",
b, i, stats.recv, stats.drop,
stats.recv == 0 ? 0 : ((double)(stats.drop*100)/(double)(stats.recv + stats.drop)));
stats.recv == 0 ? 0 : ((double)(stats.drop*100)/(double)(stats.recv + stats.drop)),
in_use == 1 ? "Locked" : (in_use == 0 ? "Not-in-use" : ""));
}
if (outdevs[i]) {
snprintf(&stats_buf[strlen(stats_buf)], sizeof(stats_buf)-strlen(stats_buf),
Expand All @@ -412,6 +413,9 @@ void print_stats() {
i, (long unsigned int) stats.recv,
i, (long unsigned int) stats.drop);
}
if (in_use != -1)
snprintf(&stats_buf[strlen(stats_buf)], sizeof(stats_buf)-strlen(stats_buf),
"Q%uLocked: %s\n", i, in_use ? "Yes" : "No");
}
}
}
Expand Down
Binary file modified userland/lib/libs/libpfring_zc_x86_64.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_zc_x86_64.so
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_zc_x86_64_core-avx2.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_zc_x86_64_corei7-avx.a
Binary file not shown.
Binary file modified userland/lib/libs/libpfring_zc_x86_64_corei7.a
Binary file not shown.
42 changes: 42 additions & 0 deletions userland/lib/pfring_zc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,48 @@ pfring_zc_ipc_detach_queue(
pfring_zc_queue *queue
);

/**
* Check if a (rx or tx) queue is locked by another (live or dead) process.
* This function opens a new pfring file descriptor.
* @param cluster_id The cluster identifier.
* @param queue_id The queue identifier.
* @param queue_mode The direction to open, RX or TX.
* @return 1 is the queue is in use, 0 otherwise, -1 on failure checking.
*/
int
pfring_zc_ipc_queue_in_use(
u_int32_t cluster_id,
u_int32_t queue_id,
pfring_zc_queue_mode queue_mode
);

/**
* Check if a (rx or tx) queue is locked by another (live or dead) process.
* This function uses the file descriptor from a cluster handle.
* @param cluster The cluster handle.
* @param queue_id The queue identifier.
* @param queue_mode The direction to open, RX or TX.
* @return 1 is the queue is in use, 0 otherwise, -1 on failure checking.
*/
int
pfring_zc_ipc_queue_in_use_from_cluster(
pfring_zc_cluster *cluster,
u_int32_t queue_id,
pfring_zc_queue_mode queue_mode
);

/**
* Check if a (rx or tx) queue is locked by another (live or dead) process.
* @param queue The queue handle.
* @param queue_mode The direction to open, RX or TX.
* @return 1 is the queue is in use, 0 otherwise, -1 on failure checking.
*/
int
pfring_zc_ipc_queue_in_use_from_queue(
pfring_zc_queue *queue,
pfring_zc_queue_mode queue_mode
);

/* **************************************************************************************** */

/**
Expand Down

0 comments on commit 0c04f72

Please sign in to comment.