Commit 5c9e418b authored by David S. Miller's avatar David S. Miller

Merge branch 'ethtool-strings'

Alexander Duyck says:

====================
ethtool: Factor out common code related to writing ethtool strings

This patch set is meant to be a cleanup and refactoring of common code bits
from several drivers. Specificlly a number of drivers engage in a pattern
where they will use some variant on an sprintf or memcpy to write a string
into the ethtool string array and then they will increment their pointer by
ETH_GSTRING_LEN.

Instead of having each driver implement this independently I am refactoring
the code so that we have one central function, ethtool_sprintf that does
all this and takes a double pointer to access the data, a formatted string
to print, and the variable arguments that are associated with the string.

Changes from v1:
Fixed usage of char ** vs  unsigned char ** in hisilicon drivers

Changes from RFC:
Renamed ethtool_gsprintf to ethtool_sprintf
Fixed reverse xmas tree issue in patch 2
====================
Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0c88eda9 acebe5b6
...@@ -251,10 +251,10 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data) ...@@ -251,10 +251,10 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
for (j = 0; j < ENA_STATS_ARRAY_TX; j++) { for (j = 0; j < ENA_STATS_ARRAY_TX; j++) {
ena_stats = &ena_stats_tx_strings[j]; ena_stats = &ena_stats_tx_strings[j];
snprintf(*data, ETH_GSTRING_LEN, ethtool_sprintf(data,
"queue_%u_%s_%s", i, "queue_%u_%s_%s", i,
is_xdp ? "xdp_tx" : "tx", ena_stats->name); is_xdp ? "xdp_tx" : "tx",
(*data) += ETH_GSTRING_LEN; ena_stats->name);
} }
if (!is_xdp) { if (!is_xdp) {
...@@ -264,9 +264,9 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data) ...@@ -264,9 +264,9 @@ static void ena_queue_strings(struct ena_adapter *adapter, u8 **data)
for (j = 0; j < ENA_STATS_ARRAY_RX; j++) { for (j = 0; j < ENA_STATS_ARRAY_RX; j++) {
ena_stats = &ena_stats_rx_strings[j]; ena_stats = &ena_stats_rx_strings[j];
snprintf(*data, ETH_GSTRING_LEN, ethtool_sprintf(data,
"queue_%u_rx_%s", i, ena_stats->name); "queue_%u_rx_%s", i,
(*data) += ETH_GSTRING_LEN; ena_stats->name);
} }
} }
} }
...@@ -280,9 +280,8 @@ static void ena_com_dev_strings(u8 **data) ...@@ -280,9 +280,8 @@ static void ena_com_dev_strings(u8 **data)
for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) { for (i = 0; i < ENA_STATS_ARRAY_ENA_COM; i++) {
ena_stats = &ena_stats_ena_com_strings[i]; ena_stats = &ena_stats_ena_com_strings[i];
snprintf(*data, ETH_GSTRING_LEN, ethtool_sprintf(data,
"ena_admin_q_%s", ena_stats->name); "ena_admin_q_%s", ena_stats->name);
(*data) += ETH_GSTRING_LEN;
} }
} }
...@@ -295,15 +294,13 @@ static void ena_get_strings(struct ena_adapter *adapter, ...@@ -295,15 +294,13 @@ static void ena_get_strings(struct ena_adapter *adapter,
for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) { for (i = 0; i < ENA_STATS_ARRAY_GLOBAL; i++) {
ena_stats = &ena_stats_global_strings[i]; ena_stats = &ena_stats_global_strings[i];
memcpy(data, ena_stats->name, ETH_GSTRING_LEN); ethtool_sprintf(&data, ena_stats->name);
data += ETH_GSTRING_LEN;
} }
if (eni_stats_needed) { if (eni_stats_needed) {
for (i = 0; i < ENA_STATS_ARRAY_ENI(adapter); i++) { for (i = 0; i < ENA_STATS_ARRAY_ENI(adapter); i++) {
ena_stats = &ena_stats_eni_strings[i]; ena_stats = &ena_stats_eni_strings[i];
memcpy(data, ena_stats->name, ETH_GSTRING_LEN); ethtool_sprintf(&data, ena_stats->name);
data += ETH_GSTRING_LEN;
} }
} }
......
...@@ -524,6 +524,68 @@ bnad_set_pauseparam(struct net_device *netdev, ...@@ -524,6 +524,68 @@ bnad_set_pauseparam(struct net_device *netdev,
return 0; return 0;
} }
static void bnad_get_txf_strings(u8 **string, int f_num)
{
ethtool_sprintf(string, "txf%d_ucast_octets", f_num);
ethtool_sprintf(string, "txf%d_ucast", f_num);
ethtool_sprintf(string, "txf%d_ucast_vlan", f_num);
ethtool_sprintf(string, "txf%d_mcast_octets", f_num);
ethtool_sprintf(string, "txf%d_mcast", f_num);
ethtool_sprintf(string, "txf%d_mcast_vlan", f_num);
ethtool_sprintf(string, "txf%d_bcast_octets", f_num);
ethtool_sprintf(string, "txf%d_bcast", f_num);
ethtool_sprintf(string, "txf%d_bcast_vlan", f_num);
ethtool_sprintf(string, "txf%d_errors", f_num);
ethtool_sprintf(string, "txf%d_filter_vlan", f_num);
ethtool_sprintf(string, "txf%d_filter_mac_sa", f_num);
}
static void bnad_get_rxf_strings(u8 **string, int f_num)
{
ethtool_sprintf(string, "rxf%d_ucast_octets", f_num);
ethtool_sprintf(string, "rxf%d_ucast", f_num);
ethtool_sprintf(string, "rxf%d_ucast_vlan", f_num);
ethtool_sprintf(string, "rxf%d_mcast_octets", f_num);
ethtool_sprintf(string, "rxf%d_mcast", f_num);
ethtool_sprintf(string, "rxf%d_mcast_vlan", f_num);
ethtool_sprintf(string, "rxf%d_bcast_octets", f_num);
ethtool_sprintf(string, "rxf%d_bcast", f_num);
ethtool_sprintf(string, "rxf%d_bcast_vlan", f_num);
ethtool_sprintf(string, "rxf%d_frame_drops", f_num);
}
static void bnad_get_cq_strings(u8 **string, int q_num)
{
ethtool_sprintf(string, "cq%d_producer_index", q_num);
ethtool_sprintf(string, "cq%d_consumer_index", q_num);
ethtool_sprintf(string, "cq%d_hw_producer_index", q_num);
ethtool_sprintf(string, "cq%d_intr", q_num);
ethtool_sprintf(string, "cq%d_poll", q_num);
ethtool_sprintf(string, "cq%d_schedule", q_num);
ethtool_sprintf(string, "cq%d_keep_poll", q_num);
ethtool_sprintf(string, "cq%d_complete", q_num);
}
static void bnad_get_rxq_strings(u8 **string, int q_num)
{
ethtool_sprintf(string, "rxq%d_packets", q_num);
ethtool_sprintf(string, "rxq%d_bytes", q_num);
ethtool_sprintf(string, "rxq%d_packets_with_error", q_num);
ethtool_sprintf(string, "rxq%d_allocbuf_failed", q_num);
ethtool_sprintf(string, "rxq%d_mapbuf_failed", q_num);
ethtool_sprintf(string, "rxq%d_producer_index", q_num);
ethtool_sprintf(string, "rxq%d_consumer_index", q_num);
}
static void bnad_get_txq_strings(u8 **string, int q_num)
{
ethtool_sprintf(string, "txq%d_packets", q_num);
ethtool_sprintf(string, "txq%d_bytes", q_num);
ethtool_sprintf(string, "txq%d_producer_index", q_num);
ethtool_sprintf(string, "txq%d_consumer_index", q_num);
ethtool_sprintf(string, "txq%d_hw_consumer_index", q_num);
}
static void static void
bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string) bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string)
{ {
...@@ -531,175 +593,57 @@ bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string) ...@@ -531,175 +593,57 @@ bnad_get_strings(struct net_device *netdev, u32 stringset, u8 *string)
int i, j, q_num; int i, j, q_num;
u32 bmap; u32 bmap;
if (stringset != ETH_SS_STATS)
return;
mutex_lock(&bnad->conf_mutex); mutex_lock(&bnad->conf_mutex);
switch (stringset) { for (i = 0; i < BNAD_ETHTOOL_STATS_NUM; i++) {
case ETH_SS_STATS: BUG_ON(!(strlen(bnad_net_stats_strings[i]) < ETH_GSTRING_LEN));
for (i = 0; i < BNAD_ETHTOOL_STATS_NUM; i++) { ethtool_sprintf(&string, bnad_net_stats_strings[i]);
BUG_ON(!(strlen(bnad_net_stats_strings[i]) < }
ETH_GSTRING_LEN));
strncpy(string, bnad_net_stats_strings[i],
ETH_GSTRING_LEN);
string += ETH_GSTRING_LEN;
}
bmap = bna_tx_rid_mask(&bnad->bna);
for (i = 0; bmap; i++) {
if (bmap & 1) {
sprintf(string, "txf%d_ucast_octets", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_ucast", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_ucast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_mcast_octets", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_mcast", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_mcast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_bcast_octets", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_bcast", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_bcast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_errors", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_filter_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "txf%d_filter_mac_sa", i);
string += ETH_GSTRING_LEN;
}
bmap >>= 1;
}
bmap = bna_rx_rid_mask(&bnad->bna); bmap = bna_tx_rid_mask(&bnad->bna);
for (i = 0; bmap; i++) { for (i = 0; bmap; i++) {
if (bmap & 1) { if (bmap & 1)
sprintf(string, "rxf%d_ucast_octets", i); bnad_get_txf_strings(&string, i);
string += ETH_GSTRING_LEN; bmap >>= 1;
sprintf(string, "rxf%d_ucast", i); }
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_ucast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_mcast_octets", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_mcast", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_mcast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_bcast_octets", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_bcast", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_bcast_vlan", i);
string += ETH_GSTRING_LEN;
sprintf(string, "rxf%d_frame_drops", i);
string += ETH_GSTRING_LEN;
}
bmap >>= 1;
}
q_num = 0; bmap = bna_rx_rid_mask(&bnad->bna);
for (i = 0; i < bnad->num_rx; i++) { for (i = 0; bmap; i++, bmap >>= 1) {
if (!bnad->rx_info[i].rx) if (bmap & 1)
continue; bnad_get_rxf_strings(&string, i);
for (j = 0; j < bnad->num_rxp_per_rx; j++) { bmap >>= 1;
sprintf(string, "cq%d_producer_index", q_num); }
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_consumer_index", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_hw_producer_index",
q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_intr", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_poll", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_schedule", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_keep_poll", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "cq%d_complete", q_num);
string += ETH_GSTRING_LEN;
q_num++;
}
}
q_num = 0; q_num = 0;
for (i = 0; i < bnad->num_rx; i++) { for (i = 0; i < bnad->num_rx; i++) {
if (!bnad->rx_info[i].rx) if (!bnad->rx_info[i].rx)
continue; continue;
for (j = 0; j < bnad->num_rxp_per_rx; j++) { for (j = 0; j < bnad->num_rxp_per_rx; j++)
sprintf(string, "rxq%d_packets", q_num); bnad_get_cq_strings(&string, q_num++);
string += ETH_GSTRING_LEN; }
sprintf(string, "rxq%d_bytes", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_packets_with_error",
q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_allocbuf_failed", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_mapbuf_failed", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_producer_index", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_consumer_index", q_num);
string += ETH_GSTRING_LEN;
q_num++;
if (bnad->rx_info[i].rx_ctrl[j].ccb &&
bnad->rx_info[i].rx_ctrl[j].ccb->
rcb[1] &&
bnad->rx_info[i].rx_ctrl[j].ccb->
rcb[1]->rxq) {
sprintf(string, "rxq%d_packets", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_bytes", q_num);
string += ETH_GSTRING_LEN;
sprintf(string,
"rxq%d_packets_with_error", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_allocbuf_failed",
q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_mapbuf_failed",
q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_producer_index",
q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "rxq%d_consumer_index",
q_num);
string += ETH_GSTRING_LEN;
q_num++;
}
}
}
q_num = 0; q_num = 0;
for (i = 0; i < bnad->num_tx; i++) { for (i = 0; i < bnad->num_rx; i++) {
if (!bnad->tx_info[i].tx) if (!bnad->rx_info[i].rx)
continue; continue;
for (j = 0; j < bnad->num_txq_per_tx; j++) { for (j = 0; j < bnad->num_rxp_per_rx; j++) {
sprintf(string, "txq%d_packets", q_num); bnad_get_rxq_strings(&string, q_num++);
string += ETH_GSTRING_LEN; if (bnad->rx_info[i].rx_ctrl[j].ccb &&
sprintf(string, "txq%d_bytes", q_num); bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1] &&
string += ETH_GSTRING_LEN; bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1]->rxq)
sprintf(string, "txq%d_producer_index", q_num); bnad_get_rxq_strings(&string, q_num++);
string += ETH_GSTRING_LEN;
sprintf(string, "txq%d_consumer_index", q_num);
string += ETH_GSTRING_LEN;
sprintf(string, "txq%d_hw_consumer_index",
q_num);
string += ETH_GSTRING_LEN;
q_num++;
}
} }
}
break; q_num = 0;
for (i = 0; i < bnad->num_tx; i++) {
default: if (!bnad->tx_info[i].tx)
break; continue;
for (j = 0; j < bnad->num_txq_per_tx; j++)
bnad_get_txq_strings(&string, q_num++);
} }
mutex_unlock(&bnad->conf_mutex); mutex_unlock(&bnad->conf_mutex);
......
...@@ -687,17 +687,14 @@ static void hns_gmac_get_stats(void *mac_drv, u64 *data) ...@@ -687,17 +687,14 @@ 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)
{ {
char *buff = (char *)data; u8 *buff = data;
u32 i; u32 i;
if (stringset != ETH_SS_STATS) if (stringset != ETH_SS_STATS)
return; return;
for (i = 0; i < ARRAY_SIZE(g_gmac_stats_string); i++) { for (i = 0; i < ARRAY_SIZE(g_gmac_stats_string); i++)
snprintf(buff, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&buff, g_gmac_stats_string[i].desc);
g_gmac_stats_string[i].desc);
buff = buff + ETH_GSTRING_LEN;
}
} }
static int hns_gmac_get_sset_count(int stringset) static int hns_gmac_get_sset_count(int stringset)
......
...@@ -462,33 +462,22 @@ int hns_ppe_get_regs_count(void) ...@@ -462,33 +462,22 @@ int hns_ppe_get_regs_count(void)
*/ */
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)
{ {
char *buff = (char *)data;
int index = ppe_cb->index; int index = ppe_cb->index;
u8 *buff = data;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_sw_pkt", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_rx_sw_pkt", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_ok", index); ethtool_sprintf(&buff, "ppe%d_rx_pkt_ok", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_rx_drop_pkt_no_bd", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_drop_pkt_no_bd", index); ethtool_sprintf(&buff, "ppe%d_rx_alloc_buf_fail", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_rx_alloc_buf_wait", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_alloc_buf_fail", index); ethtool_sprintf(&buff, "ppe%d_rx_pkt_drop_no_buf", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_rx_pkt_err_fifo_full", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_alloc_buf_wait", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_tx_bd", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_drop_no_buf", index); ethtool_sprintf(&buff, "ppe%d_tx_pkt", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_tx_pkt_ok", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_rx_pkt_err_fifo_full", index); ethtool_sprintf(&buff, "ppe%d_tx_pkt_err_fifo_empty", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "ppe%d_tx_pkt_err_csum_fail", index);
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_bd", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_ok", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_err_fifo_empty", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "ppe%d_tx_pkt_err_csum_fail", index);
} }
void hns_ppe_get_stats(struct hns_ppe_cb *ppe_cb, u64 *data) void hns_ppe_get_stats(struct hns_ppe_cb *ppe_cb, u64 *data)
......
...@@ -929,69 +929,42 @@ int hns_rcb_get_ring_regs_count(void) ...@@ -929,69 +929,42 @@ int hns_rcb_get_ring_regs_count(void)
*/ */
void hns_rcb_get_strings(int stringset, u8 *data, int index) void hns_rcb_get_strings(int stringset, u8 *data, int index)
{ {
char *buff = (char *)data; u8 *buff = data;
if (stringset != ETH_SS_STATS) if (stringset != ETH_SS_STATS)
return; return;
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_rcb_pkt_num", index); ethtool_sprintf(&buff, "tx_ring%d_rcb_pkt_num", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_ppe_tx_pkt_num", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_ppe_tx_pkt_num", index); ethtool_sprintf(&buff, "tx_ring%d_ppe_drop_pkt_num", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_fbd_num", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_ppe_drop_pkt_num", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_pkt_num", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_fbd_num", index); ethtool_sprintf(&buff, "tx_ring%d_bytes", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_err_cnt", index);
ethtool_sprintf(&buff, "tx_ring%d_io_err", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_pkt_num", index); ethtool_sprintf(&buff, "tx_ring%d_sw_err", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_seg_pkt", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_bytes", index); ethtool_sprintf(&buff, "tx_ring%d_restart_queue", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_ring%d_tx_busy", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_err_cnt", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_rcb_pkt_num", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_io_err", index); ethtool_sprintf(&buff, "rx_ring%d_ppe_pkt_num", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_ppe_drop_pkt_num", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_sw_err", index); ethtool_sprintf(&buff, "rx_ring%d_fbd_num", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_seg_pkt", index); ethtool_sprintf(&buff, "rx_ring%d_pkt_num", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_bytes", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_restart_queue", index); ethtool_sprintf(&buff, "rx_ring%d_err_cnt", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_io_err", index);
snprintf(buff, ETH_GSTRING_LEN, "tx_ring%d_tx_busy", index); ethtool_sprintf(&buff, "rx_ring%d_sw_err", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_seg_pkt", index);
ethtool_sprintf(&buff, "rx_ring%d_reuse_pg", index);
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_rcb_pkt_num", index); ethtool_sprintf(&buff, "rx_ring%d_len_err", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_non_vld_desc_err", index);
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_ppe_pkt_num", index); ethtool_sprintf(&buff, "rx_ring%d_bd_num_err", index);
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_ring%d_l2_err", index);
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_ppe_drop_pkt_num", index); ethtool_sprintf(&buff, "rx_ring%d_l3l4csum_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_fbd_num", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_pkt_num", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_bytes", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_err_cnt", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_io_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_sw_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_seg_pkt", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_reuse_pg", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_len_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_non_vld_desc_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_bd_num_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_l2_err", index);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_ring%d_l3l4csum_err", index);
} }
void hns_rcb_get_common_regs(struct rcb_common_cb *rcb_com, void *data) void hns_rcb_get_common_regs(struct rcb_common_cb *rcb_com, void *data)
......
...@@ -758,16 +758,14 @@ static void hns_xgmac_get_stats(void *mac_drv, u64 *data) ...@@ -758,16 +758,14 @@ static void hns_xgmac_get_stats(void *mac_drv, u64 *data)
*/ */
static void hns_xgmac_get_strings(u32 stringset, u8 *data) static void hns_xgmac_get_strings(u32 stringset, u8 *data)
{ {
char *buff = (char *)data; u8 *buff = data;
u32 i; u32 i;
if (stringset != ETH_SS_STATS) if (stringset != ETH_SS_STATS)
return; return;
for (i = 0; i < ARRAY_SIZE(g_xgmac_stats_string); i++) { for (i = 0; i < ARRAY_SIZE(g_xgmac_stats_string); i++)
snprintf(buff, ETH_GSTRING_LEN, g_xgmac_stats_string[i].desc); ethtool_sprintf(&buff, g_xgmac_stats_string[i].desc);
buff = buff + ETH_GSTRING_LEN;
}
} }
/** /**
......
...@@ -895,7 +895,7 @@ static void hns_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -895,7 +895,7 @@ static void hns_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{ {
struct hns_nic_priv *priv = netdev_priv(netdev); struct hns_nic_priv *priv = netdev_priv(netdev);
struct hnae_handle *h = priv->ae_handle; struct hnae_handle *h = priv->ae_handle;
char *buff = (char *)data; u8 *buff = data;
if (!h->dev->ops->get_strings) { if (!h->dev->ops->get_strings) {
netdev_err(netdev, "h->dev->ops->get_strings is null!\n"); netdev_err(netdev, "h->dev->ops->get_strings is null!\n");
...@@ -903,74 +903,45 @@ static void hns_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -903,74 +903,45 @@ static void hns_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
} }
if (stringset == ETH_SS_TEST) { if (stringset == ETH_SS_TEST) {
if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII) { if (priv->ae_handle->phy_if != PHY_INTERFACE_MODE_XGMII)
memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_MAC], ethtool_sprintf(&buff,
ETH_GSTRING_LEN); hns_nic_test_strs[MAC_INTERNALLOOP_MAC]);
buff += ETH_GSTRING_LEN; ethtool_sprintf(&buff,
} hns_nic_test_strs[MAC_INTERNALLOOP_SERDES]);
memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_SERDES],
ETH_GSTRING_LEN);
buff += ETH_GSTRING_LEN;
if ((netdev->phydev) && (!netdev->phydev->is_c45)) if ((netdev->phydev) && (!netdev->phydev->is_c45))
memcpy(buff, hns_nic_test_strs[MAC_INTERNALLOOP_PHY], ethtool_sprintf(&buff,
ETH_GSTRING_LEN); hns_nic_test_strs[MAC_INTERNALLOOP_PHY]);
} else { } else {
snprintf(buff, ETH_GSTRING_LEN, "rx_packets"); ethtool_sprintf(&buff, "rx_packets");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_packets");
snprintf(buff, ETH_GSTRING_LEN, "tx_packets"); ethtool_sprintf(&buff, "rx_bytes");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_bytes");
snprintf(buff, ETH_GSTRING_LEN, "rx_bytes"); ethtool_sprintf(&buff, "rx_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_errors");
snprintf(buff, ETH_GSTRING_LEN, "tx_bytes"); ethtool_sprintf(&buff, "rx_dropped");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_dropped");
snprintf(buff, ETH_GSTRING_LEN, "rx_errors"); ethtool_sprintf(&buff, "multicast");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "collisions");
snprintf(buff, ETH_GSTRING_LEN, "tx_errors"); ethtool_sprintf(&buff, "rx_over_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_crc_errors");
snprintf(buff, ETH_GSTRING_LEN, "rx_dropped"); ethtool_sprintf(&buff, "rx_frame_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_fifo_errors");
snprintf(buff, ETH_GSTRING_LEN, "tx_dropped"); ethtool_sprintf(&buff, "rx_missed_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_aborted_errors");
snprintf(buff, ETH_GSTRING_LEN, "multicast"); ethtool_sprintf(&buff, "tx_carrier_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "tx_fifo_errors");
snprintf(buff, ETH_GSTRING_LEN, "collisions"); ethtool_sprintf(&buff, "tx_heartbeat_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_length_errors");
snprintf(buff, ETH_GSTRING_LEN, "rx_over_errors"); ethtool_sprintf(&buff, "tx_window_errors");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "rx_compressed");
snprintf(buff, ETH_GSTRING_LEN, "rx_crc_errors"); ethtool_sprintf(&buff, "tx_compressed");
buff = buff + ETH_GSTRING_LEN; ethtool_sprintf(&buff, "netdev_rx_dropped");
snprintf(buff, ETH_GSTRING_LEN, "rx_frame_errors"); ethtool_sprintf(&buff, "netdev_tx_dropped");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_fifo_errors"); ethtool_sprintf(&buff, "netdev_tx_timeout");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_missed_errors"); h->dev->ops->get_strings(h, stringset, buff);
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_aborted_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_carrier_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_fifo_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_heartbeat_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_length_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_window_errors");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "rx_compressed");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "tx_compressed");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "netdev_rx_dropped");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "netdev_tx_dropped");
buff = buff + ETH_GSTRING_LEN;
snprintf(buff, ETH_GSTRING_LEN, "netdev_tx_timeout");
buff = buff + ETH_GSTRING_LEN;
h->dev->ops->get_strings(h, stringset, (u8 *)buff);
} }
} }
......
...@@ -2368,21 +2368,15 @@ static void i40e_get_priv_flag_strings(struct net_device *netdev, u8 *data) ...@@ -2368,21 +2368,15 @@ static void i40e_get_priv_flag_strings(struct net_device *netdev, u8 *data)
struct i40e_netdev_priv *np = netdev_priv(netdev); struct i40e_netdev_priv *np = netdev_priv(netdev);
struct i40e_vsi *vsi = np->vsi; struct i40e_vsi *vsi = np->vsi;
struct i40e_pf *pf = vsi->back; struct i40e_pf *pf = vsi->back;
char *p = (char *)data;
unsigned int i; unsigned int i;
u8 *p = data;
for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) { for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++)
snprintf(p, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&p, i40e_gstrings_priv_flags[i].flag_string);
i40e_gstrings_priv_flags[i].flag_string);
p += ETH_GSTRING_LEN;
}
if (pf->hw.pf_id != 0) if (pf->hw.pf_id != 0)
return; return;
for (i = 0; i < I40E_GL_PRIV_FLAGS_STR_LEN; i++) { for (i = 0; i < I40E_GL_PRIV_FLAGS_STR_LEN; i++)
snprintf(p, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&p, i40e_gl_gstrings_priv_flags[i].flag_string);
i40e_gl_gstrings_priv_flags[i].flag_string);
p += ETH_GSTRING_LEN;
}
} }
static void i40e_get_strings(struct net_device *netdev, u32 stringset, static void i40e_get_strings(struct net_device *netdev, u32 stringset,
......
...@@ -871,68 +871,47 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -871,68 +871,47 @@ static void ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{ {
struct ice_netdev_priv *np = netdev_priv(netdev); struct ice_netdev_priv *np = netdev_priv(netdev);
struct ice_vsi *vsi = np->vsi; struct ice_vsi *vsi = np->vsi;
char *p = (char *)data;
unsigned int i; unsigned int i;
u8 *p = data;
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < ICE_VSI_STATS_LEN; i++) { for (i = 0; i < ICE_VSI_STATS_LEN; i++)
snprintf(p, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&p,
ice_gstrings_vsi_stats[i].stat_string); ice_gstrings_vsi_stats[i].stat_string);
p += ETH_GSTRING_LEN;
}
ice_for_each_alloc_txq(vsi, i) { ice_for_each_alloc_txq(vsi, i) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p, "tx_queue_%u_packets", i);
"tx_queue_%u_packets", i); ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN, "tx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
ice_for_each_alloc_rxq(vsi, i) { ice_for_each_alloc_rxq(vsi, i) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p, "rx_queue_%u_packets", i);
"rx_queue_%u_packets", i); ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
if (vsi->type != ICE_VSI_PF) if (vsi->type != ICE_VSI_PF)
return; return;
for (i = 0; i < ICE_PF_STATS_LEN; i++) { for (i = 0; i < ICE_PF_STATS_LEN; i++)
snprintf(p, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&p,
ice_gstrings_pf_stats[i].stat_string); ice_gstrings_pf_stats[i].stat_string);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) { for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p, "tx_priority_%u_xon.nic", i);
"tx_priority_%u_xon.nic", i); ethtool_sprintf(&p, "tx_priority_%u_xoff.nic", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"tx_priority_%u_xoff.nic", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) { for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN, ethtool_sprintf(&p, "rx_priority_%u_xon.nic", i);
"rx_priority_%u_xon.nic", i); ethtool_sprintf(&p, "rx_priority_%u_xoff.nic", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"rx_priority_%u_xoff.nic", i);
p += ETH_GSTRING_LEN;
} }
break; break;
case ETH_SS_TEST: case ETH_SS_TEST:
memcpy(data, ice_gstrings_test, ICE_TEST_LEN * ETH_GSTRING_LEN); memcpy(data, ice_gstrings_test, ICE_TEST_LEN * ETH_GSTRING_LEN);
break; break;
case ETH_SS_PRIV_FLAGS: case ETH_SS_PRIV_FLAGS:
for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) { for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++)
snprintf(p, ETH_GSTRING_LEN, "%s", ethtool_sprintf(&p, ice_gstrings_priv_flags[i].name);
ice_gstrings_priv_flags[i].name);
p += ETH_GSTRING_LEN;
}
break; break;
default: default:
break; break;
......
...@@ -2347,35 +2347,23 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data) ...@@ -2347,35 +2347,23 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
IGB_TEST_LEN*ETH_GSTRING_LEN); IGB_TEST_LEN*ETH_GSTRING_LEN);
break; break;
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++) { for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++)
memcpy(p, igb_gstrings_stats[i].stat_string, ethtool_sprintf(&p,
ETH_GSTRING_LEN); igb_gstrings_stats[i].stat_string);
p += ETH_GSTRING_LEN; for (i = 0; i < IGB_NETDEV_STATS_LEN; i++)
} ethtool_sprintf(&p,
for (i = 0; i < IGB_NETDEV_STATS_LEN; i++) { igb_gstrings_net_stats[i].stat_string);
memcpy(p, igb_gstrings_net_stats[i].stat_string,
ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < adapter->num_tx_queues; i++) { for (i = 0; i < adapter->num_tx_queues; i++) {
sprintf(p, "tx_queue_%u_packets", i); ethtool_sprintf(&p, "tx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
sprintf(p, "tx_queue_%u_bytes", i); ethtool_sprintf(&p, "tx_queue_%u_restart", i);
p += ETH_GSTRING_LEN;
sprintf(p, "tx_queue_%u_restart", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < adapter->num_rx_queues; i++) { for (i = 0; i < adapter->num_rx_queues; i++) {
sprintf(p, "rx_queue_%u_packets", i); ethtool_sprintf(&p, "rx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
sprintf(p, "rx_queue_%u_bytes", i); ethtool_sprintf(&p, "rx_queue_%u_drops", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "rx_queue_%u_csum_err", i);
sprintf(p, "rx_queue_%u_drops", i); ethtool_sprintf(&p, "rx_queue_%u_alloc_failed", i);
p += ETH_GSTRING_LEN;
sprintf(p, "rx_queue_%u_csum_err", i);
p += ETH_GSTRING_LEN;
sprintf(p, "rx_queue_%u_alloc_failed", i);
p += ETH_GSTRING_LEN;
} }
/* BUG_ON(p - data != IGB_STATS_LEN * ETH_GSTRING_LEN); */ /* BUG_ON(p - data != IGB_STATS_LEN * ETH_GSTRING_LEN); */
break; break;
......
...@@ -1368,45 +1368,33 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, ...@@ -1368,45 +1368,33 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
u8 *data) u8 *data)
{ {
char *p = (char *)data;
unsigned int i; unsigned int i;
u8 *p = data;
switch (stringset) { switch (stringset) {
case ETH_SS_TEST: case ETH_SS_TEST:
for (i = 0; i < IXGBE_TEST_LEN; i++) { for (i = 0; i < IXGBE_TEST_LEN; i++)
memcpy(data, ixgbe_gstrings_test[i], ETH_GSTRING_LEN); ethtool_sprintf(&p, ixgbe_gstrings_test[i]);
data += ETH_GSTRING_LEN;
}
break; break;
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++)
memcpy(p, ixgbe_gstrings_stats[i].stat_string, ethtool_sprintf(&p,
ETH_GSTRING_LEN); ixgbe_gstrings_stats[i].stat_string);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < netdev->num_tx_queues; i++) { for (i = 0; i < netdev->num_tx_queues; i++) {
sprintf(p, "tx_queue_%u_packets", i); ethtool_sprintf(&p, "tx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
sprintf(p, "tx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < IXGBE_NUM_RX_QUEUES; i++) { for (i = 0; i < IXGBE_NUM_RX_QUEUES; i++) {
sprintf(p, "rx_queue_%u_packets", i); ethtool_sprintf(&p, "rx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
sprintf(p, "rx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) { for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) {
sprintf(p, "tx_pb_%u_pxon", i); ethtool_sprintf(&p, "tx_pb_%u_pxon", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "tx_pb_%u_pxoff", i);
sprintf(p, "tx_pb_%u_pxoff", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) { for (i = 0; i < IXGBE_MAX_PACKET_BUFFERS; i++) {
sprintf(p, "rx_pb_%u_pxon", i); ethtool_sprintf(&p, "rx_pb_%u_pxon", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "rx_pb_%u_pxoff", i);
sprintf(p, "rx_pb_%u_pxoff", i);
p += ETH_GSTRING_LEN;
} }
/* BUG_ON(p - data != IXGBE_STATS_LEN * ETH_GSTRING_LEN); */ /* BUG_ON(p - data != IXGBE_STATS_LEN * ETH_GSTRING_LEN); */
break; break;
......
...@@ -419,8 +419,8 @@ nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port, ...@@ -419,8 +419,8 @@ nfp_abm_port_get_stats_strings(struct nfp_app *app, struct nfp_port *port,
return data; return data;
alink = repr->app_priv; alink = repr->app_priv;
for (i = 0; i < alink->vnic->dp.num_r_vecs; i++) { for (i = 0; i < alink->vnic->dp.num_r_vecs; i++) {
data = nfp_pr_et(data, "q%u_no_wait", i); ethtool_sprintf(&data, "q%u_no_wait", i);
data = nfp_pr_et(data, "q%u_delayed", i); ethtool_sprintf(&data, "q%u_delayed", i);
} }
return data; return data;
} }
......
...@@ -429,17 +429,6 @@ static int nfp_net_set_ringparam(struct net_device *netdev, ...@@ -429,17 +429,6 @@ static int nfp_net_set_ringparam(struct net_device *netdev,
return nfp_net_set_ring_size(nn, rxd_cnt, txd_cnt); return nfp_net_set_ring_size(nn, rxd_cnt, txd_cnt);
} }
__printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vsnprintf(data, ETH_GSTRING_LEN, fmt, args);
va_end(args);
return data + ETH_GSTRING_LEN;
}
static unsigned int nfp_vnic_get_sw_stats_count(struct net_device *netdev) static unsigned int nfp_vnic_get_sw_stats_count(struct net_device *netdev)
{ {
struct nfp_net *nn = netdev_priv(netdev); struct nfp_net *nn = netdev_priv(netdev);
...@@ -454,29 +443,29 @@ static u8 *nfp_vnic_get_sw_stats_strings(struct net_device *netdev, u8 *data) ...@@ -454,29 +443,29 @@ static u8 *nfp_vnic_get_sw_stats_strings(struct net_device *netdev, u8 *data)
int i; int i;
for (i = 0; i < nn->max_r_vecs; i++) { for (i = 0; i < nn->max_r_vecs; i++) {
data = nfp_pr_et(data, "rvec_%u_rx_pkts", i); ethtool_sprintf(&data, "rvec_%u_rx_pkts", i);
data = nfp_pr_et(data, "rvec_%u_tx_pkts", i); ethtool_sprintf(&data, "rvec_%u_tx_pkts", i);
data = nfp_pr_et(data, "rvec_%u_tx_busy", i); ethtool_sprintf(&data, "rvec_%u_tx_busy", i);
} }
data = nfp_pr_et(data, "hw_rx_csum_ok"); ethtool_sprintf(&data, "hw_rx_csum_ok");
data = nfp_pr_et(data, "hw_rx_csum_inner_ok"); ethtool_sprintf(&data, "hw_rx_csum_inner_ok");
data = nfp_pr_et(data, "hw_rx_csum_complete"); ethtool_sprintf(&data, "hw_rx_csum_complete");
data = nfp_pr_et(data, "hw_rx_csum_err"); ethtool_sprintf(&data, "hw_rx_csum_err");
data = nfp_pr_et(data, "rx_replace_buf_alloc_fail"); ethtool_sprintf(&data, "rx_replace_buf_alloc_fail");
data = nfp_pr_et(data, "rx_tls_decrypted_packets"); ethtool_sprintf(&data, "rx_tls_decrypted_packets");
data = nfp_pr_et(data, "hw_tx_csum"); ethtool_sprintf(&data, "hw_tx_csum");
data = nfp_pr_et(data, "hw_tx_inner_csum"); ethtool_sprintf(&data, "hw_tx_inner_csum");
data = nfp_pr_et(data, "tx_gather"); ethtool_sprintf(&data, "tx_gather");
data = nfp_pr_et(data, "tx_lso"); ethtool_sprintf(&data, "tx_lso");
data = nfp_pr_et(data, "tx_tls_encrypted_packets"); ethtool_sprintf(&data, "tx_tls_encrypted_packets");
data = nfp_pr_et(data, "tx_tls_ooo"); ethtool_sprintf(&data, "tx_tls_ooo");
data = nfp_pr_et(data, "tx_tls_drop_no_sync_data"); ethtool_sprintf(&data, "tx_tls_drop_no_sync_data");
data = nfp_pr_et(data, "hw_tls_no_space"); ethtool_sprintf(&data, "hw_tls_no_space");
data = nfp_pr_et(data, "rx_tls_resync_req_ok"); ethtool_sprintf(&data, "rx_tls_resync_req_ok");
data = nfp_pr_et(data, "rx_tls_resync_req_ign"); ethtool_sprintf(&data, "rx_tls_resync_req_ign");
data = nfp_pr_et(data, "rx_tls_resync_sent"); ethtool_sprintf(&data, "rx_tls_resync_sent");
return data; return data;
} }
...@@ -550,19 +539,19 @@ nfp_vnic_get_hw_stats_strings(u8 *data, unsigned int num_vecs, bool repr) ...@@ -550,19 +539,19 @@ nfp_vnic_get_hw_stats_strings(u8 *data, unsigned int num_vecs, bool repr)
swap_off = repr * NN_ET_SWITCH_STATS_LEN; swap_off = repr * NN_ET_SWITCH_STATS_LEN;
for (i = 0; i < NN_ET_SWITCH_STATS_LEN; i++) for (i = 0; i < NN_ET_SWITCH_STATS_LEN; i++)
data = nfp_pr_et(data, nfp_net_et_stats[i + swap_off].name); ethtool_sprintf(&data, nfp_net_et_stats[i + swap_off].name);
for (i = NN_ET_SWITCH_STATS_LEN; i < NN_ET_SWITCH_STATS_LEN * 2; i++) for (i = NN_ET_SWITCH_STATS_LEN; i < NN_ET_SWITCH_STATS_LEN * 2; i++)
data = nfp_pr_et(data, nfp_net_et_stats[i - swap_off].name); ethtool_sprintf(&data, nfp_net_et_stats[i - swap_off].name);
for (i = NN_ET_SWITCH_STATS_LEN * 2; i < NN_ET_GLOBAL_STATS_LEN; i++) for (i = NN_ET_SWITCH_STATS_LEN * 2; i < NN_ET_GLOBAL_STATS_LEN; i++)
data = nfp_pr_et(data, nfp_net_et_stats[i].name); ethtool_sprintf(&data, nfp_net_et_stats[i].name);
for (i = 0; i < num_vecs; i++) { for (i = 0; i < num_vecs; i++) {
data = nfp_pr_et(data, "rxq_%u_pkts", i); ethtool_sprintf(&data, "rxq_%u_pkts", i);
data = nfp_pr_et(data, "rxq_%u_bytes", i); ethtool_sprintf(&data, "rxq_%u_bytes", i);
data = nfp_pr_et(data, "txq_%u_pkts", i); ethtool_sprintf(&data, "txq_%u_pkts", i);
data = nfp_pr_et(data, "txq_%u_bytes", i); ethtool_sprintf(&data, "txq_%u_bytes", i);
} }
return data; return data;
...@@ -610,15 +599,15 @@ static u8 *nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 *data) ...@@ -610,15 +599,15 @@ static u8 *nfp_vnic_get_tlv_stats_strings(struct nfp_net *nn, u8 *data)
memcpy(data, nfp_tlv_stat_names[id], ETH_GSTRING_LEN); memcpy(data, nfp_tlv_stat_names[id], ETH_GSTRING_LEN);
data += ETH_GSTRING_LEN; data += ETH_GSTRING_LEN;
} else { } else {
data = nfp_pr_et(data, "dev_unknown_stat%u", id); ethtool_sprintf(&data, "dev_unknown_stat%u", id);
} }
} }
for (i = 0; i < nn->max_r_vecs; i++) { for (i = 0; i < nn->max_r_vecs; i++) {
data = nfp_pr_et(data, "rxq_%u_pkts", i); ethtool_sprintf(&data, "rxq_%u_pkts", i);
data = nfp_pr_et(data, "rxq_%u_bytes", i); ethtool_sprintf(&data, "rxq_%u_bytes", i);
data = nfp_pr_et(data, "txq_%u_pkts", i); ethtool_sprintf(&data, "txq_%u_pkts", i);
data = nfp_pr_et(data, "txq_%u_bytes", i); ethtool_sprintf(&data, "txq_%u_bytes", i);
} }
return data; return data;
...@@ -666,7 +655,7 @@ static u8 *nfp_mac_get_stats_strings(struct net_device *netdev, u8 *data) ...@@ -666,7 +655,7 @@ static u8 *nfp_mac_get_stats_strings(struct net_device *netdev, u8 *data)
return data; return data;
for (i = 0; i < ARRAY_SIZE(nfp_mac_et_stats); i++) for (i = 0; i < ARRAY_SIZE(nfp_mac_et_stats); i++)
data = nfp_pr_et(data, "mac.%s", nfp_mac_et_stats[i].name); ethtool_sprintf(&data, "mac.%s", nfp_mac_et_stats[i].name);
return data; return data;
} }
......
...@@ -92,8 +92,6 @@ struct nfp_port { ...@@ -92,8 +92,6 @@ struct nfp_port {
extern const struct ethtool_ops nfp_port_ethtool_ops; extern const struct ethtool_ops nfp_port_ethtool_ops;
__printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...);
int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type, int nfp_port_setup_tc(struct net_device *netdev, enum tc_setup_type type,
void *type_data); void *type_data);
......
...@@ -246,98 +246,73 @@ static u64 ionic_sw_stats_get_count(struct ionic_lif *lif) ...@@ -246,98 +246,73 @@ static u64 ionic_sw_stats_get_count(struct ionic_lif *lif)
return total; return total;
} }
static void ionic_sw_stats_get_tx_strings(struct ionic_lif *lif, u8 **buf,
int q_num)
{
int i;
for (i = 0; i < IONIC_NUM_TX_STATS; i++)
ethtool_sprintf(buf, "tx_%d_%s", q_num,
ionic_tx_stats_desc[i].name);
if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
!test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
return;
for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++)
ethtool_sprintf(buf, "txq_%d_%s", q_num,
ionic_txq_stats_desc[i].name);
for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++)
ethtool_sprintf(buf, "txq_%d_cq_%s", q_num,
ionic_dbg_cq_stats_desc[i].name);
for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++)
ethtool_sprintf(buf, "txq_%d_intr_%s", q_num,
ionic_dbg_intr_stats_desc[i].name);
for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++)
ethtool_sprintf(buf, "txq_%d_sg_cntr_%d", q_num, i);
}
static void ionic_sw_stats_get_rx_strings(struct ionic_lif *lif, u8 **buf,
int q_num)
{
int i;
for (i = 0; i < IONIC_NUM_RX_STATS; i++)
ethtool_sprintf(buf, "rx_%d_%s", q_num,
ionic_rx_stats_desc[i].name);
if (!test_bit(IONIC_LIF_F_UP, lif->state) ||
!test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state))
return;
for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++)
ethtool_sprintf(buf, "rxq_%d_cq_%s", q_num,
ionic_dbg_cq_stats_desc[i].name);
for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++)
ethtool_sprintf(buf, "rxq_%d_intr_%s", q_num,
ionic_dbg_intr_stats_desc[i].name);
for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++)
ethtool_sprintf(buf, "rxq_%d_napi_%s", q_num,
ionic_dbg_napi_stats_desc[i].name);
for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++)
ethtool_sprintf(buf, "rxq_%d_napi_work_done_%d", q_num, i);
}
static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf) static void ionic_sw_stats_get_strings(struct ionic_lif *lif, u8 **buf)
{ {
int i, q_num; int i, q_num;
for (i = 0; i < IONIC_NUM_LIF_STATS; i++) { for (i = 0; i < IONIC_NUM_LIF_STATS; i++)
snprintf(*buf, ETH_GSTRING_LEN, ionic_lif_stats_desc[i].name); ethtool_sprintf(buf, ionic_lif_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_NUM_PORT_STATS; i++) { for (i = 0; i < IONIC_NUM_PORT_STATS; i++)
snprintf(*buf, ETH_GSTRING_LEN, ethtool_sprintf(buf, ionic_port_stats_desc[i].name);
ionic_port_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (q_num = 0; q_num < MAX_Q(lif); q_num++) { for (q_num = 0; q_num < MAX_Q(lif); q_num++)
for (i = 0; i < IONIC_NUM_TX_STATS; i++) { ionic_sw_stats_get_tx_strings(lif, buf, q_num);
snprintf(*buf, ETH_GSTRING_LEN, "tx_%d_%s",
q_num, ionic_tx_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
if (test_bit(IONIC_LIF_F_UP, lif->state) && for (q_num = 0; q_num < MAX_Q(lif); q_num++)
test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) { ionic_sw_stats_get_rx_strings(lif, buf, q_num);
for (i = 0; i < IONIC_NUM_TX_Q_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"txq_%d_%s",
q_num,
ionic_txq_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"txq_%d_cq_%s",
q_num,
ionic_dbg_cq_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"txq_%d_intr_%s",
q_num,
ionic_dbg_intr_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_MAX_NUM_SG_CNTR; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"txq_%d_sg_cntr_%d",
q_num, i);
*buf += ETH_GSTRING_LEN;
}
}
}
for (q_num = 0; q_num < MAX_Q(lif); q_num++) {
for (i = 0; i < IONIC_NUM_RX_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"rx_%d_%s",
q_num, ionic_rx_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
if (test_bit(IONIC_LIF_F_UP, lif->state) &&
test_bit(IONIC_LIF_F_SW_DEBUG_STATS, lif->state)) {
for (i = 0; i < IONIC_NUM_DBG_CQ_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"rxq_%d_cq_%s",
q_num,
ionic_dbg_cq_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_NUM_DBG_INTR_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"rxq_%d_intr_%s",
q_num,
ionic_dbg_intr_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_NUM_DBG_NAPI_STATS; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"rxq_%d_napi_%s",
q_num,
ionic_dbg_napi_stats_desc[i].name);
*buf += ETH_GSTRING_LEN;
}
for (i = 0; i < IONIC_MAX_NUM_NAPI_CNTR; i++) {
snprintf(*buf, ETH_GSTRING_LEN,
"rxq_%d_napi_work_done_%d",
q_num, i);
*buf += ETH_GSTRING_LEN;
}
}
}
} }
static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf) static void ionic_sw_stats_get_values(struct ionic_lif *lif, u64 **buf)
......
...@@ -1612,34 +1612,23 @@ static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data) ...@@ -1612,34 +1612,23 @@ static void netvsc_get_strings(struct net_device *dev, u32 stringset, u8 *data)
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < ARRAY_SIZE(netvsc_stats); i++) { for (i = 0; i < ARRAY_SIZE(netvsc_stats); i++)
memcpy(p, netvsc_stats[i].name, ETH_GSTRING_LEN); ethtool_sprintf(&p, netvsc_stats[i].name);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < ARRAY_SIZE(vf_stats); i++) { for (i = 0; i < ARRAY_SIZE(vf_stats); i++)
memcpy(p, vf_stats[i].name, ETH_GSTRING_LEN); ethtool_sprintf(&p, vf_stats[i].name);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < nvdev->num_chn; i++) { for (i = 0; i < nvdev->num_chn; i++) {
sprintf(p, "tx_queue_%u_packets", i); ethtool_sprintf(&p, "tx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
sprintf(p, "tx_queue_%u_bytes", i); ethtool_sprintf(&p, "rx_queue_%u_packets", i);
p += ETH_GSTRING_LEN; ethtool_sprintf(&p, "rx_queue_%u_bytes", i);
sprintf(p, "rx_queue_%u_packets", i); ethtool_sprintf(&p, "rx_queue_%u_xdp_drop", i);
p += ETH_GSTRING_LEN;
sprintf(p, "rx_queue_%u_bytes", i);
p += ETH_GSTRING_LEN;
sprintf(p, "rx_queue_%u_xdp_drop", i);
p += ETH_GSTRING_LEN;
} }
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
for (i = 0; i < ARRAY_SIZE(pcpu_stats); i++) { for (i = 0; i < ARRAY_SIZE(pcpu_stats); i++)
sprintf(p, pcpu_stats[i].name, cpu); ethtool_sprintf(&p, pcpu_stats[i].name, cpu);
p += ETH_GSTRING_LEN;
}
} }
break; break;
......
...@@ -2138,25 +2138,21 @@ static int virtnet_set_channels(struct net_device *dev, ...@@ -2138,25 +2138,21 @@ static int virtnet_set_channels(struct net_device *dev,
static void virtnet_get_strings(struct net_device *dev, u32 stringset, u8 *data) static void virtnet_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{ {
struct virtnet_info *vi = netdev_priv(dev); struct virtnet_info *vi = netdev_priv(dev);
char *p = (char *)data;
unsigned int i, j; unsigned int i, j;
u8 *p = data;
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < vi->curr_queue_pairs; i++) { for (i = 0; i < vi->curr_queue_pairs; i++) {
for (j = 0; j < VIRTNET_RQ_STATS_LEN; j++) { for (j = 0; j < VIRTNET_RQ_STATS_LEN; j++)
snprintf(p, ETH_GSTRING_LEN, "rx_queue_%u_%s", ethtool_sprintf(&p, "rx_queue_%u_%s", i,
i, virtnet_rq_stats_desc[j].desc); virtnet_rq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
} }
for (i = 0; i < vi->curr_queue_pairs; i++) { for (i = 0; i < vi->curr_queue_pairs; i++) {
for (j = 0; j < VIRTNET_SQ_STATS_LEN; j++) { for (j = 0; j < VIRTNET_SQ_STATS_LEN; j++)
snprintf(p, ETH_GSTRING_LEN, "tx_queue_%u_%s", ethtool_sprintf(&p, "tx_queue_%u_%s", i,
i, virtnet_sq_stats_desc[j].desc); virtnet_sq_stats_desc[j].desc);
p += ETH_GSTRING_LEN;
}
} }
break; break;
} }
......
...@@ -218,43 +218,28 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) ...@@ -218,43 +218,28 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
static void static void
vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
{ {
struct vmxnet3_adapter *adapter = netdev_priv(netdev); struct vmxnet3_adapter *adapter = netdev_priv(netdev);
if (stringset == ETH_SS_STATS) { int i, j;
int i, j;
for (j = 0; j < adapter->num_tx_queues; j++) {
for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++) {
memcpy(buf, vmxnet3_tq_dev_stats[i].desc,
ETH_GSTRING_LEN);
buf += ETH_GSTRING_LEN;
}
for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats);
i++) {
memcpy(buf, vmxnet3_tq_driver_stats[i].desc,
ETH_GSTRING_LEN);
buf += ETH_GSTRING_LEN;
}
}
for (j = 0; j < adapter->num_rx_queues; j++) { if (stringset != ETH_SS_STATS)
for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++) { return;
memcpy(buf, vmxnet3_rq_dev_stats[i].desc,
ETH_GSTRING_LEN);
buf += ETH_GSTRING_LEN;
}
for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats);
i++) {
memcpy(buf, vmxnet3_rq_driver_stats[i].desc,
ETH_GSTRING_LEN);
buf += ETH_GSTRING_LEN;
}
}
for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++) { for (j = 0; j < adapter->num_tx_queues; j++) {
memcpy(buf, vmxnet3_global_stats[i].desc, for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_dev_stats); i++)
ETH_GSTRING_LEN); ethtool_sprintf(&buf, vmxnet3_tq_dev_stats[i].desc);
buf += ETH_GSTRING_LEN; for (i = 0; i < ARRAY_SIZE(vmxnet3_tq_driver_stats); i++)
} ethtool_sprintf(&buf, vmxnet3_tq_driver_stats[i].desc);
}
for (j = 0; j < adapter->num_rx_queues; j++) {
for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_dev_stats); i++)
ethtool_sprintf(&buf, vmxnet3_rq_dev_stats[i].desc);
for (i = 0; i < ARRAY_SIZE(vmxnet3_rq_driver_stats); i++)
ethtool_sprintf(&buf, vmxnet3_rq_driver_stats[i].desc);
} }
for (i = 0; i < ARRAY_SIZE(vmxnet3_global_stats); i++)
ethtool_sprintf(&buf, vmxnet3_global_stats[i].desc);
} }
netdev_features_t vmxnet3_fix_features(struct net_device *netdev, netdev_features_t vmxnet3_fix_features(struct net_device *netdev,
......
...@@ -571,4 +571,13 @@ struct ethtool_phy_ops { ...@@ -571,4 +571,13 @@ struct ethtool_phy_ops {
*/ */
void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops); void ethtool_set_ethtool_phy_ops(const struct ethtool_phy_ops *ops);
/**
* ethtool_sprintf - Write formatted string to ethtool string data
* @data: Pointer to start of string to update
* @fmt: Format of string to write
*
* Write formatted string to data. Update data to point at start of
* next string.
*/
extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);
#endif /* _LINUX_ETHTOOL_H */ #endif /* _LINUX_ETHTOOL_H */
...@@ -1844,6 +1844,18 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) ...@@ -1844,6 +1844,18 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
return ret; return ret;
} }
__printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vsnprintf(*data, ETH_GSTRING_LEN, fmt, args);
va_end(args);
*data += ETH_GSTRING_LEN;
}
EXPORT_SYMBOL(ethtool_sprintf);
static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) static int ethtool_phys_id(struct net_device *dev, void __user *useraddr)
{ {
struct ethtool_value id; struct ethtool_value id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment