net: hisilicon: hns3: use ethtool string helpers
Subsystems (4)
PATCH v2 1/1 net: hisilicon: hns3: use ethtool string helpers
The latter is the preferred way to copy ethtool strings.
Avoids manually incrementing the pointer. Cleans up the code quite well.
Signed-off-by Rosen Penev <[email protected]>
Reviewed-by Jijie Shao <[email protected]>
Tested-by Jijie Shao <[email protected]>
---
v2: remove now useless define MAX_PREFIX_LENGTH
drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- .../hns3/hns3_common/hclge_comm_tqp_stats.c | 11 ++-- .../hns3/hns3_common/hclge_comm_tqp_stats.h | 2 +- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 54 ++++++------------- .../hisilicon/hns3/hns3pf/hclge_main.c | 50 +++++++---------- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +-- 6 files changed, 44 insertions(+), 81 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hnae3.h +1 -1
@@ -677,7 +677,7 @@ struct hnae3_ae_ops {void (*get_mac_stats)(struct hnae3_handle *handle,struct hns3_mac_stats *mac_stats);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); void (*get_regs)(struct hnae3_handle *handle, u32 *version,
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.c +3 -8
@@ -36,27 +36,22 @@ int hclge_comm_tqps_get_sset_count(struct hnae3_handle *handle) }EXPORT_SYMBOL_GPL (hclge_comm_tqps_get_sset_count); -u8 *hclge_comm_tqps_get_strings (struct hnae3_handle *handle,u8 *data) +void hclge_comm_tqps_get_strings (struct hnae3_handle *handle,u8 **data) {struct hnae3_knic_private_info *kinfo = &handle->kinfo; -u8 *buff = data;u16 i;for (i =0 ; i < kinfo->num_tqps; i++) {struct hclge_comm_tqp *tqp = container_of(kinfo->tqp[i], struct hclge_comm_tqp, q); -snprintf (buff,ETH_GSTRING_LEN ,"txq%u_pktnum_rcd" , tqp->index); - buff +=ETH_GSTRING_LEN ; +ethtool_sprintf (data,"txq%u_pktnum_rcd" , tqp->index); }for (i =0 ; i < kinfo->num_tqps; i++) {struct hclge_comm_tqp *tqp = container_of(kinfo->tqp[i], struct hclge_comm_tqp, q); -snprintf (buff,ETH_GSTRING_LEN ,"rxq%u_pktnum_rcd" , tqp->index); - buff +=ETH_GSTRING_LEN ; +ethtool_sprintf (data,"rxq%u_pktnum_rcd" , tqp->index); } - -return buff; }EXPORT_SYMBOL_GPL (hclge_comm_tqps_get_strings);
drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_tqp_stats.h +1 -1
@@ -32,7 +32,7 @@ struct hclge_comm_tqp {u64 *hclge_comm_tqps_get_stats (struct hnae3_handle *handle,u64 *data);int hclge_comm_tqps_get_sset_count (struct hnae3_handle *handle); -u8 *hclge_comm_tqps_get_strings (struct hnae3_handle *handle,u8 *data); +void hclge_comm_tqps_get_strings (struct hnae3_handle *handle,u8 **data);void hclge_comm_reset_tqp_stats (struct hnae3_handle *handle);int hclge_comm_tqps_update_stats (struct hnae3_handle *handle,struct hclge_comm_hw *hw);
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +17 -37
89 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +20 -30
89 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +2 -4
@@ -130,12 +130,10 @@ static int hclgevf_get_sset_count(struct hnae3_handle *handle, int strset) }static void hclgevf_get_strings (struct hnae3_handle *handle,u32 strset, -u8 *data) +u8 **data) { -u8 *p = (char *)data; -if (strset ==ETH_SS_STATS ) - p =hclge_comm_tqps_get_strings (handle, p); +hclge_comm_tqps_get_strings (handle, data); }static void hclgevf_get_stats (struct hnae3_handle *handle,u64 *data)
Signature · 1 line
2.47.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 4 Nov 2024 12:48:23 -0800 you wrote:
The latter is the preferred way to copy ethtool strings.
Avoids manually incrementing the pointer. Cleans up the code quite well.
Signed-off-by Rosen Penev <[email protected]>Reviewed-by Jijie Shao <[email protected]>Tested-by Jijie Shao <[email protected]>[...]
Here is the summary with links:
- [PATCHv2,net-next] net: hisilicon: hns3: use ethtool string helpers
https://git.kernel.org/netdev/net-next/c/4ea3e221907a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html