Commit 634287ba authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: add helper for printing ethtool strings

Add a helper for printing ethtool strings and advancing the
pointer correctly.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1cfcc97b
...@@ -335,53 +335,52 @@ static int nfp_net_set_ringparam(struct net_device *netdev, ...@@ -335,53 +335,52 @@ 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);
} }
static __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 void nfp_net_get_strings(struct net_device *netdev, static void nfp_net_get_strings(struct net_device *netdev,
u32 stringset, u8 *data) u32 stringset, u8 *data)
{ {
struct nfp_net *nn = netdev_priv(netdev); struct nfp_net *nn = netdev_priv(netdev);
u8 *p = data;
int i; int i;
switch (stringset) { switch (stringset) {
case ETH_SS_STATS: case ETH_SS_STATS:
for (i = 0; i < NN_ET_GLOBAL_STATS_LEN; i++) { for (i = 0; i < NN_ET_GLOBAL_STATS_LEN; i++)
memcpy(p, nfp_net_et_stats[i].name, ETH_GSTRING_LEN); data = nfp_pr_et(data, nfp_net_et_stats[i].name);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < nn->dp.num_r_vecs; i++) { for (i = 0; i < nn->dp.num_r_vecs; i++) {
sprintf(p, "rvec_%u_rx_pkts", i); data = nfp_pr_et(data, "rvec_%u_rx_pkts", i);
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "rvec_%u_tx_pkts", i);
sprintf(p, "rvec_%u_tx_pkts", i); data = nfp_pr_et(data, "rvec_%u_tx_busy", i);
p += ETH_GSTRING_LEN;
sprintf(p, "rvec_%u_tx_busy", i);
p += ETH_GSTRING_LEN;
} }
strncpy(p, "hw_rx_csum_ok", ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "hw_rx_csum_ok");
strncpy(p, "hw_rx_csum_inner_ok", ETH_GSTRING_LEN); data = nfp_pr_et(data, "hw_rx_csum_inner_ok");
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "hw_rx_csum_err");
strncpy(p, "hw_rx_csum_err", ETH_GSTRING_LEN); data = nfp_pr_et(data, "hw_tx_csum");
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "hw_tx_inner_csum");
strncpy(p, "hw_tx_csum", ETH_GSTRING_LEN); data = nfp_pr_et(data, "tx_gather");
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "tx_lso");
strncpy(p, "hw_tx_inner_csum", ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
strncpy(p, "tx_gather", ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
strncpy(p, "tx_lso", ETH_GSTRING_LEN);
p += ETH_GSTRING_LEN;
for (i = 0; i < nn->dp.num_tx_rings; i++) { for (i = 0; i < nn->dp.num_tx_rings; i++) {
sprintf(p, "txq_%u_pkts", i); data = nfp_pr_et(data, "txq_%u_pkts", i);
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "txq_%u_bytes", i);
sprintf(p, "txq_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
for (i = 0; i < nn->dp.num_rx_rings; i++) { for (i = 0; i < nn->dp.num_rx_rings; i++) {
sprintf(p, "rxq_%u_pkts", i); data = nfp_pr_et(data, "rxq_%u_pkts", i);
p += ETH_GSTRING_LEN; data = nfp_pr_et(data, "rxq_%u_bytes", i);
sprintf(p, "rxq_%u_bytes", i);
p += ETH_GSTRING_LEN;
} }
break; break;
} }
} }
......
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