Antoni Segura Puimedon has uploaded a new change for review.

Change subject: tc: add parsing for some pfifo_fast and ingress
......................................................................

tc: add parsing for some pfifo_fast and ingress

This patch adds qdisc parsing capabilities to vdsm/network/tc.py which
will aid in adding QoS configuring and reporting support.

For an qdisc data like:
    qdisc pfifo_fast 0: dev eth0 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 
1 1 1 1 1 1 1 1
    qdisc pfifo_fast 0: dev eth1 root refcnt 2 bands 3 priomap 1 2 2 2 1 2 0 0 
1 1 1 1 1 1 1 1
    qdisc drr 1: dev eth2 root refcnt 2
    qdisc tbf 10: dev eth2 parent 1:10 rate 32000Kbit burst 64Kb lat 4295.0s
    qdisc tbf 20: dev eth2 parent 1:20 rate 3200Kbit burst 100Kb lat 4294.7s
    qdisc tbf 30: dev eth2 parent 1:30 rate 800000Kbit burst 100Kb lat 4295.0s
    qdisc ingress ffff: dev eth2 parent ffff:fff1 ----------------

it would return the following dicts:
    {'kind': 'pfifo_fast', 'handle': '0:', 'pfifo_fast': {'priomap': [1, 2, 2,
     2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1]}, 'refcnt': '2', 'dev': 'eth0',
     'root': True}
    {'kind': 'pfifo_fast', 'handle': '0:', 'pfifo_fast': {'priomap': [1, 2, 2,
     2, 1, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1]}, 'refcnt': '2', 'dev': 'eth1',
     'root': True}
    {'root': True, 'kind': 'drr', 'handle': '1:', 'refcnt': '2', 'dev': 'eth2'}
    {'kind': 'tbf', 'handle': '10:', 'parent': '1:10', 'dev': 'eth2'}
    {'kind': 'tbf', 'handle': '20:', 'parent': '1:20', 'dev': 'eth2'}
    {'kind': 'tbf', 'handle': '30:', 'parent': '1:30', 'dev': 'eth2'}
    {'ingress': {}, 'kind': 'ingress', 'handle': 'ffff:',
     'parent': 'ffff:fff1', 'dev': 'eth2'}

Note that there is some basic information reported for unsupported
qdisc classes (like tbf and drr).

Change-Id: I039dc7594a261ccb32f78c0b050b28fecac417ee
Signed-off-by: Antoni S. Puimedon <[email protected]>
---
M vdsm/network/tc.py
1 file changed, 41 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/30048/1

diff --git a/vdsm/network/tc.py b/vdsm/network/tc.py
index 92d5fd7..d0e13cd 100644
--- a/vdsm/network/tc.py
+++ b/vdsm/network/tc.py
@@ -30,6 +30,7 @@
 from vdsm.utils import execCmd
 
 ERR_DEV_NOEXIST = 2
+_TC_PRIO_MAX = 15
 
 QDISC_INGRESS = 'ffff:'
 
@@ -367,7 +368,46 @@
     return data
 
 
-_parsers = {'filter': _parse_filter}
+def _parse_qdisc(tokens):
+    """Takes a token generator"""
+    data = {'kind': next(tokens), 'handle': next(tokens)}
+    for token in tokens:
+        if token == 'root':
+            data['root'] = True
+        elif token in ('dev', 'parent', 'refcnt'):
+            data[token] = next(tokens)
+        else:
+            break
+    # At this point there should be a qdisc kind
+    _qdisc_cls_parser = QDISC_CLS.get(data['kind'])
+    if _qdisc_cls_parser is not None:
+        data[data['kind']] = _qdisc_cls_parser(tokens)
+    return data
+
+
+def _parse_ingress(tokens):
+    """Returns qdisc options for ingress"""
+    return {}  # ingress doesn't have special data
+
+
+def _parse_pfifo_fast(tokens):
+    """Returns qdisc options for pfifo_fast"""
+    data = {}
+    for token in tokens:
+        if token == 'bands':
+            data[token] = next(tokens)
+        elif token == 'priomap':
+            data[token] = [int(next(tokens)) for _ in range(_TC_PRIO_MAX)]
+        elif token == 'multiqueue':
+            data[token] = next(tokens)
+    return data
+
+
+QDISC_CLS = {'fq_codel': None, 'hfsc': None, 'ingress': _parse_ingress,
+             'pfifo_fast': _parse_pfifo_fast, 'sfq': None}
+
+
+_parsers = {'filter': _parse_filter, 'qdisc': _parse_qdisc}
 
 
 def filters(dev, parent, out=None):


-- 
To view, visit http://gerrit.ovirt.org/30048
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I039dc7594a261ccb32f78c0b050b28fecac417ee
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to