kvargs: use SPDX tags
[dpdk.git] / examples / ip_pipeline / app.h
index 564996e..907d4e7 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
  */
 
 #ifndef __INCLUDE_APP_H__
@@ -428,10 +399,6 @@ struct app_eal_params {
        /* Interrupt mode for VFIO (legacy|msi|msix) */
        char *vfio_intr;
 
-       /* Support running on Xen dom0 without hugetlbfs */
-       uint32_t xen_dom0_present;
-       int xen_dom0;
-
        uint32_t parsed;
 };
 
@@ -491,6 +458,9 @@ struct app_eal_params {
 #define APP_THREAD_HEADROOM_STATS_COLLECT        1
 #endif
 
+#define APP_CORE_MASK_SIZE                                     \
+       (RTE_MAX_LCORE / 64 + ((RTE_MAX_LCORE % 64) ? 1 : 0))
+
 struct app_params {
        /* Config */
        char app_name[APP_APPNAME_SIZE];
@@ -533,7 +503,7 @@ struct app_params {
        /* Init */
        char *eal_argv[1 + APP_EAL_ARGC];
        struct cpu_core_map *core_map;
-       uint64_t core_mask;
+       uint64_t core_mask[APP_CORE_MASK_SIZE];
        struct rte_mempool *mempool[APP_MAX_MEMPOOLS];
        struct app_link_data link_data[APP_MAX_LINKS];
        struct rte_ring *swq[APP_MAX_PKTQ_SWQ];
@@ -1152,7 +1122,7 @@ app_tap_get_writer(struct app_params *app,
        struct app_pktq_tap_params *tap,
        uint32_t *pktq_out_id)
 {
-       struct app_pipeline_params *writer;
+       struct app_pipeline_params *writer = NULL;
        uint32_t pos = tap - app->tap_params;
        uint32_t n_pipelines = RTE_MIN(app->n_pipelines,
                RTE_DIM(app->pipeline_params));
@@ -1168,10 +1138,11 @@ app_tap_get_writer(struct app_params *app,
                        struct app_pktq_out_params *pktq = &p->pktq_out[j];
 
                        if ((pktq->type == APP_PKTQ_OUT_TAP) &&
-                               (pktq->id == pos))
+                               (pktq->id == pos)) {
                                n_writers++;
                                writer = p;
                                id = j;
+                       }
                }
        }
 
@@ -1358,6 +1329,36 @@ app_get_link_for_kni(struct app_params *app, struct app_pktq_kni_params *p_kni)
        return &app->link_params[link_param_idx];
 }
 
+static inline uint32_t
+app_core_is_enabled(struct app_params *app, uint32_t lcore_id)
+{
+       return(app->core_mask[lcore_id / 64] &
+               (1LLU << (lcore_id % 64)));
+}
+
+static inline void
+app_core_enable_in_core_mask(struct app_params *app, int lcore_id)
+{
+       app->core_mask[lcore_id / 64] |= 1LLU << (lcore_id % 64);
+
+}
+
+static inline void
+app_core_build_core_mask_string(struct app_params *app, char *mask_buffer)
+{
+       int i;
+
+       mask_buffer[0] = '\0';
+       for (i = (int)RTE_DIM(app->core_mask); i > 0; i--) {
+               /* For Hex representation of bits in uint64_t */
+               char buffer[(64 / 8) * 2 + 1];
+               memset(buffer, 0, sizeof(buffer));
+               snprintf(buffer, sizeof(buffer), "%016" PRIx64,
+                        app->core_mask[i-1]);
+               strcat(mask_buffer, buffer);
+       }
+}
+
 void app_pipeline_params_get(struct app_params *app,
        struct app_pipeline_params *p_in,
        struct pipeline_params *p_out);