Pool #8 was recently introduced to mlxsw to support MC-aware regime of
the switch. Pool 8 is configured differently from the other pools, with
infinite size, and statically-determined quotas. Tweak the sharedbuffer
test to handle this case.
Signed-off-by: Petr Machata <petrm(a)mellanox.com>
---
recipes/switchdev/sharedbuffer.py | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/recipes/switchdev/sharedbuffer.py b/recipes/switchdev/sharedbuffer.py
index 28a6f44..4393770 100644
--- a/recipes/switchdev/sharedbuffer.py
+++ b/recipes/switchdev/sharedbuffer.py
@@ -13,6 +13,9 @@ from TestLib import TestLib
from time import sleep
import random
+CELL_SIZE = 288 # Least common multiple of cell sizes of Spectrum and
+ # Spectrum-2, which are, respectively, 96 and 144.
+
class RandomValuePicker:
def __init__(self, pools):
self._pools = {"ingress": [], "egress": []}
@@ -27,9 +30,11 @@ class RandomValuePicker:
# support static threshold only for now
return "static"
- def _get_th(self):
- # support dynamic threshold only for now
- return random.randint(3,16)
+ def _get_th(self, pool):
+ th = random.randint(3,16)
+ if pool == 8: # Pool 8 has static quotas.
+ th *= CELL_SIZE
+ return th
def _get_pool(self, direction):
arr = self._pools[direction]
@@ -40,14 +45,17 @@ class RandomValuePicker:
return (self._get_size(), self._get_thtype())
if isinstance(objid, TcBind):
pool = self._get_pool(objid["type"])
- th = self._get_th()
+ th = self._get_th(pool)
return (pool, th)
if isinstance(objid, PortPool):
- return (self._get_th(),)
+ return (self._get_th(objid["pool"]),)
class RecordValuePickerException(Exception):
pass
+class SkipTest(Exception):
+ pass
+
class RecordValuePicker:
def __init__(self, objlist):
self._recs = []
@@ -55,6 +63,9 @@ class RecordValuePicker:
self._recs.append({"objid": item, "value":
item.var_tuple()})
def get_value(self, objid):
+ if isinstance(objid, Pool) and objid["pool"] == 8:
+ # Pool 8 is reported with infinite size, which can't be reset.
+ raise SkipTest()
for rec in self._recs:
if rec["objid"].weak_eq(objid):
return rec["value"]
@@ -124,7 +135,10 @@ def get_pools(sw, dlname, direction=None):
def do_check_pools(tl, sw, dlname, pools, vp):
for pool in pools:
pre_pools = get_pools(sw, dlname)
- (size, thtype) = vp.get_value(pool)
+ try:
+ (size, thtype) = vp.get_value(pool)
+ except SkipTest:
+ continue
pool.dl_set(sw, dlname, size, thtype)
post_pools = get_pools(sw, dlname)
pool = post_pools.get_by(pool)
--
2.4.11