[v3,1/2] net/bonding: add independent LACP sending function

Message ID 20230301024826.885727-2-chaoyong.he@corigine.com (mailing list archive)
State Not Applicable, archived
Delegated to: Ferruh Yigit
Headers
Series enhance bonding PMD to support the LACP negotiation |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Chaoyong He March 1, 2023, 2:48 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

Sending LACP control packets depends on calling the bonding port's
sending function if we disable dedicated queue. In some cases app
would not call the bonding port's sending function if there are
only LACP control packets and the negotiation between the two
bonding ports will fail.

We add the independent LACP sending function for app. App can call
it by itself and let the negotiation succeed.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 58 +++++++++++++++++++++++
 drivers/net/bonding/rte_eth_bond_8023ad.h | 21 ++++++++
 drivers/net/bonding/version.map           |  8 ++++
 3 files changed, 87 insertions(+)
  

Patch

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 4a266bb2ca..bedfe89663 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -1757,3 +1757,61 @@  rte_eth_bond_8023ad_dedicated_queues_disable(uint16_t port)
 
 	return retval;
 }
+
+int
+rte_eth_bond_8023ad_dedicated_queues_get(uint16_t port_id)
+{
+	struct rte_eth_dev *dev;
+	struct bond_dev_private *internals;
+
+	if (valid_bonded_port_id(port_id) != 0)
+		return -EINVAL;
+
+	dev = &rte_eth_devices[port_id];
+	internals = dev->data->dev_private;
+
+	if (internals->mode != BONDING_MODE_8023AD)
+		return -EINVAL;
+
+	return internals->mode4.dedicated_queues.enabled;
+}
+
+void
+rte_eth_bond_8023ad_lacp_send_one(void *queue)
+{
+	uint32_t i;
+	uint16_t member_tx_count;
+	uint16_t active_member_count;
+	uint16_t active_member_ids[RTE_MAX_ETHPORTS];
+	struct bond_tx_queue *bd_tx_q = queue;
+	struct bond_dev_private *internals = bd_tx_q->dev_private;
+
+	active_member_count = internals->active_slave_count;
+	if (unlikely(active_member_count == 0))
+		return;
+
+	for (i = 0; i < active_member_count; i++)
+		active_member_ids[i] = internals->active_slaves[i];
+
+	/* Check for LACP control packets and send if available */
+	for (i = 0; i < active_member_count; i++) {
+		struct rte_mbuf *ctrl_pkt = NULL;
+		struct port *port = &bond_mode_8023ad_ports[active_member_ids[i]];
+
+		if (likely(rte_ring_empty(port->tx_ring)))
+			continue;
+
+		if (rte_ring_dequeue(port->tx_ring, (void **)&ctrl_pkt) == 0) {
+			member_tx_count = rte_eth_tx_prepare(active_member_ids[i],
+					bd_tx_q->queue_id, &ctrl_pkt, 1);
+			member_tx_count = rte_eth_tx_burst(active_member_ids[i],
+					bd_tx_q->queue_id, &ctrl_pkt, member_tx_count);
+			/*
+			 * Re-enqueue LAG control plane packets to buffering
+			 * ring if transmission fails so the packet won't lost.
+			 */
+			if (member_tx_count != 1)
+				rte_ring_enqueue(port->tx_ring, ctrl_pkt);
+		}
+	}
+}
diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.h b/drivers/net/bonding/rte_eth_bond_8023ad.h
index 7eb392f8c8..29a1610650 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.h
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.h
@@ -331,4 +331,25 @@  rte_eth_bond_8023ad_agg_selection_get(uint16_t port_id);
 int
 rte_eth_bond_8023ad_agg_selection_set(uint16_t port_id,
 		enum rte_bond_8023ad_agg_selection agg_selection);
+
+/**
+ * Get LACP dedicated queues enable/disable for 8023ad
+ * @param port_id Bonding device id
+ * @return
+ *   0 - the port is a bonding mode 4 port with disabled dedicated queue
+ *   1 - the port is a bonding mode 4 port with enabled dedicated queue
+ *   -EINVAL - the port is not a bonding port or the bonding port's mode is not 4
+ */
+__rte_experimental
+int
+rte_eth_bond_8023ad_dedicated_queues_get(uint16_t port_id);
+
+/**
+ * Send one LACP packet for bonding port in mode 4 with disabled dedicated queue
+ * @param queue Bonding port's tx queue
+ */
+__rte_experimental
+void
+rte_eth_bond_8023ad_lacp_send_one(void *queue);
+
 #endif /* RTE_ETH_BOND_8023AD_H_ */
diff --git a/drivers/net/bonding/version.map b/drivers/net/bonding/version.map
index 9333923b4e..d5db1d15e0 100644
--- a/drivers/net/bonding/version.map
+++ b/drivers/net/bonding/version.map
@@ -31,3 +31,11 @@  DPDK_23 {
 
 	local: *;
 };
+
+EXPERIMENTAL {
+	global:
+
+	# added in 22.11
+	rte_eth_bond_8023ad_dedicated_queues_get;
+	rte_eth_bond_8023ad_lacp_send_one;
+};