Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1434213 > unrolled thread

[PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN

Started byJason Wang <jasowang@redhat.com>
First post2016-06-30 06:10 +0200
Last post2016-06-30 09:00 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN Jason Wang <jasowang@redhat.com> - 2016-06-30 06:10 +0200
    Re: [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN John Fastabend <john.fastabend@gmail.com> - 2016-06-30 07:00 +0200
      Re: [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN Jason Wang <jasowang@redhat.com> - 2016-06-30 07:20 +0200
        Re: [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN Jason Wang <jasowang@redhat.com> - 2016-06-30 08:10 +0200
          Re: [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN Jason Wang <jasowang@redhat.com> - 2016-06-30 09:00 +0200

#1434213 — [PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN

FromJason Wang <jasowang@redhat.com>
Date2016-06-30 06:10 +0200
Subject[PATCH net-next V3 5/6] net: introduce NETDEV_CHANGE_TX_QUEUE_LEN
Message-ID<rPBsB-4Qn-5@gated-at.bofh.it>
This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
will be triggered when tx_queue_len. It could be used by net device
who want to do some processing at that time. An example is tun who may
want to resize tx array when tx_queue_len is changed.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 include/linux/netdevice.h |  1 +
 net/core/net-sysfs.c      | 15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index e84d9d2..7dc2ec7 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
 #define NETDEV_PRECHANGEUPPER	0x001A
 #define NETDEV_CHANGELOWERSTATE	0x001B
 #define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C
+#define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E
 
 int register_netdevice_notifier(struct notifier_block *nb);
 int unregister_netdevice_notifier(struct notifier_block *nb);
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 7a0b616..6e4f347 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
 
 static int change_tx_queue_len(struct net_device *dev, unsigned long new_len)
 {
-	dev->tx_queue_len = new_len;
+	int res, orig_len = dev->tx_queue_len;
+
+	if (new_len != orig_len) {
+		dev->tx_queue_len = new_len;
+		res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
+		res = notifier_to_errno(res);
+		if (res) {
+			netdev_err(dev,
+				   "refused to change device tx_queue_len\n");
+			dev->tx_queue_len = orig_len;
+			return -EFAULT;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1434224

FromJohn Fastabend <john.fastabend@gmail.com>
Date2016-06-30 07:00 +0200
Message-ID<rPCf0-59c-5@gated-at.bofh.it>
In reply to#1434213
On 16-06-29 08:52 PM, Jason Wang wrote:
> This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
> will be triggered when tx_queue_len. It could be used by net device
> who want to do some processing at that time. An example is tun who may
> want to resize tx array when tx_queue_len is changed.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  include/linux/netdevice.h |  1 +
>  net/core/net-sysfs.c      | 15 ++++++++++++++-
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index e84d9d2..7dc2ec7 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
>  #define NETDEV_PRECHANGEUPPER	0x001A
>  #define NETDEV_CHANGELOWERSTATE	0x001B
>  #define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C
> +#define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E
>  
>  int register_netdevice_notifier(struct notifier_block *nb);
>  int unregister_netdevice_notifier(struct notifier_block *nb);
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 7a0b616..6e4f347 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
>  
>  static int change_tx_queue_len(struct net_device *dev, unsigned long new_len)
>  {
> -	dev->tx_queue_len = new_len;
> +	int res, orig_len = dev->tx_queue_len;
> +
> +	if (new_len != orig_len) {
> +		dev->tx_queue_len = new_len;
> +		res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
> +		res = notifier_to_errno(res);
> +		if (res) {
> +			netdev_err(dev,
> +				   "refused to change device tx_queue_len\n");
> +			dev->tx_queue_len = orig_len;
> +			return -EFAULT;
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> 

Acked-by: John Fastabend <john.r.fastabend@intel.com>

Great timing I was just looking into this because I need it for the
qdisc side.

It looks like this covers the sysfs change but the tx_queue_len can
also be changed via rtnetlink as well. So we need another patch for
that path right?

        if (tb[IFLA_TXQLEN]) {
                unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);

                if (dev->tx_queue_len ^ value)
                        status |= DO_SETLINK_NOTIFY;

                dev->tx_queue_len = value;
        }

Thanks,
John

[toc] | [prev] | [next] | [standalone]


#1434226

FromJason Wang <jasowang@redhat.com>
Date2016-06-30 07:20 +0200
Message-ID<rPCyl-5vz-5@gated-at.bofh.it>
In reply to#1434224

On 2016年06月30日 12:56, John Fastabend wrote:
> On 16-06-29 08:52 PM, Jason Wang wrote:
>> This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
>> will be triggered when tx_queue_len. It could be used by net device
>> who want to do some processing at that time. An example is tun who may
>> want to resize tx array when tx_queue_len is changed.
>>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> ---
>>   include/linux/netdevice.h |  1 +
>>   net/core/net-sysfs.c      | 15 ++++++++++++++-
>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index e84d9d2..7dc2ec7 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
>>   #define NETDEV_PRECHANGEUPPER	0x001A
>>   #define NETDEV_CHANGELOWERSTATE	0x001B
>>   #define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C
>> +#define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E
>>   
>>   int register_netdevice_notifier(struct notifier_block *nb);
>>   int unregister_netdevice_notifier(struct notifier_block *nb);
>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>> index 7a0b616..6e4f347 100644
>> --- a/net/core/net-sysfs.c
>> +++ b/net/core/net-sysfs.c
>> @@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
>>   
>>   static int change_tx_queue_len(struct net_device *dev, unsigned long new_len)
>>   {
>> -	dev->tx_queue_len = new_len;
>> +	int res, orig_len = dev->tx_queue_len;
>> +
>> +	if (new_len != orig_len) {
>> +		dev->tx_queue_len = new_len;
>> +		res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
>> +		res = notifier_to_errno(res);
>> +		if (res) {
>> +			netdev_err(dev,
>> +				   "refused to change device tx_queue_len\n");
>> +			dev->tx_queue_len = orig_len;
>> +			return -EFAULT;
>> +		}
>> +	}
>> +
>>   	return 0;
>>   }
>>   
>>
> Acked-by: John Fastabend <john.r.fastabend@intel.com>
>
> Great timing I was just looking into this because I need it for the
> qdisc side.
>
> It looks like this covers the sysfs change but the tx_queue_len can
> also be changed via rtnetlink as well. So we need another patch for
> that path right?
>
>          if (tb[IFLA_TXQLEN]) {
>                  unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
>
>                  if (dev->tx_queue_len ^ value)
>                          status |= DO_SETLINK_NOTIFY;
>
>                  dev->tx_queue_len = value;
>          }
>
> Thanks,
> John
>

Right, will do this in next version.

Thanks

[toc] | [prev] | [next] | [standalone]


#1434238

FromJason Wang <jasowang@redhat.com>
Date2016-06-30 08:10 +0200
Message-ID<rPDkJ-60E-9@gated-at.bofh.it>
In reply to#1434226

On 2016年06月30日 13:12, Jason Wang wrote:
>
>
> On 2016年06月30日 12:56, John Fastabend wrote:
>> On 16-06-29 08:52 PM, Jason Wang wrote:
>>> This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
>>> will be triggered when tx_queue_len. It could be used by net device
>>> who want to do some processing at that time. An example is tun who may
>>> want to resize tx array when tx_queue_len is changed.
>>>
>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>> ---
>>>   include/linux/netdevice.h |  1 +
>>>   net/core/net-sysfs.c      | 15 ++++++++++++++-
>>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>>> index e84d9d2..7dc2ec7 100644
>>> --- a/include/linux/netdevice.h
>>> +++ b/include/linux/netdevice.h
>>> @@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
>>>   #define NETDEV_PRECHANGEUPPER    0x001A
>>>   #define NETDEV_CHANGELOWERSTATE    0x001B
>>>   #define NETDEV_UDP_TUNNEL_PUSH_INFO    0x001C
>>> +#define NETDEV_CHANGE_TX_QUEUE_LEN    0x001E
>>>     int register_netdevice_notifier(struct notifier_block *nb);
>>>   int unregister_netdevice_notifier(struct notifier_block *nb);
>>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>>> index 7a0b616..6e4f347 100644
>>> --- a/net/core/net-sysfs.c
>>> +++ b/net/core/net-sysfs.c
>>> @@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
>>>     static int change_tx_queue_len(struct net_device *dev, unsigned 
>>> long new_len)
>>>   {
>>> -    dev->tx_queue_len = new_len;
>>> +    int res, orig_len = dev->tx_queue_len;
>>> +
>>> +    if (new_len != orig_len) {
>>> +        dev->tx_queue_len = new_len;
>>> +        res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, 
>>> dev);
>>> +        res = notifier_to_errno(res);
>>> +        if (res) {
>>> +            netdev_err(dev,
>>> +                   "refused to change device tx_queue_len\n");
>>> +            dev->tx_queue_len = orig_len;
>>> +            return -EFAULT;
>>> +        }
>>> +    }
>>> +
>>>       return 0;
>>>   }
>>>
>> Acked-by: John Fastabend <john.r.fastabend@intel.com>
>>
>> Great timing I was just looking into this because I need it for the
>> qdisc side.
>>
>> It looks like this covers the sysfs change but the tx_queue_len can
>> also be changed via rtnetlink as well. So we need another patch for
>> that path right?
>>
>>          if (tb[IFLA_TXQLEN]) {
>>                  unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
>>
>>                  if (dev->tx_queue_len ^ value)
>>                          status |= DO_SETLINK_NOTIFY;
>>
>>                  dev->tx_queue_len = value;
>>          }
>>
>> Thanks,
>> John
>>
>
> Right, will do this in next version.
>
> Thanks

Ok, since Michael has acked on the series, will prepare a patch on top.

Thanks

[toc] | [prev] | [next] | [standalone]


#1434265

FromJason Wang <jasowang@redhat.com>
Date2016-06-30 09:00 +0200
Message-ID<rPE77-6hp-7@gated-at.bofh.it>
In reply to#1434238

On 2016年06月30日 13:59, Jason Wang wrote:
>
>
> On 2016年06月30日 13:12, Jason Wang wrote:
>>
>>
>> On 2016年06月30日 12:56, John Fastabend wrote:
>>> On 16-06-29 08:52 PM, Jason Wang wrote:
>>>> This patch introduces a new event - NETDEV_CHANGE_TX_QUEUE_LEN, this
>>>> will be triggered when tx_queue_len. It could be used by net device
>>>> who want to do some processing at that time. An example is tun who may
>>>> want to resize tx array when tx_queue_len is changed.
>>>>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> ---
>>>>   include/linux/netdevice.h |  1 +
>>>>   net/core/net-sysfs.c      | 15 ++++++++++++++-
>>>>   2 files changed, 15 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>>>> index e84d9d2..7dc2ec7 100644
>>>> --- a/include/linux/netdevice.h
>>>> +++ b/include/linux/netdevice.h
>>>> @@ -2237,6 +2237,7 @@ struct netdev_lag_lower_state_info {
>>>>   #define NETDEV_PRECHANGEUPPER    0x001A
>>>>   #define NETDEV_CHANGELOWERSTATE    0x001B
>>>>   #define NETDEV_UDP_TUNNEL_PUSH_INFO    0x001C
>>>> +#define NETDEV_CHANGE_TX_QUEUE_LEN    0x001E
>>>>     int register_netdevice_notifier(struct notifier_block *nb);
>>>>   int unregister_netdevice_notifier(struct notifier_block *nb);
>>>> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
>>>> index 7a0b616..6e4f347 100644
>>>> --- a/net/core/net-sysfs.c
>>>> +++ b/net/core/net-sysfs.c
>>>> @@ -322,7 +322,20 @@ NETDEVICE_SHOW_RW(flags, fmt_hex);
>>>>     static int change_tx_queue_len(struct net_device *dev, unsigned 
>>>> long new_len)
>>>>   {
>>>> -    dev->tx_queue_len = new_len;
>>>> +    int res, orig_len = dev->tx_queue_len;
>>>> +
>>>> +    if (new_len != orig_len) {
>>>> +        dev->tx_queue_len = new_len;
>>>> +        res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, 
>>>> dev);
>>>> +        res = notifier_to_errno(res);
>>>> +        if (res) {
>>>> +            netdev_err(dev,
>>>> +                   "refused to change device tx_queue_len\n");
>>>> +            dev->tx_queue_len = orig_len;
>>>> +            return -EFAULT;
>>>> +        }
>>>> +    }
>>>> +
>>>>       return 0;
>>>>   }
>>>>
>>> Acked-by: John Fastabend <john.r.fastabend@intel.com>
>>>
>>> Great timing I was just looking into this because I need it for the
>>> qdisc side.
>>>
>>> It looks like this covers the sysfs change but the tx_queue_len can
>>> also be changed via rtnetlink as well. So we need another patch for
>>> that path right?
>>>
>>>          if (tb[IFLA_TXQLEN]) {
>>>                  unsigned long value = nla_get_u32(tb[IFLA_TXQLEN]);
>>>
>>>                  if (dev->tx_queue_len ^ value)
>>>                          status |= DO_SETLINK_NOTIFY;
>>>
>>>                  dev->tx_queue_len = value;
>>>          }
>>>
>>> Thanks,
>>> John
>>>
>>
>> Right, will do this in next version.
>>
>> Thanks
>
> Ok, since Michael has acked on the series, will prepare a patch on top.
>
> Thanks 

Since kbuild test robot has found a minor issue on this series, I will 
post v4 with this fixed.

Thanks

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web