test/ipsec: fix a typo in function name
[dpdk.git] / examples / ip_pipeline / parser.c
index 689e206..fb0769f 100644 (file)
@@ -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 <zer0@droids-corp.org>
  * 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.
  */
 
 /*
 #include <sys/wait.h>
 
 #include <rte_errno.h>
-#include <rte_cfgfile.h>
 #include <rte_string_fns.h>
 
-#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 {
@@ -586,21 +528,21 @@ my_ether_aton(const char *a)
                if (errno != 0 || end == a || (end[0] != ':' && end[0] != 0))
                        return NULL;
                a = end + 1;
-       } while (++i != sizeof(o) / sizeof(o[0]) && end[0] != 0);
+       } while (++i != RTE_DIM(o) && end[0] != 0);
 
        /* Junk at the end of line */
        if (end[0] != 0)
                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 *)&ether_addr;
+       return (struct rte_ether_addr *)&ether_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 <CORE> 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;
 }