DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] support device private dump
@ 2022-12-05  8:10 Chengwen Feng
  2022-12-05  8:10 ` [PATCH 1/2] net/bonding: support private dump ops Chengwen Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-05  8:10 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patchset adds device private dump for bonding PMD.

Chengwen Feng (2):
  net/bonding: support private dump ops
  net/bonding: support dump LACP info

 drivers/net/bonding/rte_eth_bond_pmd.c | 242 ++++++++++++++++++++++++-
 1 file changed, 241 insertions(+), 1 deletion(-)

-- 
2.17.1


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

* [PATCH 1/2] net/bonding: support private dump ops
  2022-12-05  8:10 [PATCH 0/2] support device private dump Chengwen Feng
@ 2022-12-05  8:10 ` Chengwen Feng
  2022-12-06  2:01   ` humin (Q)
  2022-12-05  8:10 ` [PATCH 2/2] net/bonding: support dump LACP info Chengwen Feng
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
  2 siblings, 1 reply; 12+ messages in thread
From: Chengwen Feng @ 2022-12-05  8:10 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patch implements eth_dev_priv_dump ops which could enhance the
debug capability.

The dump output is similar to testpmd command
"show bonding config [port]".

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 103 ++++++++++++++++++++++++-
 1 file changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index b9bcebc6cb..80fb2dc462 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3329,6 +3329,106 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	rte_spinlock_unlock(&internals->lock);
 }
 
+static const char *
+bond_mode_name(uint8_t mode)
+{
+	switch (mode) {
+	case BONDING_MODE_ROUND_ROBIN:
+		return "ROUND_ROBIN";
+	case BONDING_MODE_ACTIVE_BACKUP:
+		return "ACTIVE_BACKUP";
+	case BONDING_MODE_BALANCE:
+		return "BALANCE";
+	case BONDING_MODE_BROADCAST:
+		return "BROADCAST";
+	case BONDING_MODE_8023AD:
+		return "8023AD";
+	case BONDING_MODE_TLB:
+		return "TLB";
+	case BONDING_MODE_ALB:
+		return "ALB";
+	default:
+		return "Unknown";
+	}
+}
+
+static int
+bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+{
+	struct bond_dev_private instant_priv;
+	const struct bond_dev_private *internals = &instant_priv;
+	int bonding_mode;
+	int i;
+
+	/* Obtain a instance of dev_private to prevent data from being modified. */
+	memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private));
+	bonding_mode = internals->mode;
+
+	fprintf(f, "  - Dev basic:\n");
+	fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(bonding_mode), bonding_mode);
+
+	if (bonding_mode == BONDING_MODE_BALANCE ||
+		bonding_mode == BONDING_MODE_8023AD) {
+		fprintf(f, "\tBalance Xmit Policy: ");
+		switch (internals->balance_xmit_policy) {
+		case BALANCE_XMIT_POLICY_LAYER2:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER2");
+			break;
+		case BALANCE_XMIT_POLICY_LAYER23:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER23");
+			break;
+		case BALANCE_XMIT_POLICY_LAYER34:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER34");
+			break;
+		}
+		fprintf(f, "\n");
+	}
+
+	if (bonding_mode == BONDING_MODE_8023AD) {
+		fprintf(f, "\tIEEE802.3AD Aggregator Mode: ");
+		switch (internals->mode4.agg_selection) {
+		case AGG_BANDWIDTH:
+			fprintf(f, "bandwidth");
+			break;
+		case AGG_STABLE:
+			fprintf(f, "stable");
+			break;
+		case AGG_COUNT:
+			fprintf(f, "count");
+			break;
+		}
+		fprintf(f, "\n");
+	}
+
+	if (internals->slave_count > 0) {
+		fprintf(f, "\tSlaves (%u): [", internals->slave_count);
+		for (i = 0; i < internals->slave_count - 1; i++)
+			fprintf(f, "%u ", internals->slaves[i].port_id);
+
+		fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id);
+	} else {
+		fprintf(f, "\tSlaves: []\n");
+	}
+
+	if (internals->active_slave_count > 0) {
+		fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count);
+		for (i = 0; i < internals->active_slave_count - 1; i++)
+			fprintf(f, "%u ", internals->active_slaves[i]);
+
+		fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]);
+
+	} else {
+		fprintf(f, "\tActive Slaves: []\n");
+	}
+
+	if (internals->user_defined_primary_port)
+		fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
+	if (internals->slave_count > 0)
+		fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
+
+	return 0;
+}
+
 const struct eth_dev_ops default_dev_ops = {
 	.dev_start            = bond_ethdev_start,
 	.dev_stop             = bond_ethdev_stop,
@@ -3355,7 +3455,8 @@ const struct eth_dev_ops default_dev_ops = {
 	.mac_addr_set         = bond_ethdev_mac_address_set,
 	.mac_addr_add         = bond_ethdev_mac_addr_add,
 	.mac_addr_remove      = bond_ethdev_mac_addr_remove,
-	.flow_ops_get         = bond_flow_ops_get
+	.flow_ops_get         = bond_flow_ops_get,
+	.eth_dev_priv_dump    = bond_ethdev_priv_dump
 };
 
 static int
-- 
2.17.1


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

* [PATCH 2/2] net/bonding: support dump LACP info
  2022-12-05  8:10 [PATCH 0/2] support device private dump Chengwen Feng
  2022-12-05  8:10 ` [PATCH 1/2] net/bonding: support private dump ops Chengwen Feng
@ 2022-12-05  8:10 ` Chengwen Feng
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
  2 siblings, 0 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-05  8:10 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patch adds dump lacp info in eth_dev_priv_dump ops.

The extra dump output is to testpmd command
"show bonding lacp info [port]".

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 143 ++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index 80fb2dc462..617625a6d5 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3352,8 +3352,8 @@ bond_mode_name(uint8_t mode)
 	}
 }
 
