X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=doc%2Fguides%2Fsample_app_ug%2Fflow_classify.rst;h=9582b93760f7c7840897b3e9d625d168a0cfb2fd;hb=6d13ea8e8e49ab957deae2bba5ecf4a4bfe747d1;hp=bc12b87dd06c643b3b224313b3523c92fa16a621;hpb=fdec9301f52dd528b78c03be71db0495fe7e7944;p=dpdk.git diff --git a/doc/guides/sample_app_ug/flow_classify.rst b/doc/guides/sample_app_ug/flow_classify.rst index bc12b87dd0..9582b93760 100644 --- a/doc/guides/sample_app_ug/flow_classify.rst +++ b/doc/guides/sample_app_ug/flow_classify.rst @@ -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,7 +91,7 @@ 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) + + .offset = sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, next_proto_id), }, /* next input field (IPv4 source address) - 4 consecutive bytes. */ @@ -128,7 +101,7 @@ 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) + + .offset = sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, src_addr), }, /* next input field (IPv4 destination address) - 4 consecutive bytes. */ @@ -138,7 +111,7 @@ 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) + + .offset = sizeof(struct rte_ether_hdr) + offsetof(struct ipv4_hdr, dst_addr), }, /* @@ -151,7 +124,7 @@ 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) + + .offset = sizeof(struct rte_ether_hdr) + sizeof(struct ipv4_hdr) + offsetof(struct tcp_hdr, src_port), }, @@ -161,7 +134,7 @@ 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) + + .offset = sizeof(struct rte_ether_hdr) + sizeof(struct ipv4_hdr) + offsetof(struct 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); @@ -228,7 +201,6 @@ table`` to the flow classifier. struct flow_classifier { struct rte_flow_classifier *cls; - uint32_t table_id[RTE_FLOW_CLASSIFY_TABLE_MAX]; }; struct flow_classifier_acl { @@ -243,7 +215,6 @@ table`` to the flow classifier. cls_params.name = "flow_classifier"; cls_params.socket_id = socket_id; - cls_params.type = RTE_FLOW_CLASSIFY_TABLE_TYPE_ACL; cls_app->cls = rte_flow_classifier_create(&cls_params); if (cls_app->cls == NULL) { @@ -260,10 +231,9 @@ table`` to the flow classifier. /* initialise table create params */ cls_table_params.ops = &rte_table_acl_ops, cls_table_params.arg_create = &table_acl_params, - cls_table_params.table_metadata_size = 0; + cls_table_params.type = RTE_FLOW_CLASSIFY_TABLE_ACL_IP4_5TUPLE; - ret = rte_flow_classify_table_create(cls_app->cls, &cls_table_params, - &cls->table_id[0]); + ret = rte_flow_classify_table_create(cls_app->cls, &cls_table_params); if (ret) { rte_flow_classifier_free(cls_app->cls); rte_free(cls); @@ -305,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) @@ -454,14 +421,13 @@ following: static __attribute__((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"); @@ -481,7 +447,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]; @@ -495,7 +461,6 @@ following: if (rules[i]) { ret = rte_flow_classifier_query( cls_app->cls, - cls_app->table_id[0], bufs, nb_rx, rules[i], &classify_stats); if (ret) @@ -532,7 +497,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];