event/cnxk: fix clang build on Arm
[dpdk.git] / examples / multi_process / client_server_mp / mp_client / client.c
index 59f36af..6d4c246 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 <stdint.h>
@@ -57,7 +28,6 @@
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_interrupts.h>
-#include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
@@ -216,8 +186,8 @@ static void
 handle_packet(struct rte_mbuf *buf)
 {
        int sent;
-       const uint8_t in_port = buf->port;
-       const uint8_t out_port = output_ports[in_port];
+       const uint16_t in_port = buf->port;
+       const uint16_t out_port = output_ports[in_port];
        struct rte_eth_dev_tx_buffer *buffer = tx_buffer[out_port];
 
        sent = rte_eth_tx_buffer(out_port, client_id, buffer, buf);
@@ -250,7 +220,7 @@ main(int argc, char *argv[])
        if (parse_app_args(argc, argv) < 0)
                rte_exit(EXIT_FAILURE, "Invalid command-line arguments\n");
 
-       if (rte_eth_dev_count() == 0)
+       if (rte_eth_dev_count_avail() == 0)
                rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
        rx_ring = rte_ring_lookup(get_rx_queue_name(client_id));
@@ -276,19 +246,19 @@ main(int argc, char *argv[])
 
        for (;;) {
                uint16_t i, rx_pkts;
-               uint8_t port;
 
                rx_pkts = rte_ring_dequeue_burst(rx_ring, pkts,
                                PKT_READ_SIZE, NULL);
 
-               if (unlikely(rx_pkts == 0)){
-                       if (need_flush)
-                               for (port = 0; port < ports->num_ports; port++) {
-                                       sent = rte_eth_tx_buffer_flush(ports->id[port], client_id,
-                                                       tx_buffer[port]);
-                                       if (unlikely(sent))
-                                               tx_stats->tx[port] += sent;
-                               }
+               if (rx_pkts == 0 && need_flush) {
+                       for (i = 0; i < ports->num_ports; i++) {
+                               uint16_t port = ports->id[i];
+
+                               sent = rte_eth_tx_buffer_flush(port,
+                                                              client_id,
+                                                              tx_buffer[port]);
+                               tx_stats->tx[port] += sent;
+                       }
                        need_flush = 0;
                        continue;
                }
@@ -298,4 +268,7 @@ main(int argc, char *argv[])
 
                need_flush = 1;
        }
+
+       /* clean up the EAL */
+       rte_eal_cleanup();
 }