-static int
-bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+static void
+dump_basic(const struct rte_eth_dev *dev, FILE *f)
 {
 	struct bond_dev_private instant_priv;
 	const struct bond_dev_private *internals = &instant_priv;
@@ -3425,6 +3425,145 @@ bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
 		fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
 	if (internals->slave_count > 0)
 		fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
+}
+
+static void
+dump_lacp_conf(const struct rte_eth_bond_8023ad_conf *conf, FILE *f)
+{
+	fprintf(f, "\tfast period: %u ms\n", conf->fast_periodic_ms);
+	fprintf(f, "\tslow period: %u ms\n", conf->slow_periodic_ms);
+	fprintf(f, "\tshort timeout: %u ms\n", conf->short_timeout_ms);
+	fprintf(f, "\tlong timeout: %u ms\n", conf->long_timeout_ms);
+	fprintf(f, "\taggregate wait timeout: %u ms\n",
+			conf->aggregate_wait_timeout_ms);
+	fprintf(f, "\ttx period: %u ms\n", conf->tx_period_ms);
+	fprintf(f, "\trx marker period: %u ms\n", conf->rx_marker_period_ms);
+	fprintf(f, "\tupdate timeout: %u ms\n", conf->update_timeout_ms);
+	switch (conf->agg_selection) {
+	case AGG_BANDWIDTH:
+		fprintf(f, "\taggregation mode: bandwidth\n");
+		break;
+	case AGG_STABLE:
+		fprintf(f, "\taggregation mode: stable\n");
+		break;
+	case AGG_COUNT:
+		fprintf(f, "\taggregation mode: count\n");
+		break;
+	default:
+		fprintf(f, "\taggregation mode: invalid\n");
+		break;
+	}
+	fprintf(f, "\n");
+}
+
+static void
+dump_lacp_port_param(const struct port_params *params, FILE *f)
+{
+	char buf[RTE_ETHER_ADDR_FMT_SIZE];
+	fprintf(f, "\t\tsystem priority: %u\n", params->system_priority);
+	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
+	fprintf(f, "\t\tsystem mac address: %s\n", buf);
+	fprintf(f, "\t\tport key: %u\n", params->key);
+	fprintf(f, "\t\tport priority: %u\n", params->port_priority);
+	fprintf(f, "\t\tport number: %u\n", params->port_number);
+}
+
+static void
+dump_lacp_slave(const struct rte_eth_bond_8023ad_slave_info *info, FILE *f)
+{
+	char a_state[256] = { 0 };
+	char p_state[256] = { 0 };
+	int a_len = 0;
+	int p_len = 0;
+	uint32_t i;
+
+	static const char * const state[] = {
+		"ACTIVE",
+		"TIMEOUT",
+		"AGGREGATION",
+		"SYNCHRONIZATION",
+		"COLLECTING",
+		"DISTRIBUTING",
+		"DEFAULTED",
+		"EXPIRED"
+	};
+	static const char * const selection[] = {
+		"UNSELECTED",
+		"STANDBY",
+		"SELECTED"
+	};
+
+	for (i = 0; i < RTE_DIM(state); i++) {
+		if ((info->actor_state >> i) & 1)
+			a_len += snprintf(&a_state[a_len],
+						RTE_DIM(a_state) - a_len, "%s ",
+						state[i]);
+
+		if ((info->partner_state >> i) & 1)
+			p_len += snprintf(&p_state[p_len],
+						RTE_DIM(p_state) - p_len, "%s ",
+						state[i]);
+	}
+	fprintf(f, "\tAggregator port id: %u\n", info->agg_port_id);
+	fprintf(f, "\tselection: %s\n", selection[info->selected]);
+	fprintf(f, "\tActor detail info:\n");
+	dump_lacp_port_param(&info->actor, f);
+	fprintf(f, "\t\tport state: %s\n", a_state);
+	fprintf(f, "\tPartner detail info:\n");
+	dump_lacp_port_param(&info->partner, f);
+	fprintf(f, "\t\tport state: %s\n", p_state);
+	fprintf(f, "\n");
+}
+
+static void
+dump_lacp(uint16_t port_id, FILE *f)
+{
+	struct rte_eth_bond_8023ad_slave_info slave_info;
+	struct rte_eth_bond_8023ad_conf port_conf;
+	uint16_t slaves[RTE_MAX_ETHPORTS];
+	int num_active_slaves;
+	int i, ret;
+
+	fprintf(f, "  - Lacp info:\n");
+
+	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
+			RTE_MAX_ETHPORTS);
+	if (num_active_slaves < 0) {
+		fprintf(f, "\tFailed to get active slave list for port %u\n",
+				port_id);
+		return;
+	}
+
+	fprintf(f, "\tIEEE802.3 port: %u\n", port_id);
+	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
+	if (ret) {
+		fprintf(f, "\tGet bonded device %u 8023ad config failed\n",
+			port_id);
+		return;
+	}
+	dump_lacp_conf(&port_conf, f);
+
+	for (i = 0; i < num_active_slaves; i++) {
+		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
+				&slave_info);
+		if (ret) {
+			fprintf(f, "\tGet slave device %u 8023ad info failed\n",
+				slaves[i]);
+			return;
+		}
+		fprintf(f, "\tSlave Port: %u\n", slaves[i]);
+		dump_lacp_slave(&slave_info, f);
+	}
+}
+
+static int
+bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+{
+	const struct bond_dev_private *internals = dev->data->dev_private;
+
+	dump_basic(dev, f);
+	if (internals->mode == BONDING_MODE_8023AD)
+		dump_lacp(dev->data->port_id, f);
 
 	return 0;
 }
-- 
2.17.1


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

