DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/bonding: add user callback for bond xmit policy
@ 2024-08-15 12:10 vignesh.purushotham.srinivas
  2024-08-15 15:55 ` Patrick Robb
  2024-10-12 18:13 ` Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: vignesh.purushotham.srinivas @ 2024-08-15 12:10 UTC (permalink / raw)
  To: chas3; +Cc: humin29, dev, Vignesh PS

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 4a508bafad..69b229a5b7 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1548,6 +1548,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 a309469b1f..f407bb0ace 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net/bonding: add user callback for bond xmit policy
  2024-08-15 12:10 [PATCH] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
@ 2024-08-15 15:55 ` Patrick Robb
  2024-10-12 18:13 ` Stephen Hemminger
  1 sibling, 0 replies; 4+ messages in thread
From: Patrick Robb @ 2024-08-15 15:55 UTC (permalink / raw)
  To: vignesh.purushotham.srinivas; +Cc: chas3, humin29, dev

Recheck-request: iol-marvell-Functional

Putting in a retest for this.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net/bonding: add user callback for bond xmit policy
  2024-08-15 12:10 [PATCH] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
  2024-08-15 15:55 ` Patrick Robb
@ 2024-10-12 18:13 ` Stephen Hemminger
  2024-10-14 16:40   ` Vignesh Purushotham Srinivas
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2024-10-12 18:13 UTC (permalink / raw)
  To: vignesh.purushotham.srinivas; +Cc: chas3, humin29, dev

On Thu, 15 Aug 2024 14:10:14 +0200
<vignesh.purushotham.srinivas@ericsson.com> wrote:

> 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);

Change wording.

DPDK has replaced use of the non-inclusive term slave in bond driver.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net/bonding: add user callback for bond xmit policy
  2024-10-12 18:13 ` Stephen Hemminger
@ 2024-10-14 16:40   ` Vignesh Purushotham Srinivas
  0 siblings, 0 replies; 4+ messages in thread
From: Vignesh Purushotham Srinivas @ 2024-10-14 16:40 UTC (permalink / raw)
  To: stephen; +Cc: humin29, chas3, dev

On Thu, 15 Aug 2024 14:10:14 +0200
<vignesh.purushotham.srinivas@ericsson.com> wrote:

> > 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);
> 
> Change wording.
> 
> DPDK has replaced use of the non-inclusive term slave in bond driver.

ACK


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-14 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-15 12:10 [PATCH] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
2024-08-15 15:55 ` Patrick Robb
2024-10-12 18:13 ` Stephen Hemminger
2024-10-14 16:40   ` Vignesh Purushotham Srinivas

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).