Skip to content

Commit

Permalink
Merge ODP linux-generic v1.25.2.0
Browse files Browse the repository at this point in the history
Merge ODP linux-generic v1.25.2.0 into ODP-DPDK.
  • Loading branch information
MatiasElo authored Jan 15, 2021
2 parents 041cfc4 + 8bdd456 commit 0ecc932
Show file tree
Hide file tree
Showing 190 changed files with 8,833 additions and 3,763 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: webispy/checkpatch-action@v7

- name: Check push
if: github.event_name == 'push'
if: github.event_name == 'push' && github.ref != 'refs/heads/master'
run: |
AFTER=${{ github.event.after }}
BEFORE=${{ github.event.before }}
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ AC_PREREQ([2.5])
##########################################################################
m4_define([odpapi_generation_version], [1])
m4_define([odpapi_major_version], [25])
m4_define([odpapi_minor_version], [0])
m4_define([odpapi_minor_version], [2])
m4_define([odpapi_point_version], [0])
m4_define([odpapi_version],
[odpapi_generation_version.odpapi_major_version.odpapi_minor_version.odpapi_point_version])
Expand All @@ -22,7 +22,7 @@ AC_SUBST(ODP_VERSION_API_MINOR)
##########################################################################
m4_define([odph_version_generation], [1])
m4_define([odph_version_major], [0])
m4_define([odph_version_minor], [3])
m4_define([odph_version_minor], [4])

m4_define([odph_version],
[odph_version_generation.odph_version_major.odph_version_minor])
Expand Down
1 change: 1 addition & 0 deletions example/classifier/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
odp_classifier
pktio_env
29 changes: 29 additions & 0 deletions example/classifier/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,32 @@ include $(top_srcdir)/example/Makefile.inc
bin_PROGRAMS = odp_classifier

odp_classifier_SOURCES = odp_classifier.c

if test_example
if ODP_PKTIO_PCAP
TESTS = odp_classifier_run.sh
endif
endif
EXTRA_DIST = odp_classifier_run.sh udp64.pcap

# If building out-of-tree, make check will not copy the scripts and data to the
# $(builddir) assuming that all commands are run locally. However this prevents
# running tests on a remote target using LOG_COMPILER.
# So copy all script and data files explicitly here.
all-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
if [ -e $(srcdir)/$$f ]; then \
mkdir -p $(builddir)/$$(dirname $$f); \
cp -f $(srcdir)/$$f $(builddir)/$$f; \
fi \
done \
fi
ln -f -s $(top_srcdir)/platform/$(with_platform)/test/example/classifier/pktio_env \
pktio_env
clean-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
rm -f $(builddir)/$$f; \
done \
fi
95 changes: 94 additions & 1 deletion example/classifier/odp_classifier.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* Copyright (c) 2015-2018, Linaro Limited
* Copyright (c) 2019-2020, Nokia
* Copyright (C) 2020, Marvell
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -73,9 +74,16 @@ typedef struct {

} global_statistics;

typedef struct {
char cos_name[ODP_COS_NAME_LEN];
uint64_t count;
} ci_pass_counters;

typedef struct {
global_statistics stats[MAX_PMR_COUNT];
ci_pass_counters ci_pass_rules[MAX_PMR_COUNT];
int policy_count; /**< global policy count */
int num_ci_pass_rules; /**< ci pass count */
int appl_mode; /**< application mode */
odp_atomic_u64_t total_packets; /**< total received packets */
unsigned int cpu_count; /**< Number of CPUs to use */
Expand All @@ -100,6 +108,38 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args);
static void print_info(char *progname, appl_args_t *appl_args);
static void usage(void);

static inline int check_ci_pass_count(appl_args_t *args)
{
int i, j;
uint64_t count;

if (args->num_ci_pass_rules == 0)
return 0;

for (i = 0; i < args->num_ci_pass_rules; i++) {
for (j = 0; j < args->policy_count; j++) {
if (!strcmp(args->stats[j].cos_name,
args->ci_pass_rules[i].cos_name)) {
count = odp_atomic_load_u64(&args->stats[i].queue_pkt_count);
if (args->ci_pass_rules[i].count > count) {
ODPH_ERR("Error: Cos = %s, expected packets = %" PRIu64 ","
"received packet = %" PRIu64 "\n",
args->stats[j].cos_name,
args->ci_pass_rules[i].count, count);
return -1;
}
break;
}
}
if (j == args->policy_count) {
ODPH_ERR("Error: invalid Cos:%s specified for CI pass count\n",
args->ci_pass_rules[i].cos_name);
return -1;
}
}
return 0;
}

