netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: add real_num_[tr]x_queues to ifinfo
@ 2020-01-30 17:57 Dmitry Yakunin
  2020-01-30 18:32 ` Michal Kubecek
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Yakunin @ 2020-01-30 17:57 UTC (permalink / raw)
  To: davem, kuba; +Cc: netdev

This patch adds the number of active tx/rx queues to ifinfo message.

Now there are two ways of determining the number of active queues:
1) by counting entries in /sys/class/net/eth[0-9]+/queues/
2) by ioctl syscall if a driver implements ethtool_ops->get_channels()

Default mq qdisc sets up pfifo_fast only for active queues. So, if we want
to reproduce this behavior with custom leaf qdiscs, we should use one
of these methods which are foreign for the code where netlink was used.

Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru>
---
 include/uapi/linux/if_link.h | 2 ++
 net/core/rtnetlink.c         | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 8aec876..6566b63 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -169,6 +169,8 @@ enum {
 	IFLA_MAX_MTU,
 	IFLA_PROP_LIST,
 	IFLA_ALT_IFNAME, /* Alternative ifname */
+	IFLA_REAL_NUM_TX_QUEUES,
+	IFLA_REAL_NUM_RX_QUEUES,
 	__IFLA_MAX
 };
 
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d9001b5..3ebae18 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1013,7 +1013,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
 	       + nla_total_size(1) /* IFLA_CARRIER */
 	       + nla_total_size(4) /* IFLA_PROMISCUITY */
 	       + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
+	       + nla_total_size(4) /* IFLA_REAL_NUM_TX_QUEUES */
 	       + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
+	       + nla_total_size(4) /* IFLA_REAL_NUM_RX_QUEUES */
 	       + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */
 	       + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */
 	       + nla_total_size(1) /* IFLA_OPERSTATE */
@@ -1687,10 +1689,12 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 	    nla_put_u32(skb, IFLA_GROUP, dev->group) ||
 	    nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
 	    nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) ||
+	    nla_put_u32(skb, IFLA_REAL_NUM_TX_QUEUES, dev->real_num_tx_queues) ||
 	    nla_put_u32(skb, IFLA_GSO_MAX_SEGS, dev->gso_max_segs) ||
 	    nla_put_u32(skb, IFLA_GSO_MAX_SIZE, dev->gso_max_size) ||
 #ifdef CONFIG_RPS
 	    nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
+	    nla_put_u32(skb, IFLA_REAL_NUM_RX_QUEUES, dev->real_num_rx_queues) ||
 #endif
 	    put_master_ifindex(skb, dev) ||
 	    nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
@@ -1803,7 +1807,9 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
 	[IFLA_EXT_MASK]		= { .type = NLA_U32 },
 	[IFLA_PROMISCUITY]	= { .type = NLA_U32 },
 	[IFLA_NUM_TX_QUEUES]	= { .type = NLA_U32 },
+	[IFLA_REAL_NUM_TX_QUEUES] = { .type = NLA_U32 },
 	[IFLA_NUM_RX_QUEUES]	= { .type = NLA_U32 },
+	[IFLA_REAL_NUM_RX_QUEUES] = { .type = NLA_U32 },
 	[IFLA_GSO_MAX_SEGS]	= { .type = NLA_U32 },
 	[IFLA_GSO_MAX_SIZE]	= { .type = NLA_U32 },
 	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] netlink: add real_num_[tr]x_queues to ifinfo
  2020-01-30 17:57 [PATCH] netlink: add real_num_[tr]x_queues to ifinfo Dmitry Yakunin
@ 2020-01-30 18:32 ` Michal Kubecek
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Kubecek @ 2020-01-30 18:32 UTC (permalink / raw)
  To: netdev; +Cc: Dmitry Yakunin, davem, kuba

