X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fip_pipeline%2Fparser.c;h=3fffeb586730dde6223df67202adda5757697faf;hb=9efa8d28b4daccda08ec0a2b8e45350fe089065f;hp=689e2065a87a27d7e3e79fdcadf72a905fc7be3a;hpb=ed7a0490f7e237259ea24d059bf0b8b63e543cbc;p=dpdk.git diff --git a/examples/ip_pipeline/parser.c b/examples/ip_pipeline/parser.c index 689e2065a8..3fffeb5867 100644 --- a/examples/ip_pipeline/parser.c +++ b/examples/ip_pipeline/parser.c @@ -1,63 +1,7 @@ -/*- - * BSD LICENSE - * - * Copyright(c) 2016 Intel Corporation. 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. - */ - -/* - * For my_ether_aton() function: - * +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016 Intel Corporation. * Copyright (c) 2009, Olivier MATZ * 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 the University of California, Berkeley 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 REGENTS 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 REGENTS AND 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. */ /* @@ -92,10 +36,8 @@ #include #include -#include #include -#include "app.h" #include "parser.h" static uint32_t @@ -571,13 +513,13 @@ inet_pton6(const char *src, unsigned char *dst) return 1; } -static struct ether_addr * +static struct rte_ether_addr * my_ether_aton(const char *a) { int i; char *end; - unsigned long o[ETHER_ADDR_LEN]; - static struct ether_addr ether_addr; + unsigned long o[RTE_ETHER_ADDR_LEN]; + static struct rte_ether_addr ether_addr; i = 0; do { @@ -593,14 +535,14 @@ my_ether_aton(const char *a) return NULL; /* Support the format XX:XX:XX:XX:XX:XX */ - if (i == ETHER_ADDR_LEN) { + if (i == RTE_ETHER_ADDR_LEN) { while (i-- != 0) { if (o[i] > UINT8_MAX) return NULL; ether_addr.addr_bytes[i] = (uint8_t)o[i]; } /* Support the format XXXX:XXXX:XXXX */ - } else if (i == ETHER_ADDR_LEN / 2) { + } else if (i == RTE_ETHER_ADDR_LEN / 2) { while (i-- != 0) { if (o[i] > UINT16_MAX) return NULL; @@ -611,7 +553,7 @@ my_ether_aton(const char *a) } else return NULL; - return (struct ether_addr *)ðer_addr; + return (struct rte_ether_addr *)ðer_addr; } int @@ -639,23 +581,21 @@ parse_ipv6_addr(const char *token, struct in6_addr *ipv6) } int -parse_mac_addr(const char *token, struct ether_addr *addr) +parse_mac_addr(const char *token, struct rte_ether_addr *addr) { - struct ether_addr *tmp; + struct rte_ether_addr *tmp; tmp = my_ether_aton(token); if (tmp == NULL) return -1; - memcpy(addr, tmp, sizeof(struct ether_addr)); + memcpy(addr, tmp, sizeof(struct rte_ether_addr)); return 0; } int -parse_pipeline_core(uint32_t *socket, - uint32_t *core, - uint32_t *ht, - const char *entry) +parse_cpu_core(const char *entry, + struct cpu_core_params *p) { size_t num_len; char num[8]; @@ -665,6 +605,9 @@ parse_pipeline_core(uint32_t *socket, const char *next = skip_white_spaces(entry); char type; + if (p == NULL) + return -EINVAL; + /* Expect or [sX][cY][h]. At least one parameter is required. */ while (*next != '\0') { /* If everything parsed nothing should left */ @@ -738,8 +681,8 @@ parse_pipeline_core(uint32_t *socket, } } - *socket = s; - *core = c; - *ht = h; + p->socket_id = s; + p->core_id = c; + p->thread_id = h; return 0; }