* Re: [PATCH 1/2] net/bonding: support private dump ops
  2022-12-05  8:10 ` [PATCH 1/2] net/bonding: support private dump ops Chengwen Feng
@ 2022-12-06  2:01   ` humin (Q)
  2022-12-14  6:24     ` fengchengwen
  0 siblings, 1 reply; 12+ messages in thread
From: humin (Q) @ 2022-12-06  2:01 UTC (permalink / raw)
  To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, chas3

Hi,

在 2022/12/5 16:10, Chengwen Feng 写道:
> This patch implements eth_dev_priv_dump ops which could enhance the
> debug capability.
>
> The dump output is similar to testpmd command
> "show bonding config [port]".
>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
>   drivers/net/bonding/rte_eth_bond_pmd.c | 103 ++++++++++++++++++++++++-
>   1 file changed, 102 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index b9bcebc6cb..80fb2dc462 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -3329,6 +3329,106 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
>   	rte_spinlock_unlock(&internals->lock);
>   }
>   
> +static const char *
> +bond_mode_name(uint8_t mode)
> +{
> +	switch (mode) {
> +	case BONDING_MODE_ROUND_ROBIN:
> +		return "ROUND_ROBIN";
> +	case BONDING_MODE_ACTIVE_BACKUP:
> +		return "ACTIVE_BACKUP";
> +	case BONDING_MODE_BALANCE:
> +		return "BALANCE";
> +	case BONDING_MODE_BROADCAST:
> +		return "BROADCAST";
> +	case BONDING_MODE_8023AD:
> +		return "8023AD";
> +	case BONDING_MODE_TLB:
> +		return "TLB";
> +	case BONDING_MODE_ALB:
> +		return "ALB";
> +	default:
> +		return "Unknown";
> +	}
> +}
> +
> +static int
> +bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
> +{
> +	struct bond_dev_private instant_priv;
> +	const struct bond_dev_private *internals = &instant_priv;
> +	int bonding_mode;
> +	int i;
> +
> +	/* Obtain a instance of dev_private to prevent data from being modified. */
> +	memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private));
> +	bonding_mode = internals->mode;
> +
> +	fprintf(f, "  - Dev basic:\n");
> +	fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(bonding_mode), bonding_mode);
data type of“bonding mode”does not match "mode".
> +
> +	if (bonding_mode == BONDING_MODE_BALANCE ||
> +		bonding_mode == BONDING_MODE_8023AD) {
> +		fprintf(f, "\tBalance Xmit Policy: ");
> +		switch (internals->balance_xmit_policy) {
> +		case BALANCE_XMIT_POLICY_LAYER2:
> +			fprintf(f, "BALANCE_XMIT_POLICY_LAYER2");
> +			break;
> +		case BALANCE_XMIT_POLICY_LAYER23:
> +			fprintf(f, "BALANCE_XMIT_POLICY_LAYER23");
> +			break;
> +		case BALANCE_XMIT_POLICY_LAYER34:
> +			fprintf(f, "BALANCE_XMIT_POLICY_LAYER34");
> +			break;
> +		}
why no "default case" ?
> +		fprintf(f, "\n");
> +	}
> +
> +	if (bonding_mode == BONDING_MODE_8023AD) {
> +		fprintf(f, "\tIEEE802.3AD Aggregator Mode: ");
> +		switch (internals->mode4.agg_selection) {
> +		case AGG_BANDWIDTH:
> +			fprintf(f, "bandwidth");
> +			break;
> +		case AGG_STABLE:
> +			fprintf(f, "stable");
> +			break;
> +		case AGG_COUNT:
> +			fprintf(f, "count");
> +			break;
> +		}
same as above.
> +		fprintf(f, "\n");
> +	}
> +
> +	if (internals->slave_count > 0) {
> +		fprintf(f, "\tSlaves (%u): [", internals->slave_count);
> +		for (i = 0; i < internals->slave_count - 1; i++)
> +			fprintf(f, "%u ", internals->slaves[i].port_id);
> +
> +		fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id);
> +	} else {
> +		fprintf(f, "\tSlaves: []\n");
> +	}
> +
> +	if (internals->active_slave_count > 0) {
> +		fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count);
> +		for (i = 0; i < internals->active_slave_count - 1; i++)
> +			fprintf(f, "%u ", internals->active_slaves[i]);
> +
> +		fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]);
> +
> +	} else {
> +		fprintf(f, "\tActive Slaves: []\n");
> +	}
> +
> +	if (internals->user_defined_primary_port)
> +		fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
> +	if (internals->slave_count > 0)
> +		fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
> +
> +	return 0;
> +}
> +
>   const struct eth_dev_ops default_dev_ops = {
>   	.dev_start            = bond_ethdev_start,
>   	.dev_stop             = bond_ethdev_stop,
> @@ -3355,7 +3455,8 @@ const struct eth_dev_ops default_dev_ops = {
>   	.mac_addr_set         = bond_ethdev_mac_address_set,
>   	.mac_addr_add         = bond_ethdev_mac_addr_add,
>   	.mac_addr_remove      = bond_ethdev_mac_addr_remove,
> -	.flow_ops_get         = bond_flow_ops_get
> +	.flow_ops_get         = bond_flow_ops_get,
> +	.eth_dev_priv_dump    = bond_ethdev_priv_dump
>   };
>   
>   static int

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

* [PATCH v2 0/3] net/bonding: support device private dump
  2022-12-05  8:10 [PATCH 0/2] support device private dump Chengwen Feng
  2022-12-05  8:10 ` [PATCH 1/2] net/bonding: support private dump ops Chengwen Feng
  2022-12-05  8:10 ` [PATCH 2/2] net/bonding: support dump LACP info Chengwen Feng
@ 2022-12-14  6:13 ` Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 1/3] net/bonding: support private dump ops Chengwen Feng
                     ` (3 more replies)
  2 siblings, 4 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-14  6:13 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patchset adds device private dump for bonding PMD, and use 
rte_eth_dev_priv_dump API to implement testpmd show bonding command.

Chengwen Feng (3):
  net/bonding: support private dump ops
  net/bonding: support dump LACP info
  net/bonding: use dump API to impl show bonding cmd

---
v2: 
* address Min Hu's comment
* use rte_eth_dev_priv_dump API to implement testpmd show bonding 
  command.

 .../link_bonding_poll_mode_drv_lib.rst        |  13 +-
 drivers/net/bonding/bonding_testpmd.c         | 281 +-----------------
 drivers/net/bonding/rte_eth_bond_pmd.c        | 244 ++++++++++++++-
 3 files changed, 249 insertions(+), 289 deletions(-)

-- 
2.17.1


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

* [PATCH v2 1/3] net/bonding: support private dump ops
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
@ 2022-12-14  6:13   ` Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 2/3] net/bonding: support dump LACP info Chengwen Feng
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-14  6:13 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patch implements eth_dev_priv_dump ops which could enhance the
debug capability.

The dump output is similar to testpmd command
"show bonding config [port]".

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 105 ++++++++++++++++++++++++-
 1 file changed, 104 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index b9bcebc6cb..a366900ffa 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3329,6 +3329,108 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
 	rte_spinlock_unlock(&internals->lock);
 }
 
