@@ -37,6 +37,8 @@ static unsigned int aq_itr_rx;
3737module_param_named (aq_itr_rx , aq_itr_rx , uint , 0644 );
3838MODULE_PARM_DESC (aq_itr_rx , "RX interrupt throttle rate" );
3939
40+ static void aq_nic_update_ndev_stats (struct aq_nic_s * self );
41+
4042static void aq_nic_rss_init (struct aq_nic_s * self , unsigned int num_rss_queues )
4143{
4244 struct aq_nic_cfg_s * cfg = & self -> aq_nic_cfg ;
@@ -166,11 +168,8 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)
166168static void aq_nic_service_timer_cb (struct timer_list * t )
167169{
168170 struct aq_nic_s * self = from_timer (self , t , service_timer );
169- struct net_device * ndev = aq_nic_get_ndev ( self ) ;
171+ int ctimer = AQ_CFG_SERVICE_TIMER_INTERVAL ;
170172 int err = 0 ;
171- unsigned int i = 0U ;
172- struct aq_ring_stats_rx_s stats_rx ;
173- struct aq_ring_stats_tx_s stats_tx ;
174173
175174 if (aq_utils_obj_test (& self -> header .flags , AQ_NIC_FLAGS_IS_NOT_READY ))
176175 goto err_exit ;
@@ -182,23 +181,14 @@ static void aq_nic_service_timer_cb(struct timer_list *t)
182181 if (self -> aq_hw_ops .hw_update_stats )
183182 self -> aq_hw_ops .hw_update_stats (self -> aq_hw );
184183
185- memset (& stats_rx , 0U , sizeof (struct aq_ring_stats_rx_s ));
186- memset (& stats_tx , 0U , sizeof (struct aq_ring_stats_tx_s ));
187- for (i = AQ_DIMOF (self -> aq_vec ); i -- ;) {
188- if (self -> aq_vec [i ])
189- aq_vec_add_stats (self -> aq_vec [i ], & stats_rx , & stats_tx );
190- }
184+ aq_nic_update_ndev_stats (self );
191185
192- ndev -> stats .rx_packets = stats_rx .packets ;
193- ndev -> stats .rx_bytes = stats_rx .bytes ;
194- ndev -> stats .rx_errors = stats_rx .errors ;
195- ndev -> stats .tx_packets = stats_tx .packets ;
196- ndev -> stats .tx_bytes = stats_tx .bytes ;
197- ndev -> stats .tx_errors = stats_tx .errors ;
186+ /* If no link - use faster timer rate to detect link up asap */
187+ if (!netif_carrier_ok (self -> ndev ))
188+ ctimer = max (ctimer / 2 , 1 );
198189
199190err_exit :
200- mod_timer (& self -> service_timer ,
201- jiffies + AQ_CFG_SERVICE_TIMER_INTERVAL );
191+ mod_timer (& self -> service_timer , jiffies + ctimer );
202192}
203193
204194static void aq_nic_polling_timer_cb (struct timer_list * t )
@@ -222,7 +212,7 @@ static struct net_device *aq_nic_ndev_alloc(void)
222212
223213struct aq_nic_s * aq_nic_alloc_cold (const struct net_device_ops * ndev_ops ,
224214 const struct ethtool_ops * et_ops ,
225- struct device * dev ,
215+ struct pci_dev * pdev ,
226216 struct aq_pci_func_s * aq_pci_func ,
227217 unsigned int port ,
228218 const struct aq_hw_ops * aq_hw_ops )
@@ -242,7 +232,7 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
242232 ndev -> netdev_ops = ndev_ops ;
243233 ndev -> ethtool_ops = et_ops ;
244234
245- SET_NETDEV_DEV (ndev , dev );
235+ SET_NETDEV_DEV (ndev , & pdev -> dev );
246236
247237 ndev -> if_port = port ;
248238 self -> ndev = ndev ;
@@ -254,7 +244,8 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
254244
255245 self -> aq_hw = self -> aq_hw_ops .create (aq_pci_func , self -> port ,
256246 & self -> aq_hw_ops );
257- err = self -> aq_hw_ops .get_hw_caps (self -> aq_hw , & self -> aq_hw_caps );
247+ err = self -> aq_hw_ops .get_hw_caps (self -> aq_hw , & self -> aq_hw_caps ,
248+ pdev -> device , pdev -> subsystem_device );
258249 if (err < 0 )
259250 goto err_exit ;
260251
@@ -749,16 +740,40 @@ int aq_nic_get_regs_count(struct aq_nic_s *self)
749740
750741void aq_nic_get_stats (struct aq_nic_s * self , u64 * data )
751742{
752- struct aq_vec_s * aq_vec = NULL ;
753743 unsigned int i = 0U ;
754744 unsigned int count = 0U ;
755- int err = 0 ;
745+ struct aq_vec_s * aq_vec = NULL ;
746+ struct aq_stats_s * stats = self -> aq_hw_ops .hw_get_hw_stats (self -> aq_hw );
756747
757- err = self -> aq_hw_ops .hw_get_hw_stats (self -> aq_hw , data , & count );
758- if (err < 0 )
748+ if (!stats )
759749 goto err_exit ;
760750
761- data += count ;
751+ data [i ] = stats -> uprc + stats -> mprc + stats -> bprc ;
752+ data [++ i ] = stats -> uprc ;
753+ data [++ i ] = stats -> mprc ;
754+ data [++ i ] = stats -> bprc ;
755+ data [++ i ] = stats -> erpt ;
756+ data [++ i ] = stats -> uptc + stats -> mptc + stats -> bptc ;
757+ data [++ i ] = stats -> uptc ;
758+ data [++ i ] = stats -> mptc ;
759+ data [++ i ] = stats -> bptc ;
760+ data [++ i ] = stats -> ubrc ;
761+ data [++ i ] = stats -> ubtc ;
762+ data [++ i ] = stats -> mbrc ;
763+ data [++ i ] = stats -> mbtc ;
764+ data [++ i ] = stats -> bbrc ;
765+ data [++ i ] = stats -> bbtc ;
766+ data [++ i ] = stats -> ubrc + stats -> mbrc + stats -> bbrc ;
767+ data [++ i ] = stats -> ubtc + stats -> mbtc + stats -> bbtc ;
768+ data [++ i ] = stats -> dma_pkt_rc ;
769+ data [++ i ] = stats -> dma_pkt_tc ;
770+ data [++ i ] = stats -> dma_oct_rc ;
771+ data [++ i ] = stats -> dma_oct_tc ;
772+ data [++ i ] = stats -> dpc ;
773+
774+ i ++ ;
775+
776+ data += i ;
762777 count = 0U ;
763778
764779 for (i = 0U , aq_vec = self -> aq_vec [0 ];
@@ -768,7 +783,20 @@ void aq_nic_get_stats(struct aq_nic_s *self, u64 *data)
768783 }
769784
770785err_exit :;
771- (void )err ;
786+ }
787+
788+ static void aq_nic_update_ndev_stats (struct aq_nic_s * self )
789+ {
790+ struct net_device * ndev = self -> ndev ;
791+ struct aq_stats_s * stats = self -> aq_hw_ops .hw_get_hw_stats (self -> aq_hw );
792+
793+ ndev -> stats .rx_packets = stats -> uprc + stats -> mprc + stats -> bprc ;
794+ ndev -> stats .rx_bytes = stats -> ubrc + stats -> mbrc + stats -> bbrc ;
795+ ndev -> stats .rx_errors = stats -> erpr ;
796+ ndev -> stats .tx_packets = stats -> uptc + stats -> mptc + stats -> bptc ;
797+ ndev -> stats .tx_bytes = stats -> ubtc + stats -> mbtc + stats -> bbtc ;
798+ ndev -> stats .tx_errors = stats -> erpt ;
799+ ndev -> stats .multicast = stats -> mprc ;
772800}
773801
774802void aq_nic_get_link_ksettings (struct aq_nic_s * self ,
0 commit comments