* [PATCH v2] net/bonding: add user callback for bond xmit policy
@ 2024-10-15 8:20 vignesh.purushotham.srinivas
2024-10-17 16:04 ` Thomas Monjalon
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vignesh.purushotham.srinivas @ 2024-10-15 8:20 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 f51b1dda5d..16ebc28a5a 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1556,6 +1556,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 378bbba4e6..9d4483a972 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;
#define RTE_LOGTYPE_BOND 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 e59ff8793e..2244b39bb9 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 member_count, uint16_t *members);
/**
* 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 members
+ *
+ * @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 ffc1322047..351f2c99dc 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 34131f0e35..9372ddb027 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 v2] net/bonding: add user callback for bond xmit policy
2024-10-15 8:20 [PATCH v2] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
@ 2024-10-17 16:04 ` Thomas Monjalon
2024-10-21 5:50 ` Chaoyong He
2024-12-03 18:11 ` Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2024-10-17 16:04 UTC (permalink / raw)
To: Vignesh PS; +Cc: chas3, dev, humin29, dev, Chaoyong He
15/10/2024 10:20, vignesh.purushotham.srinivas@ericsson.com:
> 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>
We have a lack of reviews on bonding patches.
Please could you have a try to look at this other patch?
https://patches.dpdk.org/project/dpdk/patch/20241011032412.3672788-3-chaoyong.he@corigine.com/
Maybe he will do the same for you.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] net/bonding: add user callback for bond xmit policy
2024-10-15 8:20 [PATCH v2] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
2024-10-17 16:04 ` Thomas Monjalon
@ 2024-10-21 5:50 ` Chaoyong He
2024-12-03 18:11 ` Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Chaoyong He @ 2024-10-21 5:50 UTC (permalink / raw)
To: vignesh.purushotham.srinivas, chas3; +Cc: humin29, dev, Long Wu
> 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 f51b1dda5d..16ebc28a5a 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -1556,6 +1556,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 378bbba4e6..9d4483a972 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;
> #define RTE_LOGTYPE_BOND 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 e59ff8793e..2244b39bb9 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 member_count, uint16_t *members);
>
> /**
> * 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
> members
> + *
> + * @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 ffc1322047..351f2c99dc 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;
> +}
If there are 3 bonding ports, and I want to assign 'user_define_xmit_1()' to ponding port 0,
and to assign 'user_define_xmit_2()' to ponding port 2, seems will have problem?
Maybe we can use an array for the function pointer and add a 'bonding_port_id' parameter to this register API?
> +
> 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 34131f0e35..9372ddb027 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] "
Here maybe we also need modify the 'set bonding balance_xmit_policy <port_id>' command of testpmd app?
> "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 v2] net/bonding: add user callback for bond xmit policy
2024-10-15 8:20 [PATCH v2] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
2024-10-17 16:04 ` Thomas Monjalon
2024-10-21 5:50 ` Chaoyong He
@ 2024-12-03 18:11 ` Stephen Hemminger
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2024-12-03 18:11 UTC (permalink / raw)
To: vignesh.purushotham.srinivas; +Cc: chas3, humin29, dev
On Tue, 15 Oct 2024 10:20:49 +0200
<vignesh.purushotham.srinivas@ericsson.com> wrote:
> 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>
Allowing a callback hook for more complex options is good, but needs
a little more work for completeness.
The xmit callback register should take a portid to indicate which
port it is for, and do checking of that portid that it is a bond port.
Also need a test in CI. Something in testpmd to set it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-12-03 18:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15 8:20 [PATCH v2] net/bonding: add user callback for bond xmit policy vignesh.purushotham.srinivas
2024-10-17 16:04 ` Thomas Monjalon
2024-10-21 5:50 ` Chaoyong He
2024-12-03 18:11 ` Stephen Hemminger
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).