+static const char *
+bond_mode_name(uint8_t mode)
+{
+	switch (mode) {
+	case BONDING_MODE_ROUND_ROBIN:
+		return "ROUND_ROBIN";
+	case BONDING_MODE_ACTIVE_BACKUP:
+		return "ACTIVE_BACKUP";
+	case BONDING_MODE_BALANCE:
+		return "BALANCE";
+	case BONDING_MODE_BROADCAST:
+		return "BROADCAST";
+	case BONDING_MODE_8023AD:
+		return "8023AD";
+	case BONDING_MODE_TLB:
+		return "TLB";
+	case BONDING_MODE_ALB:
+		return "ALB";
+	default:
+		return "Unknown";
+	}
+}
+
+static int
+bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+{
+	struct bond_dev_private instant_priv;
+	const struct bond_dev_private *internals = &instant_priv;
+	int mode, i;
+
+	/* Obtain a instance of dev_private to prevent data from being modified. */
+	memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private));
+	mode = internals->mode;
+
+	fprintf(f, "  - Dev basic:\n");
+	fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(mode), mode);
+
+	if (mode == BONDING_MODE_BALANCE || mode == BONDING_MODE_8023AD) {
+		fprintf(f, "\tBalance Xmit Policy: ");
+		switch (internals->balance_xmit_policy) {
+		case BALANCE_XMIT_POLICY_LAYER2:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER2");
+			break;
+		case BALANCE_XMIT_POLICY_LAYER23:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER23");
+			break;
+		case BALANCE_XMIT_POLICY_LAYER34:
+			fprintf(f, "BALANCE_XMIT_POLICY_LAYER34");
+			break;
+		default:
+			fprintf(f, "Unknown");
+		}
+		fprintf(f, "\n");
+	}
+
+	if (mode == BONDING_MODE_8023AD) {
+		fprintf(f, "\tIEEE802.3AD Aggregator Mode: ");
+		switch (internals->mode4.agg_selection) {
+		case AGG_BANDWIDTH:
+			fprintf(f, "bandwidth");
+			break;
+		case AGG_STABLE:
+			fprintf(f, "stable");
+			break;
+		case AGG_COUNT:
+			fprintf(f, "count");
+			break;
+		default:
+			fprintf(f, "unknown");
+		}
+		fprintf(f, "\n");
+	}
+
+	if (internals->slave_count > 0) {
+		fprintf(f, "\tSlaves (%u): [", internals->slave_count);
+		for (i = 0; i < internals->slave_count - 1; i++)
+			fprintf(f, "%u ", internals->slaves[i].port_id);
+
+		fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id);
+	} else {
+		fprintf(f, "\tSlaves: []\n");
+	}
+
+	if (internals->active_slave_count > 0) {
+		fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count);
+		for (i = 0; i < internals->active_slave_count - 1; i++)
+			fprintf(f, "%u ", internals->active_slaves[i]);
+
+		fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]);
+
+	} else {
+		fprintf(f, "\tActive Slaves: []\n");
+	}
+
+	if (internals->user_defined_primary_port)
+		fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
+	if (internals->slave_count > 0)
+		fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
+
+	return 0;
+}
+
 const struct eth_dev_ops default_dev_ops = {
 	.dev_start            = bond_ethdev_start,
 	.dev_stop             = bond_ethdev_stop,
@@ -3355,7 +3457,8 @@ const struct eth_dev_ops default_dev_ops = {
 	.mac_addr_set         = bond_ethdev_mac_address_set,
 	.mac_addr_add         = bond_ethdev_mac_addr_add,
 	.mac_addr_remove      = bond_ethdev_mac_addr_remove,
-	.flow_ops_get         = bond_flow_ops_get
+	.flow_ops_get         = bond_flow_ops_get,
+	.eth_dev_priv_dump    = bond_ethdev_priv_dump
 };
 
 static int
-- 
2.17.1


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

* [PATCH v2 2/3] net/bonding: support dump LACP info
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 1/3] net/bonding: support private dump ops Chengwen Feng
@ 2022-12-14  6:13   ` Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 3/3] net/bonding: use dump API to impl show bonding cmd Chengwen Feng
  2022-12-14  9:55   ` [PATCH v2 0/3] net/bonding: support device private dump humin (Q)
  3 siblings, 0 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-14  6:13 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

This patch adds dump lacp info in eth_dev_priv_dump ops.

The extra dump output is similar to testpmd command
"show bonding lacp info [port]".

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/net/bonding/rte_eth_bond_pmd.c | 143 ++++++++++++++++++++++++-
 1 file changed, 141 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
index a366900ffa..e0364ef015 100644
--- a/drivers/net/bonding/rte_eth_bond_pmd.c
+++ b/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -3352,8 +3352,8 @@ bond_mode_name(uint8_t mode)
 	}
 }
 
-static int
-bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+static void
+dump_basic(const struct rte_eth_dev *dev, FILE *f)
 {
 	struct bond_dev_private instant_priv;
 	const struct bond_dev_private *internals = &instant_priv;
@@ -3427,6 +3427,145 @@ bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
 		fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
 	if (internals->slave_count > 0)
 		fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
+}
+
+static void
+dump_lacp_conf(const struct rte_eth_bond_8023ad_conf *conf, FILE *f)
+{
+	fprintf(f, "\tfast period: %u ms\n", conf->fast_periodic_ms);
+	fprintf(f, "\tslow period: %u ms\n", conf->slow_periodic_ms);
+	fprintf(f, "\tshort timeout: %u ms\n", conf->short_timeout_ms);
+	fprintf(f, "\tlong timeout: %u ms\n", conf->long_timeout_ms);
+	fprintf(f, "\taggregate wait timeout: %u ms\n",
+			conf->aggregate_wait_timeout_ms);
+	fprintf(f, "\ttx period: %u ms\n", conf->tx_period_ms);
+	fprintf(f, "\trx marker period: %u ms\n", conf->rx_marker_period_ms);
+	fprintf(f, "\tupdate timeout: %u ms\n", conf->update_timeout_ms);
+	switch (conf->agg_selection) {
+	case AGG_BANDWIDTH:
+		fprintf(f, "\taggregation mode: bandwidth\n");
+		break;
+	case AGG_STABLE:
+		fprintf(f, "\taggregation mode: stable\n");
+		break;
+	case AGG_COUNT:
+		fprintf(f, "\taggregation mode: count\n");
+		break;
+	default:
+		fprintf(f, "\taggregation mode: invalid\n");
+		break;
+	}
+	fprintf(f, "\n");
+}
+
+static void
+dump_lacp_port_param(const struct port_params *params, FILE *f)
+{
+	char buf[RTE_ETHER_ADDR_FMT_SIZE];
+	fprintf(f, "\t\tsystem priority: %u\n", params->system_priority);
+	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
+	fprintf(f, "\t\tsystem mac address: %s\n", buf);
+	fprintf(f, "\t\tport key: %u\n", params->key);
+	fprintf(f, "\t\tport priority: %u\n", params->port_priority);
+	fprintf(f, "\t\tport number: %u\n", params->port_number);
+}
+
+static void
+dump_lacp_slave(const struct rte_eth_bond_8023ad_slave_info *info, FILE *f)
+{
+	char a_state[256] = { 0 };
+	char p_state[256] = { 0 };
+	int a_len = 0;
+	int p_len = 0;
+	uint32_t i;
+
+	static const char * const state[] = {
+		"ACTIVE",
+		"TIMEOUT",
+		"AGGREGATION",
+		"SYNCHRONIZATION",
+		"COLLECTING",
+		"DISTRIBUTING",
+		"DEFAULTED",
+		"EXPIRED"
+	};
+	static const char * const selection[] = {
+		"UNSELECTED",
+		"STANDBY",
+		"SELECTED"
+	};
+
+	for (i = 0; i < RTE_DIM(state); i++) {
+		if ((info->actor_state >> i) & 1)
+			a_len += snprintf(&a_state[a_len],
+						RTE_DIM(a_state) - a_len, "%s ",
+						state[i]);
+
+		if ((info->partner_state >> i) & 1)
+			p_len += snprintf(&p_state[p_len],
+						RTE_DIM(p_state) - p_len, "%s ",
+						state[i]);
+	}
+	fprintf(f, "\tAggregator port id: %u\n", info->agg_port_id);
+	fprintf(f, "\tselection: %s\n", selection[info->selected]);
+	fprintf(f, "\tActor detail info:\n");
+	dump_lacp_port_param(&info->actor, f);
+	fprintf(f, "\t\tport state: %s\n", a_state);
+	fprintf(f, "\tPartner detail info:\n");
+	dump_lacp_port_param(&info->partner, f);
+	fprintf(f, "\t\tport state: %s\n", p_state);
+	fprintf(f, "\n");
+}
+
+static void
+dump_lacp(uint16_t port_id, FILE *f)
+{
+	struct rte_eth_bond_8023ad_slave_info slave_info;
+	struct rte_eth_bond_8023ad_conf port_conf;
+	uint16_t slaves[RTE_MAX_ETHPORTS];
+	int num_active_slaves;
+	int i, ret;
+
+	fprintf(f, "  - Lacp info:\n");
+
+	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
+			RTE_MAX_ETHPORTS);
+	if (num_active_slaves < 0) {
+		fprintf(f, "\tFailed to get active slave list for port %u\n",
+				port_id);
+		return;
+	}
+
+	fprintf(f, "\tIEEE802.3 port: %u\n", port_id);
+	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
+	if (ret) {
+		fprintf(f, "\tGet bonded device %u 8023ad config failed\n",
+			port_id);
+		return;
+	}
+	dump_lacp_conf(&port_conf, f);
+
+	for (i = 0; i < num_active_slaves; i++) {
+		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
+				&slave_info);
+		if (ret) {
+			fprintf(f, "\tGet slave device %u 8023ad info failed\n",
+				slaves[i]);
+			return;
+		}
+		fprintf(f, "\tSlave Port: %u\n", slaves[i]);
+		dump_lacp_slave(&slave_info, f);
+	}
+}
+
+static int
+bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
+{
+	const struct bond_dev_private *internals = dev->data->dev_private;
+
+	dump_basic(dev, f);
+	if (internals->mode == BONDING_MODE_8023AD)
+		dump_lacp(dev->data->port_id, f);
 
 	return 0;
 }
