Skip to content

Commit

Permalink
Necessary changes to migrate to DPDK_23_11
Browse files Browse the repository at this point in the history
  • Loading branch information
byteocean authored and guvenc committed Mar 15, 2024
1 parent 1a8d901 commit 9d18a8b
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 107 deletions.
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM --platform=${TARGETPLATFORM} debian:12-slim AS builder

ARG TARGETARCH
ARG DPDK_VER=22.11
ARG DPDK_VER=23.11
ARG DPSERVICE_FEATURES=""
ARG CLI_VERSION=0.3.0
ARG EXPORTER_VERSION=0.1.8
Expand Down Expand Up @@ -54,10 +54,9 @@ ENV DPDK_DIR=/workspace/dpdk-${DPDK_VER}
# Copy DPDK patches
COPY hack/*.patch hack/
RUN cd $DPDK_DIR \
&& patch -p1 < ../hack/dpdk_22_11_gcc12.patch \
&& patch -p1 < ../hack/dpdk_22_11_log.patch \
&& patch -p1 < ../hack/dpdk_22_11_telemetry_key.patch \
&& patch -p1 < ../hack/dpdk_22_11_ethdev_conversion.patch
&& patch -p1 < ../hack/dpdk_23_11_log.patch \
&& patch -p1 < ../hack/dpdk_23_11_telemetry_key.patch \
&& patch -p1 < ../hack/dpdk_23_11_ethdev_conversion.patch

# Compile DPDK
RUN cd $DPDK_DIR && meson setup -Dmax_ethports=132 -Dplatform=generic -Ddisable_drivers=common/dpaax,\
Expand Down
26 changes: 0 additions & 26 deletions hack/dpdk_22_11_ethdev_conversion.patch

This file was deleted.

26 changes: 0 additions & 26 deletions hack/dpdk_22_11_gcc12.patch

This file was deleted.

17 changes: 0 additions & 17 deletions hack/dpdk_22_11_telemetry_key.patch

This file was deleted.

24 changes: 24 additions & 0 deletions hack/dpdk_23_11_ethdev_conversion.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --color -ruN dpdk-23.11/lib/ethdev/rte_ethdev.c dpdk-23.11-patch/lib/ethdev/rte_ethdev.c
--- dpdk-23.11/lib/ethdev/rte_ethdev.c 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/ethdev/rte_ethdev.c 2024-03-04 12:28:35.492608466 +0000
@@ -428,7 +428,7 @@
return 1;
}

-uint64_t
+uint16_t
rte_eth_find_next_owned_by(uint16_t port_id, const uint64_t owner_id)
{
port_id = rte_eth_find_next(port_id);
diff --color -ruN dpdk-23.11/lib/ethdev/rte_ethdev.h dpdk-23.11-patch/lib/ethdev/rte_ethdev.h
--- dpdk-23.11/lib/ethdev/rte_ethdev.h 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/ethdev/rte_ethdev.h 2024-03-04 12:28:28.084570580 +0000
@@ -2126,7 +2126,7 @@
* @return
* Next valid port ID owned by owner_id, RTE_MAX_ETHPORTS if there is none.
*/
-uint64_t rte_eth_find_next_owned_by(uint16_t port_id,
+uint16_t rte_eth_find_next_owned_by(uint16_t port_id,
const uint64_t owner_id);

/**
45 changes: 21 additions & 24 deletions hack/dpdk_22_11_log.patch → hack/dpdk_23_11_log.patch
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
diff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c
index 1be35f5397..159beb63ab 100644
--- a/lib/eal/common/eal_common_log.c
+++ b/lib/eal/common/eal_common_log.c
@@ -28,11 +28,14 @@ static struct rte_logs {
diff --color -ruN dpdk-23.11/lib/log/log.c dpdk-23.11-patch/lib/log/log.c
--- dpdk-23.11/lib/log/log.c 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/log/log.c 2024-03-04 15:01:39.318300347 +0000
@@ -31,11 +31,14 @@
uint32_t type; /**< Bitfield with enabled logs. */
uint32_t level; /**< Log level. */
FILE *file; /**< Output file set by rte_openlog_stream, or NULL. */
Expand All @@ -17,7 +16,7 @@ index 1be35f5397..159beb63ab 100644
};

