Skip to contentSkip to conversation

DLB2 Bug Fixes

PATCH Superseded Timothy McDaniel 2 participants 16 messages Jun 29, 2022 – Jul 4, 2022

lore
Share & tools
lore
#0 lore raw

cover DLB2 Bug Fixes

This patch series fixes a coverity bug and a segfault.

Timothy McDaniel (2):
event/dlb2: fix port_cos array sizing event/dlb2: Fix initialization of cos bandwidth args

 drivers/event/dlb2/dlb2.c      | 2 +-
 drivers/event/dlb2/dlb2_priv.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 event/dlb2: fix port_cos array sizing

This commit fixes a segfault that resulted from reading beyond the end of the port_cos array. The root cause was using the DLB num ports define instead of the eventdev num ports define.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2_priv.h +1 -1
index 528e2ede61..8744efa79d 100644
@@ -640,7 +640,7 @@ struct dlb2_cq_weight {
 };
 
 struct dlb2_port_cos {
-	int cos_id[DLB2_MAX_NUM_LDB_PORTS];
+	int cos_id[DLB2_MAX_NUM_PORTS_ALL];
 };
 
 struct dlb2_cos_bw {
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/2 event/dlb2: Fix initialization of cos bandwidth args

In reply to Timothy McDaniel

This commit fixes a typo and resultant bug that triggered a coverity warning.

Coverity issue: 4607286

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +1 -1
index 78433d2fe0..a6182a1ac7 100644
@@ -4540,7 +4540,7 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 		for (id = 0; id < DLB2_COS_NUM_VALS; id++) {
 			set_cos_bw_args.cos_id = id;
-			set_cos_bw_args.cos_id = dlb2->cos_bw[id];
+			set_cos_bw_args.bandwidth = dlb2->cos_bw[id];
 			ret = dlb2_iface_set_cos_bw(&dlb2->qm_instance,
 						    &set_cos_bw_args);
 			if (ret != 0)
Signature · 1 line
2.25.1
#3 lore raw

v2 cover DLB2 Bug Fixes

In reply to Timothy McDaniel

Changes since V1
================
- No changes to patches 0001 and 0002
- Added 3 new bug fix patches to address issues found in final QA 0003 fix cq depth override
0004 fix cq depth override credit deadlock
0005 fix port COS initialization

Original Patchset
=================
0001 fix port_cos array sizin
- Fixes a segfault

0002 fix initialization of cos bandwidth args
- Fixes a coverity warning

Timothy McDaniel (5):
event/dlb2: fix port_cos array sizing event/dlb2: fix initialization of cos bandwidth args event/dlb2: fix cq depth override event/dlb2: fix cq depth override credit deadlock event/dlb2: fix port COS initialization

 drivers/event/dlb2/dlb2.c                  | 125 ++++++++++++++++-----
 drivers/event/dlb2/dlb2_priv.h             |  10 +-
 drivers/event/dlb2/pf/base/dlb2_resource.c |   3 -
 drivers/event/dlb2/pf/dlb2_pf.c            |   7 +-
 4 files changed, 109 insertions(+), 36 deletions(-)
Signature · 1 line
2.25.1
#4 lore raw

PATCH v2 1/5 event/dlb2: fix port_cos array sizing

This commit fixes a segfault that resulted from reading beyond the end of the port_cos array. The root cause was using the DLB num ports define instead of the eventdev num ports define.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2_priv.h +1 -1
index 528e2ede61..8744efa79d 100644
@@ -640,7 +640,7 @@ struct dlb2_cq_weight {
 };
 
 struct dlb2_port_cos {
-	int cos_id[DLB2_MAX_NUM_LDB_PORTS];
+	int cos_id[DLB2_MAX_NUM_PORTS_ALL];
 };
 
 struct dlb2_cos_bw {
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 2/5 event/dlb2: fix initialization of cos bandwidth args

In reply to Timothy McDaniel

This commit fixes a typo and resultant bug that triggered a coverity warning.

Coverity issue: 4607286

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +1 -1
index 78433d2fe0..a6182a1ac7 100644
@@ -4540,7 +4540,7 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 		for (id = 0; id < DLB2_COS_NUM_VALS; id++) {
 			set_cos_bw_args.cos_id = id;
-			set_cos_bw_args.cos_id = dlb2->cos_bw[id];
+			set_cos_bw_args.bandwidth = dlb2->cos_bw[id];
 			ret = dlb2_iface_set_cos_bw(&dlb2->qm_instance,
 						    &set_cos_bw_args);
 			if (ret != 0)
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 3/5 event/dlb2: fix cq depth override

In reply to Timothy McDaniel

This commit fixes a bug, where we could assign a cq depth of zero, leading to a subsequent divide-by-zero fault. It also fixes an issue where the original default cq depth was returned on a query, insgtead of the overridden value.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")
---
 drivers/event/dlb2/dlb2.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +8 -1
index a6182a1ac7..b50cd8e5ce 100644
@@ -4505,7 +4505,14 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 	dlb2->hw_credit_quanta = dlb2_args->hw_credit_quanta;
 	dlb2->default_depth_thresh = dlb2_args->default_depth_thresh;
 	dlb2->vector_opts_enabled = dlb2_args->vector_opts_enabled;
-	dlb2->max_cq_depth = dlb2_args->max_cq_depth;
+
+
+	if (dlb2_args->max_cq_depth != 0)
+		dlb2->max_cq_depth = dlb2_args->max_cq_depth;
+	else
+		dlb2->max_cq_depth = DLB2_DEFAULT_CQ_DEPTH;
+
+	evdev_dlb2_default_info.max_event_port_dequeue_depth = dlb2->max_cq_depth;
 
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 4/5 event/dlb2: fix cq depth override credit deadlock

In reply to Timothy McDaniel

This commit fixes a bug, where we could encounter a credit deadlock due to changing the CQ depth. To remedy this situation, the commit reduces the maximum CQ depth from 1024 to 128, and also allows configuring the maximum enqueue depth. Maximum enqueue depth must be tuned to the CQ depth, if the CQ depth is increased.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")
---
 drivers/event/dlb2/dlb2.c       | 51 +++++++++++++++++++++++++++++++++
 drivers/event/dlb2/dlb2_priv.h  |  8 +++++-
 drivers/event/dlb2/pf/dlb2_pf.c |  3 +-
 3 files changed, 60 insertions(+), 2 deletions(-)
drivers/event/dlb2/dlb2.c +51 -0
index b50cd8e5ce..8a68c25c93 100644
@@ -326,6 +326,36 @@ set_max_cq_depth(const char *key __rte_unused,
 	return 0;
 }
 
+static int
+set_max_enq_depth(const char *key __rte_unused,
+		  const char *value,
+		  void *opaque)
+{
+	int *max_enq_depth = opaque;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(max_enq_depth, value);
+	if (ret < 0)
+		return ret;
+
+	if (*max_enq_depth < DLB2_MIN_ENQ_DEPTH_OVERRIDE ||
+	    *max_enq_depth > DLB2_MAX_ENQ_DEPTH_OVERRIDE ||
+	    !rte_is_power_of_2(*max_enq_depth)) {
+		DLB2_LOG_ERR("dlb2: max_enq_depth %d and %d and a power of 2\n",
+		DLB2_MIN_ENQ_DEPTH_OVERRIDE,
+		DLB2_MAX_ENQ_DEPTH_OVERRIDE);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int
 set_max_num_events(const char *key __rte_unused,
 		   const char *value,
@@ -4514,6 +4544,15 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 	evdev_dlb2_default_info.max_event_port_dequeue_depth = dlb2->max_cq_depth;
 
+	if (dlb2_args->max_enq_depth != 0)
+		dlb2->max_enq_depth = dlb2_args->max_enq_depth;
+	else
+		dlb2->max_enq_depth = DLB2_DEFAULT_CQ_DEPTH;
+
+	evdev_dlb2_default_info.max_event_port_enqueue_depth =
+		dlb2->max_enq_depth;
+
+
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
 		DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
@@ -4650,6 +4689,7 @@ dlb2_parse_params(const char *params,
 					     DLB2_DEPTH_THRESH_ARG,
 					     DLB2_VECTOR_OPTS_ENAB_ARG,
 					     DLB2_MAX_CQ_DEPTH,
+					     DLB2_MAX_ENQ_DEPTH,
 					     DLB2_CQ_WEIGHT,
 					     DLB2_PORT_COS,
 					     DLB2_COS_BW,
@@ -4789,6 +4829,17 @@ dlb2_parse_params(const char *params,
 				return ret;
 			}
 
+			ret = rte_kvargs_process(kvlist,
+						 DLB2_MAX_ENQ_DEPTH,
+						 set_max_enq_depth,
+						 &dlb2_args->max_enq_depth);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing vector opts enabled",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
 			ret = rte_kvargs_process(kvlist,
 					DLB2_CQ_WEIGHT,
 					set_cq_weight,
drivers/event/dlb2/dlb2_priv.h +7 -1
index 8744efa79d..1edea83a5b 100644
@@ -29,7 +29,10 @@
 #define DLB2_SW_CREDIT_C_QUANTA_DEFAULT 256 /* Consumer */
 #define DLB2_DEPTH_THRESH_DEFAULT 256
 #define DLB2_MIN_CQ_DEPTH_OVERRIDE 32
-#define DLB2_MAX_CQ_DEPTH_OVERRIDE 1024
+#define DLB2_MAX_CQ_DEPTH_OVERRIDE 128
+#define DLB2_MIN_ENQ_DEPTH_OVERRIDE 32
+#define DLB2_MAX_ENQ_DEPTH_OVERRIDE 1024
+
 
 /*  command line arg strings */
 #define NUMA_NODE_ARG "numa_node"
@@ -44,6 +47,7 @@
 #define DLB2_DEPTH_THRESH_ARG "default_depth_thresh"
 #define DLB2_VECTOR_OPTS_ENAB_ARG "vector_opts_enable"
 #define DLB2_MAX_CQ_DEPTH "max_cq_depth"
+#define DLB2_MAX_ENQ_DEPTH "max_enqueue_depth"
 #define DLB2_CQ_WEIGHT "cq_weight"
 #define DLB2_PORT_COS "port_cos"
 #define DLB2_COS_BW "cos_bw"
@@ -585,6 +589,7 @@ struct dlb2_eventdev {
 	int num_dir_credits_override;
 	bool vector_opts_enabled;
 	int max_cq_depth;
+	int max_enq_depth;
 	volatile enum dlb2_run_state run_state;
 	uint16_t num_dir_queues; /* total num of evdev dir queues requested */
 	union {
@@ -660,6 +665,7 @@ struct dlb2_devargs {
 	int default_depth_thresh;
 	bool vector_opts_enabled;
 	int max_cq_depth;
+	int max_enq_depth;
 	struct dlb2_cq_weight cq_weight;
 	struct dlb2_port_cos port_cos;
 	struct dlb2_cos_bw cos_bw;
drivers/event/dlb2/pf/dlb2_pf.c +2 -1
index 0627f06a6e..086d4a1cc7 100644
@@ -708,7 +708,8 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
 		.sw_credit_quanta = DLB2_SW_CREDIT_QUANTA_DEFAULT,
 		.hw_credit_quanta = DLB2_SW_CREDIT_BATCH_SZ,
 		.default_depth_thresh = DLB2_DEPTH_THRESH_DEFAULT,
-		.max_cq_depth = DLB2_DEFAULT_CQ_DEPTH
+		.max_cq_depth = DLB2_DEFAULT_CQ_DEPTH,
+		.max_enq_depth = DLB2_MAX_ENQUEUE_DEPTH
 	};
 	struct dlb2_eventdev *dlb2;
 
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 5/5 event/dlb2: fix port COS initialization

In reply to Timothy McDaniel

Fix cos initialization, handling the default case too.

Subsitute the semicolon for the comma
that was expected in the cos_bw command line override. Commas are not allowed within a multifield option. The new format is cos_bw=%d:%d:%d:%d, where the sum of the 4 decimal vallues must be less than or equal to 100.

Corrected probe-time initalization order.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2.c                  | 63 ++++++++++++----------
 drivers/event/dlb2/pf/base/dlb2_resource.c |  3 --
 drivers/event/dlb2/pf/dlb2_pf.c            |  4 ++
 3 files changed, 39 insertions(+), 31 deletions(-)
drivers/event/dlb2/dlb2.c +35 -28
index 8a68c25c93..26af75beb8 100644
@@ -170,10 +170,11 @@ dlb2_init_port_cos(struct dlb2_eventdev *dlb2, int *port_cos)
 {
 	int q;
 
-	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++) {
-		dlb2->ev_ports[q].cos_id = port_cos[q];
-		dlb2->cos_ports[port_cos[q]]++;
-	}
+	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+		if (port_cos[q] != DLB2_COS_DEFAULT) {
+			dlb2->ev_ports[q].cos_id = port_cos[q];
+			dlb2->cos_ports[port_cos[q]]++;
+		}
 }
 
 static void
@@ -181,6 +182,17 @@ dlb2_init_cos_bw(struct dlb2_eventdev *dlb2,
 		 struct dlb2_cos_bw *cos_bw)
 {
 	int q;
+
+
+	/* If cos_bw not set, then split evenly */
+	if (cos_bw->val[0] == 0 && cos_bw->val[1] == 0 &&
+		cos_bw->val[2] == 0 && cos_bw->val[3] == 0) {
+		cos_bw->val[0] = 25;
+		cos_bw->val[1] = 25;
+		cos_bw->val[2] = 25;
+		cos_bw->val[3] = 25;
+	}
+
 	for (q = 0; q < DLB2_COS_NUM_VALS; q++)
 		dlb2->cos_bw[q] = cos_bw->val[q];
 
@@ -464,19 +476,15 @@ set_port_cos(const char *key __rte_unused,
 	}
 
 	/* command line override may take one of the following 3 forms:
-	 * port_cos=all:<cos_id> ... all ports
 	 * port_cos=port-port:<cos_id> ... a range of ports
 	 * port_cos=port:<cos_id> ... just one port
 	 */
-	if (sscanf(value, "all:%d", &cos_id) == 1) {
-		first = 0;
-		last = DLB2_MAX_NUM_LDB_PORTS - 1;
-	} else if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
+	if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
 		/* we have everything we need */
 	} else if (sscanf(value, "%d:%d", &first, &cos_id) == 2) {
 		last = first;
 	} else {
-		DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be all:val, port-port:val, or port:val\n");
+		DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be port-port:val, or port:val\n");
 		return -EINVAL;
 	}
 
@@ -511,13 +519,13 @@ set_cos_bw(const char *key __rte_unused,
 
 	/* format must be %d,%d,%d,%d */
 
-	if (sscanf(value, "%d,%d,%d,%d", &cos_bw->val[0], &cos_bw->val[1],
+	if (sscanf(value, "%d:%d:%d:%d", &cos_bw->val[0], &cos_bw->val[1],
 		   &cos_bw->val[2], &cos_bw->val[3]) != 4) {
-		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3 where all values combined are <= 100\n");
+		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3 where all values combined are <= 100\n");
 		return -EINVAL;
 	}
 	if (cos_bw->val[0] + cos_bw->val[1] + cos_bw->val[2] + cos_bw->val[3] > 100) {
-		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3  where all values combined are <= 100\n");
+		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3  where all values combined are <= 100\n");
 		return -EINVAL;
 	}
 
@@ -781,9 +789,9 @@ dlb2_hw_create_sched_domain(struct dlb2_eventdev *dlb2,
 
 	/* LDB ports */
 
-	/* tally of ports with non default COS */
-	cos_ports = dlb2->cos_ports[1] + dlb2->cos_ports[2] +
-		    dlb2->cos_ports[3];
+	/* tally of COS ports from cmd line */
+	cos_ports = dlb2->cos_ports[0] + dlb2->cos_ports[1] +
+		    dlb2->cos_ports[2] + dlb2->cos_ports[3];
 
 	if (cos_ports > resources_asked->num_ldb_ports) {
 		DLB2_LOG_ERR("dlb2: num_ldb_ports < nonzero cos_ports\n");
@@ -4552,6 +4560,17 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 	evdev_dlb2_default_info.max_event_port_enqueue_depth =
 		dlb2->max_enq_depth;
 
+	dlb2_init_queue_depth_thresholds(dlb2,
+					 dlb2_args->qid_depth_thresholds.val);
+
+	dlb2_init_cq_weight(dlb2,
+			    dlb2_args->cq_weight.limit);
+
+	dlb2_init_port_cos(dlb2,
+			   dlb2_args->port_cos.cos_id);
+
+	dlb2_init_cos_bw(dlb2,
+			 &dlb2_args->cos_bw);
 
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
@@ -4623,18 +4642,6 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 	dlb2_entry_points_init(dev);
 
-	dlb2_init_queue_depth_thresholds(dlb2,
-					 dlb2_args->qid_depth_thresholds.val);
-
-	dlb2_init_cq_weight(dlb2,
-			    dlb2_args->cq_weight.limit);
-
-	dlb2_init_port_cos(dlb2,
-			   dlb2_args->port_cos.cos_id);
-
-	dlb2_init_cos_bw(dlb2,
-			 &dlb2_args->cos_bw);
-
 	return 0;
 }
 
drivers/event/dlb2/pf/base/dlb2_resource.c +0 -3
index da1949c763..e73d289445 100644
@@ -236,9 +236,6 @@ int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver)
 		hw->rsrcs.sn_groups[i].slot_use_bitmap = 0;
 	}
 
-	for (i = 0; i < DLB2_NUM_COS_DOMAINS; i++)
-		hw->cos_reservation[i] = 100 / DLB2_NUM_COS_DOMAINS;
-
 	return 0;
 
 unwind:
drivers/event/dlb2/pf/dlb2_pf.c +4 -0
index 086d4a1cc7..dd3f2b8ece 100644
@@ -712,10 +712,14 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
 		.max_enq_depth = DLB2_MAX_ENQUEUE_DEPTH
 	};
 	struct dlb2_eventdev *dlb2;
+	int q;
 
 	DLB2_LOG_DBG("Enter with dev_id=%d socket_id=%d",
 		     eventdev->data->dev_id, eventdev->data->socket_id);
 
+	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+		dlb2_args.port_cos.cos_id[q] = DLB2_COS_DEFAULT;
+
 	dlb2_pf_iface_fn_ptrs_init();
 
 	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
Signature · 1 line
2.25.1
#9 lore raw

v3 cover DLB2 Bug Fixes

In reply to Timothy McDaniel

Changes since V2
================
- Correct typos in commit message of patch 0005

Changes since V1
================
- No changes to patches 0001 and 0002
- Added 3 new bug fix patches to address issues found in final QA 0003 fix cq depth override
0004 fix cq depth override credit deadlock
0005 fix port COS initialization

Original Patchset
=================
0001 fix port_cos array sizin
- Fixes a segfault

0002 fix initialization of cos bandwidth args
- Fixes a coverity warning

Timothy McDaniel (5):
event/dlb2: fix port_cos array sizing event/dlb2: fix initialization of cos bandwidth args event/dlb2: fix cq depth override event/dlb2: fix cq depth override credit deadlock event/dlb2: fix port COS initialization

 drivers/event/dlb2/dlb2.c                  | 125 ++++++++++++++++-----
 drivers/event/dlb2/dlb2_priv.h             |  10 +-
 drivers/event/dlb2/pf/base/dlb2_resource.c |   3 -
 drivers/event/dlb2/pf/dlb2_pf.c            |   7 +-
 4 files changed, 109 insertions(+), 36 deletions(-)
Signature · 1 line
2.25.1
#10 lore raw

PATCH v3 1/5 event/dlb2: fix port_cos array sizing

This commit fixes a segfault that resulted from reading beyond the end of the port_cos array. The root cause was using the DLB num ports define instead of the eventdev num ports define.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2_priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2_priv.h +1 -1
index 528e2ede61..8744efa79d 100644
@@ -640,7 +640,7 @@ struct dlb2_cq_weight {
 };
 
 struct dlb2_port_cos {
-	int cos_id[DLB2_MAX_NUM_LDB_PORTS];
+	int cos_id[DLB2_MAX_NUM_PORTS_ALL];
 };
 
 struct dlb2_cos_bw {
Signature · 1 line
2.25.1
#11 lore raw

PATCH v3 2/5 event/dlb2: fix initialization of cos bandwidth args

In reply to Timothy McDaniel

This commit fixes a typo and resultant bug that triggered a coverity warning.

Coverity issue: 4607286

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +1 -1
index 78433d2fe0..a6182a1ac7 100644
@@ -4540,7 +4540,7 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 		for (id = 0; id < DLB2_COS_NUM_VALS; id++) {
 			set_cos_bw_args.cos_id = id;
-			set_cos_bw_args.cos_id = dlb2->cos_bw[id];
+			set_cos_bw_args.bandwidth = dlb2->cos_bw[id];
 			ret = dlb2_iface_set_cos_bw(&dlb2->qm_instance,
 						    &set_cos_bw_args);
 			if (ret != 0)
Signature · 1 line
2.25.1
#12 lore raw

PATCH v3 3/5 event/dlb2: fix cq depth override

In reply to Timothy McDaniel

This commit fixes a bug, where we could assign a cq depth of zero, leading to a subsequent divide-by-zero fault. It also fixes an issue where the original default cq depth was returned on a query, insgtead of the overridden value.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")
---
 drivers/event/dlb2/dlb2.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/event/dlb2/dlb2.c +8 -1
index a6182a1ac7..b50cd8e5ce 100644
@@ -4505,7 +4505,14 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 	dlb2->hw_credit_quanta = dlb2_args->hw_credit_quanta;
 	dlb2->default_depth_thresh = dlb2_args->default_depth_thresh;
 	dlb2->vector_opts_enabled = dlb2_args->vector_opts_enabled;
-	dlb2->max_cq_depth = dlb2_args->max_cq_depth;
+
+
+	if (dlb2_args->max_cq_depth != 0)
+		dlb2->max_cq_depth = dlb2_args->max_cq_depth;
+	else
+		dlb2->max_cq_depth = DLB2_DEFAULT_CQ_DEPTH;
+
+	evdev_dlb2_default_info.max_event_port_dequeue_depth = dlb2->max_cq_depth;
 
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
Signature · 1 line
2.25.1
#13 lore raw

PATCH v3 4/5 event/dlb2: fix cq depth override credit deadlock

In reply to Timothy McDaniel

This commit fixes a bug, where we could encounter a credit deadlock due to changing the CQ depth. To remedy this situation, the commit reduces the maximum CQ depth from 1024 to 128, and also allows configuring the maximum enqueue depth. Maximum enqueue depth must be tuned to the CQ depth, if the CQ depth is increased.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")
---
 drivers/event/dlb2/dlb2.c       | 51 +++++++++++++++++++++++++++++++++
 drivers/event/dlb2/dlb2_priv.h  |  8 +++++-
 drivers/event/dlb2/pf/dlb2_pf.c |  3 +-
 3 files changed, 60 insertions(+), 2 deletions(-)
drivers/event/dlb2/dlb2.c +51 -0
index b50cd8e5ce..8a68c25c93 100644
@@ -326,6 +326,36 @@ set_max_cq_depth(const char *key __rte_unused,
 	return 0;
 }
 
+static int
+set_max_enq_depth(const char *key __rte_unused,
+		  const char *value,
+		  void *opaque)
+{
+	int *max_enq_depth = opaque;
+	int ret;
+
+	if (value == NULL || opaque == NULL) {
+		DLB2_LOG_ERR("NULL pointer\n");
+		return -EINVAL;
+	}
+
+	ret = dlb2_string_to_int(max_enq_depth, value);
+	if (ret < 0)
+		return ret;
+
+	if (*max_enq_depth < DLB2_MIN_ENQ_DEPTH_OVERRIDE ||
+	    *max_enq_depth > DLB2_MAX_ENQ_DEPTH_OVERRIDE ||
+	    !rte_is_power_of_2(*max_enq_depth)) {
+		DLB2_LOG_ERR("dlb2: max_enq_depth %d and %d and a power of 2\n",
+		DLB2_MIN_ENQ_DEPTH_OVERRIDE,
+		DLB2_MAX_ENQ_DEPTH_OVERRIDE);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+
 static int
 set_max_num_events(const char *key __rte_unused,
 		   const char *value,
@@ -4514,6 +4544,15 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 	evdev_dlb2_default_info.max_event_port_dequeue_depth = dlb2->max_cq_depth;
 
+	if (dlb2_args->max_enq_depth != 0)
+		dlb2->max_enq_depth = dlb2_args->max_enq_depth;
+	else
+		dlb2->max_enq_depth = DLB2_DEFAULT_CQ_DEPTH;
+
+	evdev_dlb2_default_info.max_event_port_enqueue_depth =
+		dlb2->max_enq_depth;
+
+
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
 		DLB2_LOG_ERR("could not open event hardware device, err=%d\n",
@@ -4650,6 +4689,7 @@ dlb2_parse_params(const char *params,
 					     DLB2_DEPTH_THRESH_ARG,
 					     DLB2_VECTOR_OPTS_ENAB_ARG,
 					     DLB2_MAX_CQ_DEPTH,
+					     DLB2_MAX_ENQ_DEPTH,
 					     DLB2_CQ_WEIGHT,
 					     DLB2_PORT_COS,
 					     DLB2_COS_BW,
@@ -4789,6 +4829,17 @@ dlb2_parse_params(const char *params,
 				return ret;
 			}
 
+			ret = rte_kvargs_process(kvlist,
+						 DLB2_MAX_ENQ_DEPTH,
+						 set_max_enq_depth,
+						 &dlb2_args->max_enq_depth);
+			if (ret != 0) {
+				DLB2_LOG_ERR("%s: Error parsing vector opts enabled",
+					     name);
+				rte_kvargs_free(kvlist);
+				return ret;
+			}
+
 			ret = rte_kvargs_process(kvlist,
 					DLB2_CQ_WEIGHT,
 					set_cq_weight,
drivers/event/dlb2/dlb2_priv.h +7 -1
index 8744efa79d..1edea83a5b 100644
@@ -29,7 +29,10 @@
 #define DLB2_SW_CREDIT_C_QUANTA_DEFAULT 256 /* Consumer */
 #define DLB2_DEPTH_THRESH_DEFAULT 256
 #define DLB2_MIN_CQ_DEPTH_OVERRIDE 32
-#define DLB2_MAX_CQ_DEPTH_OVERRIDE 1024
+#define DLB2_MAX_CQ_DEPTH_OVERRIDE 128
+#define DLB2_MIN_ENQ_DEPTH_OVERRIDE 32
+#define DLB2_MAX_ENQ_DEPTH_OVERRIDE 1024
+
 
 /*  command line arg strings */
 #define NUMA_NODE_ARG "numa_node"
@@ -44,6 +47,7 @@
 #define DLB2_DEPTH_THRESH_ARG "default_depth_thresh"
 #define DLB2_VECTOR_OPTS_ENAB_ARG "vector_opts_enable"
 #define DLB2_MAX_CQ_DEPTH "max_cq_depth"
+#define DLB2_MAX_ENQ_DEPTH "max_enqueue_depth"
 #define DLB2_CQ_WEIGHT "cq_weight"
 #define DLB2_PORT_COS "port_cos"
 #define DLB2_COS_BW "cos_bw"
@@ -585,6 +589,7 @@ struct dlb2_eventdev {
 	int num_dir_credits_override;
 	bool vector_opts_enabled;
 	int max_cq_depth;
+	int max_enq_depth;
 	volatile enum dlb2_run_state run_state;
 	uint16_t num_dir_queues; /* total num of evdev dir queues requested */
 	union {
@@ -660,6 +665,7 @@ struct dlb2_devargs {
 	int default_depth_thresh;
 	bool vector_opts_enabled;
 	int max_cq_depth;
+	int max_enq_depth;
 	struct dlb2_cq_weight cq_weight;
 	struct dlb2_port_cos port_cos;
 	struct dlb2_cos_bw cos_bw;
drivers/event/dlb2/pf/dlb2_pf.c +2 -1
index 0627f06a6e..086d4a1cc7 100644
@@ -708,7 +708,8 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
 		.sw_credit_quanta = DLB2_SW_CREDIT_QUANTA_DEFAULT,
 		.hw_credit_quanta = DLB2_SW_CREDIT_BATCH_SZ,
 		.default_depth_thresh = DLB2_DEPTH_THRESH_DEFAULT,
-		.max_cq_depth = DLB2_DEFAULT_CQ_DEPTH
+		.max_cq_depth = DLB2_DEFAULT_CQ_DEPTH,
+		.max_enq_depth = DLB2_MAX_ENQUEUE_DEPTH
 	};
 	struct dlb2_eventdev *dlb2;
 
Signature · 1 line
2.25.1
#14 lore raw

PATCH v3 5/5 event/dlb2: fix port COS initialization

In reply to Timothy McDaniel

Fix cos initialization, handling the default case too.

Substitute the semicolon for the comma
that was expected in the cos_bw command line override. Commas are not allowed within a multifield option. The new format is cos_bw=%d:%d:%d:%d, where the sum of the 4 decimal values must be less than or equal to 100.

Corrected probe-time initialization order.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
---
 drivers/event/dlb2/dlb2.c                  | 63 ++++++++++++----------
 drivers/event/dlb2/pf/base/dlb2_resource.c |  3 --
 drivers/event/dlb2/pf/dlb2_pf.c            |  4 ++
 3 files changed, 39 insertions(+), 31 deletions(-)
drivers/event/dlb2/dlb2.c +35 -28
index 8a68c25c93..26af75beb8 100644
@@ -170,10 +170,11 @@ dlb2_init_port_cos(struct dlb2_eventdev *dlb2, int *port_cos)
 {
 	int q;
 
-	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++) {
-		dlb2->ev_ports[q].cos_id = port_cos[q];
-		dlb2->cos_ports[port_cos[q]]++;
-	}
+	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+		if (port_cos[q] != DLB2_COS_DEFAULT) {
+			dlb2->ev_ports[q].cos_id = port_cos[q];
+			dlb2->cos_ports[port_cos[q]]++;
+		}
 }
 
 static void
@@ -181,6 +182,17 @@ dlb2_init_cos_bw(struct dlb2_eventdev *dlb2,
 		 struct dlb2_cos_bw *cos_bw)
 {
 	int q;
+
+
+	/* If cos_bw not set, then split evenly */
+	if (cos_bw->val[0] == 0 && cos_bw->val[1] == 0 &&
+		cos_bw->val[2] == 0 && cos_bw->val[3] == 0) {
+		cos_bw->val[0] = 25;
+		cos_bw->val[1] = 25;
+		cos_bw->val[2] = 25;
+		cos_bw->val[3] = 25;
+	}
+
 	for (q = 0; q < DLB2_COS_NUM_VALS; q++)
 		dlb2->cos_bw[q] = cos_bw->val[q];
 
@@ -464,19 +476,15 @@ set_port_cos(const char *key __rte_unused,
 	}
 
 	/* command line override may take one of the following 3 forms:
-	 * port_cos=all:<cos_id> ... all ports
 	 * port_cos=port-port:<cos_id> ... a range of ports
 	 * port_cos=port:<cos_id> ... just one port
 	 */
-	if (sscanf(value, "all:%d", &cos_id) == 1) {
-		first = 0;
-		last = DLB2_MAX_NUM_LDB_PORTS - 1;
-	} else if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
+	if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
 		/* we have everything we need */
 	} else if (sscanf(value, "%d:%d", &first, &cos_id) == 2) {
 		last = first;
 	} else {
-		DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be all:val, port-port:val, or port:val\n");
+		DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be port-port:val, or port:val\n");
 		return -EINVAL;
 	}
 
@@ -511,13 +519,13 @@ set_cos_bw(const char *key __rte_unused,
 
 	/* format must be %d,%d,%d,%d */
 
-	if (sscanf(value, "%d,%d,%d,%d", &cos_bw->val[0], &cos_bw->val[1],
+	if (sscanf(value, "%d:%d:%d:%d", &cos_bw->val[0], &cos_bw->val[1],
 		   &cos_bw->val[2], &cos_bw->val[3]) != 4) {
-		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3 where all values combined are <= 100\n");
+		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3 where all values combined are <= 100\n");
 		return -EINVAL;
 	}
 	if (cos_bw->val[0] + cos_bw->val[1] + cos_bw->val[2] + cos_bw->val[3] > 100) {
-		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3  where all values combined are <= 100\n");
+		DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3  where all values combined are <= 100\n");
 		return -EINVAL;
 	}
 
@@ -781,9 +789,9 @@ dlb2_hw_create_sched_domain(struct dlb2_eventdev *dlb2,
 
 	/* LDB ports */
 
-	/* tally of ports with non default COS */
-	cos_ports = dlb2->cos_ports[1] + dlb2->cos_ports[2] +
-		    dlb2->cos_ports[3];
+	/* tally of COS ports from cmd line */
+	cos_ports = dlb2->cos_ports[0] + dlb2->cos_ports[1] +
+		    dlb2->cos_ports[2] + dlb2->cos_ports[3];
 
 	if (cos_ports > resources_asked->num_ldb_ports) {
 		DLB2_LOG_ERR("dlb2: num_ldb_ports < nonzero cos_ports\n");
@@ -4552,6 +4560,17 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 	evdev_dlb2_default_info.max_event_port_enqueue_depth =
 		dlb2->max_enq_depth;
 
+	dlb2_init_queue_depth_thresholds(dlb2,
+					 dlb2_args->qid_depth_thresholds.val);
+
+	dlb2_init_cq_weight(dlb2,
+			    dlb2_args->cq_weight.limit);
+
+	dlb2_init_port_cos(dlb2,
+			   dlb2_args->port_cos.cos_id);
+
+	dlb2_init_cos_bw(dlb2,
+			 &dlb2_args->cos_bw);
 
 	err = dlb2_iface_open(&dlb2->qm_instance, name);
 	if (err < 0) {
@@ -4623,18 +4642,6 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
 	dlb2_entry_points_init(dev);
 
-	dlb2_init_queue_depth_thresholds(dlb2,
-					 dlb2_args->qid_depth_thresholds.val);
-
-	dlb2_init_cq_weight(dlb2,
-			    dlb2_args->cq_weight.limit);
-
-	dlb2_init_port_cos(dlb2,
-			   dlb2_args->port_cos.cos_id);
-
-	dlb2_init_cos_bw(dlb2,
-			 &dlb2_args->cos_bw);
-
 	return 0;
 }
 
drivers/event/dlb2/pf/base/dlb2_resource.c +0 -3
index da1949c763..e73d289445 100644
@@ -236,9 +236,6 @@ int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver)
 		hw->rsrcs.sn_groups[i].slot_use_bitmap = 0;
 	}
 
-	for (i = 0; i < DLB2_NUM_COS_DOMAINS; i++)
-		hw->cos_reservation[i] = 100 / DLB2_NUM_COS_DOMAINS;
-
 	return 0;
 
 unwind:
drivers/event/dlb2/pf/dlb2_pf.c +4 -0
index 086d4a1cc7..dd3f2b8ece 100644
@@ -712,10 +712,14 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
 		.max_enq_depth = DLB2_MAX_ENQUEUE_DEPTH
 	};
 	struct dlb2_eventdev *dlb2;
+	int q;
 
 	DLB2_LOG_DBG("Enter with dev_id=%d socket_id=%d",
 		     eventdev->data->dev_id, eventdev->data->socket_id);
 
+	for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+		dlb2_args.port_cos.cos_id[q] = DLB2_COS_DEFAULT;
+
 	dlb2_pf_iface_fn_ptrs_init();
 
 	pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
Signature · 1 line
2.25.1
#15 lore raw

Re: [PATCH v3 5/5] event/dlb2: fix port COS initialization

Quoted 9 lines · Timothy McDaniel

Fix cos initialization, handling the default case too.

Substitute the semicolon for the comma
that was expected in the cos_bw command line override. Commas are not allowed within a multifield option. The new format is cos_bw=%d:%d:%d:%d, where the sum of the 4 decimal values must be less than or equal to 100.

Quoted 4 lines

Corrected probe-time initialization order.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")

No need to CC yourself. Instead, if it is fix Cc: [email protected]. I will it on merge.

Quoted 2 lines

Fixed check-git-log.sh issues and Updated the git commit as follows and applied to dpdk-next-net-eventdev/for-main. Thanks

commit 611ae87343db1ca6fed6a99f5e3c0880e8f0f952

Author: Timothy McDaniel <[email protected]>
Date:   Sat Jul 2 11:22:39 2022 -0500

event/dlb2: fix port COS initialization

Fix cos initialization, handling the default case too.

Substitute the semicolon for the comma
that was expected in the cos_bw command line override. Commas are not allowed within a multi field option. The new format is cos_bw=%d:%d:%d:%d, where the sum of the 4 decimal values must be less than or equal to 100.

Corrected probe-time initialization order.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")

commit d98b716ead2878ede3f75049f89375d67ac43f48

Author: Timothy McDaniel <[email protected]>
Date:   Sat Jul 2 11:22:38 2022 -0500

event/dlb2: fix CQ depth override credit deadlock

This commit fixes a bug, where we could encounter a credit deadlock due to changing the CQ depth. To remedy this situation, the commit reduces the maximum CQ depth from 1024 to 128, and also allows configuring the maximum enqueue depth. Maximum enqueue depth must be tuned to the CQ depth, if the CQ depth is increased.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")

commit d0143df3f208e8091b83147c356ba1d3c4f3d97b

Author: Timothy McDaniel <[email protected]>
Date:   Sat Jul 2 11:22:37 2022 -0500

event/dlb2: fix CQ depth override

This commit fixes a bug, where we could assign a CQ depth of zero, leading to a subsequent divide-by-zero fault. It also fixes an issue where the original default CQ depth was returned on a query, instead of the overridden value.

Fixes 86fe66d45667 ("event/dlb2: allow CQ depths up to 1024")

commit d45ba4380684a86f4c723b9da2f854de22389001

Author: Timothy McDaniel <[email protected]>
Date:   Sat Jul 2 11:22:36 2022 -0500

event/dlb2: fix initialization of COS bandwidth args

This commit fixes a typo and resultant bug that triggered a coverity warning.

Coverity issue: 4607286

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")

commit 9274d2236be09989c4d18a4a852e77fb87cf53f1

Author: Timothy McDaniel <[email protected]>
Date:   Sat Jul 2 11:22:35 2022 -0500

event/dlb2: fix array sizing

This commit fixes a segfault that resulted from reading beyond the end of the port_cos array. The root cause was using the DLB num ports define instead of the eventdev num ports define.

Fixes bec8901bfe9f ("event/dlb2: support ldb port specific COS")
Quoted 169 lines
---
 drivers/event/dlb2/dlb2.c                  | 63 ++++++++++++----------
 drivers/event/dlb2/pf/base/dlb2_resource.c |  3 --
 drivers/event/dlb2/pf/dlb2_pf.c            |  4 ++
 3 files changed, 39 insertions(+), 31 deletions(-)
drivers/event/dlb2/dlb2.c +35 -28
index 8a68c25c93..26af75beb8 100644
@@ -170,10 +170,11 @@ dlb2_init_port_cos(struct dlb2_eventdev *dlb2, int *port_cos)
 {
        int q;
 
-       for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++) {
-               dlb2->ev_ports[q].cos_id = port_cos[q];
-               dlb2->cos_ports[port_cos[q]]++;
-       }
+       for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+               if (port_cos[q] != DLB2_COS_DEFAULT) {
+                       dlb2->ev_ports[q].cos_id = port_cos[q];
+                       dlb2->cos_ports[port_cos[q]]++;
+               }
 }
 
 static void
@@ -181,6 +182,17 @@ dlb2_init_cos_bw(struct dlb2_eventdev *dlb2,
                 struct dlb2_cos_bw *cos_bw)
 {
        int q;
+
+
+       /* If cos_bw not set, then split evenly */
+       if (cos_bw->val[0] == 0 && cos_bw->val[1] == 0 &&
+               cos_bw->val[2] == 0 && cos_bw->val[3] == 0) {
+               cos_bw->val[0] = 25;
+               cos_bw->val[1] = 25;
+               cos_bw->val[2] = 25;
+               cos_bw->val[3] = 25;
+       }
+
        for (q = 0; q < DLB2_COS_NUM_VALS; q++)
                dlb2->cos_bw[q] = cos_bw->val[q];
 
@@ -464,19 +476,15 @@ set_port_cos(const char *key __rte_unused,
        }
 
        /* command line override may take one of the following 3 forms:
-        * port_cos=all:<cos_id> ... all ports
         * port_cos=port-port:<cos_id> ... a range of ports
         * port_cos=port:<cos_id> ... just one port
         */
-       if (sscanf(value, "all:%d", &cos_id) == 1) {
-               first = 0;
-               last = DLB2_MAX_NUM_LDB_PORTS - 1;
-       } else if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
+       if (sscanf(value, "%d-%d:%d", &first, &last, &cos_id) == 3) {
                /* we have everything we need */
        } else if (sscanf(value, "%d:%d", &first, &cos_id) == 2) {
                last = first;
        } else {
-               DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be all:val, port-port:val, or port:val\n");
+               DLB2_LOG_ERR("Error parsing ldb port port_cos devarg. Should be port-port:val, or port:val\n");
                return -EINVAL;
        }
 
@@ -511,13 +519,13 @@ set_cos_bw(const char *key __rte_unused,
 
        /* format must be %d,%d,%d,%d */
 
-       if (sscanf(value, "%d,%d,%d,%d", &cos_bw->val[0], &cos_bw->val[1],
+       if (sscanf(value, "%d:%d:%d:%d", &cos_bw->val[0], &cos_bw->val[1],
                   &cos_bw->val[2], &cos_bw->val[3]) != 4) {
-               DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3 where all values combined are <= 100\n");
+               DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3 where all values combined are <= 100\n");
                return -EINVAL;
        }
        if (cos_bw->val[0] + cos_bw->val[1] + cos_bw->val[2] + cos_bw->val[3] > 100) {
-               DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0,bw1,bw2,bw3  where all values combined are <= 100\n");
+               DLB2_LOG_ERR("Error parsing cos bandwidth devarg. Should be bw0:bw1:bw2:bw3  where all values combined are <= 100\n");
                return -EINVAL;
        }
 
@@ -781,9 +789,9 @@ dlb2_hw_create_sched_domain(struct dlb2_eventdev *dlb2,
 
        /* LDB ports */
 
-       /* tally of ports with non default COS */
-       cos_ports = dlb2->cos_ports[1] + dlb2->cos_ports[2] +
-                   dlb2->cos_ports[3];
+       /* tally of COS ports from cmd line */
+       cos_ports = dlb2->cos_ports[0] + dlb2->cos_ports[1] +
+                   dlb2->cos_ports[2] + dlb2->cos_ports[3];
 
        if (cos_ports > resources_asked->num_ldb_ports) {
                DLB2_LOG_ERR("dlb2: num_ldb_ports < nonzero cos_ports\n");
@@ -4552,6 +4560,17 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
        evdev_dlb2_default_info.max_event_port_enqueue_depth =
                dlb2->max_enq_depth;
 
+       dlb2_init_queue_depth_thresholds(dlb2,
+                                        dlb2_args->qid_depth_thresholds.val);
+
+       dlb2_init_cq_weight(dlb2,
+                           dlb2_args->cq_weight.limit);
+
+       dlb2_init_port_cos(dlb2,
+                          dlb2_args->port_cos.cos_id);
+
+       dlb2_init_cos_bw(dlb2,
+                        &dlb2_args->cos_bw);
 
        err = dlb2_iface_open(&dlb2->qm_instance, name);
        if (err < 0) {
@@ -4623,18 +4642,6 @@ dlb2_primary_eventdev_probe(struct rte_eventdev *dev,
 
        dlb2_entry_points_init(dev);
 
-       dlb2_init_queue_depth_thresholds(dlb2,
-                                        dlb2_args->qid_depth_thresholds.val);
-
-       dlb2_init_cq_weight(dlb2,
-                           dlb2_args->cq_weight.limit);
-
-       dlb2_init_port_cos(dlb2,
-                          dlb2_args->port_cos.cos_id);
-
-       dlb2_init_cos_bw(dlb2,
-                        &dlb2_args->cos_bw);
-
        return 0;
 }
 
drivers/event/dlb2/pf/base/dlb2_resource.c +0 -3
index da1949c763..e73d289445 100644
@@ -236,9 +236,6 @@ int dlb2_resource_init(struct dlb2_hw *hw, enum dlb2_hw_ver ver)
                hw->rsrcs.sn_groups[i].slot_use_bitmap = 0;
        }
 
-       for (i = 0; i < DLB2_NUM_COS_DOMAINS; i++)
-               hw->cos_reservation[i] = 100 / DLB2_NUM_COS_DOMAINS;
-
        return 0;
 
 unwind:
drivers/event/dlb2/pf/dlb2_pf.c +4 -1
index 086d4a1cc7..dd3f2b8ece 100644
@@ -712,10 +712,14 @@ dlb2_eventdev_pci_init(struct rte_eventdev *eventdev)
                .max_enq_depth = DLB2_MAX_ENQUEUE_DEPTH
        };
        struct dlb2_eventdev *dlb2;
+       int q;
 
        DLB2_LOG_DBG("Enter with dev_id=%d socket_id=%d",
                     eventdev->data->dev_id, eventdev->data->socket_id);
 
+       for (q = 0; q < DLB2_MAX_NUM_PORTS_ALL; q++)
+               dlb2_args.port_cos.cos_id[q] = DLB2_COS_DEFAULT;
+
        dlb2_pf_iface_fn_ptrs_init();
 
        pci_dev = RTE_DEV_TO_PCI(eventdev->dev);
--

2.25.1