-- 
2.17.1


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

* [PATCH v2 3/3] net/bonding: use dump API to impl show bonding cmd
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 1/3] net/bonding: support private dump ops Chengwen Feng
  2022-12-14  6:13   ` [PATCH v2 2/3] net/bonding: support dump LACP info Chengwen Feng
@ 2022-12-14  6:13   ` Chengwen Feng
  2022-12-14  9:55   ` [PATCH v2 0/3] net/bonding: support device private dump humin (Q)
  3 siblings, 0 replies; 12+ messages in thread
From: Chengwen Feng @ 2022-12-14  6:13 UTC (permalink / raw)
  To: thomas, ferruh.yigit; +Cc: dev, chas3, humin29

The bonding PMD's eth_dev_priv_dump ops contain the following testpmd
commands output:
"show bonding config [port]" and "show bonding lacp info [port]".

To reduce duplicate code maintenance, this patch uses
rte_eth_dev_priv_dump to implement the command
"show bonding config [port]", and remove the command
"show bonding lacp info [port]".

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 .../link_bonding_poll_mode_drv_lib.rst        |  13 +-
 drivers/net/bonding/bonding_testpmd.c         | 281 +-----------------
 2 files changed, 6 insertions(+), 288 deletions(-)

diff --git a/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst b/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst
index 9510368103..21efa4d5bc 100644
--- a/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst
+++ b/doc/guides/prog_guide/link_bonding_poll_mode_drv_lib.rst
@@ -621,7 +621,8 @@ Enable one of the specific aggregators mode when in mode 4 (link-aggregation-802
 show bonding config
 ~~~~~~~~~~~~~~~~~~~
 
-Show the current configuration of a Link Bonding device::
+Show the current configuration of a Link Bonding device, it also show link-aggregation-802.3ad
+information if the Link mode is mode 4::
 
    testpmd> show bonding config (port id)
 
@@ -630,15 +631,9 @@ to show the configuration a Link Bonding device (port 9) with 3 slave devices (1
 in balance mode with a transmission policy of layer 2+3::
 
    testpmd> show bonding config 9
-        Bonding mode: 2
+     - Dev basic:
+        Bonding mode: BALANCE(2)
         Balance Xmit Policy: BALANCE_XMIT_POLICY_LAYER23
         Slaves (3): [1 3 4]
         Active Slaves (3): [1 3 4]
         Primary: [3]
-
-show bonding lacp info
-~~~~~~~~~~~~~~~~~~~~~~
-
-Show information about the Link Bonding device in mode 4 (link-aggregation-802.3ad)::
-
-   testpmd> show bonding lacp info (port_id)
diff --git a/drivers/net/bonding/bonding_testpmd.c b/drivers/net/bonding/bonding_testpmd.c
index 9529e16fb6..b3c12cada0 100644
--- a/drivers/net/bonding/bonding_testpmd.c
+++ b/drivers/net/bonding/bonding_testpmd.c
@@ -222,185 +222,6 @@ static cmdline_parse_inst_t cmd_set_balance_xmit_policy = {
 	}
 };
 
-/* *** SHOW IEEE802.3 BONDING INFORMATION *** */
-struct cmd_show_bonding_lacp_info_result {
-	cmdline_fixed_string_t show;
-	cmdline_fixed_string_t bonding;
-	cmdline_fixed_string_t lacp;
-	cmdline_fixed_string_t info;
-	portid_t port_id;
-};
-
-static void port_param_show(struct port_params *params)
-{
-	char buf[RTE_ETHER_ADDR_FMT_SIZE];
-
-	printf("\t\tsystem priority: %u\n", params->system_priority);
-	rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, &params->system);
-	printf("\t\tsystem mac address: %s\n", buf);
-	printf("\t\tport key: %u\n", params->key);
-	printf("\t\tport priority: %u\n", params->port_priority);
-	printf("\t\tport number: %u\n", params->port_number);
-}
-
-static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info)
-{
-	char a_state[256] = { 0 };
-	char p_state[256] = { 0 };
-	int a_len = 0;
-	int p_len = 0;
-	uint32_t i;
-
-	static const char * const state[] = {
-		"ACTIVE",
-		"TIMEOUT",
-		"AGGREGATION",
-		"SYNCHRONIZATION",
-		"COLLECTING",
-		"DISTRIBUTING",
-		"DEFAULTED",
-		"EXPIRED"
-	};
-	static const char * const selection[] = {
-		"UNSELECTED",
-		"STANDBY",
-		"SELECTED"
-	};
-
-	for (i = 0; i < RTE_DIM(state); i++) {
-		if ((info->actor_state >> i) & 1)
-			a_len += snprintf(&a_state[a_len],
-						RTE_DIM(a_state) - a_len, "%s ",
-						state[i]);
-
-		if ((info->partner_state >> i) & 1)
-			p_len += snprintf(&p_state[p_len],
-						RTE_DIM(p_state) - p_len, "%s ",
-						state[i]);
-	}
-	printf("\tAggregator port id: %u\n", info->agg_port_id);
-	printf("\tselection: %s\n", selection[info->selected]);
-	printf("\tActor detail info:\n");
-	port_param_show(&info->actor);
-	printf("\t\tport state: %s\n", a_state);
-	printf("\tPartner detail info:\n");
-	port_param_show(&info->partner);
-	printf("\t\tport state: %s\n", p_state);
-	printf("\n");
-}
-
-static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf)
-{
-	printf("\tfast period: %u ms\n", conf->fast_periodic_ms);
-	printf("\tslow period: %u ms\n", conf->slow_periodic_ms);
-	printf("\tshort timeout: %u ms\n", conf->short_timeout_ms);
-	printf("\tlong timeout: %u ms\n", conf->long_timeout_ms);
-	printf("\taggregate wait timeout: %u ms\n",
-			conf->aggregate_wait_timeout_ms);
-	printf("\ttx period: %u ms\n", conf->tx_period_ms);
-	printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms);
-	printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms);
-	switch (conf->agg_selection) {
-	case AGG_BANDWIDTH:
-		printf("\taggregation mode: bandwidth\n");
-		break;
-	case AGG_STABLE:
-		printf("\taggregation mode: stable\n");
-		break;
-	case AGG_COUNT:
-		printf("\taggregation mode: count\n");
-		break;
-	default:
-		printf("\taggregation mode: invalid\n");
-		break;
-	}
-
-	printf("\n");
-}
-
-static void cmd_show_bonding_lacp_info_parsed(void *parsed_result,
-	__rte_unused struct cmdline *cl, __rte_unused void *data)
-{
-	struct cmd_show_bonding_lacp_info_result *res = parsed_result;
-	struct rte_eth_bond_8023ad_slave_info slave_info;
-	struct rte_eth_bond_8023ad_conf port_conf;
-	portid_t slaves[RTE_MAX_ETHPORTS];
-	portid_t port_id = res->port_id;
-	int num_active_slaves;
-	int bonding_mode;
-	int i;
-	int ret;
-
-	bonding_mode = rte_eth_bond_mode_get(port_id);
-	if (bonding_mode != BONDING_MODE_8023AD) {
-		fprintf(stderr, "\tBonding mode is not mode 4\n");
-		return;
-	}
-
-	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
-			RTE_MAX_ETHPORTS);
-	if (num_active_slaves < 0) {
-		fprintf(stderr, "\tFailed to get active slave list for port = %u\n",
-				port_id);
-		return;
-	}
-	if (num_active_slaves == 0)
-		fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n",
-			port_id);
-
-	printf("\tIEEE802.3 port: %u\n", port_id);
-	ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf);
-	if (ret) {
-		fprintf(stderr, "\tGet bonded device %u info failed\n",
-			port_id);
-		return;
-	}
-	lacp_conf_show(&port_conf);
-
-	for (i = 0; i < num_active_slaves; i++) {
-		ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i],
-				&slave_info);
-		if (ret) {
-			fprintf(stderr, "\tGet slave device %u info failed\n",
-				slaves[i]);
-			return;
-		}
-		printf("\tSlave Port: %u\n", slaves[i]);
-		lacp_slave_info_show(&slave_info);
-	}
-}
-
-static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show =
-	TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
-		show, "show");
-static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding =
-	TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
-		bonding, "bonding");
-static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp =
-	TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
-		bonding, "lacp");
-static cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info =
-	TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
-		info, "info");
-static cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result,
-		port_id, RTE_UINT16);
-
-static cmdline_parse_inst_t cmd_show_bonding_lacp_info = {
-	.f = cmd_show_bonding_lacp_info_parsed,
-	.help_str = "show bonding lacp info <port_id> : "
-		"Show bonding IEEE802.3 information for port_id",
-	.data = NULL,
-	.tokens = {
-		(void *)&cmd_show_bonding_lacp_info_show,
-		(void *)&cmd_show_bonding_lacp_info_bonding,
-		(void *)&cmd_show_bonding_lacp_info_lacp,
-		(void *)&cmd_show_bonding_lacp_info_info,
-		(void *)&cmd_show_bonding_lacp_info_port_id,
-		NULL
-	}
-};
-
 /* *** SHOW NIC BONDING CONFIGURATION *** */
 struct cmd_show_bonding_config_result {
 	cmdline_fixed_string_t show;
@@ -413,110 +234,17 @@ static void cmd_show_bonding_config_parsed(void *parsed_result,
 	__rte_unused struct cmdline *cl, __rte_unused void *data)
 {
 	struct cmd_show_bonding_config_result *res = parsed_result;
-	int bonding_mode, agg_mode;
-	portid_t slaves[RTE_MAX_ETHPORTS];
-	int num_slaves, num_active_slaves;
-	int primary_id;
-	int i;
 	portid_t port_id = res->port_id;
+	int bonding_mode;
 
-	/* Display the bonding mode.*/
 	bonding_mode = rte_eth_bond_mode_get(port_id);
 	if (bonding_mode < 0) {
 		fprintf(stderr, "\tFailed to get bonding mode for port = %d\n",
 			port_id);
 		return;
 	}
-	printf("\tBonding mode: %d\n", bonding_mode);
-
-	if (bonding_mode == BONDING_MODE_BALANCE ||
-		bonding_mode == BONDING_MODE_8023AD) {
-		int balance_xmit_policy;
-
-		balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id);
-		if (balance_xmit_policy < 0) {
-			fprintf(stderr,
-				"\tFailed to get balance xmit policy for port = %d\n",
-				port_id);
-			return;
-		}
-		printf("\tBalance Xmit Policy: ");
-
-		switch (balance_xmit_policy) {
-		case BALANCE_XMIT_POLICY_LAYER2:
-			printf("BALANCE_XMIT_POLICY_LAYER2");
-			break;
-		case BALANCE_XMIT_POLICY_LAYER23:
-			printf("BALANCE_XMIT_POLICY_LAYER23");
-			break;
-		case BALANCE_XMIT_POLICY_LAYER34:
-			printf("BALANCE_XMIT_POLICY_LAYER34");
-			break;
-		}
-		printf("\n");
-	}
-
-	if (bonding_mode == BONDING_MODE_8023AD) {
-		agg_mode = rte_eth_bond_8023ad_agg_selection_get(port_id);
-		printf("\tIEEE802.3AD Aggregator Mode: ");
-		switch (agg_mode) {
-		case AGG_BANDWIDTH:
-			printf("bandwidth");
-			break;
-		case AGG_STABLE:
-			printf("stable");
-			break;
-		case AGG_COUNT:
-			printf("count");
-			break;
-		}
-		printf("\n");
-	}
-
-	num_slaves = rte_eth_bond_slaves_get(port_id, slaves, RTE_MAX_ETHPORTS);
-
-	if (num_slaves < 0) {
-		fprintf(stderr, "\tFailed to get slave list for port = %d\n",
-			port_id);
-		return;
-	}
-	if (num_slaves > 0) {
-		printf("\tSlaves (%d): [", num_slaves);
-		for (i = 0; i < num_slaves - 1; i++)
-			printf("%d ", slaves[i]);
 
-		printf("%d]\n", slaves[num_slaves - 1]);
-	} else {
-		printf("\tSlaves: []\n");
-	}
-
-	num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves,
-			RTE_MAX_ETHPORTS);
-
-	if (num_active_slaves < 0) {
-		fprintf(stderr,
-			"\tFailed to get active slave list for port = %d\n",
-			port_id);
-		return;
-	}
-	if (num_active_slaves > 0) {
-		printf("\tActive Slaves (%d): [", num_active_slaves);
-		for (i = 0; i < num_active_slaves - 1; i++)
-			printf("%d ", slaves[i]);
-
-		printf("%d]\n", slaves[num_active_slaves - 1]);
-
-	} else {
-		printf("\tActive Slaves: []\n");
-	}
-
-	primary_id = rte_eth_bond_primary_get(port_id);
-	if (primary_id < 0) {
-		fprintf(stderr, "\tFailed to get primary slave for port = %d\n",
-			port_id);
-		return;
-	}
-	printf("\tPrimary: [%d]\n", primary_id);
+	(void)rte_eth_dev_priv_dump(port_id, stdout);
 }
 
 static cmdline_parse_token_string_t cmd_showbonding_config_show =
@@ -976,11 +704,6 @@ static struct testpmd_driver_commands bonding_cmds = {
 		"show bonding config (port_id)\n"
 		"	Show the bonding config for port_id.\n",
 	},
-	{
-		&cmd_show_bonding_lacp_info,
-		"show bonding lacp info (port_id)\n"
-		"	Show the bonding lacp information for port_id.\n",
-	},
 	{
 		&cmd_set_bonding_primary,
 		"set bonding primary (slave_id) (port_id)\n"
-- 
2.17.1


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

* Re: [PATCH 1/2] net/bonding: support private dump ops
  2022-12-06  2:01   ` humin (Q)
