blob: 6369927e9c378b015842fb600e88e8da621f7d1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
##############################################################################
# Defines
if [[ ! -v MLXSW_CHIP ]]; then
MLXSW_CHIP=$(devlink -j dev info $DEVLINK_DEV | jq -r '.[][]["driver"]')
if [ -z "$MLXSW_CHIP" ]; then
echo "SKIP: Device $DEVLINK_DEV doesn't support devlink info command"
exit 1
fi
fi
MLXSW_SPECTRUM_REV=$(case $MLXSW_CHIP in
mlxsw_spectrum)
echo 1 ;;
mlxsw_spectrum*)
echo ${MLXSW_CHIP#mlxsw_spectrum} ;;
*)
echo "Couldn't determine Spectrum chip revision." \
> /dev/stderr ;;
esac)
mlxsw_on_spectrum()
{
local rev=$1; shift
local op="=="
local rev2=${rev%+}
if [[ $rev2 != $rev ]]; then
op=">="
fi
((MLXSW_SPECTRUM_REV $op rev2))
}
__mlxsw_only_on_spectrum()
{
local rev=$1; shift
local caller=$1; shift
local src=$1; shift
if ! mlxsw_on_spectrum "$rev"; then
log_test_skip $src:$caller "(Spectrum-$rev only)"
return 1
fi
}
mlxsw_only_on_spectrum()
{
local caller=${FUNCNAME[1]}
local src=${BASH_SOURCE[1]}
local rev
for rev in "$@"; do
if __mlxsw_only_on_spectrum "$rev" "$caller" "$src"; then
return 0
fi
done
return 1
}
mlxsw_max_descriptors_get()
{
local spectrum_rev=$MLXSW_SPECTRUM_REV
case $spectrum_rev in
1) echo 81920 ;;
2) echo 136960 ;;
3) echo 204800 ;;
4) echo 220000 ;;
*) echo "Unknown max descriptors for chip revision." > /dev/stderr
return 1 ;;
esac
}
|