DPDK patches and discussions
 help / color / mirror / Atom feed
From: <vignesh.purushotham.srinivas@ericsson.com>
To: <chas3@att.com>, <humin29@huawei.com>
Cc: <dev@dpdk.org>, Vignesh PS <vignesh.purushotham.srinivas@ericsson.com>
Subject: [RFC] net/bonding: add user callback for bond xmit policy
Date: Tue, 13 Feb 2024 18:22:46 +0100	[thread overview]
Message-ID: <20240213172246.1094308-1-vignesh.purushotham.srinivas@ericsson.com> (raw)

From: Vignesh PS <vignesh.purushotham.srinivas@ericsson.com>

Add support to bonding PMD to allow user callback
function registration for TX transmit policy.

Signed-off-by: Vignesh PS <vignesh.purushotham.srinivas@ericsson.com>
---
 .mailmap                                |  1 +
 drivers/net/bonding/eth_bond_private.h  |  6 ++----
 drivers/net/bonding/rte_eth_bond.h      | 17 +++++++++++++++++
 drivers/net/bonding/rte_eth_bond_api.c  | 15 +++++++++++++++
 drivers/net/bonding/rte_eth_bond_args.c |  2 ++
 drivers/net/bonding/rte_eth_bond_pmd.c  |  2 +-
 drivers/net/bonding/version.map         |  1 +
 7 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/.mailmap b/.mailmap
index de339562f4..6c068d5af3 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1476,6 +1476,7 @@ Viacheslav Ovsiienko <viacheslavo@nvidia.com> <viacheslavo@mellanox.com>
 Victor Kaplansky <victork@redhat.com>
 Victor Raj <victor.raj@intel.com>
 Vidya Sagar Velumuri <vvelumuri@marvell.com>
+Vignesh PS <vignesh.purushotham.srinivas@ericsson.com> <vig.vigneshps1995@gmail.com>
 Vignesh Sridhar <vignesh.sridhar@intel.com>
 Vijayakumar Muthuvel Manickam <mmvijay@gmail.com>
 Vijaya Mohan Guvva <vijay1054@gmail.com>
diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index e688894210..4141b6e09f 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -32,6 +32,7 @@
 #define PMD_BOND_XMIT_POLICY_LAYER2_KVARG	("l2")
 #define PMD_BOND_XMIT_POLICY_LAYER23_KVARG	("l23")
 #define PMD_BOND_XMIT_POLICY_LAYER34_KVARG	("l34")
+#define PMD_BOND_XMIT_POLICY_USER_KVARG	("user")
 
 extern int bond_logtype;
 
@@ -101,9 +102,6 @@ struct rte_flow {
 	uint8_t rule_data[];
 };
 
