New upstream version 18.02
[deb_dpdk.git] / examples / ip_pipeline / pipeline / pipeline_firewall_be.c
index e7a8a4c..bd5e1b2 100644 (file)
@@ -1,34 +1,5 @@
-/*-
- *   BSD LICENSE
- *
- *   Copyright(c) 2010-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.
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2016 Intel Corporation
  */
 
 #include <string.h>
@@ -161,7 +132,7 @@ static struct rte_acl_field_def field_format_ipv4[] = {
                .type = RTE_ACL_FIELD_TYPE_RANGE,
                .size = sizeof(uint16_t),
                .field_index = 4,
-               .input_index = 4,
+               .input_index = 3,
                .offset = sizeof(struct ether_hdr) +
                        sizeof(struct ipv4_hdr) +
                        offsetof(struct tcp_hdr, dst_port),
@@ -221,7 +192,7 @@ static struct rte_acl_field_def field_format_vlan_ipv4[] = {
                .type = RTE_ACL_FIELD_TYPE_RANGE,
                .size = sizeof(uint16_t),
                .field_index = 4,
-               .input_index = 4,
+               .input_index = 3,
                .offset = sizeof(struct ether_hdr) +
                        SIZEOF_VLAN_HDR +
                        sizeof(struct ipv4_hdr) +
@@ -282,7 +253,7 @@ static struct rte_acl_field_def field_format_qinq_ipv4[] = {
                .type = RTE_ACL_FIELD_TYPE_RANGE,
                .size = sizeof(uint16_t),
                .field_index = 4,
-               .input_index = 4,
+               .input_index = 3,
                .offset = sizeof(struct ether_hdr) +
                        SIZEOF_QINQ_HEADER +
                        sizeof(struct ipv4_hdr) +
@@ -564,27 +535,6 @@ pipeline_firewall_free(void *pipeline)
        return 0;
 }
 
-static int
-pipeline_firewall_track(void *pipeline,
-       __rte_unused uint32_t port_in,
-       uint32_t *port_out)
-{
-       struct pipeline *p = (struct pipeline *) pipeline;
-
-       /* Check input arguments */
-       if ((p == NULL) ||
-               (port_in >= p->n_ports_in) ||
-               (port_out == NULL))
-               return -1;
-
-       if (p->n_ports_in == 1) {
-               *port_out = 0;
-               return 0;
-       }
-
-       return -1;
-}
-
 static int
 pipeline_firewall_timer(void *pipeline)
 {
@@ -732,7 +682,7 @@ pipeline_firewall_msg_req_add_bulk_handler(struct pipeline *p, void *msg)
        n_keys = req->n_keys;
 
        for (i = 0; i < n_keys; i++) {
-               entries[i] = rte_malloc(NULL,
+               entries[i] = rte_zmalloc(NULL,
                                sizeof(struct firewall_table_entry),
                                RTE_CACHE_LINE_SIZE);
                if (entries[i] == NULL) {
@@ -740,7 +690,7 @@ pipeline_firewall_msg_req_add_bulk_handler(struct pipeline *p, void *msg)
                        return rsp;
                }
 
-               params[i] = rte_malloc(NULL,
+               params[i] = rte_zmalloc(NULL,
                                sizeof(struct rte_table_acl_rule_add_params),
                                RTE_CACHE_LINE_SIZE);
                if (params[i] == NULL) {
@@ -814,7 +764,7 @@ pipeline_firewall_msg_req_del_bulk_handler(struct pipeline *p, void *msg)
        n_keys = req->n_keys;
 
        for (i = 0; i < n_keys; i++) {
-               params[i] = rte_malloc(NULL,
+               params[i] = rte_zmalloc(NULL,
                                sizeof(struct rte_table_acl_rule_delete_params),
                                RTE_CACHE_LINE_SIZE);
                if (params[i] == NULL) {
@@ -903,5 +853,4 @@ struct pipeline_be_ops pipeline_firewall_be_ops = {
        .f_free = pipeline_firewall_free,
        .f_run = NULL,
        .f_timer = pipeline_firewall_timer,
-       .f_track = pipeline_firewall_track,
 };