From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: "Min Hu (Connor)" <humin29@huawei.com>,
Yisen Zhuang <yisen.zhuang@huawei.com>,
Lijun Ou <oulijun@huawei.com>
Subject: [PATCH 9/9] net/hns3: dump flow control info
Date: Fri, 11 Feb 2022 12:49:30 +0800 [thread overview]
Message-ID: <20220211044930.2449-10-humin29@huawei.com> (raw)
In-Reply-To: <20220211044930.2449-1-humin29@huawei.com>
This patch dumps flow control info such as flow control mode
for debug.
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
drivers/net/hns3/hns3_ethdev.c | 2 +-
drivers/net/hns3/hns3_ethdev.h | 2 +
drivers/net/hns3/hns3_ethdev_dump.c | 103 ++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
index bb1ea95ed4..4e089e682f 100644
--- a/drivers/net/hns3/hns3_ethdev.c
+++ b/drivers/net/hns3/hns3_ethdev.c
@@ -5350,7 +5350,7 @@ hns3_get_current_fc_mode(struct rte_eth_dev *dev)
return hns3_get_autoneg_fc_mode(hw);
}
-static int
+int
hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
{
struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private);
diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h
index 551392ca6d..9a0fa09b57 100644
--- a/drivers/net/hns3/hns3_ethdev.h
+++ b/drivers/net/hns3/hns3_ethdev.h
@@ -1030,6 +1030,8 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr)
return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) & mask;
}
+int
+hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf);
uint32_t hns3_get_speed_capa(struct hns3_hw *hw);
int hns3_buffer_alloc(struct hns3_hw *hw);
diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c
index 675c7efed4..e3ca3d58cc 100644
--- a/drivers/net/hns3/hns3_ethdev_dump.c
+++ b/drivers/net/hns3/hns3_ethdev_dump.c
@@ -791,6 +791,108 @@ get_tm_conf_info(FILE *file, struct rte_eth_dev *dev)
get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues);
}
+static void
+hns3_fc_mode_to_rxtx_pause(enum hns3_fc_mode fc_mode, bool *rx_pause,
+ bool *tx_pause)
+{
+ switch (fc_mode) {
+ case HNS3_FC_NONE:
+ *tx_pause = false;
+ *rx_pause = false;
+ break;
+ case HNS3_FC_RX_PAUSE:
+ *rx_pause = true;
+ *tx_pause = false;
+ break;
+ case HNS3_FC_TX_PAUSE:
+ *rx_pause = false;
+ *tx_pause = true;
+ break;
+ case HNS3_FC_FULL:
+ *rx_pause = true;
+ *tx_pause = true;
+ break;
+ default:
+ *rx_pause = false;
+ *tx_pause = false;
+ break;
+ }
+}
+
+static bool
+is_link_fc_mode(struct hns3_adapter *hns)
+{
+ struct hns3_hw *hw = &hns->hw;
+ struct hns3_pf *pf = &hns->pf;
+
+ if (hw->current_fc_status == HNS3_FC_STATUS_PFC)
+ return false;
+
+ if (hw->num_tc > 1 && !pf->support_multi_tc_pause)
+ return false;
+
+ return true;
+}
+
+static void
+get_link_fc_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+ struct rte_eth_fc_conf fc_conf;
+ bool rx_pause1;
+ bool tx_pause1;
+ bool rx_pause2;
+ bool tx_pause2;
+ int ret;
+
+ if (!is_link_fc_mode(hns))
+ return;
+
+ ret = hns3_flow_ctrl_get(dev, &fc_conf);
+ if (ret) {
+ fprintf(file, "get device flow control info fail!\n");
+ return;
+ }
+
+ hns3_fc_mode_to_rxtx_pause(hw->requested_fc_mode,
+ &rx_pause1, &tx_pause1);
+ hns3_fc_mode_to_rxtx_pause((enum hns3_fc_mode)fc_conf.mode,
+ &rx_pause2, &tx_pause2);
+
+ fprintf(file,
+ "\t -- link_fc_info:\n"
+ "\t Requested fc:\n"
+ "\t Rx: %s\n"
+ "\t Tx: %s\n"
+ "\t Current fc:\n"
+ "\t Rx: %s\n"
+ "\t Tx: %s\n"
+ "\t Autonegotiate: %s\n"
+ "\t Pause time: 0x%x\n",
+ rx_pause1 ? "On" : "Off", tx_pause1 ? "On" : "Off",
+ rx_pause2 ? "On" : "Off", tx_pause2 ? "On" : "Off",
+ fc_conf.autoneg == RTE_ETH_LINK_AUTONEG ? "On" : "Off",
+ fc_conf.pause_time);
+}
+
+static void
+get_flow_ctrl_info(FILE *file, struct rte_eth_dev *dev)
+{
+ struct hns3_adapter *hns = dev->data->dev_private;
+ struct hns3_hw *hw = &hns->hw;
+
+ fprintf(file, " - Flow Ctrl Info:\n");
+ fprintf(file,
+ "\t -- fc_common_info:\n"
+ "\t current_fc_status=%u\n"
+ "\t requested_fc_mode=%u\n",
+ hw->current_fc_status,
+ hw->requested_fc_mode);
+
+ get_link_fc_info(file, dev);
+}
+
int
hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
{
@@ -809,6 +911,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file)
get_vlan_config_info(file, hw);
get_fdir_basic_info(file, &hns->pf);
get_tm_conf_info(file, dev);
+ get_flow_ctrl_info(file, dev);
return 0;
}
--
2.33.0
next prev parent reply other threads:[~2022-02-11 4:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-11 4:49 [PATCH 0/9] dump device info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH v4 1/9] ethdev: introduce dump API Min Hu (Connor)
2022-02-11 10:41 ` Ferruh Yigit
2022-02-11 4:49 ` [PATCH 2/9] net/hns3: dump device basic info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 3/9] net/hns3: dump device feature capability Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 4/9] net/hns3: dump device MAC info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 5/9] net/hns3: dump queue info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 6/9] net/hns3: dump VLAN configuration info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 7/9] net/hns3: dump flow director basic info Min Hu (Connor)
2022-02-11 4:49 ` [PATCH 8/9] net/hns3: dump TM configuration info Min Hu (Connor)
2022-02-11 4:49 ` Min Hu (Connor) [this message]
2022-02-11 18:04 ` [PATCH 0/9] dump device info 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=20220211044930.2449-10-humin29@huawei.com \
--to=humin29@huawei.com \
--cc=dev@dpdk.org \
--cc=oulijun@huawei.com \
--cc=yisen.zhuang@huawei.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).