20
20
#include <linux/netdevice.h>
21
21
#include <linux/slab.h>
22
22
#include <net/netdev_queues.h>
23
+ #include <net/netdev_rx_queue.h>
23
24
#include <net/page_pool/helpers.h>
24
25
#include <net/netlink.h>
25
26
#include <net/net_shaper.h>
29
30
30
31
#include "netdevsim.h"
31
32
33
+ MODULE_IMPORT_NS ("NETDEV_INTERNAL" );
34
+
32
35
#define NSIM_RING_SIZE 256
33
36
34
37
static int nsim_napi_rx (struct nsim_rq * rq , struct sk_buff * skb )
@@ -722,6 +725,54 @@ static const struct netdev_queue_mgmt_ops nsim_queue_mgmt_ops = {
722
725
.ndo_queue_stop = nsim_queue_stop ,
723
726
};
724
727
728
+ static ssize_t
729
+ nsim_qreset_write (struct file * file , const char __user * data ,
730
+ size_t count , loff_t * ppos )
731
+ {
732
+ struct netdevsim * ns = file -> private_data ;
733
+ unsigned int queue , mode ;
734
+ char buf [32 ];
735
+ ssize_t ret ;
736
+
737
+ if (count >= sizeof (buf ))
738
+ return - EINVAL ;
739
+ if (copy_from_user (buf , data , count ))
740
+ return - EFAULT ;
741
+ buf [count ] = '\0' ;
742
+
743
+ ret = sscanf (buf , "%u %u" , & queue , & mode );
744
+ if (ret != 2 )
745
+ return - EINVAL ;
746
+
747
+ rtnl_lock ();
748
+ if (!netif_running (ns -> netdev )) {
749
+ ret = - ENETDOWN ;
750
+ goto exit_unlock ;
751
+ }
752
+
753
+ if (queue >= ns -> netdev -> real_num_rx_queues ) {
754
+ ret = - EINVAL ;
755
+ goto exit_unlock ;
756
+ }
757
+
758
+ ns -> rq_reset_mode = mode ;
759
+ ret = netdev_rx_queue_restart (ns -> netdev , queue );
760
+ ns -> rq_reset_mode = 0 ;
761
+ if (ret )
762
+ goto exit_unlock ;
763
+
764
+ ret = count ;
765
+ exit_unlock :
766
+ rtnl_unlock ();
767
+ return ret ;
768
+ }
769
+
770
+ static const struct file_operations nsim_qreset_fops = {
771
+ .open = simple_open ,
772
+ .write = nsim_qreset_write ,
773
+ .owner = THIS_MODULE ,
774
+ };
775
+
725
776
static ssize_t
726
777
nsim_pp_hold_read (struct file * file , char __user * data ,
727
778
size_t count , loff_t * ppos )
@@ -934,6 +985,9 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port)
934
985
935
986
ns -> pp_dfs = debugfs_create_file ("pp_hold" , 0600 , nsim_dev_port -> ddir ,
936
987
ns , & nsim_pp_hold_fops );
988
+ ns -> qr_dfs = debugfs_create_file ("queue_reset" , 0200 ,
989
+ nsim_dev_port -> ddir , ns ,
990
+ & nsim_qreset_fops );
937
991
938
992
return ns ;
939
993
@@ -947,6 +1001,7 @@ void nsim_destroy(struct netdevsim *ns)
947
1001
struct net_device * dev = ns -> netdev ;
948
1002
struct netdevsim * peer ;
949
1003
1004
+ debugfs_remove (ns -> qr_dfs );
950
1005
debugfs_remove (ns -> pp_dfs );
951
1006
952
1007
rtnl_lock ();
0 commit comments