> From: Vignesh PS <vignesh.purushotham.srini...@ericsson.com> > > Add support to bonding PMD to allow user callback function registration for > TX transmit policy. > > Signed-off-by: Vignesh PS <vignesh.purushotham.srini...@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 <viachesl...@nvidia.com> > <viachesl...@mellanox.com> Victor Kaplansky <vict...@redhat.com> Victor > Raj <victor....@intel.com> Vidya Sagar Velumuri <vvelum...@marvell.com> > +Vignesh PS <vignesh.purushotham.srini...@ericsson.com> > +<vig.vigneshps1...@gmail.com> > Vignesh Sridhar <vignesh.srid...@intel.com> Vijayakumar Muthuvel > Manickam <mmvi...@gmail.com> Vijaya Mohan Guvva > <vijay1...@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