On Tue, 8 Dec 2020 16:54:44 -0800 Wei Wang wrote:
+static void dev_disable_threaded_all(struct net_device *dev)
+{
+ struct napi_struct *napi;
+
+ list_for_each_entry(napi, &dev->napi_list, dev_list)
+ napi_set_threaded(napi, false);
+}
This is an implementation detail which should be hidden in dev.c IMHO.
Since the sysfs knob is just a device global on/off the iteration over
napis and all is best hidden away.
(sorry about the delayed review BTW, hope we can do a minor revision
and still hit 5.12)
+static int modify_napi_threaded(struct net_device *dev, unsigned long val)
+{
+ struct napi_struct *napi;
+ int ret;
+
+ if (list_empty(&dev->napi_list))
+ return -EOPNOTSUPP;
+
+ list_for_each_entry(napi, &dev->napi_list, dev_list) {
+ ret = napi_set_threaded(napi, !!val);
+ if (ret) {
+ /* Error occurred on one of the napi,
+ * reset threaded mode on all napi.
+ */
+ dev_disable_threaded_all(dev);
+ break;
+ }
+ }
+
+ return ret;
+}