@@ -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
6066int 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
7180void 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
173194void 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}
188213EXPORT_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}
387415EXPORT_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 ;
0 commit comments