struct rte_eal_opt_loglevel {
@@ -77,6 +80,13 @@ rte_openlog_stream(FILE *f)
@@ -80,6 +83,13 @@
return 0;
}

Expand All @@ -31,7 +30,7 @@ index 1be35f5397..159beb63ab 100644
FILE *
rte_log_get_stream(void)
{
@@ -499,7 +509,7 @@ rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
@@ -501,7 +511,7 @@
RTE_PER_LCORE(log_cur_msg).loglevel = level;
RTE_PER_LCORE(log_cur_msg).logtype = logtype;

Expand All @@ -40,15 +39,13 @@ index 1be35f5397..159beb63ab 100644
fflush(f);
return ret;
}
diff --git a/lib/eal/include/rte_log.h b/lib/eal/include/rte_log.h
index 319e4044a5..ee17cf93a0 100644
--- a/lib/eal/include/rte_log.h
+++ b/lib/eal/include/rte_log.h
@@ -87,6 +87,18 @@ extern "C" {
*/
diff --color -ruN dpdk-23.11/lib/log/rte_log.h dpdk-23.11-patch/lib/log/rte_log.h
--- dpdk-23.11/lib/log/rte_log.h 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/log/rte_log.h 2024-03-04 15:03:08.442486094 +0000
@@ -88,6 +88,18 @@
int rte_openlog_stream(FILE *f);

+/**
/**
+ * Change the print function that will be used by the logging system.
+ *
+ * This can be done at any time. The func argument represents
Expand All @@ -60,18 +57,18 @@ index 319e4044a5..ee17cf93a0 100644
+ */
+void rte_log_set_print_func(int (*func)(FILE *stream, const char *format, va_list ap));
+
/**
+/**
* Retrieve the stream used by the logging system (see rte_openlog_stream()
* to change it).
diff --git a/lib/eal/version.map b/lib/eal/version.map
index ab28c22791..72c8a18111 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -155,6 +155,7 @@ DPDK_23 {
rte_log_set_level;
*
diff --color -ruN dpdk-23.11/lib/log/version.map dpdk-23.11-patch/lib/log/version.map
--- dpdk-23.11/lib/log/version.map 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/log/version.map 2024-03-04 15:03:23.118516680 +0000
@@ -17,6 +17,7 @@
rte_log_set_level_pattern;
rte_log_set_level_regexp;
rte_openlog_stream;
+ rte_log_set_print_func;
rte_malloc;
rte_malloc_dump_heaps;
rte_malloc_dump_stats;
rte_vlog;

local: *;
12 changes: 12 additions & 0 deletions hack/dpdk_23_11_telemetry_key.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --color -ruN dpdk-23.11/lib/telemetry/telemetry_data.c dpdk-23.11-patch/lib/telemetry/telemetry_data.c
--- dpdk-23.11/lib/telemetry/telemetry_data.c 2023-11-28 14:35:41.000000000 +0000
+++ dpdk-23.11-patch/lib/telemetry/telemetry_data.c 2024-03-04 13:35:15.585285834 +0000
@@ -141,7 +141,7 @@
valid_name(const char *name)
{
/* non-alphanumeric characters allowed in names */
- static const char allowed[128] = { ['_'] = 1, ['/'] = 1 };
+ static const char allowed[128] = { ['_'] = 1, ['/'] = 1, ['.'] = 1, [':'] = 1, ['-'] = 1 };

for (; *name != '\0'; name++) {
if (isalnum(*name))
10 changes: 7 additions & 3 deletions src/dp_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,18 @@ static int dp_port_init_ethdev(struct dp_port *port, struct rte_eth_dev_info *de
/* Default config */
port_conf.txmode.offloads &= dev_info->tx_offload_capa;

nr_hairpin_queues = port->is_pf
? (uint16_t)(DP_NR_PF_HAIRPIN_RX_TX_QUEUES + DP_NR_VF_HAIRPIN_RX_TX_QUEUES * dp_layer->num_of_vfs)
: DP_NR_VF_HAIRPIN_RX_TX_QUEUES;
if (dp_conf_get_nic_type() == DP_CONF_NIC_TYPE_TAP)
nr_hairpin_queues = 0;
else
nr_hairpin_queues = port->is_pf
? (uint16_t)(DP_NR_PF_HAIRPIN_RX_TX_QUEUES + DP_NR_VF_HAIRPIN_RX_TX_QUEUES * dp_layer->num_of_vfs)
: DP_NR_VF_HAIRPIN_RX_TX_QUEUES;

ret = rte_eth_dev_configure(port->port_id,
DP_NR_STD_RX_QUEUES + nr_hairpin_queues,
DP_NR_STD_TX_QUEUES + nr_hairpin_queues,
&port_conf);

if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot configure ethernet device", DP_LOG_PORT(port), DP_LOG_RET(ret));
return DP_ERROR;
Expand Down
4 changes: 3 additions & 1 deletion src/dp_telemetry.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ static int dp_telemetry_graph_stats_cb(__rte_unused bool is_first,
tel_callback_ret = -ENOMEM;
return tel_callback_ret;
}

tel_callback_ret = rte_tel_data_start_dict(tel_curr_block);
if (DP_FAILED(tel_callback_ret))
return tel_callback_ret;

snprintf(dict_name, sizeof(dict_name), "Node_%hd_to_%hd",
(uint16_t)(tel_graph_node_index-1), (uint16_t)(tel_graph_node_index + (RTE_TEL_MAX_DICT_ENTRIES-2)));
tel_callback_ret = rte_tel_data_add_dict_container(tel_data, dict_name, tel_curr_block, 0);
if (DP_FAILED(tel_callback_ret))
return tel_callback_ret;
}

tel_callback_ret = rte_tel_data_add_dict_u64(tel_curr_block, stats->name, get_stat_value(stats));
tel_callback_ret = rte_tel_data_add_dict_uint(tel_curr_block, stats->name, get_stat_value(stats));
if (DP_FAILED(tel_callback_ret))
return tel_callback_ret;

Expand Down
11 changes: 6 additions & 5 deletions src/grpc/dp_grpc_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#include "dp_log.h"
#include "grpc/dp_grpc_service.h"

static pthread_t grpc_thread_id;
static rte_thread_t grpc_thread_id;
// pthread_t is opaque, must use another value for checking
static bool grpc_thread_started = false;

static void *dp_grpc_main_loop(__rte_unused void *arg)
static uint32_t dp_grpc_main_loop(__rte_unused void *arg)
{
GRPCService *grpc_svc;
char addr[12]; // '[::]:65535\0'
Expand All @@ -29,7 +29,8 @@ static void *dp_grpc_main_loop(__rte_unused void *arg)
rte_exit(EXIT_FAILURE, "Cannot run without working gRPC server\n");

GRPCService::Cleanup();
return NULL;

return 0;
}

int dp_grpc_thread_start(void)
Expand All @@ -41,7 +42,7 @@ int dp_grpc_thread_start(void)
return DP_ERROR;
}

ret = rte_ctrl_thread_create(&grpc_thread_id, "grpc-thread", NULL, dp_grpc_main_loop, NULL);
ret = rte_thread_create_control(&grpc_thread_id, "grpc-thread", dp_grpc_main_loop, NULL);
if (DP_FAILED(ret)) {
DPS_LOG_ERR("Cannot create gRPC thread", DP_LOG_RET(ret));
return ret;
Expand All @@ -59,7 +60,7 @@ int dp_grpc_thread_cancel(void)
if (!grpc_thread_started)
return DP_OK;

ret = pthread_cancel(grpc_thread_id); // returns errno on failure
ret = pthread_cancel((pthread_t)grpc_thread_id.opaque_id); // returns errno on failure
if (ret) {
DPS_LOG_ERR("Cannot cancel gRPC thread", DP_LOG_RET(ret));
return ret;
Expand Down

0 comments on commit 9d18a8b

Please sign in to comment.