replace no-return attributes
[dpdk.git] / doc / guides / sample_app_ug / flow_classify.rst
index 427fded..dc40b4d 100644 (file)
@@ -1,32 +1,5 @@
-..  BSD LICENSE
-    Copyright(c) 2017 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) 2017 Intel Corporation.
 
 Flow Classify Sample Application
 ================================
@@ -51,7 +24,7 @@ The application is located in the ``flow_classify`` sub-directory.
 Running the Application
 -----------------------
 
-To run the example in a ``linuxapp`` environment:
+To run the example in a ``linux`` environment:
 
 .. code-block:: console
 
@@ -118,8 +91,8 @@ initialisation of the ``Flow Classify`` application..
             .size = sizeof(uint8_t),
             .field_index = PROTO_FIELD_IPV4,
             .input_index = PROTO_INPUT_IPV4,
-            .offset = sizeof(struct ether_hdr) +
-                offsetof(struct ipv4_hdr, next_proto_id),
+            .offset = sizeof(struct rte_ether_hdr) +
+                offsetof(struct rte_ipv4_hdr, next_proto_id),
         },
         /* next input field (IPv4 source address) - 4 consecutive bytes. */
         {
@@ -128,8 +101,8 @@ initialisation of the ``Flow Classify`` application..
             .size = sizeof(uint32_t),
             .field_index = SRC_FIELD_IPV4,
             .input_index = SRC_INPUT_IPV4,
-            .offset = sizeof(struct ether_hdr) +
-                offsetof(struct ipv4_hdr, src_addr),
+            .offset = sizeof(struct rte_ether_hdr) +
+                offsetof(struct rte_ipv4_hdr, src_addr),
         },
         /* next input field (IPv4 destination address) - 4 consecutive bytes. */
         {
@@ -138,8 +111,8 @@ initialisation of the ``Flow Classify`` application..
             .size = sizeof(uint32_t),
             .field_index = DST_FIELD_IPV4,
             .input_index = DST_INPUT_IPV4,
-            .offset = sizeof(struct ether_hdr) +
-                offsetof(struct ipv4_hdr, dst_addr),
+            .offset = sizeof(struct rte_ether_hdr) +
+                offsetof(struct rte_ipv4_hdr, dst_addr),
         },
         /*
          * Next 2 fields (src & dst ports) form 4 consecutive bytes.
@@ -151,9 +124,9 @@ initialisation of the ``Flow Classify`` application..
             .size = sizeof(uint16_t),
             .field_index = SRCP_FIELD_IPV4,
             .input_index = SRCP_DESTP_INPUT_IPV4,
-            .offset = sizeof(struct ether_hdr) +
-                sizeof(struct ipv4_hdr) +
-                offsetof(struct tcp_hdr, src_port),
+            .offset = sizeof(struct rte_ether_hdr) +
+                sizeof(struct rte_ipv4_hdr) +
+                offsetof(struct rte_tcp_hdr, src_port),
         },
         {
              /* rte_flow uses a bit mask for protocol ports */
@@ -161,9 +134,9 @@ initialisation of the ``Flow Classify`` application..
              .size = sizeof(uint16_t),
              .field_index = DSTP_FIELD_IPV4,
              .input_index = SRCP_DESTP_INPUT_IPV4,
-             .offset = sizeof(struct ether_hdr) +
-                 sizeof(struct ipv4_hdr) +
-                 offsetof(struct tcp_hdr, dst_port),
+             .offset = sizeof(struct rte_ether_hdr) +
+                 sizeof(struct rte_ipv4_hdr) +
+                 offsetof(struct rte_tcp_hdr, dst_port),
         },
     };
 
@@ -214,7 +187,7 @@ The ``main()`` function also initializes all the ports using the user defined
 
 .. code-block:: c
 
-    for (portid = 0; portid < nb_ports; portid++) {
+    RTE_ETH_FOREACH_DEV(portid) {
         if (port_init(portid, mbuf_pool) != 0) {
             rte_exit(EXIT_FAILURE,
                      "Cannot init port %" PRIu8 "\n", portid);
@@ -302,13 +275,10 @@ Forwarding application is shown below:
     {
         struct rte_eth_conf port_conf = port_conf_default;
         const uint16_t rx_rings = 1, tx_rings = 1;
-        struct ether_addr addr;
+        struct rte_ether_addr addr;
         int retval;
         uint16_t q;
 
-        if (port >= rte_eth_dev_count())
-            return -1;
-
         /* Configure the Ethernet device. */
         retval = rte_eth_dev_configure(port, rx_rings, tx_rings, &port_conf);
         if (retval != 0)
@@ -336,7 +306,9 @@ Forwarding application is shown below:
             return retval;
 
         /* Display the port MAC address. */
-        rte_eth_macaddr_get(port, &addr);
+        retval = rte_eth_macaddr_get(port, &addr);
+        if (retval < 0)
+            return retval;
         printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
                " %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
                port,
@@ -345,7 +317,9 @@ Forwarding application is shown below:
                addr.addr_bytes[4], addr.addr_bytes[5]);
 
         /* Enable RX in promiscuous mode for the Ethernet device. */
-        rte_eth_promiscuous_enable(port);
+        retval = rte_eth_promiscuous_enable(port);
+        if (retval != 0)
+                return retval;
 
         return 0;
     }
@@ -356,7 +330,7 @@ The Ethernet ports are configured with default settings using the
 .. code-block:: c
 
     static const struct rte_eth_conf port_conf_default = {
-        .rxmode = { .max_rx_pkt_len = ETHER_MAX_LEN }
+        .rxmode = { .max_rx_pkt_len = RTE_ETHER_MAX_LEN }
     };
 
 For this example the ports are set up with 1 RX and 1 TX queue using the
@@ -373,7 +347,7 @@ Finally the RX port is set in promiscuous mode:
 
 .. code-block:: c
 
-    rte_eth_promiscuous_enable(port);
+    retval = rte_eth_promiscuous_enable(port);
 
 The Add Rules function
 ~~~~~~~~~~~~~~~~~~~~~~
@@ -448,17 +422,16 @@ following:
             .stats = (void *)&ntuple_stats
     };
 
-    static __attribute__((noreturn)) void
+    static __rte_noreturn void
     lcore_main(cls_app)
     {
-        const uint8_t nb_ports = rte_eth_dev_count();
-        uint8_t port;
+        uint16_t port;
 
         /*
          * Check that the port is on the same NUMA node as the polling thread
          * for best performance.
          */
-        for (port = 0; port < nb_ports; port++)
+        RTE_ETH_FOREACH_DEV(port)
             if (rte_eth_dev_socket_id(port) > 0 &&
                 rte_eth_dev_socket_id(port) != (int)rte_socket_id()) {
                 printf("\n\n");
@@ -478,7 +451,7 @@ following:
              * Receive packets on a port and forward them on the paired
              * port. The mapping is 0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2, etc.
              */
-            for (port = 0; port < nb_ports; port++) {
+            RTE_ETH_FOREACH_DEV(port) {
 
                 /* Get burst of RX packets, from first port of pair. */
                 struct rte_mbuf *bufs[BURST_SIZE];
@@ -528,7 +501,7 @@ The main work of the application is done within the loop:
 .. code-block:: c
 
         for (;;) {
-            for (port = 0; port < nb_ports; port++) {
+            RTE_ETH_FOREACH_DEV(port) {
 
                 /* Get burst of RX packets, from first port of pair. */
                 struct rte_mbuf *bufs[BURST_SIZE];