Commit 8eab9cfd authored by Shannon Nelson's avatar Shannon Nelson Committed by Jeff Kirsher

i40e: add VEB stats to ethtool

Print the VEB statistics in the ethtool stats output.

Change-ID: Ic93d4c3922345c43e4cfd7f7e7a906844dd2f49f
Signed-off-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 1bb8b935
...@@ -46,6 +46,8 @@ struct i40e_stats { ...@@ -46,6 +46,8 @@ struct i40e_stats {
I40E_STAT(struct i40e_pf, _name, _stat) I40E_STAT(struct i40e_pf, _name, _stat)
#define I40E_VSI_STAT(_name, _stat) \ #define I40E_VSI_STAT(_name, _stat) \
I40E_STAT(struct i40e_vsi, _name, _stat) I40E_STAT(struct i40e_vsi, _name, _stat)
#define I40E_VEB_STAT(_name, _stat) \
I40E_STAT(struct i40e_veb, _name, _stat)
static const struct i40e_stats i40e_gstrings_net_stats[] = { static const struct i40e_stats i40e_gstrings_net_stats[] = {
I40E_NETDEV_STAT(rx_packets), I40E_NETDEV_STAT(rx_packets),
...@@ -62,6 +64,21 @@ static const struct i40e_stats i40e_gstrings_net_stats[] = { ...@@ -62,6 +64,21 @@ static const struct i40e_stats i40e_gstrings_net_stats[] = {
I40E_NETDEV_STAT(rx_crc_errors), I40E_NETDEV_STAT(rx_crc_errors),
}; };
static const struct i40e_stats i40e_gstrings_veb_stats[] = {
I40E_VEB_STAT("rx_bytes", stats.rx_bytes),
I40E_VEB_STAT("tx_bytes", stats.tx_bytes),
I40E_VEB_STAT("rx_unicast", stats.rx_unicast),
I40E_VEB_STAT("tx_unicast", stats.tx_unicast),
I40E_VEB_STAT("rx_multicast", stats.rx_multicast),
I40E_VEB_STAT("tx_multicast", stats.tx_multicast),
I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast),
I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast),
I40E_VEB_STAT("rx_discards", stats.rx_discards),
I40E_VEB_STAT("tx_discards", stats.tx_discards),
I40E_VEB_STAT("tx_errors", stats.tx_errors),
I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol),
};
static const struct i40e_stats i40e_gstrings_misc_stats[] = { static const struct i40e_stats i40e_gstrings_misc_stats[] = {
I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol), I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol),
I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast), I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast),
...@@ -142,6 +159,7 @@ static struct i40e_stats i40e_gstrings_stats[] = { ...@@ -142,6 +159,7 @@ static struct i40e_stats i40e_gstrings_stats[] = {
FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \ FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \
FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \ FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \
/ sizeof(u64)) / sizeof(u64))
#define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats)
#define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \ #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \
I40E_PFC_STATS_LEN + \ I40E_PFC_STATS_LEN + \
I40E_VSI_STATS_LEN((n))) I40E_VSI_STATS_LEN((n)))
...@@ -627,10 +645,15 @@ static int i40e_get_sset_count(struct net_device *netdev, int sset) ...@@ -627,10 +645,15 @@ static int i40e_get_sset_count(struct net_device *netdev, int sset)
case ETH_SS_TEST: case ETH_SS_TEST:
return I40E_TEST_LEN; return I40E_TEST_LEN;
case ETH_SS_STATS: case ETH_SS_STATS:
if (vsi == pf->vsi[pf->lan_vsi]) if (vsi == pf->vsi[pf->lan_vsi]) {
return I40E_PF_STATS_LEN(netdev); int len = I40E_PF_STATS_LEN(netdev);
else
if (pf->lan_veb != I40E_NO_VEB)
len += I40E_VEB_STATS_LEN;
return len;
} else {
return I40E_VSI_STATS_LEN(netdev); return I40E_VSI_STATS_LEN(netdev);
}
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -686,23 +709,33 @@ static void i40e_get_ethtool_stats(struct net_device *netdev, ...@@ -686,23 +709,33 @@ static void i40e_get_ethtool_stats(struct net_device *netdev,
i += 2; i += 2;
} }
rcu_read_unlock(); rcu_read_unlock();
if (vsi == pf->vsi[pf->lan_vsi]) { if (vsi != pf->vsi[pf->lan_vsi])
for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) { return;
p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
data[i++] = (i40e_gstrings_stats[j].sizeof_stat == if (pf->lan_veb != I40E_NO_VEB) {
sizeof(u64)) ? *(u64 *)p : *(u32 *)p; struct i40e_veb *veb = pf->veb[pf->lan_veb];
} for (j = 0; j < I40E_VEB_STATS_LEN; j++) {
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) { p = (char *)veb;
data[i++] = pf->stats.priority_xon_tx[j]; p += i40e_gstrings_veb_stats[j].stat_offset;
data[i++] = pf->stats.priority_xoff_tx[j]; data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat ==
} sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
data[i++] = pf->stats.priority_xon_rx[j];
data[i++] = pf->stats.priority_xoff_rx[j];
} }
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
data[i++] = pf->stats.priority_xon_2_xoff[j];
} }
for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) {
p = (char *)pf + i40e_gstrings_stats[j].stat_offset;
data[i++] = (i40e_gstrings_stats[j].sizeof_stat ==
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
data[i++] = pf->stats.priority_xon_tx[j];
data[i++] = pf->stats.priority_xoff_tx[j];
}
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) {
data[i++] = pf->stats.priority_xon_rx[j];
data[i++] = pf->stats.priority_xoff_rx[j];
}
for (j = 0; j < I40E_MAX_USER_PRIORITY; j++)
data[i++] = pf->stats.priority_xon_2_xoff[j];
} }
static void i40e_get_strings(struct net_device *netdev, u32 stringset, static void i40e_get_strings(struct net_device *netdev, u32 stringset,
...@@ -742,34 +775,42 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset, ...@@ -742,34 +775,42 @@ static void i40e_get_strings(struct net_device *netdev, u32 stringset,
snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i); snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i);
p += ETH_GSTRING_LEN; p += ETH_GSTRING_LEN;
} }
if (vsi == pf->vsi[pf->lan_vsi]) { if (vsi != pf->vsi[pf->lan_vsi])
for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) { return;
snprintf(p, ETH_GSTRING_LEN, "port.%s",
i40e_gstrings_stats[i].stat_string); if (pf->lan_veb != I40E_NO_VEB) {
p += ETH_GSTRING_LEN; for (i = 0; i < I40E_VEB_STATS_LEN; i++) {
} snprintf(p, ETH_GSTRING_LEN, "veb.%s",
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) { i40e_gstrings_veb_stats[i].stat_string);
snprintf(p, ETH_GSTRING_LEN,
"port.tx_priority_%u_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"port.tx_priority_%u_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xon_2_xoff", i);
p += ETH_GSTRING_LEN; p += ETH_GSTRING_LEN;
} }
} }
for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) {
snprintf(p, ETH_GSTRING_LEN, "port.%s",
i40e_gstrings_stats[i].stat_string);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
"port.tx_priority_%u_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"port.tx_priority_%u_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xon", i);
p += ETH_GSTRING_LEN;
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xoff", i);
p += ETH_GSTRING_LEN;
}
for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) {
snprintf(p, ETH_GSTRING_LEN,
"port.rx_priority_%u_xon_2_xoff", i);
p += ETH_GSTRING_LEN;
}
/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */ /* BUG_ON(p - data != I40E_STATS_LEN * 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