tools/testing/selftests/tc-testing/tdc_batch.py

Source file repositories/reference/linux-study-clean/tools/testing/selftests/tc-testing/tdc_batch.py

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/tc-testing/tdc_batch.py
Extension
.py
Size
3337 bytes
Lines
113
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

#!/usr/bin/env python3

"""
tdc_batch.py - a script to generate TC batch file

Copyright (C) 2017 Chris Mi <chrism@mellanox.com>
"""

import argparse

parser = argparse.ArgumentParser(description='TC batch file generator')
parser.add_argument("device", help="device name")
parser.add_argument("file", help="batch file name")
parser.add_argument("-n", "--number", type=int,
                    help="how many lines in batch file")
parser.add_argument(
    "-a",
    "--handle_start",
    type=int,
    default=1,
    help="start handle range from (default: 1)")
parser.add_argument("-o", "--skip_sw",
                    help="skip_sw (offload), by default skip_hw",
                    action="store_true")
parser.add_argument("-s", "--share_action",
                    help="all filters share the same action",
                    action="store_true")
parser.add_argument("-p", "--prio",
                    help="all filters have different prio",
                    action="store_true")
parser.add_argument(
    "-e",
    "--operation",
    choices=['add', 'del', 'replace'],
    default='add',
    help="operation to perform on filters"
    "(default: add filter)")
parser.add_argument(
    "-m",
    "--mac_prefix",
    type=int,
    default=0,
    choices=range(0, 256),
    help="third byte of source MAC address of flower filter"
    "(default: 0)")
args = parser.parse_args()

device = args.device
file = open(args.file, 'w')

number = 1
if args.number:
    number = args.number

handle_start = args.handle_start

skip = "skip_hw"
if args.skip_sw:
    skip = "skip_sw"

share_action = ""
if args.share_action:
    share_action = "index 1"

prio = "prio 1"
if args.prio:
    prio = ""
    if number > 0x4000:
        number = 0x4000

Annotation

Implementation Notes