Skip to content

Commit 34744a7

Browse files
Jiawen WuPaolo Abeni
authored andcommitted
net: txgbe: add FDIR info to ethtool ops
Add flow director filter match and miss statistics to ethtool -S. And change the number of queues when using flow director for ehtool -l. Signed-off-by: Jiawen Wu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4bdb441 commit 34744a7

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

drivers/net/ethernet/wangxun/libwx/wx_ethtool.c

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ static const struct wx_stats wx_gstrings_stats[] = {
4343
WX_STAT("alloc_rx_buff_failed", alloc_rx_buff_failed),
4444
};
4545

46+
static const struct wx_stats wx_gstrings_fdir_stats[] = {
47+
WX_STAT("fdir_match", stats.fdirmatch),
48+
WX_STAT("fdir_miss", stats.fdirmiss),
49+
};
50+
4651
/* drivers allocates num_tx_queues and num_rx_queues symmetrically so
4752
* we set the num_rx_queues to evaluate to num_tx_queues. This is
4853
* used because we do not have a good way to get the max number of
@@ -55,13 +60,17 @@ static const struct wx_stats wx_gstrings_stats[] = {
5560
(WX_NUM_TX_QUEUES + WX_NUM_RX_QUEUES) * \
5661
(sizeof(struct wx_queue_stats) / sizeof(u64)))
5762
#define WX_GLOBAL_STATS_LEN ARRAY_SIZE(wx_gstrings_stats)
63+
#define WX_FDIR_STATS_LEN ARRAY_SIZE(wx_gstrings_fdir_stats)
5864
#define WX_STATS_LEN (WX_GLOBAL_STATS_LEN + WX_QUEUE_STATS_LEN)
5965

6066
int wx_get_sset_count(struct net_device *netdev, int sset)
6167
{
68+
struct wx *wx = netdev_priv(netdev);
69+
6270
switch (sset) {
6371
case ETH_SS_STATS:
64-
return WX_STATS_LEN;
72+
return (wx->mac.type == wx_mac_sp) ?
73+
WX_STATS_LEN + WX_FDIR_STATS_LEN : WX_STATS_LEN;
6574
default:
6675
return -EOPNOTSUPP;
6776
}
@@ -70,13 +79,18 @@ EXPORT_SYMBOL(wx_get_sset_count);
7079

7180
void wx_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
7281
{
82+
struct wx *wx = netdev_priv(netdev);
7383
u8 *p = data;
7484
int i;
7585

7686
switch (stringset) {
7787
case ETH_SS_STATS:
7888
for (i = 0; i < WX_GLOBAL_STATS_LEN; i++)
7989
ethtool_puts(&p, wx_gstrings_stats[i].stat_string);
90+
if (wx->mac.type == wx_mac_sp) {
91+
for (i = 0; i < WX_FDIR_STATS_LEN; i++)
92+
ethtool_puts(&p, wx_gstrings_fdir_stats[i].stat_string);
93+
}
8094
for (i = 0; i < netdev->num_tx_queues; i++) {
8195
ethtool_sprintf(&p, "tx_queue_%u_packets", i);
8296
ethtool_sprintf(&p, "tx_queue_%u_bytes", i);
@@ -96,7 +110,7 @@ void wx_get_ethtool_stats(struct net_device *netdev,
96110
struct wx *wx = netdev_priv(netdev);
97111
struct wx_ring *ring;
98112
unsigned int start;
99-
int i, j;
113+
int i, j, k;
100114
char *p;
101115

102116
wx_update_stats(wx);
@@ -107,6 +121,13 @@ void wx_get_ethtool_stats(struct net_device *netdev,
107121
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
108122
}
109123

124+
if (wx->mac.type == wx_mac_sp) {
125+
for (k = 0; k < WX_FDIR_STATS_LEN; k++) {
126+
p = (char *)wx + wx_gstrings_fdir_stats[k].stat_offset;
127+
data[i++] = *(u64 *)p;
128+
}
129+
}
130+
110131
for (j = 0; j < netdev->num_tx_queues; j++) {
111132
ring = wx->tx_ring[j];
112133
if (!ring) {
@@ -172,17 +193,21 @@ EXPORT_SYMBOL(wx_get_pause_stats);
172193

173194
void wx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info)
174195
{
196+
unsigned int stats_len = WX_STATS_LEN;
175197
struct wx *wx = netdev_priv(netdev);
176198

199+
if (wx->mac.type == wx_mac_sp)
200+
stats_len += WX_FDIR_STATS_LEN;
201+
177202
strscpy(info->driver, wx->driver_name, sizeof(info->driver));
178203
strscpy(info->fw_version, wx->eeprom_id, sizeof(info->fw_version));
179204
strscpy(info->bus_info, pci_name(wx->pdev), sizeof(info->bus_info));
180205
if (wx->num_tx_queues <= WX_NUM_TX_QUEUES) {
181-
info->n_stats = WX_STATS_LEN -
206+
info->n_stats = stats_len -
182207
(WX_NUM_TX_QUEUES - wx->num_tx_queues) *
183208
(sizeof(struct wx_queue_stats) / sizeof(u64)) * 2;
184209
} else {
185-
info->n_stats = WX_STATS_LEN;
210+
info->n_stats = stats_len;
186211
}
187212
}
188213
EXPORT_SYMBOL(wx_get_drvinfo);
@@ -383,6 +408,9 @@ void wx_get_channels(struct net_device *dev,
383408

384409
/* record RSS queues */
385410
ch->combined_count = wx->ring_feature[RING_F_RSS].indices;
411+
412+
if (test_bit(WX_FLAG_FDIR_CAPABLE, wx->flags))
413+
ch->combined_count = wx->ring_feature[RING_F_FDIR].indices;
386414
}
387415
EXPORT_SYMBOL(wx_get_channels);
388416