@ 2022-12-14  6:24     ` fengchengwen
  0 siblings, 0 replies; 12+ messages in thread
From: fengchengwen @ 2022-12-14  6:24 UTC (permalink / raw)
  To: humin (Q), thomas, ferruh.yigit; +Cc: dev, chas3

Hi Min,

  V2 has been solved. Please review. Thanks.

On 2022/12/6 10:01, humin (Q) wrote:
> Hi,
> 
> 在 2022/12/5 16:10, Chengwen Feng 写道:
>> This patch implements eth_dev_priv_dump ops which could enhance the
>> debug capability.
>>
>> The dump output is similar to testpmd command
>> "show bonding config [port]".
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>>   drivers/net/bonding/rte_eth_bond_pmd.c | 103 ++++++++++++++++++++++++-
>>   1 file changed, 102 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
>> index b9bcebc6cb..80fb2dc462 100644
>> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
>> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
>> @@ -3329,6 +3329,106 @@ bond_ethdev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index)
>>       rte_spinlock_unlock(&internals->lock);
>>   }
>>   +static const char *
>> +bond_mode_name(uint8_t mode)
>> +{
>> +    switch (mode) {
>> +    case BONDING_MODE_ROUND_ROBIN:
>> +        return "ROUND_ROBIN";
>> +    case BONDING_MODE_ACTIVE_BACKUP:
>> +        return "ACTIVE_BACKUP";
>> +    case BONDING_MODE_BALANCE:
>> +        return "BALANCE";
>> +    case BONDING_MODE_BROADCAST:
>> +        return "BROADCAST";
>> +    case BONDING_MODE_8023AD:
>> +        return "8023AD";
>> +    case BONDING_MODE_TLB:
>> +        return "TLB";
>> +    case BONDING_MODE_ALB:
>> +        return "ALB";
>> +    default:
>> +        return "Unknown";
>> +    }
>> +}
>> +
>> +static int
>> +bond_ethdev_priv_dump(struct rte_eth_dev *dev, FILE *f)
>> +{
>> +    struct bond_dev_private instant_priv;
>> +    const struct bond_dev_private *internals = &instant_priv;
>> +    int bonding_mode;
>> +    int i;
>> +
>> +    /* Obtain a instance of dev_private to prevent data from being modified. */
>> +    memcpy(&instant_priv, dev->data->dev_private, sizeof(struct bond_dev_private));
>> +    bonding_mode = internals->mode;
>> +
>> +    fprintf(f, "  - Dev basic:\n");
>> +    fprintf(f, "\tBonding mode: %s(%d)\n", bond_mode_name(bonding_mode), bonding_mode);
> data type of“bonding mode”does not match "mode".
>> +
>> +    if (bonding_mode == BONDING_MODE_BALANCE ||
>> +        bonding_mode == BONDING_MODE_8023AD) {
>> +        fprintf(f, "\tBalance Xmit Policy: ");
>> +        switch (internals->balance_xmit_policy) {
>> +        case BALANCE_XMIT_POLICY_LAYER2:
>> +            fprintf(f, "BALANCE_XMIT_POLICY_LAYER2");
>> +            break;
>> +        case BALANCE_XMIT_POLICY_LAYER23:
>> +            fprintf(f, "BALANCE_XMIT_POLICY_LAYER23");
>> +            break;
>> +        case BALANCE_XMIT_POLICY_LAYER34:
>> +            fprintf(f, "BALANCE_XMIT_POLICY_LAYER34");
>> +            break;
>> +        }
> why no "default case" ?
>> +        fprintf(f, "\n");
>> +    }
>> +
>> +    if (bonding_mode == BONDING_MODE_8023AD) {
>> +        fprintf(f, "\tIEEE802.3AD Aggregator Mode: ");
>> +        switch (internals->mode4.agg_selection) {
>> +        case AGG_BANDWIDTH:
>> +            fprintf(f, "bandwidth");
>> +            break;
>> +        case AGG_STABLE:
>> +            fprintf(f, "stable");
>> +            break;
>> +        case AGG_COUNT:
>> +            fprintf(f, "count");
>> +            break;
>> +        }
> same as above.
>> +        fprintf(f, "\n");
>> +    }
>> +
>> +    if (internals->slave_count > 0) {
>> +        fprintf(f, "\tSlaves (%u): [", internals->slave_count);
>> +        for (i = 0; i < internals->slave_count - 1; i++)
>> +            fprintf(f, "%u ", internals->slaves[i].port_id);
>> +
>> +        fprintf(f, "%u]\n", internals->slaves[internals->slave_count - 1].port_id);
>> +    } else {
>> +        fprintf(f, "\tSlaves: []\n");
>> +    }
>> +
>> +    if (internals->active_slave_count > 0) {
>> +        fprintf(f, "\tActive Slaves (%u): [", internals->active_slave_count);
>> +        for (i = 0; i < internals->active_slave_count - 1; i++)
>> +            fprintf(f, "%u ", internals->active_slaves[i]);
>> +
>> +        fprintf(f, "%u]\n", internals->active_slaves[internals->active_slave_count - 1]);
>> +
>> +    } else {
>> +        fprintf(f, "\tActive Slaves: []\n");
>> +    }
>> +
>> +    if (internals->user_defined_primary_port)
>> +        fprintf(f, "\tUser Defined Primary: [%u]\n", internals->primary_port);
>> +    if (internals->slave_count > 0)
>> +        fprintf(f, "\tCurrent Primary: [%u]\n", internals->current_primary_port);
>> +
>> +    return 0;
>> +}
>> +
>>   const struct eth_dev_ops default_dev_ops = {
>>       .dev_start            = bond_ethdev_start,
>>       .dev_stop             = bond_ethdev_stop,
>> @@ -3355,7 +3455,8 @@ const struct eth_dev_ops default_dev_ops = {
>>       .mac_addr_set         = bond_ethdev_mac_address_set,
>>       .mac_addr_add         = bond_ethdev_mac_addr_add,
>>       .mac_addr_remove      = bond_ethdev_mac_addr_remove,
>> -    .flow_ops_get         = bond_flow_ops_get
>> +    .flow_ops_get         = bond_flow_ops_get,
>> +    .eth_dev_priv_dump    = bond_ethdev_priv_dump
>>   };
>>     static int
> .

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

* Re: [PATCH v2 0/3] net/bonding: support device private dump
  2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
                     ` (2 preceding siblings ...)
  2022-12-14  6:13   ` [PATCH v2 3/3] net/bonding: use dump API to impl show bonding cmd Chengwen Feng
@ 2022-12-14  9:55   ` humin (Q)
  2022-12-15 10:56     ` lihuisong (C)
  3 siblings, 1 reply; 12+ messages in thread
From: humin (Q) @ 2022-12-14  9:55 UTC (permalink / raw)
  To: Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, chas3

Acked-by:Min Hu (Connor) <humin29@huawei.com>

在 2022/12/14 14:13, Chengwen Feng 写道:
> This patchset adds device private dump for bonding PMD, and use
> rte_eth_dev_priv_dump API to implement testpmd show bonding command.
>
> Chengwen Feng (3):
>    net/bonding: support private dump ops
>    net/bonding: support dump LACP info
>    net/bonding: use dump API to impl show bonding cmd
>
> ---
> v2:
> * address Min Hu's comment
> * use rte_eth_dev_priv_dump API to implement testpmd show bonding
>    command.
>
>   .../link_bonding_poll_mode_drv_lib.rst        |  13 +-
>   drivers/net/bonding/bonding_testpmd.c         | 281 +-----------------
>   drivers/net/bonding/rte_eth_bond_pmd.c        | 244 ++++++++++++++-
>   3 files changed, 249 insertions(+), 289 deletions(-)
>

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

* Re: [PATCH v2 0/3] net/bonding: support device private dump
  2022-12-14  9:55   ` [PATCH v2 0/3] net/bonding: support device private dump humin (Q)
