net/mlx5: remove unnecessary memory barrier
[dpdk.git] / examples / ip_pipeline / pipeline / pipeline_common_fe.c
index fa0a482..cc5214c 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 <stdio.h>
@@ -36,7 +7,6 @@
 #include <unistd.h>
 
 #include <rte_common.h>
-#include <rte_ring.h>
 #include <rte_malloc.h>
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
@@ -130,6 +100,34 @@ app_pipeline_track_pktq_out_to_link(struct app_params *app,
                        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;
@@ -418,6 +416,40 @@ app_pipeline_port_in_disable(struct app_params *app,
        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,
@@ -489,6 +521,8 @@ 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)
@@ -501,6 +535,8 @@ app_link_up(struct app_params *app,
                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);
@@ -515,6 +551,11 @@ app_link_up(struct app_params *app,
 
        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;
 }
 
@@ -523,6 +564,8 @@ 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)
@@ -535,6 +578,8 @@ app_link_down(struct app_params *app,
                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);
@@ -543,6 +588,11 @@ app_link_down(struct app_params *app,
 
        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;
 }