net: implement mechanism for HW based QOS
Subsystems (3)
PATCH v2 1/3 net: implement mechanism for HW based QOS
This patch provides a mechanism for lower layer devices to steer traffic using skb->priority to tx queues. This allows for hardware based QOS schemes to use the default qdisc without incurring the penalties related to global state and the qdisc lock. While reliably receiving skbs on the correct tx ring to avoid head of line blocking resulting from shuffling in the LLD. Finally, all the goodness from txq caching and xps/rps can still be leveraged.
Many drivers and hardware exist with the ability to implement QOS schemes in the hardware but currently these drivers tend to rely on firmware to reroute specific traffic, a driver specific select_queue or the queue_mapping action in the qdisc.
By using select_queue for this drivers need to be updated for each and every traffic type and we lose the goodness of much of the upstream work. Firmware solutions are inherently inflexible. And finally if admins are expected to build a qdisc and filter rules to steer traffic this requires knowledge of how the hardware is currently configured. The number of tx queues and the queue offsets may change depending on resources. Also this approach incurs all the overhead of a qdisc with filters.
With the mechanism in this patch users can set skb priority using expected methods ie setsockopt() or the stack can set the priority directly. Then the skb will be steered to the correct tx queues aligned with hardware QOS traffic classes. In the normal case with a single traffic class and all queues in this class everything works as is until the LLD enables multiple tcs.
To steer the skb we mask out the lower 4 bits of the priority and allow the hardware to configure upto 15 distinct classes of traffic. This is expected to be sufficient for most applications at any rate it is more then the 8021Q spec designates and is equal to the number of prio bands currently implemented in the default qdisc.
This in conjunction with a userspace application such as lldpad can be used to implement 8021Q transmission selection algorithms one of these algorithms being the extended transmission selection algorithm currently being used for DCB.
---
include/linux/netdevice.h | 62 +++++++++++++++++++++++++++++++++++++++++++++ net/core/dev.c | 10 +++++++ 2 files changed, 71 insertions(+), 1 deletions(-)
include/linux/netdevice.h +62 -0
@@ -646,6 +646,14 @@ struct xps_dev_maps { (nr_cpu_ids * sizeof(struct xps_map *)))#endif /* CONFIG_XPS */ +#define TC_MAX_QUEUE 16 +#define TC_BITMASK 15 +/* HW offloaded queuing disciplines txq count and offset maps */ +struct netdev_tc_txq { +u16 count; +u16 offset; +}; +/* * This structure defines the management hooks for network devices. * The following hooks can be defined; unless noted otherwise, they are
@@ -1146,6 +1154,9 @@ struct net_device {/* Data Center Bridging netlink ops */ const struct dcbnl_rtnl_ops *dcbnl_ops;#endif +u8 num_tc; +struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE ]; +u8 prio_tc_map[TC_MAX_QUEUE ];#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE )/* max exchange id for FCoE LRO by ddp */
@@ -1162,6 +1173,57 @@ struct net_device {#define NETDEV_ALIGN 32static inline +int netdev_get_prio_tc_map (const struct net_device *dev,u32 prio) +{ +return dev->prio_tc_map[prio &TC_BITMASK ]; +} + +static inline +int netdev_set_prio_tc_map (struct net_device *dev,u8 prio,u8 tc) +{ +if (tc >= dev->num_tc) +return -EINVAL ; + + dev->prio_tc_map[prio &TC_BITMASK ] = tc &TC_BITMASK ; +return 0 ; +} + +static inline +void netdev_reset_tc (struct net_device *dev) +{ + dev->num_tc =0 ; +memset (dev->tc_to_txq,0 ,sizeof (dev->tc_to_txq)); +memset (dev->prio_tc_map,0 ,sizeof (dev->prio_tc_map)); +} + +static inline +int netdev_set_tc_queue (struct net_device *dev,u8 tc,u16 count,u16 offset) +{ +if (tc >= dev->num_tc) +return -EINVAL ; + + dev->tc_to_txq[tc].count = count; + dev->tc_to_txq[tc].offset = offset; +return 0 ; +} + +static inline +int netdev_set_num_tc (struct net_device *dev,u8 num_tc) +{ +if (num_tc >TC_MAX_QUEUE ) +return -EINVAL ; + + dev->num_tc = num_tc; +return 0 ; +} + +static inline +u8 netdev_get_num_tc (const struct net_device *dev) +{ +return dev->num_tc; +} + +static inline struct netdev_queue *netdev_get_tx_queue (const struct net_device *dev,unsigned int index) {
net/core/dev.c +9 -1
@@ -2170,6 +2170,8 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb, unsigned int num_tx_queues) {u32 hash; +u16 qoffset =0 ; +u16 qcount = num_tx_queues;if (skb_rx_queue_recorded (skb)) { hash =skb_get_rx_queue (skb);
@@ -2178,13 +2180,19 @@ u16 __skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb,return hash; } +if (dev->num_tc) { +u8 tc =netdev_get_prio_tc_map (dev, skb->priority); + qoffset = dev->tc_to_txq[tc].offset; + qcount = dev->tc_to_txq[tc].count; + } +if (skb->sk && skb->sk->sk_hash) hash = skb->sk->sk_hash;else hash = (__force u16 ) skb->protocol ^ skb->rxhash; hash =jhash_1word (hash, hashrnd); -return (u16) (((u64 ) hash * num_tx_queues) >>32 ); +return (u16) (((u64 ) hash * qcount) >>32 ) + qoffset; }EXPORT_SYMBOL (__skb_tx_hash);
PATCH v2 2/3 net_sched: Allow multiple mq qdisc to be used as non-root
This patch modifies the mq qdisc to allow multiple mq qdiscs to be used. Allowing TX queues to be grouped for management.
This allows a root container qdisc to create multiple traffic classes and use the mq qdisc as a default queueing discipline. It is expected other queueing disciplines can then be grafted to the container as needed.
---
net/sched/sch_mq.c | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 37 insertions(+), 15 deletions(-)
net/sched/sch_mq.c +37 -15
@@ -19,17 +19,32 @@struct mq_sched {struct Qdisc **qdiscs; +struct netdev_tc_txq tc_txq; +u8 num_tc; }; +static void mq_queues (struct net_device *dev,struct Qdisc *sch) +{ +struct mq_sched *priv =qdisc_priv (sch); +if (priv->num_tc) { +int queue =TC_H_MIN (sch->parent) -1 ; + priv->tc_txq.count = dev->tc_to_txq[queue].count; + priv->tc_txq.offset = dev->tc_to_txq[queue].offset; + }else { + priv->tc_txq.count = dev->num_tx_queues; + priv->tc_txq.offset =0 ; + } +} +static void mq_destroy (struct Qdisc *sch) { -struct net_device *dev =qdisc_dev (sch);struct mq_sched *priv =qdisc_priv (sch);unsigned int ntx;if (!priv->qdiscs)return ; -for (ntx =0 ; ntx < dev->num_tx_queues && priv->qdiscs[ntx]; ntx++) + +for (ntx =0 ; ntx < priv->tc_txq.count && priv->qdiscs[ntx]; ntx++)qdisc_destroy (priv->qdiscs[ntx]);kfree (priv->qdiscs); }
@@ -42,20 +57,24 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt)struct Qdisc *qdisc;unsigned int ntx; -if (sch->parent !=TC_H_ROOT ) +if (sch->parent !=TC_H_ROOT && !dev->num_tc)return -EOPNOTSUPP ;if (!netif_is_multiqueue (dev))return -EOPNOTSUPP ; +/* Record num tc info in priv so we can tear down cleanly */ + priv->num_tc = dev->num_tc; +mq_queues (dev, sch); +/* pre-allocate qdiscs, attachment can't fail */ - priv->qdiscs =kcalloc (dev->num_tx_queues,sizeof (priv->qdiscs[0 ]), + priv->qdiscs =kcalloc (priv->tc_txq.count,sizeof (priv->qdiscs[0 ]),GFP_KERNEL );if (priv->qdiscs ==NULL )return -ENOMEM ; -for (ntx =0 ; ntx < dev->num_tx_queues; ntx++) { - dev_queue =netdev_get_tx_queue (dev, ntx); +for (ntx =0 ; ntx < priv->tc_txq.count; ntx++) { + dev_queue =netdev_get_tx_queue (dev, ntx + priv->tc_txq.offset); qdisc =qdisc_create_dflt (dev_queue, &pfifo_fast_ops,TC_H_MAKE (TC_H_MAJ (sch->handle),TC_H_MIN (ntx +1 )));
@@ -65,7 +84,8 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt) priv->qdiscs[ntx] = qdisc; } - sch->flags |=TCQ_F_MQROOT ; +if (!priv->num_tc) + sch->flags |=TCQ_F_MQROOT ;return 0 ; err:
@@ -75,12 +95,11 @@ err:static void mq_attach (struct Qdisc *sch) { -struct net_device *dev =qdisc_dev (sch);struct mq_sched *priv =qdisc_priv (sch);struct Qdisc *qdisc;unsigned int ntx; -for (ntx =0 ; ntx < dev->num_tx_queues; ntx++) { +for (ntx =0 ; ntx < priv->tc_txq.count; ntx++) { qdisc = priv->qdiscs[ntx]; qdisc =dev_graft_qdisc (qdisc->dev_queue, qdisc);if (qdisc)
@@ -93,6 +112,7 @@ static void mq_attach(struct Qdisc *sch)static int mq_dump (struct Qdisc *sch,struct sk_buff *skb) {struct net_device *dev =qdisc_dev (sch); +struct mq_sched *priv =qdisc_priv (sch);struct Qdisc *qdisc;unsigned int ntx;
@@ -100,8 +120,9 @@ static int mq_dump(struct Qdisc *sch, struct sk_buff *skb)memset (&sch->bstats,0 ,sizeof (sch->bstats));memset (&sch->qstats,0 ,sizeof (sch->qstats)); -for (ntx =0 ; ntx < dev->num_tx_queues; ntx++) { - qdisc =netdev_get_tx_queue (dev, ntx)->qdisc_sleeping; +for (ntx =0 ; ntx < priv->tc_txq.count; ntx++) { +int txq = ntx + priv->tc_txq.offset; + qdisc =netdev_get_tx_queue (dev, txq)->qdisc_sleeping;spin_lock_bh (qdisc_lock (qdisc)); sch->q.qlen += qdisc->q.qlen; sch->bstats.bytes += qdisc->bstats.bytes;
@@ -119,11 +140,12 @@ static int mq_dump(struct Qdisc *sch, struct sk_buff *skb)static struct netdev_queue *mq_queue_get (struct Qdisc *sch,unsigned long cl) {struct net_device *dev =qdisc_dev (sch); +struct mq_sched *priv =qdisc_priv (sch);unsigned long ntx = cl -1 ; -if (ntx >= dev->num_tx_queues) +if (ntx >= priv->tc_txq.count)return NULL ; -return netdev_get_tx_queue (dev, ntx); +return netdev_get_tx_queue (dev, priv->tc_txq.offset + ntx); } static struct netdev_queue *mq_select_queue(struct Qdisc *sch,
@@ -202,14 +224,14 @@ static int mq_dump_class_stats(struct Qdisc *sch, unsigned long cl,static void mq_walk (struct Qdisc *sch,struct qdisc_walker *arg) { -struct net_device *dev =qdisc_dev (sch); +struct mq_sched *priv =qdisc_priv (sch);unsigned int ntx;if (arg->stop)return ; arg->count = arg->skip; -for (ntx = arg->skip; ntx < dev->num_tx_queues; ntx++) { +for (ntx = arg->skip; ntx < priv->tc_txq.count; ntx++) {if (arg->fn (sch, ntx +1 , arg) <0 ) { arg->stop =1 ;break ;
PATCH v2 3/3 net_sched: implement a root container qdisc sch_mclass
In reply to John FastabendThis implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the netdev_tc_txq mappings.
Using the mclass qdisc the number of tcs currently in use along with the range of queues alloted to each class can be configured. By default skbs are mapped to traffic classes using the skb priority. This mapping is configurable.
Configurable parameters,
struct tc_mclass_qopt {
__u8 num_tc;
__u8 prio_tc_map[16];
__u8 hw;
__u16 count[16];
__u16 offset[16];
};Here the count/offset pairing give the queue alignment and the prio_tc_map gives the mapping from skb->priority to tc. The hw bit determines if the hardware should configure the count and offset values. If the hardware bit is set then the operation will fail if the hardware does not implement the ndo_setup_tc operation. This is to avoid undetermined states where the hardware may or may not control the queue mapping. Also minimal bounds checking is done on the count/offset to verify a queue does not exceed num_tx_queues and that queue ranges do not overlap. Otherwise it is left to user policy or hardware configuration to create useful mappings.
It is expected that hardware QOS schemes can be implemented by creating appropriate mappings of queues in ndo_tc_setup(). This scheme can be expanded as needed with additional qdisc being graft'd onto the root qdisc to provide per tc queuing disciplines. Allowing Software and hardware queuing disciplines can be used together
One expected use case is drivers will use the ndo_setup_tc to map queue ranges onto 802.1Q traffic classes. This provides a generic mechanism to map network traffic onto these traffic classes and removes the need for lower layer drivers to no specifics about traffic types.
---
include/linux/netdevice.h | 3 include/linux/pkt_sched.h | 9 + include/net/sch_generic.h | 2 net/sched/Makefile | 2 net/sched/sch_api.c | 1 net/sched/sch_generic.c | 10 + net/sched/sch_mclass.c | 376 +++++++++++++++++++++++++++++++++++++++++++++ net/sched/sch_mq.c | 3 8 files changed, 403 insertions(+), 3 deletions(-) create mode 100644 net/sched/sch_mclass.c
include/linux/netdevice.h +3 -0
@@ -764,6 +764,8 @@ struct netdev_tc_txq {* int (*ndo_set_vf_port)(struct net_device *dev, int vf, * struct nlattr *port[]); * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); +* +* int (*ndo_setup_tc)(struct net_device *dev, int tc); */ #define HAVE_NET_DEVICE_OPS struct net_device_ops {
@@ -822,6 +824,7 @@ struct net_device_ops { struct nlattr *port[]);int (*ndo_get_vf_port)(struct net_device *dev,int vf,struct sk_buff *skb); +int (*ndo_setup_tc)(struct net_device *dev,u8 tc);#if defined(CONFIG_FCOE ) || defined(CONFIG_FCOE_MODULE )int (*ndo_fcoe_enable)(struct net_device *dev);int (*ndo_fcoe_disable)(struct net_device *dev);
include/linux/pkt_sched.h +9 -0
@@ -481,4 +481,13 @@ struct tc_drr_stats { __u32 deficit; }; +/* MCLASS */ +struct tc_mclass_qopt { +__u8 num_tc; +__u8 prio_tc_map[16 ]; +__u8 hw; +__u16 count[16 ]; +__u16 offset[16 ]; +}; +#endif
include/net/sch_generic.h +2 -0
@@ -50,6 +50,7 @@ struct Qdisc {#define TCQ_F_INGRESS 4#define TCQ_F_CAN_BYPASS 8#define TCQ_F_MQROOT 16 +#define TCQ_F_MQSAFE 32#define TCQ_F_WARN_NONWC (1 << 16)int padded;struct Qdisc_ops *ops;
@@ -276,6 +277,7 @@ extern struct Qdisc noop_qdisc;extern struct Qdisc_ops noop_qdisc_ops;extern struct Qdisc_ops pfifo_fast_ops;extern struct Qdisc_ops mq_qdisc_ops; +extern struct Qdisc_ops mclass_qdisc_ops;struct Qdisc_class_common {u32 classid;
net/sched/Makefile +1 -1
@@ -2,7 +2,7 @@ # Makefile for the Linux Traffic Control Unit. # -obj-y := sch_generic.o sch_mq.o +obj-y := sch_generic.o sch_mq.o sch_mclass.o obj-$(CONFIG_NET_SCHED) += sch_api.o sch_blackhole.o obj-$(CONFIG_NET_CLS) += cls_api.o
net/sched/sch_api.c +1 -0
@@ -1770,6 +1770,7 @@ static int __init pktsched_init(void)register_qdisc (&bfifo_qdisc_ops);register_qdisc (&pfifo_head_drop_qdisc_ops);register_qdisc (&mq_qdisc_ops); +register_qdisc (&mclass_qdisc_ops);rtnl_register (PF_UNSPEC ,RTM_NEWQDISC , tc_modify_qdisc,NULL );rtnl_register (PF_UNSPEC ,RTM_DELQDISC , tc_get_qdisc,NULL );
net/sched/sch_generic.c +8 -2
@@ -376,7 +376,7 @@ static struct netdev_queue noop_netdev_queue = {struct Qdisc noop_qdisc = { .enqueue = noop_enqueue, .dequeue = noop_dequeue, - .flags =TCQ_F_BUILTIN , + .flags =TCQ_F_BUILTIN |TCQ_F_MQSAFE , .ops = &noop_qdisc_ops, .list =LIST_HEAD_INIT (noop_qdisc.list), .q.lock =__SPIN_LOCK_UNLOCKED (noop_qdisc.q.lock),
@@ -709,7 +709,13 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping;atomic_inc (&dev->qdisc->refcnt); }else { - qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops,TC_H_ROOT ); +if (dev->num_tc) + qdisc =qdisc_create_dflt (txq, &mclass_qdisc_ops, +TC_H_ROOT ); +else + qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops, +TC_H_ROOT ); +if (qdisc) { qdisc->ops->attach (qdisc); dev->qdisc = qdisc;
net/sched/sch_mclass.c new file +376 -0
376 lines not on this page · raw message
net/sched/sch_mq.c +3 -0
@@ -86,6 +86,9 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt)if (!priv->num_tc) sch->flags |=TCQ_F_MQROOT ; +else + sch->flags |=TCQ_F_MQSAFE ; +return 0 ; err:
Quoted 8 lines · John Fastabend
This patch provides a mechanism for lower layer devices to steer traffic using
skb->priorityto tx queues. This allows for hardware based QOS schemes to use the default qdisc without incurring the penalties related to global state and the qdisc lock. While reliably receiving skbs on the correct tx ring to avoid head of line blocking resulting from shuffling in the LLD. Finally, all the goodness from txq caching and xps/rps can still be leveraged.
Is there any chance this might be applicable to the 802.11 layer as well? We will definitely still need an ndo_select_queue handler to reset in the case where the peer doesn't support QoS, but it seems the part that depends on the frame itself could be pushed out to the generic framework instead of having net/wireless/util.c:cfg80211_classify8021d?
johannes
Quoted 10 lines · Johannes Berg
Quoted 8 lines · John Fastabend
This patch provides a mechanism for lower layer devices to steer traffic using
skb->priorityto tx queues. This allows for hardware based QOS schemes to use the default qdisc without incurring the penalties related to global state and the qdisc lock. While reliably receiving skbs on the correct tx ring to avoid head of line blocking resulting from shuffling in the LLD. Finally, all the goodness from txq caching and xps/rps can still be leveraged.
Quoted 8 lines
Is there any chance this might be applicable to the 802.11 layer as well? We will definitely still need an
ndo_select_queuehandler to reset in the case where the peer doesn't support QoS, but it seems the part that depends on the frame itself could be pushed out to the generic framework instead of having net/wireless/util.c:cfg80211_classify8021d?johannes
Johannes,
I took a quick look at this and I believe it should be doable. It would be nice to completely remove the ndo_select_queue if possible though.
I probably won't have a chance to look any further into this for at least a week maybe two. So I'll think about it a bit more later unless someone else gets there first.
Thanks,
John.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 20 lines · On Wed, 22 Dec 2010 21:29:43 -0800 John Fastabend <[email protected]>…
Quoted 10 lines · Johannes Berg
Quoted 8 lines · John Fastabend
This patch provides a mechanism for lower layer devices to steer traffic using
skb->priorityto tx queues. This allows for hardware based QOS schemes to use the default qdisc without incurring the penalties related to global state and the qdisc lock. While reliably receiving skbs on the correct tx ring to avoid head of line blocking resulting from shuffling in the LLD. Finally, all the goodness from txq caching and xps/rps can still be leveraged.Quoted 8 lines
Is there any chance this might be applicable to the 802.11 layer as well? We will definitely still need an
ndo_select_queuehandler to reset in the case where the peer doesn't support QoS, but it seems the part that depends on the frame itself could be pushed out to the generic framework instead of having net/wireless/util.c:cfg80211_classify8021d?johannes
Quoted 8 lines
Johannes,
I took a quick look at this and I believe it should be doable. It would be nice to completely remove the
ndo_select_queueif possible though.I probably won't have a chance to look any further into this for at least a week maybe two. So I'll think about it a bit more later unless someone else gets there first.
Thanks,
John.
The Beceem Wimax driver has same kind of select queue.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to John FastabendQuoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
...
include/net/sch_generic.h struct Qdisc { · line 53
Quoted 9 lines
include/net/sch_generic.h +1
-0@@ -50,6 +50,7 @@ struct Qdisc {#define TCQ_F_INGRESS 4#define TCQ_F_CAN_BYPASS 8#define TCQ_F_MQROOT 16 +#define TCQ_F_MQSAFE 32
If every other qdisc added a flag for qdiscs it likes...
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 712
Quoted 6 lines
include/net/sch_generic.h +1
-1@@ -709,7 +709,13 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping;atomic_inc (&dev->qdisc->refcnt); }else { - qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops,TC_H_ROOT ); +if (dev->num_tc)
Actually, where this num_tc is expected to be set? I can see it inside mclass only, with unsetting on destruction, but probably I miss something.
Quoted 8 lines
include/net/sch_generic.h +8
-0+ qdisc =qdisc_create_dflt (txq, &mclass_qdisc_ops, +TC_H_ROOT ); + else + qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops, +TC_H_ROOT ); + +static int mclass_init (struct Qdisc *sch,struct nlattr *opt) +{
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev)
Quoted 10 lines
include/net/sch_generic.h +10
-0+struct net_device *dev =qdisc_dev (sch); +struct mclass_sched *priv =qdisc_priv (sch); +struct netdev_queue *dev_queue; +struct Qdisc *qdisc; +int i, err = -EOPNOTSUPP ; +struct tc_mclass_qopt *qopt =NULL ; + +/* Unwind attributes on failure */ +u8 unwnd_tc = dev->num_tc; +u8 unwnd_map[16 ];
[TC_MAX_QUEUE] ?
Quoted 29 lines
include/net/sch_generic.h +29
-0+struct netdev_tc_txq unwnd_txq[16 ]; + +if (sch->parent !=TC_H_ROOT ) +return -EOPNOTSUPP ; + +if (!netif_is_multiqueue (dev)) +return -EOPNOTSUPP ; + +if (nla_len (opt) <sizeof (*qopt)) +return -EINVAL ; + qopt =nla_data (opt); + +memcpy (unwnd_map, dev->prio_tc_map,sizeof (unwnd_map)); +memcpy (unwnd_txq, dev->tc_to_txq,sizeof (unwnd_txq)); + +/* If the mclass options indicate that hardware should own +* the queue mapping then run ndo_setup_tc if this can not +* be done fail immediately. +*/ +if (qopt->hw && dev->netdev_ops->ndo_setup_tc) { + priv->hw_owned =1 ; +if (dev->netdev_ops->ndo_setup_tc (dev, qopt->num_tc)) +return -EINVAL ; + }else if (!qopt->hw) { +if (mclass_parse_opt (dev, qopt)) +return -EINVAL ; + +if (netdev_set_num_tc (dev, qopt->num_tc)) +return -ENOMEM ;
include/net/sch_generic.h
Quoted 10 lines
include/net/sch_generic.h +10
-0+ +for (i =0 ; i < qopt->num_tc; i++) +netdev_set_tc_queue (dev, i, + qopt->count[i], qopt->offset[i]); + }else { +return -EINVAL ; + } + +/* Always use supplied priority mappings */ +for (i =0 ; i <16 ; i++) {
i < qopt->num_tc ?
Quoted 6 lines
include/net/sch_generic.h +6
-0+if (netdev_set_prio_tc_map (dev, i, qopt->prio_tc_map[i])) { + err = -EINVAL ; + goto tc_err; + } + } +
include/net/sch_generic.h
Quoted 10 lines
include/net/sch_generic.h +10
-0+/* pre-allocate qdisc, attachment can't fail */ + priv->qdiscs =kcalloc (qopt->num_tc, +sizeof (priv->qdiscs[0 ]),GFP_KERNEL ); +if (priv->qdiscs ==NULL ) { + err = -ENOMEM ; + goto tc_err; + } + +for (i =0 ; i < dev->num_tc; i++) { + dev_queue =netdev_get_tx_queue (dev, dev->tc_to_txq[i].offset);
Are these offsets etc. validated?
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
Quoted 1 line · Jarek Poplawski
John Fastabend wrote:
...
Quoted 4 lines
net/sched/sch_mclass.c line 130
Quoted 2 lines
net/sched/sch_mclass.c new file +2
-0+for (i =0 ; i < dev->num_tc; i++) { + dev_queue =netdev_get_tx_queue (dev, dev->tc_to_txq[i].offset);Are these offsets etc. validated?
They are... Forget this last question.
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to John FastabendQuoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.
Btw, you could also consider better name (mqprio?) because there're many 'multi-class' queueing disciplines around.
net/sched/sch_mclass.c line 50
Quoted 5 lines
net/sched/sch_mclass.c new file +5
-0+static int mclass_parse_opt (struct net_device *dev,struct tc_mclass_qopt *qopt) +{ +int i, j; + +/* Verify TC offset and count are sane */
if (qopt->num_tc > TC_MAX_QUEUE) ?
return -EINVAL;
net/sched/sch_mclass.c line 53
Quoted 3 lines
net/sched/sch_mclass.c new file +3
-0+for (i =0 ; i < qopt->num_tc; i++) { +int last = qopt->offset[i] + qopt->count[i]; +if (last > dev->num_tx_queues)
if (last >= dev->num_tx_queues) ?
net/sched/sch_mclass.c line 56
Quoted 3 lines
net/sched/sch_mclass.c new file +3
-0+return -EINVAL ; +for (j = i +1 ; j < qopt->num_tc; j++) { +if (last > qopt->offset[j])
if (last >= qopt->offset[j]) ?
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to Jarek PoplawskiQuoted 10 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the sch_sfq is used in the above example.
Although I am not too hung up on this use case it does seem to be a good abstraction to me. Is it strictly necessary though no and looking at the class statistics of mclass could be used to get stats per traffic class.
Quoted 13 lines
...
include/net/sch_generic.h struct Qdisc { · line 53
Quoted 9 lines
include/net/sch_generic.h +1
-0@@ -50,6 +50,7 @@ struct Qdisc {#define TCQ_F_INGRESS 4#define TCQ_F_CAN_BYPASS 8#define TCQ_F_MQROOT 16 +#define TCQ_F_MQSAFE 32If every other qdisc added a flag for qdiscs it likes...
then we run out of bits and get unneeded complexity. I think I will drop the MQSAFE bit completely and let user space catch this. The worst that should happen is the noop qdisc is used.
Quoted 9 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 712
Quoted 6 lines
include/net/sch_generic.h +1
-1@@ -709,7 +709,13 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping;atomic_inc (&dev->qdisc->refcnt); }else { - qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops,TC_H_ROOT ); +if (dev->num_tc)Actually, where this
num_tcis expected to be set? I can see it inside mclass only, with unsetting on destruction, but probably I miss something.
Either through mclass as you noted or a driver could set the num_tc. One of the RFC's I sent out has ixgbe setting the num_tc when DCB was enabled.
Quoted 12 lines
Quoted 12 lines
include/net/sch_generic.h +12
-0+ qdisc =qdisc_create_dflt (txq, &mclass_qdisc_ops, +TC_H_ROOT ); + else + qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops, +TC_H_ROOT ); + +static int mclass_init (struct Qdisc *sch,struct nlattr *opt) +{ +struct net_device *dev =qdisc_dev (sch); +struct mclass_sched *priv =qdisc_priv (sch); +struct netdev_queue *dev_queue; +struct Qdisc *qdisc;
Quoted 8 lines
include/net/sch_generic.h
Quoted 6 lines
include/net/sch_generic.h +6
-0+int i, err = -EOPNOTSUPP ; +struct tc_mclass_qopt *qopt =NULL ; + +/* Unwind attributes on failure */ +u8 unwnd_tc = dev->num_tc; +u8 unwnd_map[16 ];[
TC_MAX_QUEUE] ?
Actually TC_BITMASK+1 is probably more accurate. This array maps the skb priority to a traffic class after the priority is masked with TC_BITMASK.
Quoted 3 lines
include/net/sch_generic.h
Quoted 3 lines
include/net/sch_generic.h +2
-0+struct netdev_tc_txq unwnd_txq[16 ]; +
Although unwnd_txq should be TC_MAX_QUEUE.
Quoted 31 lines
Quoted 31 lines
include/net/sch_generic.h +31
-0+if (sch->parent !=TC_H_ROOT ) +return -EOPNOTSUPP ; + +if (!netif_is_multiqueue (dev)) +return -EOPNOTSUPP ; + +if (nla_len (opt) <sizeof (*qopt)) +return -EINVAL ; + qopt =nla_data (opt); + +memcpy (unwnd_map, dev->prio_tc_map,sizeof (unwnd_map)); +memcpy (unwnd_txq, dev->tc_to_txq,sizeof (unwnd_txq)); + +/* If the mclass options indicate that hardware should own +* the queue mapping then run ndo_setup_tc if this can not +* be done fail immediately. +*/ +if (qopt->hw && dev->netdev_ops->ndo_setup_tc) { + priv->hw_owned =1 ; +if (dev->netdev_ops->ndo_setup_tc (dev, qopt->num_tc)) +return -EINVAL ; + }else if (!qopt->hw) { +if (mclass_parse_opt (dev, qopt)) +return -EINVAL ; + +if (netdev_set_num_tc (dev, qopt->num_tc)) +return -ENOMEM ; + +for (i =0 ; i < qopt->num_tc; i++) +netdev_set_tc_queue (dev, i, + qopt->count[i], qopt->offset[i]);
Quoted 8 lines
include/net/sch_generic.h
Quoted 6 lines
include/net/sch_generic.h +6
-0+ }else { +return -EINVAL ; + } + +/* Always use supplied priority mappings */ +for (i =0 ; i <16 ; i++) {i <
qopt->num_tc?
Nope, TC_BITMASK+1 here. If we only have 4 tcs for example we still need to map all 16 priority values to a tc.
Quoted 11 lines
Quoted 11 lines
include/net/sch_generic.h +10
-0+if (netdev_set_prio_tc_map (dev, i, qopt->prio_tc_map[i])) { + err = -EINVAL ; + goto tc_err; + } + } + +/* pre-allocate qdisc, attachment can't fail */ + priv->qdiscs =kcalloc (qopt->num_tc, +sizeof (priv->qdiscs[0 ]),GFP_KERNEL ); +if (priv->qdiscs ==NULL ) {
Quoted 8 lines
include/net/sch_generic.h
Quoted 6 lines
include/net/sch_generic.h +6
-0+ err = -ENOMEM ; + goto tc_err; + } + +for (i =0 ; i < dev->num_tc; i++) { + dev_queue =netdev_get_tx_queue (dev, dev->tc_to_txq[i].offset);Are these offsets etc. validated?
Yes, as your next email noted.
Thanks,
John
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to Jarek PoplawskiQuoted 8 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Btw, you could also consider better name (mqprio?) because there're many 'multi-class' queueing disciplines around.
OK.
Quoted 8 lines
net/sched/sch_mclass.c line 50
Quoted 5 lines
net/sched/sch_mclass.c new file +5
-0+static int mclass_parse_opt (struct net_device *dev,struct tc_mclass_qopt *qopt) +{ +int i, j; + +/* Verify TC offset and count are sane */ if (
qopt->num_tc>TC_MAX_QUEUE) ?return -EINVAL;
This would be caught later when netdev_set_num_tc() fails although probably best to catch all failures in this function as early as possible.
Quoted 7 lines
net/sched/sch_mclass.c line 53
Quoted 4 lines
net/sched/sch_mclass.c new file +3
-0+for (i =0 ; i < qopt->num_tc; i++) { +int last = qopt->offset[i] + qopt->count[i]; +if (last > dev->num_tx_queues)if (last >=
dev->num_tx_queues) ?
Quoted 5 lines
net/sched/sch_mclass.c line 56
Quoted 3 lines
net/sched/sch_mclass.c new file +3
-0+return -EINVAL ; +for (j = i +1 ; j < qopt->num_tc; j++) { +if (last > qopt->offset[j])if (last >= qopt->offset[j]) ?
I believe the below works as expected. The offset needs to be verified (this I missed) but offset+count can be equal to num_tx_queue indicating the last queue is in use. With 8 tx queues and num_tc=2 a valid configuration is, tc1 offset of 0 and a count of 7 with tc2 offset of 7 and count of 1.
/* Verify num_tc is in max range */
if (qopt->num_tc > TC_MAX_QUEUE)
return -EINVAL;
for (i = 0; i < qopt->num_tc; i++) {
/* Verify the queue offset is in the num tx range */
if (qopt->offset[i] >= dev->num_tx_queues)
return -EINVAL;
/* Verify the queue count is in tx range being equal to the
* num_tx_queues indicates the last queue is in use.
*/
else if (qopt->offset[i] + qopt->count[i] > dev->num_tx_queues)
return -EINVAL;
/* Verify that the offset and counts do not overlap */
for (j = i + 1; j < qopt->num_tc; j++) {
if (last > qopt->offset[j])
return -EINVAL;
}
}Thanks for the review!
John.
Quoted 2 lines
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to John FastabendQuoted 6 lines · John Fastabend
Quoted 5 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.
Quoted 7 lines
Quoted 5 lines
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
Well, I sometimes add leaf qdiscs only to get class stats with less typing, too ;-)
Quoted 24 lines
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
Quoted 1 line
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the
sch_sfqis used in the above example.
IMHO, these tc offsets and counts make simply two level hierarchy (classes with leaf subclasses) similarly (or simpler) to other classful qdisc which manage it all inside one module. Of course, we could think of another way of code organization, but it should be rather done at the beginning of schedulers design. The mq qdisc broke the design a bit adding a fake root, but I doubt we should go deeper unless it's necessary. Doing mclass (or something) as a more complex alternative to mq should be enough. Why couldn't mclass graft sch_sfq the same way as mq?
Quoted 2 lines
Although I am not too hung up on this use case it does seem to be a good abstraction to me. Is it strictly necessary though no and looking at the class statistics of mclass could be used to get stats per traffic class.
I am not too hung up on this either, especially if it's OK to others, especially to DaveM ;-)
Quoted 15 lines
Quoted 14 lines
...
include/net/sch_generic.h struct Qdisc { · line 53
Quoted 9 lines
include/net/sch_generic.h +1
-0@@ -50,6 +50,7 @@ struct Qdisc {#define TCQ_F_INGRESS 4#define TCQ_F_CAN_BYPASS 8#define TCQ_F_MQROOT 16 +#define TCQ_F_MQSAFE 32If every other qdisc added a flag for qdiscs it likes...
Quoted 1 line
then we run out of bits and get unneeded complexity. I think I will drop the MQSAFE bit completely and let user space catch this. The worst that should happen is the noop qdisc is used.
Maybe you're right. On the other hand, usually flags are added for more general purpose and the optimal/wrong configs are the matter of documentation.
Quoted 11 lines
Quoted 10 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 712
Quoted 7 lines
include/net/sch_generic.h +1
-1@@ -709,7 +709,13 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping;atomic_inc (&dev->qdisc->refcnt); }else { - qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops,TC_H_ROOT ); +if (dev->num_tc)Actually, where this
num_tcis expected to be set? I can see it inside mclass only, with unsetting on destruction, but probably I miss something.
Quoted 1 line
Either through mclass as you noted or a driver could set the
num_tc. One of the RFC's I sent out has ixgbe setting thenum_tcwhen DCB was enabled.
OK, I probably missed this second possibility in the last version.
...
Quoted 13 lines
Quoted 5 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 715
Quoted 3 lines
include/net/sch_generic.h +3
-0+/* Unwind attributes on failure */ +u8 unwnd_tc = dev->num_tc; +u8 unwnd_map[16 ];[
TC_MAX_QUEUE] ?Actually TC_BITMASK+1 is probably more accurate. This array maps the skb priority to a traffic class after the priority is masked with
TC_BITMASK.Quoted 3 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 717
Quoted 3 lines
include/net/sch_generic.h +2
-0+struct netdev_tc_txq unwnd_txq[16 ]; +Although
unwnd_txqshould beTC_MAX_QUEUE.
...
Quoted 6 lines
Quoted 4 lines
include/net/sch_generic.h
Quoted 2 lines
include/net/sch_generic.h +2
-0+/* Always use supplied priority mappings */ +for (i =0 ; i <16 ; i++) {i <
qopt->num_tc?Nope, TC_BITMASK+1 here. If we only have 4 tcs for example we still need to map all 16 priority values to a tc.
OK, anyway, all these '16' should be 'upgraded'.
Thanks,
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to John FastabendQuoted 11 lines · John Fastabend
Quoted 9 lines · Jarek Poplawski
net/sched/sch_mclass.c line 50
Quoted 5 lines · John Fastabend
net/sched/sch_mclass.c new file +5
-0+static int mclass_parse_opt (struct net_device *dev,struct tc_mclass_qopt *qopt) +{ +int i, j; + +/* Verify TC offset and count are sane */ if (
qopt->num_tc>TC_MAX_QUEUE) ?return -EINVAL;
Quoted 1 line
This would be caught later when
netdev_set_num_tc()fails although probably best to catch all failures in this function as early as possible.
Plus reading beyond the table range wouldn't look nice.
Quoted 29 lines
Quoted 8 lines
net/sched/sch_mclass.c line 53
Quoted 5 lines
net/sched/sch_mclass.c new file +3
-0+for (i =0 ; i < qopt->num_tc; i++) { +int last = qopt->offset[i] + qopt->count[i]; +if (last > dev->num_tx_queues)if (last >=
dev->num_tx_queues) ?Quoted 5 lines
net/sched/sch_mclass.c line 56
Quoted 3 lines
net/sched/sch_mclass.c new file +3
-0+return -EINVAL ; +for (j = i +1 ; j < qopt->num_tc; j++) { +if (last > qopt->offset[j])if (last >= qopt->offset[j]) ?
I believe the below works as expected. The offset needs to be verified (this I missed) but offset+count can be equal to
num_tx_queueindicating the last queue is in use. With 8 tx queues and num_tc=2 a valid configuration is, tc1 offset of 0 and a count of 7 with tc2 offset of 7 and count of 1./* Verify num_tc is in max range */ if (qopt->num_tc > TC_MAX_QUEUE) return -EINVAL; for (i = 0; i < qopt->num_tc; i++) { /* Verify the queue offset is in the num tx range */ if (qopt->offset[i] >= dev->num_tx_queues) return -EINVAL; /* Verify the queue count is in tx range being equal to the * num_tx_queues indicates the last queue is in use. */ else if (qopt->offset[i] + qopt->count[i] > dev->num_tx_queues)
Quoted 8 lines
return -EINVAL;
/* Verify that the offset and counts do not overlap */
for (j = i + 1; j < qopt->num_tc; j++) {
if (last > qopt->offset[j])
return -EINVAL;
}
}Yes, after assigning the 'last' it should work OK ;-)
Thanks,
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
In reply to Jarek PoplawskiQuoted 44 lines · Jarek Poplawski
Quoted 6 lines · John Fastabend
Quoted 5 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Quoted 7 lines
Quoted 5 lines
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
Well, I sometimes add leaf qdiscs only to get class stats with less typing, too ;-)
Quoted 24 lines
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0Quoted 1 line
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the
sch_sfqis used in the above example.
Quoted 10 lines
IMHO, these tc offsets and counts make simply two level hierarchy (classes with leaf subclasses) similarly (or simpler) to other classful qdisc which manage it all inside one module. Of course, we could think of another way of code organization, but it should be rather done at the beginning of schedulers design. The mq qdisc broke the design a bit adding a fake root, but I doubt we should go deeper unless it's necessary. Doing mclass (or something) as a more complex alternative to mq should be enough. Why couldn't mclass graft
sch_sfqthe same way as mq?
If you also want to graft a scheduler onto a traffic class now your stuck. For now this qdisc doesn't exist, but I would like to have a software implementation of the currently offloaded DCB ETS scheduler. The 802.1Qaz spec allows different scheduling algorithms to be used on each traffic class. In the current implementation mclass could graft these scheduling schemes onto each traffic class independently.
mclass
|
-------------------------------------------------------
| | | | | | | |
mq_tbf mq_tbf mq_ets mq_ets mq mq mq_wrr greedy
| |
--------- ---------
| | | | | |
red red red red red redPerhaps, being concerned with hypothetical qdiscs is a bit of a stretch but I would like to at least not preclude this work from being done in the future.
Quoted 21 lines
Quoted 2 lines
Although I am not too hung up on this use case it does seem to be a good abstraction to me. Is it strictly necessary though no and looking at the class statistics of mclass could be used to get stats per traffic class.
I am not too hung up on this either, especially if it's OK to others, especially to DaveM ;-)
Quoted 15 lines
Quoted 14 lines
...
include/net/sch_generic.h struct Qdisc { · line 53
Quoted 9 lines
include/net/sch_generic.h +1
-0@@ -50,6 +50,7 @@ struct Qdisc {#define TCQ_F_INGRESS 4#define TCQ_F_CAN_BYPASS 8#define TCQ_F_MQROOT 16 +#define TCQ_F_MQSAFE 32If every other qdisc added a flag for qdiscs it likes...
Quoted 6 lines
Quoted 1 line
then we run out of bits and get unneeded complexity. I think I will drop the MQSAFE bit completely and let user space catch this. The worst that should happen is the noop qdisc is used.
Maybe you're right. On the other hand, usually flags are added for more general purpose and the optimal/wrong configs are the matter of documentation.
So we handle this with documentation.
Quoted 30 lines
Quoted 11 lines
Quoted 10 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 712
Quoted 7 lines
include/net/sch_generic.h +1
-1@@ -709,7 +709,13 @@ static void attach_default_qdiscs(struct net_device *dev) dev->qdisc = txq->qdisc_sleeping;atomic_inc (&dev->qdisc->refcnt); }else { - qdisc =qdisc_create_dflt (txq, &mq_qdisc_ops,TC_H_ROOT ); +if (dev->num_tc)Actually, where this
num_tcis expected to be set? I can see it inside mclass only, with unsetting on destruction, but probably I miss something.Quoted 1 line
Either through mclass as you noted or a driver could set the
num_tc. One of the RFC's I sent out has ixgbe setting thenum_tcwhen DCB was enabled.OK, I probably missed this second possibility in the last version.
...
Quoted 13 lines
Quoted 5 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 715
Quoted 3 lines
include/net/sch_generic.h +3
-0+/* Unwind attributes on failure */ +u8 unwnd_tc = dev->num_tc; +u8 unwnd_map[16 ];[
TC_MAX_QUEUE] ?Actually TC_BITMASK+1 is probably more accurate. This array maps the skb priority to a traffic class after the priority is masked with
TC_BITMASK.Quoted 3 lines
include/net/sch_generic.h static void attach_default_qdiscs(struct net_device *dev) · line 717
Quoted 3 lines
include/net/sch_generic.h +2
-0+struct netdev_tc_txq unwnd_txq[16 ]; +Although
unwnd_txqshould beTC_MAX_QUEUE....
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
include/net/sch_generic.h
Quoted 2 lines
include/net/sch_generic.h +2
-0+/* Always use supplied priority mappings */ +for (i =0 ; i <16 ; i++) {i <
qopt->num_tc?Nope, TC_BITMASK+1 here. If we only have 4 tcs for example we still need to map all 16 priority values to a tc.
OK, anyway, all these '16' should be 'upgraded'.
Yes. I'll do this in the next version.
Thanks,
John.
Quoted 3 lines
Thanks,
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
Quoted 68 lines · John Fastabend
Quoted 44 lines · Jarek Poplawski
Quoted 6 lines · John Fastabend
Quoted 5 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Quoted 7 lines
Quoted 5 lines
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
Well, I sometimes add leaf qdiscs only to get class stats with less typing, too ;-)
Quoted 24 lines
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0Quoted 1 line
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the
sch_sfqis used in the above example.Quoted 10 lines
IMHO, these tc offsets and counts make simply two level hierarchy (classes with leaf subclasses) similarly (or simpler) to other classful qdisc which manage it all inside one module. Of course, we could think of another way of code organization, but it should be rather done at the beginning of schedulers design. The mq qdisc broke the design a bit adding a fake root, but I doubt we should go deeper unless it's necessary. Doing mclass (or something) as a more complex alternative to mq should be enough. Why couldn't mclass graft
sch_sfqthe same way as mq?If you also want to graft a scheduler onto a traffic class now your stuck. For now this qdisc doesn't exist, but I would like to have a software implementation of the currently offloaded DCB ETS scheduler. The 802.1Qaz spec allows different scheduling algorithms to be used on each traffic class. In the current implementation mclass could graft these scheduling schemes onto each traffic class independently.
mclass | ------------------------------------------------------- | | | | | | | | mq_tbf mq_tbf mq_ets mq_ets mq mq mq_wrr greedy | | --------- --------- | | | | | | red red red red red red
Quoted 1 line
Perhaps, being concerned with hypothetical qdiscs is a bit of a stretch but I would like to at least not preclude this work from being done in the future.
Probably, despite this very nice figure and description, I still miss something and can't see the problem. If you graft a qdisc/scheduler to a traffic class you can change the way/range of grafting depending on additional parameters or even by checking some properties of the grafted qdisc. My main concern is adding complexity to the qdisc tree structure (instead of hiding it at the class level) for something, IMHO, hardly ever popular (like both mq and DCB).
Thanks,
Jarek P.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
Quoted 71 lines · Jarek Poplawski
Quoted 68 lines · John Fastabend
Quoted 44 lines · Jarek Poplawski
Quoted 6 lines · John Fastabend
Quoted 5 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Quoted 7 lines
Quoted 5 lines
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
Well, I sometimes add leaf qdiscs only to get class stats with less typing, too ;-)
Quoted 24 lines
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0Quoted 1 line
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the
sch_sfqis used in the above example.Quoted 10 lines
IMHO, these tc offsets and counts make simply two level hierarchy (classes with leaf subclasses) similarly (or simpler) to other classful qdisc which manage it all inside one module. Of course, we could think of another way of code organization, but it should be rather done at the beginning of schedulers design. The mq qdisc broke the design a bit adding a fake root, but I doubt we should go deeper unless it's necessary. Doing mclass (or something) as a more complex alternative to mq should be enough. Why couldn't mclass graft
sch_sfqthe same way as mq?If you also want to graft a scheduler onto a traffic class now your stuck. For now this qdisc doesn't exist, but I would like to have a software implementation of the currently offloaded DCB ETS scheduler. The 802.1Qaz spec allows different scheduling algorithms to be used on each traffic class. In the current implementation mclass could graft these scheduling schemes onto each traffic class independently.
mclass | ------------------------------------------------------- | | | | | | | | mq_tbf mq_tbf mq_ets mq_ets mq mq mq_wrr greedy | | --------- --------- | | | | | | red red red red red redQuoted 1 line
Perhaps, being concerned with hypothetical qdiscs is a bit of a stretch but I would like to at least not preclude this work from being done in the future.
Quoted 8 lines
Probably, despite this very nice figure and description, I still miss something and can't see the problem. If you graft a qdisc/scheduler to a traffic class you can change the way/range of grafting depending on additional parameters or even by checking some properties of the grafted qdisc. My main concern is adding complexity to the qdisc tree structure (instead of hiding it at the class level) for something, IMHO, hardly ever popular (like both mq and DCB).
OK I'm convinced I'll keep everything contained in mclass. Building this mechanism into the qdisc seems to be adding extra complexity that is most likely not needed as you noted.
Although I suspect the "additional parameter" would be something along the lines of a queue index and offset? right? Otherwise how would a mq like qdisc know which queues it owns.
Thanks,
John.
Re: [net-next-2.6 PATCH v2 3/3] net_sched: implement a root container qdisc sch_mclass
Quoted 81 lines · John Fastabend
Quoted 71 lines · Jarek Poplawski
Quoted 68 lines · John Fastabend
Quoted 44 lines · Jarek Poplawski
Quoted 6 lines · John Fastabend
Quoted 5 lines · Jarek Poplawski
Quoted 3 lines · John Fastabend
This implements a mclass 'multi-class' queueing discipline that by default creates multiple mq qdisc's one for each traffic class. Each mq qdisc then owns a range of queues per the
netdev_tc_txqmappings.Quoted 7 lines
Quoted 5 lines
Is it really necessary to add one more abstraction layer for this, probably not most often used (or even asked by users), functionality? Why mclass can't simply do these few things more instead of attaching (and changing) mq?
The statistics work nicely when the mq qdisc is used.
Well, I sometimes add leaf qdiscs only to get class stats with less typing, too ;-)
Quoted 24 lines
qdisc mclass 8002: root tc 4 map 0 1 2 3 0 1 2 3 1 1 1 1 1 1 1 1
queues:(0:1) (2:3) (4:5) (6:15)Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8003: parent 8002:1
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8004: parent 8002:2
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8005: parent 8002:3
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc mq 8006: parent 8002:4
Sent 140 bytes 2 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8007: parent 8005:1 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0
qdisc sfq 8008: parent 8005:2 limit 127p quantum 1514b
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0Quoted 1 line
The mclass gives the statistics for the interface and then statistics on the mq qdisc gives statistics for each traffic class. Also, when using the 'mq qdisc' with this abstraction other qdisc can be grafted onto the queue. For example the
sch_sfqis used in the above example.Quoted 10 lines
IMHO, these tc offsets and counts make simply two level hierarchy (classes with leaf subclasses) similarly (or simpler) to other classful qdisc which manage it all inside one module. Of course, we could think of another way of code organization, but it should be rather done at the beginning of schedulers design. The mq qdisc broke the design a bit adding a fake root, but I doubt we should go deeper unless it's necessary. Doing mclass (or something) as a more complex alternative to mq should be enough. Why couldn't mclass graft
sch_sfqthe same way as mq?If you also want to graft a scheduler onto a traffic class now your stuck. For now this qdisc doesn't exist, but I would like to have a software implementation of the currently offloaded DCB ETS scheduler. The 802.1Qaz spec allows different scheduling algorithms to be used on each traffic class. In the current implementation mclass could graft these scheduling schemes onto each traffic class independently.
mclass | ------------------------------------------------------- | | | | | | | | mq_tbf mq_tbf mq_ets mq_ets mq mq mq_wrr greedy | | --------- --------- | | | | | | red red red red red redQuoted 1 line
Perhaps, being concerned with hypothetical qdiscs is a bit of a stretch but I would like to at least not preclude this work from being done in the future.
Quoted 8 lines
Probably, despite this very nice figure and description, I still miss something and can't see the problem. If you graft a qdisc/scheduler to a traffic class you can change the way/range of grafting depending on additional parameters or even by checking some properties of the grafted qdisc. My main concern is adding complexity to the qdisc tree structure (instead of hiding it at the class level) for something, IMHO, hardly ever popular (like both mq and DCB).
Quoted 3 lines
OK I'm convinced I'll keep everything contained in mclass. Building this mechanism into the qdisc seems to be adding extra complexity that is most likely not needed as you noted.
Although I suspect the "additional parameter" would be something along the lines of a queue index and offset? right? Otherwise how would a mq like qdisc know which queues it owns.
Perhaps something with qdisc_class_ops select_queue() could be done to make it more flexible. When I get around to implementing these hypothetical qdiscs I will have to figure it out. For now though hypothetical qdiscs are not a very compelling use case.
Thanks,
John.