77
88#include "../libwx/wx_ethtool.h"
99#include "../libwx/wx_type.h"
10+ #include "../libwx/wx_lib.h"
11+ #include "../libwx/wx_hw.h"
1012#include "ngbe_ethtool.h"
13+ #include "ngbe_type.h"
1114
1215static void ngbe_get_wol (struct net_device * netdev ,
1316 struct ethtool_wolinfo * wol )
@@ -41,6 +44,54 @@ static int ngbe_set_wol(struct net_device *netdev,
4144 return 0 ;
4245}
4346
47+ static int ngbe_set_ringparam (struct net_device * netdev ,
48+ struct ethtool_ringparam * ring ,
49+ struct kernel_ethtool_ringparam * kernel_ring ,
50+ struct netlink_ext_ack * extack )
51+ {
52+ struct wx * wx = netdev_priv (netdev );
53+ u32 new_rx_count , new_tx_count ;
54+ struct wx_ring * temp_ring ;
55+ int i ;
56+
57+ new_tx_count = clamp_t (u32 , ring -> tx_pending , WX_MIN_TXD , WX_MAX_TXD );
58+ new_tx_count = ALIGN (new_tx_count , WX_REQ_TX_DESCRIPTOR_MULTIPLE );
59+
60+ new_rx_count = clamp_t (u32 , ring -> rx_pending , WX_MIN_RXD , WX_MAX_RXD );
61+ new_rx_count = ALIGN (new_rx_count , WX_REQ_RX_DESCRIPTOR_MULTIPLE );
62+
63+ if (new_tx_count == wx -> tx_ring_count &&
64+ new_rx_count == wx -> rx_ring_count )
65+ return 0 ;
66+
67+ if (!netif_running (wx -> netdev )) {
68+ for (i = 0 ; i < wx -> num_tx_queues ; i ++ )
69+ wx -> tx_ring [i ]-> count = new_tx_count ;
70+ for (i = 0 ; i < wx -> num_rx_queues ; i ++ )
71+ wx -> rx_ring [i ]-> count = new_rx_count ;
72+ wx -> tx_ring_count = new_tx_count ;
73+ wx -> rx_ring_count = new_rx_count ;
74+
75+ return 0 ;
76+ }
77+
78+ /* allocate temporary buffer to store rings in */
79+ i = max_t (int , wx -> num_tx_queues , wx -> num_rx_queues );
80+ temp_ring = kvmalloc_array (i , sizeof (struct wx_ring ), GFP_KERNEL );
81+ if (!temp_ring )
82+ return - ENOMEM ;
83+
84+ ngbe_down (wx );
85+
86+ wx_set_ring (wx , new_tx_count , new_rx_count , temp_ring );
87+ kvfree (temp_ring );
88+
89+ wx_configure (wx );
90+ ngbe_up (wx );
91+
92+ return 0 ;
93+ }
94+
4495static const struct ethtool_ops ngbe_ethtool_ops = {
4596 .get_drvinfo = wx_get_drvinfo ,
4697 .get_link = ethtool_op_get_link ,
@@ -56,6 +107,8 @@ static const struct ethtool_ops ngbe_ethtool_ops = {
56107 .get_pause_stats = wx_get_pause_stats ,
57108 .get_pauseparam = wx_get_pauseparam ,
58109 .set_pauseparam = wx_set_pauseparam ,
110+ .get_ringparam = wx_get_ringparam ,
111+ .set_ringparam = ngbe_set_ringparam ,
59112};
60113
61114void ngbe_set_ethtool_ops (struct net_device * netdev )
0 commit comments