/* // Copyright (c) 2017 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. */ #include #include #include "app.h" //uint8_t g_n_hwq_in = N_RXQ; uint8_t g_n_hwq_in; static void check_mempools(struct app_params *app) { uint32_t i; for (i = 0; i < app->n_mempools; i++) { struct app_mempool_params *p = &app->mempool_params[i]; APP_CHECK((p->pool_size > 0), "Mempool %s size is 0\n", p->name); APP_CHECK((p->cache_size > 0), "Mempool %s cache size is 0\n", p->name); APP_CHECK(rte_is_power_of_2(p->cache_size), "Mempool %s cache size not a power of 2\n", p->name); } } static void check_links(struct app_params *app) { uint32_t i; /* Check that number of links matches the port mask */ if (app->port_mask) { uint32_t n_links_port_mask = __builtin_popcountll(app->port_mask); APP_CHECK((app->n_links == n_links_port_mask), "Not enough links provided in the PORT_MASK\n"); } for (i = 0; i < app->n_links; i++) { struct app_link_params *link = &app->link_params[i]; uint32_t rxq_max, n_rxq, n_txq, link_id, i; APP_PARAM_GET_ID(link, "LINK", link_id); /* Check that link RXQs are contiguous */ rxq_max = 0; if (link->arp_q > rxq_max) rxq_max = link->arp_q; if (link->tcp_syn_q > rxq_max) rxq_max = link->tcp_syn_q; if (link->ip_local_q > rxq_max) rxq_max = link->ip_local_q; if (link->tcp_local_q > rxq_max) rxq_max = link->tcp_local_q; if (link->udp_local_q > rxq_max) rxq_max = link->udp_local_q; if (link->sctp_local_q > rxq_max) rxq_max = link->sctp_local_q; if(enable_hwlb || enable_flow_dir){ g_n_hwq_in = app->n_hwlb_q; rxq_max = (g_n_hwq_in - 1); for (i = g_n_hwq_in; i <= rxq_max; i++) APP_CHECK(((link->arp_q == i) || (link->tcp_syn_q == i) || (link->ip_local_q == i) || (link->tcp_local_q == i) || (link->udp_local_q == i) || (link->sctp_local_q == i)), "%s RXQs are not contiguous (A)\n", link->name); } else{ for (i = 1; i <= rxq_max; i++) APP_CHECK(((link->arp_q == i) || (link->tcp_syn_q == i) || (link->ip_local_q == i) || (link->tcp_local_q == i) || (link->udp_local_q == i) || (link->sctp_local_q == i)), "%s RXQs are not contiguous (A)\n", link->name); } n_rxq = app_link_get_n_rxq(app, link); APP_CHECK((n_rxq), "%s does not have any RXQ\n", link->name); printf("n_rxq = %d\n",n_rxq); printf("rxq_max = %d\n",rxq_max); //APP_CHECK((n_rxq == rxq_max + 1), // "%s RXQs are not contiguous (B)\n", link->name); for (i = 0; i < n_rxq; i++) { char name[APP_PARAM_NAME_SIZE]; int pos; sprintf(name, "RXQ%" PRIu32 ".%" PRIu32, link_id, i); pos = APP_PARAM_FIND(app->hwq_in_params, name); APP_CHECK((pos >= 0), "%s RXQs are not contiguous (C)\n", link->name); } /* Check that link RXQs are contiguous */ n_txq = app_link_get_n_txq(app, link); APP_CHECK((n_txq), "%s does not have any TXQ\n", link->name); for (i = 0; i < n_txq; i++) { char name[APP_PARAM_NAME_SIZE]; int pos; sprintf(name, "TXQ%" PRIu32 ".%" PRIu32, link_id, i); pos = APP_PARAM_FIND(app->hwq_out_params, name); APP_CHECK((pos >= 0), "%s TXQs are not contiguous\n", link->name); } } } static void check_rxqs(struct app_params *app) { uint32_t i; for (i = 0; i < app->n_pktq_hwq_in; i++) { struct app_pktq_hwq_in_params *p = &app->hwq_in_params[i]; uint32_t n_readers = app_rxq_get_readers(app, p); APP_CHECK((p->size > 0), "%s size is 0\n", p->name); APP_CHECK((rte_is_power_of_2(p->size)), "%s size is not a power of 2\n", p->name); APP_CHECK((p->burst > 0), "%s burst size is 0\n", p->name); APP_CHECK((p->burst <= p->size), "%s burst size is bigger than its size\n", p->name); APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); APP_CHECK((n_readers == 1), "%s has more than one reader\n", p->name); } } static void check_txqs(struct app_params *app) { uint32_t i; for (i = 0; i < app->n_pktq_hwq_out; i++) { struct app_pktq_hwq_out_params *p = &app->hwq_out_params[i]; uint32_t n_writers = app_txq_get_writers(app, p); APP_CHECK((p->size > 0), "%s size is 0\n", p->name); APP_CHECK((rte_is_power_of_2(p->size)), "%s size is not a power of 2\n", p->name); APP_CHECK((p->burst > 0), "%s burst size is 0\n", p->name); APP_CHECK((p->burst <= p->size), "%s burst size is bigger than its size\n", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); APP_CHECK((n_writers == 1), "%s has more than one writer\n", p->name); } } static void check_swqs(struct app_params *app) { uint32_t i; for (i = 0; i < app->n_pktq_swq; i++) { struct app_pktq_swq_params *p = &app->swq_params[i]; uint32_t n_readers = app_swq_get_readers(app, p); uint32_t n_writers = app_swq_get_writers(app, p); uint32_t n_flags; APP_CHECK((p->size > 0), "%s size is 0\n", p->name); APP_CHECK((rte_is_power_of_2(p->size)), "%s size is not a power of 2\n", p->name); APP_CHECK((p->burst_read > 0), "%s read burst size is 0\n", p->name); APP_CHECK((p->burst_read <= p->size), "%s read burst size is bigger than its size\n", p->name); APP_CHECK((p->burst_write > 0), "%s write burst size is 0\n", p->name); APP_CHECK((p->burst_write <= p->size), "%s write burst size is bigger than its size\n", p->name); APP_CHECK((n_readers != 0), "%s has no reader\n", p->name); if (n_readers > 1) APP_LOG(app, LOW, "%s has more than one reader", p->name); APP_CHECK((n_writers != 0), "%s has no writer\n", p->name); if (n_writers > 1) APP_LOG(app, LOW, "%s has