@ 2022-12-15 10:56     ` lihuisong (C)
  2023-01-16 12:34       ` Ferruh Yigit
  0 siblings, 1 reply; 12+ messages in thread
From: lihuisong (C) @ 2022-12-15 10:56 UTC (permalink / raw)
  To: humin (Q), Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, chas3


在 2022/12/14 17:55, humin (Q) 写道:
> Acked-by:Min Hu (Connor) <humin29@huawei.com>
Indeed, it is better to move them to bonding PMD. lgtm
Series-acked-by: Huisong Li <lihuisong@huawei.com>
>
> 在 2022/12/14 14:13, Chengwen Feng 写道:
>> This patchset adds device private dump for bonding PMD, and use
>> rte_eth_dev_priv_dump API to implement testpmd show bonding command.
>>
>> Chengwen Feng (3):
>>    net/bonding: support private dump ops
>>    net/bonding: support dump LACP info
>>    net/bonding: use dump API to impl show bonding cmd
>>
>> ---
>> v2:
>> * address Min Hu's comment
>> * use rte_eth_dev_priv_dump API to implement testpmd show bonding
>>    command.
>>
>>   .../link_bonding_poll_mode_drv_lib.rst        |  13 +-
>>   drivers/net/bonding/bonding_testpmd.c         | 281 +-----------------
>>   drivers/net/bonding/rte_eth_bond_pmd.c        | 244 ++++++++++++++-
>>   3 files changed, 249 insertions(+), 289 deletions(-)
>>
>
> .

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