@@ -400,6 +428,9 @@ int wx_set_channels(struct net_device *dev,
400428
if (count > wx_max_channels(wx))
401429
return -EINVAL;
402430

431+
if (test_bit(WX_FLAG_FDIR_CAPABLE, wx->flags))
432+
wx->ring_feature[RING_F_FDIR].limit = count;
433+
403434
wx->ring_feature[RING_F_RSS].limit = count;
404435

405436
return 0;

drivers/net/ethernet/wangxun/libwx/wx_hw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,11 @@ void wx_update_stats(struct wx *wx)
23522352
hwstats->b2ogprc += rd32(wx, WX_RDM_BMC2OS_CNT);
23532353
hwstats->rdmdrop += rd32(wx, WX_RDM_DRP_PKT);
23542354

2355+
if (wx->mac.type == wx_mac_sp) {
2356+
hwstats->fdirmatch += rd32(wx, WX_RDB_FDIR_MATCH);
2357+
hwstats->fdirmiss += rd32(wx, WX_RDB_FDIR_MISS);
2358+
}
2359+
23552360
for (i = 0; i < wx->mac.max_rx_queues; i++)
23562361
hwstats->qmprc += rd32(wx, WX_PX_MPRC(i));
23572362
}

drivers/net/ethernet/wangxun/libwx/wx_type.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@
157157
#define WX_RDB_RA_CTL_RSS_IPV6_TCP BIT(21)
158158
#define WX_RDB_RA_CTL_RSS_IPV4_UDP BIT(22)
159159
#define WX_RDB_RA_CTL_RSS_IPV6_UDP BIT(23)
160+
#define WX_RDB_FDIR_MATCH 0x19558
161+
#define WX_RDB_FDIR_MISS 0x1955C
160162

161163
/******************************* PSR Registers *******************************/
162164
/* psr control */
@@ -1018,6 +1020,8 @@ struct wx_hw_stats {
10181020
u64 crcerrs;
10191021
u64 rlec;
10201022
u64 qmprc;
1023+
u64 fdirmatch;
1024+
u64 fdirmiss;
10211025
};
10221026

10231027
enum wx_state {

0 commit comments

Comments
 (0)