netdev
[Top] [All Lists]

[PATCH] net: allow controlling NAPI weight with sysfs

To: "David S. Miller" <davem@xxxxxxxxxxxxx>
Subject: [PATCH] net: allow controlling NAPI weight with sysfs
From: Stephen Hemminger <shemminger@xxxxxxxx>
Date: Thu, 2 Jun 2005 11:14:37 -0700
Cc: Mitch Williams <mitch.a.williams@xxxxxxxxx>, netdev@xxxxxxxxxxx, john.ronciak@xxxxxxxxx, ganesh.venkatesan@xxxxxxxxx, jesse.brandeburg@xxxxxxxxx
In-reply-to: <Pine.CYG.4.58.0505261406210.2364@mawilli1-desk2.amr.corp.intel.com>
Organization: Open Source Development Lab
References: <Pine.CYG.4.58.0505261406210.2364@mawilli1-desk2.amr.corp.intel.com>
Sender: netdev-bounce@xxxxxxxxxxx
Simple interface to allow changing network device scheduling weight
with sysfs. Please consider this for 2.6.12, since risk/impact is small.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxx>

Index: napi-sysfs/net/core/net-sysfs.c
===================================================================
--- napi-sysfs.orig/net/core/net-sysfs.c
+++ napi-sysfs/net/core/net-sysfs.c
@@ -184,6 +184,22 @@ static ssize_t store_tx_queue_len(struct
 static CLASS_DEVICE_ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, 
                         store_tx_queue_len);
 
+NETDEVICE_SHOW(weight, fmt_ulong);
+
+static int change_weight(struct net_device *net, unsigned long new_weight)
+{
+       net->weight = new_weight;
+       return 0;
+}
+
+static ssize_t store_weight(struct class_device *dev, const char *buf, size_t 
len)
+{
+       return netdev_store(dev, buf, len, change_weight);
+}
+
+static CLASS_DEVICE_ATTR(weight, S_IRUGO | S_IWUSR, show_weight, 
+                        store_weight);
+
 
 static struct class_device_attribute *net_class_attributes[] = {
        &class_device_attr_ifindex,
@@ -193,6 +209,7 @@ static struct class_device_attribute *ne
        &class_device_attr_features,
        &class_device_attr_mtu,
        &class_device_attr_flags,
+       &class_device_attr_weight,
        &class_device_attr_type,
        &class_device_attr_address,
        &class_device_attr_broadcast,

<Prev in Thread] Current Thread [Next in Thread>