提交 0d42e026 编写于 作者: M moyufeng 提交者: Xie XiuQi

net: hns3: Modify iteration 11 reviewed code

driver inclusion
category: bugfix
bugzilla: NA
CVE: NA

Modify iteration 11 reviewed code.
Signed-off-by: Nmoyufeng <moyufeng@huawei.com>
Reviewed-by: Nlipeng <lipeng321@huawei.com>
Reviewed-by: NHanjun Guo <guohanjun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7972d66b
...@@ -90,6 +90,11 @@ struct hnae3_queue { ...@@ -90,6 +90,11 @@ struct hnae3_queue {
u16 rx_desc_num;/* total number of rx desc */ u16 rx_desc_num;/* total number of rx desc */
}; };
struct hns3_mac_stats {
u64 tx_pause_cnt;
u64 rx_pause_cnt;
};
/*hnae3 loop mode*/ /*hnae3 loop mode*/
enum hnae3_loop { enum hnae3_loop {
HNAE3_LOOP_APP, HNAE3_LOOP_APP,
...@@ -287,6 +292,8 @@ struct hnae3_ae_dev { ...@@ -287,6 +292,8 @@ struct hnae3_ae_dev {
* Remove multicast address from mac table * Remove multicast address from mac table
* update_stats() * update_stats()
* Update Old network device statistics * Update Old network device statistics
* get_mac_stats()
* get mac pause statistics including tx_cnt and rx_cnt
* get_ethtool_stats() * get_ethtool_stats()
* Get ethtool network device statistics * Get ethtool network device statistics
* get_strings() * get_strings()
...@@ -411,8 +418,8 @@ struct hnae3_ae_ops { ...@@ -411,8 +418,8 @@ struct hnae3_ae_ops {
void (*update_stats)(struct hnae3_handle *handle, void (*update_stats)(struct hnae3_handle *handle,
struct net_device_stats *net_stats); struct net_device_stats *net_stats);
void (*get_stats)(struct hnae3_handle *handle, u64 *data); void (*get_stats)(struct hnae3_handle *handle, u64 *data);
void (*get_mac_pause_stats)(struct hnae3_handle *handle, u64 *tx_cnt, void (*get_mac_stats)(struct hnae3_handle *handle,
u64 *rx_cnt); struct hns3_mac_stats *mac_stats);
void (*get_strings)(struct hnae3_handle *handle, void (*get_strings)(struct hnae3_handle *handle,
u32 stringset, u8 *data); u32 stringset, u8 *data);
int (*get_sset_count)(struct hnae3_handle *handle, int stringset); int (*get_sset_count)(struct hnae3_handle *handle, int stringset);
......
...@@ -1773,15 +1773,15 @@ bool hns3_get_tx_timeo_queue_info(struct net_device *ndev) ...@@ -1773,15 +1773,15 @@ bool hns3_get_tx_timeo_queue_info(struct net_device *ndev)
tx_ring->stats.seg_pkt_cnt, tx_ring->stats.tx_err_cnt, tx_ring->stats.seg_pkt_cnt, tx_ring->stats.tx_err_cnt,
tx_ring->stats.restart_queue, tx_ring->stats.tx_busy); tx_ring->stats.restart_queue, tx_ring->stats.tx_busy);
if (h->ae_algo->ops->update_stats && /* When mac received many pause frames continuous, it's unable to send
h->ae_algo->ops->get_mac_pause_stats) { * packets, which may cause tx timeout
u64 tx_pause_cnt, rx_pause_cnt; */
if (h->ae_algo->ops->get_mac_stats) {
struct hns3_mac_stats mac_stats;
h->ae_algo->ops->update_stats(h, &ndev->stats); h->ae_algo->ops->get_mac_stats(h, &mac_stats);
h->ae_algo->ops->get_mac_pause_stats(h, &tx_pause_cnt,
&rx_pause_cnt);
netdev_info(ndev, "tx_pause_cnt: %llu, rx_pause_cnt: %llu\n", netdev_info(ndev, "tx_pause_cnt: %llu, rx_pause_cnt: %llu\n",
tx_pause_cnt, rx_pause_cnt); mac_stats.tx_pause_cnt, mac_stats.rx_pause_cnt);
} }
hw_head = readl_relaxed(tx_ring->tqp->io_base + hw_head = readl_relaxed(tx_ring->tqp->io_base +
......
...@@ -94,7 +94,7 @@ static void hclge_dbg_dump_reg_common(struct hclge_dev *hdev, ...@@ -94,7 +94,7 @@ static void hclge_dbg_dump_reg_common(struct hclge_dev *hdev,
} }
desc = desc_src; desc = desc_src;
ret = hclge_dbg_cmd_send(hdev, desc, index, bd_num, cmd); ret = hclge_dbg_cmd_send(hdev, desc, index, bd_num, cmd);
if (ret != HCLGE_CMD_EXEC_SUCCESS) { if (ret != HCLGE_CMD_EXEC_SUCCESS) {
kfree(desc_src); kfree(desc_src);
return; return;
...@@ -946,14 +946,15 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev) ...@@ -946,14 +946,15 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev)
ret = hclge_cmd_send(&hdev->hw, &desc, 1); ret = hclge_cmd_send(&hdev->hw, &desc, 1);
if (ret) { if (ret) {
dev_err(&hdev->pdev->dev, dev_err(&hdev->pdev->dev,
"hclge_cmd_send fail, status is %d.\n", ret); "hclge_cmd_send fail, status is %d, cmd: 0x%x.\n",
ret, HCLGE_OPC_M7_STATS_BD);
return; return;
} }
bd_num = desc.data[0]; bd_num = desc.data[0];
buf_len = sizeof(struct hclge_desc) * bd_num; buf_len = sizeof(struct hclge_desc) * bd_num;
desc_src = kzalloc(buf_len, GFP_ATOMIC); desc_src = kzalloc(buf_len, GFP_KERNEL);
if (!desc_src) { if (!desc_src) {
dev_err(&hdev->pdev->dev, "call kzalloc failed\n"); dev_err(&hdev->pdev->dev, "call kzalloc failed\n");
return; return;
...@@ -962,7 +963,7 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev) ...@@ -962,7 +963,7 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev)
desc_tmp = desc_src; desc_tmp = desc_src;
ret = hclge_dbg_cmd_send(hdev, desc_tmp, 0, bd_num, ret = hclge_dbg_cmd_send(hdev, desc_tmp, 0, bd_num,
HCLGE_OPC_M7_STATS_INFO); HCLGE_OPC_M7_STATS_INFO);
if (ret != HCLGE_CMD_EXEC_SUCCESS) { if (ret) {
kfree(desc_src); kfree(desc_src);
return; return;
} }
...@@ -981,6 +982,33 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev) ...@@ -981,6 +982,33 @@ void hclge_dbg_get_m7_stats_info(struct hclge_dev *hdev)
kfree(desc_src); kfree(desc_src);
} }
#define HCLGE_CMD_NCL_CONFIG_BD_NUM 5
static void hclge_ncl_config_data_print(struct hclge_dev *hdev,
struct hclge_desc *desc, int *offset,
int *length)
{
#define HCLGE_CMD_DATA_NUM 6
int i;
int j;
for (i = 0; i < HCLGE_CMD_NCL_CONFIG_BD_NUM; i++) {
for (j = 0; j < HCLGE_CMD_DATA_NUM; j++) {
if (i == 0 && j == 0)
continue;
dev_info(&hdev->pdev->dev, "0x%04x | 0x%08x\n",
*offset,
le32_to_cpu(desc[i].data[j]));
*offset += sizeof(u32);
*length -= sizeof(u32);
if (*length <= 0)
return;
}
}
}
/* hclge_dbg_dump_ncl_config: print specified range of NCL_CONFIG file /* hclge_dbg_dump_ncl_config: print specified range of NCL_CONFIG file
* @hdev: pointer to struct hclge_dev * @hdev: pointer to struct hclge_dev
* @cmd_buf: string that contains offset and length * @cmd_buf: string that contains offset and length
...@@ -989,8 +1017,6 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf) ...@@ -989,8 +1017,6 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf)
{ {
#define HCLGE_MAX_NCL_CONFIG_OFFSET 16384 #define HCLGE_MAX_NCL_CONFIG_OFFSET 16384
#define HCLGE_MAX_NCL_CONFIG_LENGTH (20 + 24 * 4) #define HCLGE_MAX_NCL_CONFIG_LENGTH (20 + 24 * 4)
#define HCLGE_CMD_NCL_CONFIG_BD_NUM 5
#define HCLGE_CMD_DATA_NUM 6
struct hclge_desc desc[HCLGE_CMD_NCL_CONFIG_BD_NUM]; struct hclge_desc desc[HCLGE_CMD_NCL_CONFIG_BD_NUM];
int bd_num = HCLGE_CMD_NCL_CONFIG_BD_NUM; int bd_num = HCLGE_CMD_NCL_CONFIG_BD_NUM;
...@@ -998,8 +1024,6 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf) ...@@ -998,8 +1024,6 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf)
int length; int length;
int data0; int data0;
int ret; int ret;
int i;
int j;
ret = sscanf(cmd_buf, "%x %x", &offset, &length); ret = sscanf(cmd_buf, "%x %x", &offset, &length);
if (ret != 2) { if (ret != 2) {
...@@ -1030,20 +1054,7 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf) ...@@ -1030,20 +1054,7 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, char *cmd_buf)
if (ret) if (ret)
return; return;
for (i = 0; i < bd_num; i++) { hclge_ncl_config_data_print(hdev, desc, &offset, &length);
for (j = 0; j < HCLGE_CMD_DATA_NUM; j++) {
if (i == 0 && j == 0)
continue;
dev_info(&hdev->pdev->dev, "0x%04x | 0x%08x\n",
offset,
le32_to_cpu(desc[i].data[j]));
offset += sizeof(u32);
length -= sizeof(u32);
if (length <= 0)
return;
}
}
} }
} }
......
...@@ -307,6 +307,7 @@ static int hclge_mac_update_stats_complete(struct hclge_dev *hdev, u32 desc_num) ...@@ -307,6 +307,7 @@ static int hclge_mac_update_stats_complete(struct hclge_dev *hdev, u32 desc_num)
u16 i, k, n; u16 i, k, n;
int ret; int ret;
/* This will be called in service task, can only use GFP_ATOMIC */
desc = kcalloc(desc_num, sizeof(struct hclge_desc), GFP_ATOMIC); desc = kcalloc(desc_num, sizeof(struct hclge_desc), GFP_ATOMIC);
if (!desc) if (!desc)
return -ENOMEM; return -ENOMEM;
...@@ -647,14 +648,16 @@ static void hclge_get_stats(struct hnae3_handle *handle, u64 *data) ...@@ -647,14 +648,16 @@ static void hclge_get_stats(struct hnae3_handle *handle, u64 *data)
p = hclge_tqps_get_stats(handle, p); p = hclge_tqps_get_stats(handle, p);
} }
static void hclge_get_mac_pause_stat(struct hnae3_handle *handle, u64 *tx_cnt, static void hclge_get_mac_stat(struct hnae3_handle *handle,
u64 *rx_cnt) struct hns3_mac_stats *mac_stats)
{ {
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport *vport = hclge_get_vport(handle);
struct hclge_dev *hdev = vport->back; struct hclge_dev *hdev = vport->back;
*tx_cnt = hdev->hw_stats.mac_stats.mac_tx_mac_pause_num; hclge_update_stats(handle, NULL);
*rx_cnt = hdev->hw_stats.mac_stats.mac_rx_mac_pause_num;
mac_stats->tx_pause_cnt = hdev->hw_stats.mac_stats.mac_tx_mac_pause_num;
mac_stats->rx_pause_cnt = hdev->hw_stats.mac_stats.mac_rx_mac_pause_num;
} }
static int hclge_parse_func_status(struct hclge_dev *hdev, static int hclge_parse_func_status(struct hclge_dev *hdev,
...@@ -9223,7 +9226,7 @@ struct hnae3_ae_ops hclge_ops = { ...@@ -9223,7 +9226,7 @@ struct hnae3_ae_ops hclge_ops = {
.set_mtu = hclge_set_mtu, .set_mtu = hclge_set_mtu,
.reset_queue = hclge_reset_tqp, .reset_queue = hclge_reset_tqp,
.get_stats = hclge_get_stats, .get_stats = hclge_get_stats,
.get_mac_pause_stats = hclge_get_mac_pause_stat, .get_mac_stats = hclge_get_mac_stat,
.update_stats = hclge_update_stats, .update_stats = hclge_update_stats,
.get_strings = hclge_get_strings, .get_strings = hclge_get_strings,
.get_sset_count = hclge_get_sset_count, .get_sset_count = hclge_get_sset_count,
......
...@@ -170,11 +170,11 @@ struct hclgevf_misc_vector { ...@@ -170,11 +170,11 @@ struct hclgevf_misc_vector {
}; };
struct hclgevf_rst_stats { struct hclgevf_rst_stats {
unsigned long rst_cnt; /* the number of reset has been done */ u32 rst_cnt; /* the number of all reset */
u32 vf_func_rst_cnt; /* the number of VF function reset */ u32 vf_func_rst_cnt; /* the number of VF function reset */
u32 flr_rst_cnt; /* the number of FLR */ u32 flr_rst_cnt; /* the number of FLR */
u32 vf_rst_cnt; /* the number of VF reset */ u32 vf_rst_cnt; /* the number of VF reset */
u32 rst_done_cnt; /* the number of reset has completed */ u32 rst_done_cnt; /* the number of sucessful reset */
}; };
struct hclgevf_dev { struct hclgevf_dev {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册