* Re: [PATCH v2 0/3] net/bonding: support device private dump
  2022-12-15 10:56     ` lihuisong (C)
@ 2023-01-16 12:34       ` Ferruh Yigit
  0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2023-01-16 12:34 UTC (permalink / raw)
  To: lihuisong (C), humin (Q), Chengwen Feng, thomas, ferruh.yigit; +Cc: dev, chas3

On 12/15/2022 10:56 AM, lihuisong (C) wrote:

> 
> 在 2022/12/14 17:55, humin (Q) 写道:

>>
>> 在 2022/12/14 14:13, Chengwen Feng 写道:
>>> This patchset adds device private dump for bonding PMD, and use
>>> rte_eth_dev_priv_dump API to implement testpmd show bonding command.
>>>
>>> Chengwen Feng (3):
>>>    net/bonding: support private dump ops
>>>    net/bonding: support dump LACP info
>>>    net/bonding: use dump API to impl show bonding cmd
>>>
>>> ---
>>> v2:
>>> * address Min Hu's comment
>>> * use rte_eth_dev_priv_dump API to implement testpmd show bonding
>>>    command.
>>>
>>>   .../link_bonding_poll_mode_drv_lib.rst        |  13 +-
>>>   drivers/net/bonding/bonding_testpmd.c         | 281 +-----------------
>>>   drivers/net/bonding/rte_eth_bond_pmd.c        | 244 ++++++++++++++-
>>>   3 files changed, 249 insertions(+), 289 deletions(-)
>>>
>> Acked-by:Min Hu (Connor) <humin29@huawei.com>
>
> Indeed, it is better to move them to bonding PMD. lgtm
> Series-acked-by: Huisong Li <lihuisong@huawei.com>

+1 to move code to bonding PMD & merge LACP info withing show bonding
config command and remove the redundant one from bonding testpmd,

For series,
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>


Series applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2023-01-16 12:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05  8:10 [PATCH 0/2] support device private dump Chengwen Feng
2022-12-05  8:10 ` [PATCH 1/2] net/bonding: support private dump ops Chengwen Feng
2022-12-06  2:01   ` humin (Q)
2022-12-14  6:24     ` fengchengwen
2022-12-05  8:10 ` [PATCH 2/2] net/bonding: support dump LACP info Chengwen Feng
2022-12-14  6:13 ` [PATCH v2 0/3] net/bonding: support device private dump Chengwen Feng
2022-12-14  6:13   ` [PATCH v2 1/3] net/bonding: support private dump ops Chengwen Feng
2022-12-14  6:13   ` [PATCH v2 2/3] net/bonding: support dump LACP info Chengwen Feng
2022-12-14  6:13   ` [PATCH v2 3/3] net/bonding: use dump API to impl show bonding cmd Chengwen Feng
2022-12-14  9:55   ` [PATCH v2 0/3] net/bonding: support device private dump humin (Q)
2022-12-15 10:56     ` lihuisong (C)
2023-01-16 12:34       ` Ferruh Yigit

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