@@ -559,15 +559,20 @@ static int xsc_eth_open_qp_sq(struct xsc_channel *c,
559559 u8 ele_log_size = psq_param -> sq_attr .ele_log_size ;
560560 u8 q_log_size = psq_param -> sq_attr .q_log_size ;
561561 struct xsc_modify_raw_qp_mbox_in * modify_in ;
562+ struct xsc_channel_stats * channel_stats ;
562563 struct xsc_create_qp_mbox_in * in ;
563564 struct xsc_core_device * xdev ;
564565 struct xsc_adapter * adapter ;
566+ struct xsc_stats * stats ;
565567 unsigned int hw_npages ;
566568 int inlen ;
567569 int ret ;
568570
569571 adapter = c -> adapter ;
570572 xdev = adapter -> xdev ;
573+ stats = adapter -> stats ;
574+ channel_stats = & stats -> channel_stats [c -> chl_idx ];
575+ psq -> stats = & channel_stats -> sq [sq_idx ];
571576 psq_param -> wq .db_numa_node = cpu_to_node (c -> cpu );
572577
573578 ret = xsc_eth_wq_cyc_create (xdev , & psq_param -> wq ,
@@ -868,11 +873,16 @@ static int xsc_eth_alloc_rq(struct xsc_channel *c,
868873 u8 q_log_size = prq_param -> rq_attr .q_log_size ;
869874 struct page_pool_params pagepool_params = {0 };
870875 struct xsc_adapter * adapter = c -> adapter ;
876+ struct xsc_channel_stats * channel_stats ;
871877 u32 pool_size = 1 << q_log_size ;
878+ struct xsc_stats * stats ;
872879 int ret = 0 ;
873880 u32 wq_sz ;
874881 int i , f ;
875882
883+ stats = c -> adapter -> stats ;
884+ channel_stats = & stats -> channel_stats [c -> chl_idx ];
885+ prq -> stats = & channel_stats -> rq ;
876886 prq_param -> wq .db_numa_node = cpu_to_node (c -> cpu );
877887
878888 ret = xsc_eth_wq_cyc_create (c -> adapter -> xdev , & prq_param -> wq ,
@@ -1653,6 +1663,14 @@ static int xsc_eth_close(struct net_device *netdev)
16531663 return ret ;
16541664}
16551665
1666+ static void xsc_eth_get_stats (struct net_device * netdev ,
1667+ struct rtnl_link_stats64 * stats )
1668+ {
1669+ struct xsc_adapter * adapter = netdev_priv (netdev );
1670+
1671+ xsc_eth_fold_sw_stats64 (adapter , stats );
1672+ }
1673+
16561674static int xsc_eth_set_hw_mtu (struct xsc_core_device * xdev ,
16571675 u16 mtu , u16 rx_buf_sz )
16581676{
@@ -1684,6 +1702,7 @@ static const struct net_device_ops xsc_netdev_ops = {
16841702 .ndo_open = xsc_eth_open ,
16851703 .ndo_stop = xsc_eth_close ,
16861704 .ndo_start_xmit = xsc_eth_xmit_start ,
1705+ .ndo_get_stats64 = xsc_eth_get_stats ,
16871706};
16881707
16891708static void xsc_eth_build_nic_netdev (struct xsc_adapter * adapter )
@@ -1897,14 +1916,22 @@ static int xsc_eth_probe(struct auxiliary_device *adev,
18971916 goto err_nic_cleanup ;
18981917 }
18991918
1919+ adapter -> stats = kvzalloc (sizeof (* adapter -> stats ), GFP_KERNEL );
1920+ if (!adapter -> stats ) {
1921+ err = - ENOMEM ;
1922+ goto err_detach ;
1923+ }
1924+
19001925 err = register_netdev (netdev );
19011926 if (err ) {
19021927 netdev_err (netdev , "register_netdev failed, err=%d\n" , err );
1903- goto err_detach ;
1928+ goto err_free_stats ;
19041929 }
19051930
19061931 return 0 ;
19071932
1933+ err_free_stats :
1934+ kvfree (adapter -> stats );
19081935err_detach :
19091936 xsc_eth_detach (xdev , adapter );
19101937err_nic_cleanup :
@@ -1929,7 +1956,7 @@ static void xsc_eth_remove(struct auxiliary_device *adev)
19291956 return ;
19301957
19311958 unregister_netdev (adapter -> netdev );
1932-
1959+ kvfree ( adapter -> stats );
19331960 free_netdev (adapter -> netdev );
19341961
19351962 xdev -> eth_priv = NULL ;
0 commit comments