-typedef void (*burst_xmit_hash_t)(struct rte_mbuf **buf, uint16_t nb_pkts,
-		uint16_t member_count, uint16_t *members);
-
 /** Link Bonding PMD device private configuration Structure */
 struct bond_dev_private {
 	uint16_t port_id;			/**< Port Id of Bonding Port */
@@ -118,7 +116,7 @@ struct bond_dev_private {
 	/**< Flag for whether primary port is user defined or not */
 
 	uint8_t balance_xmit_policy;
-	/**< Transmit policy - l2 / l23 / l34 for operation in balance mode */
+	/**< Transmit policy - l2 / l23 / l34 / user for operation in balance mode */
 	burst_xmit_hash_t burst_xmit_hash;
 	/**< Transmit policy hash function */
 
diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index f10165f2c6..66bc41097a 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -91,6 +91,11 @@ extern "C" {
 /**< Layer 2+3 (Ethernet MAC + IP Addresses) transmit load balancing */
 #define BALANCE_XMIT_POLICY_LAYER34		(2)
 /**< Layer 3+4 (IP Addresses + UDP Ports) transmit load balancing */
+#define BALANCE_XMIT_POLICY_USER		(3)
+/**< User callback function to transmit load balancing */
+
+typedef void (*burst_xmit_hash_t)(struct rte_mbuf **buf, uint16_t nb_pkts,
+	uint16_t slave_count, uint16_t *slaves);
 
 /**
  * Create a bonding rte_eth_dev device
@@ -351,6 +356,18 @@ 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);
 
+/**
+ * Register transmit callback function for bonded device to use when it is operating in
+ * balance mode. The callback is ignored in other modes of operation.
+ *
+ * @param cb_fn           User defined callback function to determine the xmit slave
+ *
+ * @return
+ *     0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_eth_bond_xmit_policy_cb_register(burst_xmit_hash_t cb_fn);
 
 #ifdef __cplusplus
 }
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 99e496556a..b53038eeda 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -15,6 +15,8 @@
 #include "eth_bond_private.h"
 #include "eth_bond_8023ad_private.h"
 
+static burst_xmit_hash_t burst_xmit_user_hash;
+
 int
 check_for_bonding_ethdev(const struct rte_eth_dev *eth_dev)
 {
@@ -972,6 +974,13 @@ rte_eth_bond_mac_address_reset(uint16_t bonding_port_id)
 	return 0;
 }
 
+int
+rte_eth_bond_xmit_policy_cb_register(burst_xmit_hash_t cb_fn)
+{
+	burst_xmit_user_hash = cb_fn;
+	return 0;
+}
+
 int
 rte_eth_bond_xmit_policy_set(uint16_t bonding_port_id, uint8_t policy)
 {
@@ -995,6 +1004,12 @@ rte_eth_bond_xmit_policy_set(uint16_t bonding_port_id, uint8_t policy)
 		internals->balance_xmit_policy = policy;
 		internals->burst_xmit_hash = burst_xmit_l34_hash;
 		break;
+	case BALANCE_XMIT_POLICY_USER:
+		if (burst_xmit_user_hash == NULL)
+			return -1;
+		internals->balance_xmit_policy = policy;
+		internals->burst_xmit_hash = burst_xmit_user_hash;
+		break;
 
 	default:
 		return -1;
diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
index bdec5d61d4..eaa313bf73 100644
--- a/drivers/net/bonding/rte_eth_bond_args.c
+++ b/drivers/net/bonding/rte_eth_bond_args.c
@@ -261,6 +261,8 @@ bond_ethdev_parse_balance_xmit_policy_kvarg(const char *key __rte_unused,
 		*xmit_policy = BALANCE_XMIT_POLICY_LAYER23;
 	else if (strcmp(PMD_BOND_XMIT_POLICY_LAYER34_KVARG, value) == 0)
 		*xmit_policy = BALANCE_XMIT_POLICY_LAYER34;
+	else if (strcmp(PMD_BOND_XMIT_POLICY_USER_KVARG, value) == 0)
+		*xmit_policy = BALANCE_XMIT_POLICY_USER;
 	else
 		return -1;
 
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index c40d18d128..92b0126a6d 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -4251,7 +4251,7 @@ RTE_PMD_REGISTER_PARAM_STRING(net_bonding,
 	"member=<ifc> "
 	"primary=<ifc> "
 	"mode=[0-6] "
-	"xmit_policy=[l2 | l23 | l34] "
+	"xmit_policy=[l2 | l23 | l34 | user] "
 	"agg_mode=[count | stable | bandwidth] "
 	"socket_id=<int> "
 	"mac=<mac addr> "
diff --git a/drivers/net/bonding/version.map b/drivers/net/bonding/version.map
index 09ee21c55f..6e82d2c72f 100644
--- a/drivers/net/bonding/version.map
+++ b/drivers/net/bonding/version.map
@@ -35,4 +35,5 @@ EXPERIMENTAL {
 	rte_eth_bond_member_add;
 	rte_eth_bond_member_remove;
 	rte_eth_bond_members_get;
+	rte_eth_bond_xmit_policy_cb_register;
 };
-- 
2.34.1



                 reply	other threads:[~2024-02-13 17:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240213172246.1094308-1-vignesh.purushotham.srinivas@ericsson.com \
    --to=vignesh.purushotham.srinivas@ericsson.com \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.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).