DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, niklas.soderlund@corigine.com,
	Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3 1/2] net/bonding: add independent LACP sending function
Date: Wed,  1 Mar 2023 10:48:25 +0800	[thread overview]
Message-ID: <20230301024826.885727-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20230301024826.885727-1-chaoyong.he@corigine.com>

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(+)

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;
+};
-- 
2.39.1


  reply	other threads:[~2023-03-01  2:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16  7:15 [PATCH 0/2] enhance bonding PMD to support the LACP negotiation Chaoyong He
2023-02-16  7:15 ` [PATCH 1/2] net/bonding: add independent LACP sending function Chaoyong He
2023-02-16 19:47   ` Stephen Hemminger
2023-02-20  9:46     ` Simon Horman
2023-02-20 16:31       ` Stephen Hemminger
2023-02-22  6:47         ` Chaoyong He
2023-02-16  7:15 ` [PATCH 2/2] app/testpmd: add support for bonding port's LACP negotiation Chaoyong He
2023-02-16  8:32 ` [PATCH v2 0/2] enhance bonding PMD to support the " Chaoyong He
2023-02-16  8:32   ` [PATCH v2 1/2] net/bonding: add independent LACP sending function Chaoyong He
2023-02-16  8:32   ` [PATCH v2 2/2] app/testpmd: add support for bonding port's LACP negotiation Chaoyong He
2023-02-16 17:05     ` Ferruh Yigit
2023-02-22  6:47       ` Chaoyong He
2023-03-01  2:48   ` [PATCH v3 0/2] enhance bonding PMD to support the " Chaoyong He
2023-03-01  2:48     ` Chaoyong He [this message]
2023-03-01  2:48     ` [PATCH v3 2/2] app/testpmd: add support for bonding port's " Chaoyong He
2023-03-15 12:03     ` [PATCH v3 0/2] enhance bonding PMD to support the " Niklas Söderlund
2023-05-12  1:50     ` Chaoyong He
2023-06-06  1:23       ` Chaoyong He
2023-06-06 16:48         ` Ferruh Yigit
2023-06-07  3:10           ` Chaoyong He
2023-06-23 13:32             ` Ferruh Yigit
2023-06-25  1:32               ` humin (Q)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230301024826.885727-2-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=niklas.soderlund@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).