Skip to contentSkip to conversation

ipc: increase hotplug devargs limit

PATCH In review Thomas Monjalon 2 participants 3 messages Nov 3 – Nov 6

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipc: increase hotplug devargs limit

Derive the hotplug devargs buffer size from the IPC parameter capacity. This increases the maximum devargs length in multi-process mode from 127 to 247 bytes, excluding the terminating null byte.

---
 lib/eal/common/eal_common_dev.c | 2 +-
 lib/eal/common/hotplug_mp.h     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_dev.c +1 -1
index f42a8d2349..febb584313 100644
@@ -276,7 +276,7 @@ rte_dev_probe(const char *devargs)
 		goto skip_mp_req;
 
 	if (strlen(devargs) >= EAL_DEV_MP_DEV_ARGS_MAX_LEN) {
-		EAL_LOG(ERR, "devargs truncated (len %zu, max %d)",
+		EAL_LOG(ERR, "devargs truncated (len %zu, max %zu)",
 			strlen(devargs), EAL_DEV_MP_DEV_ARGS_MAX_LEN);
 		return -E2BIG;
 	}
lib/eal/common/hotplug_mp.h +7 -1
index 7221284286..bd2f0f296a 100644
@@ -5,6 +5,7 @@
 #ifndef _HOTPLUG_MP_H_
 #define _HOTPLUG_MP_H_
 
+#include "rte_eal.h"
 #include "rte_dev.h"
 
 #define EAL_DEV_MP_ACTION_REQUEST      "eal_dev_mp_request"
@@ -12,7 +13,9 @@
 
 #define EAL_DEV_MP_DEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
 #define EAL_DEV_MP_BUS_NAME_MAX_LEN 32
-#define EAL_DEV_MP_DEV_ARGS_MAX_LEN 128
+#define EAL_DEV_MP_DEV_ARGS_MAX_LEN (RTE_MP_MAX_PARAM_LEN \
+	- sizeof(enum eal_dev_req_type) - sizeof(int))
+	/* minus t and result from struct eal_dev_mp_req */
 
 enum eal_dev_req_type {
 	EAL_DEV_REQ_TYPE_ATTACH,
@@ -27,6 +30,9 @@ struct eal_dev_mp_req {
 	int result;
 };
 
+static_assert(sizeof(struct eal_dev_mp_req) <= RTE_MP_MAX_PARAM_LEN,
+	"Hotplug message struct exceeds IPC parameter capacity");
+
 /**
  * Register all mp action callbacks for hotplug.
  *
Signature · 1 line
2.55.0
#1 lore raw
Quoted 48 lines · Thomas Monjalon

Derive the hotplug devargs buffer size from the IPC parameter capacity. This increases the maximum devargs length in multi-process mode from 127 to 247 bytes, excluding the terminating null byte.

---
 lib/eal/common/eal_common_dev.c | 2 +-
 lib/eal/common/hotplug_mp.h     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_dev.c +1 -1
index f42a8d2349..febb584313 100644
@@ -276,7 +276,7 @@ rte_dev_probe(const char *devargs)
                goto skip_mp_req;
 
        if (strlen(devargs) >= EAL_DEV_MP_DEV_ARGS_MAX_LEN) {
-               EAL_LOG(ERR, "devargs truncated (len %zu, max %d)",
+               EAL_LOG(ERR, "devargs truncated (len %zu, max %zu)",
                        strlen(devargs), EAL_DEV_MP_DEV_ARGS_MAX_LEN);
                return -E2BIG;
        }
lib/eal/common/hotplug_mp.h +4 -1
index 7221284286..bd2f0f296a 100644
@@ -5,6 +5,7 @@
 #ifndef _HOTPLUG_MP_H_
 #define _HOTPLUG_MP_H_
 
+#include "rte_eal.h"
 #include "rte_dev.h"
 
 #define EAL_DEV_MP_ACTION_REQUEST      "eal_dev_mp_request"
@@ -12,7 +13,9 @@
 
 #define EAL_DEV_MP_DEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
 #define EAL_DEV_MP_BUS_NAME_MAX_LEN 32
-#define EAL_DEV_MP_DEV_ARGS_MAX_LEN 128
+#define EAL_DEV_MP_DEV_ARGS_MAX_LEN (RTE_MP_MAX_PARAM_LEN \
+       - sizeof(enum eal_dev_req_type) - sizeof(int))
+       /* minus t and result from struct eal_dev_mp_req */
 
 enum eal_dev_req_type {
        EAL_DEV_REQ_TYPE_ATTACH,

lib/eal/common/hotplug_mp.h struct eal_dev_mp_req { · line 35

Quoted 6 lines
lib/eal/common/hotplug_mp.h +3 -0
@@ -27,6 +30,9 @@ struct eal_dev_mp_req {
        int result;
 };
 
+static_assert(sizeof(struct eal_dev_mp_req) <= RTE_MP_MAX_PARAM_LEN,
+       "Hotplug message struct exceeds IPC parameter capacity");
+

A bit ugly to list those fields, even with the assert.

No strong opinion, just listing an alternative.

The idea is to switch to a flexible array for devargs.

 struct eal_dev_mp_req {
     enum eal_dev_req_type t;
-    char devargs[EAL_DEV_MP_DEV_ARGS_MAX_LEN];
     int result;

+ char devargs[];
};

+#define EAL_DEV_MP_DEV_ARGS_MAX_LEN \
+ (RTE_MP_MAX_PARAM_LEN - sizeof(struct eal_dev_mp_req))

This requires an update of eal_dev_hotplug_request_to_primary/eal_dev_hotplug_request_to_secondary so they manipulate a rte_mp_msg object.
A bonus side effect is that it avoids copies on stack for the message, as the caller already provides the message buffer.

Signature · 1 line
David Marchand
#2 lore raw

06/11/2026 10:58, David Marchand:

Quoted 73 lines · Thomas Monjalon
Quoted 48 lines

Derive the hotplug devargs buffer size from the IPC parameter capacity. This increases the maximum devargs length in multi-process mode from 127 to 247 bytes, excluding the terminating null byte.

---
 lib/eal/common/eal_common_dev.c | 2 +-
 lib/eal/common/hotplug_mp.h     | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)
lib/eal/common/eal_common_dev.c +1 -1
index f42a8d2349..febb584313 100644
@@ -276,7 +276,7 @@ rte_dev_probe(const char *devargs)
                goto skip_mp_req;
 
        if (strlen(devargs) >= EAL_DEV_MP_DEV_ARGS_MAX_LEN) {
-               EAL_LOG(ERR, "devargs truncated (len %zu, max %d)",
+               EAL_LOG(ERR, "devargs truncated (len %zu, max %zu)",
                        strlen(devargs), EAL_DEV_MP_DEV_ARGS_MAX_LEN);
                return -E2BIG;
        }
lib/eal/common/hotplug_mp.h +4 -1
index 7221284286..bd2f0f296a 100644
@@ -5,6 +5,7 @@
 #ifndef _HOTPLUG_MP_H_
 #define _HOTPLUG_MP_H_
 
+#include "rte_eal.h"
 #include "rte_dev.h"
 
 #define EAL_DEV_MP_ACTION_REQUEST      "eal_dev_mp_request"
@@ -12,7 +13,9 @@
 
 #define EAL_DEV_MP_DEV_NAME_MAX_LEN RTE_DEV_NAME_MAX_LEN
 #define EAL_DEV_MP_BUS_NAME_MAX_LEN 32
-#define EAL_DEV_MP_DEV_ARGS_MAX_LEN 128
+#define EAL_DEV_MP_DEV_ARGS_MAX_LEN (RTE_MP_MAX_PARAM_LEN \
+       - sizeof(enum eal_dev_req_type) - sizeof(int))
+       /* minus t and result from struct eal_dev_mp_req */
 
 enum eal_dev_req_type {
        EAL_DEV_REQ_TYPE_ATTACH,

lib/eal/common/hotplug_mp.h struct eal_dev_mp_req { · line 35

Quoted 6 lines
lib/eal/common/hotplug_mp.h +3 -0
@@ -27,6 +30,9 @@ struct eal_dev_mp_req {
        int result;
 };
 
+static_assert(sizeof(struct eal_dev_mp_req) <= RTE_MP_MAX_PARAM_LEN,
+       "Hotplug message struct exceeds IPC parameter capacity");
+

A bit ugly to list those fields, even with the assert.

No strong opinion, just listing an alternative.

The idea is to switch to a flexible array for devargs.

 struct eal_dev_mp_req {
     enum eal_dev_req_type t;
(quoted diff) +3 -1
-    char devargs[EAL_DEV_MP_DEV_ARGS_MAX_LEN];
     int result;
+    char devargs[];
 };
 
+#define EAL_DEV_MP_DEV_ARGS_MAX_LEN \
+    (RTE_MP_MAX_PARAM_LEN - sizeof(struct eal_dev_mp_req))
Quoted 5 lines

This requires an update of eal_dev_hotplug_request_to_primary/eal_dev_hotplug_request_to_secondary so they manipulate a rte_mp_msg object.
A bonus side effect is that it avoids copies on stack for the message, as the caller already provides the message buffer.

Yes it looks better.