tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh
Extension
.sh
Size
10661 bytes
Lines
353
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright 2020 NXP

WAIT_TIME=1
NUM_NETIFS=4
STABLE_MAC_ADDRS=yes
lib_dir=$(dirname $0)/../../../net/forwarding
source $lib_dir/tc_common.sh
source $lib_dir/lib.sh

require_command tcpdump

h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
swp2=${NETIFS[p3]}
h2=${NETIFS[p4]}

# Helpers to map a VCAP IS1 and VCAP IS2 lookup and policy to a chain number
# used by the kernel driver. The numbers are:
# VCAP IS1 lookup 0:            10000
# VCAP IS1 lookup 1:            11000
# VCAP IS1 lookup 2:            12000
# VCAP IS2 lookup 0 policy 0:   20000
# VCAP IS2 lookup 0 policy 1:   20001
# VCAP IS2 lookup 0 policy 255: 20255
# VCAP IS2 lookup 1 policy 0:   21000
# VCAP IS2 lookup 1 policy 1:   21001
# VCAP IS2 lookup 1 policy 255: 21255
IS1()
{
	local lookup=$1

	echo $((10000 + 1000 * lookup))
}

IS2()
{
	local lookup=$1
	local pag=$2

	echo $((20000 + 1000 * lookup + pag))
}

ES0()
{
	echo 0
}

# The Ocelot switches have a fixed ingress pipeline composed of:
#
# +----------------------------------------------+      +-----------------------------------------+
# |                   VCAP IS1                   |      |                  VCAP IS2               |
# |                                              |      |                                         |
# | +----------+    +----------+    +----------+ |      |            +----------+    +----------+ |
# | | Lookup 0 |    | Lookup 1 |    | Lookup 2 | | --+------> PAG 0: | Lookup 0 | -> | Lookup 1 | |
# | +----------+ -> +----------+ -> +----------+ |   |  |            +----------+    +----------+ |
# | |key&action|    |key&action|    |key&action| |   |  |            |key&action|    |key&action| |
# | |key&action|    |key&action|    |key&action| |   |  |            |    ..    |    |    ..    | |
# | |    ..    |    |    ..    |    |    ..    | |   |  |            +----------+    +----------+ |
# | +----------+    +----------+    +----------+ |   |  |                                         |
# |                                 selects PAG  |   |  |            +----------+    +----------+ |
# +----------------------------------------------+   +------> PAG 1: | Lookup 0 | -> | Lookup 1 | |
#                                                    |  |            +----------+    +----------+ |
#                                                    |  |            |key&action|    |key&action| |
#                                                    |  |            |    ..    |    |    ..    | |
#                                                    |  |            +----------+    +----------+ |
#                                                    |  |      ...                                |
#                                                    |  |                                         |
#                                                    |  |            +----------+    +----------+ |

Annotation

Implementation Notes