aboutsummaryrefslogtreecommitdiffstats
path: root/examples/ip_pipeline/pipeline
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ip_pipeline/pipeline')
-rw-r--r--examples/ip_pipeline/pipeline/hash_func.h356
-rw-r--r--examples/ip_pipeline/pipeline/hash_func_arm64.h261
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_actions_common.h202
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_common_be.c176
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_common_be.h134
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_common_fe.c1455
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_common_fe.h231
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_firewall.c1421
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_firewall.h60
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_firewall_be.c856
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_firewall_be.h147
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_actions.c1286
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_actions.h60
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c960
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h139
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_classification.c1878
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_classification.h106
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c723
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h113
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_master.c20
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_master.h12
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_master_be.c141
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_master_be.h12
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_passthrough.c45
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_passthrough.h12
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_passthrough_be.c929
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_passthrough_be.h44
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_routing.c1613
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_routing.h71
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_routing_be.c1966
-rw-r--r--examples/ip_pipeline/pipeline/pipeline_routing_be.h283
31 files changed, 0 insertions, 15712 deletions
diff --git a/examples/ip_pipeline/pipeline/hash_func.h b/examples/ip_pipeline/pipeline/hash_func.h
deleted file mode 100644
index 806ac227..00000000
--- a/examples/ip_pipeline/pipeline/hash_func.h
+++ /dev/null
@@ -1,356 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-#ifndef __INCLUDE_HASH_FUNC_H__
-#define __INCLUDE_HASH_FUNC_H__
-
-static inline uint64_t
-hash_xor_key8(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0;
-
- xor0 = seed ^ (k[0] & m[0]);
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key16(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key24(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
-
- xor0 ^= k[2] & m[2];
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key32(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0, xor1;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
- xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
- xor0 ^= xor1;
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key40(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0, xor1;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
- xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
-
- xor0 ^= xor1;
-
- xor0 ^= k[4] & m[4];
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key48(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0, xor1, xor2;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
- xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
- xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
- xor0 ^= xor1;
-
- xor0 ^= xor2;
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key56(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0, xor1, xor2;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
- xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
- xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
-
- xor0 ^= xor1;
- xor2 ^= k[6] & m[6];
-
- xor0 ^= xor2;
-
- return (xor0 >> 32) ^ xor0;
-}
-
-static inline uint64_t
-hash_xor_key64(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t xor0, xor1, xor2, xor3;
-
- xor0 = ((k[0] & m[0]) ^ seed) ^ (k[1] & m[1]);
- xor1 = (k[2] & m[2]) ^ (k[3] & m[3]);
- xor2 = (k[4] & m[4]) ^ (k[5] & m[5]);
- xor3 = (k[6] & m[6]) ^ (k[7] & m[7]);
-
- xor0 ^= xor1;
- xor2 ^= xor3;
-
- xor0 ^= xor2;
-
- return (xor0 >> 32) ^ xor0;
-}
-
-#if defined(RTE_ARCH_X86_64)
-
-#include <x86intrin.h>
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t crc0;
-
- crc0 = _mm_crc32_u64(seed, k[0] & m[0]);
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, crc0, crc1;
-
- k0 = k[0] & m[0];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, crc0, crc1;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc0 = _mm_crc32_u64(crc0, k2);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
- crc3 = k2 >> 32;
-
- crc0 = _mm_crc32_u64(crc0, crc1);
- crc1 = _mm_crc32_u64(crc2, crc3);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
- crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
- crc0 = _mm_crc32_u64(crc0, crc1);
- crc1 = _mm_crc32_u64(crc2, crc3);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, k5, crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
- crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
- crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
- crc1 = _mm_crc32_u64(crc3, k5);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
- crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
- crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
- crc5 = k5 >> 32;
-
- crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
- crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint64_t k0, k2, k5, crc0, crc1, crc2, crc3, crc4, crc5;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = _mm_crc32_u64(k0, seed);
- crc1 = _mm_crc32_u64(k0 >> 32, k[1] & m[1]);
-
- crc2 = _mm_crc32_u64(k2, k[3] & m[3]);
- crc3 = _mm_crc32_u64(k2 >> 32, k[4] & m[4]);
-
- crc4 = _mm_crc32_u64(k5, k[6] & m[6]);
- crc5 = _mm_crc32_u64(k5 >> 32, k[7] & m[7]);
-
- crc0 = _mm_crc32_u64(crc0, (crc1 << 32) ^ crc2);
- crc1 = _mm_crc32_u64(crc3, (crc4 << 32) ^ crc5);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-#define hash_default_key8 hash_crc_key8
-#define hash_default_key16 hash_crc_key16
-#define hash_default_key24 hash_crc_key24
-#define hash_default_key32 hash_crc_key32
-#define hash_default_key40 hash_crc_key40
-#define hash_default_key48 hash_crc_key48
-#define hash_default_key56 hash_crc_key56
-#define hash_default_key64 hash_crc_key64
-
-#elif defined(RTE_ARCH_ARM64)
-#include "hash_func_arm64.h"
-#else
-
-#define hash_default_key8 hash_xor_key8
-#define hash_default_key16 hash_xor_key16
-#define hash_default_key24 hash_xor_key24
-#define hash_default_key32 hash_xor_key32
-#define hash_default_key40 hash_xor_key40
-#define hash_default_key48 hash_xor_key48
-#define hash_default_key56 hash_xor_key56
-#define hash_default_key64 hash_xor_key64
-
-#endif
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/hash_func_arm64.h b/examples/ip_pipeline/pipeline/hash_func_arm64.h
deleted file mode 100644
index ae6c0f41..00000000
--- a/examples/ip_pipeline/pipeline/hash_func_arm64.h
+++ /dev/null
@@ -1,261 +0,0 @@
-/*-
- * BSD LICENSE
- *
- * Copyright(c) 2017 Linaro Limited. All rights reserved.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Intel Corporation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#ifndef __HASH_FUNC_ARM64_H__
-#define __HASH_FUNC_ARM64_H__
-
-#define _CRC32CX(crc, val) \
- __asm__("crc32cx %w[c], %w[c], %x[v]":[c] "+r" (crc):[v] "r" (val))
-
-static inline uint64_t
-hash_crc_key8(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key;
- uint64_t *m = mask;
- uint32_t crc0;
-
- crc0 = seed;
- _CRC32CX(crc0, k[0] & m[0]);
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key16(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0;
- uint64_t *m = mask;
- uint32_t crc0, crc1;
-
- k0 = k[0] & m[0];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key24(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2;
- uint64_t *m = mask;
- uint32_t crc0, crc1;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- _CRC32CX(crc0, k2);
-
- crc0 ^= crc1;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key32(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2;
- uint64_t *m = mask;
- uint32_t crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc2 = k2;
- _CRC32CX(crc2, k[3] & m[3]);
- crc3 = k2 >> 32;
-
- _CRC32CX(crc0, crc1);
- _CRC32CX(crc2, crc3);
-
- crc0 ^= crc2;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key40(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2;
- uint64_t *m = mask;
- uint32_t crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc2 = k2;
- _CRC32CX(crc2, k[3] & m[3]);
- crc3 = k2 >> 32;
- _CRC32CX(crc3, k[4] & m[4]);
-
- _CRC32CX(crc0, crc1);
- _CRC32CX(crc2, crc3);
-
- crc0 ^= crc2;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key48(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2, k5;
- uint64_t *m = mask;
- uint32_t crc0, crc1, crc2, crc3;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc2 = k2;
- _CRC32CX(crc2, k[3] & m[3]);
- crc3 = k2 >> 32;
- _CRC32CX(crc3, k[4] & m[4]);
-
- _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
- _CRC32CX(crc3, k5);
-
- crc0 ^= crc3;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key56(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2, k5;
- uint64_t *m = mask;
- uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc2 = k2;
- _CRC32CX(crc2, k[3] & m[3]);
- crc3 = k2 >> 32;
- _CRC32CX(crc3, k[4] & m[4]);
-
- crc4 = k5;
- _CRC32CX(crc4, k[6] & m[6]);
- crc5 = k5 >> 32;
-
- _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
- _CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5);
-
- crc0 ^= crc3;
-
- return crc0;
-}
-
-static inline uint64_t
-hash_crc_key64(void *key, void *mask, __rte_unused uint32_t key_size,
- uint64_t seed)
-{
- uint64_t *k = key, k0, k2, k5;
- uint64_t *m = mask;
- uint32_t crc0, crc1, crc2, crc3, crc4, crc5;
-
- k0 = k[0] & m[0];
- k2 = k[2] & m[2];
- k5 = k[5] & m[5];
-
- crc0 = k0;
- _CRC32CX(crc0, seed);
- crc1 = k0 >> 32;
- _CRC32CX(crc1, k[1] & m[1]);
-
- crc2 = k2;
- _CRC32CX(crc2, k[3] & m[3]);
- crc3 = k2 >> 32;
- _CRC32CX(crc3, k[4] & m[4]);
-
- crc4 = k5;
- _CRC32CX(crc4, k[6] & m[6]);
- crc5 = k5 >> 32;
- _CRC32CX(crc5, k[7] & m[7]);
-
- _CRC32CX(crc0, ((uint64_t)crc1 << 32) ^ crc2);
- _CRC32CX(crc3, ((uint64_t)crc4 << 32) ^ crc5);
-
- crc0 ^= crc3;
-
- return crc0;
-}
-
-#define hash_default_key8 hash_crc_key8
-#define hash_default_key16 hash_crc_key16
-#define hash_default_key24 hash_crc_key24
-#define hash_default_key32 hash_crc_key32
-#define hash_default_key40 hash_crc_key40
-#define hash_default_key48 hash_crc_key48
-#define hash_default_key56 hash_crc_key56
-#define hash_default_key64 hash_crc_key64
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_actions_common.h b/examples/ip_pipeline/pipeline/pipeline_actions_common.h
deleted file mode 100644
index 23f88367..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_actions_common.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-#ifndef __INCLUDE_PIPELINE_ACTIONS_COMMON_H__
-#define __INCLUDE_PIPELINE_ACTIONS_COMMON_H__
-
-#include <stdint.h>
-
-#include <rte_common.h>
-#include <rte_cycles.h>
-#include <rte_mbuf.h>
-#include <rte_pipeline.h>
-
-#define PIPELINE_PORT_IN_AH(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- __rte_unused struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint32_t n_pkts, \
- void *arg) \
-{ \
- uint32_t i; \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
- f_pkt4_work(&pkts[i], arg); \
- \
- for ( ; i < n_pkts; i++) \
- f_pkt_work(pkts[i], arg); \
- \
- return 0; \
-}
-
-#define PIPELINE_PORT_IN_AH_HIJACK_ALL(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint32_t n_pkts, \
- void *arg) \
-{ \
- uint64_t pkt_mask = RTE_LEN2MASK(n_pkts, uint64_t); \
- uint32_t i; \
- \
- rte_pipeline_ah_packet_hijack(p, pkt_mask); \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
- f_pkt4_work(&pkts[i], arg); \
- \
- for ( ; i < n_pkts; i++) \
- f_pkt_work(pkts[i], arg); \
- \
- return 0; \
-}
-
-#define PIPELINE_TABLE_AH_HIT(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- __rte_unused struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint64_t pkts_in_mask, \
- struct rte_pipeline_table_entry **entries, \
- void *arg) \
-{ \
- if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
- uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
- uint32_t i; \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
- f_pkt4_work(&pkts[i], &entries[i], arg); \
- \
- for ( ; i < n_pkts; i++) \
- f_pkt_work(pkts[i], entries[i], arg); \
- } else \
- for ( ; pkts_in_mask; ) { \
- uint32_t pos = __builtin_ctzll(pkts_in_mask); \
- uint64_t pkt_mask = 1LLU << pos; \
- \
- pkts_in_mask &= ~pkt_mask; \
- f_pkt_work(pkts[pos], entries[pos], arg); \
- } \
- \
- return 0; \
-}
-
-#define PIPELINE_TABLE_AH_MISS(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- __rte_unused struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint64_t pkts_in_mask, \
- struct rte_pipeline_table_entry *entry, \
- void *arg) \
-{ \
- if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
- uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
- uint32_t i; \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) \
- f_pkt4_work(&pkts[i], entry, arg); \
- \
- for ( ; i < n_pkts; i++) \
- f_pkt_work(pkts[i], entry, arg); \
- } else \
- for ( ; pkts_in_mask; ) { \
- uint32_t pos = __builtin_ctzll(pkts_in_mask); \
- uint64_t pkt_mask = 1LLU << pos; \
- \
- pkts_in_mask &= ~pkt_mask; \
- f_pkt_work(pkts[pos], entry, arg); \
- } \
- \
- return 0; \
-}
-
-#define PIPELINE_TABLE_AH_HIT_DROP_TIME(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint64_t pkts_mask, \
- struct rte_pipeline_table_entry **entries, \
- void *arg) \
-{ \
- uint64_t pkts_in_mask = pkts_mask; \
- uint64_t pkts_out_mask = pkts_mask; \
- uint64_t time = rte_rdtsc(); \
- \
- if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
- uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
- uint32_t i; \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
- uint64_t mask = f_pkt4_work(&pkts[i], \
- &entries[i], arg, time); \
- pkts_out_mask ^= mask << i; \
- } \
- \
- for ( ; i < n_pkts; i++) { \
- uint64_t mask = f_pkt_work(pkts[i], \
- entries[i], arg, time); \
- pkts_out_mask ^= mask << i; \
- } \
- } else \
- for ( ; pkts_in_mask; ) { \
- uint32_t pos = __builtin_ctzll(pkts_in_mask); \
- uint64_t pkt_mask = 1LLU << pos; \
- uint64_t mask = f_pkt_work(pkts[pos], \
- entries[pos], arg, time); \
- \
- pkts_in_mask &= ~pkt_mask; \
- pkts_out_mask ^= mask << pos; \
- } \
- \
- rte_pipeline_ah_packet_drop(p, pkts_out_mask ^ pkts_mask); \
- \
- return 0; \
-}
-
-#define PIPELINE_TABLE_AH_MISS_DROP_TIME(f_ah, f_pkt_work, f_pkt4_work) \
-static int \
-f_ah( \
- struct rte_pipeline *p, \
- struct rte_mbuf **pkts, \
- uint64_t pkts_mask, \
- struct rte_pipeline_table_entry *entry, \
- void *arg) \
-{ \
- uint64_t pkts_in_mask = pkts_mask; \
- uint64_t pkts_out_mask = pkts_mask; \
- uint64_t time = rte_rdtsc(); \
- \
- if ((pkts_in_mask & (pkts_in_mask + 1)) == 0) { \
- uint64_t n_pkts = __builtin_popcountll(pkts_in_mask); \
- uint32_t i; \
- \
- for (i = 0; i < (n_pkts & (~0x3LLU)); i += 4) { \
- uint64_t mask = f_pkt4_work(&pkts[i], \
- entry, arg, time); \
- pkts_out_mask ^= mask << i; \
- } \
- \
- for ( ; i < n_pkts; i++) { \
- uint64_t mask = f_pkt_work(pkts[i], entry, arg, time);\
- pkts_out_mask ^= mask << i; \
- } \
- } else \
- for ( ; pkts_in_mask; ) { \
- uint32_t pos = __builtin_ctzll(pkts_in_mask); \
- uint64_t pkt_mask = 1LLU << pos; \
- uint64_t mask = f_pkt_work(pkts[pos], \
- entry, arg, time); \
- \
- pkts_in_mask &= ~pkt_mask; \
- pkts_out_mask ^= mask << pos; \
- } \
- \
- rte_pipeline_ah_packet_drop(p, pkts_out_mask ^ pkts_mask); \
- \
- return 0; \
-}
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_common_be.c b/examples/ip_pipeline/pipeline/pipeline_common_be.c
deleted file mode 100644
index 5d84989a..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_common_be.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-
-#include "pipeline_common_be.h"
-
-void *
-pipeline_msg_req_ping_handler(__rte_unused struct pipeline *p,
- void *msg)
-{
- struct pipeline_msg_rsp *rsp = msg;
-
- rsp->status = 0; /* OK */
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_stats_port_in_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_stats_msg_req *req = msg;
- struct pipeline_stats_port_in_msg_rsp *rsp = msg;
- uint32_t port_id;
-
- /* Check request */
- if (req->id >= p->n_ports_in) {
- rsp->status = -1;
- return rsp;
- }
- port_id = p->port_in_id[req->id];
-
- /* Process request */
- rsp->status = rte_pipeline_port_in_stats_read(p->p,
- port_id,
- &rsp->stats,
- 1);
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_stats_port_out_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_stats_msg_req *req = msg;
- struct pipeline_stats_port_out_msg_rsp *rsp = msg;
- uint32_t port_id;
-
- /* Check request */
- if (req->id >= p->n_ports_out) {
- rsp->status = -1;
- return rsp;
- }
- port_id = p->port_out_id[req->id];
-
- /* Process request */
- rsp->status = rte_pipeline_port_out_stats_read(p->p,
- port_id,
- &rsp->stats,
- 1);
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_stats_table_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_stats_msg_req *req = msg;
- struct pipeline_stats_table_msg_rsp *rsp = msg;
- uint32_t table_id;
-
- /* Check request */
- if (req->id >= p->n_tables) {
- rsp->status = -1;
- return rsp;
- }
- table_id = p->table_id[req->id];
-
- /* Process request */
- rsp->status = rte_pipeline_table_stats_read(p->p,
- table_id,
- &rsp->stats,
- 1);
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_port_in_enable_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_port_in_msg_req *req = msg;
- struct pipeline_msg_rsp *rsp = msg;
- uint32_t port_id;
-
- /* Check request */
- if (req->port_id >= p->n_ports_in) {
- rsp->status = -1;
- return rsp;
- }
- port_id = p->port_in_id[req->port_id];
-
- /* Process request */
- rsp->status = rte_pipeline_port_in_enable(p->p,
- port_id);
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_port_in_disable_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_port_in_msg_req *req = msg;
- struct pipeline_msg_rsp *rsp = msg;
- uint32_t port_id;
-
- /* Check request */
- if (req->port_id >= p->n_ports_in) {
- rsp->status = -1;
- return rsp;
- }
- port_id = p->port_in_id[req->port_id];
-
- /* Process request */
- rsp->status = rte_pipeline_port_in_disable(p->p,
- port_id);
-
- return rsp;
-}
-
-void *
-pipeline_msg_req_invalid_handler(__rte_unused struct pipeline *p,
- void *msg)
-{
- struct pipeline_msg_rsp *rsp = msg;
-
- rsp->status = -1; /* Error */
-
- return rsp;
-}
-
-int
-pipeline_msg_req_handle(struct pipeline *p)
-{
- uint32_t msgq_id;
-
- for (msgq_id = 0; msgq_id < p->n_msgq; msgq_id++) {
- for ( ; ; ) {
- struct pipeline_msg_req *req;
- pipeline_msg_req_handler f_handle;
-
- req = pipeline_msg_recv(p, msgq_id);
- if (req == NULL)
- break;
-
- f_handle = (req->type < PIPELINE_MSG_REQS) ?
- p->handlers[req->type] :
- pipeline_msg_req_invalid_handler;
-
- if (f_handle == NULL)
- f_handle = pipeline_msg_req_invalid_handler;
-
- pipeline_msg_send(p,
- msgq_id,
- f_handle(p, (void *) req));
- }
- }
-
- return 0;
-}
diff --git a/examples/ip_pipeline/pipeline/pipeline_common_be.h b/examples/ip_pipeline/pipeline/pipeline_common_be.h
deleted file mode 100644
index 83bd04e6..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_common_be.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_COMMON_BE_H__
-#define __INCLUDE_PIPELINE_COMMON_BE_H__
-
-#include <rte_common.h>
-#include <rte_ring.h>
-#include <rte_pipeline.h>
-
-#include "pipeline_be.h"
-
-struct pipeline;
-
-enum pipeline_msg_req_type {
- PIPELINE_MSG_REQ_PING = 0,
- PIPELINE_MSG_REQ_STATS_PORT_IN,
- PIPELINE_MSG_REQ_STATS_PORT_OUT,
- PIPELINE_MSG_REQ_STATS_TABLE,
- PIPELINE_MSG_REQ_PORT_IN_ENABLE,
- PIPELINE_MSG_REQ_PORT_IN_DISABLE,
- PIPELINE_MSG_REQ_CUSTOM,
- PIPELINE_MSG_REQS
-};
-
-typedef void *(*pipeline_msg_req_handler)(struct pipeline *p, void *msg);
-
-struct pipeline {
- struct rte_pipeline *p;
- uint32_t port_in_id[PIPELINE_MAX_PORT_IN];
- uint32_t port_out_id[PIPELINE_MAX_PORT_OUT];
- uint32_t table_id[PIPELINE_MAX_TABLES];
- struct rte_ring *msgq_in[PIPELINE_MAX_MSGQ_IN];
- struct rte_ring *msgq_out[PIPELINE_MAX_MSGQ_OUT];
-
- uint32_t n_ports_in;
- uint32_t n_ports_out;
- uint32_t n_tables;
- uint32_t n_msgq;
-
- pipeline_msg_req_handler handlers[PIPELINE_MSG_REQS];
- char name[PIPELINE_NAME_SIZE];
- uint32_t log_level;
-};
-
-enum pipeline_log_level {
- PIPELINE_LOG_LEVEL_HIGH = 1,
- PIPELINE_LOG_LEVEL_LOW,
- PIPELINE_LOG_LEVELS
-};
-
-#define PLOG(p, level, fmt, ...) \
-do { \
- if (p->log_level >= PIPELINE_LOG_LEVEL_ ## level) \
- fprintf(stdout, "[%s] " fmt "\n", p->name, ## __VA_ARGS__);\
-} while (0)
-
-static inline void *
-pipeline_msg_recv(struct pipeline *p,
- uint32_t msgq_id)
-{
- struct rte_ring *r = p->msgq_in[msgq_id];
- void *msg;
- int status = rte_ring_sc_dequeue(r, &msg);
-
- if (status != 0)
- return NULL;
-
- return msg;
-}
-
-static inline void
-pipeline_msg_send(struct pipeline *p,
- uint32_t msgq_id,
- void *msg)
-{
- struct rte_ring *r = p->msgq_out[msgq_id];
- int status;
-
- do {
- status = rte_ring_sp_enqueue(r, msg);
- } while (status == -ENOBUFS);
-}
-
-struct pipeline_msg_req {
- enum pipeline_msg_req_type type;
-};
-
-struct pipeline_stats_msg_req {
- enum pipeline_msg_req_type type;
- uint32_t id;
-};
-
-struct pipeline_port_in_msg_req {
- enum pipeline_msg_req_type type;
- uint32_t port_id;
-};
-
-struct pipeline_custom_msg_req {
- enum pipeline_msg_req_type type;
- uint32_t subtype;
-};
-
-struct pipeline_msg_rsp {
- int status;
-};
-
-struct pipeline_stats_port_in_msg_rsp {
- int status;
- struct rte_pipeline_port_in_stats stats;
-};
-
-struct pipeline_stats_port_out_msg_rsp {
- int status;
- struct rte_pipeline_port_out_stats stats;
-};
-
-struct pipeline_stats_table_msg_rsp {
- int status;
- struct rte_pipeline_table_stats stats;
-};
-
-void *pipeline_msg_req_ping_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_stats_port_in_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_stats_port_out_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_stats_table_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_port_in_enable_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_port_in_disable_handler(struct pipeline *p, void *msg);
-void *pipeline_msg_req_invalid_handler(struct pipeline *p, void *msg);
-
-int pipeline_msg_req_handle(struct pipeline *p);
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
deleted file mode 100644
index cc5214c7..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c
+++ /dev/null
@@ -1,1455 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <cmdline_rdline.h>
-#include <cmdline_parse.h>
-#include <cmdline_parse_num.h>
-#include <cmdline_parse_string.h>
-#include <cmdline.h>
-
-#include "pipeline_common_fe.h"
-#include "parser.h"
-
-struct app_link_params *
-app_pipeline_track_pktq_out_to_link(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t pktq_out_id)
-{
- struct app_pipeline_params *p;
-
- /* Check input arguments */
- if (app == NULL)
- return NULL;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if (p == NULL)
- return NULL;
-
- for ( ; ; ) {
- struct app_pktq_out_params *pktq_out =
- &p->pktq_out[pktq_out_id];
-
- switch (pktq_out->type) {
- case APP_PKTQ_OUT_HWQ:
- {
- struct app_pktq_hwq_out_params *hwq_out;
-
- hwq_out = &app->hwq_out_params[pktq_out->id];
-
- return app_get_link_for_txq(app, hwq_out);
- }
-
- case APP_PKTQ_OUT_SWQ:
- {
- struct pipeline_params pp;
- struct pipeline_type *ptype;
- struct app_pktq_swq_params *swq;
- uint32_t pktq_in_id;
- int status;
-
- swq = &app->swq_params[pktq_out->id];
- p = app_swq_get_reader(app, swq, &pktq_in_id);
- if (p == NULL)
- return NULL;
-
- ptype = app_pipeline_type_find(app, p->type);
- if ((ptype == NULL) || (ptype->fe_ops->f_track == NULL))
- return NULL;
-
- app_pipeline_params_get(app, p, &pp);
- status = ptype->fe_ops->f_track(&pp,
- pktq_in_id,
- &pktq_out_id);
- if (status)
- return NULL;
-
- break;
- }
-
- case APP_PKTQ_OUT_TM:
- {
- struct pipeline_params pp;
- struct pipeline_type *ptype;
- struct app_pktq_tm_params *tm;
- uint32_t pktq_in_id;
- int status;
-
- tm = &app->tm_params[pktq_out->id];
- p = app_tm_get_reader(app, tm, &pktq_in_id);
- if (p == NULL)
- return NULL;
-
- ptype = app_pipeline_type_find(app, p->type);
- if ((ptype == NULL) || (ptype->fe_ops->f_track == NULL))
- return NULL;
-
- app_pipeline_params_get(app, p, &pp);
- status = ptype->fe_ops->f_track(&pp,
- pktq_in_id,
- &pktq_out_id);
- if (status)
- return NULL;
-
- break;
- }
-
- case APP_PKTQ_OUT_KNI:
- {
- struct pipeline_params pp;
- struct pipeline_type *ptype;
- struct app_pktq_kni_params *kni;
- uint32_t pktq_in_id;
- int status;
-
- kni = &app->kni_params[pktq_out->id];
- p = app_kni_get_reader(app, kni, &pktq_in_id);
- if (p == NULL)
- return NULL;
-
- ptype = app_pipeline_type_find(app, p->type);
- if ((ptype == NULL) || (ptype->fe_ops->f_track == NULL))
- return NULL;
-
- app_pipeline_params_get(app, p, &pp);
- status = ptype->fe_ops->f_track(&pp,
- pktq_in_id,
- &pktq_out_id);
- if (status)
- return NULL;
-
- break;
- }
-
- case APP_PKTQ_OUT_TAP:
- case APP_PKTQ_OUT_SINK:
- default:
- return NULL;
- }
- }
-}
-
-int
-app_pipeline_track_default(struct pipeline_params *p,
- uint32_t port_in,
- uint32_t *port_out)
-{
- /* Check input arguments */
- if ((p == NULL) ||
- (port_in >= p->n_ports_in) ||
- (port_out == NULL))
- return -1;
-
- if (p->n_ports_out == 1) {
- *port_out = 0;
- return 0;
- }
-
- return -1;
-}
-
-int
-app_pipeline_ping(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_params *p;
- struct pipeline_msg_req *req;
- struct pipeline_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if (p == NULL)
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_PING;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_pipeline_stats_port_in(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id,
- struct rte_pipeline_port_in_stats *stats)
-{
- struct app_pipeline_params *p;
- struct pipeline_stats_msg_req *req;
- struct pipeline_stats_port_in_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (stats == NULL))
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if ((p == NULL) ||
- (port_id >= p->n_pktq_in))
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_STATS_PORT_IN;
- req->id = port_id;
-
- /* Send request and wait for response */
- rsp = (struct pipeline_stats_port_in_msg_rsp *)
- app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
- if (status == 0)
- memcpy(stats, &rsp->stats, sizeof(rsp->stats));
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_pipeline_stats_port_out(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id,
- struct rte_pipeline_port_out_stats *stats)
-{
- struct app_pipeline_params *p;
- struct pipeline_stats_msg_req *req;
- struct pipeline_stats_port_out_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (pipeline_id >= app->n_pipelines) ||
- (stats == NULL))
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if ((p == NULL) ||
- (port_id >= p->n_pktq_out))
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_STATS_PORT_OUT;
- req->id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
- if (status == 0)
- memcpy(stats, &rsp->stats, sizeof(rsp->stats));
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_pipeline_stats_table(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t table_id,
- struct rte_pipeline_table_stats *stats)
-{
- struct app_pipeline_params *p;
- struct pipeline_stats_msg_req *req;
- struct pipeline_stats_table_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (stats == NULL))
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if (p == NULL)
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_STATS_TABLE;
- req->id = table_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
- if (status == 0)
- memcpy(stats, &rsp->stats, sizeof(rsp->stats));
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_pipeline_port_in_enable(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct app_pipeline_params *p;
- struct pipeline_port_in_msg_req *req;
- struct pipeline_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if ((p == NULL) ||
- (port_id >= p->n_pktq_in))
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_PORT_IN_ENABLE;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_pipeline_port_in_disable(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct app_pipeline_params *p;
- struct pipeline_port_in_msg_req *req;
- struct pipeline_msg_rsp *rsp;
- int status = 0;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if ((p == NULL) ||
- (port_id >= p->n_pktq_in))
- return -1;
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- /* Fill in request */
- req->type = PIPELINE_MSG_REQ_PORT_IN_DISABLE;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Check response */
- status = rsp->status;
-
- /* Message buffer free */
- app_msg_free(app, rsp);
-
- return status;
-}
-
-int
-app_link_set_op(struct app_params *app,
- uint32_t link_id,
- uint32_t pipeline_id,
- app_link_op op,
- void *arg)
-{
- struct app_pipeline_params *pp;
- struct app_link_params *lp;
- struct app_link_data *ld;
- uint32_t ppos, lpos;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (op == NULL))
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, lp);
- if (lp == NULL)
- return -1;
- lpos = lp - app->link_params;
- ld = &app->link_data[lpos];
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, pp);
- if (pp == NULL)
- return -1;
- ppos = pp - app->pipeline_params;
-
- ld->f_link[ppos] = op;
- ld->arg[ppos] = arg;
-
- return 0;
-}
-
-int
-app_link_config(struct app_params *app,
- uint32_t link_id,
- uint32_t ip,
- uint32_t depth)
-{
- struct app_link_params *p;
- uint32_t i, netmask, host, bcast;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
- if (p == NULL) {
- APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
- link_id);
- return -1;
- }
-
- if (p->state) {
- APP_LOG(app, HIGH, "%s is UP, please bring it DOWN first",
- p->name);
- return -1;
- }
-
- netmask = (~0U) << (32 - depth);
- host = ip & netmask;
- bcast = host | (~netmask);
-
- if ((ip == 0) ||
- (ip == UINT32_MAX) ||
- (ip == host) ||
- (ip == bcast)) {
- APP_LOG(app, HIGH, "Illegal IP address");
- return -1;
- }
-
- for (i = 0; i < app->n_links; i++) {
- struct app_link_params *link = &app->link_params[i];
-
- if (strcmp(p->name, link->name) == 0)
- continue;
-
- if (link->ip == ip) {
- APP_LOG(app, HIGH,
- "%s is already assigned this IP address",
- link->name);
- return -1;
- }
- }
-
- if ((depth == 0) || (depth > 32)) {
- APP_LOG(app, HIGH, "Illegal value for depth parameter "
- "(%" PRIu32 ")",
- depth);
- return -1;
- }
-
- /* Save link parameters */
- p->ip = ip;
- p->depth = depth;
-
- return 0;
-}
-
-int
-app_link_up(struct app_params *app,
- uint32_t link_id)
-{
- struct app_link_params *p;
- struct app_link_data *d;
- int i;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
- if (p == NULL) {
- APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
- link_id);
- return -1;
- }
-
- d = &app->link_data[p - app->link_params];
-
- /* Check link state */
- if (p->state) {
- APP_LOG(app, HIGH, "%s is already UP", p->name);
- return 0;
- }
-
- /* Check that IP address is valid */
- if (p->ip == 0) {
- APP_LOG(app, HIGH, "%s IP address is not set", p->name);
- return 0;
- }
-
- app_link_up_internal(app, p);
-
- /* Callbacks */
- for (i = 0; i < APP_MAX_PIPELINES; i++)
- if (d->f_link[i])
- d->f_link[i](app, link_id, 1, d->arg[i]);
-
- return 0;
-}
-
-int
-app_link_down(struct app_params *app,
- uint32_t link_id)
-{
- struct app_link_params *p;
- struct app_link_data *d;
- uint32_t i;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
- if (p == NULL) {
- APP_LOG(app, HIGH, "LINK%" PRIu32 " is not a valid link",
- link_id);
- return -1;
- }
-
- d = &app->link_data[p - app->link_params];
-
- /* Check link state */
- if (p->state == 0) {
- APP_LOG(app, HIGH, "%s is already DOWN", p->name);
- return 0;
- }
-
- app_link_down_internal(app, p);
-
- /* Callbacks */
- for (i = 0; i < APP_MAX_PIPELINES; i++)
- if (d->f_link[i])
- d->f_link[i](app, link_id, 0, d->arg[i]);
-
- return 0;
-}
-
-/*
- * ping
- */
-
-struct cmd_ping_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t ping_string;
-};
-
-static void
-cmd_ping_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_ping_result *params = parsed_result;
- struct app_params *app = data;
- int status;
-
- status = app_pipeline_ping(app, params->pipeline_id);
- if (status != 0)
- printf("Command failed\n");
-}
-
-static cmdline_parse_token_string_t cmd_ping_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_ping_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_ping_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_ping_result, pipeline_id, UINT32);
-
-static cmdline_parse_token_string_t cmd_ping_ping_string =
- TOKEN_STRING_INITIALIZER(struct cmd_ping_result, ping_string, "ping");
-
-static cmdline_parse_inst_t cmd_ping = {
- .f = cmd_ping_parsed,
- .data = NULL,
- .help_str = "Pipeline ping",
- .tokens = {
- (void *) &cmd_ping_p_string,
- (void *) &cmd_ping_pipeline_id,
- (void *) &cmd_ping_ping_string,
- NULL,
- },
-};
-
-/*
- * stats port in
- */
-
-struct cmd_stats_port_in_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t stats_string;
- cmdline_fixed_string_t port_string;
- cmdline_fixed_string_t in_string;
- uint32_t port_in_id;
-
-};
-
-static void
-cmd_stats_port_in_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_stats_port_in_result *params = parsed_result;
- struct app_params *app = data;
- struct rte_pipeline_port_in_stats stats;
- int status;
-
- status = app_pipeline_stats_port_in(app,
- params->pipeline_id,
- params->port_in_id,
- &stats);
-
- if (status != 0) {
- printf("Command failed\n");
- return;
- }
-
- /* Display stats */
- printf("Pipeline %" PRIu32 " - stats for input port %" PRIu32 ":\n"
- "\tPkts in: %" PRIu64 "\n"
- "\tPkts dropped by AH: %" PRIu64 "\n"
- "\tPkts dropped by other: %" PRIu64 "\n",
- params->pipeline_id,
- params->port_in_id,
- stats.stats.n_pkts_in,
- stats.n_pkts_dropped_by_ah,
- stats.stats.n_pkts_drop);
-}
-
-static cmdline_parse_token_string_t cmd_stats_port_in_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, p_string,
- "p");
-
-static cmdline_parse_token_num_t cmd_stats_port_in_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, pipeline_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_stats_port_in_stats_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, stats_string,
- "stats");
-
-static cmdline_parse_token_string_t cmd_stats_port_in_port_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, port_string,
- "port");
-
-static cmdline_parse_token_string_t cmd_stats_port_in_in_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_in_result, in_string,
- "in");
-
- cmdline_parse_token_num_t cmd_stats_port_in_port_in_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_port_in_result, port_in_id,
- UINT32);
-
-static cmdline_parse_inst_t cmd_stats_port_in = {
- .f = cmd_stats_port_in_parsed,
- .data = NULL,
- .help_str = "Pipeline input port stats",
- .tokens = {
- (void *) &cmd_stats_port_in_p_string,
- (void *) &cmd_stats_port_in_pipeline_id,
- (void *) &cmd_stats_port_in_stats_string,
- (void *) &cmd_stats_port_in_port_string,
- (void *) &cmd_stats_port_in_in_string,
- (void *) &cmd_stats_port_in_port_in_id,
- NULL,
- },
-};
-
-/*
- * stats port out
- */
-
-struct cmd_stats_port_out_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t stats_string;
- cmdline_fixed_string_t port_string;
- cmdline_fixed_string_t out_string;
- uint32_t port_out_id;
-};
-
-static void
-cmd_stats_port_out_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
-
- struct cmd_stats_port_out_result *params = parsed_result;
- struct app_params *app = data;
- struct rte_pipeline_port_out_stats stats;
- int status;
-
- status = app_pipeline_stats_port_out(app,
- params->pipeline_id,
- params->port_out_id,
- &stats);
-
- if (status != 0) {
- printf("Command failed\n");
- return;
- }
-
- /* Display stats */
- printf("Pipeline %" PRIu32 " - stats for output port %" PRIu32 ":\n"
- "\tPkts in: %" PRIu64 "\n"
- "\tPkts dropped by AH: %" PRIu64 "\n"
- "\tPkts dropped by other: %" PRIu64 "\n",
- params->pipeline_id,
- params->port_out_id,
- stats.stats.n_pkts_in,
- stats.n_pkts_dropped_by_ah,
- stats.stats.n_pkts_drop);
-}
-
-static cmdline_parse_token_string_t cmd_stats_port_out_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, p_string,
- "p");
-
-static cmdline_parse_token_num_t cmd_stats_port_out_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, pipeline_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_stats_port_out_stats_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, stats_string,
- "stats");
-
-static cmdline_parse_token_string_t cmd_stats_port_out_port_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, port_string,
- "port");
-
-static cmdline_parse_token_string_t cmd_stats_port_out_out_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_port_out_result, out_string,
- "out");
-
-static cmdline_parse_token_num_t cmd_stats_port_out_port_out_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_port_out_result, port_out_id,
- UINT32);
-
-static cmdline_parse_inst_t cmd_stats_port_out = {
- .f = cmd_stats_port_out_parsed,
- .data = NULL,
- .help_str = "Pipeline output port stats",
- .tokens = {
- (void *) &cmd_stats_port_out_p_string,
- (void *) &cmd_stats_port_out_pipeline_id,
- (void *) &cmd_stats_port_out_stats_string,
- (void *) &cmd_stats_port_out_port_string,
- (void *) &cmd_stats_port_out_out_string,
- (void *) &cmd_stats_port_out_port_out_id,
- NULL,
- },
-};
-
-/*
- * stats table
- */
-
-struct cmd_stats_table_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t stats_string;
- cmdline_fixed_string_t table_string;
- uint32_t table_id;
-};
-
-static void
-cmd_stats_table_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_stats_table_result *params = parsed_result;
- struct app_params *app = data;
- struct rte_pipeline_table_stats stats;
- int status;
-
- status = app_pipeline_stats_table(app,
- params->pipeline_id,
- params->table_id,
- &stats);
-
- if (status != 0) {
- printf("Command failed\n");
- return;
- }
-
- /* Display stats */
- printf("Pipeline %" PRIu32 " - stats for table %" PRIu32 ":\n"
- "\tPkts in: %" PRIu64 "\n"
- "\tPkts in with lookup miss: %" PRIu64 "\n"
- "\tPkts in with lookup hit dropped by AH: %" PRIu64 "\n"
- "\tPkts in with lookup hit dropped by others: %" PRIu64 "\n"
- "\tPkts in with lookup miss dropped by AH: %" PRIu64 "\n"
- "\tPkts in with lookup miss dropped by others: %" PRIu64 "\n",
- params->pipeline_id,
- params->table_id,
- stats.stats.n_pkts_in,
- stats.stats.n_pkts_lookup_miss,
- stats.n_pkts_dropped_by_lkp_hit_ah,
- stats.n_pkts_dropped_lkp_hit,
- stats.n_pkts_dropped_by_lkp_miss_ah,
- stats.n_pkts_dropped_lkp_miss);
-}
-
-static cmdline_parse_token_string_t cmd_stats_table_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, p_string,
- "p");
-
-static cmdline_parse_token_num_t cmd_stats_table_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, pipeline_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_stats_table_stats_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, stats_string,
- "stats");
-
-static cmdline_parse_token_string_t cmd_stats_table_table_string =
- TOKEN_STRING_INITIALIZER(struct cmd_stats_table_result, table_string,
- "table");
-
-static cmdline_parse_token_num_t cmd_stats_table_table_id =
- TOKEN_NUM_INITIALIZER(struct cmd_stats_table_result, table_id, UINT32);
-
-static cmdline_parse_inst_t cmd_stats_table = {
- .f = cmd_stats_table_parsed,
- .data = NULL,
- .help_str = "Pipeline table stats",
- .tokens = {
- (void *) &cmd_stats_table_p_string,
- (void *) &cmd_stats_table_pipeline_id,
- (void *) &cmd_stats_table_stats_string,
- (void *) &cmd_stats_table_table_string,
- (void *) &cmd_stats_table_table_id,
- NULL,
- },
-};
-
-/*
- * port in enable
- */
-
-struct cmd_port_in_enable_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t port_string;
- cmdline_fixed_string_t in_string;
- uint32_t port_in_id;
- cmdline_fixed_string_t enable_string;
-};
-
-static void
-cmd_port_in_enable_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_port_in_enable_result *params = parsed_result;
- struct app_params *app = data;
- int status;
-
- status = app_pipeline_port_in_enable(app,
- params->pipeline_id,
- params->port_in_id);
-
- if (status != 0)
- printf("Command failed\n");
-}
-
-static cmdline_parse_token_string_t cmd_port_in_enable_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, p_string,
- "p");
-
-static cmdline_parse_token_num_t cmd_port_in_enable_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, pipeline_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_port_in_enable_port_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, port_string,
- "port");
-
-static cmdline_parse_token_string_t cmd_port_in_enable_in_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result, in_string,
- "in");
-
-static cmdline_parse_token_num_t cmd_port_in_enable_port_in_id =
- TOKEN_NUM_INITIALIZER(struct cmd_port_in_enable_result, port_in_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_port_in_enable_enable_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_enable_result,
- enable_string, "enable");
-
-static cmdline_parse_inst_t cmd_port_in_enable = {
- .f = cmd_port_in_enable_parsed,
- .data = NULL,
- .help_str = "Pipeline input port enable",
- .tokens = {
- (void *) &cmd_port_in_enable_p_string,
- (void *) &cmd_port_in_enable_pipeline_id,
- (void *) &cmd_port_in_enable_port_string,
- (void *) &cmd_port_in_enable_in_string,
- (void *) &cmd_port_in_enable_port_in_id,
- (void *) &cmd_port_in_enable_enable_string,
- NULL,
- },
-};
-
-/*
- * port in disable
- */
-
-struct cmd_port_in_disable_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t port_string;
- cmdline_fixed_string_t in_string;
- uint32_t port_in_id;
- cmdline_fixed_string_t disable_string;
-};
-
-static void
-cmd_port_in_disable_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_port_in_disable_result *params = parsed_result;
- struct app_params *app = data;
- int status;
-
- status = app_pipeline_port_in_disable(app,
- params->pipeline_id,
- params->port_in_id);
-
- if (status != 0)
- printf("Command failed\n");
-}
-
-static cmdline_parse_token_string_t cmd_port_in_disable_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, p_string,
- "p");
-
-static cmdline_parse_token_num_t cmd_port_in_disable_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, pipeline_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_port_in_disable_port_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, port_string,
- "port");
-
-static cmdline_parse_token_string_t cmd_port_in_disable_in_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result, in_string,
- "in");
-
-static cmdline_parse_token_num_t cmd_port_in_disable_port_in_id =
- TOKEN_NUM_INITIALIZER(struct cmd_port_in_disable_result, port_in_id,
- UINT32);
-
-static cmdline_parse_token_string_t cmd_port_in_disable_disable_string =
- TOKEN_STRING_INITIALIZER(struct cmd_port_in_disable_result,
- disable_string, "disable");
-
-static cmdline_parse_inst_t cmd_port_in_disable = {
- .f = cmd_port_in_disable_parsed,
- .data = NULL,
- .help_str = "Pipeline input port disable",
- .tokens = {
- (void *) &cmd_port_in_disable_p_string,
- (void *) &cmd_port_in_disable_pipeline_id,
- (void *) &cmd_port_in_disable_port_string,
- (void *) &cmd_port_in_disable_in_string,
- (void *) &cmd_port_in_disable_port_in_id,
- (void *) &cmd_port_in_disable_disable_string,
- NULL,
- },
-};
-
-/*
- * link config
- */
-
-static void
-print_link_info(struct app_link_params *p)
-{
- struct rte_eth_stats stats;
- struct ether_addr *mac_addr;
- uint32_t netmask = (~0U) << (32 - p->depth);
- uint32_t host = p->ip & netmask;
- uint32_t bcast = host | (~netmask);
-
- memset(&stats, 0, sizeof(stats));
- rte_eth_stats_get(p->pmd_id, &stats);
-
- mac_addr = (struct ether_addr *) &p->mac_addr;
-
- if (strlen(p->pci_bdf))
- printf("%s(%s): flags=<%s>\n",
- p->name,
- p->pci_bdf,
- (p->state) ? "UP" : "DOWN");
- else
- printf("%s: flags=<%s>\n",
- p->name,
- (p->state) ? "UP" : "DOWN");
-
- if (p->ip)
- printf("\tinet %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32
- " netmask %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32 " "
- "broadcast %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32 "\n",
- (p->ip >> 24) & 0xFF,
- (p->ip >> 16) & 0xFF,
- (p->ip >> 8) & 0xFF,
- p->ip & 0xFF,
- (netmask >> 24) & 0xFF,
- (netmask >> 16) & 0xFF,
- (netmask >> 8) & 0xFF,
- netmask & 0xFF,
- (bcast >> 24) & 0xFF,
- (bcast >> 16) & 0xFF,
- (bcast >> 8) & 0xFF,
- bcast & 0xFF);
-
- printf("\tether %02" PRIx32 ":%02" PRIx32 ":%02" PRIx32
- ":%02" PRIx32 ":%02" PRIx32 ":%02" PRIx32 "\n",
- mac_addr->addr_bytes[0],
- mac_addr->addr_bytes[1],
- mac_addr->addr_bytes[2],
- mac_addr->addr_bytes[3],
- mac_addr->addr_bytes[4],
- mac_addr->addr_bytes[5]);
-
- printf("\tRX packets %" PRIu64
- " bytes %" PRIu64
- "\n",
- stats.ipackets,
- stats.ibytes);
-
- printf("\tRX errors %" PRIu64
- " missed %" PRIu64
- " no-mbuf %" PRIu64
- "\n",
- stats.ierrors,
- stats.imissed,
- stats.rx_nombuf);
-
- printf("\tTX packets %" PRIu64
- " bytes %" PRIu64 "\n",
- stats.opackets,
- stats.obytes);
-
- printf("\tTX errors %" PRIu64
- "\n",
- stats.oerrors);
-
- printf("\n");
-}
-
-/*
- * link
- *
- * link config:
- * link <linkid> config <ipaddr> <depth>
- *
- * link up:
- * link <linkid> up
- *
- * link down:
- * link <linkid> down
- *
- * link ls:
- * link ls
- */
-
-struct cmd_link_result {
- cmdline_fixed_string_t link_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_link_parsed(
- void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- void *data)
-{
- struct cmd_link_result *params = parsed_result;
- struct app_params *app = data;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- uint32_t link_id;
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status != 0) {
- printf(CMD_MSG_TOO_MANY_ARGS, "link");
- return;
- }
-
- /* link ls */
- if ((n_tokens == 1) && (strcmp(tokens[0], "ls") == 0)) {
- for (link_id = 0; link_id < app->n_links; link_id++) {
- struct app_link_params *p;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, p);
- print_link_info(p);
- }
- return;
- } /* link ls */
-
- if (n_tokens < 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "link");
- return;
- }
-
- if (parser_read_uint32(&link_id, tokens[0])) {
- printf(CMD_MSG_INVALID_ARG, "linkid");
- return;
- }
-
- /* link config */
- if (strcmp(tokens[1], "config") == 0) {
- struct in_addr ipaddr_ipv4;
- uint32_t depth;
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "link config");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &ipaddr_ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "ipaddr");
- return;
- }
-
- if (parser_read_uint32(&depth, tokens[3])) {
- printf(CMD_MSG_INVALID_ARG, "depth");
- return;
- }
-
- status = app_link_config(app,
- link_id,
- rte_be_to_cpu_32(ipaddr_ipv4.s_addr),
- depth);
- if (status)
- printf(CMD_MSG_FAIL, "link config");
-
- return;
- } /* link config */
-
- /* link up */
- if (strcmp(tokens[1], "up") == 0) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "link up");
- return;
- }
-
- status = app_link_up(app, link_id);
- if (status)
- printf(CMD_MSG_FAIL, "link up");
-
- return;
- } /* link up */
-
- /* link down */
- if (strcmp(tokens[1], "down") == 0) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "link down");
- return;
- }
-
- status = app_link_down(app, link_id);
- if (status)
- printf(CMD_MSG_FAIL, "link down");
-
- return;
- } /* link down */
-
- printf(CMD_MSG_MISMATCH_ARGS, "link");
-}
-
-static cmdline_parse_token_string_t cmd_link_link_string =
- TOKEN_STRING_INITIALIZER(struct cmd_link_result, link_string, "link");
-
-static cmdline_parse_token_string_t cmd_link_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_link_result, multi_string,
- TOKEN_STRING_MULTI);
-
-static cmdline_parse_inst_t cmd_link = {
- .f = cmd_link_parsed,
- .data = NULL,
- .help_str = "link config / up / down / ls",
- .tokens = {
- (void *) &cmd_link_link_string,
- (void *) &cmd_link_multi_string,
- NULL,
- },
-};
-
-/*
- * quit
- */
-
-struct cmd_quit_result {
- cmdline_fixed_string_t quit;
-};
-
-static void
-cmd_quit_parsed(
- __rte_unused void *parsed_result,
- struct cmdline *cl,
- __rte_unused void *data)
-{
- cmdline_quit(cl);
-}
-
-static cmdline_parse_token_string_t cmd_quit_quit =
- TOKEN_STRING_INITIALIZER(struct cmd_quit_result, quit, "quit");
-
-static cmdline_parse_inst_t cmd_quit = {
- .f = cmd_quit_parsed,
- .data = NULL,
- .help_str = "Quit",
- .tokens = {
- (void *) &cmd_quit_quit,
- NULL,
- },
-};
-
-/*
- * run
- *
- * run <file>
- * run <file> [<count> [<interval>]]
- <count> default is 1
- * <interval> is measured in milliseconds, default is 1 second
- */
-
-static void
-app_run_file(
- cmdline_parse_ctx_t *ctx,
- const char *file_name)
-{
- struct cmdline *file_cl;
- int fd;
-
- fd = open(file_name, O_RDONLY);
- if (fd < 0) {
- printf("Cannot open file \"%s\"\n", file_name);
- return;
- }
-
- file_cl = cmdline_new(ctx, "", fd, 1);
- cmdline_interact(file_cl);
- close(fd);
-}
-
-struct cmd_run_result {
- cmdline_fixed_string_t run_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_run_parsed(
- void *parsed_result,
- struct cmdline *cl,
- __attribute__((unused)) void *data)
-{
- struct cmd_run_result *params = parsed_result;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- char *file_name;
- uint32_t count, interval, i;
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status) {
- printf(CMD_MSG_TOO_MANY_ARGS, "run");
- return;
- }
-
- switch (n_tokens) {
- case 0:
- printf(CMD_MSG_NOT_ENOUGH_ARGS, "run");
- return;
-
- case 1:
- file_name = tokens[0];
- count = 1;
- interval = 1000;
- break;
-
- case 2:
- file_name = tokens[0];
-
- if (parser_read_uint32(&count, tokens[1]) ||
- (count == 0)) {
- printf(CMD_MSG_INVALID_ARG, "count");
- return;
- }
-
- interval = 1000;
- break;
-
- case 3:
- file_name = tokens[0];
-
- if (parser_read_uint32(&count, tokens[1]) ||
- (count == 0)) {
- printf(CMD_MSG_INVALID_ARG, "count");
- return;
- }
-
- if (parser_read_uint32(&interval, tokens[2]) ||
- (interval == 0)) {
- printf(CMD_MSG_INVALID_ARG, "interval");
- return;
- }
- break;
-
- default:
- printf(CMD_MSG_MISMATCH_ARGS, "run");
- return;
- }
-
- for (i = 0; i < count; i++) {
- app_run_file(cl->ctx, file_name);
- if (interval)
- usleep(interval * 1000);
- }
-}
-
-static cmdline_parse_token_string_t cmd_run_run_string =
- TOKEN_STRING_INITIALIZER(struct cmd_run_result, run_string, "run");
-
-static cmdline_parse_token_string_t cmd_run_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_run_result, multi_string,
- TOKEN_STRING_MULTI);
-
-
-static cmdline_parse_inst_t cmd_run = {
- .f = cmd_run_parsed,
- .data = NULL,
- .help_str = "Run CLI script file",
- .tokens = {
- (void *) &cmd_run_run_string,
- (void *) &cmd_run_multi_string,
- NULL,
- },
-};
-
-static cmdline_parse_ctx_t pipeline_common_cmds[] = {
- (cmdline_parse_inst_t *) &cmd_quit,
- (cmdline_parse_inst_t *) &cmd_run,
- (cmdline_parse_inst_t *) &cmd_link,
- (cmdline_parse_inst_t *) &cmd_ping,
- (cmdline_parse_inst_t *) &cmd_stats_port_in,
- (cmdline_parse_inst_t *) &cmd_stats_port_out,
- (cmdline_parse_inst_t *) &cmd_stats_table,
- (cmdline_parse_inst_t *) &cmd_port_in_enable,
- (cmdline_parse_inst_t *) &cmd_port_in_disable,
- NULL,
-};
-
-int
-app_pipeline_common_cmd_push(struct app_params *app)
-{
- uint32_t n_cmds, i;
-
- /* Check for available slots in the application commands array */
- n_cmds = RTE_DIM(pipeline_common_cmds) - 1;
- if (n_cmds > APP_MAX_CMDS - app->n_cmds)
- return -ENOMEM;
-
- /* Push pipeline commands into the application */
- memcpy(&app->cmds[app->n_cmds],
- pipeline_common_cmds,
- n_cmds * sizeof(cmdline_parse_ctx_t));
-
- for (i = 0; i < n_cmds; i++)
- app->cmds[app->n_cmds + i]->data = app;
-
- app->n_cmds += n_cmds;
- app->cmds[app->n_cmds] = NULL;
-
- return 0;
-}
diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.h b/examples/ip_pipeline/pipeline/pipeline_common_fe.h
deleted file mode 100644
index 7227544f..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_common_fe.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_COMMON_FE_H__
-#define __INCLUDE_PIPELINE_COMMON_FE_H__
-
-#include <rte_common.h>
-#include <rte_cycles.h>
-#include <rte_malloc.h>
-#include <cmdline_parse.h>
-
-#include "pipeline_common_be.h"
-#include "pipeline.h"
-#include "app.h"
-
-#ifndef MSG_TIMEOUT_DEFAULT
-#define MSG_TIMEOUT_DEFAULT 1000
-#endif
-
-static inline struct app_pipeline_data *
-app_pipeline_data(struct app_params *app, uint32_t id)
-{
- struct app_pipeline_params *params;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", id, params);
- if (params == NULL)
- return NULL;
-
- return &app->pipeline_data[params - app->pipeline_params];
-}
-
-static inline void *
-app_pipeline_data_fe(struct app_params *app, uint32_t id, struct pipeline_type *ptype)
-{
- struct app_pipeline_data *pipeline_data;
-
- pipeline_data = app_pipeline_data(app, id);
- if (pipeline_data == NULL)
- return NULL;
-
- if (strcmp(pipeline_data->ptype->name, ptype->name) != 0)
- return NULL;
-
- if (pipeline_data->enabled == 0)
- return NULL;
-
- return pipeline_data->fe;
-}
-
-static inline struct rte_ring *
-app_pipeline_msgq_in_get(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_msgq_params *p;
-
- APP_PARAM_FIND_BY_ID(app->msgq_params,
- "MSGQ-REQ-PIPELINE",
- pipeline_id,
- p);
- if (p == NULL)
- return NULL;
-
- return app->msgq[p - app->msgq_params];
-}
-
-static inline struct rte_ring *
-app_pipeline_msgq_out_get(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_msgq_params *p;
-
- APP_PARAM_FIND_BY_ID(app->msgq_params,
- "MSGQ-RSP-PIPELINE",
- pipeline_id,
- p);
- if (p == NULL)
- return NULL;
-
- return app->msgq[p - app->msgq_params];
-}
-
-static inline void *
-app_msg_alloc(__rte_unused struct app_params *app)
-{
- return rte_malloc(NULL, 2048, RTE_CACHE_LINE_SIZE);
-}
-
-static inline void
-app_msg_free(__rte_unused struct app_params *app,
- void *msg)
-{
- rte_free(msg);
-}
-
-static inline void
-app_msg_send(struct app_params *app,
- uint32_t pipeline_id,
- void *msg)
-{
- struct rte_ring *r = app_pipeline_msgq_in_get(app, pipeline_id);
- int status;
-
- do {
- status = rte_ring_sp_enqueue(r, msg);
- } while (status == -ENOBUFS);
-}
-
-static inline void *
-app_msg_recv(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct rte_ring *r = app_pipeline_msgq_out_get(app, pipeline_id);
- void *msg;
- int status = rte_ring_sc_dequeue(r, &msg);
-
- if (status != 0)
- return NULL;
-
- return msg;
-}
-
-static inline void *
-app_msg_send_recv(struct app_params *app,
- uint32_t pipeline_id,
- void *msg,
- uint32_t timeout_ms)
-{
- struct rte_ring *r_req = app_pipeline_msgq_in_get(app, pipeline_id);
- struct rte_ring *r_rsp = app_pipeline_msgq_out_get(app, pipeline_id);
- uint64_t hz = rte_get_tsc_hz();
- void *msg_recv;
- uint64_t deadline;
- int status;
-
- /* send */
- do {
- status = rte_ring_sp_enqueue(r_req, (void *) msg);
- } while (status == -ENOBUFS);
-
- /* recv */
- deadline = (timeout_ms) ?
- (rte_rdtsc() + ((hz * timeout_ms) / 1000)) :
- UINT64_MAX;
-
- do {
- if (rte_rdtsc() > deadline)
- return NULL;
-
- status = rte_ring_sc_dequeue(r_rsp, &msg_recv);
- } while (status != 0);
-
- return msg_recv;
-}
-
-struct app_link_params *
-app_pipeline_track_pktq_out_to_link(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t pktq_out_id);
-
-int
-app_pipeline_track_default(struct pipeline_params *params,
- uint32_t port_in,
- uint32_t *port_out);
-
-int
-app_pipeline_ping(struct app_params *app,
- uint32_t pipeline_id);
-
-int
-app_pipeline_stats_port_in(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id,
- struct rte_pipeline_port_in_stats *stats);
-
-int
-app_pipeline_stats_port_out(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id,
- struct rte_pipeline_port_out_stats *stats);
-
-int
-app_pipeline_stats_table(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t table_id,
- struct rte_pipeline_table_stats *stats);
-
-int
-app_pipeline_port_in_enable(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_pipeline_port_in_disable(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_link_set_op(struct app_params *app,
- uint32_t link_id,
- uint32_t pipeline_id,
- app_link_op op,
- void *arg);
-
-int
-app_link_config(struct app_params *app,
- uint32_t link_id,
- uint32_t ip,
- uint32_t depth);
-
-int
-app_link_up(struct app_params *app,
- uint32_t link_id);
-
-int
-app_link_down(struct app_params *app,
- uint32_t link_id);
-
-int
-app_pipeline_common_cmd_push(struct app_params *app);
-
-#define CMD_MSG_OUT_OF_MEMORY "Not enough memory\n"
-#define CMD_MSG_NOT_ENOUGH_ARGS "Not enough arguments for command \"%s\"\n"
-#define CMD_MSG_TOO_MANY_ARGS "Too many arguments for command \"%s\"\n"
-#define CMD_MSG_MISMATCH_ARGS "Incorrect set of arguments for command \"%s\"\n"
-#define CMD_MSG_INVALID_ARG "Invalid value for argument \"%s\"\n"
-#define CMD_MSG_ARG_NOT_FOUND "Syntax error: \"%s\" not found\n"
-#define CMD_MSG_FILE_ERR "Error in file \"%s\" at line %u\n"
-#define CMD_MSG_FAIL "Command \"%s\" failed\n"
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.c b/examples/ip_pipeline/pipeline/pipeline_firewall.c
deleted file mode 100644
index 0cae9d74..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_firewall.c
+++ /dev/null
@@ -1,1421 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/queue.h>
-#include <netinet/in.h>
-
-#include <rte_common.h>
-#include <rte_hexdump.h>
-#include <rte_malloc.h>
-#include <cmdline_rdline.h>
-#include <cmdline_parse.h>
-#include <cmdline_parse_num.h>
-#include <cmdline_parse_string.h>
-
-#include "app.h"
-#include "pipeline_common_fe.h"
-#include "pipeline_firewall.h"
-#include "parser.h"
-
-struct app_pipeline_firewall_rule {
- struct pipeline_firewall_key key;
- int32_t priority;
- uint32_t port_id;
- void *entry_ptr;
-
- TAILQ_ENTRY(app_pipeline_firewall_rule) node;
-};
-
-struct app_pipeline_firewall {
- /* parameters */
- uint32_t n_ports_in;
- uint32_t n_ports_out;
-
- /* rules */
- TAILQ_HEAD(, app_pipeline_firewall_rule) rules;
- uint32_t n_rules;
- uint32_t default_rule_present;
- uint32_t default_rule_port_id;
- void *default_rule_entry_ptr;
-};
-
-static void
-print_firewall_ipv4_rule(struct app_pipeline_firewall_rule *rule)
-{
- printf("Prio = %" PRId32 " (SA = %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32 "/%" PRIu32 ", "
- "DA = %" PRIu32 ".%" PRIu32
- ".%"PRIu32 ".%" PRIu32 "/%" PRIu32 ", "
- "SP = %" PRIu32 "-%" PRIu32 ", "
- "DP = %" PRIu32 "-%" PRIu32 ", "
- "Proto = %" PRIu32 " / 0x%" PRIx32 ") => "
- "Port = %" PRIu32 " (entry ptr = %p)\n",
-
- rule->priority,
-
- (rule->key.key.ipv4_5tuple.src_ip >> 24) & 0xFF,
- (rule->key.key.ipv4_5tuple.src_ip >> 16) & 0xFF,
- (rule->key.key.ipv4_5tuple.src_ip >> 8) & 0xFF,
- rule->key.key.ipv4_5tuple.src_ip & 0xFF,
- rule->key.key.ipv4_5tuple.src_ip_mask,
-
- (rule->key.key.ipv4_5tuple.dst_ip >> 24) & 0xFF,
- (rule->key.key.ipv4_5tuple.dst_ip >> 16) & 0xFF,
- (rule->key.key.ipv4_5tuple.dst_ip >> 8) & 0xFF,
- rule->key.key.ipv4_5tuple.dst_ip & 0xFF,
- rule->key.key.ipv4_5tuple.dst_ip_mask,
-
- rule->key.key.ipv4_5tuple.src_port_from,
- rule->key.key.ipv4_5tuple.src_port_to,
-
- rule->key.key.ipv4_5tuple.dst_port_from,
- rule->key.key.ipv4_5tuple.dst_port_to,
-
- rule->key.key.ipv4_5tuple.proto,
- rule->key.key.ipv4_5tuple.proto_mask,
-
- rule->port_id,
- rule->entry_ptr);
-}
-
-static struct app_pipeline_firewall_rule *
-app_pipeline_firewall_rule_find(struct app_pipeline_firewall *p,
- struct pipeline_firewall_key *key)
-{
- struct app_pipeline_firewall_rule *r;
-
- TAILQ_FOREACH(r, &p->rules, node)
- if (memcmp(key,
- &r->key,
- sizeof(struct pipeline_firewall_key)) == 0)
- return r;
-
- return NULL;
-}
-
-static int
-app_pipeline_firewall_ls(
- struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_firewall *p;
- struct app_pipeline_firewall_rule *rule;
- uint32_t n_rules;
- int priority;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- n_rules = p->n_rules;
- for (priority = 0; n_rules; priority++)
- TAILQ_FOREACH(rule, &p->rules, node)
- if (rule->priority == priority) {
- print_firewall_ipv4_rule(rule);
- n_rules--;
- }
-
- if (p->default_rule_present)
- printf("Default rule: port %" PRIu32 " (entry ptr = %p)\n",
- p->default_rule_port_id,
- p->default_rule_entry_ptr);
- else
- printf("Default rule: DROP\n");
-
- printf("\n");
-
- return 0;
-}
-
-static void*
-app_pipeline_firewall_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct app_pipeline_firewall *p;
- uint32_t size;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct app_pipeline_firewall));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
-
- /* Initialization */
- p->n_ports_in = params->n_ports_in;
- p->n_ports_out = params->n_ports_out;
-
- TAILQ_INIT(&p->rules);
- p->n_rules = 0;
- p->default_rule_present = 0;
- p->default_rule_port_id = 0;
- p->default_rule_entry_ptr = NULL;
-
- return (void *) p;
-}
-
-static int
-app_pipeline_firewall_free(void *pipeline)
-{
- struct app_pipeline_firewall *p = pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- while (!TAILQ_EMPTY(&p->rules)) {
- struct app_pipeline_firewall_rule *rule;
-
- rule = TAILQ_FIRST(&p->rules);
- TAILQ_REMOVE(&p->rules, rule, node);
- rte_free(rule);
- }
-
- rte_free(p);
- return 0;
-}
-
-static int
-app_pipeline_firewall_key_check_and_normalize(struct pipeline_firewall_key *key)
-{
- switch (key->type) {
- case PIPELINE_FIREWALL_IPV4_5TUPLE:
- {
- uint32_t src_ip_depth = key->key.ipv4_5tuple.src_ip_mask;
- uint32_t dst_ip_depth = key->key.ipv4_5tuple.dst_ip_mask;
- uint16_t src_port_from = key->key.ipv4_5tuple.src_port_from;
- uint16_t src_port_to = key->key.ipv4_5tuple.src_port_to;
- uint16_t dst_port_from = key->key.ipv4_5tuple.dst_port_from;
- uint16_t dst_port_to = key->key.ipv4_5tuple.dst_port_to;
-
- uint32_t src_ip_netmask = 0;
- uint32_t dst_ip_netmask = 0;
-
- if ((src_ip_depth > 32) ||
- (dst_ip_depth > 32) ||
- (src_port_from > src_port_to) ||
- (dst_port_from > dst_port_to))
- return -1;
-
- if (src_ip_depth)
- src_ip_netmask = (~0U) << (32 - src_ip_depth);
-
- if (dst_ip_depth)
- dst_ip_netmask = ((~0U) << (32 - dst_ip_depth));
-
- key->key.ipv4_5tuple.src_ip &= src_ip_netmask;
- key->key.ipv4_5tuple.dst_ip &= dst_ip_netmask;
-
- return 0;
- }
-
- default:
- return -1;
- }
-}
-
-int
-app_pipeline_firewall_load_file(char *filename,
- struct pipeline_firewall_key *keys,
- uint32_t *priorities,
- uint32_t *port_ids,
- uint32_t *n_keys,
- uint32_t *line)
-{
- FILE *f = NULL;
- char file_buf[1024];
- uint32_t i, l;
-
- /* Check input arguments */
- if ((filename == NULL) ||
- (keys == NULL) ||
- (priorities == NULL) ||
- (port_ids == NULL) ||
- (n_keys == NULL) ||
- (*n_keys == 0) ||
- (line == NULL)) {
- if (line)
- *line = 0;
- return -1;
- }
-
- /* Open input file */
- f = fopen(filename, "r");
- if (f == NULL) {
- *line = 0;
- return -1;
- }
-
- /* Read file */
- for (i = 0, l = 1; i < *n_keys; l++) {
- char *tokens[32];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- uint32_t priority = 0;
- struct in_addr sipaddr;
- uint32_t sipdepth = 0;
- struct in_addr dipaddr;
- uint32_t dipdepth = 0;
- uint16_t sport0 = 0;
- uint16_t sport1 = 0;
- uint16_t dport0 = 0;
- uint16_t dport1 = 0;
- uint8_t proto = 0;
- uint8_t protomask = 0;
- uint32_t port_id = 0;
-
- int status;
-
- if (fgets(file_buf, sizeof(file_buf), f) == NULL)
- break;
-
- status = parse_tokenize_string(file_buf, tokens, &n_tokens);
- if (status)
- goto error1;
-
- if ((n_tokens == 0) || (tokens[0][0] == '#'))
- continue;
-
- if ((n_tokens != 15) ||
- strcmp(tokens[0], "priority") ||
- parser_read_uint32(&priority, tokens[1]) ||
- strcmp(tokens[2], "ipv4") ||
- parse_ipv4_addr(tokens[3], &sipaddr) ||
- parser_read_uint32(&sipdepth, tokens[4]) ||
- parse_ipv4_addr(tokens[5], &dipaddr) ||
- parser_read_uint32(&dipdepth, tokens[6]) ||
- parser_read_uint16(&sport0, tokens[7]) ||
- parser_read_uint16(&sport1, tokens[8]) ||
- parser_read_uint16(&dport0, tokens[9]) ||
- parser_read_uint16(&dport1, tokens[10]) ||
- parser_read_uint8(&proto, tokens[11]) ||
- parser_read_uint8_hex(&protomask, tokens[12]) ||
- strcmp(tokens[13], "port") ||
- parser_read_uint32(&port_id, tokens[14]))
- goto error1;
-
- keys[i].type = PIPELINE_FIREWALL_IPV4_5TUPLE;
- keys[i].key.ipv4_5tuple.src_ip =
- rte_be_to_cpu_32(sipaddr.s_addr);
- keys[i].key.ipv4_5tuple.src_ip_mask = sipdepth;
- keys[i].key.ipv4_5tuple.dst_ip =
- rte_be_to_cpu_32(dipaddr.s_addr);
- keys[i].key.ipv4_5tuple.dst_ip_mask = dipdepth;
- keys[i].key.ipv4_5tuple.src_port_from = sport0;
- keys[i].key.ipv4_5tuple.src_port_to = sport1;
- keys[i].key.ipv4_5tuple.dst_port_from = dport0;
- keys[i].key.ipv4_5tuple.dst_port_to = dport1;
- keys[i].key.ipv4_5tuple.proto = proto;
- keys[i].key.ipv4_5tuple.proto_mask = protomask;
-
- port_ids[i] = port_id;
- priorities[i] = priority;
-
- if (app_pipeline_firewall_key_check_and_normalize(&keys[i]))
- goto error1;
-
- i++;
- }
-
- /* Close file */
- *n_keys = i;
- fclose(f);
- return 0;
-
-error1:
- *line = l;
- fclose(f);
- return -1;
-}
-
-int
-app_pipeline_firewall_add_rule(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *key,
- uint32_t priority,
- uint32_t port_id)
-{
- struct app_pipeline_firewall *p;
- struct app_pipeline_firewall_rule *rule;
- struct pipeline_firewall_add_msg_req *req;
- struct pipeline_firewall_add_msg_rsp *rsp;
- int new_rule;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL) ||
- (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- if (app_pipeline_firewall_key_check_and_normalize(key) != 0)
- return -1;
-
- /* Find existing rule or allocate new rule */
- rule = app_pipeline_firewall_rule_find(p, key);
- new_rule = (rule == NULL);
- if (rule == NULL) {
- rule = rte_malloc(NULL, sizeof(*rule), RTE_CACHE_LINE_SIZE);
-
- if (rule == NULL)
- return -1;
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL) {
- if (new_rule)
- rte_free(rule);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_ADD;
- memcpy(&req->key, key, sizeof(*key));
- req->priority = priority;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- if (new_rule)
- rte_free(rule);
- return -1;
- }
-
- /* Read response and write rule */
- if (rsp->status ||
- (rsp->entry_ptr == NULL) ||
- ((new_rule == 0) && (rsp->key_found == 0)) ||
- ((new_rule == 1) && (rsp->key_found == 1))) {
- app_msg_free(app, rsp);
- if (new_rule)
- rte_free(rule);
- return -1;
- }
-
- memcpy(&rule->key, key, sizeof(*key));
- rule->priority = priority;
- rule->port_id = port_id;
- rule->entry_ptr = rsp->entry_ptr;
-
- /* Commit rule */
- if (new_rule) {
- TAILQ_INSERT_TAIL(&p->rules, rule, node);
- p->n_rules++;
- }
-
- print_firewall_ipv4_rule(rule);
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_firewall_delete_rule(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *key)
-{
- struct app_pipeline_firewall *p;
- struct app_pipeline_firewall_rule *rule;
- struct pipeline_firewall_del_msg_req *req;
- struct pipeline_firewall_del_msg_rsp *rsp;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL) ||
- (key->type != PIPELINE_FIREWALL_IPV4_5TUPLE))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- if (app_pipeline_firewall_key_check_and_normalize(key) != 0)
- return -1;
-
- /* Find rule */
- rule = app_pipeline_firewall_rule_find(p, key);
- if (rule == NULL)
- return 0;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_DEL;
- memcpy(&req->key, key, sizeof(*key));
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status || !rsp->key_found) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Remove rule */
- TAILQ_REMOVE(&p->rules, rule, node);
- p->n_rules--;
- rte_free(rule);
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_firewall_add_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *keys,
- uint32_t n_keys,
- uint32_t *priorities,
- uint32_t *port_ids)
-{
- struct app_pipeline_firewall *p;
- struct pipeline_firewall_add_bulk_msg_req *req;
- struct pipeline_firewall_add_bulk_msg_rsp *rsp;
-
- struct app_pipeline_firewall_rule **rules;
- int *new_rules;
-
- int *keys_found;
- void **entries_ptr;
-
- uint32_t i;
- int status = 0;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- rules = rte_malloc(NULL,
- n_keys * sizeof(struct app_pipeline_firewall_rule *),
- RTE_CACHE_LINE_SIZE);
- if (rules == NULL)
- return -1;
-
- new_rules = rte_malloc(NULL,
- n_keys * sizeof(int),
- RTE_CACHE_LINE_SIZE);
- if (new_rules == NULL) {
- rte_free(rules);
- return -1;
- }
-
- /* check data integrity and add to rule list */
- for (i = 0; i < n_keys; i++) {
- if (port_ids[i] >= p->n_ports_out) {
- rte_free(rules);
- rte_free(new_rules);
- return -1;
- }
-
- if (app_pipeline_firewall_key_check_and_normalize(&keys[i]) != 0) {
- rte_free(rules);
- rte_free(new_rules);
- return -1;
- }
-
- rules[i] = app_pipeline_firewall_rule_find(p, &keys[i]);
- new_rules[i] = (rules[i] == NULL);
- if (rules[i] == NULL) {
- rules[i] = rte_malloc(NULL,
- sizeof(*rules[i]),
- RTE_CACHE_LINE_SIZE);
-
- if (rules[i] == NULL) {
- uint32_t j;
-
- for (j = 0; j <= i; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- return -1;
- }
- }
- }
-
- keys_found = rte_malloc(NULL,
- n_keys * sizeof(int),
- RTE_CACHE_LINE_SIZE);
- if (keys_found == NULL) {
- uint32_t j;
-
- for (j = 0; j < n_keys; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- return -1;
- }
-
- entries_ptr = rte_malloc(NULL,
- n_keys * sizeof(struct rte_pipeline_table_entry *),
- RTE_CACHE_LINE_SIZE);
- if (entries_ptr == NULL) {
- uint32_t j;
-
- for (j = 0; j < n_keys; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- rte_free(keys_found);
- return -1;
- }
- for (i = 0; i < n_keys; i++) {
- entries_ptr[i] = rte_malloc(NULL,
- sizeof(struct rte_pipeline_table_entry),
- RTE_CACHE_LINE_SIZE);
-
- if (entries_ptr[i] == NULL) {
- uint32_t j;
-
- for (j = 0; j < n_keys; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- for (j = 0; j <= i; j++)
- rte_free(entries_ptr[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- rte_free(keys_found);
- rte_free(entries_ptr);
- return -1;
- }
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL) {
- uint32_t j;
-
- for (j = 0; j < n_keys; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- for (j = 0; j < n_keys; j++)
- rte_free(entries_ptr[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- rte_free(keys_found);
- rte_free(entries_ptr);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_ADD_BULK;
-
- req->keys = keys;
- req->n_keys = n_keys;
- req->port_ids = port_ids;
- req->priorities = priorities;
- req->keys_found = keys_found;
- req->entries_ptr = entries_ptr;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- uint32_t j;
-
- for (j = 0; j < n_keys; j++)
- if (new_rules[j])
- rte_free(rules[j]);
-
- for (j = 0; j < n_keys; j++)
- rte_free(entries_ptr[j]);
-
- rte_free(rules);
- rte_free(new_rules);
- rte_free(keys_found);
- rte_free(entries_ptr);
- return -1;
- }
-
- if (rsp->status) {
- for (i = 0; i < n_keys; i++)
- if (new_rules[i])
- rte_free(rules[i]);
-
- for (i = 0; i < n_keys; i++)
- rte_free(entries_ptr[i]);
-
- status = -1;
- goto cleanup;
- }
-
- for (i = 0; i < n_keys; i++) {
- if (entries_ptr[i] == NULL ||
- ((new_rules[i] == 0) && (keys_found[i] == 0)) ||
- ((new_rules[i] == 1) && (keys_found[i] == 1))) {
- for (i = 0; i < n_keys; i++)
- if (new_rules[i])
- rte_free(rules[i]);
-
- for (i = 0; i < n_keys; i++)
- rte_free(entries_ptr[i]);
-
- status = -1;
- goto cleanup;
- }
- }
-
- for (i = 0; i < n_keys; i++) {
- memcpy(&rules[i]->key, &keys[i], sizeof(keys[i]));
- rules[i]->priority = priorities[i];
- rules[i]->port_id = port_ids[i];
- rules[i]->entry_ptr = entries_ptr[i];
-
- /* Commit rule */
- if (new_rules[i]) {
- TAILQ_INSERT_TAIL(&p->rules, rules[i], node);
- p->n_rules++;
- }
-
- print_firewall_ipv4_rule(rules[i]);
- }
-
-cleanup:
- app_msg_free(app, rsp);
- rte_free(rules);
- rte_free(new_rules);
- rte_free(keys_found);
- rte_free(entries_ptr);
-
- return status;
-}
-
-int
-app_pipeline_firewall_delete_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *keys,
- uint32_t n_keys)
-{
- struct app_pipeline_firewall *p;
- struct pipeline_firewall_del_bulk_msg_req *req;
- struct pipeline_firewall_del_bulk_msg_rsp *rsp;
-
- struct app_pipeline_firewall_rule **rules;
- int *keys_found;
-
- uint32_t i;
- int status = 0;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- rules = rte_malloc(NULL,
- n_keys * sizeof(struct app_pipeline_firewall_rule *),
- RTE_CACHE_LINE_SIZE);
- if (rules == NULL)
- return -1;
-
- for (i = 0; i < n_keys; i++) {
- if (app_pipeline_firewall_key_check_and_normalize(&keys[i]) != 0) {
- return -1;
- }
-
- rules[i] = app_pipeline_firewall_rule_find(p, &keys[i]);
- }
-
- keys_found = rte_malloc(NULL,
- n_keys * sizeof(int),
- RTE_CACHE_LINE_SIZE);
- if (keys_found == NULL) {
- rte_free(rules);
- return -1;
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL) {
- rte_free(rules);
- rte_free(keys_found);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_DEL_BULK;
-
- req->keys = keys;
- req->n_keys = n_keys;
- req->keys_found = keys_found;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- rte_free(rules);
- rte_free(keys_found);
- return -1;
- }
-
- if (rsp->status) {
- status = -1;
- goto cleanup;
- }
-
- for (i = 0; i < n_keys; i++) {
- if (keys_found[i] == 0) {
- status = -1;
- goto cleanup;
- }
- }
-
- for (i = 0; i < n_keys; i++) {
- TAILQ_REMOVE(&p->rules, rules[i], node);
- p->n_rules--;
- rte_free(rules[i]);
- }
-
-cleanup:
- app_msg_free(app, rsp);
- rte_free(rules);
- rte_free(keys_found);
-
- return status;
-}
-
-int
-app_pipeline_firewall_add_default_rule(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct app_pipeline_firewall *p;
- struct pipeline_firewall_add_default_msg_req *req;
- struct pipeline_firewall_add_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_ADD_DEFAULT;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write rule */
- if (rsp->status || (rsp->entry_ptr == NULL)) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- p->default_rule_port_id = port_id;
- p->default_rule_entry_ptr = rsp->entry_ptr;
-
- /* Commit rule */
- p->default_rule_present = 1;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_firewall_delete_default_rule(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_firewall *p;
- struct pipeline_firewall_del_default_msg_req *req;
- struct pipeline_firewall_del_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_firewall);
- if (p == NULL)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FIREWALL_MSG_REQ_DEL_DEFAULT;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write rule */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Commit rule */
- p->default_rule_present = 0;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-/*
- * firewall
- *
- * firewall add:
- * p <pipelineid> firewall add priority <priority>
- * ipv4 <sipaddr> <sipdepth> <dipaddr> <dipdepth>
- * <sport0> <sport1> <dport0> <dport1> <proto> <protomask>
- * port <portid>
- * Note: <protomask> is a hex value
- *
- * p <pipelineid> firewall add bulk <file>
- *
- * firewall add default:
- * p <pipelineid> firewall add default <port ID>
- *
- * firewall del:
- * p <pipelineid> firewall del
- * ipv4 <sipaddr> <sipdepth> <dipaddr> <dipdepth>
- * <sport0> <sport1> <dport0> <dport1> <proto> <protomask>
- *
- * p <pipelineid> firewall del bulk <file>
- *
- * firewall del default:
- * p <pipelineid> firewall del default
- *
- * firewall ls:
- * p <pipelineid> firewall ls
- */
-
-struct cmd_firewall_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t firewall_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void cmd_firewall_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- void *data)
-{
- struct cmd_firewall_result *params = parsed_result;
- struct app_params *app = data;
- int status;
-
- char *tokens[17];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status) {
- printf(CMD_MSG_TOO_MANY_ARGS, "firewall");
- return;
- }
-
- /* firewall add */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "priority") == 0)) {
- struct pipeline_firewall_key key;
- uint32_t priority;
- struct in_addr sipaddr;
- uint32_t sipdepth;
- struct in_addr dipaddr;
- uint32_t dipdepth;
- uint16_t sport0;
- uint16_t sport1;
- uint16_t dport0;
- uint16_t dport1;
- uint8_t proto;
- uint8_t protomask;
- uint32_t port_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 16) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall add");
- return;
- }
-
- if (parser_read_uint32(&priority, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "priority");
- return;
- }
-
- if (strcmp(tokens[3], "ipv4")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "ipv4");
- return;
- }
-
- if (parse_ipv4_addr(tokens[4], &sipaddr)) {
- printf(CMD_MSG_INVALID_ARG, "sipaddr");
- return;
- }
-
- if (parser_read_uint32(&sipdepth, tokens[5])) {
- printf(CMD_MSG_INVALID_ARG, "sipdepth");
- return;
- }
-
- if (parse_ipv4_addr(tokens[6], &dipaddr)) {
- printf(CMD_MSG_INVALID_ARG, "dipaddr");
- return;
- }
-
- if (parser_read_uint32(&dipdepth, tokens[7])) {
- printf(CMD_MSG_INVALID_ARG, "dipdepth");
- return;
- }
-
- if (parser_read_uint16(&sport0, tokens[8])) {
- printf(CMD_MSG_INVALID_ARG, "sport0");
- return;
- }
-
- if (parser_read_uint16(&sport1, tokens[9])) {
- printf(CMD_MSG_INVALID_ARG, "sport1");
- return;
- }
-
- if (parser_read_uint16(&dport0, tokens[10])) {
- printf(CMD_MSG_INVALID_ARG, "dport0");
- return;
- }
-
- if (parser_read_uint16(&dport1, tokens[11])) {
- printf(CMD_MSG_INVALID_ARG, "dport1");
- return;
- }
-
- if (parser_read_uint8(&proto, tokens[12])) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- if (parser_read_uint8_hex(&protomask, tokens[13])) {
- printf(CMD_MSG_INVALID_ARG, "protomask");
- return;
- }
-
- if (strcmp(tokens[14], "port")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "port");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[15])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- key.type = PIPELINE_FIREWALL_IPV4_5TUPLE;
- key.key.ipv4_5tuple.src_ip = rte_be_to_cpu_32(sipaddr.s_addr);
- key.key.ipv4_5tuple.src_ip_mask = sipdepth;
- key.key.ipv4_5tuple.dst_ip = rte_be_to_cpu_32(dipaddr.s_addr);
- key.key.ipv4_5tuple.dst_ip_mask = dipdepth;
- key.key.ipv4_5tuple.src_port_from = sport0;
- key.key.ipv4_5tuple.src_port_to = sport1;
- key.key.ipv4_5tuple.dst_port_from = dport0;
- key.key.ipv4_5tuple.dst_port_to = dport1;
- key.key.ipv4_5tuple.proto = proto;
- key.key.ipv4_5tuple.proto_mask = protomask;
-
- status = app_pipeline_firewall_add_rule(app,
- params->pipeline_id,
- &key,
- priority,
- port_id);
- if (status)
- printf(CMD_MSG_FAIL, "firewall add");
-
- return;
- } /* firewall add */
-
- /* firewall add bulk */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "bulk") == 0)) {
- struct pipeline_firewall_key *keys;
- uint32_t *priorities, *port_ids, n_keys, line;
- char *filename;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall add bulk");
- return;
- }
-
- filename = tokens[2];
-
- n_keys = APP_PIPELINE_FIREWALL_MAX_RULES_IN_FILE;
- keys = malloc(n_keys * sizeof(struct pipeline_firewall_key));
- if (keys == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- return;
- }
- memset(keys, 0, n_keys * sizeof(struct pipeline_firewall_key));
-
- priorities = malloc(n_keys * sizeof(uint32_t));
- if (priorities == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- free(keys);
- return;
- }
-
- port_ids = malloc(n_keys * sizeof(uint32_t));
- if (port_ids == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- free(priorities);
- free(keys);
- return;
- }
-
- status = app_pipeline_firewall_load_file(filename,
- keys,
- priorities,
- port_ids,
- &n_keys,
- &line);
- if (status != 0) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(port_ids);
- free(priorities);
- free(keys);
- return;
- }
-
- status = app_pipeline_firewall_add_bulk(app,
- params->pipeline_id,
- keys,
- n_keys,
- priorities,
- port_ids);
- if (status)
- printf(CMD_MSG_FAIL, "firewall add bulk");
-
- free(keys);
- free(priorities);
- free(port_ids);
- return;
- } /* firewall add bulk */
-
- /* firewall add default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- uint32_t port_id;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall add default");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- status = app_pipeline_firewall_add_default_rule(app,
- params->pipeline_id,
- port_id);
- if (status)
- printf(CMD_MSG_FAIL, "firewall add default");
-
- return;
- } /* firewall add default */
-
- /* firewall del */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "ipv4") == 0)) {
- struct pipeline_firewall_key key;
- struct in_addr sipaddr;
- uint32_t sipdepth;
- struct in_addr dipaddr;
- uint32_t dipdepth;
- uint16_t sport0;
- uint16_t sport1;
- uint16_t dport0;
- uint16_t dport1;
- uint8_t proto;
- uint8_t protomask;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 12) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall del");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &sipaddr)) {
- printf(CMD_MSG_INVALID_ARG, "sipaddr");
- return;
- }
-
- if (parser_read_uint32(&sipdepth, tokens[3])) {
- printf(CMD_MSG_INVALID_ARG, "sipdepth");
- return;
- }
-
- if (parse_ipv4_addr(tokens[4], &dipaddr)) {
- printf(CMD_MSG_INVALID_ARG, "dipaddr");
- return;
- }
-
- if (parser_read_uint32(&dipdepth, tokens[5])) {
- printf(CMD_MSG_INVALID_ARG, "dipdepth");
- return;
- }
-
- if (parser_read_uint16(&sport0, tokens[6])) {
- printf(CMD_MSG_INVALID_ARG, "sport0");
- return;
- }
-
- if (parser_read_uint16(&sport1, tokens[7])) {
- printf(CMD_MSG_INVALID_ARG, "sport1");
- return;
- }
-
- if (parser_read_uint16(&dport0, tokens[8])) {
- printf(CMD_MSG_INVALID_ARG, "dport0");
- return;
- }
-
- if (parser_read_uint16(&dport1, tokens[9])) {
- printf(CMD_MSG_INVALID_ARG, "dport1");
- return;
- }
-
- if (parser_read_uint8(&proto, tokens[10])) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- if (parser_read_uint8_hex(&protomask, tokens[11])) {
- printf(CMD_MSG_INVALID_ARG, "protomask");
- return;
- }
-
- key.type = PIPELINE_FIREWALL_IPV4_5TUPLE;
- key.key.ipv4_5tuple.src_ip = rte_be_to_cpu_32(sipaddr.s_addr);
- key.key.ipv4_5tuple.src_ip_mask = sipdepth;
- key.key.ipv4_5tuple.dst_ip = rte_be_to_cpu_32(dipaddr.s_addr);
- key.key.ipv4_5tuple.dst_ip_mask = dipdepth;
- key.key.ipv4_5tuple.src_port_from = sport0;
- key.key.ipv4_5tuple.src_port_to = sport1;
- key.key.ipv4_5tuple.dst_port_from = dport0;
- key.key.ipv4_5tuple.dst_port_to = dport1;
- key.key.ipv4_5tuple.proto = proto;
- key.key.ipv4_5tuple.proto_mask = protomask;
-
- status = app_pipeline_firewall_delete_rule(app,
- params->pipeline_id,
- &key);
- if (status)
- printf(CMD_MSG_FAIL, "firewall del");
-
- return;
- } /* firewall del */
-
- /* firewall del bulk */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "bulk") == 0)) {
- struct pipeline_firewall_key *keys;
- uint32_t *priorities, *port_ids, n_keys, line;
- char *filename;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall del bulk");
- return;
- }
-
- filename = tokens[2];
-
- n_keys = APP_PIPELINE_FIREWALL_MAX_RULES_IN_FILE;
- keys = malloc(n_keys * sizeof(struct pipeline_firewall_key));
- if (keys == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- return;
- }
- memset(keys, 0, n_keys * sizeof(struct pipeline_firewall_key));
-
- priorities = malloc(n_keys * sizeof(uint32_t));
- if (priorities == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- free(keys);
- return;
- }
-
- port_ids = malloc(n_keys * sizeof(uint32_t));
- if (port_ids == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- free(priorities);
- free(keys);
- return;
- }
-
- status = app_pipeline_firewall_load_file(filename,
- keys,
- priorities,
- port_ids,
- &n_keys,
- &line);
- if (status != 0) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(port_ids);
- free(priorities);
- free(keys);
- return;
- }
-
- status = app_pipeline_firewall_delete_bulk(app,
- params->pipeline_id,
- keys,
- n_keys);
- if (status)
- printf(CMD_MSG_FAIL, "firewall del bulk");
-
- free(port_ids);
- free(priorities);
- free(keys);
- return;
- } /* firewall del bulk */
-
- /* firewall del default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall del default");
- return;
- }
-
- status = app_pipeline_firewall_delete_default_rule(app,
- params->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "firewall del default");
-
- return;
-
- } /* firewall del default */
-
- /* firewall ls */
- if ((n_tokens >= 1) && (strcmp(tokens[0], "ls") == 0)) {
- if (n_tokens != 1) {
- printf(CMD_MSG_MISMATCH_ARGS, "firewall ls");
- return;
- }
-
- status = app_pipeline_firewall_ls(app, params->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "firewall ls");
-
- return;
- } /* firewall ls */
-
- printf(CMD_MSG_MISMATCH_ARGS, "firewall");
-}
-
-static cmdline_parse_token_string_t cmd_firewall_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_firewall_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_firewall_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_firewall_result, pipeline_id, UINT32);
-
-static cmdline_parse_token_string_t cmd_firewall_firewall_string =
- TOKEN_STRING_INITIALIZER(struct cmd_firewall_result, firewall_string,
- "firewall");
-
-static cmdline_parse_token_string_t cmd_firewall_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_firewall_result, multi_string,
- TOKEN_STRING_MULTI);
-
-static cmdline_parse_inst_t cmd_firewall = {
- .f = cmd_firewall_parsed,
- .data = NULL,
- .help_str = "firewall add / add bulk / add default / del / del bulk"
- " / del default / ls",
- .tokens = {
- (void *) &cmd_firewall_p_string,
- (void *) &cmd_firewall_pipeline_id,
- (void *) &cmd_firewall_firewall_string,
- (void *) &cmd_firewall_multi_string,
- NULL,
- },
-};
-
-static cmdline_parse_ctx_t pipeline_cmds[] = {
- (cmdline_parse_inst_t *) &cmd_firewall,
- NULL,
-};
-
-static struct pipeline_fe_ops pipeline_firewall_fe_ops = {
- .f_init = app_pipeline_firewall_init,
- .f_post_init = NULL,
- .f_free = app_pipeline_firewall_free,
- .f_track = app_pipeline_track_default,
- .cmds = pipeline_cmds,
-};
-
-struct pipeline_type pipeline_firewall = {
- .name = "FIREWALL",
- .be_ops = &pipeline_firewall_be_ops,
- .fe_ops = &pipeline_firewall_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall.h b/examples/ip_pipeline/pipeline/pipeline_firewall.h
deleted file mode 100644
index 27304b00..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_firewall.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FIREWALL_H__
-#define __INCLUDE_PIPELINE_FIREWALL_H__
-
-#include "pipeline.h"
-#include "pipeline_firewall_be.h"
-
-int
-app_pipeline_firewall_add_rule(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *key,
- uint32_t priority,
- uint32_t port_id);
-
-int
-app_pipeline_firewall_delete_rule(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *key);
-
-int
-app_pipeline_firewall_add_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *keys,
- uint32_t n_keys,
- uint32_t *priorities,
- uint32_t *port_ids);
-
-int
-app_pipeline_firewall_delete_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_firewall_key *keys,
- uint32_t n_keys);
-
-int
-app_pipeline_firewall_add_default_rule(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_pipeline_firewall_delete_default_rule(struct app_params *app,
- uint32_t pipeline_id);
-
-#ifndef APP_PIPELINE_FIREWALL_MAX_RULES_IN_FILE
-#define APP_PIPELINE_FIREWALL_MAX_RULES_IN_FILE 65536
-#endif
-
-int
-app_pipeline_firewall_load_file(char *filename,
- struct pipeline_firewall_key *keys,
- uint32_t *priorities,
- uint32_t *port_ids,
- uint32_t *n_keys,
- uint32_t *line);
-
-extern struct pipeline_type pipeline_firewall;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall_be.c b/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
deleted file mode 100644
index bd5e1b2b..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_firewall_be.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <string.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <rte_ether.h>
-#include <rte_ip.h>
-#include <rte_tcp.h>
-#include <rte_byteorder.h>
-#include <rte_table_acl.h>
-
-#include "pipeline_firewall_be.h"
-#include "parser.h"
-
-struct pipeline_firewall {
- struct pipeline p;
- pipeline_msg_req_handler custom_handlers[PIPELINE_FIREWALL_MSG_REQS];
-
- uint32_t n_rules;
- uint32_t n_rule_fields;
- struct rte_acl_field_def *field_format;
- uint32_t field_format_size;
-} __rte_cache_aligned;
-
-static void *
-pipeline_firewall_msg_req_custom_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler handlers[] = {
- [PIPELINE_MSG_REQ_PING] =
- pipeline_msg_req_ping_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_IN] =
- pipeline_msg_req_stats_port_in_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
- pipeline_msg_req_stats_port_out_handler,
- [PIPELINE_MSG_REQ_STATS_TABLE] =
- pipeline_msg_req_stats_table_handler,
- [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
- pipeline_msg_req_port_in_enable_handler,
- [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
- pipeline_msg_req_port_in_disable_handler,
- [PIPELINE_MSG_REQ_CUSTOM] =
- pipeline_firewall_msg_req_custom_handler,
-};
-
-static void *
-pipeline_firewall_msg_req_add_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_firewall_msg_req_del_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_firewall_msg_req_add_bulk_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_firewall_msg_req_del_bulk_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_firewall_msg_req_add_default_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_firewall_msg_req_del_default_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler custom_handlers[] = {
- [PIPELINE_FIREWALL_MSG_REQ_ADD] =
- pipeline_firewall_msg_req_add_handler,
- [PIPELINE_FIREWALL_MSG_REQ_DEL] =
- pipeline_firewall_msg_req_del_handler,
- [PIPELINE_FIREWALL_MSG_REQ_ADD_BULK] =
- pipeline_firewall_msg_req_add_bulk_handler,
- [PIPELINE_FIREWALL_MSG_REQ_DEL_BULK] =
- pipeline_firewall_msg_req_del_bulk_handler,
- [PIPELINE_FIREWALL_MSG_REQ_ADD_DEFAULT] =
- pipeline_firewall_msg_req_add_default_handler,
- [PIPELINE_FIREWALL_MSG_REQ_DEL_DEFAULT] =
- pipeline_firewall_msg_req_del_default_handler,
-};
-
-/*
- * Firewall table
- */
-struct firewall_table_entry {
- struct rte_pipeline_table_entry head;
-};
-
-static struct rte_acl_field_def field_format_ipv4[] = {
- /* Protocol */
- [0] = {
- .type = RTE_ACL_FIELD_TYPE_BITMASK,
- .size = sizeof(uint8_t),
- .field_index = 0,
- .input_index = 0,
- .offset = sizeof(struct ether_hdr) +
- offsetof(struct ipv4_hdr, next_proto_id),
- },
-
- /* Source IP address (IPv4) */
- [1] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 1,
- .input_index = 1,
- .offset = sizeof(struct ether_hdr) +
- offsetof(struct ipv4_hdr, src_addr),
- },
-
- /* Destination IP address (IPv4) */
- [2] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 2,
- .input_index = 2,
- .offset = sizeof(struct ether_hdr) +
- offsetof(struct ipv4_hdr, dst_addr),
- },
-
- /* Source Port */
- [3] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 3,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, src_port),
- },
-
- /* Destination Port */
- [4] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 4,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, dst_port),
- },
-};
-
-#define SIZEOF_VLAN_HDR 4
-
-static struct rte_acl_field_def field_format_vlan_ipv4[] = {
- /* Protocol */
- [0] = {
- .type = RTE_ACL_FIELD_TYPE_BITMASK,
- .size = sizeof(uint8_t),
- .field_index = 0,
- .input_index = 0,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_VLAN_HDR +
- offsetof(struct ipv4_hdr, next_proto_id),
- },
-
- /* Source IP address (IPv4) */
- [1] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 1,
- .input_index = 1,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_VLAN_HDR +
- offsetof(struct ipv4_hdr, src_addr),
- },
-
- /* Destination IP address (IPv4) */
- [2] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 2,
- .input_index = 2,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_VLAN_HDR +
- offsetof(struct ipv4_hdr, dst_addr),
- },
-
- /* Source Port */
- [3] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 3,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_VLAN_HDR +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, src_port),
- },
-
- /* Destination Port */
- [4] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 4,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_VLAN_HDR +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, dst_port),
- },
-};
-
-#define SIZEOF_QINQ_HEADER 8
-
-static struct rte_acl_field_def field_format_qinq_ipv4[] = {
- /* Protocol */
- [0] = {
- .type = RTE_ACL_FIELD_TYPE_BITMASK,
- .size = sizeof(uint8_t),
- .field_index = 0,
- .input_index = 0,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_QINQ_HEADER +
- offsetof(struct ipv4_hdr, next_proto_id),
- },
-
- /* Source IP address (IPv4) */
- [1] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 1,
- .input_index = 1,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_QINQ_HEADER +
- offsetof(struct ipv4_hdr, src_addr),
- },
-
- /* Destination IP address (IPv4) */
- [2] = {
- .type = RTE_ACL_FIELD_TYPE_MASK,
- .size = sizeof(uint32_t),
- .field_index = 2,
- .input_index = 2,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_QINQ_HEADER +
- offsetof(struct ipv4_hdr, dst_addr),
- },
-
- /* Source Port */
- [3] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 3,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_QINQ_HEADER +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, src_port),
- },
-
- /* Destination Port */
- [4] = {
- .type = RTE_ACL_FIELD_TYPE_RANGE,
- .size = sizeof(uint16_t),
- .field_index = 4,
- .input_index = 3,
- .offset = sizeof(struct ether_hdr) +
- SIZEOF_QINQ_HEADER +
- sizeof(struct ipv4_hdr) +
- offsetof(struct tcp_hdr, dst_port),
- },
-};
-
-static int
-pipeline_firewall_parse_args(struct pipeline_firewall *p,
- struct pipeline_params *params)
-{
- uint32_t n_rules_present = 0;
- uint32_t pkt_type_present = 0;
- uint32_t i;
-
- /* defaults */
- p->n_rules = 4 * 1024;
- p->n_rule_fields = RTE_DIM(field_format_ipv4);
- p->field_format = field_format_ipv4;
- p->field_format_size = sizeof(field_format_ipv4);
-
- for (i = 0; i < params->n_args; i++) {
- char *arg_name = params->args_name[i];
- char *arg_value = params->args_value[i];
-
- if (strcmp(arg_name, "n_rules") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_rules_present == 0, params->name,
- arg_name);
- n_rules_present = 1;
-
- status = parser_read_uint32(&p->n_rules,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
- continue;
- }
-
- if (strcmp(arg_name, "pkt_type") == 0) {
- PIPELINE_PARSE_ERR_DUPLICATE(
- pkt_type_present == 0, params->name,
- arg_name);
- pkt_type_present = 1;
-
- /* ipv4 */
- if (strcmp(arg_value, "ipv4") == 0) {
- p->n_rule_fields = RTE_DIM(field_format_ipv4);
- p->field_format = field_format_ipv4;
- p->field_format_size =
- sizeof(field_format_ipv4);
- continue;
- }
-
- /* vlan_ipv4 */
- if (strcmp(arg_value, "vlan_ipv4") == 0) {
- p->n_rule_fields =
- RTE_DIM(field_format_vlan_ipv4);
- p->field_format = field_format_vlan_ipv4;
- p->field_format_size =
- sizeof(field_format_vlan_ipv4);
- continue;
- }
-
- /* qinq_ipv4 */
- if (strcmp(arg_value, "qinq_ipv4") == 0) {
- p->n_rule_fields =
- RTE_DIM(field_format_qinq_ipv4);
- p->field_format = field_format_qinq_ipv4;
- p->field_format_size =
- sizeof(field_format_qinq_ipv4);
- continue;
- }
-
- /* other */
- PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
- arg_name, arg_value);
- }
-
- /* other */
- PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
- }
-
- return 0;
-}
-
-static void *
-pipeline_firewall_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct pipeline *p;
- struct pipeline_firewall *p_fw;
- uint32_t size, i;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_firewall));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- p_fw = (struct pipeline_firewall *) p;
- if (p == NULL)
- return NULL;
-
- strcpy(p->name, params->name);
- p->log_level = params->log_level;
-
- PLOG(p, HIGH, "Firewall");
-
- /* Parse arguments */
- if (pipeline_firewall_parse_args(p_fw, params))
- return NULL;
-
- /* Pipeline */
- {
- struct rte_pipeline_params pipeline_params = {
- .name = params->name,
- .socket_id = params->socket_id,
- .offset_port_id = 0,
- };
-
- p->p = rte_pipeline_create(&pipeline_params);
- if (p->p == NULL) {
- rte_free(p);
- return NULL;
- }
- }
-
- /* Input ports */
- p->n_ports_in = params->n_ports_in;
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_port_in_params port_params = {
- .ops = pipeline_port_in_params_get_ops(
- &params->port_in[i]),
- .arg_create = pipeline_port_in_params_convert(
- &params->port_in[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- .burst_size = params->port_in[i].burst_size,
- };
-
- int status = rte_pipeline_port_in_create(p->p,
- &port_params,
- &p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Output ports */
- p->n_ports_out = params->n_ports_out;
- for (i = 0; i < p->n_ports_out; i++) {
- struct rte_pipeline_port_out_params port_params = {
- .ops = pipeline_port_out_params_get_ops(
- &params->port_out[i]),
- .arg_create = pipeline_port_out_params_convert(
- &params->port_out[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- };
-
- int status = rte_pipeline_port_out_create(p->p,
- &port_params,
- &p->port_out_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Tables */
- p->n_tables = 1;
- {
- struct rte_table_acl_params table_acl_params = {
- .name = params->name,
- .n_rules = p_fw->n_rules,
- .n_rule_fields = p_fw->n_rule_fields,
- };
-
- struct rte_pipeline_table_params table_params = {
- .ops = &rte_table_acl_ops,
- .arg_create = &table_acl_params,
- .f_action_hit = NULL,
- .f_action_miss = NULL,
- .arg_ah = NULL,
- .action_data_size =
- sizeof(struct firewall_table_entry) -
- sizeof(struct rte_pipeline_table_entry),
- };
-
- int status;
-
- memcpy(table_acl_params.field_format,
- p_fw->field_format,
- p_fw->field_format_size);
-
- status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Connecting input ports to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_connect_to_table(p->p,
- p->port_in_id[i],
- p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Enable input ports */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_enable(p->p,
- p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Check pipeline consistency */
- if (rte_pipeline_check(p->p) < 0) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- /* Message queues */
- p->n_msgq = params->n_msgq;
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_in[i] = params->msgq_in[i];
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_out[i] = params->msgq_out[i];
-
- /* Message handlers */
- memcpy(p->handlers, handlers, sizeof(p->handlers));
- memcpy(p_fw->custom_handlers,
- custom_handlers,
- sizeof(p_fw->custom_handlers));
-
- return p;
-}
-
-static int
-pipeline_firewall_free(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_pipeline_free(p->p);
- rte_free(p);
- return 0;
-}
-
-static int
-pipeline_firewall_timer(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- pipeline_msg_req_handle(p);
- rte_pipeline_flush(p->p);
-
- return 0;
-}
-
-void *
-pipeline_firewall_msg_req_custom_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_firewall *p_fw = (struct pipeline_firewall *) p;
- struct pipeline_custom_msg_req *req = msg;
- pipeline_msg_req_handler f_handle;
-
- f_handle = (req->subtype < PIPELINE_FIREWALL_MSG_REQS) ?
- p_fw->custom_handlers[req->subtype] :
- pipeline_msg_req_invalid_handler;
-
- if (f_handle == NULL)
- f_handle = pipeline_msg_req_invalid_handler;
-
- return f_handle(p, req);
-}
-
-void *
-pipeline_firewall_msg_req_add_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_add_msg_req *req = msg;
- struct pipeline_firewall_add_msg_rsp *rsp = msg;
-
- struct rte_table_acl_rule_add_params params;
- struct firewall_table_entry entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
- };
-
- memset(&params, 0, sizeof(params));
-
- switch (req->key.type) {
- case PIPELINE_FIREWALL_IPV4_5TUPLE:
- params.priority = req->priority;
- params.field_value[0].value.u8 =
- req->key.key.ipv4_5tuple.proto;
- params.field_value[0].mask_range.u8 =
- req->key.key.ipv4_5tuple.proto_mask;
- params.field_value[1].value.u32 =
- req->key.key.ipv4_5tuple.src_ip;
- params.field_value[1].mask_range.u32 =
- req->key.key.ipv4_5tuple.src_ip_mask;
- params.field_value[2].value.u32 =
- req->key.key.ipv4_5tuple.dst_ip;
- params.field_value[2].mask_range.u32 =
- req->key.key.ipv4_5tuple.dst_ip_mask;
- params.field_value[3].value.u16 =
- req->key.key.ipv4_5tuple.src_port_from;
- params.field_value[3].mask_range.u16 =
- req->key.key.ipv4_5tuple.src_port_to;
- params.field_value[4].value.u16 =
- req->key.key.ipv4_5tuple.dst_port_from;
- params.field_value[4].mask_range.u16 =
- req->key.key.ipv4_5tuple.dst_port_to;
- break;
-
- default:
- rsp->status = -1; /* Error */
- return rsp;
- }
-
- rsp->status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &params,
- (struct rte_pipeline_table_entry *) &entry,
- &rsp->key_found,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_firewall_msg_req_del_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_del_msg_req *req = msg;
- struct pipeline_firewall_del_msg_rsp *rsp = msg;
-
- struct rte_table_acl_rule_delete_params params;
-
- memset(&params, 0, sizeof(params));
-
- switch (req->key.type) {
- case PIPELINE_FIREWALL_IPV4_5TUPLE:
- params.field_value[0].value.u8 =
- req->key.key.ipv4_5tuple.proto;
- params.field_value[0].mask_range.u8 =
- req->key.key.ipv4_5tuple.proto_mask;
- params.field_value[1].value.u32 =
- req->key.key.ipv4_5tuple.src_ip;
- params.field_value[1].mask_range.u32 =
- req->key.key.ipv4_5tuple.src_ip_mask;
- params.field_value[2].value.u32 =
- req->key.key.ipv4_5tuple.dst_ip;
- params.field_value[2].mask_range.u32 =
- req->key.key.ipv4_5tuple.dst_ip_mask;
- params.field_value[3].value.u16 =
- req->key.key.ipv4_5tuple.src_port_from;
- params.field_value[3].mask_range.u16 =
- req->key.key.ipv4_5tuple.src_port_to;
- params.field_value[4].value.u16 =
- req->key.key.ipv4_5tuple.dst_port_from;
- params.field_value[4].mask_range.u16 =
- req->key.key.ipv4_5tuple.dst_port_to;
- break;
-
- default:
- rsp->status = -1; /* Error */
- return rsp;
- }
-
- rsp->status = rte_pipeline_table_entry_delete(p->p,
- p->table_id[0],
- &params,
- &rsp->key_found,
- NULL);
-
- return rsp;
-}
-
-static void *
-pipeline_firewall_msg_req_add_bulk_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_add_bulk_msg_req *req = msg;
- struct pipeline_firewall_add_bulk_msg_rsp *rsp = msg;
-
- struct rte_table_acl_rule_add_params *params[req->n_keys];
- struct firewall_table_entry *entries[req->n_keys];
-
- uint32_t i, n_keys;
-
- n_keys = req->n_keys;
-
- for (i = 0; i < n_keys; i++) {
- entries[i] = rte_zmalloc(NULL,
- sizeof(struct firewall_table_entry),
- RTE_CACHE_LINE_SIZE);
- if (entries[i] == NULL) {
- rsp->status = -1;
- return rsp;
- }
-
- params[i] = rte_zmalloc(NULL,
- sizeof(struct rte_table_acl_rule_add_params),
- RTE_CACHE_LINE_SIZE);
- if (params[i] == NULL) {
- rsp->status = -1;
- return rsp;
- }
-
- entries[i]->head.action = RTE_PIPELINE_ACTION_PORT;
- entries[i]->head.port_id = p->port_out_id[req->port_ids[i]];
-
- switch (req->keys[i].type) {
- case PIPELINE_FIREWALL_IPV4_5TUPLE:
- params[i]->priority = req->priorities[i];
- params[i]->field_value[0].value.u8 =
- req->keys[i].key.ipv4_5tuple.proto;
- params[i]->field_value[0].mask_range.u8 =
- req->keys[i].key.ipv4_5tuple.proto_mask;
- params[i]->field_value[1].value.u32 =
- req->keys[i].key.ipv4_5tuple.src_ip;
- params[i]->field_value[1].mask_range.u32 =
- req->keys[i].key.ipv4_5tuple.src_ip_mask;
- params[i]->field_value[2].value.u32 =
- req->keys[i].key.ipv4_5tuple.dst_ip;
- params[i]->field_value[2].mask_range.u32 =
- req->keys[i].key.ipv4_5tuple.dst_ip_mask;
- params[i]->field_value[3].value.u16 =
- req->keys[i].key.ipv4_5tuple.src_port_from;
- params[i]->field_value[3].mask_range.u16 =
- req->keys[i].key.ipv4_5tuple.src_port_to;
- params[i]->field_value[4].value.u16 =
- req->keys[i].key.ipv4_5tuple.dst_port_from;
- params[i]->field_value[4].mask_range.u16 =
- req->keys[i].key.ipv4_5tuple.dst_port_to;
- break;
-
- default:
- rsp->status = -1; /* Error */
-
- for (i = 0; i < n_keys; i++) {
- rte_free(entries[i]);
- rte_free(params[i]);
- }
-
- return rsp;
- }
- }
-
- rsp->status = rte_pipeline_table_entry_add_bulk(p->p, p->table_id[0],
- (void *)params, (struct rte_pipeline_table_entry **)entries,
- n_keys, req->keys_found,
- (struct rte_pipeline_table_entry **)req->entries_ptr);
-
- for (i = 0; i < n_keys; i++) {
- rte_free(entries[i]);
- rte_free(params[i]);
- }
-
- return rsp;
-}
-
-static void *
-pipeline_firewall_msg_req_del_bulk_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_del_bulk_msg_req *req = msg;
- struct pipeline_firewall_del_bulk_msg_rsp *rsp = msg;
-
- struct rte_table_acl_rule_delete_params *params[req->n_keys];
-
- uint32_t i, n_keys;
-
- n_keys = req->n_keys;
-
- for (i = 0; i < n_keys; i++) {
- params[i] = rte_zmalloc(NULL,
- sizeof(struct rte_table_acl_rule_delete_params),
- RTE_CACHE_LINE_SIZE);
- if (params[i] == NULL) {
- rsp->status = -1;
- return rsp;
- }
-
- switch (req->keys[i].type) {
- case PIPELINE_FIREWALL_IPV4_5TUPLE:
- params[i]->field_value[0].value.u8 =
- req->keys[i].key.ipv4_5tuple.proto;
- params[i]->field_value[0].mask_range.u8 =
- req->keys[i].key.ipv4_5tuple.proto_mask;
- params[i]->field_value[1].value.u32 =
- req->keys[i].key.ipv4_5tuple.src_ip;
- params[i]->field_value[1].mask_range.u32 =
- req->keys[i].key.ipv4_5tuple.src_ip_mask;
- params[i]->field_value[2].value.u32 =
- req->keys[i].key.ipv4_5tuple.dst_ip;
- params[i]->field_value[2].mask_range.u32 =
- req->keys[i].key.ipv4_5tuple.dst_ip_mask;
- params[i]->field_value[3].value.u16 =
- req->keys[i].key.ipv4_5tuple.src_port_from;
- params[i]->field_value[3].mask_range.u16 =
- req->keys[i].key.ipv4_5tuple.src_port_to;
- params[i]->field_value[4].value.u16 =
- req->keys[i].key.ipv4_5tuple.dst_port_from;
- params[i]->field_value[4].mask_range.u16 =
- req->keys[i].key.ipv4_5tuple.dst_port_to;
- break;
-
- default:
- rsp->status = -1; /* Error */
-
- for (i = 0; i < n_keys; i++)
- rte_free(params[i]);
-
- return rsp;
- }
- }
-
- rsp->status = rte_pipeline_table_entry_delete_bulk(p->p, p->table_id[0],
- (void **)&params, n_keys, req->keys_found, NULL);
-
- for (i = 0; i < n_keys; i++)
- rte_free(params[i]);
-
- return rsp;
-}
-
-void *
-pipeline_firewall_msg_req_add_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_add_default_msg_req *req = msg;
- struct pipeline_firewall_add_default_msg_rsp *rsp = msg;
-
- struct firewall_table_entry default_entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
- };
-
- rsp->status = rte_pipeline_table_default_entry_add(p->p,
- p->table_id[0],
- (struct rte_pipeline_table_entry *) &default_entry,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_firewall_msg_req_del_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_firewall_del_default_msg_rsp *rsp = msg;
-
- rsp->status = rte_pipeline_table_default_entry_delete(p->p,
- p->table_id[0],
- NULL);
-
- return rsp;
-}
-
-struct pipeline_be_ops pipeline_firewall_be_ops = {
- .f_init = pipeline_firewall_init,
- .f_free = pipeline_firewall_free,
- .f_run = NULL,
- .f_timer = pipeline_firewall_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_firewall_be.h b/examples/ip_pipeline/pipeline/pipeline_firewall_be.h
deleted file mode 100644
index 246f0a6d..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_firewall_be.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FIREWALL_BE_H__
-#define __INCLUDE_PIPELINE_FIREWALL_BE_H__
-
-#include "pipeline_common_be.h"
-
-enum pipeline_firewall_key_type {
- PIPELINE_FIREWALL_IPV4_5TUPLE,
-};
-
-struct pipeline_firewall_key_ipv4_5tuple {
- uint32_t src_ip;
- uint32_t src_ip_mask;
- uint32_t dst_ip;
- uint32_t dst_ip_mask;
- uint16_t src_port_from;
- uint16_t src_port_to;
- uint16_t dst_port_from;
- uint16_t dst_port_to;
- uint8_t proto;
- uint8_t proto_mask;
-};
-
-struct pipeline_firewall_key {
- enum pipeline_firewall_key_type type;
- union {
- struct pipeline_firewall_key_ipv4_5tuple ipv4_5tuple;
- } key;
-};
-
-enum pipeline_firewall_msg_req_type {
- PIPELINE_FIREWALL_MSG_REQ_ADD = 0,
- PIPELINE_FIREWALL_MSG_REQ_DEL,
- PIPELINE_FIREWALL_MSG_REQ_ADD_BULK,
- PIPELINE_FIREWALL_MSG_REQ_DEL_BULK,
- PIPELINE_FIREWALL_MSG_REQ_ADD_DEFAULT,
- PIPELINE_FIREWALL_MSG_REQ_DEL_DEFAULT,
- PIPELINE_FIREWALL_MSG_REQS
-};
-
-/*
- * MSG ADD
- */
-struct pipeline_firewall_add_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-
- /* key */
- struct pipeline_firewall_key key;
-
- /* data */
- int32_t priority;
- uint32_t port_id;
-};
-
-struct pipeline_firewall_add_msg_rsp {
- int status;
- int key_found;
- void *entry_ptr;
-};
-
-/*
- * MSG DEL
- */
-struct pipeline_firewall_del_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-
- /* key */
- struct pipeline_firewall_key key;
-};
-
-struct pipeline_firewall_del_msg_rsp {
- int status;
- int key_found;
-};
-
-/*
- * MSG ADD BULK
- */
-struct pipeline_firewall_add_bulk_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-
- struct pipeline_firewall_key *keys;
- uint32_t n_keys;
-
- uint32_t *priorities;
- uint32_t *port_ids;
- int *keys_found;
- void **entries_ptr;
-};
-struct pipeline_firewall_add_bulk_msg_rsp {
- int status;
-};
-
-/*
- * MSG DEL BULK
- */
-struct pipeline_firewall_del_bulk_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-
- /* key */
- struct pipeline_firewall_key *keys;
- uint32_t n_keys;
- int *keys_found;
-};
-
-struct pipeline_firewall_del_bulk_msg_rsp {
- int status;
-};
-
-/*
- * MSG ADD DEFAULT
- */
-struct pipeline_firewall_add_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-
- /* data */
- uint32_t port_id;
-};
-
-struct pipeline_firewall_add_default_msg_rsp {
- int status;
- void *entry_ptr;
-};
-
-/*
- * MSG DEL DEFAULT
- */
-struct pipeline_firewall_del_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_firewall_msg_req_type subtype;
-};
-
-struct pipeline_firewall_del_default_msg_rsp {
- int status;
-};
-
-extern struct pipeline_be_ops pipeline_firewall_be_ops;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions.c b/examples/ip_pipeline/pipeline/pipeline_flow_actions.c
deleted file mode 100644
index 021aee18..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions.c
+++ /dev/null
@@ -1,1286 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/queue.h>
-#include <netinet/in.h>
-#include <unistd.h>
-
-#include <rte_common.h>
-#include <rte_hexdump.h>
-#include <rte_malloc.h>
-#include <cmdline_rdline.h>
-#include <cmdline_parse.h>
-#include <cmdline_parse_num.h>
-#include <cmdline_parse_string.h>
-
-#include "app.h"
-#include "pipeline_common_fe.h"
-#include "pipeline_flow_actions.h"
-#include "hash_func.h"
-#include "parser.h"
-
-/*
- * Flow actions pipeline
- */
-#ifndef N_FLOWS_BULK
-#define N_FLOWS_BULK 4096
-#endif
-
-struct app_pipeline_fa_flow {
- struct pipeline_fa_flow_params params;
- void *entry_ptr;
-};
-
-struct app_pipeline_fa_dscp {
- uint32_t traffic_class;
- enum rte_meter_color color;
-};
-
-struct app_pipeline_fa {
- /* Parameters */
- uint32_t n_ports_in;
- uint32_t n_ports_out;
- struct pipeline_fa_params params;
-
- /* Flows */
- struct app_pipeline_fa_dscp dscp[PIPELINE_FA_N_DSCP];
- struct app_pipeline_fa_flow *flows;
-} __rte_cache_aligned;
-
-static void*
-app_pipeline_fa_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct app_pipeline_fa *p;
- uint32_t size, i;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct app_pipeline_fa));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
-
- /* Initialization */
- p->n_ports_in = params->n_ports_in;
- p->n_ports_out = params->n_ports_out;
- if (pipeline_fa_parse_args(&p->params, params)) {
- rte_free(p);
- return NULL;
- }
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(
- p->params.n_flows * sizeof(struct app_pipeline_fa_flow));
- p->flows = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p->flows == NULL) {
- rte_free(p);
- return NULL;
- }
-
- /* Initialization of flow table */
- for (i = 0; i < p->params.n_flows; i++)
- pipeline_fa_flow_params_set_default(&p->flows[i].params);
-
- /* Initialization of DSCP table */
- for (i = 0; i < RTE_DIM(p->dscp); i++) {
- p->dscp[i].traffic_class = 0;
- p->dscp[i].color = e_RTE_METER_GREEN;
- }
-
- return (void *) p;
-}
-
-static int
-app_pipeline_fa_free(void *pipeline)
-{
- struct app_pipeline_fa *p = pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_free(p->flows);
- rte_free(p);
-
- return 0;
-}
-
-static int
-flow_params_check(struct app_pipeline_fa *p,
- __rte_unused uint32_t meter_update_mask,
- uint32_t policer_update_mask,
- uint32_t port_update,
- struct pipeline_fa_flow_params *params)
-{
- uint32_t mask, i;
-
- /* Meter */
-
- /* Policer */
- for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
- struct pipeline_fa_policer_params *p = &params->p[i];
- uint32_t j;
-
- if ((mask & policer_update_mask) == 0)
- continue;
-
- for (j = 0; j < e_RTE_METER_COLORS; j++) {
- struct pipeline_fa_policer_action *action =
- &p->action[j];
-
- if ((action->drop == 0) &&
- (action->color >= e_RTE_METER_COLORS))
- return -1;
- }
- }
-
- /* Port */
- if (port_update && (params->port_id >= p->n_ports_out))
- return -1;
-
- return 0;
-}
-
-int
-app_pipeline_fa_flow_config(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t flow_id,
- uint32_t meter_update_mask,
- uint32_t policer_update_mask,
- uint32_t port_update,
- struct pipeline_fa_flow_params *params)
-{
- struct app_pipeline_fa *p;
- struct app_pipeline_fa_flow *flow;
-
- struct pipeline_fa_flow_config_msg_req *req;
- struct pipeline_fa_flow_config_msg_rsp *rsp;
-
- uint32_t i, mask;
-
- /* Check input arguments */
- if ((app == NULL) ||
- ((meter_update_mask == 0) &&
- (policer_update_mask == 0) &&
- (port_update == 0)) ||
- (meter_update_mask >= (1 << PIPELINE_FA_N_TC_MAX)) ||
- (policer_update_mask >= (1 << PIPELINE_FA_N_TC_MAX)) ||
- (params == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- if (flow_params_check(p,
- meter_update_mask,
- policer_update_mask,
- port_update,
- params) != 0)
- return -1;
-
- flow_id %= p->params.n_flows;
- flow = &p->flows[flow_id];
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FA_MSG_REQ_FLOW_CONFIG;
- req->entry_ptr = flow->entry_ptr;
- req->flow_id = flow_id;
- req->meter_update_mask = meter_update_mask;
- req->policer_update_mask = policer_update_mask;
- req->port_update = port_update;
- memcpy(&req->params, params, sizeof(*params));
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status ||
- (rsp->entry_ptr == NULL)) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Commit flow */
- for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
- if ((mask & meter_update_mask) == 0)
- continue;
-
- memcpy(&flow->params.m[i], &params->m[i], sizeof(params->m[i]));
- }
-
- for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
- if ((mask & policer_update_mask) == 0)
- continue;
-
- memcpy(&flow->params.p[i], &params->p[i], sizeof(params->p[i]));
- }
-
- if (port_update)
- flow->params.port_id = params->port_id;
-
- flow->entry_ptr = rsp->entry_ptr;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_fa_flow_config_bulk(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t *flow_id,
- uint32_t n_flows,
- uint32_t meter_update_mask,
- uint32_t policer_update_mask,
- uint32_t port_update,
- struct pipeline_fa_flow_params *params)
-{
- struct app_pipeline_fa *p;
- struct pipeline_fa_flow_config_bulk_msg_req *req;
- struct pipeline_fa_flow_config_bulk_msg_rsp *rsp;
- void **req_entry_ptr;
- uint32_t *req_flow_id;
- uint32_t i;
- int status;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (flow_id == NULL) ||
- (n_flows == 0) ||
- ((meter_update_mask == 0) &&
- (policer_update_mask == 0) &&
- (port_update == 0)) ||
- (meter_update_mask >= (1 << PIPELINE_FA_N_TC_MAX)) ||
- (policer_update_mask >= (1 << PIPELINE_FA_N_TC_MAX)) ||
- (params == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- for (i = 0; i < n_flows; i++) {
- struct pipeline_fa_flow_params *flow_params = &params[i];
-
- if (flow_params_check(p,
- meter_update_mask,
- policer_update_mask,
- port_update,
- flow_params) != 0)
- return -1;
- }
-
- /* Allocate and write request */
- req_entry_ptr = (void **) rte_malloc(NULL,
- n_flows * sizeof(void *),
- RTE_CACHE_LINE_SIZE);
- if (req_entry_ptr == NULL)
- return -1;
-
- req_flow_id = (uint32_t *) rte_malloc(NULL,
- n_flows * sizeof(uint32_t),
- RTE_CACHE_LINE_SIZE);
- if (req_flow_id == NULL) {
- rte_free(req_entry_ptr);
- return -1;
- }
-
- for (i = 0; i < n_flows; i++) {
- uint32_t fid = flow_id[i] % p->params.n_flows;
- struct app_pipeline_fa_flow *flow = &p->flows[fid];
-
- req_flow_id[i] = fid;
- req_entry_ptr[i] = flow->entry_ptr;
- }
-
- req = app_msg_alloc(app);
- if (req == NULL) {
- rte_free(req_flow_id);
- rte_free(req_entry_ptr);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FA_MSG_REQ_FLOW_CONFIG_BULK;
- req->entry_ptr = req_entry_ptr;
- req->flow_id = req_flow_id;
- req->n_flows = n_flows;
- req->meter_update_mask = meter_update_mask;
- req->policer_update_mask = policer_update_mask;
- req->port_update = port_update;
- req->params = params;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- rte_free(req_flow_id);
- rte_free(req_entry_ptr);
- return -1;
- }
-
- /* Read response */
- status = (rsp->n_flows == n_flows) ? 0 : -1;
-
- /* Commit flows */
- for (i = 0; i < rsp->n_flows; i++) {
- uint32_t fid = flow_id[i] % p->params.n_flows;
- struct app_pipeline_fa_flow *flow = &p->flows[fid];
- struct pipeline_fa_flow_params *flow_params = &params[i];
- void *entry_ptr = req_entry_ptr[i];
- uint32_t j, mask;
-
- for (j = 0, mask = 1; j < PIPELINE_FA_N_TC_MAX;
- j++, mask <<= 1) {
- if ((mask & meter_update_mask) == 0)
- continue;
-
- memcpy(&flow->params.m[j],
- &flow_params->m[j],
- sizeof(flow_params->m[j]));
- }
-
- for (j = 0, mask = 1; j < PIPELINE_FA_N_TC_MAX;
- j++, mask <<= 1) {
- if ((mask & policer_update_mask) == 0)
- continue;
-
- memcpy(&flow->params.p[j],
- &flow_params->p[j],
- sizeof(flow_params->p[j]));
- }
-
- if (port_update)
- flow->params.port_id = flow_params->port_id;
-
- flow->entry_ptr = entry_ptr;
- }
-
- /* Free response */
- app_msg_free(app, rsp);
- rte_free(req_flow_id);
- rte_free(req_entry_ptr);
-
- return status;
-}
-
-int
-app_pipeline_fa_dscp_config(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t dscp,
- uint32_t traffic_class,
- enum rte_meter_color color)
-{
- struct app_pipeline_fa *p;
-
- struct pipeline_fa_dscp_config_msg_req *req;
- struct pipeline_fa_dscp_config_msg_rsp *rsp;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (dscp >= PIPELINE_FA_N_DSCP) ||
- (traffic_class >= PIPELINE_FA_N_TC_MAX) ||
- (color >= e_RTE_METER_COLORS))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- if (p->params.dscp_enabled == 0)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FA_MSG_REQ_DSCP_CONFIG;
- req->dscp = dscp;
- req->traffic_class = traffic_class;
- req->color = color;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Commit DSCP */
- p->dscp[dscp].traffic_class = traffic_class;
- p->dscp[dscp].color = color;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_fa_flow_policer_stats_read(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t flow_id,
- uint32_t policer_id,
- int clear,
- struct pipeline_fa_policer_stats *stats)
-{
- struct app_pipeline_fa *p;
- struct app_pipeline_fa_flow *flow;
-
- struct pipeline_fa_policer_stats_msg_req *req;
- struct pipeline_fa_policer_stats_msg_rsp *rsp;
-
- /* Check input arguments */
- if ((app == NULL) || (stats == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- flow_id %= p->params.n_flows;
- flow = &p->flows[flow_id];
-
- if ((policer_id >= p->params.n_meters_per_flow) ||
- (flow->entry_ptr == NULL))
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FA_MSG_REQ_POLICER_STATS_READ;
- req->entry_ptr = flow->entry_ptr;
- req->policer_id = policer_id;
- req->clear = clear;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- memcpy(stats, &rsp->stats, sizeof(*stats));
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-static const char *
-color_to_string(enum rte_meter_color color)
-{
- switch (color) {
- case e_RTE_METER_GREEN: return "G";
- case e_RTE_METER_YELLOW: return "Y";
- case e_RTE_METER_RED: return "R";
- default: return "?";
- }
-}
-
-static int
-string_to_color(char *s, enum rte_meter_color *c)
-{
- if (strcmp(s, "G") == 0) {
- *c = e_RTE_METER_GREEN;
- return 0;
- }
-
- if (strcmp(s, "Y") == 0) {
- *c = e_RTE_METER_YELLOW;
- return 0;
- }
-
- if (strcmp(s, "R") == 0) {
- *c = e_RTE_METER_RED;
- return 0;
- }
-
- return -1;
-}
-
-static const char *
-policer_action_to_string(struct pipeline_fa_policer_action *a)
-{
- if (a->drop)
- return "D";
-
- return color_to_string(a->color);
-}
-
-static int
-string_to_policer_action(char *s, struct pipeline_fa_policer_action *a)
-{
- if (strcmp(s, "G") == 0) {
- a->drop = 0;
- a->color = e_RTE_METER_GREEN;
- return 0;
- }
-
- if (strcmp(s, "Y") == 0) {
- a->drop = 0;
- a->color = e_RTE_METER_YELLOW;
- return 0;
- }
-
- if (strcmp(s, "R") == 0) {
- a->drop = 0;
- a->color = e_RTE_METER_RED;
- return 0;
- }
-
- if (strcmp(s, "D") == 0) {
- a->drop = 1;
- a->color = e_RTE_METER_GREEN;
- return 0;
- }
-
- return -1;
-}
-
-static void
-print_flow(struct app_pipeline_fa *p,
- uint32_t flow_id,
- struct app_pipeline_fa_flow *flow)
-{
- uint32_t i;
-
- printf("Flow ID = %" PRIu32 "\n", flow_id);
-
- for (i = 0; i < p->params.n_meters_per_flow; i++) {
- struct rte_meter_trtcm_params *meter = &flow->params.m[i];
- struct pipeline_fa_policer_params *policer = &flow->params.p[i];
-
- printf("\ttrTCM [CIR = %" PRIu64
- ", CBS = %" PRIu64 ", PIR = %" PRIu64
- ", PBS = %" PRIu64 "] Policer [G : %s, Y : %s, R : %s]\n",
- meter->cir,
- meter->cbs,
- meter->pir,
- meter->pbs,
- policer_action_to_string(&policer->action[e_RTE_METER_GREEN]),
- policer_action_to_string(&policer->action[e_RTE_METER_YELLOW]),
- policer_action_to_string(&policer->action[e_RTE_METER_RED]));
- }
-
- printf("\tPort %u (entry_ptr = %p)\n",
- flow->params.port_id,
- flow->entry_ptr);
-}
-
-
-static int
-app_pipeline_fa_flow_ls(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_fa *p;
- uint32_t i;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- for (i = 0; i < p->params.n_flows; i++) {
- struct app_pipeline_fa_flow *flow = &p->flows[i];
-
- print_flow(p, i, flow);
- }
-
- return 0;
-}
-
-static int
-app_pipeline_fa_dscp_ls(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_fa *p;
- uint32_t i;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id,
- &pipeline_flow_actions);
- if (p == NULL)
- return -1;
-
- if (p->params.dscp_enabled == 0)
- return -1;
-
- for (i = 0; i < RTE_DIM(p->dscp); i++) {
- struct app_pipeline_fa_dscp *dscp = &p->dscp[i];
-
- printf("DSCP = %2" PRIu32 ": Traffic class = %" PRIu32
- ", Color = %s\n",
- i,
- dscp->traffic_class,
- color_to_string(dscp->color));
- }
-
- return 0;
-}
-
-int
-app_pipeline_fa_load_file(char *filename,
- uint32_t *flow_ids,
- struct pipeline_fa_flow_params *p,
- uint32_t *n_flows,
- uint32_t *line)
-{
- FILE *f = NULL;
- char file_buf[1024];
- uint32_t i, l;
-
- /* Check input arguments */
- if ((filename == NULL) ||
- (flow_ids == NULL) ||
- (p == NULL) ||
- (n_flows == NULL) ||
- (*n_flows == 0) ||
- (line == NULL)) {
- if (line)
- *line = 0;
- return -1;
- }
-
- /* Open input file */
- f = fopen(filename, "r");
- if (f == NULL) {
- *line = 0;
- return -1;
- }
-
- /* Read file */
- for (i = 0, l = 1; i < *n_flows; l++) {
- char *tokens[64];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- int status;
-
- if (fgets(file_buf, sizeof(file_buf), f) == NULL)
- break;
-
- status = parse_tokenize_string(file_buf, tokens, &n_tokens);
- if (status)
- goto error1;
-
- if ((n_tokens == 0) || (tokens[0][0] == '#'))
- continue;
-
-
- if ((n_tokens != 64) ||
- /* flow */
- strcmp(tokens[0], "flow") ||
- parser_read_uint32(&flow_ids[i], tokens[1]) ||
-
- /* meter & policer 0 */
- strcmp(tokens[2], "meter") ||
- strcmp(tokens[3], "0") ||
- strcmp(tokens[4], "trtcm") ||
- parser_read_uint64(&p[i].m[0].cir, tokens[5]) ||
- parser_read_uint64(&p[i].m[0].pir, tokens[6]) ||
- parser_read_uint64(&p[i].m[0].cbs, tokens[7]) ||
- parser_read_uint64(&p[i].m[0].pbs, tokens[8]) ||
- strcmp(tokens[9], "policer") ||
- strcmp(tokens[10], "0") ||
- strcmp(tokens[11], "g") ||
- string_to_policer_action(tokens[12],
- &p[i].p[0].action[e_RTE_METER_GREEN]) ||
- strcmp(tokens[13], "y") ||
- string_to_policer_action(tokens[14],
- &p[i].p[0].action[e_RTE_METER_YELLOW]) ||
- strcmp(tokens[15], "r") ||
- string_to_policer_action(tokens[16],
- &p[i].p[0].action[e_RTE_METER_RED]) ||
-
- /* meter & policer 1 */
- strcmp(tokens[17], "meter") ||
- strcmp(tokens[18], "1") ||
- strcmp(tokens[19], "trtcm") ||
- parser_read_uint64(&p[i].m[1].cir, tokens[20]) ||
- parser_read_uint64(&p[i].m[1].pir, tokens[21]) ||
- parser_read_uint64(&p[i].m[1].cbs, tokens[22]) ||
- parser_read_uint64(&p[i].m[1].pbs, tokens[23]) ||
- strcmp(tokens[24], "policer") ||
- strcmp(tokens[25], "1") ||
- strcmp(tokens[26], "g") ||
- string_to_policer_action(tokens[27],
- &p[i].p[1].action[e_RTE_METER_GREEN]) ||
- strcmp(tokens[28], "y") ||
- string_to_policer_action(tokens[29],
- &p[i].p[1].action[e_RTE_METER_YELLOW]) ||
- strcmp(tokens[30], "r") ||
- string_to_policer_action(tokens[31],
- &p[i].p[1].action[e_RTE_METER_RED]) ||
-
- /* meter & policer 2 */
- strcmp(tokens[32], "meter") ||
- strcmp(tokens[33], "2") ||
- strcmp(tokens[34], "trtcm") ||
- parser_read_uint64(&p[i].m[2].cir, tokens[35]) ||
- parser_read_uint64(&p[i].m[2].pir, tokens[36]) ||
- parser_read_uint64(&p[i].m[2].cbs, tokens[37]) ||
- parser_read_uint64(&p[i].m[2].pbs, tokens[38]) ||
- strcmp(tokens[39], "policer") ||
- strcmp(tokens[40], "2") ||
- strcmp(tokens[41], "g") ||
- string_to_policer_action(tokens[42],
- &p[i].p[2].action[e_RTE_METER_GREEN]) ||
- strcmp(tokens[43], "y") ||
- string_to_policer_action(tokens[44],
- &p[i].p[2].action[e_RTE_METER_YELLOW]) ||
- strcmp(tokens[45], "r") ||
- string_to_policer_action(tokens[46],
- &p[i].p[2].action[e_RTE_METER_RED]) ||
-
- /* meter & policer 3 */
- strcmp(tokens[47], "meter") ||
- strcmp(tokens[48], "3") ||
- strcmp(tokens[49], "trtcm") ||
- parser_read_uint64(&p[i].m[3].cir, tokens[50]) ||
- parser_read_uint64(&p[i].m[3].pir, tokens[51]) ||
- parser_read_uint64(&p[i].m[3].cbs, tokens[52]) ||
- parser_read_uint64(&p[i].m[3].pbs, tokens[53]) ||
- strcmp(tokens[54], "policer") ||
- strcmp(tokens[55], "3") ||
- strcmp(tokens[56], "g") ||
- string_to_policer_action(tokens[57],
- &p[i].p[3].action[e_RTE_METER_GREEN]) ||
- strcmp(tokens[58], "y") ||
- string_to_policer_action(tokens[59],
- &p[i].p[3].action[e_RTE_METER_YELLOW]) ||
- strcmp(tokens[60], "r") ||
- string_to_policer_action(tokens[61],
- &p[i].p[3].action[e_RTE_METER_RED]) ||
-
- /* port */
- strcmp(tokens[62], "port") ||
- parser_read_uint32(&p[i].port_id, tokens[63]))
- goto error1;
-
- i++;
- }
-
- /* Close file */
- *n_flows = i;
- fclose(f);
- return 0;
-
-error1:
- *line = l;
- fclose(f);
- return -1;
-}
-
-/*
- * action
- *
- * flow meter, policer and output port configuration:
- * p <pipelineid> action flow <flowid> meter <meterid> trtcm <cir> <pir> <cbs> <pbs>
- *
- * p <pipelineid> action flow <flowid> policer <policerid> g <gaction> y <yaction> r <raction>
- * <action> is one of the following:
- * G = recolor to green
- * Y = recolor as yellow
- * R = recolor as red
- * D = drop
- *
- * p <pipelineid> action flow <flowid> port <port ID>
- *
- * p <pipelineid> action flow bulk <file>
- *
- * flow policer stats read:
- * p <pipelineid> action flow <flowid> stats
- *
- * flow ls:
- * p <pipelineid> action flow ls
- *
- * dscp table configuration:
- * p <pipelineid> action dscp <dscpid> class <class ID> color <color>
- *
- * dscp table ls:
- * p <pipelineid> action dscp ls
-**/
-
-struct cmd_action_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t action_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_action_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_action_result *params = parsed_result;
- struct app_params *app = data;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status != 0) {
- printf(CMD_MSG_TOO_MANY_ARGS, "action");
- return;
- }
-
- /* action flow meter */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "flow") == 0) &&
- strcmp(tokens[1], "bulk") &&
- strcmp(tokens[1], "ls") &&
- (strcmp(tokens[2], "meter") == 0)) {
- struct pipeline_fa_flow_params flow_params;
- uint32_t flow_id, meter_id;
-
- if (n_tokens != 9) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow meter");
- return;
- }
-
- memset(&flow_params, 0, sizeof(flow_params));
-
- if (parser_read_uint32(&flow_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- if (parser_read_uint32(&meter_id, tokens[3]) ||
- (meter_id >= PIPELINE_FA_N_TC_MAX)) {
- printf(CMD_MSG_INVALID_ARG, "meterid");
- return;
- }
-
- if (strcmp(tokens[4], "trtcm")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "trtcm");
- return;
- }
-
- if (parser_read_uint64(&flow_params.m[meter_id].cir, tokens[5])) {
- printf(CMD_MSG_INVALID_ARG, "cir");
- return;
- }
-
- if (parser_read_uint64(&flow_params.m[meter_id].pir, tokens[6])) {
- printf(CMD_MSG_INVALID_ARG, "pir");
- return;
- }
-
- if (parser_read_uint64(&flow_params.m[meter_id].cbs, tokens[7])) {
- printf(CMD_MSG_INVALID_ARG, "cbs");
- return;
- }
-
- if (parser_read_uint64(&flow_params.m[meter_id].pbs, tokens[8])) {
- printf(CMD_MSG_INVALID_ARG, "pbs");
- return;
- }
-
- status = app_pipeline_fa_flow_config(app,
- params->pipeline_id,
- flow_id,
- 1 << meter_id,
- 0,
- 0,
- &flow_params);
- if (status)
- printf(CMD_MSG_FAIL, "action flow meter");
-
- return;
- } /* action flow meter */
-
- /* action flow policer */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "flow") == 0) &&
- strcmp(tokens[1], "bulk") &&
- strcmp(tokens[1], "ls") &&
- (strcmp(tokens[2], "policer") == 0)) {
- struct pipeline_fa_flow_params flow_params;
- uint32_t flow_id, policer_id;
-
- if (n_tokens != 10) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow policer");
- return;
- }
-
- memset(&flow_params, 0, sizeof(flow_params));
-
- if (parser_read_uint32(&flow_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- if (parser_read_uint32(&policer_id, tokens[3]) ||
- (policer_id >= PIPELINE_FA_N_TC_MAX)) {
- printf(CMD_MSG_INVALID_ARG, "policerid");
- return;
- }
-
- if (strcmp(tokens[4], "g")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "g");
- return;
- }
-
- if (string_to_policer_action(tokens[5],
- &flow_params.p[policer_id].action[e_RTE_METER_GREEN])) {
- printf(CMD_MSG_INVALID_ARG, "gaction");
- return;
- }
-
- if (strcmp(tokens[6], "y")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "y");
- return;
- }
-
- if (string_to_policer_action(tokens[7],
- &flow_params.p[policer_id].action[e_RTE_METER_YELLOW])) {
- printf(CMD_MSG_INVALID_ARG, "yaction");
- return;
- }
-
- if (strcmp(tokens[8], "r")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "r");
- return;
- }
-
- if (string_to_policer_action(tokens[9],
- &flow_params.p[policer_id].action[e_RTE_METER_RED])) {
- printf(CMD_MSG_INVALID_ARG, "raction");
- return;
- }
-
- status = app_pipeline_fa_flow_config(app,
- params->pipeline_id,
- flow_id,
- 0,
- 1 << policer_id,
- 0,
- &flow_params);
- if (status != 0)
- printf(CMD_MSG_FAIL, "action flow policer");
-
- return;
- } /* action flow policer */
-
- /* action flow port */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "flow") == 0) &&
- strcmp(tokens[1], "bulk") &&
- strcmp(tokens[1], "ls") &&
- (strcmp(tokens[2], "port") == 0)) {
- struct pipeline_fa_flow_params flow_params;
- uint32_t flow_id, port_id;
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow port");
- return;
- }
-
- memset(&flow_params, 0, sizeof(flow_params));
-
- if (parser_read_uint32(&flow_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[3])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- flow_params.port_id = port_id;
-
- status = app_pipeline_fa_flow_config(app,
- params->pipeline_id,
- flow_id,
- 0,
- 0,
- 1,
- &flow_params);
- if (status)
- printf(CMD_MSG_FAIL, "action flow port");
-
- return;
- } /* action flow port */
-
- /* action flow stats */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "flow") == 0) &&
- strcmp(tokens[1], "bulk") &&
- strcmp(tokens[1], "ls") &&
- (strcmp(tokens[2], "stats") == 0)) {
- struct pipeline_fa_policer_stats stats;
- uint32_t flow_id, policer_id;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow stats");
- return;
- }
-
- if (parser_read_uint32(&flow_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- for (policer_id = 0;
- policer_id < PIPELINE_FA_N_TC_MAX;
- policer_id++) {
- status = app_pipeline_fa_flow_policer_stats_read(app,
- params->pipeline_id,
- flow_id,
- policer_id,
- 1,
- &stats);
- if (status != 0) {
- printf(CMD_MSG_FAIL, "action flow stats");
- return;
- }
-
- /* Display stats */
- printf("\tPolicer: %" PRIu32
- "\tPkts G: %" PRIu64
- "\tPkts Y: %" PRIu64
- "\tPkts R: %" PRIu64
- "\tPkts D: %" PRIu64 "\n",
- policer_id,
- stats.n_pkts[e_RTE_METER_GREEN],
- stats.n_pkts[e_RTE_METER_YELLOW],
- stats.n_pkts[e_RTE_METER_RED],
- stats.n_pkts_drop);
- }
-
- return;
- } /* action flow stats */
-
- /* action flow bulk */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "flow") == 0) &&
- (strcmp(tokens[1], "bulk") == 0)) {
- struct pipeline_fa_flow_params *flow_params;
- uint32_t *flow_ids, n_flows, line;
- char *filename;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow bulk");
- return;
- }
-
- filename = tokens[2];
-
- n_flows = APP_PIPELINE_FA_MAX_RECORDS_IN_FILE;
- flow_ids = malloc(n_flows * sizeof(uint32_t));
- if (flow_ids == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- return;
- }
-
- flow_params = malloc(n_flows * sizeof(struct pipeline_fa_flow_params));
- if (flow_params == NULL) {
- printf(CMD_MSG_OUT_OF_MEMORY);
- free(flow_ids);
- return;
- }
-
- status = app_pipeline_fa_load_file(filename,
- flow_ids,
- flow_params,
- &n_flows,
- &line);
- if (status) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(flow_params);
- free(flow_ids);
- return;
- }
-
- status = app_pipeline_fa_flow_config_bulk(app,
- params->pipeline_id,
- flow_ids,
- n_flows,
- 0xF,
- 0xF,
- 1,
- flow_params);
- if (status)
- printf(CMD_MSG_FAIL, "action flow bulk");
-
- free(flow_params);
- free(flow_ids);
- return;
- } /* action flow bulk */
-
- /* action flow ls */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "flow") == 0) &&
- (strcmp(tokens[1], "ls") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "action flow ls");
- return;
- }
-
- status = app_pipeline_fa_flow_ls(app,
- params->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "action flow ls");
-
- return;
- } /* action flow ls */
-
- /* action dscp */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "dscp") == 0) &&
- strcmp(tokens[1], "ls")) {
- uint32_t dscp_id, tc_id;
- enum rte_meter_color color;
-
- if (n_tokens != 6) {
- printf(CMD_MSG_MISMATCH_ARGS, "action dscp");
- return;
- }
-
- if (parser_read_uint32(&dscp_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "dscpid");
- return;
- }
-
- if (strcmp(tokens[2], "class")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "class");
- return;
- }
-
- if (parser_read_uint32(&tc_id, tokens[3])) {
- printf(CMD_MSG_INVALID_ARG, "classid");
- return;
- }
-
- if (strcmp(tokens[4], "color")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "color");
- return;
- }
-
- if (string_to_color(tokens[5], &color)) {
- printf(CMD_MSG_INVALID_ARG, "colorid");
- return;
- }
-
- status = app_pipeline_fa_dscp_config(app,
- params->pipeline_id,
- dscp_id,
- tc_id,
- color);
- if (status != 0)
- printf(CMD_MSG_FAIL, "action dscp");
-
- return;
- } /* action dscp */
-
- /* action dscp ls */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "dscp") == 0) &&
- (strcmp(tokens[1], "ls") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "action dscp ls");
- return;
- }
-
- status = app_pipeline_fa_dscp_ls(app,
- params->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "action dscp ls");
-
- return;
- } /* action dscp ls */
-
- printf(CMD_MSG_FAIL, "action");
-}
-
-static cmdline_parse_token_string_t cmd_action_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_action_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_action_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_action_result, pipeline_id, UINT32);
-
-static cmdline_parse_token_string_t cmd_action_action_string =
- TOKEN_STRING_INITIALIZER(struct cmd_action_result, action_string, "action");
-
-static cmdline_parse_token_string_t cmd_action_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_action_result, multi_string,
- TOKEN_STRING_MULTI);
-
-cmdline_parse_inst_t cmd_action = {
- .f = cmd_action_parsed,
- .data = NULL,
- .help_str = "flow actions (meter, policer, policer stats, dscp table)",
- .tokens = {
- (void *) &cmd_action_p_string,
- (void *) &cmd_action_pipeline_id,
- (void *) &cmd_action_action_string,
- (void *) &cmd_action_multi_string,
- NULL,
- },
-};
-
-static cmdline_parse_ctx_t pipeline_cmds[] = {
- (cmdline_parse_inst_t *) &cmd_action,
- NULL,
-};
-
-static struct pipeline_fe_ops pipeline_flow_actions_fe_ops = {
- .f_init = app_pipeline_fa_init,
- .f_post_init = NULL,
- .f_free = app_pipeline_fa_free,
- .f_track = app_pipeline_track_default,
- .cmds = pipeline_cmds,
-};
-
-struct pipeline_type pipeline_flow_actions = {
- .name = "FLOW_ACTIONS",
- .be_ops = &pipeline_flow_actions_be_ops,
- .fe_ops = &pipeline_flow_actions_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions.h b/examples/ip_pipeline/pipeline/pipeline_flow_actions.h
deleted file mode 100644
index 885923e4..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FLOW_ACTIONS_H__
-#define __INCLUDE_PIPELINE_FLOW_ACTIONS_H__
-
-#include <rte_meter.h>
-
-#include "pipeline.h"
-#include "pipeline_flow_actions_be.h"
-
-int
-app_pipeline_fa_flow_config(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t flow_id,
- uint32_t meter_update_mask,
- uint32_t policer_update_mask,
- uint32_t port_update,
- struct pipeline_fa_flow_params *params);
-
-int
-app_pipeline_fa_flow_config_bulk(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t *flow_id,
- uint32_t n_flows,
- uint32_t meter_update_mask,
- uint32_t policer_update_mask,
- uint32_t port_update,
- struct pipeline_fa_flow_params *params);
-
-int
-app_pipeline_fa_dscp_config(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t dscp,
- uint32_t traffic_class,
- enum rte_meter_color color);
-
-int
-app_pipeline_fa_flow_policer_stats_read(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t flow_id,
- uint32_t policer_id,
- int clear,
- struct pipeline_fa_policer_stats *stats);
-
-#ifndef APP_PIPELINE_FA_MAX_RECORDS_IN_FILE
-#define APP_PIPELINE_FA_MAX_RECORDS_IN_FILE 65536
-#endif
-
-int
-app_pipeline_fa_load_file(char *filename,
- uint32_t *flow_ids,
- struct pipeline_fa_flow_params *p,
- uint32_t *n_flows,
- uint32_t *line);
-
-extern struct pipeline_type pipeline_flow_actions;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
deleted file mode 100644
index 9599b7d8..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.c
+++ /dev/null
@@ -1,960 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <string.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <rte_cycles.h>
-#include <rte_table_array.h>
-#include <rte_byteorder.h>
-#include <rte_ip.h>
-
-#include "pipeline_actions_common.h"
-#include "pipeline_flow_actions_be.h"
-#include "parser.h"
-#include "hash_func.h"
-
-int
-pipeline_fa_flow_params_set_default(struct pipeline_fa_flow_params *params)
-{
- uint32_t i;
-
- if (params == NULL)
- return -1;
-
- for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
- struct rte_meter_trtcm_params *m = &params->m[i];
-
- m->cir = 1;
- m->cbs = 1;
- m->pir = 1;
- m->pbs = 2;
- }
-
- for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
- struct pipeline_fa_policer_params *p = &params->p[i];
- uint32_t j;
-
- for (j = 0; j < e_RTE_METER_COLORS; j++) {
- struct pipeline_fa_policer_action *a = &p->action[j];
-
- a->drop = 0;
- a->color = (enum rte_meter_color) j;
- }
- }
-
- params->port_id = 0;
-
- return 0;
-}
-
-struct dscp_entry {
- uint32_t traffic_class;
- enum rte_meter_color color;
-};
-
-struct pipeline_flow_actions {
- struct pipeline p;
- struct pipeline_fa_params params;
- pipeline_msg_req_handler custom_handlers[PIPELINE_FA_MSG_REQS];
-
- struct dscp_entry dscp[PIPELINE_FA_N_DSCP];
-} __rte_cache_aligned;
-
-static void *
-pipeline_fa_msg_req_custom_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler handlers[] = {
- [PIPELINE_MSG_REQ_PING] =
- pipeline_msg_req_ping_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_IN] =
- pipeline_msg_req_stats_port_in_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
- pipeline_msg_req_stats_port_out_handler,
- [PIPELINE_MSG_REQ_STATS_TABLE] =
- pipeline_msg_req_stats_table_handler,
- [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
- pipeline_msg_req_port_in_enable_handler,
- [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
- pipeline_msg_req_port_in_disable_handler,
- [PIPELINE_MSG_REQ_CUSTOM] =
- pipeline_fa_msg_req_custom_handler,
-};
-
-static void *
-pipeline_fa_msg_req_flow_config_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fa_msg_req_flow_config_bulk_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fa_msg_req_dscp_config_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fa_msg_req_policer_stats_read_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler custom_handlers[] = {
- [PIPELINE_FA_MSG_REQ_FLOW_CONFIG] =
- pipeline_fa_msg_req_flow_config_handler,
- [PIPELINE_FA_MSG_REQ_FLOW_CONFIG_BULK] =
- pipeline_fa_msg_req_flow_config_bulk_handler,
- [PIPELINE_FA_MSG_REQ_DSCP_CONFIG] =
- pipeline_fa_msg_req_dscp_config_handler,
- [PIPELINE_FA_MSG_REQ_POLICER_STATS_READ] =
- pipeline_fa_msg_req_policer_stats_read_handler,
-};
-
-/*
- * Flow table
- */
-struct meter_policer {
- struct rte_meter_trtcm meter;
- struct pipeline_fa_policer_params policer;
- struct pipeline_fa_policer_stats stats;
-};
-
-struct flow_table_entry {
- struct rte_pipeline_table_entry head;
- struct meter_policer mp[PIPELINE_FA_N_TC_MAX];
-};
-
-static int
-flow_table_entry_set_meter(struct flow_table_entry *entry,
- uint32_t meter_id,
- struct pipeline_fa_flow_params *params)
-{
- struct rte_meter_trtcm *meter = &entry->mp[meter_id].meter;
- struct rte_meter_trtcm_params *meter_params = &params->m[meter_id];
-
- return rte_meter_trtcm_config(meter, meter_params);
-}
-
-static void
-flow_table_entry_set_policer(struct flow_table_entry *entry,
- uint32_t policer_id,
- struct pipeline_fa_flow_params *params)
-{
- struct pipeline_fa_policer_params *p0 = &entry->mp[policer_id].policer;
- struct pipeline_fa_policer_params *p1 = &params->p[policer_id];
-
- memcpy(p0, p1, sizeof(*p0));
-}
-
-static void
-flow_table_entry_set_port_id(struct pipeline_flow_actions *p,
- struct flow_table_entry *entry,
- struct pipeline_fa_flow_params *params)
-{
- entry->head.action = RTE_PIPELINE_ACTION_PORT;
- entry->head.port_id = p->p.port_out_id[params->port_id];
-}
-
-static int
-flow_table_entry_set_default(struct pipeline_flow_actions *p,
- struct flow_table_entry *entry)
-{
- struct pipeline_fa_flow_params params;
- uint32_t i;
-
- pipeline_fa_flow_params_set_default(&params);
-
- memset(entry, 0, sizeof(*entry));
-
- flow_table_entry_set_port_id(p, entry, &params);
-
- for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++) {
- int status;
-
- status = flow_table_entry_set_meter(entry, i, &params);
- if (status)
- return status;
- }
-
- for (i = 0; i < PIPELINE_FA_N_TC_MAX; i++)
- flow_table_entry_set_policer(entry, i, &params);
-
- return 0;
-}
-
-static inline uint64_t
-pkt_work(
- struct rte_mbuf *pkt,
- struct rte_pipeline_table_entry *table_entry,
- void *arg,
- uint64_t time)
-{
- struct pipeline_flow_actions *p = arg;
- struct flow_table_entry *entry =
- (struct flow_table_entry *) table_entry;
-
- struct ipv4_hdr *pkt_ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT32_PTR(pkt, p->params.ip_hdr_offset);
- enum rte_meter_color *pkt_color = (enum rte_meter_color *)
- RTE_MBUF_METADATA_UINT32_PTR(pkt, p->params.color_offset);
-
- /* Read (IP header) */
- uint32_t total_length = rte_bswap16(pkt_ip->total_length);
- uint32_t dscp = pkt_ip->type_of_service >> 2;
-
- uint32_t tc = p->dscp[dscp].traffic_class;
- enum rte_meter_color color = p->dscp[dscp].color;
-
- struct rte_meter_trtcm *meter = &entry->mp[tc].meter;
- struct pipeline_fa_policer_params *policer = &entry->mp[tc].policer;
- struct pipeline_fa_policer_stats *stats = &entry->mp[tc].stats;
-
- /* Read (entry), compute */
- enum rte_meter_color color2 = rte_meter_trtcm_color_aware_check(meter,
- time,
- total_length,
- color);
-
- enum rte_meter_color color3 = policer->action[color2].color;
- uint64_t drop = policer->action[color2].drop;
-
- /* Read (entry), write (entry, color) */
- stats->n_pkts[color3] += drop ^ 1LLU;
- stats->n_pkts_drop += drop;
- *pkt_color = color3;
-
- return drop;
-}
-
-static inline uint64_t
-pkt4_work(
- struct rte_mbuf **pkts,
- struct rte_pipeline_table_entry **table_entries,
- void *arg,
- uint64_t time)
-{
- struct pipeline_flow_actions *p = arg;
-
- struct flow_table_entry *entry0 =
- (struct flow_table_entry *) table_entries[0];
- struct flow_table_entry *entry1 =
- (struct flow_table_entry *) table_entries[1];
- struct flow_table_entry *entry2 =
- (struct flow_table_entry *) table_entries[2];
- struct flow_table_entry *entry3 =
- (struct flow_table_entry *) table_entries[3];
-
- struct ipv4_hdr *pkt0_ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[0], p->params.ip_hdr_offset);
- struct ipv4_hdr *pkt1_ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[1], p->params.ip_hdr_offset);
- struct ipv4_hdr *pkt2_ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[2], p->params.ip_hdr_offset);
- struct ipv4_hdr *pkt3_ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[3], p->params.ip_hdr_offset);
-
- enum rte_meter_color *pkt0_color = (enum rte_meter_color *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[0], p->params.color_offset);
- enum rte_meter_color *pkt1_color = (enum rte_meter_color *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[1], p->params.color_offset);
- enum rte_meter_color *pkt2_color = (enum rte_meter_color *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[2], p->params.color_offset);
- enum rte_meter_color *pkt3_color = (enum rte_meter_color *)
- RTE_MBUF_METADATA_UINT32_PTR(pkts[3], p->params.color_offset);
-
- /* Read (IP header) */
- uint32_t total_length0 = rte_bswap16(pkt0_ip->total_length);
- uint32_t dscp0 = pkt0_ip->type_of_service >> 2;
-
- uint32_t total_length1 = rte_bswap16(pkt1_ip->total_length);
- uint32_t dscp1 = pkt1_ip->type_of_service >> 2;
-
- uint32_t total_length2 = rte_bswap16(pkt2_ip->total_length);
- uint32_t dscp2 = pkt2_ip->type_of_service >> 2;
-
- uint32_t total_length3 = rte_bswap16(pkt3_ip->total_length);
- uint32_t dscp3 = pkt3_ip->type_of_service >> 2;
-
- uint32_t tc0 = p->dscp[dscp0].traffic_class;
- enum rte_meter_color color0 = p->dscp[dscp0].color;
-
- uint32_t tc1 = p->dscp[dscp1].traffic_class;
- enum rte_meter_color color1 = p->dscp[dscp1].color;
-
- uint32_t tc2 = p->dscp[dscp2].traffic_class;
- enum rte_meter_color color2 = p->dscp[dscp2].color;
-
- uint32_t tc3 = p->dscp[dscp3].traffic_class;
- enum rte_meter_color color3 = p->dscp[dscp3].color;
-
- struct rte_meter_trtcm *meter0 = &entry0->mp[tc0].meter;
- struct pipeline_fa_policer_params *policer0 = &entry0->mp[tc0].policer;
- struct pipeline_fa_policer_stats *stats0 = &entry0->mp[tc0].stats;
-
- struct rte_meter_trtcm *meter1 = &entry1->mp[tc1].meter;
- struct pipeline_fa_policer_params *policer1 = &entry1->mp[tc1].policer;
- struct pipeline_fa_policer_stats *stats1 = &entry1->mp[tc1].stats;
-
- struct rte_meter_trtcm *meter2 = &entry2->mp[tc2].meter;
- struct pipeline_fa_policer_params *policer2 = &entry2->mp[tc2].policer;
- struct pipeline_fa_policer_stats *stats2 = &entry2->mp[tc2].stats;
-
- struct rte_meter_trtcm *meter3 = &entry3->mp[tc3].meter;
- struct pipeline_fa_policer_params *policer3 = &entry3->mp[tc3].policer;
- struct pipeline_fa_policer_stats *stats3 = &entry3->mp[tc3].stats;
-
- /* Read (entry), compute, write (entry) */
- enum rte_meter_color color2_0 = rte_meter_trtcm_color_aware_check(
- meter0,
- time,
- total_length0,
- color0);
-
- enum rte_meter_color color2_1 = rte_meter_trtcm_color_aware_check(
- meter1,
- time,
- total_length1,
- color1);
-
- enum rte_meter_color color2_2 = rte_meter_trtcm_color_aware_check(
- meter2,
- time,
- total_length2,
- color2);
-
- enum rte_meter_color color2_3 = rte_meter_trtcm_color_aware_check(
- meter3,
- time,
- total_length3,
- color3);
-
- enum rte_meter_color color3_0 = policer0->action[color2_0].color;
- enum rte_meter_color color3_1 = policer1->action[color2_1].color;
- enum rte_meter_color color3_2 = policer2->action[color2_2].color;
- enum rte_meter_color color3_3 = policer3->action[color2_3].color;
-
- uint64_t drop0 = policer0->action[color2_0].drop;
- uint64_t drop1 = policer1->action[color2_1].drop;
- uint64_t drop2 = policer2->action[color2_2].drop;
- uint64_t drop3 = policer3->action[color2_3].drop;
-
- /* Read (entry), write (entry, color) */
- stats0->n_pkts[color3_0] += drop0 ^ 1LLU;
- stats0->n_pkts_drop += drop0;
-
- stats1->n_pkts[color3_1] += drop1 ^ 1LLU;
- stats1->n_pkts_drop += drop1;
-
- stats2->n_pkts[color3_2] += drop2 ^ 1LLU;
- stats2->n_pkts_drop += drop2;
-
- stats3->n_pkts[color3_3] += drop3 ^ 1LLU;
- stats3->n_pkts_drop += drop3;
-
- *pkt0_color = color3_0;
- *pkt1_color = color3_1;
- *pkt2_color = color3_2;
- *pkt3_color = color3_3;
-
- return drop0 | (drop1 << 1) | (drop2 << 2) | (drop3 << 3);
-}
-
-PIPELINE_TABLE_AH_HIT_DROP_TIME(fa_table_ah_hit, pkt_work, pkt4_work);
-
-static rte_pipeline_table_action_handler_hit
-get_fa_table_ah_hit(__rte_unused struct pipeline_flow_actions *p)
-{
- return fa_table_ah_hit;
-}
-
-/*
- * Argument parsing
- */
-int
-pipeline_fa_parse_args(struct pipeline_fa_params *p,
- struct pipeline_params *params)
-{
- uint32_t n_flows_present = 0;
- uint32_t n_meters_per_flow_present = 0;
- uint32_t flow_id_offset_present = 0;
- uint32_t ip_hdr_offset_present = 0;
- uint32_t color_offset_present = 0;
- uint32_t i;
-
- /* Default values */
- p->n_meters_per_flow = 1;
- p->dscp_enabled = 0;
-
- for (i = 0; i < params->n_args; i++) {
- char *arg_name = params->args_name[i];
- char *arg_value = params->args_value[i];
-
- /* n_flows */
- if (strcmp(arg_name, "n_flows") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_flows_present == 0, params->name,
- arg_name);
- n_flows_present = 1;
-
- status = parser_read_uint32(&p->n_flows,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->n_flows != 0)), params->name,
- arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* n_meters_per_flow */
- if (strcmp(arg_name, "n_meters_per_flow") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_meters_per_flow_present == 0,
- params->name, arg_name);
- n_meters_per_flow_present = 1;
-
- status = parser_read_uint32(&p->n_meters_per_flow,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->n_meters_per_flow != 0)),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG(((status != -ERANGE) &&
- (p->n_meters_per_flow <=
- PIPELINE_FA_N_TC_MAX)), params->name,
- arg_name, arg_value);
-
- continue;
- }
-
- /* flow_id_offset */
- if (strcmp(arg_name, "flow_id_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- flow_id_offset_present == 0,
- params->name, arg_name);
- flow_id_offset_present = 1;
-
- status = parser_read_uint32(&p->flow_id_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* ip_hdr_offset */
- if (strcmp(arg_name, "ip_hdr_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- ip_hdr_offset_present == 0,
- params->name, arg_name);
- ip_hdr_offset_present = 1;
-
- status = parser_read_uint32(&p->ip_hdr_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* color_offset */
- if (strcmp(arg_name, "color_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- color_offset_present == 0, params->name,
- arg_name);
- color_offset_present = 1;
-
- status = parser_read_uint32(&p->color_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- p->dscp_enabled = 1;
-
- continue;
- }
-
- /* Unknown argument */
- PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
- }
-
- /* Check that mandatory arguments are present */
- PIPELINE_PARSE_ERR_MANDATORY((n_flows_present), params->name,
- "n_flows");
- PIPELINE_PARSE_ERR_MANDATORY((flow_id_offset_present),
- params->name, "flow_id_offset");
- PIPELINE_PARSE_ERR_MANDATORY((ip_hdr_offset_present),
- params->name, "ip_hdr_offset");
- PIPELINE_PARSE_ERR_MANDATORY((color_offset_present), params->name,
- "color_offset");
-
- return 0;
-}
-
-static void
-dscp_init(struct pipeline_flow_actions *p)
-{
- uint32_t i;
-
- for (i = 0; i < PIPELINE_FA_N_DSCP; i++) {
- p->dscp[i].traffic_class = 0;
- p->dscp[i].color = e_RTE_METER_GREEN;
- }
-}
-
-static void *pipeline_fa_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct pipeline *p;
- struct pipeline_flow_actions *p_fa;
- uint32_t size, i;
-
- /* Check input arguments */
- if (params == NULL)
- return NULL;
-
- if (params->n_ports_in != params->n_ports_out)
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(
- sizeof(struct pipeline_flow_actions));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
- p_fa = (struct pipeline_flow_actions *) p;
-
- strcpy(p->name, params->name);
- p->log_level = params->log_level;
-
- PLOG(p, HIGH, "Flow actions");
-
- /* Parse arguments */
- if (pipeline_fa_parse_args(&p_fa->params, params))
- return NULL;
-
- dscp_init(p_fa);
-
- /* Pipeline */
- {
- struct rte_pipeline_params pipeline_params = {
- .name = params->name,
- .socket_id = params->socket_id,
- .offset_port_id = 0,
- };
-
- p->p = rte_pipeline_create(&pipeline_params);
- if (p->p == NULL) {
- rte_free(p);
- return NULL;
- }
- }
-
- /* Input ports */
- p->n_ports_in = params->n_ports_in;
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_port_in_params port_params = {
- .ops = pipeline_port_in_params_get_ops(
- &params->port_in[i]),
- .arg_create = pipeline_port_in_params_convert(
- &params->port_in[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- .burst_size = params->port_in[i].burst_size,
- };
-
- int status = rte_pipeline_port_in_create(p->p,
- &port_params,
- &p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Output ports */
- p->n_ports_out = params->n_ports_out;
- for (i = 0; i < p->n_ports_out; i++) {
- struct rte_pipeline_port_out_params port_params = {
- .ops = pipeline_port_out_params_get_ops(
- &params->port_out[i]),
- .arg_create = pipeline_port_out_params_convert(
- &params->port_out[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- };
-
- int status = rte_pipeline_port_out_create(p->p,
- &port_params,
- &p->port_out_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Tables */
- p->n_tables = 1;
- {
- struct rte_table_array_params table_array_params = {
- .n_entries = p_fa->params.n_flows,
- .offset = p_fa->params.flow_id_offset,
- };
-
- struct rte_pipeline_table_params table_params = {
- .ops = &rte_table_array_ops,
- .arg_create = &table_array_params,
- .f_action_hit = get_fa_table_ah_hit(p_fa),
- .f_action_miss = NULL,
- .arg_ah = p_fa,
- .action_data_size =
- sizeof(struct flow_table_entry) -
- sizeof(struct rte_pipeline_table_entry),
- };
-
- int status;
-
- status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Connecting input ports to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_connect_to_table(p->p,
- p->port_in_id[i],
- p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Enable input ports */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_enable(p->p,
- p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Initialize table entries */
- for (i = 0; i < p_fa->params.n_flows; i++) {
- struct rte_table_array_key key = {
- .pos = i,
- };
-
- struct flow_table_entry entry;
- struct rte_pipeline_table_entry *entry_ptr;
- int key_found, status;
-
- flow_table_entry_set_default(p_fa, &entry);
-
- status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &key,
- (struct rte_pipeline_table_entry *) &entry,
- &key_found,
- &entry_ptr);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Check pipeline consistency */
- if (rte_pipeline_check(p->p) < 0) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- /* Message queues */
- p->n_msgq = params->n_msgq;
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_in[i] = params->msgq_in[i];
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_out[i] = params->msgq_out[i];
-
- /* Message handlers */
- memcpy(p->handlers, handlers, sizeof(p->handlers));
- memcpy(p_fa->custom_handlers,
- custom_handlers,
- sizeof(p_fa->custom_handlers));
-
- return p;
-}
-
-static int
-pipeline_fa_free(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_pipeline_free(p->p);
- rte_free(p);
- return 0;
-}
-
-static int
-pipeline_fa_timer(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- pipeline_msg_req_handle(p);
- rte_pipeline_flush(p->p);
-
- return 0;
-}
-
-void *
-pipeline_fa_msg_req_custom_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_flow_actions *p_fa =
- (struct pipeline_flow_actions *) p;
- struct pipeline_custom_msg_req *req = msg;
- pipeline_msg_req_handler f_handle;
-
- f_handle = (req->subtype < PIPELINE_FA_MSG_REQS) ?
- p_fa->custom_handlers[req->subtype] :
- pipeline_msg_req_invalid_handler;
-
- if (f_handle == NULL)
- f_handle = pipeline_msg_req_invalid_handler;
-
- return f_handle(p, req);
-}
-
-void *
-pipeline_fa_msg_req_flow_config_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
- struct pipeline_fa_flow_config_msg_req *req = msg;
- struct pipeline_fa_flow_config_msg_rsp *rsp = msg;
- struct flow_table_entry *entry;
- uint32_t mask, i;
-
- /* Set flow table entry to default if not configured before */
- if (req->entry_ptr == NULL) {
- struct rte_table_array_key key = {
- .pos = req->flow_id % p_fa->params.n_flows,
- };
-
- struct flow_table_entry default_entry;
-
- int key_found, status;
-
- flow_table_entry_set_default(p_fa, &default_entry);
-
- status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &key,
- (struct rte_pipeline_table_entry *) &default_entry,
- &key_found,
- (struct rte_pipeline_table_entry **) &entry);
- if (status) {
- rsp->status = -1;
- return rsp;
- }
- } else
- entry = (struct flow_table_entry *) req->entry_ptr;
-
- /* Meter */
- for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
- int status;
-
- if ((mask & req->meter_update_mask) == 0)
- continue;
-
- status = flow_table_entry_set_meter(entry, i, &req->params);
- if (status) {
- rsp->status = -1;
- return rsp;
- }
- }
-
- /* Policer */
- for (i = 0, mask = 1; i < PIPELINE_FA_N_TC_MAX; i++, mask <<= 1) {
- if ((mask & req->policer_update_mask) == 0)
- continue;
-
- flow_table_entry_set_policer(entry, i, &req->params);
- }
-
- /* Port */
- if (req->port_update)
- flow_table_entry_set_port_id(p_fa, entry, &req->params);
-
- /* Response */
- rsp->status = 0;
- rsp->entry_ptr = (void *) entry;
- return rsp;
-}
-
-void *
-pipeline_fa_msg_req_flow_config_bulk_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
- struct pipeline_fa_flow_config_bulk_msg_req *req = msg;
- struct pipeline_fa_flow_config_bulk_msg_rsp *rsp = msg;
- uint32_t i;
-
- for (i = 0; i < req->n_flows; i++) {
- struct flow_table_entry *entry;
- uint32_t j, mask;
-
- /* Set flow table entry to default if not configured before */
- if (req->entry_ptr[i] == NULL) {
- struct rte_table_array_key key = {
- .pos = req->flow_id[i] % p_fa->params.n_flows,
- };
-
- struct flow_table_entry entry_to_add;
-
- int key_found, status;
-
- flow_table_entry_set_default(p_fa, &entry_to_add);
-
- status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &key,
- (struct rte_pipeline_table_entry *) &entry_to_add,
- &key_found,
- (struct rte_pipeline_table_entry **) &entry);
- if (status) {
- rsp->n_flows = i;
- return rsp;
- }
-
- req->entry_ptr[i] = (void *) entry;
- } else
- entry = (struct flow_table_entry *) req->entry_ptr[i];
-
- /* Meter */
- for (j = 0, mask = 1;
- j < PIPELINE_FA_N_TC_MAX;
- j++, mask <<= 1) {
- int status;
-
- if ((mask & req->meter_update_mask) == 0)
- continue;
-
- status = flow_table_entry_set_meter(entry,
- j, &req->params[i]);
- if (status) {
- rsp->n_flows = i;
- return rsp;
- }
- }
-
- /* Policer */
- for (j = 0, mask = 1;
- j < PIPELINE_FA_N_TC_MAX;
- j++, mask <<= 1) {
- if ((mask & req->policer_update_mask) == 0)
- continue;
-
- flow_table_entry_set_policer(entry,
- j, &req->params[i]);
- }
-
- /* Port */
- if (req->port_update)
- flow_table_entry_set_port_id(p_fa,
- entry, &req->params[i]);
- }
-
- /* Response */
- rsp->n_flows = i;
- return rsp;
-}
-
-void *
-pipeline_fa_msg_req_dscp_config_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_flow_actions *p_fa = (struct pipeline_flow_actions *) p;
- struct pipeline_fa_dscp_config_msg_req *req = msg;
- struct pipeline_fa_dscp_config_msg_rsp *rsp = msg;
-
- /* Check request */
- if ((req->dscp >= PIPELINE_FA_N_DSCP) ||
- (req->traffic_class >= PIPELINE_FA_N_TC_MAX) ||
- (req->color >= e_RTE_METER_COLORS)) {
- rsp->status = -1;
- return rsp;
- }
-
- p_fa->dscp[req->dscp].traffic_class = req->traffic_class;
- p_fa->dscp[req->dscp].color = req->color;
- rsp->status = 0;
- return rsp;
-}
-
-void *
-pipeline_fa_msg_req_policer_stats_read_handler(__rte_unused struct pipeline *p,
- void *msg)
-{
- struct pipeline_fa_policer_stats_msg_req *req = msg;
- struct pipeline_fa_policer_stats_msg_rsp *rsp = msg;
-
- struct flow_table_entry *entry = req->entry_ptr;
- uint32_t policer_id = req->policer_id;
- int clear = req->clear;
-
- /* Check request */
- if ((req->entry_ptr == NULL) ||
- (req->policer_id >= PIPELINE_FA_N_TC_MAX)) {
- rsp->status = -1;
- return rsp;
- }
-
- memcpy(&rsp->stats,
- &entry->mp[policer_id].stats,
- sizeof(rsp->stats));
- if (clear)
- memset(&entry->mp[policer_id].stats,
- 0, sizeof(entry->mp[policer_id].stats));
- rsp->status = 0;
- return rsp;
-}
-
-struct pipeline_be_ops pipeline_flow_actions_be_ops = {
- .f_init = pipeline_fa_init,
- .f_free = pipeline_fa_free,
- .f_run = NULL,
- .f_timer = pipeline_fa_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h b/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h
deleted file mode 100644
index ef6cb263..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_actions_be.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FLOW_ACTIONS_BE_H__
-#define __INCLUDE_PIPELINE_FLOW_ACTIONS_BE_H__
-
-#include <rte_meter.h>
-
-#include "pipeline_common_be.h"
-
-#ifndef PIPELINE_FA_N_TC_MAX
-#define PIPELINE_FA_N_TC_MAX 4
-#endif
-
-#define PIPELINE_FA_N_DSCP 64
-
-struct pipeline_fa_params {
- uint32_t n_flows;
- uint32_t n_meters_per_flow;
- uint32_t flow_id_offset;
- uint32_t ip_hdr_offset;
- uint32_t color_offset;
- uint32_t dscp_enabled;
-};
-
-int
-pipeline_fa_parse_args(struct pipeline_fa_params *p,
- struct pipeline_params *params);
-
-struct pipeline_fa_policer_action {
- uint32_t drop;
- enum rte_meter_color color;
-};
-
-struct pipeline_fa_policer_params {
- struct pipeline_fa_policer_action action[e_RTE_METER_COLORS];
-};
-
-struct pipeline_fa_flow_params {
- struct rte_meter_trtcm_params m[PIPELINE_FA_N_TC_MAX];
- struct pipeline_fa_policer_params p[PIPELINE_FA_N_TC_MAX];
- uint32_t port_id;
-};
-
-int
-pipeline_fa_flow_params_set_default(struct pipeline_fa_flow_params *params);
-
-struct pipeline_fa_policer_stats {
- uint64_t n_pkts[e_RTE_METER_COLORS];
- uint64_t n_pkts_drop;
-};
-
-enum pipeline_fa_msg_req_type {
- PIPELINE_FA_MSG_REQ_FLOW_CONFIG = 0,
- PIPELINE_FA_MSG_REQ_FLOW_CONFIG_BULK,
- PIPELINE_FA_MSG_REQ_DSCP_CONFIG,
- PIPELINE_FA_MSG_REQ_POLICER_STATS_READ,
- PIPELINE_FA_MSG_REQS,
-};
-
-/*
- * MSG FLOW CONFIG
- */
-struct pipeline_fa_flow_config_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fa_msg_req_type subtype;
-
- void *entry_ptr;
- uint32_t flow_id;
-
- uint32_t meter_update_mask;
- uint32_t policer_update_mask;
- uint32_t port_update;
- struct pipeline_fa_flow_params params;
-};
-
-struct pipeline_fa_flow_config_msg_rsp {
- int status;
- void *entry_ptr;
-};
-
-/*
- * MSG FLOW CONFIG BULK
- */
-struct pipeline_fa_flow_config_bulk_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fa_msg_req_type subtype;
-
- void **entry_ptr;
- uint32_t *flow_id;
- uint32_t n_flows;
-
- uint32_t meter_update_mask;
- uint32_t policer_update_mask;
- uint32_t port_update;
- struct pipeline_fa_flow_params *params;
-};
-
-struct pipeline_fa_flow_config_bulk_msg_rsp {
- uint32_t n_flows;
-};
-
-/*
- * MSG DSCP CONFIG
- */
-struct pipeline_fa_dscp_config_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fa_msg_req_type subtype;
-
- uint32_t dscp;
- uint32_t traffic_class;
- enum rte_meter_color color;
-};
-
-struct pipeline_fa_dscp_config_msg_rsp {
- int status;
-};
-
-/*
- * MSG POLICER STATS READ
- */
-struct pipeline_fa_policer_stats_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fa_msg_req_type subtype;
-
- void *entry_ptr;
- uint32_t policer_id;
- int clear;
-};
-
-struct pipeline_fa_policer_stats_msg_rsp {
- int status;
- struct pipeline_fa_policer_stats stats;
-};
-
-extern struct pipeline_be_ops pipeline_flow_actions_be_ops;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
deleted file mode 100644
index d39e0fb1..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
+++ /dev/null
@@ -1,1878 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/queue.h>
-#include <netinet/in.h>
-#include <unistd.h>
-
-#include <rte_common.h>
-#include <rte_hexdump.h>
-#include <rte_malloc.h>
-#include <cmdline_rdline.h>
-#include <cmdline_parse.h>
-#include <cmdline_parse_num.h>
-#include <cmdline_parse_string.h>
-
-#include "app.h"
-#include "pipeline_common_fe.h"
-#include "pipeline_flow_classification.h"
-#include "hash_func.h"
-#include "parser.h"
-
-/*
- * Key conversion
- */
-
-struct pkt_key_qinq {
- uint16_t ethertype_svlan;
- uint16_t svlan;
- uint16_t ethertype_cvlan;
- uint16_t cvlan;
-} __attribute__((__packed__));
-
-struct pkt_key_ipv4_5tuple {
- uint8_t ttl;
- uint8_t proto;
- uint16_t checksum;
- uint32_t ip_src;
- uint32_t ip_dst;
- uint16_t port_src;
- uint16_t port_dst;
-} __attribute__((__packed__));
-
-struct pkt_key_ipv6_5tuple {
- uint16_t payload_length;
- uint8_t proto;
- uint8_t hop_limit;
- uint8_t ip_src[16];
- uint8_t ip_dst[16];
- uint16_t port_src;
- uint16_t port_dst;
-} __attribute__((__packed__));
-
-static int
-app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
- uint8_t *key_out,
- uint32_t *signature)
-{
- uint8_t buffer[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
- uint8_t m[PIPELINE_FC_FLOW_KEY_MAX_SIZE]; /* key mask */
- void *key_buffer = (key_out) ? key_out : buffer;
-
- memset(m, 0xFF, sizeof(m));
- switch (key_in->type) {
- case FLOW_KEY_QINQ:
- {
- struct pkt_key_qinq *qinq = key_buffer;
-
- qinq->ethertype_svlan = 0;
- qinq->svlan = rte_cpu_to_be_16(key_in->key.qinq.svlan);
- qinq->ethertype_cvlan = 0;
- qinq->cvlan = rte_cpu_to_be_16(key_in->key.qinq.cvlan);
-
- if (signature)
- *signature = (uint32_t) hash_default_key8(qinq, m, 8, 0);
- return 0;
- }
-
- case FLOW_KEY_IPV4_5TUPLE:
- {
- struct pkt_key_ipv4_5tuple *ipv4 = key_buffer;
-
- ipv4->ttl = 0;
- ipv4->proto = key_in->key.ipv4_5tuple.proto;
- ipv4->checksum = 0;
- ipv4->ip_src = rte_cpu_to_be_32(key_in->key.ipv4_5tuple.ip_src);
- ipv4->ip_dst = rte_cpu_to_be_32(key_in->key.ipv4_5tuple.ip_dst);
- ipv4->port_src = rte_cpu_to_be_16(key_in->key.ipv4_5tuple.port_src);
- ipv4->port_dst = rte_cpu_to_be_16(key_in->key.ipv4_5tuple.port_dst);
-
- if (signature)
- *signature = (uint32_t) hash_default_key16(ipv4, m, 16, 0);
- return 0;
- }
-
- case FLOW_KEY_IPV6_5TUPLE:
- {
- struct pkt_key_ipv6_5tuple *ipv6 = key_buffer;
-
- memset(ipv6, 0, 64);
- ipv6->payload_length = 0;
- ipv6->proto = key_in->key.ipv6_5tuple.proto;
- ipv6->hop_limit = 0;
- memcpy(&ipv6->ip_src, &key_in->key.ipv6_5tuple.ip_src, 16);
- memcpy(&ipv6->ip_dst, &key_in->key.ipv6_5tuple.ip_dst, 16);
- ipv6->port_src = rte_cpu_to_be_16(key_in->key.ipv6_5tuple.port_src);
- ipv6->port_dst = rte_cpu_to_be_16(key_in->key.ipv6_5tuple.port_dst);
-
- if (signature)
- *signature = (uint32_t) hash_default_key64(ipv6, m, 64, 0);
- return 0;
- }
-
- default:
- return -1;
- }
-}
-
-/*
- * Flow classification pipeline
- */
-
-struct app_pipeline_fc_flow {
- struct pipeline_fc_key key;
- uint32_t port_id;
- uint32_t flow_id;
- uint32_t signature;
- void *entry_ptr;
-
- TAILQ_ENTRY(app_pipeline_fc_flow) node;
-};
-
-#define N_BUCKETS 65536
-
-struct app_pipeline_fc {
- /* Parameters */
- uint32_t n_ports_in;
- uint32_t n_ports_out;
-
- /* Flows */
- TAILQ_HEAD(, app_pipeline_fc_flow) flows[N_BUCKETS];
- uint32_t n_flows;
-
- /* Default flow */
- uint32_t default_flow_present;
- uint32_t default_flow_port_id;
- void *default_flow_entry_ptr;
-};
-
-static struct app_pipeline_fc_flow *
-app_pipeline_fc_flow_find(struct app_pipeline_fc *p,
- struct pipeline_fc_key *key)
-{
- struct app_pipeline_fc_flow *f;
- uint32_t signature, bucket_id;
-
- app_pipeline_fc_key_convert(key, NULL, &signature);
- bucket_id = signature & (N_BUCKETS - 1);
-
- TAILQ_FOREACH(f, &p->flows[bucket_id], node)
- if ((signature == f->signature) &&
- (memcmp(key,
- &f->key,
- sizeof(struct pipeline_fc_key)) == 0))
- return f;
-
- return NULL;
-}
-
-static void*
-app_pipeline_fc_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct app_pipeline_fc *p;
- uint32_t size, i;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct app_pipeline_fc));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
-
- /* Initialization */
- p->n_ports_in = params->n_ports_in;
- p->n_ports_out = params->n_ports_out;
-
- for (i = 0; i < N_BUCKETS; i++)
- TAILQ_INIT(&p->flows[i]);
- p->n_flows = 0;
-
- return (void *) p;
-}
-
-static int
-app_pipeline_fc_free(void *pipeline)
-{
- struct app_pipeline_fc *p = pipeline;
- uint32_t i;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- for (i = 0; i < N_BUCKETS; i++)
- while (!TAILQ_EMPTY(&p->flows[i])) {
- struct app_pipeline_fc_flow *flow;
-
- flow = TAILQ_FIRST(&p->flows[i]);
- TAILQ_REMOVE(&p->flows[i], flow, node);
- rte_free(flow);
- }
-
- rte_free(p);
- return 0;
-}
-
-static int
-app_pipeline_fc_key_check(struct pipeline_fc_key *key)
-{
- switch (key->type) {
- case FLOW_KEY_QINQ:
- {
- uint16_t svlan = key->key.qinq.svlan;
- uint16_t cvlan = key->key.qinq.cvlan;
-
- if ((svlan & 0xF000) ||
- (cvlan & 0xF000))
- return -1;
-
- return 0;
- }
-
- case FLOW_KEY_IPV4_5TUPLE:
- return 0;
-
- case FLOW_KEY_IPV6_5TUPLE:
- return 0;
-
- default:
- return -1;
- }
-}
-
-int
-app_pipeline_fc_load_file_qinq(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line)
-{
- FILE *f = NULL;
- char file_buf[1024];
- uint32_t i, l;
-
- /* Check input arguments */
- if ((filename == NULL) ||
- (keys == NULL) ||
- (port_ids == NULL) ||
- (flow_ids == NULL) ||
- (n_keys == NULL) ||
- (*n_keys == 0) ||
- (line == NULL)) {
- if (line)
- *line = 0;
- return -1;
- }
-
- /* Open input file */
- f = fopen(filename, "r");
- if (f == NULL) {
- *line = 0;
- return -1;
- }
-
- /* Read file */
- for (i = 0, l = 1; i < *n_keys; l++) {
- char *tokens[32];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- uint16_t svlan, cvlan;
- uint32_t portid, flowid;
- int status;
-
- if (fgets(file_buf, sizeof(file_buf), f) == NULL)
- break;
-
- status = parse_tokenize_string(file_buf, tokens, &n_tokens);
- if (status)
- goto error1;
-
- if ((n_tokens == 0) || (tokens[0][0] == '#'))
- continue;
-
- if ((n_tokens != 7) ||
- strcmp(tokens[0], "qinq") ||
- parser_read_uint16(&svlan, tokens[1]) ||
- parser_read_uint16(&cvlan, tokens[2]) ||
- strcmp(tokens[3], "port") ||
- parser_read_uint32(&portid, tokens[4]) ||
- strcmp(tokens[5], "id") ||
- parser_read_uint32(&flowid, tokens[6]))
- goto error1;
-
- keys[i].type = FLOW_KEY_QINQ;
- keys[i].key.qinq.svlan = svlan;
- keys[i].key.qinq.cvlan = cvlan;
-
- port_ids[i] = portid;
- flow_ids[i] = flowid;
-
- if (app_pipeline_fc_key_check(&keys[i]))
- goto error1;
-
- i++;
- }
-
- /* Close file */
- *n_keys = i;
- fclose(f);
- return 0;
-
-error1:
- *line = l;
- fclose(f);
- return -1;
-}
-
-int
-app_pipeline_fc_load_file_ipv4(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line)
-{
- FILE *f = NULL;
- char file_buf[1024];
- uint32_t i, l;
-
- /* Check input arguments */
- if ((filename == NULL) ||
- (keys == NULL) ||
- (port_ids == NULL) ||
- (flow_ids == NULL) ||
- (n_keys == NULL) ||
- (*n_keys == 0) ||
- (line == NULL)) {
- if (line)
- *line = 0;
- return -1;
- }
-
- /* Open input file */
- f = fopen(filename, "r");
- if (f == NULL) {
- *line = 0;
- return -1;
- }
-
- /* Read file */
- for (i = 0, l = 1; i < *n_keys; l++) {
- char *tokens[32];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- struct in_addr sipaddr, dipaddr;
- uint16_t sport, dport;
- uint8_t proto;
- uint32_t portid, flowid;
- int status;
-
- if (fgets(file_buf, sizeof(file_buf), f) == NULL)
- break;
-
- status = parse_tokenize_string(file_buf, tokens, &n_tokens);
- if (status)
- goto error2;
-
- if ((n_tokens == 0) || (tokens[0][0] == '#'))
- continue;
-
- if ((n_tokens != 10) ||
- strcmp(tokens[0], "ipv4") ||
- parse_ipv4_addr(tokens[1], &sipaddr) ||
- parse_ipv4_addr(tokens[2], &dipaddr) ||
- parser_read_uint16(&sport, tokens[3]) ||
- parser_read_uint16(&dport, tokens[4]) ||
- parser_read_uint8(&proto, tokens[5]) ||
- strcmp(tokens[6], "port") ||
- parser_read_uint32(&portid, tokens[7]) ||
- strcmp(tokens[8], "id") ||
- parser_read_uint32(&flowid, tokens[9]))
- goto error2;
-
- keys[i].type = FLOW_KEY_IPV4_5TUPLE;
- keys[i].key.ipv4_5tuple.ip_src = rte_be_to_cpu_32(sipaddr.s_addr);
- keys[i].key.ipv4_5tuple.ip_dst = rte_be_to_cpu_32(dipaddr.s_addr);
- keys[i].key.ipv4_5tuple.port_src = sport;
- keys[i].key.ipv4_5tuple.port_dst = dport;
- keys[i].key.ipv4_5tuple.proto = proto;
-
- port_ids[i] = portid;
- flow_ids[i] = flowid;
-
- if (app_pipeline_fc_key_check(&keys[i]))
- goto error2;
-
- i++;
- }
-
- /* Close file */
- *n_keys = i;
- fclose(f);
- return 0;
-
-error2:
- *line = l;
- fclose(f);
- return -1;
-}
-
-int
-app_pipeline_fc_load_file_ipv6(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line)
-{
- FILE *f = NULL;
- char file_buf[1024];
- uint32_t i, l;
-
- /* Check input arguments */
- if ((filename == NULL) ||
- (keys == NULL) ||
- (port_ids == NULL) ||
- (flow_ids == NULL) ||
- (n_keys == NULL) ||
- (*n_keys == 0) ||
- (line == NULL)) {
- if (line)
- *line = 0;
- return -1;
- }
-
- /* Open input file */
- f = fopen(filename, "r");
- if (f == NULL) {
- *line = 0;
- return -1;
- }
-
- /* Read file */
- for (i = 0, l = 1; i < *n_keys; l++) {
- char *tokens[32];
- uint32_t n_tokens = RTE_DIM(tokens);
-
- struct in6_addr sipaddr, dipaddr;
- uint16_t sport, dport;
- uint8_t proto;
- uint32_t portid, flowid;
- int status;
-
- if (fgets(file_buf, sizeof(file_buf), f) == NULL)
- break;
-
- status = parse_tokenize_string(file_buf, tokens, &n_tokens);
- if (status)
- goto error3;
-
- if ((n_tokens == 0) || (tokens[0][0] == '#'))
- continue;
-
- if ((n_tokens != 10) ||
- strcmp(tokens[0], "ipv6") ||
- parse_ipv6_addr(tokens[1], &sipaddr) ||
- parse_ipv6_addr(tokens[2], &dipaddr) ||
- parser_read_uint16(&sport, tokens[3]) ||
- parser_read_uint16(&dport, tokens[4]) ||
- parser_read_uint8(&proto, tokens[5]) ||
- strcmp(tokens[6], "port") ||
- parser_read_uint32(&portid, tokens[7]) ||
- strcmp(tokens[8], "id") ||
- parser_read_uint32(&flowid, tokens[9]))
- goto error3;
-
- keys[i].type = FLOW_KEY_IPV6_5TUPLE;
- memcpy(keys[i].key.ipv6_5tuple.ip_src,
- sipaddr.s6_addr,
- sizeof(sipaddr.s6_addr));
- memcpy(keys[i].key.ipv6_5tuple.ip_dst,
- dipaddr.s6_addr,
- sizeof(dipaddr.s6_addr));
- keys[i].key.ipv6_5tuple.port_src = sport;
- keys[i].key.ipv6_5tuple.port_dst = dport;
- keys[i].key.ipv6_5tuple.proto = proto;
-
- port_ids[i] = portid;
- flow_ids[i] = flowid;
-
- if (app_pipeline_fc_key_check(&keys[i]))
- goto error3;
-
- i++;
- }
-
- /* Close file */
- *n_keys = i;
- fclose(f);
- return 0;
-
-error3:
- *line = l;
- fclose(f);
- return -1;
-}
-
-
-
-int
-app_pipeline_fc_add(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key,
- uint32_t port_id,
- uint32_t flow_id)
-{
- struct app_pipeline_fc *p;
- struct app_pipeline_fc_flow *flow;
-
- struct pipeline_fc_add_msg_req *req;
- struct pipeline_fc_add_msg_rsp *rsp;
-
- uint32_t signature;
- int new_flow;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- if (app_pipeline_fc_key_check(key) != 0)
- return -1;
-
- /* Find existing flow or allocate new flow */
- flow = app_pipeline_fc_flow_find(p, key);
- new_flow = (flow == NULL);
- if (flow == NULL) {
- flow = rte_malloc(NULL, sizeof(*flow), RTE_CACHE_LINE_SIZE);
-
- if (flow == NULL)
- return -1;
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD;
- app_pipeline_fc_key_convert(key, req->key, &signature);
- req->port_id = port_id;
- req->flow_id = flow_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- if (new_flow)
- rte_free(flow);
- return -1;
- }
-
- /* Read response and write flow */
- if (rsp->status ||
- (rsp->entry_ptr == NULL) ||
- ((new_flow == 0) && (rsp->key_found == 0)) ||
- ((new_flow == 1) && (rsp->key_found == 1))) {
- app_msg_free(app, rsp);
- if (new_flow)
- rte_free(flow);
- return -1;
- }
-
- memset(&flow->key, 0, sizeof(flow->key));
- memcpy(&flow->key, key, sizeof(flow->key));
- flow->port_id = port_id;
- flow->flow_id = flow_id;
- flow->signature = signature;
- flow->entry_ptr = rsp->entry_ptr;
-
- /* Commit rule */
- if (new_flow) {
- uint32_t bucket_id = signature & (N_BUCKETS - 1);
-
- TAILQ_INSERT_TAIL(&p->flows[bucket_id], flow, node);
- p->n_flows++;
- }
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_fc_add_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key,
- uint32_t *port_id,
- uint32_t *flow_id,
- uint32_t n_keys)
-{
- struct app_pipeline_fc *p;
- struct pipeline_fc_add_bulk_msg_req *req;
- struct pipeline_fc_add_bulk_msg_rsp *rsp;
-
- struct app_pipeline_fc_flow **flow;
- uint32_t *signature;
- int *new_flow;
- struct pipeline_fc_add_bulk_flow_req *flow_req;
- struct pipeline_fc_add_bulk_flow_rsp *flow_rsp;
-
- uint32_t i;
- int status;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL) ||
- (port_id == NULL) ||
- (flow_id == NULL) ||
- (n_keys == 0))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -1;
-
- for (i = 0; i < n_keys; i++)
- if (port_id[i] >= p->n_ports_out)
- return -1;
-
- for (i = 0; i < n_keys; i++)
- if (app_pipeline_fc_key_check(&key[i]) != 0)
- return -1;
-
- /* Memory allocation */
- flow = rte_malloc(NULL,
- n_keys * sizeof(struct app_pipeline_fc_flow *),
- RTE_CACHE_LINE_SIZE);
- if (flow == NULL)
- return -1;
-
- signature = rte_malloc(NULL,
- n_keys * sizeof(uint32_t),
- RTE_CACHE_LINE_SIZE);
- if (signature == NULL) {
- rte_free(flow);
- return -1;
- }
-
- new_flow = rte_malloc(
- NULL,
- n_keys * sizeof(int),
- RTE_CACHE_LINE_SIZE);
- if (new_flow == NULL) {
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
-
- flow_req = rte_malloc(NULL,
- n_keys * sizeof(struct pipeline_fc_add_bulk_flow_req),
- RTE_CACHE_LINE_SIZE);
- if (flow_req == NULL) {
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
-
- flow_rsp = rte_malloc(NULL,
- n_keys * sizeof(struct pipeline_fc_add_bulk_flow_rsp),
- RTE_CACHE_LINE_SIZE);
- if (flow_rsp == NULL) {
- rte_free(flow_req);
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
-
- /* Find existing flow or allocate new flow */
- for (i = 0; i < n_keys; i++) {
- flow[i] = app_pipeline_fc_flow_find(p, &key[i]);
- new_flow[i] = (flow[i] == NULL);
- if (flow[i] == NULL) {
- flow[i] = rte_zmalloc(NULL,
- sizeof(struct app_pipeline_fc_flow),
- RTE_CACHE_LINE_SIZE);
-
- if (flow[i] == NULL) {
- uint32_t j;
-
- for (j = 0; j < i; j++)
- if (new_flow[j])
- rte_free(flow[j]);
-
- rte_free(flow_rsp);
- rte_free(flow_req);
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
- }
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL) {
- for (i = 0; i < n_keys; i++)
- if (new_flow[i])
- rte_free(flow[i]);
-
- rte_free(flow_rsp);
- rte_free(flow_req);
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
-
- for (i = 0; i < n_keys; i++) {
- app_pipeline_fc_key_convert(&key[i],
- flow_req[i].key,
- &signature[i]);
- flow_req[i].port_id = port_id[i];
- flow_req[i].flow_id = flow_id[i];
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD_BULK;
- req->req = flow_req;
- req->rsp = flow_rsp;
- req->n_keys = n_keys;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, 10000);
- if (rsp == NULL) {
- for (i = 0; i < n_keys; i++)
- if (new_flow[i])
- rte_free(flow[i]);
-
- rte_free(flow_rsp);
- rte_free(flow_req);
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
- return -1;
- }
-
- /* Read response */
- status = 0;
-
- for (i = 0; i < rsp->n_keys; i++)
- if ((flow_rsp[i].entry_ptr == NULL) ||
- ((new_flow[i] == 0) && (flow_rsp[i].key_found == 0)) ||
- ((new_flow[i] == 1) && (flow_rsp[i].key_found == 1)))
- status = -1;
-
- if (rsp->n_keys < n_keys)
- status = -1;
-
- /* Commit flows */
- for (i = 0; i < rsp->n_keys; i++) {
- memcpy(&flow[i]->key, &key[i], sizeof(flow[i]->key));
- flow[i]->port_id = port_id[i];
- flow[i]->flow_id = flow_id[i];
- flow[i]->signature = signature[i];
- flow[i]->entry_ptr = flow_rsp[i].entry_ptr;
-
- if (new_flow[i]) {
- uint32_t bucket_id = signature[i] & (N_BUCKETS - 1);
-
- TAILQ_INSERT_TAIL(&p->flows[bucket_id], flow[i], node);
- p->n_flows++;
- }
- }
-
- /* Free resources */
-
- for (i = rsp->n_keys; i < n_keys; i++)
- if (new_flow[i])
- rte_free(flow[i]);
-
- app_msg_free(app, rsp);
- rte_free(flow_rsp);
- rte_free(flow_req);
- rte_free(new_flow);
- rte_free(signature);
- rte_free(flow);
-
- return status;
-}
-
-int
-app_pipeline_fc_del(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key)
-{
- struct app_pipeline_fc *p;
- struct app_pipeline_fc_flow *flow;
-
- struct pipeline_fc_del_msg_req *req;
- struct pipeline_fc_del_msg_rsp *rsp;
-
- uint32_t signature, bucket_id;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -1;
-
- if (app_pipeline_fc_key_check(key) != 0)
- return -1;
-
- /* Find rule */
- flow = app_pipeline_fc_flow_find(p, key);
- if (flow == NULL)
- return 0;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FC_MSG_REQ_FLOW_DEL;
- app_pipeline_fc_key_convert(key, req->key, &signature);
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status || !rsp->key_found) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Remove rule */
- bucket_id = signature & (N_BUCKETS - 1);
- TAILQ_REMOVE(&p->flows[bucket_id], flow, node);
- p->n_flows--;
- rte_free(flow);
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_fc_add_default(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct app_pipeline_fc *p;
-
- struct pipeline_fc_add_default_msg_req *req;
- struct pipeline_fc_add_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FC_MSG_REQ_FLOW_ADD_DEFAULT;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write flow */
- if (rsp->status || (rsp->entry_ptr == NULL)) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- p->default_flow_port_id = port_id;
- p->default_flow_entry_ptr = rsp->entry_ptr;
-
- /* Commit route */
- p->default_flow_present = 1;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_fc_del_default(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_fc *p;
-
- struct pipeline_fc_del_default_msg_req *req;
- struct pipeline_fc_del_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -EINVAL;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_FC_MSG_REQ_FLOW_DEL_DEFAULT;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Commit route */
- p->default_flow_present = 0;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-/*
- * Flow ls
- */
-
-static void
-print_fc_qinq_flow(struct app_pipeline_fc_flow *flow)
-{
- printf("(SVLAN = %" PRIu32 ", "
- "CVLAN = %" PRIu32 ") => "
- "Port = %" PRIu32 ", "
- "Flow ID = %" PRIu32 ", "
- "(signature = 0x%08" PRIx32 ", "
- "entry_ptr = %p)\n",
-
- flow->key.key.qinq.svlan,
- flow->key.key.qinq.cvlan,
- flow->port_id,
- flow->flow_id,
- flow->signature,
- flow->entry_ptr);
-}
-
-static void
-print_fc_ipv4_5tuple_flow(struct app_pipeline_fc_flow *flow)
-{
- printf("(SA = %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ", "
- "DA = %" PRIu32 ".%" PRIu32 ".%" PRIu32 ".%" PRIu32 ", "
- "SP = %" PRIu32 ", "
- "DP = %" PRIu32 ", "
- "Proto = %" PRIu32 ") => "
- "Port = %" PRIu32 ", "
- "Flow ID = %" PRIu32 " "
- "(signature = 0x%08" PRIx32 ", "
- "entry_ptr = %p)\n",
-
- (flow->key.key.ipv4_5tuple.ip_src >> 24) & 0xFF,
- (flow->key.key.ipv4_5tuple.ip_src >> 16) & 0xFF,
- (flow->key.key.ipv4_5tuple.ip_src >> 8) & 0xFF,
- flow->key.key.ipv4_5tuple.ip_src & 0xFF,
-
- (flow->key.key.ipv4_5tuple.ip_dst >> 24) & 0xFF,
- (flow->key.key.ipv4_5tuple.ip_dst >> 16) & 0xFF,
- (flow->key.key.ipv4_5tuple.ip_dst >> 8) & 0xFF,
- flow->key.key.ipv4_5tuple.ip_dst & 0xFF,
-
- flow->key.key.ipv4_5tuple.port_src,
- flow->key.key.ipv4_5tuple.port_dst,
-
- flow->key.key.ipv4_5tuple.proto,
-
- flow->port_id,
- flow->flow_id,
- flow->signature,
- flow->entry_ptr);
-}
-
-static void
-print_fc_ipv6_5tuple_flow(struct app_pipeline_fc_flow *flow) {
- printf("(SA = %02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32 ", "
- "DA = %02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32
- ":%02" PRIx32 "%02" PRIx32 ":%02" PRIx32 "%02" PRIx32 ", "
- "SP = %" PRIu32 ", "
- "DP = %" PRIu32 " "
- "Proto = %" PRIu32 " "
- "=> Port = %" PRIu32 ", "
- "Flow ID = %" PRIu32 " "
- "(signature = 0x%08" PRIx32 ", "
- "entry_ptr = %p)\n",
-
- flow->key.key.ipv6_5tuple.ip_src[0],
- flow->key.key.ipv6_5tuple.ip_src[1],
- flow->key.key.ipv6_5tuple.ip_src[2],
- flow->key.key.ipv6_5tuple.ip_src[3],
- flow->key.key.ipv6_5tuple.ip_src[4],
- flow->key.key.ipv6_5tuple.ip_src[5],
- flow->key.key.ipv6_5tuple.ip_src[6],
- flow->key.key.ipv6_5tuple.ip_src[7],
- flow->key.key.ipv6_5tuple.ip_src[8],
- flow->key.key.ipv6_5tuple.ip_src[9],
- flow->key.key.ipv6_5tuple.ip_src[10],
- flow->key.key.ipv6_5tuple.ip_src[11],
- flow->key.key.ipv6_5tuple.ip_src[12],
- flow->key.key.ipv6_5tuple.ip_src[13],
- flow->key.key.ipv6_5tuple.ip_src[14],
- flow->key.key.ipv6_5tuple.ip_src[15],
-
- flow->key.key.ipv6_5tuple.ip_dst[0],
- flow->key.key.ipv6_5tuple.ip_dst[1],
- flow->key.key.ipv6_5tuple.ip_dst[2],
- flow->key.key.ipv6_5tuple.ip_dst[3],
- flow->key.key.ipv6_5tuple.ip_dst[4],
- flow->key.key.ipv6_5tuple.ip_dst[5],
- flow->key.key.ipv6_5tuple.ip_dst[6],
- flow->key.key.ipv6_5tuple.ip_dst[7],
- flow->key.key.ipv6_5tuple.ip_dst[8],
- flow->key.key.ipv6_5tuple.ip_dst[9],
- flow->key.key.ipv6_5tuple.ip_dst[10],
- flow->key.key.ipv6_5tuple.ip_dst[11],
- flow->key.key.ipv6_5tuple.ip_dst[12],
- flow->key.key.ipv6_5tuple.ip_dst[13],
- flow->key.key.ipv6_5tuple.ip_dst[14],
- flow->key.key.ipv6_5tuple.ip_dst[15],
-
- flow->key.key.ipv6_5tuple.port_src,
- flow->key.key.ipv6_5tuple.port_dst,
-
- flow->key.key.ipv6_5tuple.proto,
-
- flow->port_id,
- flow->flow_id,
- flow->signature,
- flow->entry_ptr);
-}
-
-static void
-print_fc_flow(struct app_pipeline_fc_flow *flow)
-{
- switch (flow->key.type) {
- case FLOW_KEY_QINQ:
- print_fc_qinq_flow(flow);
- break;
-
- case FLOW_KEY_IPV4_5TUPLE:
- print_fc_ipv4_5tuple_flow(flow);
- break;
-
- case FLOW_KEY_IPV6_5TUPLE:
- print_fc_ipv6_5tuple_flow(flow);
- break;
- }
-}
-
-static int
-app_pipeline_fc_ls(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_fc *p;
- struct app_pipeline_fc_flow *flow;
- uint32_t i;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_flow_classification);
- if (p == NULL)
- return -1;
-
- for (i = 0; i < N_BUCKETS; i++)
- TAILQ_FOREACH(flow, &p->flows[i], node)
- print_fc_flow(flow);
-
- if (p->default_flow_present)
- printf("Default flow: port %" PRIu32 " (entry ptr = %p)\n",
- p->default_flow_port_id,
- p->default_flow_entry_ptr);
- else
- printf("Default: DROP\n");
-
- return 0;
-}
-/*
- * flow
- *
- * flow add:
- * p <pipelineid> flow add qinq <svlan> <cvlan> port <portid> id <flowid>
- * p <pipelineid> flow add qinq bulk <file>
- * p <pipelineid> flow add ipv4 <sipaddr> <dipaddr> <sport> <dport> <proto> port <port ID> id <flowid>
- * p <pipelineid> flow add ipv4 bulk <file>
- * p <pipelineid> flow add ipv6 <sipaddr> <dipaddr> <sport> <dport> <proto> port <port ID> id <flowid>
- * p <pipelineid> flow add ipv6 bulk <file>
- *
- * flow add default:
- * p <pipelineid> flow add default <portid>
- *
- * flow del:
- * p <pipelineid> flow del qinq <svlan> <cvlan>
- * p <pipelineid> flow del ipv4 <sipaddr> <dipaddr> <sport> <dport> <proto>
- * p <pipelineid> flow del ipv6 <sipaddr> <dipaddr> <sport> <dport> <proto>
- *
- * flow del default:
- * p <pipelineid> flow del default
- *
- * flow ls:
- * p <pipelineid> flow ls
- */
-
-struct cmd_flow_result {
- cmdline_fixed_string_t p_string;
- uint32_t pipeline_id;
- cmdline_fixed_string_t flow_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_flow_parsed(void *parsed_result,
- __attribute__((unused)) struct cmdline *cl,
- void *data)
-{
- struct cmd_flow_result *results = parsed_result;
- struct app_params *app = data;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- status = parse_tokenize_string(results->multi_string, tokens, &n_tokens);
- if (status) {
- printf(CMD_MSG_TOO_MANY_ARGS, "flow");
- return;
- }
-
- /* flow add qinq */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "qinq") == 0) &&
- strcmp(tokens[2], "bulk")) {
- struct pipeline_fc_key key;
- uint32_t svlan;
- uint32_t cvlan;
- uint32_t port_id;
- uint32_t flow_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 8) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add qinq");
- return;
- }
-
- if (parser_read_uint32(&svlan, tokens[2]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "svlan");
- return;
- }
-
- if (parser_read_uint32(&cvlan, tokens[3]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "cvlan");
- return;
- }
-
- if (strcmp(tokens[4], "port") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "port");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[5]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (strcmp(tokens[6], "id") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "id");
- return;
- }
-
- if (parser_read_uint32(&flow_id, tokens[7]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- key.type = FLOW_KEY_QINQ;
- key.key.qinq.svlan = svlan;
- key.key.qinq.cvlan = cvlan;
-
- status = app_pipeline_fc_add(app,
- results->pipeline_id,
- &key,
- port_id,
- flow_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow add qinq");
-
- return;
- } /* flow add qinq */
-
- /* flow add ipv4 */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "ipv4") == 0) &&
- strcmp(tokens[2], "bulk")) {
- struct pipeline_fc_key key;
- struct in_addr sipaddr;
- struct in_addr dipaddr;
- uint32_t sport;
- uint32_t dport;
- uint32_t proto;
- uint32_t port_id;
- uint32_t flow_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 11) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv4");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &sipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sipv4addr");
- return;
- }
- if (parse_ipv4_addr(tokens[3], &dipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dipv4addr");
- return;
- }
-
- if (parser_read_uint32(&sport, tokens[4]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sport");
- return;
- }
-
- if (parser_read_uint32(&dport, tokens[5]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dport");
- return;
- }
-
- if (parser_read_uint32(&proto, tokens[6]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- if (strcmp(tokens[7], "port") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "port");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[8]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (strcmp(tokens[9], "id") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "id");
- return;
- }
-
- if (parser_read_uint32(&flow_id, tokens[10]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- key.type = FLOW_KEY_IPV4_5TUPLE;
- key.key.ipv4_5tuple.ip_src = rte_be_to_cpu_32(sipaddr.s_addr);
- key.key.ipv4_5tuple.ip_dst = rte_be_to_cpu_32(dipaddr.s_addr);
- key.key.ipv4_5tuple.port_src = sport;
- key.key.ipv4_5tuple.port_dst = dport;
- key.key.ipv4_5tuple.proto = proto;
-
- status = app_pipeline_fc_add(app,
- results->pipeline_id,
- &key,
- port_id,
- flow_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow add ipv4");
-
- return;
- } /* flow add ipv4 */
-
- /* flow add ipv6 */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "ipv6") == 0) &&
- strcmp(tokens[2], "bulk")) {
- struct pipeline_fc_key key;
- struct in6_addr sipaddr;
- struct in6_addr dipaddr;
- uint32_t sport;
- uint32_t dport;
- uint32_t proto;
- uint32_t port_id;
- uint32_t flow_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 11) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv6");
- return;
- }
-
- if (parse_ipv6_addr(tokens[2], &sipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sipv6addr");
- return;
- }
- if (parse_ipv6_addr(tokens[3], &dipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dipv6addr");
- return;
- }
-
- if (parser_read_uint32(&sport, tokens[4]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sport");
- return;
- }
-
- if (parser_read_uint32(&dport, tokens[5]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dport");
- return;
- }
-
- if (parser_read_uint32(&proto, tokens[6]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- if (strcmp(tokens[7], "port") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "port");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[8]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (strcmp(tokens[9], "id") != 0) {
- printf(CMD_MSG_ARG_NOT_FOUND, "id");
- return;
- }
-
- if (parser_read_uint32(&flow_id, tokens[10]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "flowid");
- return;
- }
-
- key.type = FLOW_KEY_IPV6_5TUPLE;
- memcpy(key.key.ipv6_5tuple.ip_src, (void *)&sipaddr, 16);
- memcpy(key.key.ipv6_5tuple.ip_dst, (void *)&dipaddr, 16);
- key.key.ipv6_5tuple.port_src = sport;
- key.key.ipv6_5tuple.port_dst = dport;
- key.key.ipv6_5tuple.proto = proto;
-
- status = app_pipeline_fc_add(app,
- results->pipeline_id,
- &key,
- port_id,
- flow_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow add ipv6");
-
- return;
- } /* flow add ipv6 */
-
- /* flow add qinq bulk */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "qinq") == 0) &&
- (strcmp(tokens[2], "bulk") == 0)) {
- struct pipeline_fc_key *keys;
- uint32_t *port_ids, *flow_ids, n_keys, line;
- char *filename;
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add qinq bulk");
- return;
- }
-
- filename = tokens[3];
-
- n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
- keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
- if (keys == NULL)
- return;
- memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
-
- port_ids = malloc(n_keys * sizeof(uint32_t));
- if (port_ids == NULL) {
- free(keys);
- return;
- }
-
- flow_ids = malloc(n_keys * sizeof(uint32_t));
- if (flow_ids == NULL) {
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_load_file_qinq(filename,
- keys,
- port_ids,
- flow_ids,
- &n_keys,
- &line);
- if (status != 0) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_add_bulk(app,
- results->pipeline_id,
- keys,
- port_ids,
- flow_ids,
- n_keys);
- if (status)
- printf(CMD_MSG_FAIL, "flow add qinq bulk");
-
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- } /* flow add qinq bulk */
-
- /* flow add ipv4 bulk */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "ipv4") == 0) &&
- (strcmp(tokens[2], "bulk") == 0)) {
- struct pipeline_fc_key *keys;
- uint32_t *port_ids, *flow_ids, n_keys, line;
- char *filename;
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv4 bulk");
- return;
- }
-
- filename = tokens[3];
-
- n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
- keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
- if (keys == NULL)
- return;
- memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
-
- port_ids = malloc(n_keys * sizeof(uint32_t));
- if (port_ids == NULL) {
- free(keys);
- return;
- }
-
- flow_ids = malloc(n_keys * sizeof(uint32_t));
- if (flow_ids == NULL) {
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_load_file_ipv4(filename,
- keys,
- port_ids,
- flow_ids,
- &n_keys,
- &line);
- if (status != 0) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_add_bulk(app,
- results->pipeline_id,
- keys,
- port_ids,
- flow_ids,
- n_keys);
- if (status)
- printf(CMD_MSG_FAIL, "flow add ipv4 bulk");
-
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- } /* flow add ipv4 bulk */
-
- /* flow add ipv6 bulk */
- if ((n_tokens >= 3) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "ipv6") == 0) &&
- (strcmp(tokens[2], "bulk") == 0)) {
- struct pipeline_fc_key *keys;
- uint32_t *port_ids, *flow_ids, n_keys, line;
- char *filename;
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add ipv6 bulk");
- return;
- }
-
- filename = tokens[3];
-
- n_keys = APP_PIPELINE_FC_MAX_FLOWS_IN_FILE;
- keys = malloc(n_keys * sizeof(struct pipeline_fc_key));
- if (keys == NULL)
- return;
- memset(keys, 0, n_keys * sizeof(struct pipeline_fc_key));
-
- port_ids = malloc(n_keys * sizeof(uint32_t));
- if (port_ids == NULL) {
- free(keys);
- return;
- }
-
- flow_ids = malloc(n_keys * sizeof(uint32_t));
- if (flow_ids == NULL) {
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_load_file_ipv6(filename,
- keys,
- port_ids,
- flow_ids,
- &n_keys,
- &line);
- if (status != 0) {
- printf(CMD_MSG_FILE_ERR, filename, line);
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- }
-
- status = app_pipeline_fc_add_bulk(app,
- results->pipeline_id,
- keys,
- port_ids,
- flow_ids,
- n_keys);
- if (status)
- printf(CMD_MSG_FAIL, "flow add ipv6 bulk");
-
- free(flow_ids);
- free(port_ids);
- free(keys);
- return;
- } /* flow add ipv6 bulk */
-
- /* flow add default*/
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- uint32_t port_id;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow add default");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[2]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- status = app_pipeline_fc_add_default(app,
- results->pipeline_id,
- port_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow add default");
-
- return;
- } /* flow add default */
-
- /* flow del qinq */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "qinq") == 0)) {
- struct pipeline_fc_key key;
- uint32_t svlan;
- uint32_t cvlan;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow del qinq");
- return;
- }
-
- if (parser_read_uint32(&svlan, tokens[2]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "svlan");
- return;
- }
-
- if (parser_read_uint32(&cvlan, tokens[3]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "cvlan");
- return;
- }
-
- key.type = FLOW_KEY_QINQ;
- key.key.qinq.svlan = svlan;
- key.key.qinq.cvlan = cvlan;
-
- status = app_pipeline_fc_del(app,
- results->pipeline_id,
- &key);
- if (status)
- printf(CMD_MSG_FAIL, "flow del qinq");
-
- return;
- } /* flow del qinq */
-
- /* flow del ipv4 */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "ipv4") == 0)) {
- struct pipeline_fc_key key;
- struct in_addr sipaddr;
- struct in_addr dipaddr;
- uint32_t sport;
- uint32_t dport;
- uint32_t proto;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 7) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow del ipv4");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &sipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sipv4addr");
- return;
- }
- if (parse_ipv4_addr(tokens[3], &dipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dipv4addr");
- return;
- }
-
- if (parser_read_uint32(&sport, tokens[4]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sport");
- return;
- }
-
- if (parser_read_uint32(&dport, tokens[5]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dport");
- return;
- }
-
- if (parser_read_uint32(&proto, tokens[6]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- key.type = FLOW_KEY_IPV4_5TUPLE;
- key.key.ipv4_5tuple.ip_src = rte_be_to_cpu_32(sipaddr.s_addr);
- key.key.ipv4_5tuple.ip_dst = rte_be_to_cpu_32(dipaddr.s_addr);
- key.key.ipv4_5tuple.port_src = sport;
- key.key.ipv4_5tuple.port_dst = dport;
- key.key.ipv4_5tuple.proto = proto;
-
- status = app_pipeline_fc_del(app,
- results->pipeline_id,
- &key);
- if (status)
- printf(CMD_MSG_FAIL, "flow del ipv4");
-
- return;
- } /* flow del ipv4 */
-
- /* flow del ipv6 */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "ipv6") == 0)) {
- struct pipeline_fc_key key;
- struct in6_addr sipaddr;
- struct in6_addr dipaddr;
- uint32_t sport;
- uint32_t dport;
- uint32_t proto;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 7) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow del ipv6");
- return;
- }
-
- if (parse_ipv6_addr(tokens[2], &sipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sipv6addr");
- return;
- }
-
- if (parse_ipv6_addr(tokens[3], &dipaddr) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dipv6addr");
- return;
- }
-
- if (parser_read_uint32(&sport, tokens[4]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "sport");
- return;
- }
-
- if (parser_read_uint32(&dport, tokens[5]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "dport");
- return;
- }
-
- if (parser_read_uint32(&proto, tokens[6]) != 0) {
- printf(CMD_MSG_INVALID_ARG, "proto");
- return;
- }
-
- key.type = FLOW_KEY_IPV6_5TUPLE;
- memcpy(key.key.ipv6_5tuple.ip_src, &sipaddr, 16);
- memcpy(key.key.ipv6_5tuple.ip_dst, &dipaddr, 16);
- key.key.ipv6_5tuple.port_src = sport;
- key.key.ipv6_5tuple.port_dst = dport;
- key.key.ipv6_5tuple.proto = proto;
-
- status = app_pipeline_fc_del(app,
- results->pipeline_id,
- &key);
- if (status)
- printf(CMD_MSG_FAIL, "flow del ipv6");
-
- return;
- } /* flow del ipv6 */
-
- /* flow del default*/
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow del default");
- return;
- }
-
- status = app_pipeline_fc_del_default(app,
- results->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow del default");
-
- return;
- } /* flow del default */
-
- /* flow ls */
- if ((n_tokens >= 1) && (strcmp(tokens[0], "ls") == 0)) {
- if (n_tokens != 1) {
- printf(CMD_MSG_MISMATCH_ARGS, "flow ls");
- return;
- }
-
- status = app_pipeline_fc_ls(app, results->pipeline_id);
- if (status)
- printf(CMD_MSG_FAIL, "flow ls");
-
- return;
- } /* flow ls */
-
- printf(CMD_MSG_MISMATCH_ARGS, "flow");
-}
-
-static cmdline_parse_token_string_t cmd_flow_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_flow_pipeline_id =
- TOKEN_NUM_INITIALIZER(struct cmd_flow_result, pipeline_id, UINT32);
-
-static cmdline_parse_token_string_t cmd_flow_flow_string =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_result, flow_string, "flow");
-
-static cmdline_parse_token_string_t cmd_flow_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_flow_result, multi_string,
- TOKEN_STRING_MULTI);
-
-static cmdline_parse_inst_t cmd_flow = {
- .f = cmd_flow_parsed,
- .data = NULL,
- .help_str = "flow add / add bulk / add default / del / del default / ls",
- .tokens = {
- (void *) &cmd_flow_p_string,
- (void *) &cmd_flow_pipeline_id,
- (void *) &cmd_flow_flow_string,
- (void *) &cmd_flow_multi_string,
- NULL,
- },
-};
-
-static cmdline_parse_ctx_t pipeline_cmds[] = {
- (cmdline_parse_inst_t *) &cmd_flow,
- NULL,
-};
-
-static struct pipeline_fe_ops pipeline_flow_classification_fe_ops = {
- .f_init = app_pipeline_fc_init,
- .f_post_init = NULL,
- .f_free = app_pipeline_fc_free,
- .f_track = app_pipeline_track_default,
- .cmds = pipeline_cmds,
-};
-
-struct pipeline_type pipeline_flow_classification = {
- .name = "FLOW_CLASSIFICATION",
- .be_ops = &pipeline_flow_classification_be_ops,
- .fe_ops = &pipeline_flow_classification_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.h b/examples/ip_pipeline/pipeline/pipeline_flow_classification.h
deleted file mode 100644
index 8c354989..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FLOW_CLASSIFICATION_H__
-#define __INCLUDE_PIPELINE_FLOW_CLASSIFICATION_H__
-
-#include "pipeline.h"
-#include "pipeline_flow_classification_be.h"
-
-enum flow_key_type {
- FLOW_KEY_QINQ,
- FLOW_KEY_IPV4_5TUPLE,
- FLOW_KEY_IPV6_5TUPLE,
-};
-
-struct flow_key_qinq {
- uint16_t svlan;
- uint16_t cvlan;
-};
-
-struct flow_key_ipv4_5tuple {
- uint32_t ip_src;
- uint32_t ip_dst;
- uint16_t port_src;
- uint16_t port_dst;
- uint32_t proto;
-};
-
-struct flow_key_ipv6_5tuple {
- uint8_t ip_src[16];
- uint8_t ip_dst[16];
- uint16_t port_src;
- uint16_t port_dst;
- uint32_t proto;
-};
-
-struct pipeline_fc_key {
- enum flow_key_type type;
- union {
- struct flow_key_qinq qinq;
- struct flow_key_ipv4_5tuple ipv4_5tuple;
- struct flow_key_ipv6_5tuple ipv6_5tuple;
- } key;
-};
-
-int
-app_pipeline_fc_add(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key,
- uint32_t port_id,
- uint32_t flow_id);
-
-int
-app_pipeline_fc_add_bulk(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key,
- uint32_t *port_id,
- uint32_t *flow_id,
- uint32_t n_keys);
-
-int
-app_pipeline_fc_del(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_fc_key *key);
-
-int
-app_pipeline_fc_add_default(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_pipeline_fc_del_default(struct app_params *app,
- uint32_t pipeline_id);
-
-#ifndef APP_PIPELINE_FC_MAX_FLOWS_IN_FILE
-#define APP_PIPELINE_FC_MAX_FLOWS_IN_FILE (16 * 1024 * 1024)
-#endif
-
-int
-app_pipeline_fc_load_file_qinq(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line);
-
-int
-app_pipeline_fc_load_file_ipv4(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line);
-
-int
-app_pipeline_fc_load_file_ipv6(char *filename,
- struct pipeline_fc_key *keys,
- uint32_t *port_ids,
- uint32_t *flow_ids,
- uint32_t *n_keys,
- uint32_t *line);
-
-extern struct pipeline_type pipeline_flow_classification;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
deleted file mode 100644
index 097ec346..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
+++ /dev/null
@@ -1,723 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <string.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <rte_table_hash.h>
-#include <rte_byteorder.h>
-#include <pipeline.h>
-
-#include "pipeline_flow_classification_be.h"
-#include "pipeline_actions_common.h"
-#include "parser.h"
-#include "hash_func.h"
-
-struct pipeline_flow_classification {
- struct pipeline p;
- pipeline_msg_req_handler custom_handlers[PIPELINE_FC_MSG_REQS];
-
- uint32_t n_flows;
- uint32_t key_size;
- uint32_t flow_id;
-
- uint32_t key_offset;
- uint32_t hash_offset;
- uint8_t key_mask[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
- uint32_t key_mask_present;
- uint32_t flow_id_offset;
-
-} __rte_cache_aligned;
-
-static void *
-pipeline_fc_msg_req_custom_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler handlers[] = {
- [PIPELINE_MSG_REQ_PING] =
- pipeline_msg_req_ping_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_IN] =
- pipeline_msg_req_stats_port_in_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
- pipeline_msg_req_stats_port_out_handler,
- [PIPELINE_MSG_REQ_STATS_TABLE] =
- pipeline_msg_req_stats_table_handler,
- [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
- pipeline_msg_req_port_in_enable_handler,
- [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
- pipeline_msg_req_port_in_disable_handler,
- [PIPELINE_MSG_REQ_CUSTOM] =
- pipeline_fc_msg_req_custom_handler,
-};
-
-static void *
-pipeline_fc_msg_req_add_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fc_msg_req_add_bulk_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fc_msg_req_del_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fc_msg_req_add_default_handler(struct pipeline *p, void *msg);
-
-static void *
-pipeline_fc_msg_req_del_default_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler custom_handlers[] = {
- [PIPELINE_FC_MSG_REQ_FLOW_ADD] =
- pipeline_fc_msg_req_add_handler,
- [PIPELINE_FC_MSG_REQ_FLOW_ADD_BULK] =
- pipeline_fc_msg_req_add_bulk_handler,
- [PIPELINE_FC_MSG_REQ_FLOW_DEL] =
- pipeline_fc_msg_req_del_handler,
- [PIPELINE_FC_MSG_REQ_FLOW_ADD_DEFAULT] =
- pipeline_fc_msg_req_add_default_handler,
- [PIPELINE_FC_MSG_REQ_FLOW_DEL_DEFAULT] =
- pipeline_fc_msg_req_del_default_handler,
-};
-
-/*
- * Flow table
- */
-struct flow_table_entry {
- struct rte_pipeline_table_entry head;
-
- uint32_t flow_id;
- uint32_t pad;
-};
-
-rte_table_hash_op_hash hash_func[] = {
- hash_default_key8,
- hash_default_key16,
- hash_default_key24,
- hash_default_key32,
- hash_default_key40,
- hash_default_key48,
- hash_default_key56,
- hash_default_key64
-};
-
-/*
- * Flow table AH - Write flow_id to packet meta-data
- */
-static inline void
-pkt_work_flow_id(
- struct rte_mbuf *pkt,
- struct rte_pipeline_table_entry *table_entry,
- void *arg)
-{
- struct pipeline_flow_classification *p_fc = arg;
- uint32_t *flow_id_ptr =
- RTE_MBUF_METADATA_UINT32_PTR(pkt, p_fc->flow_id_offset);
- struct flow_table_entry *entry =
- (struct flow_table_entry *) table_entry;
-
- /* Read */
- uint32_t flow_id = entry->flow_id;
-
- /* Compute */
-
- /* Write */
- *flow_id_ptr = flow_id;
-}
-
-static inline void
-pkt4_work_flow_id(
- struct rte_mbuf **pkts,
- struct rte_pipeline_table_entry **table_entries,
- void *arg)
-{
- struct pipeline_flow_classification *p_fc = arg;
-
- uint32_t *flow_id_ptr0 =
- RTE_MBUF_METADATA_UINT32_PTR(pkts[0], p_fc->flow_id_offset);
- uint32_t *flow_id_ptr1 =
- RTE_MBUF_METADATA_UINT32_PTR(pkts[1], p_fc->flow_id_offset);
- uint32_t *flow_id_ptr2 =
- RTE_MBUF_METADATA_UINT32_PTR(pkts[2], p_fc->flow_id_offset);
- uint32_t *flow_id_ptr3 =
- RTE_MBUF_METADATA_UINT32_PTR(pkts[3], p_fc->flow_id_offset);
-
- struct flow_table_entry *entry0 =
- (struct flow_table_entry *) table_entries[0];
- struct flow_table_entry *entry1 =
- (struct flow_table_entry *) table_entries[1];
- struct flow_table_entry *entry2 =
- (struct flow_table_entry *) table_entries[2];
- struct flow_table_entry *entry3 =
- (struct flow_table_entry *) table_entries[3];
-
- /* Read */
- uint32_t flow_id0 = entry0->flow_id;
- uint32_t flow_id1 = entry1->flow_id;
- uint32_t flow_id2 = entry2->flow_id;
- uint32_t flow_id3 = entry3->flow_id;
-
- /* Compute */
-
- /* Write */
- *flow_id_ptr0 = flow_id0;
- *flow_id_ptr1 = flow_id1;
- *flow_id_ptr2 = flow_id2;
- *flow_id_ptr3 = flow_id3;
-}
-
-PIPELINE_TABLE_AH_HIT(fc_table_ah_hit,
- pkt_work_flow_id, pkt4_work_flow_id);
-
-static rte_pipeline_table_action_handler_hit
-get_fc_table_ah_hit(struct pipeline_flow_classification *p)
-{
- if (p->flow_id)
- return fc_table_ah_hit;
-
- return NULL;
-}
-
-/*
- * Argument parsing
- */
-static int
-pipeline_fc_parse_args(struct pipeline_flow_classification *p,
- struct pipeline_params *params)
-{
- uint32_t n_flows_present = 0;
- uint32_t key_offset_present = 0;
- uint32_t key_size_present = 0;
- uint32_t hash_offset_present = 0;
- uint32_t key_mask_present = 0;
- uint32_t flow_id_offset_present = 0;
-
- uint32_t i;
- char key_mask_str[PIPELINE_FC_FLOW_KEY_MAX_SIZE * 2 + 1];
-
- p->hash_offset = 0;
-
- /* default values */
- p->flow_id = 0;
-
- for (i = 0; i < params->n_args; i++) {
- char *arg_name = params->args_name[i];
- char *arg_value = params->args_value[i];
-
- /* n_flows */
- if (strcmp(arg_name, "n_flows") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_flows_present == 0, params->name,
- arg_name);
- n_flows_present = 1;
-
- status = parser_read_uint32(&p->n_flows,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->n_flows != 0)), params->name,
- arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* key_offset */
- if (strcmp(arg_name, "key_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- key_offset_present == 0, params->name,
- arg_name);
- key_offset_present = 1;
-
- status = parser_read_uint32(&p->key_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* key_size */
- if (strcmp(arg_name, "key_size") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- key_size_present == 0, params->name,
- arg_name);
- key_size_present = 1;
-
- status = parser_read_uint32(&p->key_size,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->key_size != 0) &&
- (p->key_size % 8 == 0)),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG(((status != -ERANGE) &&
- (p->key_size <=
- PIPELINE_FC_FLOW_KEY_MAX_SIZE)),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* key_mask */
- if (strcmp(arg_name, "key_mask") == 0) {
- int mask_str_len = strlen(arg_value);
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- key_mask_present == 0,
- params->name, arg_name);
- key_mask_present = 1;
-
- PIPELINE_ARG_CHECK((mask_str_len <=
- (PIPELINE_FC_FLOW_KEY_MAX_SIZE * 2)),
- "Parse error in section \"%s\": entry "
- "\"%s\" is too long", params->name,
- arg_name);
-
- snprintf(key_mask_str, mask_str_len + 1, "%s",
- arg_value);
-
- continue;
- }
-
- /* hash_offset */
- if (strcmp(arg_name, "hash_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- hash_offset_present == 0, params->name,
- arg_name);
- hash_offset_present = 1;
-
- status = parser_read_uint32(&p->hash_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* flow_id_offset */
- if (strcmp(arg_name, "flowid_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- flow_id_offset_present == 0, params->name,
- arg_name);
- flow_id_offset_present = 1;
-
- status = parser_read_uint32(&p->flow_id_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- p->flow_id = 1;
-
- continue;
- }
-
- /* Unknown argument */
- PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
- }
-
- /* Check that mandatory arguments are present */
- PIPELINE_PARSE_ERR_MANDATORY((n_flows_present), params->name,
- "n_flows");
- PIPELINE_PARSE_ERR_MANDATORY((key_offset_present), params->name,
- "key_offset");
- PIPELINE_PARSE_ERR_MANDATORY((key_size_present), params->name,
- "key_size");
-
- if (key_mask_present) {
- uint32_t key_size = p->key_size;
- int status;
-
- PIPELINE_ARG_CHECK(((key_size == 8) || (key_size == 16)),
- "Parse error in section \"%s\": entry key_mask "
- "only allowed for key_size of 8 or 16 bytes",
- params->name);
-
- PIPELINE_ARG_CHECK((strlen(key_mask_str) ==
- (key_size * 2)), "Parse error in section "
- "\"%s\": key_mask should have exactly %u hex "
- "digits", params->name, (key_size * 2));
-
- PIPELINE_ARG_CHECK((hash_offset_present == 0), "Parse "
- "error in section \"%s\": entry hash_offset only "
- "allowed when key_mask is not present",
- params->name);
-
- status = parse_hex_string(key_mask_str, p->key_mask,
- &p->key_size);
-
- PIPELINE_PARSE_ERR_INV_VAL(((status == 0) &&
- (key_size == p->key_size)), params->name,
- "key_mask", key_mask_str);
- }
-
- p->key_mask_present = key_mask_present;
-
- return 0;
-}
-
-static void *pipeline_fc_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct pipeline *p;
- struct pipeline_flow_classification *p_fc;
- uint32_t size, i;
-
- /* Check input arguments */
- if (params == NULL)
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(
- sizeof(struct pipeline_flow_classification));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
- p_fc = (struct pipeline_flow_classification *) p;
-
- strcpy(p->name, params->name);
- p->log_level = params->log_level;
-
- PLOG(p, HIGH, "Flow classification");
-
- /* Parse arguments */
- if (pipeline_fc_parse_args(p_fc, params))
- return NULL;
-
- /* Pipeline */
- {
- struct rte_pipeline_params pipeline_params = {
- .name = params->name,
- .socket_id = params->socket_id,
- .offset_port_id = 0,
- };
-
- p->p = rte_pipeline_create(&pipeline_params);
- if (p->p == NULL) {
- rte_free(p);
- return NULL;
- }
- }
-
- /* Input ports */
- p->n_ports_in = params->n_ports_in;
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_port_in_params port_params = {
- .ops = pipeline_port_in_params_get_ops(
- &params->port_in[i]),
- .arg_create = pipeline_port_in_params_convert(
- &params->port_in[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- .burst_size = params->port_in[i].burst_size,
- };
-
- int status = rte_pipeline_port_in_create(p->p,
- &port_params,
- &p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Output ports */
- p->n_ports_out = params->n_ports_out;
- for (i = 0; i < p->n_ports_out; i++) {
- struct rte_pipeline_port_out_params port_params = {
- .ops = pipeline_port_out_params_get_ops(
- &params->port_out[i]),
- .arg_create = pipeline_port_out_params_convert(
- &params->port_out[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- };
-
- int status = rte_pipeline_port_out_create(p->p,
- &port_params,
- &p->port_out_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Tables */
- p->n_tables = 1;
- {
- struct rte_table_hash_params table_hash_params = {
- .name = p->name,
- .key_size = p_fc->key_size,
- .key_offset = p_fc->key_offset,
- .key_mask = (p_fc->key_mask_present) ?
- p_fc->key_mask : NULL,
- .n_keys = p_fc->n_flows,
- .n_buckets = rte_align32pow2(p_fc->n_flows / 4),
- .f_hash = hash_func[(p_fc->key_size / 8) - 1],
- .seed = 0,
- };
-
- struct rte_pipeline_table_params table_params = {
- .ops = NULL, /* set below */
- .arg_create = NULL, /* set below */
- .f_action_hit = get_fc_table_ah_hit(p_fc),
- .f_action_miss = NULL,
- .arg_ah = p_fc,
- .action_data_size = sizeof(struct flow_table_entry) -
- sizeof(struct rte_pipeline_table_entry),
- };
-
- int status;
-
- switch (p_fc->key_size) {
- case 8:
- table_params.ops = &rte_table_hash_key8_ext_ops;
- break;
-
- case 16:
- table_params.ops = &rte_table_hash_key16_ext_ops;
- break;
-
- default:
- table_params.ops = &rte_table_hash_ext_ops;
- }
-
- table_params.arg_create = &table_hash_params;
-
- status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Connecting input ports to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_connect_to_table(p->p,
- p->port_in_id[i],
- p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Enable input ports */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_enable(p->p,
- p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Check pipeline consistency */
- if (rte_pipeline_check(p->p) < 0) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- /* Message queues */
- p->n_msgq = params->n_msgq;
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_in[i] = params->msgq_in[i];
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_out[i] = params->msgq_out[i];
-
- /* Message handlers */
- memcpy(p->handlers, handlers, sizeof(p->handlers));
- memcpy(p_fc->custom_handlers,
- custom_handlers,
- sizeof(p_fc->custom_handlers));
-
- return p;
-}
-
-static int
-pipeline_fc_free(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_pipeline_free(p->p);
- rte_free(p);
- return 0;
-}
-
-static int
-pipeline_fc_timer(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- pipeline_msg_req_handle(p);
- rte_pipeline_flush(p->p);
-
- return 0;
-}
-
-static void *
-pipeline_fc_msg_req_custom_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_flow_classification *p_fc =
- (struct pipeline_flow_classification *) p;
- struct pipeline_custom_msg_req *req = msg;
- pipeline_msg_req_handler f_handle;
-
- f_handle = (req->subtype < PIPELINE_FC_MSG_REQS) ?
- p_fc->custom_handlers[req->subtype] :
- pipeline_msg_req_invalid_handler;
-
- if (f_handle == NULL)
- f_handle = pipeline_msg_req_invalid_handler;
-
- return f_handle(p, req);
-}
-
-static void *
-pipeline_fc_msg_req_add_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_fc_add_msg_req *req = msg;
- struct pipeline_fc_add_msg_rsp *rsp = msg;
-
- struct flow_table_entry entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
- .flow_id = req->flow_id,
- };
-
- rsp->status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &req->key,
- (struct rte_pipeline_table_entry *) &entry,
- &rsp->key_found,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-static void *
-pipeline_fc_msg_req_add_bulk_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_fc_add_bulk_msg_req *req = msg;
- struct pipeline_fc_add_bulk_msg_rsp *rsp = msg;
- uint32_t i;
-
- for (i = 0; i < req->n_keys; i++) {
- struct pipeline_fc_add_bulk_flow_req *flow_req = &req->req[i];
- struct pipeline_fc_add_bulk_flow_rsp *flow_rsp = &req->rsp[i];
-
- struct flow_table_entry entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[flow_req->port_id]},
- },
- .flow_id = flow_req->flow_id,
- };
-
- int status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &flow_req->key,
- (struct rte_pipeline_table_entry *) &entry,
- &flow_rsp->key_found,
- (struct rte_pipeline_table_entry **)
- &flow_rsp->entry_ptr);
-
- if (status)
- break;
- }
-
- rsp->n_keys = i;
-
- return rsp;
-}
-
-static void *
-pipeline_fc_msg_req_del_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_fc_del_msg_req *req = msg;
- struct pipeline_fc_del_msg_rsp *rsp = msg;
-
- rsp->status = rte_pipeline_table_entry_delete(p->p,
- p->table_id[0],
- &req->key,
- &rsp->key_found,
- NULL);
-
- return rsp;
-}
-
-static void *
-pipeline_fc_msg_req_add_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_fc_add_default_msg_req *req = msg;
- struct pipeline_fc_add_default_msg_rsp *rsp = msg;
-
- struct flow_table_entry default_entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
-
- .flow_id = 0,
- };
-
- rsp->status = rte_pipeline_table_default_entry_add(p->p,
- p->table_id[0],
- (struct rte_pipeline_table_entry *) &default_entry,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-static void *
-pipeline_fc_msg_req_del_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_fc_del_default_msg_rsp *rsp = msg;
-
- rsp->status = rte_pipeline_table_default_entry_delete(p->p,
- p->table_id[0],
- NULL);
-
- return rsp;
-}
-
-struct pipeline_be_ops pipeline_flow_classification_be_ops = {
- .f_init = pipeline_fc_init,
- .f_free = pipeline_fc_free,
- .f_run = NULL,
- .f_timer = pipeline_fc_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h
deleted file mode 100644
index 18f5bb42..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_FLOW_CLASSIFICATION_BE_H__
-#define __INCLUDE_PIPELINE_FLOW_CLASSIFICATION_BE_H__
-
-#include "pipeline_common_be.h"
-
-enum pipeline_fc_msg_req_type {
- PIPELINE_FC_MSG_REQ_FLOW_ADD = 0,
- PIPELINE_FC_MSG_REQ_FLOW_ADD_BULK,
- PIPELINE_FC_MSG_REQ_FLOW_DEL,
- PIPELINE_FC_MSG_REQ_FLOW_ADD_DEFAULT,
- PIPELINE_FC_MSG_REQ_FLOW_DEL_DEFAULT,
- PIPELINE_FC_MSG_REQS,
-};
-
-#ifndef PIPELINE_FC_FLOW_KEY_MAX_SIZE
-#define PIPELINE_FC_FLOW_KEY_MAX_SIZE 64
-#endif
-
-/*
- * MSG ADD
- */
-struct pipeline_fc_add_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fc_msg_req_type subtype;
-
- uint8_t key[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
-
- uint32_t port_id;
- uint32_t flow_id;
-};
-
-struct pipeline_fc_add_msg_rsp {
- int status;
- int key_found;
- void *entry_ptr;
-};
-
-/*
- * MSG ADD BULK
- */
-struct pipeline_fc_add_bulk_flow_req {
- uint8_t key[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
- uint32_t port_id;
- uint32_t flow_id;
-};
-
-struct pipeline_fc_add_bulk_flow_rsp {
- int key_found;
- void *entry_ptr;
-};
-
-struct pipeline_fc_add_bulk_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fc_msg_req_type subtype;
-
- struct pipeline_fc_add_bulk_flow_req *req;
- struct pipeline_fc_add_bulk_flow_rsp *rsp;
- uint32_t n_keys;
-};
-
-struct pipeline_fc_add_bulk_msg_rsp {
- uint32_t n_keys;
-};
-
-/*
- * MSG DEL
- */
-struct pipeline_fc_del_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fc_msg_req_type subtype;
-
- uint8_t key[PIPELINE_FC_FLOW_KEY_MAX_SIZE];
-};
-
-struct pipeline_fc_del_msg_rsp {
- int status;
- int key_found;
-};
-
-/*
- * MSG ADD DEFAULT
- */
-struct pipeline_fc_add_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fc_msg_req_type subtype;
-
- uint32_t port_id;
-};
-
-struct pipeline_fc_add_default_msg_rsp {
- int status;
- void *entry_ptr;
-};
-
-/*
- * MSG DEL DEFAULT
- */
-struct pipeline_fc_del_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_fc_msg_req_type subtype;
-};
-
-struct pipeline_fc_del_default_msg_rsp {
- int status;
-};
-
-extern struct pipeline_be_ops pipeline_flow_classification_be_ops;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_master.c b/examples/ip_pipeline/pipeline/pipeline_master.c
deleted file mode 100644
index b0d730a6..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_master.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include "pipeline_master.h"
-#include "pipeline_master_be.h"
-
-static struct pipeline_fe_ops pipeline_master_fe_ops = {
- .f_init = NULL,
- .f_post_init = NULL,
- .f_free = NULL,
- .f_track = NULL,
- .cmds = NULL,
-};
-
-struct pipeline_type pipeline_master = {
- .name = "MASTER",
- .be_ops = &pipeline_master_be_ops,
- .fe_ops = &pipeline_master_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_master.h b/examples/ip_pipeline/pipeline/pipeline_master.h
deleted file mode 100644
index a5183e33..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_master.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_MASTER_H__
-#define __INCLUDE_PIPELINE_MASTER_H__
-
-#include "pipeline.h"
-
-extern struct pipeline_type pipeline_master;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_master_be.c b/examples/ip_pipeline/pipeline/pipeline_master_be.c
deleted file mode 100644
index c72038ea..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_master_be.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-
-#include <cmdline_parse.h>
-#include <cmdline_parse_string.h>
-#include <cmdline_socket.h>
-#include <cmdline.h>
-
-#include "app.h"
-#include "pipeline_master_be.h"
-
-struct pipeline_master {
- struct app_params *app;
- struct cmdline *cl;
- int post_init_done;
- int script_file_done;
-} __rte_cache_aligned;
-
-static void*
-pipeline_init(__rte_unused struct pipeline_params *params, void *arg)
-{
- struct app_params *app = (struct app_params *) arg;
- struct pipeline_master *p;
- uint32_t size;
-
- /* Check input arguments */
- if (app == NULL)
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_master));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
-
- /* Initialization */
- p->app = app;
-
- p->cl = cmdline_stdin_new(app->cmds, "pipeline> ");
- if (p->cl == NULL) {
- rte_free(p);
- return NULL;
- }
-
- p->post_init_done = 0;
- p->script_file_done = 0;
- if (app->script_file == NULL)
- p->script_file_done = 1;
-
- return (void *) p;
-}
-
-static int
-pipeline_free(void *pipeline)
-{
- struct pipeline_master *p = (struct pipeline_master *) pipeline;
-
- if (p == NULL)
- return -EINVAL;
-
- cmdline_stdin_exit(p->cl);
- rte_free(p);
-
- return 0;
-}
-
-static int
-pipeline_run(void *pipeline)
-{
- struct pipeline_master *p = (struct pipeline_master *) pipeline;
- struct app_params *app = p->app;
- int status;
-#ifdef RTE_LIBRTE_KNI
- uint32_t i;
-#endif /* RTE_LIBRTE_KNI */
-
- /* Application post-init phase */
- if (p->post_init_done == 0) {
- app_post_init(app);
-
- p->post_init_done = 1;
- }
-
- /* Run startup script file */
- if (p->script_file_done == 0) {
- struct app_params *app = p->app;
- int fd = open(app->script_file, O_RDONLY);
-
- if (fd < 0)
- printf("Cannot open CLI script file \"%s\"\n",
- app->script_file);
- else {
- struct cmdline *file_cl;
-
- printf("Running CLI script file \"%s\" ...\n",
- app->script_file);
- file_cl = cmdline_new(p->cl->ctx, "", fd, 1);
- cmdline_interact(file_cl);
- close(fd);
- }
-
- p->script_file_done = 1;
- }
-
- /* Command Line Interface (CLI) */
- status = cmdline_poll(p->cl);
- if (status < 0)
- rte_panic("CLI poll error (%" PRId32 ")\n", status);
- else if (status == RDLINE_EXITED) {
- cmdline_stdin_exit(p->cl);
- rte_exit(0, "Bye!\n");
- }
-
-#ifdef RTE_LIBRTE_KNI
- /* Handle KNI requests from Linux kernel */
- for (i = 0; i < app->n_pktq_kni; i++)
- rte_kni_handle_request(app->kni[i]);
-#endif /* RTE_LIBRTE_KNI */
-
- return 0;
-}
-
-static int
-pipeline_timer(__rte_unused void *pipeline)
-{
- return 0;
-}
-
-struct pipeline_be_ops pipeline_master_be_ops = {
- .f_init = pipeline_init,
- .f_free = pipeline_free,
- .f_run = pipeline_run,
- .f_timer = pipeline_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_master_be.h b/examples/ip_pipeline/pipeline/pipeline_master_be.h
deleted file mode 100644
index 847c564c..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_master_be.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_MASTER_BE_H__
-#define __INCLUDE_PIPELINE_MASTER_BE_H__
-
-#include "pipeline_common_be.h"
-
-extern struct pipeline_be_ops pipeline_master_be_ops;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough.c b/examples/ip_pipeline/pipeline/pipeline_passthrough.c
deleted file mode 100644
index 031f5f05..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#include "pipeline_passthrough.h"
-#include "pipeline_passthrough_be.h"
-
-static int
-app_pipeline_passthrough_track(struct pipeline_params *p,
- uint32_t port_in,
- uint32_t *port_out)
-{
- struct pipeline_passthrough_params pp;
- int status;
-
- /* Check input arguments */
- if ((p == NULL) ||
- (port_in >= p->n_ports_in) ||
- (port_out == NULL))
- return -1;
-
- status = pipeline_passthrough_parse_args(&pp, p);
- if (status)
- return -1;
-
- if (pp.dma_hash_lb_enabled)
- return -1;
-
- *port_out = port_in / (p->n_ports_in / p->n_ports_out);
- return 0;
-}
-
-static struct pipeline_fe_ops pipeline_passthrough_fe_ops = {
- .f_init = NULL,
- .f_post_init = NULL,
- .f_free = NULL,
- .f_track = app_pipeline_passthrough_track,
- .cmds = NULL,
-};
-
-struct pipeline_type pipeline_passthrough = {
- .name = "PASS-THROUGH",
- .be_ops = &pipeline_passthrough_be_ops,
- .fe_ops = &pipeline_passthrough_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough.h b/examples/ip_pipeline/pipeline/pipeline_passthrough.h
deleted file mode 100644
index 7a7a2fc6..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_PASSTHROUGH_H__
-#define __INCLUDE_PIPELINE_PASSTHROUGH_H__
-
-#include "pipeline.h"
-
-extern struct pipeline_type pipeline_passthrough;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
deleted file mode 100644
index b2bbaedd..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.c
+++ /dev/null
@@ -1,929 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <rte_byteorder.h>
-#include <rte_table_stub.h>
-#include <rte_table_hash.h>
-#include <rte_pipeline.h>
-
-#include "pipeline_passthrough_be.h"
-#include "pipeline_actions_common.h"
-#include "parser.h"
-#include "hash_func.h"
-
-#define SWAP_DIM (PIPELINE_PASSTHROUGH_SWAP_N_FIELDS_MAX * \
- (PIPELINE_PASSTHROUGH_SWAP_FIELD_SIZE_MAX / sizeof(uint64_t)))
-
-struct pipeline_passthrough {
- struct pipeline p;
- struct pipeline_passthrough_params params;
- rte_table_hash_op_hash f_hash;
- uint32_t swap_field0_offset[SWAP_DIM];
- uint32_t swap_field1_offset[SWAP_DIM];
- uint64_t swap_field_mask[SWAP_DIM];
- uint32_t swap_n_fields;
-} __rte_cache_aligned;
-
-static pipeline_msg_req_handler handlers[] = {
- [PIPELINE_MSG_REQ_PING] =
- pipeline_msg_req_ping_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_IN] =
- pipeline_msg_req_stats_port_in_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
- pipeline_msg_req_stats_port_out_handler,
- [PIPELINE_MSG_REQ_STATS_TABLE] =
- pipeline_msg_req_stats_table_handler,
- [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
- pipeline_msg_req_port_in_enable_handler,
- [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
- pipeline_msg_req_port_in_disable_handler,
- [PIPELINE_MSG_REQ_CUSTOM] =
- pipeline_msg_req_invalid_handler,
-};
-
-static __rte_always_inline void
-pkt_work_dma(
- struct rte_mbuf *pkt,
- void *arg,
- uint32_t dma_size,
- uint32_t hash_enabled,
- uint32_t lb_hash,
- uint32_t port_out_pow2)
-{
- struct pipeline_passthrough *p = arg;
-
- uint64_t *dma_dst = RTE_MBUF_METADATA_UINT64_PTR(pkt,
- p->params.dma_dst_offset);
- uint64_t *dma_src = RTE_MBUF_METADATA_UINT64_PTR(pkt,
- p->params.dma_src_offset);
- uint64_t *dma_mask = (uint64_t *) p->params.dma_src_mask;
- uint32_t *dma_hash = RTE_MBUF_METADATA_UINT32_PTR(pkt,
- p->params.dma_hash_offset);
- uint32_t i;
-
- /* Read (dma_src), compute (dma_dst), write (dma_dst) */
- for (i = 0; i < (dma_size / 8); i++)
- dma_dst[i] = dma_src[i] & dma_mask[i];
-
- /* Read (dma_dst), compute (hash), write (hash) */
- if (hash_enabled) {
- uint32_t hash = p->f_hash(dma_src, dma_mask, dma_size, 0);
- *dma_hash = hash;
-
- if (lb_hash) {
- uint32_t port_out;
-
- if (port_out_pow2)
- port_out
- = hash & (p->p.n_ports_out - 1);
- else
- port_out
- = hash % p->p.n_ports_out;
-
- rte_pipeline_port_out_packet_insert(p->p.p,
- port_out, pkt);
- }
- }
-}
-
-static __rte_always_inline void
-pkt4_work_dma(
- struct rte_mbuf **pkts,
- void *arg,
- uint32_t dma_size,
- uint32_t hash_enabled,
- uint32_t lb_hash,
- uint32_t port_out_pow2)
-{
- struct pipeline_passthrough *p = arg;
-
- uint64_t *dma_dst0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- p->params.dma_dst_offset);
- uint64_t *dma_dst1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- p->params.dma_dst_offset);
- uint64_t *dma_dst2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- p->params.dma_dst_offset);
- uint64_t *dma_dst3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- p->params.dma_dst_offset);
-
- uint64_t *dma_src0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- p->params.dma_src_offset);
- uint64_t *dma_src1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- p->params.dma_src_offset);
- uint64_t *dma_src2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- p->params.dma_src_offset);
- uint64_t *dma_src3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- p->params.dma_src_offset);
-
- uint64_t *dma_mask = (uint64_t *) p->params.dma_src_mask;
-
- uint32_t *dma_hash0 = RTE_MBUF_METADATA_UINT32_PTR(pkts[0],
- p->params.dma_hash_offset);
- uint32_t *dma_hash1 = RTE_MBUF_METADATA_UINT32_PTR(pkts[1],
- p->params.dma_hash_offset);
- uint32_t *dma_hash2 = RTE_MBUF_METADATA_UINT32_PTR(pkts[2],
- p->params.dma_hash_offset);
- uint32_t *dma_hash3 = RTE_MBUF_METADATA_UINT32_PTR(pkts[3],
- p->params.dma_hash_offset);
-
- uint32_t i;
-
- /* Read (dma_src), compute (dma_dst), write (dma_dst) */
- for (i = 0; i < (dma_size / 8); i++) {
- dma_dst0[i] = dma_src0[i] & dma_mask[i];
- dma_dst1[i] = dma_src1[i] & dma_mask[i];
- dma_dst2[i] = dma_src2[i] & dma_mask[i];
- dma_dst3[i] = dma_src3[i] & dma_mask[i];
- }
-
- /* Read (dma_dst), compute (hash), write (hash) */
- if (hash_enabled) {
- uint32_t hash0 = p->f_hash(dma_src0, dma_mask, dma_size, 0);
- uint32_t hash1 = p->f_hash(dma_src1, dma_mask, dma_size, 0);
- uint32_t hash2 = p->f_hash(dma_src2, dma_mask, dma_size, 0);
- uint32_t hash3 = p->f_hash(dma_src3, dma_mask, dma_size, 0);
-
- *dma_hash0 = hash0;
- *dma_hash1 = hash1;
- *dma_hash2 = hash2;
- *dma_hash3 = hash3;
-
- if (lb_hash) {
- uint32_t port_out0, port_out1, port_out2, port_out3;
-
- if (port_out_pow2) {
- port_out0
- = hash0 & (p->p.n_ports_out - 1);
- port_out1
- = hash1 & (p->p.n_ports_out - 1);
- port_out2
- = hash2 & (p->p.n_ports_out - 1);
- port_out3
- = hash3 & (p->p.n_ports_out - 1);
- } else {
- port_out0
- = hash0 % p->p.n_ports_out;
- port_out1
- = hash1 % p->p.n_ports_out;
- port_out2
- = hash2 % p->p.n_ports_out;
- port_out3
- = hash3 % p->p.n_ports_out;
- }
- rte_pipeline_port_out_packet_insert(p->p.p,
- port_out0, pkts[0]);
- rte_pipeline_port_out_packet_insert(p->p.p,
- port_out1, pkts[1]);
- rte_pipeline_port_out_packet_insert(p->p.p,
- port_out2, pkts[2]);
- rte_pipeline_port_out_packet_insert(p->p.p,
- port_out3, pkts[3]);
- }
- }
-}
-
-static __rte_always_inline void
-pkt_work_swap(
- struct rte_mbuf *pkt,
- void *arg)
-{
- struct pipeline_passthrough *p = arg;
- uint32_t i;
-
- /* Read(field0, field1), compute(field0, field1), write(field0, field1) */
- for (i = 0; i < p->swap_n_fields; i++) {
- uint64_t *field0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt,
- p->swap_field0_offset[i]);
- uint64_t *field1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt,
- p->swap_field1_offset[i]);
- uint64_t mask = p->swap_field_mask[i];
-
- uint64_t field0 = *field0_ptr;
- uint64_t field1 = *field1_ptr;
-
- *field0_ptr = (field0 & (~mask)) + (field1 & mask);
- *field1_ptr = (field0 & mask) + (field1 & (~mask));
- }
-}
-
-static __rte_always_inline void
-pkt4_work_swap(
- struct rte_mbuf **pkts,
- void *arg)
-{
- struct pipeline_passthrough *p = arg;
- uint32_t i;
-
- /* Read(field0, field1), compute(field0, field1), write(field0, field1) */
- for (i = 0; i < p->swap_n_fields; i++) {
- uint64_t *pkt0_field0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- p->swap_field0_offset[i]);
- uint64_t *pkt1_field0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- p->swap_field0_offset[i]);
- uint64_t *pkt2_field0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- p->swap_field0_offset[i]);
- uint64_t *pkt3_field0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- p->swap_field0_offset[i]);
-
- uint64_t *pkt0_field1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- p->swap_field1_offset[i]);
- uint64_t *pkt1_field1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- p->swap_field1_offset[i]);
- uint64_t *pkt2_field1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- p->swap_field1_offset[i]);
- uint64_t *pkt3_field1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- p->swap_field1_offset[i]);
-
- uint64_t mask = p->swap_field_mask[i];
-
- uint64_t pkt0_field0 = *pkt0_field0_ptr;
- uint64_t pkt1_field0 = *pkt1_field0_ptr;
- uint64_t pkt2_field0 = *pkt2_field0_ptr;
- uint64_t pkt3_field0 = *pkt3_field0_ptr;
-
- uint64_t pkt0_field1 = *pkt0_field1_ptr;
- uint64_t pkt1_field1 = *pkt1_field1_ptr;
- uint64_t pkt2_field1 = *pkt2_field1_ptr;
- uint64_t pkt3_field1 = *pkt3_field1_ptr;
-
- *pkt0_field0_ptr = (pkt0_field0 & (~mask)) + (pkt0_field1 & mask);
- *pkt1_field0_ptr = (pkt1_field0 & (~mask)) + (pkt1_field1 & mask);
- *pkt2_field0_ptr = (pkt2_field0 & (~mask)) + (pkt2_field1 & mask);
- *pkt3_field0_ptr = (pkt3_field0 & (~mask)) + (pkt3_field1 & mask);
-
- *pkt0_field1_ptr = (pkt0_field0 & mask) + (pkt0_field1 & (~mask));
- *pkt1_field1_ptr = (pkt1_field0 & mask) + (pkt1_field1 & (~mask));
- *pkt2_field1_ptr = (pkt2_field0 & mask) + (pkt2_field1 & (~mask));
- *pkt3_field1_ptr = (pkt3_field0 & mask) + (pkt3_field1 & (~mask));
- }
-}
-
-#define PKT_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-static inline void \
-pkt_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2( \
- struct rte_mbuf *pkt, \
- void *arg) \
-{ \
- pkt_work_dma(pkt, arg, dma_size, hash_enabled, lb_hash, port_pow2); \
-}
-
-#define PKT4_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-static inline void \
-pkt4_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2( \
- struct rte_mbuf **pkts, \
- void *arg) \
-{ \
- pkt4_work_dma(pkts, arg, dma_size, hash_enabled, lb_hash, port_pow2); \
-}
-
-#define port_in_ah_dma(dma_size, hash_enabled, lb_hash, port_pow2) \
-PKT_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-PKT4_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-PIPELINE_PORT_IN_AH(port_in_ah_dma_size##dma_size##_hash \
- ##hash_enabled##_lb##lb_hash##_pw##port_pow2, \
- pkt_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2, \
- pkt4_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2)
-
-
-#define port_in_ah_lb(dma_size, hash_enabled, lb_hash, port_pow2) \
-PKT_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-PKT4_WORK_DMA(dma_size, hash_enabled, lb_hash, port_pow2) \
-PIPELINE_PORT_IN_AH_HIJACK_ALL( \
- port_in_ah_lb_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2, \
- pkt_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2, \
- pkt4_work_dma_size##dma_size##_hash##hash_enabled \
- ##_lb##lb_hash##_pw##port_pow2)
-
-PIPELINE_PORT_IN_AH(port_in_ah_swap, pkt_work_swap, pkt4_work_swap)
-
-
-/* Port in AH DMA(dma_size, hash_enabled, lb_hash, port_pow2) */
-
-port_in_ah_dma(8, 0, 0, 0)
-port_in_ah_dma(8, 1, 0, 0)
-port_in_ah_lb(8, 1, 1, 0)
-port_in_ah_lb(8, 1, 1, 1)
-
-port_in_ah_dma(16, 0, 0, 0)
-port_in_ah_dma(16, 1, 0, 0)
-port_in_ah_lb(16, 1, 1, 0)
-port_in_ah_lb(16, 1, 1, 1)
-
-port_in_ah_dma(24, 0, 0, 0)
-port_in_ah_dma(24, 1, 0, 0)
-port_in_ah_lb(24, 1, 1, 0)
-port_in_ah_lb(24, 1, 1, 1)
-
-port_in_ah_dma(32, 0, 0, 0)
-port_in_ah_dma(32, 1, 0, 0)
-port_in_ah_lb(32, 1, 1, 0)
-port_in_ah_lb(32, 1, 1, 1)
-
-port_in_ah_dma(40, 0, 0, 0)
-port_in_ah_dma(40, 1, 0, 0)
-port_in_ah_lb(40, 1, 1, 0)
-port_in_ah_lb(40, 1, 1, 1)
-
-port_in_ah_dma(48, 0, 0, 0)
-port_in_ah_dma(48, 1, 0, 0)
-port_in_ah_lb(48, 1, 1, 0)
-port_in_ah_lb(48, 1, 1, 1)
-
-port_in_ah_dma(56, 0, 0, 0)
-port_in_ah_dma(56, 1, 0, 0)
-port_in_ah_lb(56, 1, 1, 0)
-port_in_ah_lb(56, 1, 1, 1)
-
-port_in_ah_dma(64, 0, 0, 0)
-port_in_ah_dma(64, 1, 0, 0)
-port_in_ah_lb(64, 1, 1, 0)
-port_in_ah_lb(64, 1, 1, 1)
-
-static rte_pipeline_port_in_action_handler
-get_port_in_ah(struct pipeline_passthrough *p)
-{
- if ((p->params.dma_enabled == 0) &&
- (p->params.swap_enabled == 0))
- return NULL;
-
- if (p->params.swap_enabled)
- return port_in_ah_swap;
-
- if (p->params.dma_hash_enabled) {
- if (p->params.dma_hash_lb_enabled) {
- if (rte_is_power_of_2(p->p.n_ports_out))
- switch (p->params.dma_size) {
-
- case 8: return port_in_ah_lb_size8_hash1_lb1_pw1;
- case 16: return port_in_ah_lb_size16_hash1_lb1_pw1;
- case 24: return port_in_ah_lb_size24_hash1_lb1_pw1;
- case 32: return port_in_ah_lb_size32_hash1_lb1_pw1;
- case 40: return port_in_ah_lb_size40_hash1_lb1_pw1;
- case 48: return port_in_ah_lb_size48_hash1_lb1_pw1;
- case 56: return port_in_ah_lb_size56_hash1_lb1_pw1;
- case 64: return port_in_ah_lb_size64_hash1_lb1_pw1;
- default: return NULL;
- }
- else
- switch (p->params.dma_size) {
-
- case 8: return port_in_ah_lb_size8_hash1_lb1_pw0;
- case 16: return port_in_ah_lb_size16_hash1_lb1_pw0;
- case 24: return port_in_ah_lb_size24_hash1_lb1_pw0;
- case 32: return port_in_ah_lb_size32_hash1_lb1_pw0;
- case 40: return port_in_ah_lb_size40_hash1_lb1_pw0;
- case 48: return port_in_ah_lb_size48_hash1_lb1_pw0;
- case 56: return port_in_ah_lb_size56_hash1_lb1_pw0;
- case 64: return port_in_ah_lb_size64_hash1_lb1_pw0;
- default: return NULL;
- }
- } else
- switch (p->params.dma_size) {
-
- case 8: return port_in_ah_dma_size8_hash1_lb0_pw0;
- case 16: return port_in_ah_dma_size16_hash1_lb0_pw0;
- case 24: return port_in_ah_dma_size24_hash1_lb0_pw0;
- case 32: return port_in_ah_dma_size32_hash1_lb0_pw0;
- case 40: return port_in_ah_dma_size40_hash1_lb0_pw0;
- case 48: return port_in_ah_dma_size48_hash1_lb0_pw0;
- case 56: return port_in_ah_dma_size56_hash1_lb0_pw0;
- case 64: return port_in_ah_dma_size64_hash1_lb0_pw0;
- default: return NULL;
- }
- } else
- switch (p->params.dma_size) {
-
- case 8: return port_in_ah_dma_size8_hash0_lb0_pw0;
- case 16: return port_in_ah_dma_size16_hash0_lb0_pw0;
- case 24: return port_in_ah_dma_size24_hash0_lb0_pw0;
- case 32: return port_in_ah_dma_size32_hash0_lb0_pw0;
- case 40: return port_in_ah_dma_size40_hash0_lb0_pw0;
- case 48: return port_in_ah_dma_size48_hash0_lb0_pw0;
- case 56: return port_in_ah_dma_size56_hash0_lb0_pw0;
- case 64: return port_in_ah_dma_size64_hash0_lb0_pw0;
- default: return NULL;
- }
-}
-
-int
-pipeline_passthrough_parse_args(struct pipeline_passthrough_params *p,
- struct pipeline_params *params)
-{
- uint32_t dma_dst_offset_present = 0;
- uint32_t dma_src_offset_present = 0;
- uint32_t dma_src_mask_present = 0;
- char dma_mask_str[PIPELINE_PASSTHROUGH_DMA_SIZE_MAX * 2 + 1];
- uint32_t dma_size_present = 0;
- uint32_t dma_hash_offset_present = 0;
- uint32_t dma_hash_lb_present = 0;
- uint32_t i;
-
- /* default values */
- p->dma_enabled = 0;
- p->dma_hash_enabled = 0;
- p->dma_hash_lb_enabled = 0;
- memset(p->dma_src_mask, 0xFF, sizeof(p->dma_src_mask));
- p->swap_enabled = 0;
- p->swap_n_fields = 0;
-
- for (i = 0; i < params->n_args; i++) {
- char *arg_name = params->args_name[i];
- char *arg_value = params->args_value[i];
-
- /* dma_dst_offset */
- if (strcmp(arg_name, "dma_dst_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_dst_offset_present == 0, params->name,
- arg_name);
- dma_dst_offset_present = 1;
-
- status = parser_read_uint32(&p->dma_dst_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- p->dma_enabled = 1;
-
- continue;
- }
-
- /* dma_src_offset */
- if (strcmp(arg_name, "dma_src_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_src_offset_present == 0, params->name,
- arg_name);
- dma_src_offset_present = 1;
-
- status = parser_read_uint32(&p->dma_src_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- p->dma_enabled = 1;
-
- continue;
- }
-
- /* dma_size */
- if (strcmp(arg_name, "dma_size") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_size_present == 0, params->name,
- arg_name);
- dma_size_present = 1;
-
- status = parser_read_uint32(&p->dma_size,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->dma_size != 0) &&
- ((p->dma_size % 8) == 0)),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG(((status != -ERANGE) &&
- (p->dma_size <=
- PIPELINE_PASSTHROUGH_DMA_SIZE_MAX)),
- params->name, arg_name, arg_value);
-
- p->dma_enabled = 1;
-
- continue;
- }
-
- /* dma_src_mask */
- if (strcmp(arg_name, "dma_src_mask") == 0) {
- int mask_str_len = strlen(arg_value);
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_src_mask_present == 0,
- params->name, arg_name);
- dma_src_mask_present = 1;
-
- PIPELINE_ARG_CHECK((mask_str_len <=
- (PIPELINE_PASSTHROUGH_DMA_SIZE_MAX * 2)),
- "Parse error in section \"%s\": entry "
- "\"%s\" too long", params->name,
- arg_name);
-
- snprintf(dma_mask_str, mask_str_len + 1,
- "%s", arg_value);
-
- p->dma_enabled = 1;
-
- continue;
- }
-
- /* dma_hash_offset */
- if (strcmp(arg_name, "dma_hash_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_hash_offset_present == 0,
- params->name, arg_name);
- dma_hash_offset_present = 1;
-
- status = parser_read_uint32(&p->dma_hash_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- p->dma_hash_enabled = 1;
-
- continue;
- }
-
- /* load_balance mode */
- if (strcmp(arg_name, "lb") == 0) {
- PIPELINE_PARSE_ERR_DUPLICATE(
- dma_hash_lb_present == 0,
- params->name, arg_name);
- dma_hash_lb_present = 1;
-
- if (strcmp(arg_value, "hash") &&
- strcmp(arg_value, "HASH"))
-
- PIPELINE_PARSE_ERR_INV_VAL(0,
- params->name,
- arg_name,
- arg_value);
-
- p->dma_hash_lb_enabled = 1;
-
- continue;
- }
-
- /* swap */
- if (strcmp(arg_name, "swap") == 0) {
- uint32_t a, b, n_args;
- int len;
-
- n_args = sscanf(arg_value, "%" SCNu32 " %" SCNu32 "%n",
- &a, &b, &len);
- PIPELINE_PARSE_ERR_INV_VAL(((n_args == 2) &&
- ((size_t) len == strlen(arg_value))),
- params->name, arg_name, arg_value);
-
- p->swap_field0_offset[p->swap_n_fields] = a;
- p->swap_field1_offset[p->swap_n_fields] = b;
- p->swap_n_fields++;
- p->swap_enabled = 1;
-
- continue;
- }
-
- /* any other */
- PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
- }
-
- /* Check correlations between arguments */
- PIPELINE_ARG_CHECK((p->dma_enabled + p->swap_enabled < 2),
- "Parse error in section \"%s\": DMA and SWAP actions are both enabled",
- params->name);
- PIPELINE_ARG_CHECK((dma_dst_offset_present == p->dma_enabled),
- "Parse error in section \"%s\": missing entry "
- "\"dma_dst_offset\"", params->name);
- PIPELINE_ARG_CHECK((dma_src_offset_present == p->dma_enabled),
- "Parse error in section \"%s\": missing entry "
- "\"dma_src_offset\"", params->name);
- PIPELINE_ARG_CHECK((dma_size_present == p->dma_enabled),
- "Parse error in section \"%s\": missing entry "
- "\"dma_size\"", params->name);
- PIPELINE_ARG_CHECK((p->dma_hash_enabled <= p->dma_enabled),
- "Parse error in section \"%s\": missing all DMA entries",
- params->name);
- PIPELINE_ARG_CHECK((p->dma_hash_lb_enabled <= p->dma_hash_enabled),
- "Parse error in section \"%s\": missing all DMA hash entries ",
- params->name);
-
- if (dma_src_mask_present) {
- uint32_t dma_size = p->dma_size;
- int status;
-
- PIPELINE_ARG_CHECK((strlen(dma_mask_str) ==
- (dma_size * 2)), "Parse error in section "
- "\"%s\": dma_src_mask should have exactly %u hex "
- "digits", params->name, (dma_size * 2));
-
- status = parse_hex_string(dma_mask_str, p->dma_src_mask,
- &p->dma_size);
-
- PIPELINE_PARSE_ERR_INV_VAL(((status == 0) &&
- (dma_size == p->dma_size)), params->name,
- "dma_src_mask", dma_mask_str);
- }
-
- if (p->dma_hash_lb_enabled)
- PIPELINE_ARG_CHECK((params->n_ports_out > 1),
- "Parse error in section \"%s\": entry \"lb\" not "
- "allowed for single output port pipeline",
- params->name);
- else
- PIPELINE_ARG_CHECK(((params->n_ports_in >= params->n_ports_out)
- && ((params->n_ports_in % params->n_ports_out) == 0)),
- "Parse error in section \"%s\": n_ports_in needs to be "
- "a multiple of n_ports_out (lb mode disabled)",
- params->name);
-
- return 0;
-}
-
-static rte_table_hash_op_hash
-get_hash_function(struct pipeline_passthrough *p)
-{
- switch (p->params.dma_size) {
-
- case 8: return hash_default_key8;
- case 16: return hash_default_key16;
- case 24: return hash_default_key24;
- case 32: return hash_default_key32;
- case 40: return hash_default_key40;
- case 48: return hash_default_key48;
- case 56: return hash_default_key56;
- case 64: return hash_default_key64;
- default: return NULL;
- }
-}
-
-static int
-pipeline_passthrough_swap_convert(struct pipeline_passthrough *p)
-{
- uint32_t i;
-
- p->swap_n_fields = 0;
-
- for (i = 0; i < p->params.swap_n_fields; i++) {
- uint32_t offset0 = p->params.swap_field0_offset[i];
- uint32_t offset1 = p->params.swap_field1_offset[i];
- uint32_t size = offset1 - offset0;
- uint32_t j;
-
- /* Check */
- if ((offset0 >= offset1) ||
- (size > PIPELINE_PASSTHROUGH_SWAP_FIELD_SIZE_MAX) ||
- (p->swap_n_fields >= SWAP_DIM))
- return -1;
-
- for (j = 0; j < (size / sizeof(uint64_t)); j++) {
- p->swap_field0_offset[p->swap_n_fields] = offset0;
- p->swap_field1_offset[p->swap_n_fields] = offset1;
- p->swap_field_mask[p->swap_n_fields] = UINT64_MAX;
- p->swap_n_fields++;
- offset0 += sizeof(uint64_t);
- offset1 += sizeof(uint64_t);
- }
- if (size % sizeof(uint64_t)) {
- uint32_t n_bits = (size % sizeof(uint64_t)) * 8;
-
- p->swap_field0_offset[p->swap_n_fields] = offset0;
- p->swap_field1_offset[p->swap_n_fields] = offset1;
- p->swap_field_mask[p->swap_n_fields] =
- RTE_LEN2MASK(n_bits, uint64_t);
- p->swap_n_fields++;
- }
- }
-
- return 0;
-}
-
-static void*
-pipeline_passthrough_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct pipeline *p;
- struct pipeline_passthrough *p_pt;
- uint32_t size, i;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_passthrough));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- p_pt = (struct pipeline_passthrough *) p;
- if (p == NULL)
- return NULL;
-
- strcpy(p->name, params->name);
- p->log_level = params->log_level;
-
- PLOG(p, HIGH, "Pass-through");
-
- /* Parse arguments */
- if (pipeline_passthrough_parse_args(&p_pt->params, params))
- return NULL;
- if (pipeline_passthrough_swap_convert(p_pt))
- return NULL;
- p_pt->f_hash = get_hash_function(p_pt);
-
- /* Pipeline */
- {
- struct rte_pipeline_params pipeline_params = {
- .name = "PASS-THROUGH",
- .socket_id = params->socket_id,
- .offset_port_id = 0,
- };
-
- p->p = rte_pipeline_create(&pipeline_params);
- if (p->p == NULL) {
- rte_free(p);
- return NULL;
- }
- }
-
- p->n_ports_in = params->n_ports_in;
- p->n_ports_out = params->n_ports_out;
- p->n_tables = p->n_ports_in;
-
- /*Input ports*/
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_port_in_params port_params = {
- .ops = pipeline_port_in_params_get_ops(
- &params->port_in[i]),
- .arg_create = pipeline_port_in_params_convert(
- &params->port_in[i]),
- .f_action = get_port_in_ah(p_pt),
- .arg_ah = p_pt,
- .burst_size = params->port_in[i].burst_size,
- };
-
- int status = rte_pipeline_port_in_create(p->p,
- &port_params,
- &p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Output ports */
- for (i = 0; i < p->n_ports_out; i++) {
- struct rte_pipeline_port_out_params port_params = {
- .ops = pipeline_port_out_params_get_ops(
- &params->port_out[i]),
- .arg_create = pipeline_port_out_params_convert(
- &params->port_out[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- };
-
- int status = rte_pipeline_port_out_create(p->p,
- &port_params,
- &p->port_out_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Tables */
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_table_params table_params = {
- .ops = &rte_table_stub_ops,
- .arg_create = NULL,
- .f_action_hit = NULL,
- .f_action_miss = NULL,
- .arg_ah = NULL,
- .action_data_size = 0,
- };
-
- int status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Connecting input ports to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_connect_to_table(p->p,
- p->port_in_id[i],
- p->table_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Add entries to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- uint32_t port_out_id = (p_pt->params.dma_hash_lb_enabled == 0) ?
- (i / (p->n_ports_in / p->n_ports_out)) :
- 0;
-
- struct rte_pipeline_table_entry default_entry = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[port_out_id]},
- };
-
- struct rte_pipeline_table_entry *default_entry_ptr;
-
- int status = rte_pipeline_table_default_entry_add(p->p,
- p->table_id[i],
- &default_entry,
- &default_entry_ptr);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Enable input ports */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_enable(p->p,
- p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Check pipeline consistency */
- if (rte_pipeline_check(p->p) < 0) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- /* Message queues */
- p->n_msgq = params->n_msgq;
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_in[i] = params->msgq_in[i];
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_out[i] = params->msgq_out[i];
-
- /* Message handlers */
- memcpy(p->handlers, handlers, sizeof(p->handlers));
-
- return p;
-}
-
-static int
-pipeline_passthrough_free(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_pipeline_free(p->p);
- rte_free(p);
- return 0;
-}
-
-static int
-pipeline_passthrough_timer(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- pipeline_msg_req_handle(p);
- rte_pipeline_flush(p->p);
-
- return 0;
-}
-
-struct pipeline_be_ops pipeline_passthrough_be_ops = {
- .f_init = pipeline_passthrough_init,
- .f_free = pipeline_passthrough_free,
- .f_run = NULL,
- .f_timer = pipeline_passthrough_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.h b/examples/ip_pipeline/pipeline/pipeline_passthrough_be.h
deleted file mode 100644
index 94d1d1cf..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_passthrough_be.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_PASSTHROUGH_BE_H__
-#define __INCLUDE_PIPELINE_PASSTHROUGH_BE_H__
-
-#include "pipeline_common_be.h"
-
-#define PIPELINE_PASSTHROUGH_DMA_SIZE_MAX 64
-
-#ifndef PIPELINE_PASSTHROUGH_SWAP_N_FIELDS_MAX
-#define PIPELINE_PASSTHROUGH_SWAP_N_FIELDS_MAX 8
-#endif
-
-#ifndef PIPELINE_PASSTHROUGH_SWAP_FIELD_SIZE_MAX
-#define PIPELINE_PASSTHROUGH_SWAP_FIELD_SIZE_MAX 16
-#endif
-
-struct pipeline_passthrough_params {
- uint32_t dma_enabled;
- uint32_t dma_dst_offset;
- uint32_t dma_src_offset;
- uint8_t dma_src_mask[PIPELINE_PASSTHROUGH_DMA_SIZE_MAX];
- uint32_t dma_size;
-
- uint32_t dma_hash_enabled;
- uint32_t dma_hash_offset;
-
- uint32_t dma_hash_lb_enabled;
-
- uint32_t swap_enabled;
- uint32_t swap_field0_offset[PIPELINE_PASSTHROUGH_SWAP_N_FIELDS_MAX];
- uint32_t swap_field1_offset[PIPELINE_PASSTHROUGH_SWAP_N_FIELDS_MAX];
- uint32_t swap_n_fields;
-};
-
-int
-pipeline_passthrough_parse_args(struct pipeline_passthrough_params *p,
- struct pipeline_params *params);
-
-extern struct pipeline_be_ops pipeline_passthrough_be_ops;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.c b/examples/ip_pipeline/pipeline/pipeline_routing.c
deleted file mode 100644
index 0562c63a..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_routing.c
+++ /dev/null
@@ -1,1613 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <cmdline_parse.h>
-#include <cmdline_parse_num.h>
-#include <cmdline_parse_string.h>
-
-#include "app.h"
-#include "pipeline_common_fe.h"
-#include "pipeline_routing.h"
-#include "parser.h"
-
-struct app_pipeline_routing_route {
- struct pipeline_routing_route_key key;
- struct pipeline_routing_route_data data;
- void *entry_ptr;
-
- TAILQ_ENTRY(app_pipeline_routing_route) node;
-};
-
-struct app_pipeline_routing_arp_entry {
- struct pipeline_routing_arp_key key;
- struct ether_addr macaddr;
- void *entry_ptr;
-
- TAILQ_ENTRY(app_pipeline_routing_arp_entry) node;
-};
-
-struct pipeline_routing {
- /* Parameters */
- struct app_params *app;
- uint32_t pipeline_id;
- uint32_t n_ports_in;
- uint32_t n_ports_out;
- struct pipeline_routing_params rp;
-
- /* Links */
- uint32_t link_id[PIPELINE_MAX_PORT_OUT];
-
- /* Routes */
- TAILQ_HEAD(, app_pipeline_routing_route) routes;
- uint32_t n_routes;
-
- uint32_t default_route_present;
- uint32_t default_route_port_id;
- void *default_route_entry_ptr;
-
- /* ARP entries */
- TAILQ_HEAD(, app_pipeline_routing_arp_entry) arp_entries;
- uint32_t n_arp_entries;
-
- uint32_t default_arp_entry_present;
- uint32_t default_arp_entry_port_id;
- void *default_arp_entry_ptr;
-};
-
-static int
-app_pipeline_routing_find_link(struct pipeline_routing *p,
- uint32_t link_id,
- uint32_t *port_id)
-{
- uint32_t i;
-
- for (i = 0; i < p->n_ports_out; i++)
- if (p->link_id[i] == link_id) {
- *port_id = i;
- return 0;
- }
-
- return -1;
-}
-
-static void
-app_pipeline_routing_link_op(__rte_unused struct app_params *app,
- uint32_t link_id,
- uint32_t up,
- void *arg)
-{
- struct pipeline_routing_route_key key0, key1;
- struct pipeline_routing *p = arg;
- struct app_link_params *lp;
- uint32_t port_id, netmask;
- int status;
-
- if (app == NULL)
- return;
-
- APP_PARAM_FIND_BY_ID(app->link_params, "LINK", link_id, lp);
- if (lp == NULL)
- return;
-
- status = app_pipeline_routing_find_link(p,
- link_id,
- &port_id);
- if (status)
- return;
-
- netmask = (~0U) << (32 - lp->depth);
-
- /* Local network (directly attached network) */
- key0.type = PIPELINE_ROUTING_ROUTE_IPV4;
- key0.key.ipv4.ip = lp->ip & netmask;
- key0.key.ipv4.depth = lp->depth;
-
- /* Local termination */
- key1.type = PIPELINE_ROUTING_ROUTE_IPV4;
- key1.key.ipv4.ip = lp->ip;
- key1.key.ipv4.depth = 32;
-
- if (up) {
- struct pipeline_routing_route_data data0, data1;
-
- /* Local network (directly attached network) */
- memset(&data0, 0, sizeof(data0));
- data0.flags = PIPELINE_ROUTING_ROUTE_LOCAL |
- PIPELINE_ROUTING_ROUTE_ARP;
- if (p->rp.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ)
- data0.flags |= PIPELINE_ROUTING_ROUTE_QINQ;
- if (p->rp.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) {
- data0.flags |= PIPELINE_ROUTING_ROUTE_MPLS;
- data0.l2.mpls.n_labels = 1;
- }
- data0.port_id = port_id;
-
- if (p->rp.n_arp_entries)
- app_pipeline_routing_add_route(app,
- p->pipeline_id,
- &key0,
- &data0);
-
- /* Local termination */
- memset(&data1, 0, sizeof(data1));
- data1.flags = PIPELINE_ROUTING_ROUTE_LOCAL |
- PIPELINE_ROUTING_ROUTE_ARP;
- if (p->rp.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ)
- data1.flags |= PIPELINE_ROUTING_ROUTE_QINQ;
- if (p->rp.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) {
- data1.flags |= PIPELINE_ROUTING_ROUTE_MPLS;
- data1.l2.mpls.n_labels = 1;
- }
- data1.port_id = p->rp.port_local_dest;
-
- app_pipeline_routing_add_route(app,
- p->pipeline_id,
- &key1,
- &data1);
- } else {
- /* Local network (directly attached network) */
- if (p->rp.n_arp_entries)
- app_pipeline_routing_delete_route(app,
- p->pipeline_id,
- &key0);
-
- /* Local termination */
- app_pipeline_routing_delete_route(app,
- p->pipeline_id,
- &key1);
- }
-}
-
-static int
-app_pipeline_routing_set_link_op(
- struct app_params *app,
- struct pipeline_routing *p)
-{
- uint32_t port_id;
-
- for (port_id = 0; port_id < p->n_ports_out; port_id++) {
- struct app_link_params *link;
- uint32_t link_id;
- int status;
-
- link = app_pipeline_track_pktq_out_to_link(app,
- p->pipeline_id,
- port_id);
- if (link == NULL)
- continue;
-
- link_id = link - app->link_params;
- p->link_id[port_id] = link_id;
-
- status = app_link_set_op(app,
- link_id,
- p->pipeline_id,
- app_pipeline_routing_link_op,
- (void *) p);
- if (status)
- return status;
- }
-
- return 0;
-}
-
-static void *
-app_pipeline_routing_init(struct pipeline_params *params,
- void *arg)
-{
- struct app_params *app = (struct app_params *) arg;
- struct pipeline_routing *p;
- uint32_t pipeline_id, size;
- int status;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- APP_PARAM_GET_ID(params, "PIPELINE", pipeline_id);
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_routing));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- if (p == NULL)
- return NULL;
-
- /* Initialization */
- p->app = app;
- p->pipeline_id = pipeline_id;
- p->n_ports_in = params->n_ports_in;
- p->n_ports_out = params->n_ports_out;
-
- status = pipeline_routing_parse_args(&p->rp, params);
- if (status) {
- rte_free(p);
- return NULL;
- }
- TAILQ_INIT(&p->routes);
- p->n_routes = 0;
-
- TAILQ_INIT(&p->arp_entries);
- p->n_arp_entries = 0;
-
- app_pipeline_routing_set_link_op(app, p);
-
- return p;
-}
-
-static int
-app_pipeline_routing_post_init(void *pipeline)
-{
- struct pipeline_routing *p = pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- return app_pipeline_routing_set_macaddr(p->app, p->pipeline_id);
-}
-
-static int
-app_pipeline_routing_free(void *pipeline)
-{
- struct pipeline_routing *p = pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- while (!TAILQ_EMPTY(&p->routes)) {
- struct app_pipeline_routing_route *route;
-
- route = TAILQ_FIRST(&p->routes);
- TAILQ_REMOVE(&p->routes, route, node);
- rte_free(route);
- }
-
- while (!TAILQ_EMPTY(&p->arp_entries)) {
- struct app_pipeline_routing_arp_entry *arp_entry;
-
- arp_entry = TAILQ_FIRST(&p->arp_entries);
- TAILQ_REMOVE(&p->arp_entries, arp_entry, node);
- rte_free(arp_entry);
- }
-
- rte_free(p);
- return 0;
-}
-
-static struct app_pipeline_routing_route *
-app_pipeline_routing_find_route(struct pipeline_routing *p,
- const struct pipeline_routing_route_key *key)
-{
- struct app_pipeline_routing_route *it, *found;
-
- found = NULL;
- TAILQ_FOREACH(it, &p->routes, node) {
- if ((key->type == it->key.type) &&
- (key->key.ipv4.ip == it->key.key.ipv4.ip) &&
- (key->key.ipv4.depth == it->key.key.ipv4.depth)) {
- found = it;
- break;
- }
- }
-
- return found;
-}
-
-static struct app_pipeline_routing_arp_entry *
-app_pipeline_routing_find_arp_entry(struct pipeline_routing *p,
- const struct pipeline_routing_arp_key *key)
-{
- struct app_pipeline_routing_arp_entry *it, *found;
-
- found = NULL;
- TAILQ_FOREACH(it, &p->arp_entries, node) {
- if ((key->type == it->key.type) &&
- (key->key.ipv4.port_id == it->key.key.ipv4.port_id) &&
- (key->key.ipv4.ip == it->key.key.ipv4.ip)) {
- found = it;
- break;
- }
- }
-
- return found;
-}
-
-static void
-print_route(const struct app_pipeline_routing_route *route)
-{
- if (route->key.type == PIPELINE_ROUTING_ROUTE_IPV4) {
- const struct pipeline_routing_route_key_ipv4 *key =
- &route->key.key.ipv4;
-
- printf("IP Prefix = %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32 "/%" PRIu32
- " => (Port = %" PRIu32,
-
- (key->ip >> 24) & 0xFF,
- (key->ip >> 16) & 0xFF,
- (key->ip >> 8) & 0xFF,
- key->ip & 0xFF,
-
- key->depth,
- route->data.port_id);
-
- if (route->data.flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- printf(", Local");
- else if (route->data.flags & PIPELINE_ROUTING_ROUTE_ARP)
- printf(
- ", Next Hop IP = %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32,
-
- (route->data.ethernet.ip >> 24) & 0xFF,
- (route->data.ethernet.ip >> 16) & 0xFF,
- (route->data.ethernet.ip >> 8) & 0xFF,
- route->data.ethernet.ip & 0xFF);
- else
- printf(
- ", Next Hop HWaddress = %02" PRIx32
- ":%02" PRIx32 ":%02" PRIx32
- ":%02" PRIx32 ":%02" PRIx32
- ":%02" PRIx32,
-
- route->data.ethernet.macaddr.addr_bytes[0],
- route->data.ethernet.macaddr.addr_bytes[1],
- route->data.ethernet.macaddr.addr_bytes[2],
- route->data.ethernet.macaddr.addr_bytes[3],
- route->data.ethernet.macaddr.addr_bytes[4],
- route->data.ethernet.macaddr.addr_bytes[5]);
-
- if (route->data.flags & PIPELINE_ROUTING_ROUTE_QINQ)
- printf(", QinQ SVLAN = %" PRIu32 " CVLAN = %" PRIu32,
- route->data.l2.qinq.svlan,
- route->data.l2.qinq.cvlan);
-
- if (route->data.flags & PIPELINE_ROUTING_ROUTE_MPLS) {
- uint32_t i;
-
- printf(", MPLS labels");
- for (i = 0; i < route->data.l2.mpls.n_labels; i++)
- printf(" %" PRIu32,
- route->data.l2.mpls.labels[i]);
- }
-
- printf(")\n");
- }
-}
-
-static void
-print_arp_entry(const struct app_pipeline_routing_arp_entry *entry)
-{
- printf("(Port = %" PRIu32 ", IP = %" PRIu32 ".%" PRIu32
- ".%" PRIu32 ".%" PRIu32
- ") => HWaddress = %02" PRIx32 ":%02" PRIx32 ":%02" PRIx32
- ":%02" PRIx32 ":%02" PRIx32 ":%02" PRIx32 "\n",
-
- entry->key.key.ipv4.port_id,
- (entry->key.key.ipv4.ip >> 24) & 0xFF,
- (entry->key.key.ipv4.ip >> 16) & 0xFF,
- (entry->key.key.ipv4.ip >> 8) & 0xFF,
- entry->key.key.ipv4.ip & 0xFF,
-
- entry->macaddr.addr_bytes[0],
- entry->macaddr.addr_bytes[1],
- entry->macaddr.addr_bytes[2],
- entry->macaddr.addr_bytes[3],
- entry->macaddr.addr_bytes[4],
- entry->macaddr.addr_bytes[5]);
-}
-
-static int
-app_pipeline_routing_route_ls(struct app_params *app, uint32_t pipeline_id)
-{
- struct pipeline_routing *p;
- struct app_pipeline_routing_route *it;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -EINVAL;
-
- TAILQ_FOREACH(it, &p->routes, node)
- print_route(it);
-
- if (p->default_route_present)
- printf("Default route: port %" PRIu32 " (entry ptr = %p)\n",
- p->default_route_port_id,
- p->default_route_entry_ptr);
- else
- printf("Default: DROP\n");
-
- return 0;
-}
-
-int
-app_pipeline_routing_add_route(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_route_key *key,
- struct pipeline_routing_route_data *data)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_route_add_msg_req *req;
- struct pipeline_routing_route_add_msg_rsp *rsp;
-
- struct app_pipeline_routing_route *entry;
-
- int new_entry;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL) ||
- (data == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- switch (key->type) {
- case PIPELINE_ROUTING_ROUTE_IPV4:
- {
- uint32_t depth = key->key.ipv4.depth;
- uint32_t netmask;
-
- /* key */
- if ((depth == 0) || (depth > 32))
- return -1;
-
- netmask = (~0U) << (32 - depth);
- key->key.ipv4.ip &= netmask;
-
- /* data */
- if (data->port_id >= p->n_ports_out)
- return -1;
-
- /* Valid range of VLAN tags 12 bits */
- if (data->flags & PIPELINE_ROUTING_ROUTE_QINQ)
- if ((data->l2.qinq.svlan & 0xF000) ||
- (data->l2.qinq.cvlan & 0xF000))
- return -1;
-
- /* Max number of MPLS labels supported */
- if (data->flags & PIPELINE_ROUTING_ROUTE_MPLS) {
- uint32_t i;
-
- if (data->l2.mpls.n_labels >
- PIPELINE_ROUTING_MPLS_LABELS_MAX)
- return -1;
-
- /* Max MPLS label value 20 bits */
- for (i = 0; i < data->l2.mpls.n_labels; i++)
- if (data->l2.mpls.labels[i] & 0xFFF00000)
- return -1;
- }
- }
- break;
-
- default:
- return -1;
- }
-
- /* Find existing rule or allocate new rule */
- entry = app_pipeline_routing_find_route(p, key);
- new_entry = (entry == NULL);
- if (entry == NULL) {
- entry = rte_malloc(NULL, sizeof(*entry), RTE_CACHE_LINE_SIZE);
-
- if (entry == NULL)
- return -1;
- }
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL) {
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD;
- memcpy(&req->key, key, sizeof(*key));
- memcpy(&req->data, data, sizeof(*data));
-
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- /* Read response and write entry */
- if (rsp->status ||
- (rsp->entry_ptr == NULL) ||
- ((new_entry == 0) && (rsp->key_found == 0)) ||
- ((new_entry == 1) && (rsp->key_found == 1))) {
- app_msg_free(app, rsp);
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- memcpy(&entry->key, key, sizeof(*key));
- memcpy(&entry->data, data, sizeof(*data));
- entry->entry_ptr = rsp->entry_ptr;
-
- /* Commit entry */
- if (new_entry) {
- TAILQ_INSERT_TAIL(&p->routes, entry, node);
- p->n_routes++;
- }
-
- /* Message buffer free */
- app_msg_free(app, rsp);
- return 0;
-}
-
-int
-app_pipeline_routing_delete_route(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_route_key *key)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_route_delete_msg_req *req;
- struct pipeline_routing_route_delete_msg_rsp *rsp;
-
- struct app_pipeline_routing_route *entry;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- switch (key->type) {
- case PIPELINE_ROUTING_ROUTE_IPV4:
- {
- uint32_t depth = key->key.ipv4.depth;
- uint32_t netmask;
-
- /* key */
- if ((depth == 0) || (depth > 32))
- return -1;
-
- netmask = (~0U) << (32 - depth);
- key->key.ipv4.ip &= netmask;
- }
- break;
-
- default:
- return -1;
- }
-
- /* Find rule */
- entry = app_pipeline_routing_find_route(p, key);
- if (entry == NULL)
- return 0;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL;
- memcpy(&req->key, key, sizeof(*key));
-
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status || !rsp->key_found) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Remove route */
- TAILQ_REMOVE(&p->routes, entry, node);
- p->n_routes--;
- rte_free(entry);
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_routing_add_default_route(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_route_add_default_msg_req *req;
- struct pipeline_routing_route_add_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write route */
- if (rsp->status || (rsp->entry_ptr == NULL)) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- p->default_route_port_id = port_id;
- p->default_route_entry_ptr = rsp->entry_ptr;
-
- /* Commit route */
- p->default_route_present = 1;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_routing_delete_default_route(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_arp_delete_default_msg_req *req;
- struct pipeline_routing_arp_delete_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write route */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Commit route */
- p->default_route_present = 0;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-static int
-app_pipeline_routing_arp_ls(struct app_params *app, uint32_t pipeline_id)
-{
- struct pipeline_routing *p;
- struct app_pipeline_routing_arp_entry *it;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -EINVAL;
-
- TAILQ_FOREACH(it, &p->arp_entries, node)
- print_arp_entry(it);
-
- if (p->default_arp_entry_present)
- printf("Default entry: port %" PRIu32 " (entry ptr = %p)\n",
- p->default_arp_entry_port_id,
- p->default_arp_entry_ptr);
- else
- printf("Default: DROP\n");
-
- return 0;
-}
-
-int
-app_pipeline_routing_add_arp_entry(struct app_params *app, uint32_t pipeline_id,
- struct pipeline_routing_arp_key *key,
- struct ether_addr *macaddr)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_arp_add_msg_req *req;
- struct pipeline_routing_arp_add_msg_rsp *rsp;
-
- struct app_pipeline_routing_arp_entry *entry;
-
- int new_entry;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL) ||
- (macaddr == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- switch (key->type) {
- case PIPELINE_ROUTING_ARP_IPV4:
- {
- uint32_t port_id = key->key.ipv4.port_id;
-
- /* key */
- if (port_id >= p->n_ports_out)
- return -1;
- }
- break;
-
- default:
- return -1;
- }
-
- /* Find existing entry or allocate new */
- entry = app_pipeline_routing_find_arp_entry(p, key);
- new_entry = (entry == NULL);
- if (entry == NULL) {
- entry = rte_malloc(NULL, sizeof(*entry), RTE_CACHE_LINE_SIZE);
-
- if (entry == NULL)
- return -1;
- }
-
- /* Message buffer allocation */
- req = app_msg_alloc(app);
- if (req == NULL) {
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ARP_ADD;
- memcpy(&req->key, key, sizeof(*key));
- ether_addr_copy(macaddr, &req->macaddr);
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL) {
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- /* Read response and write entry */
- if (rsp->status ||
- (rsp->entry_ptr == NULL) ||
- ((new_entry == 0) && (rsp->key_found == 0)) ||
- ((new_entry == 1) && (rsp->key_found == 1))) {
- app_msg_free(app, rsp);
- if (new_entry)
- rte_free(entry);
- return -1;
- }
-
- memcpy(&entry->key, key, sizeof(*key));
- ether_addr_copy(macaddr, &entry->macaddr);
- entry->entry_ptr = rsp->entry_ptr;
-
- /* Commit entry */
- if (new_entry) {
- TAILQ_INSERT_TAIL(&p->arp_entries, entry, node);
- p->n_arp_entries++;
- }
-
- /* Message buffer free */
- app_msg_free(app, rsp);
- return 0;
-}
-
-int
-app_pipeline_routing_delete_arp_entry(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_arp_key *key)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_arp_delete_msg_req *req;
- struct pipeline_routing_arp_delete_msg_rsp *rsp;
-
- struct app_pipeline_routing_arp_entry *entry;
-
- /* Check input arguments */
- if ((app == NULL) ||
- (key == NULL))
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -EINVAL;
-
- switch (key->type) {
- case PIPELINE_ROUTING_ARP_IPV4:
- {
- uint32_t port_id = key->key.ipv4.port_id;
-
- /* key */
- if (port_id >= p->n_ports_out)
- return -1;
- }
- break;
-
- default:
- return -1;
- }
-
- /* Find rule */
- entry = app_pipeline_routing_find_arp_entry(p, key);
- if (entry == NULL)
- return 0;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ARP_DEL;
- memcpy(&req->key, key, sizeof(*key));
-
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response */
- if (rsp->status || !rsp->key_found) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- /* Remove entry */
- TAILQ_REMOVE(&p->arp_entries, entry, node);
- p->n_arp_entries--;
- rte_free(entry);
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_routing_add_default_arp_entry(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_arp_add_default_msg_req *req;
- struct pipeline_routing_arp_add_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -1;
-
- if (port_id >= p->n_ports_out)
- return -1;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -1;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT;
- req->port_id = port_id;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -1;
-
- /* Read response and write entry */
- if (rsp->status || rsp->entry_ptr == NULL) {
- app_msg_free(app, rsp);
- return -1;
- }
-
- p->default_arp_entry_port_id = port_id;
- p->default_arp_entry_ptr = rsp->entry_ptr;
-
- /* Commit entry */
- p->default_arp_entry_present = 1;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_routing_delete_default_arp_entry(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct pipeline_routing *p;
-
- struct pipeline_routing_arp_delete_default_msg_req *req;
- struct pipeline_routing_arp_delete_default_msg_rsp *rsp;
-
- /* Check input arguments */
- if (app == NULL)
- return -1;
-
- p = app_pipeline_data_fe(app, pipeline_id, &pipeline_routing);
- if (p == NULL)
- return -EINVAL;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -ENOMEM;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT;
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -ETIMEDOUT;
-
- /* Read response and write entry */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return rsp->status;
- }
-
- /* Commit entry */
- p->default_arp_entry_present = 0;
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-int
-app_pipeline_routing_set_macaddr(struct app_params *app,
- uint32_t pipeline_id)
-{
- struct app_pipeline_params *p;
- struct pipeline_routing_set_macaddr_msg_req *req;
- struct pipeline_routing_set_macaddr_msg_rsp *rsp;
- uint32_t port_id;
-
- /* Check input arguments */
- if (app == NULL)
- return -EINVAL;
-
- APP_PARAM_FIND_BY_ID(app->pipeline_params, "PIPELINE", pipeline_id, p);
- if (p == NULL)
- return -EINVAL;
-
- /* Allocate and write request */
- req = app_msg_alloc(app);
- if (req == NULL)
- return -ENOMEM;
-
- req->type = PIPELINE_MSG_REQ_CUSTOM;
- req->subtype = PIPELINE_ROUTING_MSG_REQ_SET_MACADDR;
-
- memset(req->macaddr, 0, sizeof(req->macaddr));
- for (port_id = 0; port_id < p->n_pktq_out; port_id++) {
- struct app_link_params *link;
-
- link = app_pipeline_track_pktq_out_to_link(app,
- pipeline_id,
- port_id);
- if (link)
- req->macaddr[port_id] = link->mac_addr;
- }
-
- /* Send request and wait for response */
- rsp = app_msg_send_recv(app, pipeline_id, req, MSG_TIMEOUT_DEFAULT);
- if (rsp == NULL)
- return -ETIMEDOUT;
-
- /* Read response and write entry */
- if (rsp->status) {
- app_msg_free(app, rsp);
- return rsp->status;
- }
-
- /* Free response */
- app_msg_free(app, rsp);
-
- return 0;
-}
-
-/*
- * route
- *
- * route add (ARP = ON/OFF, MPLS = ON/OFF, QINQ = ON/OFF):
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhmacaddr>
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhipaddr>
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhmacaddr> qinq <svlan> <cvlan>
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhipaddr> qinq <svlan> <cvlan>
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhmacaddr> mpls <mpls labels>
- * p <pipelineid> route add <ipaddr> <depth> port <portid> ether <nhipaddr> mpls <mpls labels>
- *
- * route add default:
- * p <pipelineid> route add default <portid>
- *
- * route del:
- * p <pipelineid> route del <ipaddr> <depth>
- *
- * route del default:
- * p <pipelineid> route del default
- *
- * route ls:
- * p <pipelineid> route ls
- */
-
-struct cmd_route_result {
- cmdline_fixed_string_t p_string;
- uint32_t p;
- cmdline_fixed_string_t route_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_route_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_route_result *params = parsed_result;
- struct app_params *app = data;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status != 0) {
- printf(CMD_MSG_TOO_MANY_ARGS, "route");
- return;
- }
-
- /* route add */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- strcmp(tokens[1], "default")) {
- struct pipeline_routing_route_key key;
- struct pipeline_routing_route_data route_data;
- struct in_addr ipv4, nh_ipv4;
- struct ether_addr mac_addr;
- uint32_t depth, port_id, svlan, cvlan, i;
- uint32_t mpls_labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
- uint32_t n_labels = RTE_DIM(mpls_labels);
-
- memset(&key, 0, sizeof(key));
- memset(&route_data, 0, sizeof(route_data));
-
- if (n_tokens < 7) {
- printf(CMD_MSG_NOT_ENOUGH_ARGS, "route add");
- return;
- }
-
- if (parse_ipv4_addr(tokens[1], &ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "ipaddr");
- return;
- }
-
- if (parser_read_uint32(&depth, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "depth");
- return;
- }
-
- if (strcmp(tokens[3], "port")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "port");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[4])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (strcmp(tokens[5], "ether")) {
- printf(CMD_MSG_ARG_NOT_FOUND, "ether");
- return;
- }
-
- if (parse_mac_addr(tokens[6], &mac_addr)) {
- if (parse_ipv4_addr(tokens[6], &nh_ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "nhmacaddr or nhipaddr");
- return;
- }
-
- route_data.flags |= PIPELINE_ROUTING_ROUTE_ARP;
- }
-
- if (n_tokens > 7) {
- if (strcmp(tokens[7], "mpls") == 0) {
- if (n_tokens != 9) {
- printf(CMD_MSG_MISMATCH_ARGS, "route add mpls");
- return;
- }
-
- if (parse_mpls_labels(tokens[8], mpls_labels, &n_labels)) {
- printf(CMD_MSG_INVALID_ARG, "mpls labels");
- return;
- }
-
- route_data.flags |= PIPELINE_ROUTING_ROUTE_MPLS;
- } else if (strcmp(tokens[7], "qinq") == 0) {
- if (n_tokens != 10) {
- printf(CMD_MSG_MISMATCH_ARGS, "route add qinq");
- return;
- }
-
- if (parser_read_uint32(&svlan, tokens[8])) {
- printf(CMD_MSG_INVALID_ARG, "svlan");
- return;
- }
- if (parser_read_uint32(&cvlan, tokens[9])) {
- printf(CMD_MSG_INVALID_ARG, "cvlan");
- return;
- }
-
- route_data.flags |= PIPELINE_ROUTING_ROUTE_QINQ;
- } else {
- printf(CMD_MSG_ARG_NOT_FOUND, "mpls or qinq");
- return;
- }
- }
-
- switch (route_data.flags) {
- case 0:
- route_data.port_id = port_id;
- route_data.ethernet.macaddr = mac_addr;
- break;
-
- case PIPELINE_ROUTING_ROUTE_ARP:
- route_data.port_id = port_id;
- route_data.ethernet.ip = rte_be_to_cpu_32(nh_ipv4.s_addr);
- break;
-
- case PIPELINE_ROUTING_ROUTE_MPLS:
- route_data.port_id = port_id;
- route_data.ethernet.macaddr = mac_addr;
- for (i = 0; i < n_labels; i++)
- route_data.l2.mpls.labels[i] = mpls_labels[i];
- route_data.l2.mpls.n_labels = n_labels;
- break;
-
- case PIPELINE_ROUTING_ROUTE_MPLS | PIPELINE_ROUTING_ROUTE_ARP:
- route_data.port_id = port_id;
- route_data.ethernet.ip = rte_be_to_cpu_32(nh_ipv4.s_addr);
- for (i = 0; i < n_labels; i++)
- route_data.l2.mpls.labels[i] = mpls_labels[i];
- route_data.l2.mpls.n_labels = n_labels;
- break;
-
- case PIPELINE_ROUTING_ROUTE_QINQ:
- route_data.port_id = port_id;
- route_data.ethernet.macaddr = mac_addr;
- route_data.l2.qinq.svlan = svlan;
- route_data.l2.qinq.cvlan = cvlan;
- break;
-
- case PIPELINE_ROUTING_ROUTE_QINQ | PIPELINE_ROUTING_ROUTE_ARP:
- default:
- route_data.port_id = port_id;
- route_data.ethernet.ip = rte_be_to_cpu_32(nh_ipv4.s_addr);
- route_data.l2.qinq.svlan = svlan;
- route_data.l2.qinq.cvlan = cvlan;
- break;
- }
-
- key.type = PIPELINE_ROUTING_ROUTE_IPV4;
- key.key.ipv4.ip = rte_be_to_cpu_32(ipv4.s_addr);
- key.key.ipv4.depth = depth;
-
- status = app_pipeline_routing_add_route(app,
- params->p,
- &key,
- &route_data);
- if (status != 0)
- printf(CMD_MSG_FAIL, "route add");
-
- return;
- } /* route add */
-
- /* route add default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- uint32_t port_id;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "route add default");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- status = app_pipeline_routing_add_default_route(app,
- params->p,
- port_id);
- if (status != 0)
- printf(CMD_MSG_FAIL, "route add default");
-
- return;
- } /* route add default */
-
- /* route del*/
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- strcmp(tokens[1], "default")) {
- struct pipeline_routing_route_key key;
- struct in_addr ipv4;
- uint32_t depth;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "route del");
- return;
- }
-
- if (parse_ipv4_addr(tokens[1], &ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "ipaddr");
- return;
- }
-
- if (parser_read_uint32(&depth, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "depth");
- return;
- }
-
- key.type = PIPELINE_ROUTING_ROUTE_IPV4;
- key.key.ipv4.ip = rte_be_to_cpu_32(ipv4.s_addr);
- key.key.ipv4.depth = depth;
-
- status = app_pipeline_routing_delete_route(app, params->p, &key);
- if (status != 0)
- printf(CMD_MSG_FAIL, "route del");
-
- return;
- } /* route del */
-
- /* route del default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "route del default");
- return;
- }
-
- status = app_pipeline_routing_delete_default_route(app,
- params->p);
- if (status != 0)
- printf(CMD_MSG_FAIL, "route del default");
-
- return;
- } /* route del default */
-
- /* route ls */
- if ((n_tokens >= 1) && (strcmp(tokens[0], "ls") == 0)) {
- if (n_tokens != 1) {
- printf(CMD_MSG_MISMATCH_ARGS, "route ls");
- return;
- }
-
- status = app_pipeline_routing_route_ls(app, params->p);
- if (status != 0)
- printf(CMD_MSG_FAIL, "route ls");
-
- return;
- } /* route ls */
-
- printf(CMD_MSG_MISMATCH_ARGS, "route");
-}
-
-static cmdline_parse_token_string_t cmd_route_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_route_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_route_p =
- TOKEN_NUM_INITIALIZER(struct cmd_route_result, p, UINT32);
-
-static cmdline_parse_token_string_t cmd_route_route_string =
- TOKEN_STRING_INITIALIZER(struct cmd_route_result, route_string, "route");
-
-static cmdline_parse_token_string_t cmd_route_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_route_result, multi_string,
- TOKEN_STRING_MULTI);
-
-static cmdline_parse_inst_t cmd_route = {
- .f = cmd_route_parsed,
- .data = NULL,
- .help_str = "route add / add default / del / del default / ls",
- .tokens = {
- (void *)&cmd_route_p_string,
- (void *)&cmd_route_p,
- (void *)&cmd_route_route_string,
- (void *)&cmd_route_multi_string,
- NULL,
- },
-};
-
-/*
- * arp
- *
- * arp add:
- * p <pipelineid> arp add <portid> <ipaddr> <macaddr>
- *
- * arp add default:
- * p <pipelineid> arp add default <portid>
- *
- * arp del:
- * p <pipelineid> arp del <portid> <ipaddr>
- *
- * arp del default:
- * p <pipelineid> arp del default
- *
- * arp ls:
- * p <pipelineid> arp ls
- */
-
-struct cmd_arp_result {
- cmdline_fixed_string_t p_string;
- uint32_t p;
- cmdline_fixed_string_t arp_string;
- cmdline_multi_string_t multi_string;
-};
-
-static void
-cmd_arp_parsed(
- void *parsed_result,
- __rte_unused struct cmdline *cl,
- void *data)
-{
- struct cmd_arp_result *params = parsed_result;
- struct app_params *app = data;
-
- char *tokens[16];
- uint32_t n_tokens = RTE_DIM(tokens);
- int status;
-
- status = parse_tokenize_string(params->multi_string, tokens, &n_tokens);
- if (status != 0) {
- printf(CMD_MSG_TOO_MANY_ARGS, "arp");
- return;
- }
-
- /* arp add */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- strcmp(tokens[1], "default")) {
- struct pipeline_routing_arp_key key;
- struct in_addr ipv4;
- struct ether_addr mac_addr;
- uint32_t port_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 4) {
- printf(CMD_MSG_MISMATCH_ARGS, "arp add");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "ipaddr");
- return;
- }
-
- if (parse_mac_addr(tokens[3], &mac_addr)) {
- printf(CMD_MSG_INVALID_ARG, "macaddr");
- return;
- }
-
- key.type = PIPELINE_ROUTING_ARP_IPV4;
- key.key.ipv4.port_id = port_id;
- key.key.ipv4.ip = rte_be_to_cpu_32(ipv4.s_addr);
-
- status = app_pipeline_routing_add_arp_entry(app,
- params->p,
- &key,
- &mac_addr);
- if (status != 0)
- printf(CMD_MSG_FAIL, "arp add");
-
- return;
- } /* arp add */
-
- /* arp add default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "add") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- uint32_t port_id;
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "arp add default");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[2])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- status = app_pipeline_routing_add_default_arp_entry(app,
- params->p,
- port_id);
- if (status != 0)
- printf(CMD_MSG_FAIL, "arp add default");
-
- return;
- } /* arp add default */
-
- /* arp del*/
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- strcmp(tokens[1], "default")) {
- struct pipeline_routing_arp_key key;
- struct in_addr ipv4;
- uint32_t port_id;
-
- memset(&key, 0, sizeof(key));
-
- if (n_tokens != 3) {
- printf(CMD_MSG_MISMATCH_ARGS, "arp del");
- return;
- }
-
- if (parser_read_uint32(&port_id, tokens[1])) {
- printf(CMD_MSG_INVALID_ARG, "portid");
- return;
- }
-
- if (parse_ipv4_addr(tokens[2], &ipv4)) {
- printf(CMD_MSG_INVALID_ARG, "ipaddr");
- return;
- }
-
- key.type = PIPELINE_ROUTING_ARP_IPV4;
- key.key.ipv4.ip = rte_be_to_cpu_32(ipv4.s_addr);
- key.key.ipv4.port_id = port_id;
-
- status = app_pipeline_routing_delete_arp_entry(app,
- params->p,
- &key);
- if (status != 0)
- printf(CMD_MSG_FAIL, "arp del");
-
- return;
- } /* arp del */
-
- /* arp del default */
- if ((n_tokens >= 2) &&
- (strcmp(tokens[0], "del") == 0) &&
- (strcmp(tokens[1], "default") == 0)) {
- if (n_tokens != 2) {
- printf(CMD_MSG_MISMATCH_ARGS, "arp del default");
- return;
- }
-
- status = app_pipeline_routing_delete_default_arp_entry(app,
- params->p);
- if (status != 0)
- printf(CMD_MSG_FAIL, "arp del default");
-
- return;
- } /* arp del default */
-
- /* arp ls */
- if ((n_tokens >= 1) && (strcmp(tokens[0], "ls") == 0)) {
- if (n_tokens != 1) {
- printf(CMD_MSG_MISMATCH_ARGS, "arp ls");
- return;
- }
-
- status = app_pipeline_routing_arp_ls(app, params->p);
- if (status != 0)
- printf(CMD_MSG_FAIL, "arp ls");
-
- return;
- } /* arp ls */
-
- printf(CMD_MSG_FAIL, "arp");
-}
-
-static cmdline_parse_token_string_t cmd_arp_p_string =
- TOKEN_STRING_INITIALIZER(struct cmd_arp_result, p_string, "p");
-
-static cmdline_parse_token_num_t cmd_arp_p =
- TOKEN_NUM_INITIALIZER(struct cmd_arp_result, p, UINT32);
-
-static cmdline_parse_token_string_t cmd_arp_arp_string =
- TOKEN_STRING_INITIALIZER(struct cmd_arp_result, arp_string, "arp");
-
-static cmdline_parse_token_string_t cmd_arp_multi_string =
- TOKEN_STRING_INITIALIZER(struct cmd_arp_result, multi_string,
- TOKEN_STRING_MULTI);
-
-static cmdline_parse_inst_t cmd_arp = {
- .f = cmd_arp_parsed,
- .data = NULL,
- .help_str = "arp add / add default / del / del default / ls",
- .tokens = {
- (void *)&cmd_arp_p_string,
- (void *)&cmd_arp_p,
- (void *)&cmd_arp_arp_string,
- (void *)&cmd_arp_multi_string,
- NULL,
- },
-};
-
-static cmdline_parse_ctx_t pipeline_cmds[] = {
- (cmdline_parse_inst_t *)&cmd_route,
- (cmdline_parse_inst_t *)&cmd_arp,
- NULL,
-};
-
-static struct pipeline_fe_ops pipeline_routing_fe_ops = {
- .f_init = app_pipeline_routing_init,
- .f_post_init = app_pipeline_routing_post_init,
- .f_free = app_pipeline_routing_free,
- .f_track = app_pipeline_track_default,
- .cmds = pipeline_cmds,
-};
-
-struct pipeline_type pipeline_routing = {
- .name = "ROUTING",
- .be_ops = &pipeline_routing_be_ops,
- .fe_ops = &pipeline_routing_fe_ops,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing.h b/examples/ip_pipeline/pipeline/pipeline_routing.h
deleted file mode 100644
index f2492957..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_routing.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_ROUTING_H__
-#define __INCLUDE_PIPELINE_ROUTING_H__
-
-#include "pipeline.h"
-#include "pipeline_routing_be.h"
-
-/*
- * Route
- */
-
-int
-app_pipeline_routing_add_route(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_route_key *key,
- struct pipeline_routing_route_data *data);
-
-int
-app_pipeline_routing_delete_route(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_route_key *key);
-
-int
-app_pipeline_routing_add_default_route(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_pipeline_routing_delete_default_route(struct app_params *app,
- uint32_t pipeline_id);
-
-/*
- * ARP
- */
-
-int
-app_pipeline_routing_add_arp_entry(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_arp_key *key,
- struct ether_addr *macaddr);
-
-int
-app_pipeline_routing_delete_arp_entry(struct app_params *app,
- uint32_t pipeline_id,
- struct pipeline_routing_arp_key *key);
-
-int
-app_pipeline_routing_add_default_arp_entry(struct app_params *app,
- uint32_t pipeline_id,
- uint32_t port_id);
-
-int
-app_pipeline_routing_delete_default_arp_entry(struct app_params *app,
- uint32_t pipeline_id);
-
-/*
- * SETTINGS
- */
-int
-app_pipeline_routing_set_macaddr(struct app_params *app,
- uint32_t pipeline_id);
-
-/*
- * Pipeline type
- */
-extern struct pipeline_type pipeline_routing;
-
-#endif
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c b/examples/ip_pipeline/pipeline/pipeline_routing_be.c
deleted file mode 100644
index 6258a1a9..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c
+++ /dev/null
@@ -1,1966 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2016 Intel Corporation
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <rte_common.h>
-#include <rte_malloc.h>
-#include <rte_ip.h>
-#include <rte_byteorder.h>
-#include <rte_table_lpm.h>
-#include <rte_table_hash.h>
-#include <rte_pipeline.h>
-
-#include "pipeline_routing_be.h"
-#include "pipeline_actions_common.h"
-#include "parser.h"
-#include "hash_func.h"
-
-#define MPLS_LABEL(label, exp, s, ttl) \
- (((((uint64_t) (label)) & 0xFFFFFLLU) << 12) | \
- ((((uint64_t) (exp)) & 0x7LLU) << 9) | \
- ((((uint64_t) (s)) & 0x1LLU) << 8) | \
- (((uint64_t) (ttl)) & 0xFFLU))
-
-#define RTE_SCHED_PORT_HIERARCHY(subport, pipe, \
- traffic_class, queue, color) \
- ((((uint64_t) (queue)) & 0x3) | \
- ((((uint64_t) (traffic_class)) & 0x3) << 2) | \
- ((((uint64_t) (color)) & 0x3) << 4) | \
- ((((uint64_t) (subport)) & 0xFFFF) << 16) | \
- ((((uint64_t) (pipe)) & 0xFFFFFFFF) << 32))
-
-
-/* Network Byte Order (NBO) */
-#define SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr, ethertype) \
- (((uint64_t) macaddr) | (((uint64_t) rte_cpu_to_be_16(ethertype)) << 48))
-
-#ifndef PIPELINE_ROUTING_LPM_TABLE_NUMBER_TABLE8s
-#define PIPELINE_ROUTING_LPM_TABLE_NUMBER_TABLE8s 256
-#endif
-
-struct pipeline_routing {
- struct pipeline p;
- struct pipeline_routing_params params;
- pipeline_msg_req_handler custom_handlers[PIPELINE_ROUTING_MSG_REQS];
- uint64_t macaddr[PIPELINE_MAX_PORT_OUT];
-} __rte_cache_aligned;
-
-/*
- * Message handlers
- */
-static void *
-pipeline_routing_msg_req_custom_handler(struct pipeline *p, void *msg);
-
-static pipeline_msg_req_handler handlers[] = {
- [PIPELINE_MSG_REQ_PING] =
- pipeline_msg_req_ping_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_IN] =
- pipeline_msg_req_stats_port_in_handler,
- [PIPELINE_MSG_REQ_STATS_PORT_OUT] =
- pipeline_msg_req_stats_port_out_handler,
- [PIPELINE_MSG_REQ_STATS_TABLE] =
- pipeline_msg_req_stats_table_handler,
- [PIPELINE_MSG_REQ_PORT_IN_ENABLE] =
- pipeline_msg_req_port_in_enable_handler,
- [PIPELINE_MSG_REQ_PORT_IN_DISABLE] =
- pipeline_msg_req_port_in_disable_handler,
- [PIPELINE_MSG_REQ_CUSTOM] =
- pipeline_routing_msg_req_custom_handler,
-};
-
-static void *
-pipeline_routing_msg_req_route_add_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_route_del_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_route_add_default_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_route_del_default_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_arp_add_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_arp_del_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_arp_add_default_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_arp_del_default_handler(struct pipeline *p,
- void *msg);
-
-static void *
-pipeline_routing_msg_req_set_macaddr_handler(struct pipeline *p,
- void *msg);
-
-static pipeline_msg_req_handler custom_handlers[] = {
- [PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD] =
- pipeline_routing_msg_req_route_add_handler,
- [PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL] =
- pipeline_routing_msg_req_route_del_handler,
- [PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT] =
- pipeline_routing_msg_req_route_add_default_handler,
- [PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT] =
- pipeline_routing_msg_req_route_del_default_handler,
- [PIPELINE_ROUTING_MSG_REQ_ARP_ADD] =
- pipeline_routing_msg_req_arp_add_handler,
- [PIPELINE_ROUTING_MSG_REQ_ARP_DEL] =
- pipeline_routing_msg_req_arp_del_handler,
- [PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT] =
- pipeline_routing_msg_req_arp_add_default_handler,
- [PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT] =
- pipeline_routing_msg_req_arp_del_default_handler,
- [PIPELINE_ROUTING_MSG_REQ_SET_MACADDR] =
- pipeline_routing_msg_req_set_macaddr_handler,
-};
-
-/*
- * Routing table
- */
-struct routing_table_entry {
- struct rte_pipeline_table_entry head;
- uint32_t flags;
- uint32_t port_id; /* Output port ID */
- uint32_t ip; /* Next hop IP address (only valid for remote routes) */
-
- /* ether_l2 */
- uint16_t data_offset;
- uint16_t ether_l2_length;
- uint64_t slab[4];
- uint16_t slab_offset[4];
-};
-
-struct layout {
- uint16_t a;
- uint32_t b;
- uint16_t c;
-} __attribute__((__packed__));
-
-#define MACADDR_DST_WRITE(slab_ptr, slab) \
-{ \
- struct layout *dst = (struct layout *) (slab_ptr); \
- struct layout *src = (struct layout *) &(slab); \
- \
- dst->b = src->b; \
- dst->c = src->c; \
-}
-
-static __rte_always_inline void
-pkt_work_routing(
- struct rte_mbuf *pkt,
- struct rte_pipeline_table_entry *table_entry,
- void *arg,
- int arp,
- int qinq,
- int qinq_sched,
- int mpls,
- int mpls_color_mark)
-{
- struct pipeline_routing *p_rt = arg;
-
- struct routing_table_entry *entry =
- (struct routing_table_entry *) table_entry;
-
- struct ipv4_hdr *ip = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT8_PTR(pkt, p_rt->params.ip_hdr_offset);
-
- enum rte_meter_color pkt_color = (enum rte_meter_color)
- RTE_MBUF_METADATA_UINT32(pkt, p_rt->params.color_offset);
-
- struct pipeline_routing_arp_key_ipv4 *arp_key =
- (struct pipeline_routing_arp_key_ipv4 *)
- RTE_MBUF_METADATA_UINT8_PTR(pkt, p_rt->params.arp_key_offset);
-
- uint64_t *slab0_ptr, *slab1_ptr, *slab2_ptr, *slab3_ptr, sched;
- uint32_t ip_da, nh_ip, port_id;
- uint16_t total_length, data_offset, ether_l2_length;
-
- /* Read */
- total_length = rte_bswap16(ip->total_length);
- ip_da = ip->dst_addr;
- data_offset = entry->data_offset;
- ether_l2_length = entry->ether_l2_length;
- slab0_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt, entry->slab_offset[0]);
- slab1_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt, entry->slab_offset[1]);
- slab2_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt, entry->slab_offset[2]);
- slab3_ptr = RTE_MBUF_METADATA_UINT64_PTR(pkt, entry->slab_offset[3]);
-
- if (arp) {
- port_id = entry->port_id;
- nh_ip = entry->ip;
- if (entry->flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- nh_ip = ip_da;
- }
-
- /* Compute */
- total_length += ether_l2_length;
-
- if (qinq && qinq_sched) {
- uint32_t dscp = ip->type_of_service >> 2;
- uint32_t svlan, cvlan, tc, tc_q;
-
- if (qinq_sched == 1) {
- uint64_t slab_qinq = rte_bswap64(entry->slab[0]);
-
- svlan = (slab_qinq >> 48) & 0xFFF;
- cvlan = (slab_qinq >> 16) & 0xFFF;
- tc = (dscp >> 2) & 0x3;
- tc_q = dscp & 0x3;
- } else {
- uint32_t ip_src = rte_bswap32(ip->src_addr);
-
- svlan = 0;
- cvlan = (ip_src >> 16) & 0xFFF;
- tc = (ip_src >> 2) & 0x3;
- tc_q = ip_src & 0x3;
- }
- sched = RTE_SCHED_PORT_HIERARCHY(svlan,
- cvlan,
- tc,
- tc_q,
- e_RTE_METER_GREEN);
- }
-
- /* Write */
- pkt->data_off = data_offset;
- pkt->data_len = total_length;
- pkt->pkt_len = total_length;
-
- if ((qinq == 0) && (mpls == 0)) {
- *slab0_ptr = entry->slab[0];
-
- if (arp == 0)
- MACADDR_DST_WRITE(slab1_ptr, entry->slab[1]);
- }
-
- if (qinq) {
- *slab0_ptr = entry->slab[0];
- *slab1_ptr = entry->slab[1];
-
- if (arp == 0)
- MACADDR_DST_WRITE(slab2_ptr, entry->slab[2]);
-
- if (qinq_sched) {
- pkt->hash.sched.lo = sched & 0xFFFFFFFF;
- pkt->hash.sched.hi = sched >> 32;
- }
- }
-
- if (mpls) {
- if (mpls_color_mark) {
- uint64_t mpls_exp = rte_bswap64(
- (MPLS_LABEL(0, pkt_color, 0, 0) << 32) |
- MPLS_LABEL(0, pkt_color, 0, 0));
-
- *slab0_ptr = entry->slab[0] | mpls_exp;
- *slab1_ptr = entry->slab[1] | mpls_exp;
- *slab2_ptr = entry->slab[2];
- } else {
- *slab0_ptr = entry->slab[0];
- *slab1_ptr = entry->slab[1];
- *slab2_ptr = entry->slab[2];
- }
-
- if (arp == 0)
- MACADDR_DST_WRITE(slab3_ptr, entry->slab[3]);
- }
-
- if (arp) {
- arp_key->port_id = port_id;
- arp_key->ip = nh_ip;
- }
-}
-
-static __rte_always_inline void
-pkt4_work_routing(
- struct rte_mbuf **pkts,
- struct rte_pipeline_table_entry **table_entries,
- void *arg,
- int arp,
- int qinq,
- int qinq_sched,
- int mpls,
- int mpls_color_mark)
-{
- struct pipeline_routing *p_rt = arg;
-
- struct routing_table_entry *entry0 =
- (struct routing_table_entry *) table_entries[0];
- struct routing_table_entry *entry1 =
- (struct routing_table_entry *) table_entries[1];
- struct routing_table_entry *entry2 =
- (struct routing_table_entry *) table_entries[2];
- struct routing_table_entry *entry3 =
- (struct routing_table_entry *) table_entries[3];
-
- struct ipv4_hdr *ip0 = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[0],
- p_rt->params.ip_hdr_offset);
- struct ipv4_hdr *ip1 = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[1],
- p_rt->params.ip_hdr_offset);
- struct ipv4_hdr *ip2 = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[2],
- p_rt->params.ip_hdr_offset);
- struct ipv4_hdr *ip3 = (struct ipv4_hdr *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[3],
- p_rt->params.ip_hdr_offset);
-
- enum rte_meter_color pkt0_color = (enum rte_meter_color)
- RTE_MBUF_METADATA_UINT32(pkts[0], p_rt->params.color_offset);
- enum rte_meter_color pkt1_color = (enum rte_meter_color)
- RTE_MBUF_METADATA_UINT32(pkts[1], p_rt->params.color_offset);
- enum rte_meter_color pkt2_color = (enum rte_meter_color)
- RTE_MBUF_METADATA_UINT32(pkts[2], p_rt->params.color_offset);
- enum rte_meter_color pkt3_color = (enum rte_meter_color)
- RTE_MBUF_METADATA_UINT32(pkts[3], p_rt->params.color_offset);
-
- struct pipeline_routing_arp_key_ipv4 *arp_key0 =
- (struct pipeline_routing_arp_key_ipv4 *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[0],
- p_rt->params.arp_key_offset);
- struct pipeline_routing_arp_key_ipv4 *arp_key1 =
- (struct pipeline_routing_arp_key_ipv4 *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[1],
- p_rt->params.arp_key_offset);
- struct pipeline_routing_arp_key_ipv4 *arp_key2 =
- (struct pipeline_routing_arp_key_ipv4 *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[2],
- p_rt->params.arp_key_offset);
- struct pipeline_routing_arp_key_ipv4 *arp_key3 =
- (struct pipeline_routing_arp_key_ipv4 *)
- RTE_MBUF_METADATA_UINT8_PTR(pkts[3],
- p_rt->params.arp_key_offset);
-
- uint64_t *slab0_ptr0, *slab1_ptr0, *slab2_ptr0, *slab3_ptr0;
- uint64_t *slab0_ptr1, *slab1_ptr1, *slab2_ptr1, *slab3_ptr1;
- uint64_t *slab0_ptr2, *slab1_ptr2, *slab2_ptr2, *slab3_ptr2;
- uint64_t *slab0_ptr3, *slab1_ptr3, *slab2_ptr3, *slab3_ptr3;
- uint64_t sched0, sched1, sched2, sched3;
-
- uint32_t ip_da0, nh_ip0, port_id0;
- uint32_t ip_da1, nh_ip1, port_id1;
- uint32_t ip_da2, nh_ip2, port_id2;
- uint32_t ip_da3, nh_ip3, port_id3;
-
- uint16_t total_length0, data_offset0, ether_l2_length0;
- uint16_t total_length1, data_offset1, ether_l2_length1;
- uint16_t total_length2, data_offset2, ether_l2_length2;
- uint16_t total_length3, data_offset3, ether_l2_length3;
-
- /* Read */
- total_length0 = rte_bswap16(ip0->total_length);
- total_length1 = rte_bswap16(ip1->total_length);
- total_length2 = rte_bswap16(ip2->total_length);
- total_length3 = rte_bswap16(ip3->total_length);
-
- ip_da0 = ip0->dst_addr;
- ip_da1 = ip1->dst_addr;
- ip_da2 = ip2->dst_addr;
- ip_da3 = ip3->dst_addr;
-
- data_offset0 = entry0->data_offset;
- data_offset1 = entry1->data_offset;
- data_offset2 = entry2->data_offset;
- data_offset3 = entry3->data_offset;
-
- ether_l2_length0 = entry0->ether_l2_length;
- ether_l2_length1 = entry1->ether_l2_length;
- ether_l2_length2 = entry2->ether_l2_length;
- ether_l2_length3 = entry3->ether_l2_length;
-
- slab0_ptr0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- entry0->slab_offset[0]);
- slab1_ptr0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- entry0->slab_offset[1]);
- slab2_ptr0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- entry0->slab_offset[2]);
- slab3_ptr0 = RTE_MBUF_METADATA_UINT64_PTR(pkts[0],
- entry0->slab_offset[3]);
-
- slab0_ptr1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- entry1->slab_offset[0]);
- slab1_ptr1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- entry1->slab_offset[1]);
- slab2_ptr1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- entry1->slab_offset[2]);
- slab3_ptr1 = RTE_MBUF_METADATA_UINT64_PTR(pkts[1],
- entry1->slab_offset[3]);
-
- slab0_ptr2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- entry2->slab_offset[0]);
- slab1_ptr2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- entry2->slab_offset[1]);
- slab2_ptr2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- entry2->slab_offset[2]);
- slab3_ptr2 = RTE_MBUF_METADATA_UINT64_PTR(pkts[2],
- entry2->slab_offset[3]);
-
- slab0_ptr3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- entry3->slab_offset[0]);
- slab1_ptr3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- entry3->slab_offset[1]);
- slab2_ptr3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- entry3->slab_offset[2]);
- slab3_ptr3 = RTE_MBUF_METADATA_UINT64_PTR(pkts[3],
- entry3->slab_offset[3]);
-
- if (arp) {
- port_id0 = entry0->port_id;
- nh_ip0 = entry0->ip;
- if (entry0->flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- nh_ip0 = ip_da0;
-
- port_id1 = entry1->port_id;
- nh_ip1 = entry1->ip;
- if (entry1->flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- nh_ip1 = ip_da1;
-
- port_id2 = entry2->port_id;
- nh_ip2 = entry2->ip;
- if (entry2->flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- nh_ip2 = ip_da2;
-
- port_id3 = entry3->port_id;
- nh_ip3 = entry3->ip;
- if (entry3->flags & PIPELINE_ROUTING_ROUTE_LOCAL)
- nh_ip3 = ip_da3;
- }
-
- /* Compute */
- total_length0 += ether_l2_length0;
- total_length1 += ether_l2_length1;
- total_length2 += ether_l2_length2;
- total_length3 += ether_l2_length3;
-
- if (qinq && qinq_sched) {
- uint32_t dscp0 = ip0->type_of_service >> 2;
- uint32_t dscp1 = ip1->type_of_service >> 2;
- uint32_t dscp2 = ip2->type_of_service >> 2;
- uint32_t dscp3 = ip3->type_of_service >> 2;
- uint32_t svlan0, cvlan0, tc0, tc_q0;
- uint32_t svlan1, cvlan1, tc1, tc_q1;
- uint32_t svlan2, cvlan2, tc2, tc_q2;
- uint32_t svlan3, cvlan3, tc3, tc_q3;
-
- if (qinq_sched == 1) {
- uint64_t slab_qinq0 = rte_bswap64(entry0->slab[0]);
- uint64_t slab_qinq1 = rte_bswap64(entry1->slab[0]);
- uint64_t slab_qinq2 = rte_bswap64(entry2->slab[0]);
- uint64_t slab_qinq3 = rte_bswap64(entry3->slab[0]);
-
- svlan0 = (slab_qinq0 >> 48) & 0xFFF;
- svlan1 = (slab_qinq1 >> 48) & 0xFFF;
- svlan2 = (slab_qinq2 >> 48) & 0xFFF;
- svlan3 = (slab_qinq3 >> 48) & 0xFFF;
-
- cvlan0 = (slab_qinq0 >> 16) & 0xFFF;
- cvlan1 = (slab_qinq1 >> 16) & 0xFFF;
- cvlan2 = (slab_qinq2 >> 16) & 0xFFF;
- cvlan3 = (slab_qinq3 >> 16) & 0xFFF;
-
- tc0 = (dscp0 >> 2) & 0x3;
- tc1 = (dscp1 >> 2) & 0x3;
- tc2 = (dscp2 >> 2) & 0x3;
- tc3 = (dscp3 >> 2) & 0x3;
-
- tc_q0 = dscp0 & 0x3;
- tc_q1 = dscp1 & 0x3;
- tc_q2 = dscp2 & 0x3;
- tc_q3 = dscp3 & 0x3;
- } else {
- uint32_t ip_src0 = rte_bswap32(ip0->src_addr);
- uint32_t ip_src1 = rte_bswap32(ip1->src_addr);
- uint32_t ip_src2 = rte_bswap32(ip2->src_addr);
- uint32_t ip_src3 = rte_bswap32(ip3->src_addr);
-
- svlan0 = 0;
- svlan1 = 0;
- svlan2 = 0;
- svlan3 = 0;
-
- cvlan0 = (ip_src0 >> 16) & 0xFFF;
- cvlan1 = (ip_src1 >> 16) & 0xFFF;
- cvlan2 = (ip_src2 >> 16) & 0xFFF;
- cvlan3 = (ip_src3 >> 16) & 0xFFF;
-
- tc0 = (ip_src0 >> 2) & 0x3;
- tc1 = (ip_src1 >> 2) & 0x3;
- tc2 = (ip_src2 >> 2) & 0x3;
- tc3 = (ip_src3 >> 2) & 0x3;
-
- tc_q0 = ip_src0 & 0x3;
- tc_q1 = ip_src1 & 0x3;
- tc_q2 = ip_src2 & 0x3;
- tc_q3 = ip_src3 & 0x3;
- }
-
- sched0 = RTE_SCHED_PORT_HIERARCHY(svlan0,
- cvlan0,
- tc0,
- tc_q0,
- e_RTE_METER_GREEN);
- sched1 = RTE_SCHED_PORT_HIERARCHY(svlan1,
- cvlan1,
- tc1,
- tc_q1,
- e_RTE_METER_GREEN);
- sched2 = RTE_SCHED_PORT_HIERARCHY(svlan2,
- cvlan2,
- tc2,
- tc_q2,
- e_RTE_METER_GREEN);
- sched3 = RTE_SCHED_PORT_HIERARCHY(svlan3,
- cvlan3,
- tc3,
- tc_q3,
- e_RTE_METER_GREEN);
-
- }
-
- /* Write */
- pkts[0]->data_off = data_offset0;
- pkts[1]->data_off = data_offset1;
- pkts[2]->data_off = data_offset2;
- pkts[3]->data_off = data_offset3;
-
- pkts[0]->data_len = total_length0;
- pkts[1]->data_len = total_length1;
- pkts[2]->data_len = total_length2;
- pkts[3]->data_len = total_length3;
-
- pkts[0]->pkt_len = total_length0;
- pkts[1]->pkt_len = total_length1;
- pkts[2]->pkt_len = total_length2;
- pkts[3]->pkt_len = total_length3;
-
- if ((qinq == 0) && (mpls == 0)) {
- *slab0_ptr0 = entry0->slab[0];
- *slab0_ptr1 = entry1->slab[0];
- *slab0_ptr2 = entry2->slab[0];
- *slab0_ptr3 = entry3->slab[0];
-
- if (arp == 0) {
- MACADDR_DST_WRITE(slab1_ptr0, entry0->slab[1]);
- MACADDR_DST_WRITE(slab1_ptr1, entry1->slab[1]);
- MACADDR_DST_WRITE(slab1_ptr2, entry2->slab[1]);
- MACADDR_DST_WRITE(slab1_ptr3, entry3->slab[1]);
- }
- }
-
- if (qinq) {
- *slab0_ptr0 = entry0->slab[0];
- *slab0_ptr1 = entry1->slab[0];
- *slab0_ptr2 = entry2->slab[0];
- *slab0_ptr3 = entry3->slab[0];
-
- *slab1_ptr0 = entry0->slab[1];
- *slab1_ptr1 = entry1->slab[1];
- *slab1_ptr2 = entry2->slab[1];
- *slab1_ptr3 = entry3->slab[1];
-
- if (arp == 0) {
- MACADDR_DST_WRITE(slab2_ptr0, entry0->slab[2]);
- MACADDR_DST_WRITE(slab2_ptr1, entry1->slab[2]);
- MACADDR_DST_WRITE(slab2_ptr2, entry2->slab[2]);
- MACADDR_DST_WRITE(slab2_ptr3, entry3->slab[2]);
- }
-
- if (qinq_sched) {
- pkts[0]->hash.sched.lo = sched0 & 0xFFFFFFFF;
- pkts[0]->hash.sched.hi = sched0 >> 32;
- pkts[1]->hash.sched.lo = sched1 & 0xFFFFFFFF;
- pkts[1]->hash.sched.hi = sched1 >> 32;
- pkts[2]->hash.sched.lo = sched2 & 0xFFFFFFFF;
- pkts[2]->hash.sched.hi = sched2 >> 32;
- pkts[3]->hash.sched.lo = sched3 & 0xFFFFFFFF;
- pkts[3]->hash.sched.hi = sched3 >> 32;
- }
- }
-
- if (mpls) {
- if (mpls_color_mark) {
- uint64_t mpls_exp0 = rte_bswap64(
- (MPLS_LABEL(0, pkt0_color, 0, 0) << 32) |
- MPLS_LABEL(0, pkt0_color, 0, 0));
- uint64_t mpls_exp1 = rte_bswap64(
- (MPLS_LABEL(0, pkt1_color, 0, 0) << 32) |
- MPLS_LABEL(0, pkt1_color, 0, 0));
- uint64_t mpls_exp2 = rte_bswap64(
- (MPLS_LABEL(0, pkt2_color, 0, 0) << 32) |
- MPLS_LABEL(0, pkt2_color, 0, 0));
- uint64_t mpls_exp3 = rte_bswap64(
- (MPLS_LABEL(0, pkt3_color, 0, 0) << 32) |
- MPLS_LABEL(0, pkt3_color, 0, 0));
-
- *slab0_ptr0 = entry0->slab[0] | mpls_exp0;
- *slab0_ptr1 = entry1->slab[0] | mpls_exp1;
- *slab0_ptr2 = entry2->slab[0] | mpls_exp2;
- *slab0_ptr3 = entry3->slab[0] | mpls_exp3;
-
- *slab1_ptr0 = entry0->slab[1] | mpls_exp0;
- *slab1_ptr1 = entry1->slab[1] | mpls_exp1;
- *slab1_ptr2 = entry2->slab[1] | mpls_exp2;
- *slab1_ptr3 = entry3->slab[1] | mpls_exp3;
-
- *slab2_ptr0 = entry0->slab[2];
- *slab2_ptr1 = entry1->slab[2];
- *slab2_ptr2 = entry2->slab[2];
- *slab2_ptr3 = entry3->slab[2];
- } else {
- *slab0_ptr0 = entry0->slab[0];
- *slab0_ptr1 = entry1->slab[0];
- *slab0_ptr2 = entry2->slab[0];
- *slab0_ptr3 = entry3->slab[0];
-
- *slab1_ptr0 = entry0->slab[1];
- *slab1_ptr1 = entry1->slab[1];
- *slab1_ptr2 = entry2->slab[1];
- *slab1_ptr3 = entry3->slab[1];
-
- *slab2_ptr0 = entry0->slab[2];
- *slab2_ptr1 = entry1->slab[2];
- *slab2_ptr2 = entry2->slab[2];
- *slab2_ptr3 = entry3->slab[2];
- }
-
- if (arp == 0) {
- MACADDR_DST_WRITE(slab3_ptr0, entry0->slab[3]);
- MACADDR_DST_WRITE(slab3_ptr1, entry1->slab[3]);
- MACADDR_DST_WRITE(slab3_ptr2, entry2->slab[3]);
- MACADDR_DST_WRITE(slab3_ptr3, entry3->slab[3]);
- }
- }
-
- if (arp) {
- arp_key0->port_id = port_id0;
- arp_key1->port_id = port_id1;
- arp_key2->port_id = port_id2;
- arp_key3->port_id = port_id3;
-
- arp_key0->ip = nh_ip0;
- arp_key1->ip = nh_ip1;
- arp_key2->ip = nh_ip2;
- arp_key3->ip = nh_ip3;
- }
-}
-
-#define PKT_WORK_ROUTING_ETHERNET(arp) \
-static inline void \
-pkt_work_routing_ether_arp##arp( \
- struct rte_mbuf *pkt, \
- struct rte_pipeline_table_entry *table_entry, \
- void *arg) \
-{ \
- pkt_work_routing(pkt, table_entry, arg, arp, 0, 0, 0, 0);\
-}
-
-#define PKT4_WORK_ROUTING_ETHERNET(arp) \
-static inline void \
-pkt4_work_routing_ether_arp##arp( \
- struct rte_mbuf **pkts, \
- struct rte_pipeline_table_entry **table_entries, \
- void *arg) \
-{ \
- pkt4_work_routing(pkts, table_entries, arg, arp, 0, 0, 0, 0);\
-}
-
-#define routing_table_ah_hit_ether(arp) \
-PKT_WORK_ROUTING_ETHERNET(arp) \
-PKT4_WORK_ROUTING_ETHERNET(arp) \
-PIPELINE_TABLE_AH_HIT(routing_table_ah_hit_ether_arp##arp, \
- pkt_work_routing_ether_arp##arp, \
- pkt4_work_routing_ether_arp##arp)
-
-routing_table_ah_hit_ether(0)
-routing_table_ah_hit_ether(1)
-
-#define PKT_WORK_ROUTING_ETHERNET_QINQ(sched, arp) \
-static inline void \
-pkt_work_routing_ether_qinq_sched##sched##_arp##arp( \
- struct rte_mbuf *pkt, \
- struct rte_pipeline_table_entry *table_entry, \
- void *arg) \
-{ \
- pkt_work_routing(pkt, table_entry, arg, arp, 1, sched, 0, 0);\
-}
-
-#define PKT4_WORK_ROUTING_ETHERNET_QINQ(sched, arp) \
-static inline void \
-pkt4_work_routing_ether_qinq_sched##sched##_arp##arp( \
- struct rte_mbuf **pkts, \
- struct rte_pipeline_table_entry **table_entries, \
- void *arg) \
-{ \
- pkt4_work_routing(pkts, table_entries, arg, arp, 1, sched, 0, 0);\
-}
-
-#define routing_table_ah_hit_ether_qinq(sched, arp) \
-PKT_WORK_ROUTING_ETHERNET_QINQ(sched, arp) \
-PKT4_WORK_ROUTING_ETHERNET_QINQ(sched, arp) \
-PIPELINE_TABLE_AH_HIT(routing_table_ah_hit_ether_qinq_sched##sched##_arp##arp,\
- pkt_work_routing_ether_qinq_sched##sched##_arp##arp, \
- pkt4_work_routing_ether_qinq_sched##sched##_arp##arp)
-
-routing_table_ah_hit_ether_qinq(0, 0)
-routing_table_ah_hit_ether_qinq(1, 0)
-routing_table_ah_hit_ether_qinq(2, 0)
-routing_table_ah_hit_ether_qinq(0, 1)
-routing_table_ah_hit_ether_qinq(1, 1)
-routing_table_ah_hit_ether_qinq(2, 1)
-
-#define PKT_WORK_ROUTING_ETHERNET_MPLS(color, arp) \
-static inline void \
-pkt_work_routing_ether_mpls_color##color##_arp##arp( \
- struct rte_mbuf *pkt, \
- struct rte_pipeline_table_entry *table_entry, \
- void *arg) \
-{ \
- pkt_work_routing(pkt, table_entry, arg, arp, 0, 0, 1, color);\
-}
-
-#define PKT4_WORK_ROUTING_ETHERNET_MPLS(color, arp) \
-static inline void \
-pkt4_work_routing_ether_mpls_color##color##_arp##arp( \
- struct rte_mbuf **pkts, \
- struct rte_pipeline_table_entry **table_entries, \
- void *arg) \
-{ \
- pkt4_work_routing(pkts, table_entries, arg, arp, 0, 0, 1, color);\
-}
-
-#define routing_table_ah_hit_ether_mpls(color, arp) \
-PKT_WORK_ROUTING_ETHERNET_MPLS(color, arp) \
-PKT4_WORK_ROUTING_ETHERNET_MPLS(color, arp) \
-PIPELINE_TABLE_AH_HIT(routing_table_ah_hit_ether_mpls_color##color##_arp##arp,\
- pkt_work_routing_ether_mpls_color##color##_arp##arp, \
- pkt4_work_routing_ether_mpls_color##color##_arp##arp)
-
-routing_table_ah_hit_ether_mpls(0, 0)
-routing_table_ah_hit_ether_mpls(1, 0)
-routing_table_ah_hit_ether_mpls(0, 1)
-routing_table_ah_hit_ether_mpls(1, 1)
-
-static rte_pipeline_table_action_handler_hit
-get_routing_table_ah_hit(struct pipeline_routing *p)
-{
- if (p->params.dbg_ah_disable)
- return NULL;
-
- switch (p->params.encap) {
- case PIPELINE_ROUTING_ENCAP_ETHERNET:
- return (p->params.n_arp_entries) ?
- routing_table_ah_hit_ether_arp1 :
- routing_table_ah_hit_ether_arp0;
-
- case PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ:
- if (p->params.n_arp_entries)
- switch (p->params.qinq_sched) {
- case 0:
- return routing_table_ah_hit_ether_qinq_sched0_arp1;
- case 1:
- return routing_table_ah_hit_ether_qinq_sched1_arp1;
- case 2:
- return routing_table_ah_hit_ether_qinq_sched2_arp1;
- default:
- return NULL;
- }
- else
- switch (p->params.qinq_sched) {
- case 0:
- return routing_table_ah_hit_ether_qinq_sched0_arp0;
- case 1:
- return routing_table_ah_hit_ether_qinq_sched1_arp0;
- case 2:
- return routing_table_ah_hit_ether_qinq_sched2_arp0;
- default:
- return NULL;
- }
-
- case PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS:
- if (p->params.n_arp_entries)
- if (p->params.mpls_color_mark)
- return routing_table_ah_hit_ether_mpls_color1_arp1;
- else
- return routing_table_ah_hit_ether_mpls_color0_arp1;
- else
- if (p->params.mpls_color_mark)
- return routing_table_ah_hit_ether_mpls_color1_arp0;
- else
- return routing_table_ah_hit_ether_mpls_color0_arp0;
-
- default:
- return NULL;
- }
-}
-
-/*
- * ARP table
- */
-struct arp_table_entry {
- struct rte_pipeline_table_entry head;
- uint64_t macaddr;
-};
-
-/**
- * ARP table AH
- */
-static inline void
-pkt_work_arp(
- struct rte_mbuf *pkt,
- struct rte_pipeline_table_entry *table_entry,
- __rte_unused void *arg)
-{
- struct arp_table_entry *entry = (struct arp_table_entry *) table_entry;
-
- /* Read */
- uint64_t macaddr_dst = entry->macaddr;
- uint64_t *slab_ptr = (uint64_t *) ((char *) pkt->buf_addr +
- (pkt->data_off - 2));
-
- /* Compute */
-
- /* Write */
- MACADDR_DST_WRITE(slab_ptr, macaddr_dst);
-}
-
-static inline void
-pkt4_work_arp(
- struct rte_mbuf **pkts,
- struct rte_pipeline_table_entry **table_entries,
- __rte_unused void *arg)
-{
- struct arp_table_entry *entry0 =
- (struct arp_table_entry *) table_entries[0];
- struct arp_table_entry *entry1 =
- (struct arp_table_entry *) table_entries[1];
- struct arp_table_entry *entry2 =
- (struct arp_table_entry *) table_entries[2];
- struct arp_table_entry *entry3 =
- (struct arp_table_entry *) table_entries[3];
-
- /* Read */
- uint64_t macaddr_dst0 = entry0->macaddr;
- uint64_t macaddr_dst1 = entry1->macaddr;
- uint64_t macaddr_dst2 = entry2->macaddr;
- uint64_t macaddr_dst3 = entry3->macaddr;
-
- uint64_t *slab_ptr0 = (uint64_t *) ((char *) pkts[0]->buf_addr +
- (pkts[0]->data_off - 2));
- uint64_t *slab_ptr1 = (uint64_t *) ((char *) pkts[1]->buf_addr +
- (pkts[1]->data_off - 2));
- uint64_t *slab_ptr2 = (uint64_t *) ((char *) pkts[2]->buf_addr +
- (pkts[2]->data_off - 2));
- uint64_t *slab_ptr3 = (uint64_t *) ((char *) pkts[3]->buf_addr +
- (pkts[3]->data_off - 2));
-
- /* Compute */
-
- /* Write */
- MACADDR_DST_WRITE(slab_ptr0, macaddr_dst0);
- MACADDR_DST_WRITE(slab_ptr1, macaddr_dst1);
- MACADDR_DST_WRITE(slab_ptr2, macaddr_dst2);
- MACADDR_DST_WRITE(slab_ptr3, macaddr_dst3);
-}
-
-PIPELINE_TABLE_AH_HIT(arp_table_ah_hit,
- pkt_work_arp,
- pkt4_work_arp);
-
-static rte_pipeline_table_action_handler_hit
-get_arp_table_ah_hit(struct pipeline_routing *p)
-{
- if (p->params.dbg_ah_disable)
- return NULL;
-
- return arp_table_ah_hit;
-}
-
-/*
- * Argument parsing
- */
-int
-pipeline_routing_parse_args(struct pipeline_routing_params *p,
- struct pipeline_params *params)
-{
- uint32_t n_routes_present = 0;
- uint32_t port_local_dest_present = 0;
- uint32_t encap_present = 0;
- uint32_t qinq_sched_present = 0;
- uint32_t mpls_color_mark_present = 0;
- uint32_t n_arp_entries_present = 0;
- uint32_t ip_hdr_offset_present = 0;
- uint32_t arp_key_offset_present = 0;
- uint32_t color_offset_present = 0;
- uint32_t dbg_ah_disable_present = 0;
- uint32_t i;
-
- /* default values */
- p->n_routes = PIPELINE_ROUTING_N_ROUTES_DEFAULT;
- p->port_local_dest = params->n_ports_out - 1;
- p->encap = PIPELINE_ROUTING_ENCAP_ETHERNET;
- p->qinq_sched = 0;
- p->mpls_color_mark = 0;
- p->n_arp_entries = 0;
- p->dbg_ah_disable = 0;
-
- for (i = 0; i < params->n_args; i++) {
- char *arg_name = params->args_name[i];
- char *arg_value = params->args_value[i];
-
- /* n_routes */
- if (strcmp(arg_name, "n_routes") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_routes_present == 0, params->name,
- arg_name);
- n_routes_present = 1;
-
- status = parser_read_uint32(&p->n_routes,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status != -EINVAL) &&
- (p->n_routes != 0)), params->name,
- arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
- /* port_local_dest */
- if (strcmp(arg_name, "port_local_dest") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- port_local_dest_present == 0, params->name,
- arg_name);
- port_local_dest_present = 1;
-
- status = parser_read_uint32(&p->port_local_dest,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL(((status == 0) &&
- (p->port_local_dest < params->n_ports_out)),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* encap */
- if (strcmp(arg_name, "encap") == 0) {
- PIPELINE_PARSE_ERR_DUPLICATE(encap_present == 0,
- params->name, arg_name);
- encap_present = 1;
-
- /* ethernet */
- if (strcmp(arg_value, "ethernet") == 0) {
- p->encap = PIPELINE_ROUTING_ENCAP_ETHERNET;
- continue;
- }
-
- /* ethernet_qinq */
- if (strcmp(arg_value, "ethernet_qinq") == 0) {
- p->encap = PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ;
- continue;
- }
-
- /* ethernet_mpls */
- if (strcmp(arg_value, "ethernet_mpls") == 0) {
- p->encap = PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS;
- continue;
- }
-
- /* any other */
- PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
- arg_name, arg_value);
- }
-
- /* qinq_sched */
- if (strcmp(arg_name, "qinq_sched") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- qinq_sched_present == 0, params->name,
- arg_name);
- qinq_sched_present = 1;
-
- status = parser_read_arg_bool(arg_value);
- if (status == -EINVAL) {
- if (strcmp(arg_value, "test") == 0) {
- p->qinq_sched = 2;
- continue;
- }
- } else {
- p->qinq_sched = status;
- continue;
- }
-
- PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
- arg_name, arg_value);
- }
-
- /* mpls_color_mark */
- if (strcmp(arg_name, "mpls_color_mark") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- mpls_color_mark_present == 0,
- params->name, arg_name);
- mpls_color_mark_present = 1;
-
-
- status = parser_read_arg_bool(arg_value);
- if (status >= 0) {
- p->mpls_color_mark = status;
- continue;
- }
-
- PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
- arg_name, arg_value);
- }
-
- /* n_arp_entries */
- if (strcmp(arg_name, "n_arp_entries") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- n_arp_entries_present == 0, params->name,
- arg_name);
- n_arp_entries_present = 1;
-
- status = parser_read_uint32(&p->n_arp_entries,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* ip_hdr_offset */
- if (strcmp(arg_name, "ip_hdr_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- ip_hdr_offset_present == 0, params->name,
- arg_name);
- ip_hdr_offset_present = 1;
-
- status = parser_read_uint32(&p->ip_hdr_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* arp_key_offset */
- if (strcmp(arg_name, "arp_key_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- arp_key_offset_present == 0, params->name,
- arg_name);
- arp_key_offset_present = 1;
-
- status = parser_read_uint32(&p->arp_key_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* color_offset */
- if (strcmp(arg_name, "color_offset") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- color_offset_present == 0, params->name,
- arg_name);
- color_offset_present = 1;
-
- status = parser_read_uint32(&p->color_offset,
- arg_value);
- PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
- params->name, arg_name, arg_value);
- PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
- params->name, arg_name, arg_value);
-
- continue;
- }
-
- /* debug */
- if (strcmp(arg_name, "dbg_ah_disable") == 0) {
- int status;
-
- PIPELINE_PARSE_ERR_DUPLICATE(
- dbg_ah_disable_present == 0, params->name,
- arg_name);
- dbg_ah_disable_present = 1;
-
- status = parser_read_arg_bool(arg_value);
- if (status >= 0) {
- p->dbg_ah_disable = status;
- continue;
- }
-
- PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
- arg_name, arg_value);
-
- continue;
- }
-
- /* any other */
- PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
- }
-
- /* Check that mandatory arguments are present */
- PIPELINE_PARSE_ERR_MANDATORY(ip_hdr_offset_present, params->name,
- "ip_hdr_offset");
-
- /* Check relations between arguments */
- switch (p->encap) {
- case PIPELINE_ROUTING_ENCAP_ETHERNET:
- PIPELINE_ARG_CHECK((!p->qinq_sched), "Parse error in "
- "section \"%s\": encap = ethernet, therefore "
- "qinq_sched = yes/test is not allowed",
- params->name);
- PIPELINE_ARG_CHECK((!p->mpls_color_mark), "Parse error "
- "in section \"%s\": encap = ethernet, therefore "
- "mpls_color_mark = yes is not allowed",
- params->name);
- PIPELINE_ARG_CHECK((!color_offset_present), "Parse error "
- "in section \"%s\": encap = ethernet, therefore "
- "color_offset is not allowed",
- params->name);
- break;
-
- case PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ:
- PIPELINE_ARG_CHECK((!p->mpls_color_mark), "Parse error "
- "in section \"%s\": encap = ethernet_qinq, "
- "therefore mpls_color_mark = yes is not allowed",
- params->name);
- PIPELINE_ARG_CHECK((!color_offset_present), "Parse error "
- "in section \"%s\": encap = ethernet_qinq, "
- "therefore color_offset is not allowed",
- params->name);
- break;
-
- case PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS:
- PIPELINE_ARG_CHECK((!p->qinq_sched), "Parse error in "
- "section \"%s\": encap = ethernet_mpls, therefore "
- "qinq_sched = yes/test is not allowed",
- params->name);
- break;
- }
-
- PIPELINE_ARG_CHECK((!(p->n_arp_entries &&
- (!arp_key_offset_present))), "Parse error in section "
- "\"%s\": n_arp_entries is set while "
- "arp_key_offset is not set", params->name);
-
- PIPELINE_ARG_CHECK((!((p->n_arp_entries == 0) &&
- arp_key_offset_present)), "Parse error in section "
- "\"%s\": arp_key_offset present while "
- "n_arp_entries is not set", params->name);
-
- return 0;
-}
-
-static void *
-pipeline_routing_init(struct pipeline_params *params,
- __rte_unused void *arg)
-{
- struct pipeline *p;
- struct pipeline_routing *p_rt;
- uint32_t size, i;
-
- /* Check input arguments */
- if ((params == NULL) ||
- (params->n_ports_in == 0) ||
- (params->n_ports_out == 0))
- return NULL;
-
- /* Memory allocation */
- size = RTE_CACHE_LINE_ROUNDUP(sizeof(struct pipeline_routing));
- p = rte_zmalloc(NULL, size, RTE_CACHE_LINE_SIZE);
- p_rt = (struct pipeline_routing *) p;
- if (p == NULL)
- return NULL;
-
- strcpy(p->name, params->name);
- p->log_level = params->log_level;
-
- PLOG(p, HIGH, "Routing");
-
- /* Parse arguments */
- if (pipeline_routing_parse_args(&p_rt->params, params))
- return NULL;
-
- /* Pipeline */
- {
- struct rte_pipeline_params pipeline_params = {
- .name = params->name,
- .socket_id = params->socket_id,
- .offset_port_id = 0,
- };
-
- p->p = rte_pipeline_create(&pipeline_params);
- if (p->p == NULL) {
- rte_free(p);
- return NULL;
- }
- }
-
- /* Input ports */
- p->n_ports_in = params->n_ports_in;
- for (i = 0; i < p->n_ports_in; i++) {
- struct rte_pipeline_port_in_params port_params = {
- .ops = pipeline_port_in_params_get_ops(
- &params->port_in[i]),
- .arg_create = pipeline_port_in_params_convert(
- &params->port_in[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- .burst_size = params->port_in[i].burst_size,
- };
-
- int status = rte_pipeline_port_in_create(p->p,
- &port_params,
- &p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Output ports */
- p->n_ports_out = params->n_ports_out;
- for (i = 0; i < p->n_ports_out; i++) {
- struct rte_pipeline_port_out_params port_params = {
- .ops = pipeline_port_out_params_get_ops(
- &params->port_out[i]),
- .arg_create = pipeline_port_out_params_convert(
- &params->port_out[i]),
- .f_action = NULL,
- .arg_ah = NULL,
- };
-
- int status = rte_pipeline_port_out_create(p->p,
- &port_params,
- &p->port_out_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Routing table */
- p->n_tables = 1;
- {
- struct rte_table_lpm_params table_lpm_params = {
- .name = p->name,
- .n_rules = p_rt->params.n_routes,
- .number_tbl8s = PIPELINE_ROUTING_LPM_TABLE_NUMBER_TABLE8s,
- .flags = 0,
- .entry_unique_size = sizeof(struct routing_table_entry),
- .offset = p_rt->params.ip_hdr_offset +
- __builtin_offsetof(struct ipv4_hdr, dst_addr),
- };
-
- struct rte_pipeline_table_params table_params = {
- .ops = &rte_table_lpm_ops,
- .arg_create = &table_lpm_params,
- .f_action_hit = get_routing_table_ah_hit(p_rt),
- .f_action_miss = NULL,
- .arg_ah = p_rt,
- .action_data_size =
- sizeof(struct routing_table_entry) -
- sizeof(struct rte_pipeline_table_entry),
- };
-
- int status;
-
- status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* ARP table configuration */
- if (p_rt->params.n_arp_entries) {
- struct rte_table_hash_params table_arp_params = {
- .name = p->name,
- .key_size = 8,
- .key_offset = p_rt->params.arp_key_offset,
- .key_mask = NULL,
- .n_keys = p_rt->params.n_arp_entries,
- .n_buckets =
- rte_align32pow2(p_rt->params.n_arp_entries / 4),
- .f_hash = hash_default_key8,
- .seed = 0,
- };
-
- struct rte_pipeline_table_params table_params = {
- .ops = &rte_table_hash_key8_ext_ops,
- .arg_create = &table_arp_params,
- .f_action_hit = get_arp_table_ah_hit(p_rt),
- .f_action_miss = NULL,
- .arg_ah = p_rt,
- .action_data_size = sizeof(struct arp_table_entry) -
- sizeof(struct rte_pipeline_table_entry),
- };
-
- int status;
-
- status = rte_pipeline_table_create(p->p,
- &table_params,
- &p->table_id[1]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- p->n_tables++;
- }
-
- /* Connecting input ports to tables */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_connect_to_table(p->p,
- p->port_in_id[i],
- p->table_id[0]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Enable input ports */
- for (i = 0; i < p->n_ports_in; i++) {
- int status = rte_pipeline_port_in_enable(p->p,
- p->port_in_id[i]);
-
- if (status) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
- }
-
- /* Check pipeline consistency */
- if (rte_pipeline_check(p->p) < 0) {
- rte_pipeline_free(p->p);
- rte_free(p);
- return NULL;
- }
-
- /* Message queues */
- p->n_msgq = params->n_msgq;
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_in[i] = params->msgq_in[i];
- for (i = 0; i < p->n_msgq; i++)
- p->msgq_out[i] = params->msgq_out[i];
-
- /* Message handlers */
- memcpy(p->handlers, handlers, sizeof(p->handlers));
- memcpy(p_rt->custom_handlers,
- custom_handlers,
- sizeof(p_rt->custom_handlers));
-
- return p;
-}
-
-static int
-pipeline_routing_free(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- /* Check input arguments */
- if (p == NULL)
- return -1;
-
- /* Free resources */
- rte_pipeline_free(p->p);
- rte_free(p);
- return 0;
-}
-
-static int
-pipeline_routing_timer(void *pipeline)
-{
- struct pipeline *p = (struct pipeline *) pipeline;
-
- pipeline_msg_req_handle(p);
- rte_pipeline_flush(p->p);
-
- return 0;
-}
-
-void *
-pipeline_routing_msg_req_custom_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_routing *p_rt = (struct pipeline_routing *) p;
- struct pipeline_custom_msg_req *req = msg;
- pipeline_msg_req_handler f_handle;
-
- f_handle = (req->subtype < PIPELINE_ROUTING_MSG_REQS) ?
- p_rt->custom_handlers[req->subtype] :
- pipeline_msg_req_invalid_handler;
-
- if (f_handle == NULL)
- f_handle = pipeline_msg_req_invalid_handler;
-
- return f_handle(p, req);
-}
-
-void *
-pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing *p_rt = (struct pipeline_routing *) p;
- struct pipeline_routing_route_add_msg_req *req = msg;
- struct pipeline_routing_route_add_msg_rsp *rsp = msg;
-
- struct rte_table_lpm_key key = {
- .ip = req->key.key.ipv4.ip,
- .depth = req->key.key.ipv4.depth,
- };
-
- struct routing_table_entry entry_arp0 = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->data.port_id]},
- },
-
- .flags = req->data.flags,
- .port_id = req->data.port_id,
- .ip = 0,
- .data_offset = 0,
- .ether_l2_length = 0,
- .slab = {0},
- .slab_offset = {0},
- };
-
- struct routing_table_entry entry_arp1 = {
- .head = {
- .action = RTE_PIPELINE_ACTION_TABLE,
- {.table_id = p->table_id[1]},
- },
-
- .flags = req->data.flags,
- .port_id = req->data.port_id,
- .ip = rte_bswap32(req->data.ethernet.ip),
- .data_offset = 0,
- .ether_l2_length = 0,
- .slab = {0},
- .slab_offset = {0},
- };
-
- struct rte_pipeline_table_entry *entry = (p_rt->params.n_arp_entries) ?
- (struct rte_pipeline_table_entry *) &entry_arp1 :
- (struct rte_pipeline_table_entry *) &entry_arp0;
-
- if ((req->key.type != PIPELINE_ROUTING_ROUTE_IPV4) ||
- ((p_rt->params.n_arp_entries == 0) &&
- (req->data.flags & PIPELINE_ROUTING_ROUTE_ARP)) ||
- (p_rt->params.n_arp_entries &&
- ((req->data.flags & PIPELINE_ROUTING_ROUTE_ARP) == 0)) ||
- ((p_rt->params.encap != PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ) &&
- (req->data.flags & PIPELINE_ROUTING_ROUTE_QINQ)) ||
- ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ) &&
- ((req->data.flags & PIPELINE_ROUTING_ROUTE_QINQ) == 0)) ||
- ((p_rt->params.encap != PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) &&
- (req->data.flags & PIPELINE_ROUTING_ROUTE_MPLS)) ||
- ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) &&
- ((req->data.flags & PIPELINE_ROUTING_ROUTE_MPLS) == 0))) {
- rsp->status = -1;
- return rsp;
- }
-
- /* Ether - ARP off */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET) &&
- (p_rt->params.n_arp_entries == 0)) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t macaddr_dst;
- uint64_t ethertype = ETHER_TYPE_IPv4;
-
- macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
- macaddr_dst = rte_bswap64(macaddr_dst << 16);
-
- entry_arp0.slab[0] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype);
- entry_arp0.slab_offset[0] = p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] = rte_bswap64(macaddr_dst);
- entry_arp0.slab_offset[1] = p_rt->params.ip_hdr_offset - 2 * 8;
-
- entry_arp0.data_offset = entry_arp0.slab_offset[1] + 2
- - sizeof(struct rte_mbuf);
- entry_arp0.ether_l2_length = 14;
- }
-
- /* Ether - ARP on */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET) &&
- p_rt->params.n_arp_entries) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t ethertype = ETHER_TYPE_IPv4;
-
- entry_arp1.slab[0] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype);
- entry_arp1.slab_offset[0] = p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.data_offset = entry_arp1.slab_offset[0] - 6
- - sizeof(struct rte_mbuf);
- entry_arp1.ether_l2_length = 14;
- }
-
- /* Ether QinQ - ARP off */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ) &&
- (p_rt->params.n_arp_entries == 0)) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t macaddr_dst;
- uint64_t ethertype_ipv4 = ETHER_TYPE_IPv4;
- uint64_t ethertype_vlan = 0x8100;
- uint64_t ethertype_qinq = 0x9100;
- uint64_t svlan = req->data.l2.qinq.svlan;
- uint64_t cvlan = req->data.l2.qinq.cvlan;
-
- macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
- macaddr_dst = rte_bswap64(macaddr_dst << 16);
-
- entry_arp0.slab[0] = rte_bswap64((svlan << 48) |
- (ethertype_vlan << 32) |
- (cvlan << 16) |
- ethertype_ipv4);
- entry_arp0.slab_offset[0] = p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype_qinq);
- entry_arp0.slab_offset[1] = p_rt->params.ip_hdr_offset - 2 * 8;
-
- entry_arp0.slab[2] = rte_bswap64(macaddr_dst);
- entry_arp0.slab_offset[2] = p_rt->params.ip_hdr_offset - 3 * 8;
-
- entry_arp0.data_offset = entry_arp0.slab_offset[2] + 2
- - sizeof(struct rte_mbuf);
- entry_arp0.ether_l2_length = 22;
- }
-
- /* Ether QinQ - ARP on */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ) &&
- p_rt->params.n_arp_entries) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t ethertype_ipv4 = ETHER_TYPE_IPv4;
- uint64_t ethertype_vlan = 0x8100;
- uint64_t ethertype_qinq = 0x9100;
- uint64_t svlan = req->data.l2.qinq.svlan;
- uint64_t cvlan = req->data.l2.qinq.cvlan;
-
- entry_arp1.slab[0] = rte_bswap64((svlan << 48) |
- (ethertype_vlan << 32) |
- (cvlan << 16) |
- ethertype_ipv4);
- entry_arp1.slab_offset[0] = p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.slab[1] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype_qinq);
- entry_arp1.slab_offset[1] = p_rt->params.ip_hdr_offset - 2 * 8;
-
- entry_arp1.data_offset = entry_arp1.slab_offset[1] - 6
- - sizeof(struct rte_mbuf);
- entry_arp1.ether_l2_length = 22;
- }
-
- /* Ether MPLS - ARP off */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) &&
- (p_rt->params.n_arp_entries == 0)) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t macaddr_dst;
- uint64_t ethertype_mpls = 0x8847;
-
- uint64_t label0 = req->data.l2.mpls.labels[0];
- uint64_t label1 = req->data.l2.mpls.labels[1];
- uint64_t label2 = req->data.l2.mpls.labels[2];
- uint64_t label3 = req->data.l2.mpls.labels[3];
- uint32_t n_labels = req->data.l2.mpls.n_labels;
-
- macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr));
- macaddr_dst = rte_bswap64(macaddr_dst << 16);
-
- switch (n_labels) {
- case 1:
- entry_arp0.slab[0] = 0;
- entry_arp0.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] = rte_bswap64(
- MPLS_LABEL(label0, 0, 1, 0));
- entry_arp0.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 8;
- break;
-
- case 2:
- entry_arp0.slab[0] = 0;
- entry_arp0.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] = rte_bswap64(
- (MPLS_LABEL(label0, 0, 0, 0) << 32) |
- MPLS_LABEL(label1, 0, 1, 0));
- entry_arp0.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 8;
- break;
-
- case 3:
- entry_arp0.slab[0] = rte_bswap64(
- (MPLS_LABEL(label1, 0, 0, 0) << 32) |
- MPLS_LABEL(label2, 0, 1, 0));
- entry_arp0.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] = rte_bswap64(
- MPLS_LABEL(label0, 0, 0, 0));
- entry_arp0.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 2 * 8;
- break;
-
- case 4:
- entry_arp0.slab[0] = rte_bswap64(
- (MPLS_LABEL(label2, 0, 0, 0) << 32) |
- MPLS_LABEL(label3, 0, 1, 0));
- entry_arp0.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp0.slab[1] = rte_bswap64(
- (MPLS_LABEL(label0, 0, 0, 0) << 32) |
- MPLS_LABEL(label1, 0, 0, 0));
- entry_arp0.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 2 * 8;
- break;
-
- default:
- rsp->status = -1;
- return rsp;
- }
-
- entry_arp0.slab[2] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype_mpls);
- entry_arp0.slab_offset[2] = p_rt->params.ip_hdr_offset -
- (n_labels * 4 + 8);
-
- entry_arp0.slab[3] = rte_bswap64(macaddr_dst);
- entry_arp0.slab_offset[3] = p_rt->params.ip_hdr_offset -
- (n_labels * 4 + 2 * 8);
-
- entry_arp0.data_offset = entry_arp0.slab_offset[3] + 2
- - sizeof(struct rte_mbuf);
- entry_arp0.ether_l2_length = n_labels * 4 + 14;
- }
-
- /* Ether MPLS - ARP on */
- if ((p_rt->params.encap == PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS) &&
- p_rt->params.n_arp_entries) {
- uint64_t macaddr_src = p_rt->macaddr[req->data.port_id];
- uint64_t ethertype_mpls = 0x8847;
-
- uint64_t label0 = req->data.l2.mpls.labels[0];
- uint64_t label1 = req->data.l2.mpls.labels[1];
- uint64_t label2 = req->data.l2.mpls.labels[2];
- uint64_t label3 = req->data.l2.mpls.labels[3];
- uint32_t n_labels = req->data.l2.mpls.n_labels;
-
- switch (n_labels) {
- case 1:
- entry_arp1.slab[0] = 0;
- entry_arp1.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.slab[1] = rte_bswap64(
- MPLS_LABEL(label0, 0, 1, 0));
- entry_arp1.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 8;
- break;
-
- case 2:
- entry_arp1.slab[0] = 0;
- entry_arp1.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.slab[1] = rte_bswap64(
- (MPLS_LABEL(label0, 0, 0, 0) << 32) |
- MPLS_LABEL(label1, 0, 1, 0));
- entry_arp1.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 8;
- break;
-
- case 3:
- entry_arp1.slab[0] = rte_bswap64(
- (MPLS_LABEL(label1, 0, 0, 0) << 32) |
- MPLS_LABEL(label2, 0, 1, 0));
- entry_arp1.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.slab[1] = rte_bswap64(
- MPLS_LABEL(label0, 0, 0, 0));
- entry_arp1.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 2 * 8;
- break;
-
- case 4:
- entry_arp1.slab[0] = rte_bswap64(
- (MPLS_LABEL(label2, 0, 0, 0) << 32) |
- MPLS_LABEL(label3, 0, 1, 0));
- entry_arp1.slab_offset[0] =
- p_rt->params.ip_hdr_offset - 8;
-
- entry_arp1.slab[1] = rte_bswap64(
- (MPLS_LABEL(label0, 0, 0, 0) << 32) |
- MPLS_LABEL(label1, 0, 0, 0));
- entry_arp1.slab_offset[1] =
- p_rt->params.ip_hdr_offset - 2 * 8;
- break;
-
- default:
- rsp->status = -1;
- return rsp;
- }
-
- entry_arp1.slab[2] =
- SLAB_NBO_MACADDRSRC_ETHERTYPE(macaddr_src, ethertype_mpls);
- entry_arp1.slab_offset[2] = p_rt->params.ip_hdr_offset -
- (n_labels * 4 + 8);
-
- entry_arp1.data_offset = entry_arp1.slab_offset[2] - 6
- - sizeof(struct rte_mbuf);
- entry_arp1.ether_l2_length = n_labels * 4 + 14;
- }
-
- rsp->status = rte_pipeline_table_entry_add(p->p,
- p->table_id[0],
- &key,
- entry,
- &rsp->key_found,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_route_del_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing_route_delete_msg_req *req = msg;
- struct pipeline_routing_route_delete_msg_rsp *rsp = msg;
-
- struct rte_table_lpm_key key = {
- .ip = req->key.key.ipv4.ip,
- .depth = req->key.key.ipv4.depth,
- };
-
- if (req->key.type != PIPELINE_ROUTING_ROUTE_IPV4) {
- rsp->status = -1;
- return rsp;
- }
-
- rsp->status = rte_pipeline_table_entry_delete(p->p,
- p->table_id[0],
- &key,
- &rsp->key_found,
- NULL);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_route_add_default_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_routing_route_add_default_msg_req *req = msg;
- struct pipeline_routing_route_add_default_msg_rsp *rsp = msg;
-
- struct routing_table_entry default_entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
-
- .flags = 0,
- .port_id = 0,
- .ip = 0,
- };
-
- rsp->status = rte_pipeline_table_default_entry_add(p->p,
- p->table_id[0],
- (struct rte_pipeline_table_entry *) &default_entry,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_route_del_default_handler(struct pipeline *p,
- void *msg)
-{
- struct pipeline_routing_route_delete_default_msg_rsp *rsp = msg;
-
- rsp->status = rte_pipeline_table_default_entry_delete(p->p,
- p->table_id[0],
- NULL);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_arp_add_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing_arp_add_msg_req *req = msg;
- struct pipeline_routing_arp_add_msg_rsp *rsp = msg;
-
- struct pipeline_routing_arp_key_ipv4 key = {
- .port_id = req->key.key.ipv4.port_id,
- .ip = rte_bswap32(req->key.key.ipv4.ip),
- };
-
- struct arp_table_entry entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->key.key.ipv4.port_id]},
- },
-
- .macaddr = 0, /* set below */
- };
-
- if (req->key.type != PIPELINE_ROUTING_ARP_IPV4) {
- rsp->status = -1;
- return rsp;
- }
-
- entry.macaddr = *((uint64_t *)&(req->macaddr));
- entry.macaddr = entry.macaddr << 16;
-
- rsp->status = rte_pipeline_table_entry_add(p->p,
- p->table_id[1],
- &key,
- (struct rte_pipeline_table_entry *) &entry,
- &rsp->key_found,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_arp_del_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing_arp_delete_msg_req *req = msg;
- struct pipeline_routing_arp_delete_msg_rsp *rsp = msg;
-
- struct pipeline_routing_arp_key_ipv4 key = {
- .port_id = req->key.key.ipv4.port_id,
- .ip = rte_bswap32(req->key.key.ipv4.ip),
- };
-
- if (req->key.type != PIPELINE_ROUTING_ARP_IPV4) {
- rsp->status = -1;
- return rsp;
- }
-
- rsp->status = rte_pipeline_table_entry_delete(p->p,
- p->table_id[1],
- &key,
- &rsp->key_found,
- NULL);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_arp_add_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing_arp_add_default_msg_req *req = msg;
- struct pipeline_routing_arp_add_default_msg_rsp *rsp = msg;
-
- struct arp_table_entry default_entry = {
- .head = {
- .action = RTE_PIPELINE_ACTION_PORT,
- {.port_id = p->port_out_id[req->port_id]},
- },
-
- .macaddr = 0,
- };
-
- rsp->status = rte_pipeline_table_default_entry_add(p->p,
- p->table_id[1],
- (struct rte_pipeline_table_entry *) &default_entry,
- (struct rte_pipeline_table_entry **) &rsp->entry_ptr);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_arp_del_default_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing_arp_delete_default_msg_rsp *rsp = msg;
-
- rsp->status = rte_pipeline_table_default_entry_delete(p->p,
- p->table_id[1],
- NULL);
-
- return rsp;
-}
-
-void *
-pipeline_routing_msg_req_set_macaddr_handler(struct pipeline *p, void *msg)
-{
- struct pipeline_routing *p_rt = (struct pipeline_routing *) p;
- struct pipeline_routing_set_macaddr_msg_req *req = msg;
- struct pipeline_routing_set_macaddr_msg_rsp *rsp = msg;
- uint32_t port_id;
-
- for (port_id = 0; port_id < p->n_ports_out; port_id++)
- p_rt->macaddr[port_id] = req->macaddr[port_id];
-
- rsp->status = 0;
-
- return rsp;
-}
-
-struct pipeline_be_ops pipeline_routing_be_ops = {
- .f_init = pipeline_routing_init,
- .f_free = pipeline_routing_free,
- .f_run = NULL,
- .f_timer = pipeline_routing_timer,
-};
diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.h b/examples/ip_pipeline/pipeline/pipeline_routing_be.h
deleted file mode 100644
index 7140ee40..00000000
--- a/examples/ip_pipeline/pipeline/pipeline_routing_be.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2015 Intel Corporation
- */
-
-#ifndef __INCLUDE_PIPELINE_ROUTING_BE_H__
-#define __INCLUDE_PIPELINE_ROUTING_BE_H__
-
-#include <rte_ether.h>
-
-#include "pipeline_common_be.h"
-
-/*
- * Pipeline argument parsing
- */
-#ifndef PIPELINE_ROUTING_N_ROUTES_DEFAULT
-#define PIPELINE_ROUTING_N_ROUTES_DEFAULT 4096
-#endif
-
-enum pipeline_routing_encap {
- PIPELINE_ROUTING_ENCAP_ETHERNET = 0,
- PIPELINE_ROUTING_ENCAP_ETHERNET_QINQ,
- PIPELINE_ROUTING_ENCAP_ETHERNET_MPLS,
-};
-
-struct pipeline_routing_params {
- /* routing */
- uint32_t n_routes;
- uint32_t port_local_dest;
-
- /* routing packet encapsulation */
- enum pipeline_routing_encap encap;
- uint32_t qinq_sched;
- uint32_t mpls_color_mark;
-
- /* arp */
- uint32_t n_arp_entries;
-
- /* packet buffer offsets */
- uint32_t ip_hdr_offset;
- uint32_t arp_key_offset;
- uint32_t color_offset;
-
- /* debug */
- uint32_t dbg_ah_disable;
-};
-
-int
-pipeline_routing_parse_args(struct pipeline_routing_params *p,
- struct pipeline_params *params);
-
-/*
- * Route
- */
-enum pipeline_routing_route_key_type {
- PIPELINE_ROUTING_ROUTE_IPV4,
-};
-
-struct pipeline_routing_route_key_ipv4 {
- uint32_t ip;
- uint32_t depth;
-};
-
-struct pipeline_routing_route_key {
- enum pipeline_routing_route_key_type type;
- union {
- struct pipeline_routing_route_key_ipv4 ipv4;
- } key;
-};
-
-enum pipeline_routing_route_flags {
- PIPELINE_ROUTING_ROUTE_LOCAL = 1 << 0, /* 0 = remote; 1 = local */
- PIPELINE_ROUTING_ROUTE_ARP = 1 << 1, /* 0 = ARP OFF; 1 = ARP ON */
- PIPELINE_ROUTING_ROUTE_QINQ = 1 << 2, /* 0 = QINQ OFF; 1 = QINQ ON */
- PIPELINE_ROUTING_ROUTE_MPLS = 1 << 3, /* 0 = MPLS OFF; 1 = MPLS ON */
-};
-
-#define PIPELINE_ROUTING_MPLS_LABELS_MAX 4
-
-struct pipeline_routing_route_data {
- uint32_t flags;
- uint32_t port_id; /* Output port ID */
-
- union {
- /* Next hop IP (valid only when ARP is enabled) */
- uint32_t ip;
-
- /* Next hop MAC address (valid only when ARP disabled */
- struct ether_addr macaddr;
- } ethernet;
-
- union {
- struct {
- uint16_t svlan;
- uint16_t cvlan;
- } qinq;
-
- struct {
- uint32_t labels[PIPELINE_ROUTING_MPLS_LABELS_MAX];
- uint32_t n_labels;
- } mpls;
- } l2;
-};
-
-/*
- * ARP
- */
-enum pipeline_routing_arp_key_type {
- PIPELINE_ROUTING_ARP_IPV4,
-};
-
-struct pipeline_routing_arp_key_ipv4 {
- uint32_t port_id;
- uint32_t ip;
-};
-
-struct pipeline_routing_arp_key {
- enum pipeline_routing_arp_key_type type;
- union {
- struct pipeline_routing_arp_key_ipv4 ipv4;
- } key;
-};
-
-/*
- * Messages
- */
-enum pipeline_routing_msg_req_type {
- PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD,
- PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL,
- PIPELINE_ROUTING_MSG_REQ_ROUTE_ADD_DEFAULT,
- PIPELINE_ROUTING_MSG_REQ_ROUTE_DEL_DEFAULT,
- PIPELINE_ROUTING_MSG_REQ_ARP_ADD,
- PIPELINE_ROUTING_MSG_REQ_ARP_DEL,
- PIPELINE_ROUTING_MSG_REQ_ARP_ADD_DEFAULT,
- PIPELINE_ROUTING_MSG_REQ_ARP_DEL_DEFAULT,
- PIPELINE_ROUTING_MSG_REQ_SET_MACADDR,
- PIPELINE_ROUTING_MSG_REQS
-};
-
-/*
- * MSG ROUTE ADD
- */
-struct pipeline_routing_route_add_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* key */
- struct pipeline_routing_route_key key;
-
- /* data */
- struct pipeline_routing_route_data data;
-};
-
-struct pipeline_routing_route_add_msg_rsp {
- int status;
- int key_found;
- void *entry_ptr;
-};
-
-/*
- * MSG ROUTE DELETE
- */
-struct pipeline_routing_route_delete_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* key */
- struct pipeline_routing_route_key key;
-};
-
-struct pipeline_routing_route_delete_msg_rsp {
- int status;
- int key_found;
-};
-
-/*
- * MSG ROUTE ADD DEFAULT
- */
-struct pipeline_routing_route_add_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* data */
- uint32_t port_id;
-};
-
-struct pipeline_routing_route_add_default_msg_rsp {
- int status;
- void *entry_ptr;
-};
-
-/*
- * MSG ROUTE DELETE DEFAULT
- */
-struct pipeline_routing_route_delete_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-};
-
-struct pipeline_routing_route_delete_default_msg_rsp {
- int status;
-};
-
-/*
- * MSG ARP ADD
- */
-struct pipeline_routing_arp_add_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* key */
- struct pipeline_routing_arp_key key;
-
- /* data */
- struct ether_addr macaddr;
-};
-
-struct pipeline_routing_arp_add_msg_rsp {
- int status;
- int key_found;
- void *entry_ptr;
-};
-
-/*
- * MSG ARP DELETE
- */
-struct pipeline_routing_arp_delete_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* key */
- struct pipeline_routing_arp_key key;
-};
-
-struct pipeline_routing_arp_delete_msg_rsp {
- int status;
- int key_found;
-};
-
-/*
- * MSG ARP ADD DEFAULT
- */
-struct pipeline_routing_arp_add_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- /* data */
- uint32_t port_id;
-};
-
-struct pipeline_routing_arp_add_default_msg_rsp {
- int status;
- void *entry_ptr;
-};
-
-/*
- * MSG ARP DELETE DEFAULT
- */
-struct pipeline_routing_arp_delete_default_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-};
-
-struct pipeline_routing_arp_delete_default_msg_rsp {
- int status;
-};
-
-/*
- * MSG SET MACADDR
- */
-struct pipeline_routing_set_macaddr_msg_req {
- enum pipeline_msg_req_type type;
- enum pipeline_routing_msg_req_type subtype;
-
- uint64_t macaddr[PIPELINE_MAX_PORT_OUT];
-};
-
-struct pipeline_routing_set_macaddr_msg_rsp {
- int status;
-};
-
-extern struct pipeline_be_ops pipeline_routing_be_ops;
-
-#endif