[v4,3/6] net/bonding: add bonding port arguments

Message ID 20231018074821.1908906-4-chaoyong.he@corigine.com (mailing list archive)
State Superseded
Delegated to: Ferruh Yigit
Headers
Series Enhance the bond framework to support offload |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Oct. 18, 2023, 7:48 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Include the following new arguments for bonding ports:
- "notify_member" to enable/disable member notification.
- "dedicated_queue" to enable/disable dedicated queue.

Add these two arguments in initial argument.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/bonding/eth_bond_private.h  | 10 ++++
 drivers/net/bonding/rte_eth_bond.h      | 14 ++++++
 drivers/net/bonding/rte_eth_bond_api.c  | 14 ++++++
 drivers/net/bonding/rte_eth_bond_args.c | 44 ++++++++++++++++++
 drivers/net/bonding/rte_eth_bond_pmd.c  | 61 ++++++++++++++++++++++++-
 5 files changed, 142 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index f69e85c199..f9603a0f6b 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -28,6 +28,8 @@ 
 #define PMD_BOND_LSC_POLL_PERIOD_KVARG		("lsc_poll_period_ms")
 #define PMD_BOND_LINK_UP_PROP_DELAY_KVARG	("up_delay")
 #define PMD_BOND_LINK_DOWN_PROP_DELAY_KVARG	("down_delay")
+#define PMD_BOND_NOTIFY_MEMBER_KVARG		("notify_member")
+#define PMD_BOND_DEDICATED_QUEUE_KVARG		("dedicated_queue")
 
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
@@ -319,6 +321,14 @@  int
 bond_ethdev_parse_time_ms_kvarg(const char *key,
 		const char *value, void *extra_args);
 
+int
+bond_ethdev_parse_notify_member_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
+int
+bond_ethdev_parse_dedicated_queue_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args);
+
 void
 bond_tlb_disable(struct bond_dev_private *internals);
 
diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index 987269b323..936ab8c3a0 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -351,6 +351,20 @@  rte_eth_bond_link_up_prop_delay_set(uint16_t bonding_port_id,
 int
 rte_eth_bond_link_up_prop_delay_get(uint16_t bonding_port_id);
 
+/**
+ * Set the flag that whether bonding device enable dedicated queue.
+ *
+ * @param bonding_port_id
+ *   Port ID of bonding device.
+ * @param queue_flag
+ *   The flag of enable bond dedicated queue
+ *
+ * @return
+ *   0 on success, negative value otherwise.
+ */
+int
+rte_eth_bond_dedicated_queue_flag_set(uint16_t bonding_port_id, bool queue_flag);
+
 /**
  * Set the flag of whether bonding port notifies member ports.
  *
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 317c3c1542..656ddd35a7 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -1114,6 +1114,20 @@  rte_eth_bond_link_up_prop_delay_get(uint16_t bonding_port_id)
 	return internals->link_up_delay_ms;
 }
 
+int
+rte_eth_bond_dedicated_queue_flag_set(uint16_t bonding_port_id, bool queue_flag)
+{
+	struct bond_dev_private *internals;
+
+	if (valid_bonding_port_id(bonding_port_id) != 0)
+		return -1;
+
+	internals = rte_eth_devices[bonding_port_id].data->dev_private;
+	internals->mode4.dedicated_queues.enabled = queue_flag;
+
+	return 0;
+}
+
 int
 rte_eth_bond_notify_member_flag_set(uint16_t bonding_port_id, bool notify)
 {
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index bdec5d61d4..8a3e4656ef 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -20,6 +20,8 @@  const char *pmd_bond_init_valid_arguments[] = {
 	PMD_BOND_MAC_ADDR_KVARG,
 	PMD_BOND_AGG_MODE_KVARG,
 	RTE_DEVARGS_KEY_DRIVER,
+	PMD_BOND_NOTIFY_MEMBER_KVARG,
+	PMD_BOND_DEDICATED_QUEUE_KVARG,
 	NULL
 };
 
@@ -297,3 +299,45 @@  bond_ethdev_parse_time_ms_kvarg(const char *key __rte_unused,
 
 	return 0;
 }
+
+int
+bond_ethdev_parse_notify_member_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args)
+{
+	bool *notify_member;
+
+	if (value == NULL || extra_args == NULL)
+		return -1;
+
+	notify_member = extra_args;
+
+	if (strcmp("enable", value) == 0)
+		*notify_member = true;
+	else if (strcmp("disable", value) == 0)
+		*notify_member = false;
+	else
+		return -1;
+
+	return 0;
+}
+
+int
+bond_ethdev_parse_dedicated_queue_kvarg(const char *key __rte_unused,
+		const char *value, void *extra_args)
+{
+	bool *dedicated_queue;
+
+	if (value == NULL || extra_args == NULL)
+		return -1;
+
+	dedicated_queue = extra_args;
+
+	if (strcmp("enable", value) == 0)
+		*dedicated_queue = true;
+	else if (strcmp("disable", value) == 0)
+		*dedicated_queue = false;
+	else
+		return -1;
+
+	return 0;
+}
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index fc7f0f364f..4bede0aa71 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -4232,6 +4232,63 @@  bond_ethdev_configure(struct rte_eth_dev *dev)
 		return -1;
 	}
 
+	/* Parse/set notify member flag */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_NOTIFY_MEMBER_KVARG);
+	if (arg_count == 1) {
+		bool notify_member;
+		if (rte_kvargs_process(kvlist,
+				       PMD_BOND_NOTIFY_MEMBER_KVARG,
+				       &bond_ethdev_parse_notify_member_kvarg,
+				       &notify_member) < 0) {
+			RTE_BOND_LOG(ERR,
+				     "Invalid notify member value specified"
+				     " for bonding device %s", name);
+			return -1;
+		}
+
+		if (rte_eth_bond_notify_member_flag_set(port_id, notify_member) != 0) {
+			RTE_BOND_LOG(ERR,
+				     "Failed to set notify member (%u) on"
+				     " bonding device %s", notify_member, name);
+			return -1;
+		}
+	} else if (arg_count > 1) {
+		RTE_BOND_LOG(ERR,
+			     "notify member flag can be specified only once"
+			     " for bonding device %s", name);
+		return -1;
+	}
+
+	/* Parse/set dedicated queue flag */
+	arg_count = rte_kvargs_count(kvlist, PMD_BOND_DEDICATED_QUEUE_KVARG);
+	if (arg_count == 1) {
+		bool dedicated_queue;
+		if (rte_kvargs_process(kvlist,
+				       PMD_BOND_DEDICATED_QUEUE_KVARG,
+				       &bond_ethdev_parse_dedicated_queue_kvarg,
+				       &dedicated_queue) < 0) {
+			RTE_BOND_LOG(ERR,
+				     "Invalid dedicated queue flag specified"
+				     " for bonding device %s", name);
+			return -1;
+		}
+
+		if (internals->mode == BONDING_MODE_8023AD) {
+			if (rte_eth_bond_dedicated_queue_flag_set(port_id, dedicated_queue) != 0) {
+				RTE_BOND_LOG(ERR,
+					     "Failed to enable/disable dedicated"
+					     " queue flag on bonding device %s",
+					     name);
+				return -1;
+			}
+		}
+	} else if (arg_count > 1) {
+		RTE_BOND_LOG(ERR,
+			     "dedicated queue flag can be specified only once"
+			     " for bonding device %s", name);
+		return -1;
+	}
+
 	/* configure members so we can pass mtu setting */
 	for (i = 0; i < internals->member_count; i++) {
 		struct rte_eth_dev *member_ethdev =
@@ -4269,7 +4326,9 @@  RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"mac=<mac addr> "
 	"lsc_poll_period_ms=<int> "
 	"up_delay=<int> "
-	"down_delay=<int>");
+	"down_delay=<int>"
+	"notify_member=[enable | disable] "
+	"dedicated_queue=[enable | disable] ");
 
 /* We can't use RTE_LOG_REGISTER_DEFAULT because of the forced name for
  * this library, see meson.build.