From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
James Hershaw <james.hershaw@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH v3 1/8] ethdev: add member notification for bonding port
Date: Sun, 8 Oct 2023 09:50:34 +0800 [thread overview]
Message-ID: <20231008015041.1551165-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231008015041.1551165-1-chaoyong.he@corigine.com>
From: Long Wu <long.wu@corigine.com>
Bonding PMD does not let member ports know the bonding port's
information, like how many member ports the bonding port has,
what mode the bonding port is in and so on.
Add the notification interface for bonding port to let member
port know it is added to a bonding port and what the bonding
port's configuration is. If so the member ports have chance to
achieve its bond-flow-offlod or other private bonding functions.
Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/bonding/eth_bond_private.h | 1 +
drivers/net/bonding/rte_eth_bond.h | 46 ++++++++++++++++
drivers/net/bonding/rte_eth_bond_api.c | 73 ++++++++++++++++++++++++++
drivers/net/bonding/rte_eth_bond_pmd.c | 27 ++++++++--
drivers/net/bonding/version.map | 3 ++
lib/ethdev/ethdev_driver.h | 18 +++++++
6 files changed, 165 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h
index e688894210..f69e85c199 100644
--- a/drivers/net/bonding/eth_bond_private.h
+++ b/drivers/net/bonding/eth_bond_private.h
@@ -180,6 +180,7 @@ struct bond_dev_private {
uint8_t member_update_idx;
bool kvargs_processing_is_done;
+ bool notify_member; /**< Enable member notification of bonding port. */
uint32_t candidate_max_rx_pktlen;
uint32_t max_rx_pktlen;
diff --git a/drivers/net/bonding/rte_eth_bond.h b/drivers/net/bonding/rte_eth_bond.h
index f10165f2c6..737beca446 100644
--- a/drivers/net/bonding/rte_eth_bond.h
+++ b/drivers/net/bonding/rte_eth_bond.h
@@ -351,6 +351,52 @@ 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);
+/**
+ * Set the flag of whether bonding port notifies member ports.
+ *
+ * @param bonding_port_id
+ * Port ID of bonding device.
+ * @param notify_member
+ * Flag of whether bonding port notifies member ports.
+ *
+ * @return
+ * 0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_eth_bond_notify_member_flag_set(uint16_t bonding_port_id, bool notify_member);
+
+/**
+ * Get the flag of whether bonding port notifies member ports.
+ *
+ * @param bonding_port_id
+ * Port ID of bonding device.
+ * @param notify_member
+ * Flag of whether bonding port notifies member ports.
+ *
+ * @return
+ * 0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_eth_bond_notify_member_flag_get(uint16_t bonding_port_id, bool *notify_member);
+
+/**
+ * Notify the member ports of bonding port's information.
+ *
+ * This interface is called in the following functions:
+ * - bond_ethdev_lsc_event_callback()
+ * - bond_ethdev_configure()
+ *
+ * @param bonding_port_id
+ * Port ID of bonding device.
+ *
+ * @return
+ * 0 on success, negative value otherwise.
+ */
+__rte_experimental
+int
+rte_eth_bond_notify_members(uint16_t bonding_port_id);
#ifdef __cplusplus
}
diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c
index 99e496556a..48c1d050fd 100644
--- a/drivers/net/bonding/rte_eth_bond_api.c
+++ b/drivers/net/bonding/rte_eth_bond_api.c
@@ -627,6 +627,17 @@ __eth_bond_member_add_lock_free(uint16_t bonding_port_id, uint16_t member_port_i
member_vlan_filter_set(bonding_port_id, member_port_id);
+ if (internals->notify_member &&
+ *member_eth_dev->dev_ops->bond_notify_member != NULL) {
+ ret = member_eth_dev->dev_ops->bond_notify_member(member_eth_dev,
+ bonding_eth_dev);
+ if (ret < 0) {
+ RTE_BOND_LOG(ERR, "Add member (port %u) notify failed!",
+ member_port_id);
+ return -1;
+ }
+ }
+
return 0;
}
@@ -733,6 +744,10 @@ __eth_bond_member_remove_lock_free(uint16_t bonding_port_id,
member_eth_dev = &rte_eth_devices[member_port_id];
member_remove(internals, member_eth_dev);
member_eth_dev->data->dev_flags &= (~RTE_ETH_DEV_BONDING_MEMBER);
+ if (internals->notify_member &&
+ *member_eth_dev->dev_ops->bond_notify_member != NULL)
+ member_eth_dev->dev_ops->bond_notify_member(member_eth_dev,
+ bonding_eth_dev);
/* first member in the active list will be the primary by default,
* otherwise use first device in list */
@@ -1098,3 +1113,61 @@ rte_eth_bond_link_up_prop_delay_get(uint16_t bonding_port_id)
return internals->link_up_delay_ms;
}
+
+int
+rte_eth_bond_notify_member_flag_set(uint16_t bonding_port_id, bool notify_member)
+{
+ struct bond_dev_private *internals;
+
+ if (valid_bonding_port_id(bonding_port_id) != 0)
+ return -EINVAL;
+
+ internals = rte_eth_devices[bonding_port_id].data->dev_private;
+
+ internals->notify_member = notify_member;
+
+ return 0;
+}
+
+int
+rte_eth_bond_notify_member_flag_get(uint16_t bonding_port_id, bool *notify_member)
+{
+ struct bond_dev_private *internals;
+
+ if (valid_bonding_port_id(bonding_port_id) != 0)
+ return -EINVAL;
+
+ internals = rte_eth_devices[bonding_port_id].data->dev_private;
+
+ *notify_member = internals->notify_member;
+
+ return 0;
+}
+
+int
+rte_eth_bond_notify_members(uint16_t bonding_port_id)
+{
+ uint32_t i;
+ uint16_t member_port_id;
+ struct rte_eth_dev *bond_dev;
+ struct bond_dev_private *internals;
+ struct rte_eth_dev *member_dev[RTE_MAX_ETHPORTS];
+
+ if (valid_bonding_port_id(bonding_port_id) != 0)
+ return -EINVAL;
+
+ bond_dev = &rte_eth_devices[bonding_port_id];
+ internals = bond_dev->data->dev_private;
+
+ for (i = 0; i < internals->member_count; i++) {
+ member_port_id = internals->members[i].port_id;
+ member_dev[i] = &rte_eth_devices[member_port_id];
+ if (*member_dev[i]->dev_ops->bond_notify_member == NULL)
+ return -ENOTSUP;
+ }
+
+ for (i = 0; i < internals->member_count; i++)
+ member_dev[i]->dev_ops->bond_notify_member(member_dev[i], bond_dev);
+
+ return 0;
+}
diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 122b1187fd..b99b8b8938 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -2968,11 +2968,13 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
int valid_member = 0;
uint16_t active_pos, member_idx;
uint16_t i;
+ uint16_t bonding_port_id;
if (type != RTE_ETH_EVENT_INTR_LSC || param == NULL)
return rc;
- bonding_eth_dev = &rte_eth_devices[*(uint16_t *)param];
+ bonding_port_id = *(uint16_t *)param;
+ bonding_eth_dev = &rte_eth_devices[bonding_port_id];
if (check_for_bonding_ethdev(bonding_eth_dev))
return rc;
@@ -3044,8 +3046,10 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
* using it.
*/
if (internals->user_defined_primary_port &&
- internals->primary_port == port_id)
+ internals->primary_port == port_id) {
bond_ethdev_primary_set(internals, port_id);
+ rte_eth_bond_notify_members(bonding_port_id);
+ }
} else {
if (active_pos == internals->active_member_count)
goto link_update;
@@ -3064,6 +3068,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type,
internals->active_members[0]);
else
internals->current_primary_port = internals->primary_port;
+ rte_eth_bond_notify_members(bonding_port_id);
mac_address_members_update(bonding_eth_dev);
bond_ethdev_promiscuous_update(bonding_eth_dev);
bond_ethdev_allmulticast_update(bonding_eth_dev);
@@ -3362,6 +3367,7 @@ dump_basic(const struct rte_eth_dev *dev, FILE *f)
struct bond_dev_private instant_priv;
const struct bond_dev_private *internals = &instant_priv;
int mode, i;
+ bool notify_member;
/* Obtain a instance of dev_private to prevent data from being modified. */
memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private));
@@ -3431,6 +3437,13 @@ dump_basic(const struct rte_eth_dev *dev, FILE *f)
fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
if (internals->member_count > 0)
fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
+
+ if (rte_eth_bond_notify_member_flag_get(internals->port_id, ¬ify_member) == 0)
+ fprintf(f, "\tNotify Member Ports Flag: %s\n",
+ notify_member ? "enable" : "disable");
+ else
+ fprintf(f, "\tFailed to get notify member ports flag for bonding port %d\n",
+ internals->port_id);
}
static void
@@ -3983,8 +3996,12 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
* if no kvlist, it means that this bonding device has been created
* through the bonding api.
*/
- if (!kvlist || internals->kvargs_processing_is_done)
+ if (!kvlist || internals->kvargs_processing_is_done) {
+ if (internals->notify_member && rte_eth_bond_notify_members(port_id) != 0)
+ RTE_BOND_LOG(ERR, "Notify member ports failed");
+
return 0;
+ }
internals->kvargs_processing_is_done = true;
@@ -4222,6 +4239,10 @@ bond_ethdev_configure(struct rte_eth_dev *dev)
return -1;
}
}
+
+ if (internals->notify_member && rte_eth_bond_notify_members(port_id) != 0)
+ RTE_BOND_LOG(ERR, "Notify member ports failed");
+
return 0;
}
diff --git a/drivers/net/bonding/version.map b/drivers/net/bonding/version.map
index 09ee21c55f..3bd5e8ad11 100644
--- a/drivers/net/bonding/version.map
+++ b/drivers/net/bonding/version.map
@@ -35,4 +35,7 @@ EXPERIMENTAL {
rte_eth_bond_member_add;
rte_eth_bond_member_remove;
rte_eth_bond_members_get;
+ rte_eth_bond_notify_member_flag_get;
+ rte_eth_bond_notify_member_flag_set;
+ rte_eth_bond_notify_members;
};
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index deb23ada18..f626f971e5 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1216,6 +1216,21 @@ typedef int (*eth_count_aggr_ports_t)(struct rte_eth_dev *dev);
typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id,
uint8_t affinity);
+/**
+ * @internal
+ * Bonding port notifies the member ports.
+ *
+ * @param dev
+ * Member port (ethdev) handle.
+ * @param bonding_dev
+ * Bonding port (ethdev) handle.
+ *
+ * @return
+ * Negative on error, 0 on success.
+ */
+typedef int (*eth_bond_notify_member)(struct rte_eth_dev *dev,
+ struct rte_eth_dev *bonding_dev);
+
/**
* @internal A structure containing the functions exported by an Ethernet driver.
*/
@@ -1455,6 +1470,9 @@ struct eth_dev_ops {
eth_count_aggr_ports_t count_aggr_ports;
/** Map a Tx queue with an aggregated port of the DPDK port */
eth_map_aggr_tx_affinity_t map_aggr_tx_affinity;
+
+ /** Notify the member port of bonding port information */
+ eth_bond_notify_member bond_notify_member;
};
/**
--
2.39.1
next prev parent reply other threads:[~2023-10-08 1:51 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 2:40 [PATCH 0/8] Enhance the bond framework to support offload Chaoyong He
2023-10-05 2:40 ` [PATCH 1/8] ethdev: add member notification for bonding port Chaoyong He
2023-10-05 2:40 ` [PATCH 2/8] ethdev: add API to get hardware creation of " Chaoyong He
2023-10-05 2:40 ` [PATCH 3/8] net/bonding: modify interface comment format Chaoyong He
2023-10-05 2:40 ` [PATCH 4/8] net/bonding: add bonding port arguments Chaoyong He
2023-10-05 2:40 ` [PATCH 5/8] net/bonding: support add port by data name Chaoyong He
2023-10-05 2:40 ` [PATCH 6/8] net/bonding: create new rte flow header file Chaoyong He
2023-10-05 2:40 ` [PATCH 7/8] net/bonding: support checking valid bonding port ID Chaoyong He
2023-10-05 2:40 ` [PATCH 8/8] net/bonding: add commands for bonding port notification Chaoyong He
2023-10-07 1:34 ` [PATCH v2 0/8] Enhance the bond framework to support offload Chaoyong He
2023-10-07 1:34 ` [PATCH v2 1/8] ethdev: add member notification for bonding port Chaoyong He
2023-10-07 15:49 ` Stephen Hemminger
2023-10-08 1:37 ` Chaoyong He
2023-10-07 1:34 ` [PATCH v2 2/8] ethdev: add API to get hardware creation of " Chaoyong He
2023-10-07 1:34 ` [PATCH v2 3/8] net/bonding: modify interface comment format Chaoyong He
2023-10-07 1:34 ` [PATCH v2 4/8] net/bonding: add bonding port arguments Chaoyong He
2023-10-07 1:34 ` [PATCH v2 5/8] net/bonding: support add port by data name Chaoyong He
2023-10-07 1:34 ` [PATCH v2 6/8] net/bonding: create new rte flow header file Chaoyong He
2023-10-07 1:34 ` [PATCH v2 7/8] net/bonding: support checking valid bonding port ID Chaoyong He
2023-10-07 1:34 ` [PATCH v2 8/8] net/bonding: add commands for bonding port notification Chaoyong He
2023-10-08 1:50 ` [PATCH v3 0/8] Enhance the bond framework to support offload Chaoyong He
2023-10-08 1:50 ` Chaoyong He [this message]
2023-10-08 2:49 ` [PATCH v3 1/8] ethdev: add member notification for bonding port lihuisong (C)
2023-10-09 3:11 ` 回复: " Long Wu
2023-10-17 8:27 ` lihuisong (C)
2023-10-18 2:16 ` Chaoyong He
2023-10-08 1:50 ` [PATCH v3 2/8] ethdev: add API to get hardware creation of " Chaoyong He
2023-10-08 1:50 ` [PATCH v3 3/8] net/bonding: modify interface comment format Chaoyong He
2023-10-08 1:50 ` [PATCH v3 4/8] net/bonding: add bonding port arguments Chaoyong He
2023-10-08 1:50 ` [PATCH v3 5/8] net/bonding: support add port by data name Chaoyong He
2023-10-08 1:50 ` [PATCH v3 6/8] net/bonding: create new rte flow header file Chaoyong He
2023-10-08 1:50 ` [PATCH v3 7/8] net/bonding: support checking valid bonding port ID Chaoyong He
2023-10-17 8:33 ` lihuisong (C)
2023-10-17 9:25 ` Chaoyong He
2023-10-17 11:34 ` lihuisong (C)
2023-10-18 1:53 ` Chaoyong He
2023-10-17 15:56 ` Stephen Hemminger
2023-10-08 1:50 ` [PATCH v3 8/8] net/bonding: add commands for bonding port notification Chaoyong He
2023-10-13 2:22 ` [PATCH v3 0/8] Enhance the bond framework to support offload Chaoyong He
2023-10-13 12:53 ` Ferruh Yigit
2023-10-18 7:48 ` [PATCH v4 0/6] " Chaoyong He
2023-10-18 7:48 ` [PATCH v4 1/6] ethdev: add member notification for bonding port Chaoyong He
2023-10-18 7:48 ` [PATCH v4 2/6] ethdev: add API to get hardware creation of " Chaoyong He
2023-10-18 7:48 ` [PATCH v4 3/6] net/bonding: add bonding port arguments Chaoyong He
2023-10-18 7:48 ` [PATCH v4 4/6] net/bonding: support add port by data name Chaoyong He
2023-10-18 7:48 ` [PATCH v4 5/6] net/bonding: support checking valid bonding port ID Chaoyong He
2023-10-18 7:48 ` [PATCH v4 6/6] net/bonding: add commands for bonding port notification Chaoyong He
2023-11-15 16:01 ` [PATCH v4 0/6] Enhance the bond framework to support offload Ferruh Yigit
2023-11-16 1:45 ` Chaoyong He
2023-12-26 2:37 ` [PATCH v5 00/14] " Chaoyong He
2023-12-26 2:37 ` [PATCH v5 01/14] ethdev: add member notification for bonding port Chaoyong He
2023-12-26 2:37 ` [PATCH v5 02/14] ethdev: add API to get firmware creation of " Chaoyong He
2023-12-26 2:37 ` [PATCH v5 03/14] net/bonding: add bonding port arguments Chaoyong He
2023-12-26 2:37 ` [PATCH v5 04/14] net/bonding: support add port by data name Chaoyong He
2023-12-26 2:37 ` [PATCH v5 05/14] net/bonding: support checking valid bonding port ID Chaoyong He
2023-12-26 2:37 ` [PATCH v5 06/14] net/bonding: add commands for bonding port notification Chaoyong He
2023-12-26 2:37 ` [PATCH v5 07/14] net/bonding: create new rte flow header file Chaoyong He
2023-12-26 2:37 ` [PATCH v5 08/14] net/nfp: add bond firmware creation initialization Chaoyong He
2023-12-26 2:37 ` [PATCH v5 09/14] net/nfp: reset bond configuration of firmware Chaoyong He
2023-12-26 2:37 ` [PATCH v5 10/14] net/nfp: handle link event of bond firmware creation Chaoyong He
2023-12-26 2:37 ` [PATCH v5 11/14] net/nfp: support bond member notification Chaoyong He
2023-12-26 2:37 ` [PATCH v5 12/14] net/nfp: handle bond packets from firmware Chaoyong He
2023-12-26 2:37 ` [PATCH v5 13/14] net/nfp: support getting bond firmware creation Chaoyong He
2023-12-26 2:37 ` [PATCH v5 14/14] net/nfp: support offloading bond-flow Chaoyong He
2023-12-26 7:28 ` [PATCH v6 00/14] Enhance the bond framework to support offload Chaoyong He
2023-12-26 7:28 ` [PATCH v6 01/14] ethdev: add member notification for bonding port Chaoyong He
2023-12-26 7:28 ` [PATCH v6 02/14] ethdev: add API to get firmware creation of " Chaoyong He
2023-12-26 7:28 ` [PATCH v6 03/14] net/bonding: add bonding port arguments Chaoyong He
2023-12-26 7:28 ` [PATCH v6 04/14] net/bonding: support add port by data name Chaoyong He
2023-12-26 7:28 ` [PATCH v6 05/14] net/bonding: support checking valid bonding port ID Chaoyong He
2023-12-26 7:28 ` [PATCH v6 06/14] net/bonding: add commands for bonding port notification Chaoyong He
2023-12-26 7:28 ` [PATCH v6 07/14] net/bonding: create new rte flow header file Chaoyong He
2023-12-26 7:28 ` [PATCH v6 08/14] net/nfp: add bond firmware creation initialization Chaoyong He
2023-12-26 7:28 ` [PATCH v6 09/14] net/nfp: reset bond configuration of firmware Chaoyong He
2023-12-26 7:28 ` [PATCH v6 10/14] net/nfp: handle link event of bond firmware creation Chaoyong He
2023-12-26 7:28 ` [PATCH v6 11/14] net/nfp: support bond member notification Chaoyong He
2023-12-26 7:28 ` [PATCH v6 12/14] net/nfp: handle bond packets from firmware Chaoyong He
2023-12-26 7:28 ` [PATCH v6 13/14] net/nfp: support getting bond firmware creation Chaoyong He
2023-12-26 7:28 ` [PATCH v6 14/14] net/nfp: support offloading bond-flow Chaoyong He
2024-09-22 22:30 ` [PATCH v6 00/14] Enhance the bond framework to support offload Ferruh Yigit
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=20231008015041.1551165-2-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=james.hershaw@corigine.com \
--cc=long.wu@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).