On Thu, Jan 30, 2020 at 08:57:49PM +0300, Dmitry Yakunin wrote:
> This patch adds the number of active tx/rx queues to ifinfo message.
> 
> Now there are two ways of determining the number of active queues:
> 1) by counting entries in /sys/class/net/eth[0-9]+/queues/
> 2) by ioctl syscall if a driver implements ethtool_ops->get_channels()
> 
> Default mq qdisc sets up pfifo_fast only for active queues. So, if we want
> to reproduce this behavior with custom leaf qdiscs, we should use one
> of these methods which are foreign for the code where netlink was used.

Netlink interface for get_channels() and set_channels() ethtool_ops is
one of the first I plan to submit when net-next is open again after the
merge window.

Michal

> 
> Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru>
> ---
>  include/uapi/linux/if_link.h | 2 ++
>  net/core/rtnetlink.c         | 6 ++++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index 8aec876..6566b63 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -169,6 +169,8 @@ enum {
>  	IFLA_MAX_MTU,
>  	IFLA_PROP_LIST,
>  	IFLA_ALT_IFNAME, /* Alternative ifname */
> +	IFLA_REAL_NUM_TX_QUEUES,
> +	IFLA_REAL_NUM_RX_QUEUES,
>  	__IFLA_MAX
>  };
>  
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index d9001b5..3ebae18 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -1013,7 +1013,9 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev,
>  	       + nla_total_size(1) /* IFLA_CARRIER */
>  	       + nla_total_size(4) /* IFLA_PROMISCUITY */
>  	       + nla_total_size(4) /* IFLA_NUM_TX_QUEUES */
> +	       + nla_total_size(4) /* IFLA_REAL_NUM_TX_QUEUES */
>  	       + nla_total_size(4) /* IFLA_NUM_RX_QUEUES */
> +	       + nla_total_size(4) /* IFLA_REAL_NUM_RX_QUEUES */
>  	       + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */
>  	       + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */
>  	       + nla_total_size(1) /* IFLA_OPERSTATE */
> @@ -1687,10 +1689,12 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
>  	    nla_put_u32(skb, IFLA_GROUP, dev->group) ||
>  	    nla_put_u32(skb, IFLA_PROMISCUITY, dev->promiscuity) ||
>  	    nla_put_u32(skb, IFLA_NUM_TX_QUEUES, dev->num_tx_queues) ||
> +	    nla_put_u32(skb, IFLA_REAL_NUM_TX_QUEUES, dev->real_num_tx_queues) ||
>  	    nla_put_u32(skb, IFLA_GSO_MAX_SEGS, dev->gso_max_segs) ||
>  	    nla_put_u32(skb, IFLA_GSO_MAX_SIZE, dev->gso_max_size) ||
>  #ifdef CONFIG_RPS
>  	    nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) ||
> +	    nla_put_u32(skb, IFLA_REAL_NUM_RX_QUEUES, dev->real_num_rx_queues) ||
>  #endif
>  	    put_master_ifindex(skb, dev) ||
>  	    nla_put_u8(skb, IFLA_CARRIER, netif_carrier_ok(dev)) ||
> @@ -1803,7 +1807,9 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = {
>  	[IFLA_EXT_MASK]		= { .type = NLA_U32 },
>  	[IFLA_PROMISCUITY]	= { .type = NLA_U32 },
>  	[IFLA_NUM_TX_QUEUES]	= { .type = NLA_U32 },
> +	[IFLA_REAL_NUM_TX_QUEUES] = { .type = NLA_U32 },
>  	[IFLA_NUM_RX_QUEUES]	= { .type = NLA_U32 },
> +	[IFLA_REAL_NUM_RX_QUEUES] = { .type = NLA_U32 },
>  	[IFLA_GSO_MAX_SEGS]	= { .type = NLA_U32 },
>  	[IFLA_GSO_MAX_SIZE]	= { .type = NLA_U32 },
>  	[IFLA_PHYS_PORT_ID]	= { .type = NLA_BINARY, .len = MAX_PHYS_ITEM_ID_LEN },
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-30 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-30 17:57 [PATCH] netlink: add real_num_[tr]x_queues to ifinfo Dmitry Yakunin
2020-01-30 18:32 ` Michal Kubecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).