net: hisilicon: hns: use ethtool string helpers
Subsystems (4)
PATCH 1/1 net: hisilicon: hns: 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.
--- drivers/net/ethernet/hisilicon/hns/hnae.h | 2 +- .../net/ethernet/hisilicon/hns/hns_ae_adapt.c | 20 ++---- .../ethernet/hisilicon/hns/hns_dsaf_gmac.c | 5 +- .../net/ethernet/hisilicon/hns/hns_dsaf_mac.c | 3 +- .../net/ethernet/hisilicon/hns/hns_dsaf_mac.h | 4 +- .../ethernet/hisilicon/hns/hns_dsaf_main.c | 70 +++++++------------ .../ethernet/hisilicon/hns/hns_dsaf_main.h | 2 +- .../net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 31 ++++---- .../net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +- .../net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 66 +++++++++-------- .../net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +- .../ethernet/hisilicon/hns/hns_dsaf_xgmac.c | 5 +- .../net/ethernet/hisilicon/hns/hns_ethtool.c | 67 +++++++++--------- 13 files changed, 122 insertions(+), 157 deletions(-)
drivers/net/ethernet/hisilicon/hns/hnae.h +1 -1
@@ -512,7 +512,7 @@ struct hnae_ae_ops { struct net_device_stats *net_stats);void (*get_stats)(struct hnae_handle *handle,u64 *data);void (*get_strings)(struct hnae_handle *handle, -u32 stringset,u8 *data); +u32 stringset,u8 **data);int (*get_sset_count)(struct hnae_handle *handle,int stringset);void (*update_led_status)(struct hnae_handle *handle); int (*set_led_id)(struct hnae_handle *handle,
drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c +7 -13
@@ -730,15 +730,14 @@ static void hns_ae_get_stats(struct hnae_handle *handle, u64 *data)hns_dsaf_get_stats (vf_cb->dsaf_dev, p, vf_cb->port_index); } -static void hns_ae_get_strings (struct hnae_handle *handle, -u32 stringset,u8 *data) +static void hns_ae_get_strings (struct hnae_handle *handle,u32 stringset, +u8 **data) {int port;int idx;struct hns_mac_cb *mac_cb;struct hns_ppe_cb *ppe_cb;struct dsaf_device *dsaf_dev =hns_ae_get_dsaf_dev (handle->dev); -u8 *p = data;struct hnae_vf_cb *vf_cb;assert (handle);
@@ -748,19 +747,14 @@ static void hns_ae_get_strings(struct hnae_handle *handle, mac_cb =hns_get_mac_cb (handle); ppe_cb =hns_get_ppe_cb (handle); -for (idx =0 ; idx < handle->q_num; idx++) { -hns_rcb_get_strings (stringset, p, idx); - p +=ETH_GSTRING_LEN *hns_rcb_get_ring_sset_count (stringset); - } - -hns_ppe_get_strings (ppe_cb, stringset, p); - p +=ETH_GSTRING_LEN *hns_ppe_get_sset_count (stringset); +for (idx =0 ; idx < handle->q_num; idx++) +hns_rcb_get_strings (stringset, data, idx); -hns_mac_get_strings (mac_cb, stringset, p); - p +=ETH_GSTRING_LEN *hns_mac_get_sset_count (mac_cb, stringset); +hns_ppe_get_strings (ppe_cb, stringset, data); +hns_mac_get_strings (mac_cb, stringset, data);if (mac_cb->mac_type ==HNAE_PORT_SERVICE ) -hns_dsaf_get_strings (stringset, p, port, dsaf_dev); +hns_dsaf_get_strings (stringset, data, port, dsaf_dev); }static int hns_ae_get_sset_count (struct hnae_handle *handle,int stringset)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c +2 -3
@@ -669,16 +669,15 @@ static void hns_gmac_get_stats(void *mac_drv, u64 *data) } } -static void hns_gmac_get_strings (u32 stringset,u8 *data) +static void hns_gmac_get_strings (u32 stringset,u8 **data) { -u8 *buff = data;u32 i;if (stringset !=ETH_SS_STATS )return ;for (i =0 ; i <ARRAY_SIZE (g_gmac_stats_string); i++) -ethtool_puts (&buff, g_gmac_stats_string[i].desc); +ethtool_puts (data, g_gmac_stats_string[i].desc); }static int hns_gmac_get_sset_count (int stringset)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c +1 -2
@@ -1190,8 +1190,7 @@ void hns_mac_get_stats(struct hns_mac_cb *mac_cb, u64 *data) mac_ctrl_drv->get_ethtool_stats (mac_ctrl_drv, data); } -void hns_mac_get_strings (struct hns_mac_cb *mac_cb, -int stringset,u8 *data) +void hns_mac_get_strings (struct hns_mac_cb *mac_cb,int stringset,u8 **data) {struct mac_driver *mac_ctrl_drv =hns_mac_get_drv (mac_cb);
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h +2 -2
@@ -378,7 +378,7 @@ struct mac_driver {void (*get_regs)(void *mac_drv,void *data);int (*get_regs_count)(void );/* get strings name for ethtool statistic */ -void (*get_strings)(u32 stringset,u8 *data); +void (*get_strings)(u32 stringset,u8 **data);/* get the number of strings*/ int (*get_sset_count)(int stringset);
@@ -445,7 +445,7 @@ int hns_mac_config_mac_loopback(struct hns_mac_cb *mac_cb, enum hnae_loop loop, int en);void hns_mac_update_stats (struct hns_mac_cb *mac_cb);void hns_mac_get_stats (struct hns_mac_cb *mac_cb,u64 *data); -void hns_mac_get_strings (struct hns_mac_cb *mac_cb,int stringset,u8 *data); +void hns_mac_get_strings (struct hns_mac_cb *mac_cb,int stringset,u8 **data);int hns_mac_get_sset_count (struct hns_mac_cb *mac_cb,int stringset);void hns_mac_get_regs (struct hns_mac_cb *mac_cb,void *data);int hns_mac_get_regs_count (struct hns_mac_cb *mac_cb);
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +24 -46
100 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.h +1 -1
@@ -442,7 +442,7 @@ void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 inode_num);int hns_dsaf_get_sset_count (struct dsaf_device *dsaf_dev,int stringset);void hns_dsaf_get_stats (struct dsaf_device *ddev,u64 *data,int port); -void hns_dsaf_get_strings (int stringset,u8 *data,int port, +void hns_dsaf_get_strings (int stringset,u8 **data,int port,struct dsaf_device *dsaf_dev);void hns_dsaf_get_regs (struct dsaf_device *ddev,u32 port,void *data);
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c +15 -16
@@ -457,24 +457,23 @@ int hns_ppe_get_regs_count(void)* @stringset: string set type * @data: output string */ -void hns_ppe_get_strings (struct hns_ppe_cb *ppe_cb,int stringset,u8 *data) +void hns_ppe_get_strings (struct hns_ppe_cb *ppe_cb,int stringset,u8 **data) {int index = ppe_cb->index; -u8 *buff = data; - -ethtool_sprintf (&buff,"ppe%d_rx_sw_pkt" , index); -ethtool_sprintf (&buff,"ppe%d_rx_pkt_ok" , index); -ethtool_sprintf (&buff,"ppe%d_rx_drop_pkt_no_bd" , index); -ethtool_sprintf (&buff,"ppe%d_rx_alloc_buf_fail" , index); -ethtool_sprintf (&buff,"ppe%d_rx_alloc_buf_wait" , index); -ethtool_sprintf (&buff,"ppe%d_rx_pkt_drop_no_buf" , index); -ethtool_sprintf (&buff,"ppe%d_rx_pkt_err_fifo_full" , index); - -ethtool_sprintf (&buff,"ppe%d_tx_bd" , index); -ethtool_sprintf (&buff,"ppe%d_tx_pkt" , index); -ethtool_sprintf (&buff,"ppe%d_tx_pkt_ok" , index); -ethtool_sprintf (&buff,"ppe%d_tx_pkt_err_fifo_empty" , index); -ethtool_sprintf (&buff,"ppe%d_tx_pkt_err_csum_fail" , index); + +ethtool_sprintf (data,"ppe%d_rx_sw_pkt" , index); +ethtool_sprintf (data,"ppe%d_rx_pkt_ok" , index); +ethtool_sprintf (data,"ppe%d_rx_drop_pkt_no_bd" , index); +ethtool_sprintf (data,"ppe%d_rx_alloc_buf_fail" , index); +ethtool_sprintf (data,"ppe%d_rx_alloc_buf_wait" , index); +ethtool_sprintf (data,"ppe%d_rx_pkt_drop_no_buf" , index); +ethtool_sprintf (data,"ppe%d_rx_pkt_err_fifo_full" , index); + +ethtool_sprintf (data,"ppe%d_tx_bd" , index); +ethtool_sprintf (data,"ppe%d_tx_pkt" , index); +ethtool_sprintf (data,"ppe%d_tx_pkt_ok" , index); +ethtool_sprintf (data,"ppe%d_tx_pkt_err_fifo_empty" , index); +ethtool_sprintf (data,"ppe%d_tx_pkt_err_csum_fail" , index); }void hns_ppe_get_stats (struct hns_ppe_cb *ppe_cb,u64 *data)
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h +1 -1
@@ -109,7 +109,7 @@ int hns_ppe_get_sset_count(int stringset);int hns_ppe_get_regs_count (void );void hns_ppe_get_regs (struct hns_ppe_cb *ppe_cb,void *data); -void hns_ppe_get_strings (struct hns_ppe_cb *ppe_cb,int stringset,u8 *data); +void hns_ppe_get_strings (struct hns_ppe_cb *ppe_cb,int stringset,u8 **data);void hns_ppe_get_stats (struct hns_ppe_cb *ppe_cb,u64 *data);void hns_ppe_set_tso_enable (struct hns_ppe_cb *ppe_cb,u32 value); void hns_ppe_set_rss_key(struct hns_ppe_cb *ppe_cb,
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c +32 -34
76 lines not on this page · raw message
drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h +1 -1
@@ -157,7 +157,7 @@ int hns_rcb_get_ring_regs_count(void);void hns_rcb_get_ring_regs (struct hnae_queue *queue,void *data); -void hns_rcb_get_strings (int stringset,u8 *data,int index); +void hns_rcb_get_strings (int stringset,u8 **data,int index);void hns_rcb_set_rx_ring_bs (struct hnae_queue *q,u32 buf_size);void hns_rcb_set_tx_ring_bs (struct hnae_queue *q,u32 buf_size);
drivers/net/ethernet/hisilicon/hns/hns_dsaf_xgmac.c +2 -3
@@ -743,16 +743,15 @@ static void hns_xgmac_get_stats(void *mac_drv, u64 *data)*@stringset: type of values in data *@data:data for value of string name */ -static void hns_xgmac_get_strings (u32 stringset,u8 *data) +static void hns_xgmac_get_strings (u32 stringset,u8 **data) { -u8 *buff = data;u32 i;if (stringset !=ETH_SS_STATS )return ;for (i =0 ; i <ARRAY_SIZE (g_xgmac_stats_string); i++) -ethtool_puts (&buff, g_xgmac_stats_string[i].desc); +ethtool_puts (data, g_xgmac_stats_string[i].desc); }/**
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +33 -34
90 lines not on this page · raw message
Signature · 1 line
2.47.0
PATCH 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.
--- 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 | 53 ++++++------------- .../hisilicon/hns3/hns3pf/hclge_main.c | 50 +++++++---------- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +-- 6 files changed, 44 insertions(+), 80 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 -36
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
Simon Horman
reviewerRe: [PATCH net-next] net: hisilicon: hns3: use ethtool string helpers
Quoted 7 lines · Rosen Penev
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]>
...
Quoted 5 lines
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +0
-0
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c static int hns3_get_sset_count(struct net_device *netdev, int stringset) · line 516
Quoted 10 lines
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +3
-2@@ -509,54 +509,38 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset) } } -static void *hns3_update_strings (u8 *data,const struct hns3_stats *stats, -u32 stat_count,u32 num_tqps,const char *prefix) +static void hns3_update_strings (u8 **data,const struct hns3_stats *stats, +u32 stat_count,u32 num_tqps, +const char *prefix) {#define MAX_PREFIX_SIZE (6 + 4)
Hi Rosen,
As per Jakub's feedback on v1, can't this #define be removed?
...
Re: [PATCH net-next] net: hisilicon: hns3: use ethtool string helpers
Quoted 30 lines · Simon Horman
Quoted 7 lines · Rosen Penev
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]>...
Quoted 5 lines
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +0
-0drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c static int hns3_get_sset_count(struct net_device *netdev, int stringset) · line 516
Quoted 10 lines
drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +3
-2@@ -509,54 +509,38 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset) } } -static void *hns3_update_strings (u8 *data,const struct hns3_stats *stats, -u32 stat_count,u32 num_tqps,const char *prefix) +static void hns3_update_strings (u8 **data,const struct hns3_stats *stats, +u32 stat_count,u32 num_tqps, +const char *prefix) {#define MAX_PREFIX_SIZE (6 + 4)Hi Rosen,
Quoted 1 line
As per Jakub's feedback on v1, can't this #define be removed?
Removed in v2.
Quoted 2 lines
...
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 8 lines · On Fri, 1 Nov 2024 15:00:22 -0700 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]>[...]
Here is the summary with links:
- [net-next] net: hisilicon: hns: use ethtool string helpers
https://git.kernel.org/netdev/net-next/c/7a4ea5da4d02
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html