static inline void print_cls_statistics(appl_args_t *args)
{
int i;
Expand Down Expand Up @@ -670,6 +710,11 @@ int main(int argc, char *argv[])
args->shutdown = 1;
odph_thread_join(thread_tbl, num_workers);

if (check_ci_pass_count(args)) {
ODPH_ERR("Error: Packet count verification failed\n");
exit(EXIT_FAILURE);
}

for (i = 0; i < args->policy_count; i++) {
if ((i != args->policy_count - 1) &&
odp_cls_pmr_destroy(args->stats[i].pmr))
Expand Down Expand Up @@ -1006,6 +1051,42 @@ static int parse_pmr_policy(appl_args_t *appl_args, char *optarg)
return 0;
}

static int parse_policy_ci_pass_count(appl_args_t *appl_args, char *optarg)
{
int num_ci_pass_rules;
char *token, *value;
size_t len;
ci_pass_counters *ci_pass_rules;
char *count_str;

num_ci_pass_rules = appl_args->num_ci_pass_rules;
ci_pass_rules = appl_args->ci_pass_rules;

/* last array index is needed for default queue */
if (num_ci_pass_rules >= MAX_PMR_COUNT) {
ODPH_ERR("Too many ci pass counters. Max count is %i.\n",
MAX_PMR_COUNT);
return -1;
}

len = strlen(optarg);
len++;
count_str = malloc(len);
strcpy(count_str, optarg);

token = strtok(count_str, ":");
value = strtok(NULL, ":");
if (!token || !value) {
free(count_str);
return -1;
}
strcpy(ci_pass_rules[num_ci_pass_rules].cos_name, token);
ci_pass_rules[num_ci_pass_rules].count = atoll(value);
appl_args->num_ci_pass_rules++;
free(count_str);
return 0;
}

/**
* Parse and store the command line arguments
*
Expand All @@ -1029,13 +1110,14 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args)
{"policy", required_argument, NULL, 'p'},
{"mode", required_argument, NULL, 'm'},
{"time", required_argument, NULL, 't'},
{"ci_pass", required_argument, NULL, 'C'},
{"promisc_mode", no_argument, NULL, 'P'},
{"verbose", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};

static const char *shortopts = "+c:t:i:p:m:t:Pvh";
static const char *shortopts = "+c:t:i:p:m:t:C:Pvh";

appl_args->cpu_count = 1; /* Use one worker by default */
appl_args->verbose = 0;
Expand Down Expand Up @@ -1086,6 +1168,12 @@ static int parse_args(int argc, char *argv[], appl_args_t *appl_args)
else
appl_args->appl_mode = APPL_MODE_REPLY;
break;
case 'C':
if (parse_policy_ci_pass_count(appl_args, optarg)) {
ret = -1;
break;
}
break;
case 'P':
appl_args->promisc_mode = 1;
break;
Expand Down Expand Up @@ -1176,6 +1264,11 @@ static void usage(void)
" 0: Runs in infinite loop\n"
" default: Runs in infinite loop\n"
"\n"
" -C, --ci_pass <dst queue:count>\n"
" Minimum acceptable packet count for a CoS destination queue.\n"
" If the received packet count is smaller than this value,\n"
" the application will exit with an error.\n"
" E.g: -C \"queue1:100\" -C \"queue2:200\" -C \"DefaultQueue:100\"\n"
" -P, --promisc_mode Enable promiscuous mode.\n"
" -v, --verbose Verbose output.\n"
" -h, --help Display help and exit.\n"
Expand Down
34 changes: 34 additions & 0 deletions example/classifier/odp_classifier_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
#
# Copyright (c) 2020, Marvell
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

if [ -f ./pktio_env ]; then
. ./pktio_env
else
echo "BUG: unable to find pktio_env!"
echo "pktio_env has to be in current directory"
exit 1
fi

setup_interfaces

./odp_classifier${EXEEXT} -t $TIME_OUT_VAL -i $IF0 -m 0 -p \
"ODP_PMR_SIP_ADDR:10.10.10.0:0xFFFFFF00:queue1" -P -C "queue1:${CPASS_COUNT_ARG1}" \
-C "DefaultCos:${CPASS_COUNT_ARG2}"

STATUS=$?

if [ ${STATUS} -ne 0 ]; then
echo "Error: status ${STATUS}"
exit 1
fi

validate_result

cleanup_interfaces

exit 0
Binary file added example/classifier/udp64.pcap
Binary file not shown.
1 change: 1 addition & 0 deletions example/generator/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
odp_generator
pktio_env
7 changes: 4 additions & 3 deletions example/generator/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ odp_generator_SOURCES = odp_generator.c
TEST_EXTENSIONS = .sh

if test_example
TESTS = generator_null_test.sh
TESTS_ENVIRONMENT += ODP_PLATFORM=$(with_platform)
TESTS = generator_run.sh
endif
EXTRA_DIST = generator_null_test.sh
EXTRA_DIST = generator_run.sh

# If building out-of-tree, make check will not copy the scripts and data to the
# $(builddir) assuming that all commands are run locally. However this prevents
Expand All @@ -25,6 +24,8 @@ all-local:
fi \
done \
fi
ln -f -s $(top_srcdir)/platform/$(with_platform)/test/example/generator/pktio_env \
pktio_env
clean-local:
if [ "x$(srcdir)" != "x$(builddir)" ]; then \
for f in $(EXTRA_DIST); do \
Expand Down
24 changes: 0 additions & 24 deletions example/generator/generator_null_test.sh

This file was deleted.

31 changes: 31 additions & 0 deletions example/generator/generator_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
#
# Copyright (c) 2020, Marvell
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

if [ -f ./pktio_env ]; then
. ./pktio_env
else
echo "BUG: unable to find pktio_env!"
echo "pktio_env has to be in current directory"
exit 1
fi

setup_interfaces

./odp_generator${EXEEXT} -w 1 -n 1 -I $IF0 -m u
STATUS=$?

if [ "$STATUS" -ne 0 ]; then
echo "Error: status was: $STATUS, expected 0"
exit 1
fi

validate_result

cleanup_interfaces

exit 0
11 changes: 5 additions & 6 deletions example/generator/odp_generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ static void sig_handler(int signo ODP_UNUSED)
*/
static int scan_ip(char *buf, unsigned int *paddr)
{
int part1, part2, part3, part4;
unsigned int part1, part2, part3, part4;
char tail = 0;
int field;

if (buf == NULL)
return 0;

field = sscanf(buf, "%d . %d . %d . %d %c",
field = sscanf(buf, "%u . %u . %u . %u %c",
&part1, &part2, &part3, &part4, &tail);

if (field < 4 || field > 5) {
Expand All @@ -206,15 +206,14 @@ static int scan_ip(char *buf, unsigned int *paddr)
return 0;
}

if ((part1 >= 0 && part1 <= 255) && (part2 >= 0 && part2 <= 255) &&
(part3 >= 0 && part3 <= 255) && (part4 >= 0 && part4 <= 255)) {
if (part1 <= 255 && part2 <= 255 && part3 <= 255 && part4 <= 255) {
if (paddr)
*paddr = part1 << 24 | part2 << 16 | part3 << 8 | part4;
return 1;
} else {
printf("not good ip %d:%d:%d:%d/n", part1, part2, part3, part4);
}

printf("not good ip %u:%u:%u:%u/n", part1, part2, part3, part4);

return 0;
}

Expand Down
8 changes: 7 additions & 1 deletion example/packet/odp_packet_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ static int print_packet(test_global_t *global, odp_packet_t pkt,
nsec = nsec - (sec * ODP_TIME_SEC_IN_NS);
pktio = odp_packet_input(pkt);

odp_pktio_info(pktio, &pktio_info);
if (odp_pktio_info(pktio, &pktio_info)) {
printf("Error: odp_pktio_info() failed\n");
return -1;
}

printf("PACKET [%" PRIu64 "]\n", num_packet);
printf(" time: %" PRIu64 ".%09" PRIu64 " sec\n", sec, nsec);
Expand Down Expand Up @@ -653,6 +656,9 @@ static int receive_packets(test_global_t *global)

odp_packet_free(pkt);

if (odp_unlikely(printed < 0))
return -1;

if (!printed)
continue;

Expand Down
Loading

0 comments on commit 0ecc932

Please sign in to comment.