]> git.droids-corp.org - dpdk.git/commitdiff
fix ethdev ports enumeration
authorThomas Monjalon <thomas@monjalon.net>
Thu, 5 Apr 2018 15:33:20 +0000 (17:33 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 17 Apr 2018 22:25:27 +0000 (00:25 +0200)
Some DPDK applications wrongly assume these requirements:
    - no hotplug, i.e. ports are never detached
    - all allocated ports are available to the application

Such application iterates over ports by its own mean.
The most common pattern is to request the port count and
assume ports with index in the range [0..count[ can be used.

There are three consequences when using such wrong design:
    - new ports having an index higher than the port count won't be seen
    - old ports being detached (RTE_ETH_DEV_UNUSED) can be seen as ghosts
    - failsafe sub-devices (RTE_ETH_DEV_DEFERRED) will be seen by the application

Such mistake will be less common with growing hotplug awareness.
All applications and examples inside this repository - except testpmd -
must be fixed to use the iterator RTE_ETH_FOREACH_DEV.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
109 files changed:
app/proc-info/main.c
app/test-eventdev/test_perf_common.c
app/test-eventdev/test_pipeline_common.c
app/test-pmd/cmdline.c
app/test-pmd/testpmd.c
doc/guides/sample_app_ug/flow_classify.rst
doc/guides/sample_app_ug/l2_forward_job_stats.rst
doc/guides/sample_app_ug/l2_forward_real_virtual.rst
doc/guides/sample_app_ug/link_status_intr.rst
doc/guides/sample_app_ug/skeleton.rst
drivers/net/bonding/Makefile
drivers/net/bonding/meson.build
drivers/net/bonding/rte_eth_bond_args.c
drivers/net/mvpp2/mrvl_ethdev.c
examples/bond/Makefile
examples/bond/main.c
examples/bond/meson.build
examples/distributor/Makefile
examples/distributor/main.c
examples/distributor/meson.build
examples/ethtool/ethtool-app/Makefile
examples/ethtool/ethtool-app/ethapp.c
examples/eventdev_pipeline/main.c
examples/eventdev_pipeline/pipeline_worker_generic.c
examples/eventdev_pipeline/pipeline_worker_tx.c
examples/exception_path/Makefile
examples/exception_path/main.c
examples/exception_path/meson.build
examples/flow_classify/flow_classify.c
examples/ip_fragmentation/Makefile
examples/ip_fragmentation/main.c
examples/ip_fragmentation/meson.build
examples/ip_reassembly/Makefile
examples/ip_reassembly/main.c
examples/ip_reassembly/meson.build
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/Makefile
examples/ipv4_multicast/main.c
examples/ipv4_multicast/meson.build
examples/kni/Makefile
examples/kni/main.c
examples/kni/meson.build
examples/l2fwd-cat/Makefile
examples/l2fwd-cat/l2fwd-cat.c
examples/l2fwd-cat/meson.build
examples/l2fwd-crypto/Makefile
examples/l2fwd-crypto/main.c
examples/l2fwd-crypto/meson.build
examples/l2fwd-jobstats/Makefile
examples/l2fwd-jobstats/main.c
examples/l2fwd-jobstats/meson.build
examples/l2fwd-keepalive/Makefile
examples/l2fwd-keepalive/main.c
examples/l2fwd-keepalive/meson.build
examples/l2fwd/Makefile
examples/l2fwd/main.c
examples/l2fwd/meson.build
examples/l3fwd-acl/Makefile
examples/l3fwd-acl/main.c
examples/l3fwd-acl/meson.build
examples/l3fwd-power/Makefile
examples/l3fwd-power/main.c
examples/l3fwd-power/meson.build
examples/l3fwd-vf/Makefile
examples/l3fwd-vf/main.c
examples/l3fwd-vf/meson.build
examples/l3fwd/Makefile
examples/l3fwd/main.c
examples/l3fwd/meson.build
examples/multi_process/l2fwd_fork/Makefile
examples/multi_process/l2fwd_fork/main.c
examples/multi_process/symmetric_mp/Makefile
examples/multi_process/symmetric_mp/main.c
examples/packet_ordering/Makefile
examples/packet_ordering/main.c
examples/packet_ordering/meson.build
examples/performance-thread/l3fwd-thread/Makefile
examples/performance-thread/l3fwd-thread/main.c
examples/ptpclient/Makefile
examples/ptpclient/meson.build
examples/ptpclient/ptpclient.c
examples/rxtx_callbacks/Makefile
examples/rxtx_callbacks/main.c
examples/rxtx_callbacks/meson.build
examples/skeleton/Makefile
examples/skeleton/basicfwd.c
examples/skeleton/meson.build
examples/tep_termination/Makefile
examples/tep_termination/main.c
examples/tep_termination/meson.build
examples/vhost/Makefile
examples/vhost/main.c
examples/vhost/meson.build
examples/vm_power_manager/Makefile
examples/vm_power_manager/channel_monitor.c
examples/vm_power_manager/main.c
examples/vmdq/Makefile
examples/vmdq/main.c
examples/vmdq/meson.build
examples/vmdq_dcb/Makefile
examples/vmdq_dcb/main.c
examples/vmdq_dcb/meson.build
lib/librte_eventdev/rte_event_eth_rx_adapter.c
lib/librte_latencystats/Makefile
lib/librte_latencystats/meson.build
lib/librte_latencystats/rte_latencystats.c
test/test/test_event_eth_rx_adapter.c
test/test/test_pmd_perf.c
test/test/test_pmd_ring.c

index f90c14498bcfdbc3de9a868a52859ff0bd424176..115df9d9623d433f53ee3635e89778c5b6cada19 100644 (file)
@@ -636,7 +636,7 @@ main(int argc, char **argv)
        if (enabled_port_mask == 0)
                enabled_port_mask = 0xffff;
 
-       for (i = 0; i < nb_ports; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                if (enabled_port_mask & (1 << i)) {
                        if (enable_stats)
                                nic_stats_display(i);
index f16791861c1bf6ec6459216066e1f307985088bc..d1bd5e9a278326f8c334acc38c19e5ea3338881d 100644 (file)
@@ -355,7 +355,7 @@ perf_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride,
        memset(&queue_conf, 0,
                        sizeof(struct rte_event_eth_rx_adapter_queue_conf));
        queue_conf.ev.sched_type = opt->sched_type_list[0];
-       for (prod = 0; prod < rte_eth_dev_count(); prod++) {
+       RTE_ETH_FOREACH_DEV(prod) {
                uint32_t cap;
 
                ret = rte_event_eth_rx_adapter_caps_get(opt->dev_id,
@@ -673,7 +673,7 @@ perf_elt_init(struct rte_mempool *mp, void *arg __rte_unused,
 int
 perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 {
-       int i;
+       uint16_t i;
        struct test_perf *t = evt_test_priv(test);
        struct rte_eth_conf port_conf = {
                .rxmode = {
@@ -705,7 +705,7 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                return -ENODEV;
        }
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
 
                if (rte_eth_dev_configure(i, 1, 1,
                                        &port_conf)
@@ -736,11 +736,11 @@ perf_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 
 void perf_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
 {
-       int i;
+       uint16_t i;
        RTE_SET_USED(test);
 
        if (opt->prod_type == EVT_PROD_TYPE_ETH_RX_ADPTR) {
-               for (i = 0; i < rte_eth_dev_count(); i++) {
+               RTE_ETH_FOREACH_DEV(i) {
                        rte_event_eth_rx_adapter_stop(i);
                        rte_eth_dev_stop(i);
                        rte_eth_dev_close(i);
index 6cad9357b8cbf32e45620cd5300a0ae0d8fb12f3..b4dbe3769ce34a7df1cc5de353bdb6407d067d58 100644 (file)
@@ -213,7 +213,7 @@ pipeline_opt_check(struct evt_options *opt, uint64_t nb_queues)
 int
 pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
 {
-       int i;
+       uint16_t i;
        uint8_t nb_queues = 1;
        uint8_t mt_state = 0;
        struct test_pipeline *t = evt_test_priv(test);
@@ -239,7 +239,7 @@ pipeline_ethdev_setup(struct evt_test *test, struct evt_options *opt)
                return -ENODEV;
        }
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                struct rte_eth_dev_info dev_info;
 
                memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
@@ -337,7 +337,7 @@ pipeline_event_rx_adapter_setup(struct evt_options *opt, uint8_t stride,
        memset(&queue_conf, 0,
                        sizeof(struct rte_event_eth_rx_adapter_queue_conf));
        queue_conf.ev.sched_type = opt->sched_type_list[0];
-       for (prod = 0; prod < rte_eth_dev_count(); prod++) {
+       RTE_ETH_FOREACH_DEV(prod) {
                uint32_t cap;
 
                ret = rte_event_eth_rx_adapter_caps_get(opt->dev_id,
@@ -453,7 +453,7 @@ pipeline_event_tx_service_setup(struct evt_test *test, struct evt_options *opt,
 void
 pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
 {
-       int i;
+       uint16_t i;
        RTE_SET_USED(test);
        RTE_SET_USED(opt);
        struct test_pipeline *t = evt_test_priv(test);
@@ -464,7 +464,7 @@ pipeline_ethdev_destroy(struct evt_test *test, struct evt_options *opt)
                rte_service_component_unregister(t->tx_service.service_id);
        }
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                rte_event_eth_rx_adapter_stop(i);
                rte_eth_dev_stop(i);
                rte_eth_dev_close(i);
index 512e3b55ef668ae90552a0b3060daef940c2435b..3e9006cc1f8ddbee7bed2ac5d077475ce62f195e 100644 (file)
@@ -1999,7 +1999,7 @@ cmd_config_rss_parsed(void *parsed_result,
        struct cmd_config_rss *res = parsed_result;
        struct rte_eth_rss_conf rss_conf = { .rss_key_len = 0, };
        int diag;
-       uint8_t i;
+       uint16_t i;
 
        if (!strcmp(res->value, "all"))
                rss_conf.rss_hf = ETH_RSS_IP | ETH_RSS_TCP |
@@ -2033,7 +2033,7 @@ cmd_config_rss_parsed(void *parsed_result,
                return;
        }
        rss_conf.rss_key = NULL;
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                diag = rte_eth_dev_rss_hash_update(i, &rss_conf);
                if (diag < 0)
                        printf("Configuration of RSS hash at ethernet port %d "
index 29e789e48c20df537adbd486ab9a1ba6a8a1b0f5..7f7560d3964eac990a4cf3aea15662dbafa18cc4 100644 (file)
@@ -1120,9 +1120,8 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
        uint64_t tics_per_1sec;
        uint64_t tics_datum;
        uint64_t tics_current;
-       uint8_t idx_port, cnt_ports;
+       uint16_t idx_port;
 
-       cnt_ports = rte_eth_dev_count();
        tics_datum = rte_rdtsc();
        tics_per_1sec = rte_get_timer_hz();
 #endif
@@ -1137,9 +1136,7 @@ run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)
                        tics_current = rte_rdtsc();
                        if (tics_current - tics_datum >= tics_per_1sec) {
                                /* Periodic bitrate calculation */
-                               for (idx_port = 0;
-                                               idx_port < cnt_ports;
-                                               idx_port++)
+                               RTE_ETH_FOREACH_DEV(idx_port)
                                        rte_stats_bitrate_calc(bitrate_data,
                                                idx_port);
                                tics_datum = tics_current;
index 524747741b9a9bea546238b1c2df61adc2cbb6e2..a0095962c03414e102d66dfb01f128b994ac36de 100644 (file)
@@ -187,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);
@@ -424,14 +424,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");
@@ -451,7 +450,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];
@@ -501,7 +500,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];
index bfdf9c8f2371373742ccdffdaf97a868c30afa79..f14a780ae9f99cba11b1a9b1e35e859087579459 100644 (file)
@@ -193,7 +193,7 @@ in the *DPDK Programmer's Guide* and the *DPDK API Reference*.
     /*
      * Each logical core is assigned a dedicated TX queue on each port.
      */
-    for (portid = 0; portid < nb_ports; portid++) {
+    RTE_ETH_FOREACH_DEV(portid) {
         /* skip ports that are not enabled */
         if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
            continue;
index f02be05ceb7047304b40ceb0f6e188eee24ac293..c91f5738064f7635a2d1567d0fd7a3efaabaac1b 100644 (file)
@@ -213,7 +213,7 @@ in the *DPDK Programmer's Guide* - Rel 1.4 EAR and the *DPDK API Reference*.
      * Each logical core is assigned a dedicated TX queue on each port.
      */
 
-    for (portid = 0; portid < nb_ports; portid++) {
+    RTE_ETH_FOREACH_DEV(portid) {
         /* skip ports that are not enabled */
 
         if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
index 8fa6d76cedf68cb25716487803d73db3e4eef901..57673456be5c4a9f060267e1f0adbd2360e04b4c 100644 (file)
@@ -99,7 +99,7 @@ To fully understand this code, it is recommended to study the chapters that rela
      * Each logical core is assigned a dedicated TX queue on each port.
      */
 
-    for (portid = 0; portid < nb_ports; portid++) {
+    RTE_ETH_FOREACH_DEV(portid) {
         /* skip ports that are not enabled */
 
         if ((lsi_enabled_port_mask & (1 << portid)) == 0)
index 0503584def67badb7d8f46866dc270c75b700e57..d3a3712f41bd71868443b72ee1c437f2d6ef84b3 100644 (file)
@@ -81,7 +81,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);
@@ -199,7 +199,7 @@ looks like the following:
          * 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())
@@ -216,7 +216,7 @@ looks like the 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];
@@ -246,7 +246,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];
index 4a6633ede7244a2a1eb2f1734b829270176b1423..44353a1f86d9b92819025060c4f9b8b54e270f87 100644 (file)
@@ -8,6 +8,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 #
 LIB = librte_pmd_bond.a
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
index 44d5fd8e776d18cdcc296b9ebb0a5135c4cd4289..98fdd37afff1c98584db0d53c76ddda01a9d86b0 100644 (file)
@@ -9,4 +9,6 @@ sources = files('rte_eth_bond_api.c', 'rte_eth_bond_pmd.c',
 deps += 'sched' # needed for rte_bitmap.h
 deps += ['ip_frag', 'cmdline']
 
+allow_experimental_apis = true
+
 install_headers('rte_eth_bond.h', 'rte_eth_bond_8023ad.h')
index e99681e2d48a11d3180e72ca8b1fbaef6545e9d4..eb205c8bb2e2b2b420553a2a3556cff39d219fe1 100644 (file)
@@ -32,7 +32,7 @@ find_port_id_by_pci_addr(const struct rte_pci_addr *pci_addr)
        struct rte_pci_addr *eth_pci_addr;
        unsigned i;
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                pci_dev = RTE_ETH_DEV_TO_PCI(&rte_eth_devices[i]);
                eth_pci_addr = &pci_dev->addr;
 
@@ -50,7 +50,7 @@ find_port_id_by_dev_name(const char *name)
 {
        unsigned i;
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                if (rte_eth_devices[i].data == NULL)
                        continue;
 
index d787154cc4392606c8fb5c638078c5cccc4908ed..05998bf2dbc0f31184ffede00f605111e9773683 100644 (file)
@@ -2810,7 +2810,7 @@ rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
 
        RTE_LOG(INFO, PMD, "Removing %s\n", name);
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) { /* FIXME: removing all devices! */
                char ifname[RTE_ETH_NAME_MAX_LEN];
 
                rte_eth_dev_get_name_by_port(i, ifname);
index 44d10d4f51f99a2e0994fd30df8cfc1f46ec8d5a..e7afce35879511eb352940dcc710ee7861d671ec 100644 (file)
@@ -25,6 +25,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -58,6 +60,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y)
 CFLAGS_main.o += -Wno-return-type
 endif
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
index 455f108eebb8827e0bb4593b670cac496b23a8b1..d68162f1d9f2a3d63a09717e075a3678ceb4963c 100644 (file)
@@ -738,7 +738,7 @@ int
 main(int argc, char *argv[])
 {
        int ret;
-       uint8_t nb_ports, i;
+       uint16_t nb_ports, i;
 
        /* init EAL */
        ret = rte_eal_init(argc, argv);
@@ -761,7 +761,7 @@ main(int argc, char *argv[])
 
        /* initialize all ports */
        slaves_count = nb_ports;
-       for (i = 0; i < nb_ports; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                slave_port_init(i, mbuf_pool);
                slaves[i] = i;
        }
index 8f65e4a8d4667aa633873cd409d426b11e25d319..82e355a49270fa20c8a764dd1b95c5c890dae8cd 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'pmd_bond'
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 05ea0bfecb90810f0ada74f76789b6e8577abaa7..cb1bd216d237ecc21db3abf12509cdf7715a9540 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index c49d680bd0c88335aeb14f70070f11604dbc0e75..62831a05c7a73fcf7008ef7dc6aaf8abae0c3211 100644 (file)
@@ -198,7 +198,7 @@ lcore_rx(struct lcore_params *p)
        uint16_t port;
        struct rte_mbuf *bufs[BURST_SIZE*2];
 
-       for (port = 0; port < nb_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << port)) == 0)
                        continue;
@@ -295,11 +295,11 @@ flush_one_port(struct output_buffer *outbuf, uint8_t outp)
 }
 
 static inline void
-flush_all_ports(struct output_buffer *tx_buffers, uint16_t nb_ports)
+flush_all_ports(struct output_buffer *tx_buffers)
 {
        uint16_t outp;
 
-       for (outp = 0; outp < nb_ports; outp++) {
+       RTE_ETH_FOREACH_DEV(outp) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << outp)) == 0)
                        continue;
@@ -367,11 +367,10 @@ static int
 lcore_tx(struct rte_ring *in_r)
 {
        static struct output_buffer tx_buffers[RTE_MAX_ETHPORTS];
-       const uint16_t nb_ports = rte_eth_dev_count();
        const int socket_id = rte_socket_id();
        uint16_t port;
 
-       for (port = 0; port < nb_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << port)) == 0)
                        continue;
@@ -386,7 +385,7 @@ lcore_tx(struct rte_ring *in_r)
        printf("\nCore %u doing packet TX.\n", rte_lcore_id());
        while (!quit_signal) {
 
-               for (port = 0; port < nb_ports; port++) {
+               RTE_ETH_FOREACH_DEV(port) {
                        /* skip ports that are not enabled */
                        if ((enabled_port_mask & (1 << port)) == 0)
                                continue;
@@ -398,7 +397,7 @@ lcore_tx(struct rte_ring *in_r)
 
                        /* if we get no traffic, flush anything we have */
                        if (unlikely(nb_rx == 0)) {
-                               flush_all_ports(tx_buffers, nb_ports);
+                               flush_all_ports(tx_buffers);
                                continue;
                        }
 
@@ -446,14 +445,14 @@ print_stats(void)
        unsigned int i, j;
        const unsigned int num_workers = rte_lcore_count() - 4;
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                rte_eth_stats_get(i, &eth_stats);
                app_stats.port_rx_pkts[i] = eth_stats.ipackets;
                app_stats.port_tx_pkts[i] = eth_stats.opackets;
        }
 
        printf("\n\nRX Thread:\n");
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                printf("Port %u Pktsin : %5.2f\n", i,
                                (app_stats.port_rx_pkts[i] -
                                prev_app_stats.port_rx_pkts[i])/1000000.0);
@@ -492,7 +491,7 @@ print_stats(void)
        printf(" - Dequeued:    %5.2f\n",
                        (app_stats.tx.dequeue_pkts -
                        prev_app_stats.tx.dequeue_pkts)/1000000.0);
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                printf("Port %u Pktsout: %5.2f\n",
                                i, (app_stats.port_tx_pkts[i] -
                                prev_app_stats.port_tx_pkts[i])/1000000.0);
@@ -694,7 +693,7 @@ main(int argc, char *argv[])
        nb_ports_available = nb_ports;
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        printf("\nSkipping disabled port %d\n", portid);
index 88c001f564b5c213e7864b70857359df05ef260a..d036ea0f6c592ef2bdded0ed9818b2fdebda8032 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'distributor'
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 4cd9efdd574b3c909abd44b7f40f6502703c36e0..1d400f19bcc384ccc90d7aabc0d5a31e25ca90ad 100644 (file)
@@ -16,6 +16,7 @@ APP = ethtool
 # all source are stored in SRCS-y
 SRCS-y := main.c ethapp.c
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3 -D_GNU_SOURCE -pthread -I$(SRCDIR)/../lib
 CFLAGS += $(WERROR_FLAGS)
 
index 0c3f1f6e1473f047d7a6507eaf728b7c086e80f6..4d62f4c17ec8b274d8d185a3d19e7203ebf561d1 100644 (file)
@@ -145,9 +145,9 @@ pcmd_drvinfo_callback(__rte_unused void *ptr_params,
        __rte_unused void *ptr_data)
 {
        struct ethtool_drvinfo info;
-       int id_port;
+       uint16_t id_port;
 
-       for (id_port = 0; id_port < rte_eth_dev_count(); id_port++) {
+       RTE_ETH_FOREACH_DEV(id_port) {
                memset(&info, 0, sizeof(info));
                if (rte_ethtool_get_drvinfo(id_port, &info)) {
                        printf("Error getting info for port %i\n", id_port);
@@ -167,10 +167,10 @@ pcmd_link_callback(__rte_unused void *ptr_params,
        __rte_unused struct cmdline *ctx,
        __rte_unused void *ptr_data)
 {
-       int num_ports = rte_eth_dev_count();
-       int id_port, stat_port;
+       uint16_t id_port;
+       int stat_port;
 
-       for (id_port = 0; id_port < num_ports; id_port++) {
+       RTE_ETH_FOREACH_DEV(id_port) {
                if (!rte_eth_dev_is_valid_port(id_port))
                        continue;
                stat_port = rte_ethtool_get_link(id_port);
index 2422c18490f9e51727f044676623a7ec5b82e3b1..bbab9959735d2090a9b1fb28c1406aafd509e14d 100644 (file)
@@ -339,10 +339,9 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 }
 
 static int
-init_ports(unsigned int num_ports)
+init_ports(uint16_t num_ports)
 {
-       uint8_t portid;
-       unsigned int i;
+       uint16_t portid, i;
 
        if (!cdata.num_mbuf)
                cdata.num_mbuf = 16384 * num_ports;
@@ -354,12 +353,12 @@ init_ports(unsigned int num_ports)
                        /* data_room_size */ RTE_MBUF_DEFAULT_BUF_SIZE,
                        rte_socket_id());
 
-       for (portid = 0; portid < num_ports; portid++)
+       RTE_ETH_FOREACH_DEV(portid)
                if (port_init(portid, mp) != 0)
-                       rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8 "\n",
+                       rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu16 "\n",
                                        portid);
 
-       for (i = 0; i < num_ports; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                void *userdata = (void *)(uintptr_t) i;
                fdata->tx_buf[i] =
                        rte_malloc(NULL, RTE_ETH_TX_BUFFER_SIZE(32), 0);
@@ -375,13 +374,13 @@ init_ports(unsigned int num_ports)
 }
 
 static void
-do_capability_setup(uint16_t nb_ethdev, uint8_t eventdev_id)
+do_capability_setup(uint8_t eventdev_id)
 {
-       int i;
+       uint16_t i;
        uint8_t mt_unsafe = 0;
        uint8_t burst = 0;
 
-       for (i = 0; i < nb_ethdev; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                struct rte_eth_dev_info dev_info;
                memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
 
@@ -483,7 +482,7 @@ main(int argc, char **argv)
                fprintf(stderr, "Warning: More than one eventdev, using idx 0");
 
 
-       do_capability_setup(num_ports, 0);
+       do_capability_setup(0);
        fdata->cap.check_opt();
 
        worker_data = rte_calloc(0, cdata.num_workers,
index c673160f557c2f5075bb037d9d3f0544ff7c53e2..2215e9ebedaf86715a184ddf08a530aff4db29d1 100644 (file)
@@ -138,7 +138,7 @@ consumer(void)
                                &packet, 1, 0);
 
                if (n == 0) {
-                       for (i = 0; i < rte_eth_dev_count(); i++)
+                       RTE_ETH_FOREACH_DEV(i)
                                rte_eth_tx_buffer_flush(i, 0, fdata->tx_buf[i]);
                        return 0;
                }
@@ -196,14 +196,13 @@ consumer_burst(void)
        unsigned int i, j;
        uint8_t dev_id = cons_data.dev_id;
        uint8_t port_id = cons_data.port_id;
-       uint16_t nb_ports = rte_eth_dev_count();
 
        do {
                uint16_t n = rte_event_dequeue_burst(dev_id, port_id,
                                packets, RTE_DIM(packets), 0);
 
                if (n == 0) {
-                       for (j = 0; j < nb_ports; j++)
+                       RTE_ETH_FOREACH_DEV(j)
                                rte_eth_tx_buffer_flush(j, 0, fdata->tx_buf[j]);
                        return 0;
                }
@@ -521,7 +520,7 @@ generic_opt_check(void)
                rte_exit(EXIT_FAILURE,
                                "Event dev doesn't support all type queues\n");
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                ret = rte_event_eth_rx_adapter_caps_get(0, i, &cap);
                if (ret)
                        rte_exit(EXIT_FAILURE,
index b254b03f78499b19e53f7444f2670061192c5148..fc98128ece03ebd15d6cc21db93b3c00e112a92a 100644 (file)
@@ -735,7 +735,7 @@ worker_tx_opt_check(void)
                rte_exit(EXIT_FAILURE,
                                "Event dev doesn't support all type queues\n");
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                ret = rte_event_eth_rx_adapter_caps_get(0, i, &cap);
                if (ret)
                        rte_exit(EXIT_FAILURE,
index ae74781ec7a39c7c77227faa8a6478e29d3b30b7..88f709eff180837059b4ca59ea96b27b5674fa62 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index dda391cd51e1d8303eab8544ff6b97b77360a8e7..996f4939dc21c51b30d58b1b8cc4ba2414860f10 100644 (file)
@@ -475,7 +475,7 @@ init_port(uint16_t port)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -487,7 +487,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -571,14 +571,14 @@ main(int argc, char** argv)
                FATAL_ERROR("Port mask requires more ports than available");
 
        /* Initialise each port */
-       for (port = 0; port < nb_sys_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                /* Skip ports that are not enabled */
                if ((ports_mask & (1 << port)) == 0) {
                        continue;
                }
                init_port(port);
        }
-       check_all_ports_link_status(nb_sys_ports, ports_mask);
+       check_all_ports_link_status(ports_mask);
 
        /* Launch per-lcore function on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
index c34e11e36d214b8deea947d0ae346b0a05db27d9..2b0a25036125381fe131a60eef688103ace49f77 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 32d9b1d3011f6f5fe22c65cd9dbe31139a9fb423..a65ef20f9f1473f4b1808915eae605e6814f44a0 100644 (file)
@@ -259,8 +259,7 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
 static __attribute__((noreturn)) void
 lcore_main(struct flow_classifier *cls_app)
 {
-       const uint8_t nb_ports = rte_eth_dev_count();
-       uint8_t port;
+       uint16_t port;
        int ret;
        int i = 0;
 
@@ -275,7 +274,7 @@ lcore_main(struct flow_classifier *cls_app)
         * 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");
@@ -294,7 +293,7 @@ lcore_main(struct flow_classifier *cls_app)
                 * 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];
                        const uint16_t nb_rx = rte_eth_rx_burst(port, 0,
@@ -754,7 +753,7 @@ main(int argc, char *argv[])
 {
        struct rte_mempool *mbuf_pool;
        uint8_t nb_ports;
-       uint8_t portid;
+       uint16_t portid;
        int ret;
        int socket_id;
        struct rte_table_acl_params table_acl_params;
@@ -789,7 +788,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* Initialize all ports. */
-       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);
index 9e89e744c6f19bdd82e924787b203297bf009f6a..3b58ced54576841ea02bb6c56f0968f2fa750449 100644 (file)
@@ -24,6 +24,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -49,6 +51,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index d3b1da6c0937435bfc37a213e15b7d0ad4d45f20..f525c3a9c96c459f5aa7494ff082cc4a18e363b0 100644 (file)
@@ -571,7 +571,7 @@ print_ethaddr(const char *name, struct ether_addr *eth_addr)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -583,7 +583,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -876,7 +876,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
                struct rte_eth_rxconf rxq_conf;
 
@@ -994,7 +994,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
@@ -1016,7 +1016,7 @@ main(int argc, char **argv)
        if (init_routing_table() < 0)
                rte_exit(EXIT_FAILURE, "Cannot init routing table\n");
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        /* launch per-lcore init on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
index 304203eedd1aa96514db0a0bd1a957ac9167960a..9782a6a7b42589fbdef91a9e1a77c380b77de9b9 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps +=  ['ip_frag', 'lpm']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 1e81315f2a0b63abcedc670b9b4801b2989e4f6c..6438d977e940a76255725711f8eff315efbbe6eb 100644 (file)
@@ -24,6 +24,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -49,6 +51,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 350a9739c178438d8eef101271d14c7466b62ec0..ddff358800f2fa3c52f10928665e80bc3e999702 100644 (file)
@@ -702,7 +702,7 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -714,7 +714,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -1023,7 +1023,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_conf local_port_conf = port_conf;
 
@@ -1141,7 +1141,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
@@ -1157,7 +1157,7 @@ main(int argc, char **argv)
        if (init_routing_table() < 0)
                rte_exit(EXIT_FAILURE, "Cannot init routing table\n");
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        signal(SIGUSR1, signal_handler);
        signal(SIGTERM, signal_handler);
index 8ebd4829154169c5f99f8be26ba29ab40d42ec95..8a667c26580e37ad03fcaf71a7bec8056cc634de 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['lpm', 'ip_frag']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 3a8562ee9d5dadb9b6700dd2e4307e18862a3b9a..3001d626b671cbe98e663f26bfe2373e84f76428 100644 (file)
@@ -1173,7 +1173,7 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -1185,7 +1185,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -1383,7 +1383,7 @@ cryptodevs_init(void)
                if (sess_sz > max_sess_sz)
                        max_sess_sz = sess_sz;
        }
-       for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
+       RTE_ETH_FOREACH_DEV(port_id) {
                void *sec_ctx;
 
                if ((enabled_port_mask & (1 << port_id)) == 0)
@@ -1470,7 +1470,7 @@ cryptodevs_init(void)
        }
 
        /* create session pools for eth devices that implement security */
-       for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
+       RTE_ETH_FOREACH_DEV(port_id) {
                if ((enabled_port_mask & (1 << port_id)) &&
                                rte_eth_dev_get_sec_ctx(port_id)) {
                        int socket_id = rte_eth_dev_socket_id(port_id);
@@ -1646,7 +1646,7 @@ main(int32_t argc, char **argv)
        int32_t ret;
        uint32_t lcore_id;
        uint8_t socket_id;
-       uint16_t portid, nb_ports;
+       uint16_t portid;
 
        /* init EAL */
        ret = rte_eal_init(argc, argv);
@@ -1665,8 +1665,6 @@ main(int32_t argc, char **argv)
                rte_exit(EXIT_FAILURE, "Invalid unprotected portmask 0x%x\n",
                                unprotected_port_mask);
 
-       nb_ports = rte_eth_dev_count();
-
        if (check_params() < 0)
                rte_exit(EXIT_FAILURE, "check_params failed\n");
 
@@ -1700,7 +1698,7 @@ main(int32_t argc, char **argv)
                pool_init(&socket_ctx[socket_id], socket_id, NB_MBUF);
        }
 
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
 
@@ -1710,7 +1708,7 @@ main(int32_t argc, char **argv)
        cryptodevs_init();
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
 
@@ -1729,7 +1727,7 @@ main(int32_t argc, char **argv)
                        rte_eth_promiscuous_enable(portid);
        }
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        /* launch per-lcore init on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
index a16c623332d2638dd115b5fdcc5dc6712685ccb5..236e706b30b8d317d32c5d14110051e387bf5f7c 100644 (file)
@@ -24,6 +24,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -49,6 +51,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index c3bcf2c808b37d78fae25f6b6a4d603bce2bd4ad..23b266bbe2ddeddeb05bf7c15ea6b84d72108a38 100644 (file)
@@ -578,7 +578,7 @@ init_mcast_hash(void)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -590,7 +590,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -683,7 +683,7 @@ main(int argc, char **argv)
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_conf local_port_conf = port_conf;
 
@@ -786,7 +786,7 @@ main(int argc, char **argv)
                printf("done:\n");
        }
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        /* initialize the multicast hash */
        int retval = init_mcast_hash();
index d9e4c7c2190a878754425906769b626c6d4ea960..6969e2c54a337211b6a5055da826c5c31c0fe043 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'hash'
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 562dc2741267260d2456e3a9dac361fc02484456..96ae2fc6f8340dd2a0a3873a170f70c097f7874c 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -53,6 +55,7 @@ $(error This application can only operate in a linuxapp environment, \
 please change the definition of the RTE_TARGET environment variable)
 endif
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index aebfedd598514e2a62e360a410a3a433561a3925..d944bae6923b59463ba700b87542ff8169771eeb 100644 (file)
@@ -275,7 +275,7 @@ kni_egress(struct kni_port_params *p)
 static int
 main_loop(__rte_unused void *arg)
 {
-       uint8_t i, nb_ports = rte_eth_dev_count();
+       uint16_t i;
        int32_t f_stop;
        const unsigned lcore_id = rte_lcore_id();
        enum lcore_rxtx {
@@ -286,7 +286,7 @@ main_loop(__rte_unused void *arg)
        };
        enum lcore_rxtx flag = LCORE_NONE;
 
-       for (i = 0; i < nb_ports; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                if (!kni_port_params_array[i])
                        continue;
                if (kni_port_params_array[i]->lcore_rx == (uint8_t)lcore_id) {
@@ -626,7 +626,7 @@ init_port(uint16_t port)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -638,7 +638,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -940,7 +940,7 @@ main(int argc, char** argv)
        init_kni();
 
        /* Initialise each port */
-       for (port = 0; port < nb_sys_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                /* Skip ports that are not enabled */
                if (!(ports_mask & (1 << port)))
                        continue;
@@ -952,7 +952,7 @@ main(int argc, char** argv)
 
                kni_alloc(port);
        }
-       check_all_ports_link_status(nb_sys_ports, ports_mask);
+       check_all_ports_link_status(ports_mask);
 
        /* Launch per-lcore function on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
@@ -962,7 +962,7 @@ main(int argc, char** argv)
        }
 
        /* Release resources */
-       for (port = 0; port < nb_sys_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                if (!(ports_mask & (1 << port)))
                        continue;
                kni_free_kni(port);
index c39aead6f73c9aa36a2e7ade572e8cd14ea668c0..bf3561713b70c25d4b5222eaa53338ef359e0e3f 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['kni', 'bus_pci']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index aec770c28b785e2ce732ae1339af6fe87913fb49..fe0f20073356e0b800dddccf07b148990333159e 100644 (file)
@@ -23,6 +23,7 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -D_GNU_SOURCE
 LDFLAGS += -lpqos
 
@@ -55,6 +56,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index 69339cca81b81680476ef0acf8f134d9e72bd429..34429286468eedd2e8f19d3c4f8262d802544169 100644 (file)
@@ -95,14 +95,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 static __attribute__((noreturn)) void
 lcore_main(void)
 {
-       const uint16_t nb_ports = rte_eth_dev_count();
        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())
@@ -119,7 +118,7 @@ lcore_main(void)
                 * 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];
@@ -186,7 +185,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* Initialize all ports. */
-       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 %"PRIu16 "\n",
                                        portid);
index b6deabc9765607f621e48461e8ed4b7f6b1a5874..29e5d0cf76a016fedfe38c2b714b0c0e7fbfdd14 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 ext_deps += cc.find_library('pqos')
+allow_experimental_apis = true
 cflags += '-D_GNU_SOURCE'
 cflags += '-I/usr/local/include' # assume pqos lib installed in /usr/local
 sources = files(
index a67f087b288cc2cd4dad2f982a86d99665a50a40..99afdd2e35e91f65deef2ec3a2702bdd8fc74dd8 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 4d8341e291296c5f468c3f4400294390c2c0166a..b1ad19284166667d8034dc1425b5d5b16ac1647c 100644 (file)
@@ -1721,7 +1721,7 @@ l2fwd_crypto_parse_args(struct l2fwd_crypto_options *options,
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -1733,7 +1733,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -2309,7 +2309,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 static int
 initialize_ports(struct l2fwd_crypto_options *options)
 {
-       uint16_t last_portid, portid;
+       uint16_t last_portid = 0, portid;
        unsigned enabled_portcount = 0;
        unsigned nb_ports = rte_eth_dev_count();
 
@@ -2322,7 +2322,7 @@ initialize_ports(struct l2fwd_crypto_options *options)
        for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++)
                l2fwd_dst_ports[portid] = 0;
 
-       for (last_portid = 0, portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                int retval;
                struct rte_eth_dev_info dev_info;
                struct rte_eth_rxconf rxq_conf;
@@ -2426,7 +2426,7 @@ initialize_ports(struct l2fwd_crypto_options *options)
                return -1;
        }
 
-       check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+       check_all_ports_link_status(l2fwd_enabled_port_mask);
 
        return enabled_portcount;
 }
@@ -2470,12 +2470,12 @@ reserve_key_memory(struct l2fwd_crypto_options *options)
 int
 main(int argc, char **argv)
 {
-       struct lcore_queue_conf *qconf;
+       struct lcore_queue_conf *qconf = NULL;
        struct l2fwd_crypto_options options;
 
        uint8_t nb_cryptodevs, cdev_id;
-       uint16_t nb_ports, portid;
-       unsigned lcore_id, rx_lcore_id;
+       uint16_t portid;
+       unsigned lcore_id, rx_lcore_id = 0;
        int ret, enabled_cdevcount, enabled_portcount;
        uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] = {0};
 
@@ -2516,10 +2516,8 @@ main(int argc, char **argv)
        if (enabled_portcount < 1)
                rte_exit(EXIT_FAILURE, "Failed to initial Ethernet ports\n");
 
-       nb_ports = rte_eth_dev_count();
        /* Initialize the port/queue configuration of each logical core */
-       for (rx_lcore_id = 0, qconf = NULL, portid = 0;
-                       portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
 
                /* skip ports that are not enabled */
                if ((options.portmask & (1 << portid)) == 0)
index 09438a6a022bd91f1e32aeefdff4528f9e061838..6c852ad1994eef8451fd8485fbf1587a57addebe 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'cryptodev'
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 696a8b21a41919270981886e95025ea3110bf00d..a9315d47565390ae941b8034b15a4eca7b732af8 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,7 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
-
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 2554f448af032b64b9c3709d40b13c303645a34d..248224840a258f0cf3283896822fd10cba421457 100644 (file)
@@ -680,7 +680,7 @@ l2fwd_parse_args(int argc, char **argv)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -692,7 +692,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -742,7 +742,7 @@ main(int argc, char **argv)
        int ret;
        char name[RTE_JOBSTATS_NAMESIZE];
        uint16_t nb_ports;
-       uint16_t nb_ports_available;
+       uint16_t nb_ports_available = 0;
        uint16_t portid, last_port;
        uint8_t i;
 
@@ -782,7 +782,7 @@ main(int argc, char **argv)
        /*
         * Each logical core is assigned a dedicated TX queue on each port.
         */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -804,7 +804,7 @@ main(int argc, char **argv)
        qconf = NULL;
 
        /* Initialize the port/queue configuration of each logical core */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -827,10 +827,8 @@ main(int argc, char **argv)
                printf("Lcore %u: RX port %u\n", rx_lcore_id, portid);
        }
 
-       nb_ports_available = nb_ports;
-
        /* Initialise each port */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_dev_info dev_info;
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_txconf txq_conf;
@@ -839,9 +837,10 @@ main(int argc, char **argv)
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
                        printf("Skipping disabled port %u\n", portid);
-                       nb_ports_available--;
                        continue;
                }
+               nb_ports_available++;
+
                /* init port */
                printf("Initializing port %u... ", portid);
                fflush(stdout);
@@ -934,7 +933,7 @@ main(int argc, char **argv)
                        "All available ports are disabled. Please set portmask.\n");
        }
 
-       check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+       check_all_ports_link_status(l2fwd_enabled_port_mask);
 
        drain_tsc = (hz + US_PER_S - 1) / US_PER_S * BURST_TX_DRAIN_US;
 
index 1ffd484e2350051155f886979ccb7de60b3aa32e..3653aa7ec5af311d7c05c6a90b701e754a4e026e 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['jobstats', 'timer']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 4ab67db44ed1e4ed6ff4f866e4fdab18c6312ba2..af28956680f440e37ed40daa3bd792a8920fe7bc 100644 (file)
@@ -25,6 +25,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -50,6 +52,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 LDFLAGS += -lrt
index 39b8c328639c63fffd0a8b5015da623b83490250..e9ad91a1fc7e2f9d766cf7d566adcd92b604f0c4 100644 (file)
@@ -445,7 +445,7 @@ l2fwd_parse_args(int argc, char **argv)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -457,7 +457,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -526,7 +526,7 @@ main(int argc, char **argv)
        struct lcore_queue_conf *qconf;
        int ret;
        uint16_t nb_ports;
-       uint16_t nb_ports_available;
+       uint16_t nb_ports_available = 0;
        uint16_t portid, last_port;
        unsigned lcore_id, rx_lcore_id;
        unsigned nb_ports_in_mask = 0;
@@ -573,7 +573,7 @@ main(int argc, char **argv)
        /*
         * Each logical core is assigned a dedicated TX queue on each port.
         */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -595,7 +595,7 @@ main(int argc, char **argv)
        qconf = NULL;
 
        /* Initialize the port/queue configuration of each logical core */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -619,10 +619,8 @@ main(int argc, char **argv)
                        rx_lcore_id, portid);
        }
 
-       nb_ports_available = nb_ports;
-
        /* Initialise each port */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_dev_info dev_info;
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_txconf txq_conf;
@@ -631,9 +629,10 @@ main(int argc, char **argv)
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
                        printf("Skipping disabled port %u\n", portid);
-                       nb_ports_available--;
                        continue;
                }
+               nb_ports_available++;
+
                /* init port */
                printf("Initializing port %u... ", portid);
                fflush(stdout);
@@ -728,7 +727,7 @@ main(int argc, char **argv)
                        "All available ports are disabled. Please set portmask.\n");
        }
 
-       check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+       check_all_ports_link_status(l2fwd_enabled_port_mask);
 
        struct rte_timer hb_timer, stats_timer;
 
index 6f7b007e1e4378f5c2f7577d96d9e7697331f947..2dffffaaa054791881631ca2c080a689f4c08077 100644 (file)
@@ -8,6 +8,7 @@
 
 ext_deps += cc.find_library('rt')
 deps += 'timer'
+allow_experimental_apis = true
 sources = files(
        'main.c', 'shm.c'
 )
index a8a47ad4e22bdf35f288dcd940e3d6a9fc3a4b85..1d7760de9c234e1593af192952e8a6b1494d0b4a 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index e4a4a7c36c5df2428c6e735ea97e2e81e6825c29..f8ca29cf679118374941ae9dbe0fc509cfeab45a 100644 (file)
@@ -444,7 +444,7 @@ l2fwd_parse_args(int argc, char **argv)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -458,7 +458,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                if (force_quit)
                        return;
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if (force_quit)
                                return;
                        if ((port_mask & (1 << portid)) == 0)
@@ -517,7 +517,7 @@ main(int argc, char **argv)
        struct lcore_queue_conf *qconf;
        int ret;
        uint16_t nb_ports;
-       uint16_t nb_ports_available;
+       uint16_t nb_ports_available = 0;
        uint16_t portid, last_port;
        unsigned lcore_id, rx_lcore_id;
        unsigned nb_ports_in_mask = 0;
@@ -562,7 +562,7 @@ main(int argc, char **argv)
        /*
         * Each logical core is assigned a dedicated TX queue on each port.
         */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -585,7 +585,7 @@ main(int argc, char **argv)
        qconf = NULL;
 
        /* Initialize the port/queue configuration of each logical core */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -610,8 +610,6 @@ main(int argc, char **argv)
                printf("Lcore %u: RX port %u\n", rx_lcore_id, portid);
        }
 
-       nb_ports_available = nb_ports;
-
        nb_mbufs = RTE_MAX(nb_ports * (nb_rxd + nb_txd + MAX_PKT_BURST +
                nb_lcores * MEMPOOL_CACHE_SIZE), 8192U);
 
@@ -623,7 +621,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n");
 
        /* Initialise each port */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_txconf txq_conf;
                struct rte_eth_conf local_port_conf = port_conf;
@@ -632,9 +630,10 @@ main(int argc, char **argv)
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
                        printf("Skipping disabled port %u\n", portid);
-                       nb_ports_available--;
                        continue;
                }
+               nb_ports_available++;
+
                /* init port */
                printf("Initializing port %u... ", portid);
                fflush(stdout);
@@ -726,7 +725,7 @@ main(int argc, char **argv)
                        "All available ports are disabled. Please set portmask.\n");
        }
 
-       check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+       check_all_ports_link_status(l2fwd_enabled_port_mask);
 
        ret = 0;
        /* launch per-lcore init on every lcore */
@@ -738,7 +737,7 @@ main(int argc, char **argv)
                }
        }
 
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
                printf("Closing port %d...", portid);
index c34e11e36d214b8deea947d0ae346b0a05db27d9..2b0a25036125381fe131a60eef688103ace49f77 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 285683f833fd3ec8a8c2088cf6fe992af95dba8e..eabca1ed71c6539031a5474c49854315b2e9ffe7 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 9aebb331844063df0d248de138675fbcca4a4a37..3c547cd8e7db4b2cce791094af10bb32909864a5 100644 (file)
@@ -1805,7 +1805,7 @@ init_mem(unsigned nb_mbuf)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -1817,7 +1817,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -1903,7 +1903,7 @@ main(int argc, char **argv)
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -2043,7 +2043,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
 
@@ -2064,7 +2064,7 @@ main(int argc, char **argv)
                        rte_eth_promiscuous_enable(portid);
        }
 
-       check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        /* launch per-lcore init on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
index 7096e00c107351ac99da879200a26d10b7c839c1..68cebd6cee70b09465c5748219debb43a6853a15 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['acl', 'lpm', 'hash']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 390b7d6b6d3c923f393e31eba12a2d0cd1cd6495..d4e1ac64f08b9e018cce202325bb8cddb9a58a56 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -54,6 +56,7 @@ please change the definition of the RTE_TARGET environment variable)
 all:
 else
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index b2a7c79e66bfffb20e97abced99973d48d55d4b8..16f4d098c6e36f80199d3c4c3416b945facedeaf 100644 (file)
@@ -341,7 +341,7 @@ static void
 signal_exit_now(int sigtype)
 {
        unsigned lcore_id;
-       unsigned int portid, nb_ports;
+       unsigned int portid;
        int ret;
 
        if (sigtype == SIGINT) {
@@ -357,8 +357,7 @@ signal_exit_now(int sigtype)
                                                        "core%u\n", lcore_id);
                }
 
-               nb_ports = rte_eth_dev_count();
-               for (portid = 0; portid < nb_ports; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((enabled_port_mask & (1 << portid)) == 0)
                                continue;
 
@@ -1512,7 +1511,7 @@ init_mem(unsigned nb_mbuf)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -1524,7 +1523,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -1659,7 +1658,7 @@ main(int argc, char **argv)
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -1834,7 +1833,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
@@ -1855,7 +1854,7 @@ main(int argc, char **argv)
                rte_spinlock_init(&(locks[portid]));
        }
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        /* launch per-lcore init on every lcore */
        rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
index 61e8daa96fd59146f2dc7eb438a80b1136583c81..cb50c7ab43ee614a23fb1c6c969d14a2b2872b54 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['power', 'timer', 'lpm', 'hash']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index dfb1d52d36a08453a48fe74fdaf9f7b853d7f3fc..d776689fa094c3a73fcb68dd4339b17499bc16ad 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3 $(USER_FLAGS)
 CFLAGS += $(WERROR_FLAGS)
 
index c69bd62fae4c39b8cb62d2463b5211b8fbadd017..7a9927c343ba9281eb2b2235edebc6cb19b4ac19 100644 (file)
@@ -648,11 +648,10 @@ static void
 signal_handler(int signum)
 {
        uint16_t portid;
-       uint16_t nb_ports = rte_eth_dev_count();
 
        /* When we receive a SIGINT signal */
        if (signum == SIGINT) {
-               for (portid = 0; portid < nb_ports; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        /* skip ports that are not enabled */
                        if ((enabled_port_mask & (1 << portid)) == 0)
                                continue;
@@ -958,7 +957,7 @@ main(int argc, char **argv)
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -1063,7 +1062,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
index 226286e74489db0f02b644ede618e6bcc5acc443..00f3c38f4776ff173b76da45ed5070847c519aeb 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['lpm', 'hash']
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index cccdd9dfaa03198490e4dbece829ca180aeb2cff..8cc8f6aaa19388999dda212208e7e588c4779793 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -I$(SRCDIR)
 CFLAGS += -O3 $(USER_FLAGS)
 CFLAGS += $(WERROR_FLAGS)
index e7111fa18c404a57596566478de8150754d2e368..8f7961cec551683d55c603942ec158a945811cf7 100644 (file)
@@ -694,7 +694,7 @@ init_mem(unsigned nb_mbuf)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -708,7 +708,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                if (force_quit)
                        return;
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if (force_quit)
                                return;
                        if ((port_mask & (1 << portid)) == 0)
@@ -837,7 +837,7 @@ main(int argc, char **argv)
        setup_l3fwd_lookup_tables();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -971,7 +971,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
@@ -1007,7 +1007,7 @@ main(int argc, char **argv)
        }
 
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        ret = 0;
        /* launch per-lcore init on every lcore */
@@ -1020,7 +1020,7 @@ main(int argc, char **argv)
        }
 
        /* stop ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
                printf("Closing port %d...", portid);
index 6dd4b902223de59988196daf1806ef88deb74707..cbef07f4fc764a44b0b826cc550a0a9a628a976b 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['hash', 'lpm']
+allow_experimental_apis = true
 sources = files(
        'l3fwd_em.c', 'l3fwd_lpm.c', 'main.c'
 )
index b65582ef10bdd0bfaa905c25d8fe4fff01ae1bae..79d506862d3bec4c27e327a924723c9649061d91 100644 (file)
@@ -16,6 +16,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index bc9ceb5ca48cda35ab2fd036f38428bccba61fc6..6b130f2f5dd29df71ae6dff2b89b5fdf2a23ba62 100644 (file)
@@ -838,7 +838,7 @@ l2fwd_parse_args(int argc, char **argv)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -850,7 +850,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -897,7 +897,7 @@ main(int argc, char **argv)
        struct lcore_queue_conf *qconf;
        int ret;
        uint16_t nb_ports;
-       uint16_t nb_ports_available;
+       uint16_t nb_ports_available = 0;
        uint16_t portid, last_port;
        unsigned rx_lcore_id;
        unsigned nb_ports_in_mask = 0;
@@ -946,7 +946,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n");
 
        /* create the mbuf pool */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -969,7 +969,7 @@ main(int argc, char **argv)
        /*
         * Each logical core is assigned a dedicated TX queue on each port.
         */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
                        continue;
@@ -992,7 +992,7 @@ main(int argc, char **argv)
        qconf = NULL;
 
        /* Initialize the port/queue configuration of each logical core */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct lcore_resource_struct *res;
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0)
@@ -1025,10 +1025,8 @@ main(int argc, char **argv)
                printf("Lcore %u: RX port %u\n", rx_lcore_id, (unsigned) portid);
        }
 
-       nb_ports_available = nb_ports;
-
        /* Initialise each port */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_txconf txq_conf;
                struct rte_eth_conf local_port_conf = port_conf;
@@ -1036,9 +1034,9 @@ main(int argc, char **argv)
                /* skip ports that are not enabled */
                if ((l2fwd_enabled_port_mask & (1 << portid)) == 0) {
                        printf("Skipping disabled port %u\n", (unsigned) portid);
-                       nb_ports_available--;
                        continue;
                }
+               nb_ports_available++;
                /* init port */
                printf("Initializing port %u... ", (unsigned) portid);
                fflush(stdout);
@@ -1129,7 +1127,7 @@ main(int argc, char **argv)
                        "All available ports are disabled. Please set portmask.\n");
        }
 
-       check_all_ports_link_status(nb_ports, l2fwd_enabled_port_mask);
+       check_all_ports_link_status(l2fwd_enabled_port_mask);
 
        /* Record pair lcore */
        /**
@@ -1140,7 +1138,7 @@ main(int argc, char **argv)
         * procedure completed. So, record the pair relationship for those lcores working
         * on ports.
         **/
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                uint32_t pair_port;
                unsigned lcore = 0, pair_lcore = 0;
                unsigned j, find_lcore, find_pair_lcore;
index 6fb9cc3663b14f422cff30f38bf9828e04402b76..6c0fcb55b29e311fc37672723d0aed56d963567d 100644 (file)
@@ -16,6 +16,7 @@ APP = symmetric_mp
 # all source are stored in SRCS-y
 SRCS-y := main.c
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 1ada4ef5167c554691d5dc2e4837b6626993ecc2..2fbf088038ffab9e4c4a77ec4fe3376a7f59ab19 100644 (file)
@@ -115,7 +115,7 @@ smp_parse_args(int argc, char **argv)
        int opt, ret;
        char **argvopt;
        int option_index;
-       unsigned i, port_mask = 0;
+       uint16_t i, port_mask = 0;
        char *prgname = argv[0];
        static struct option lgopts[] = {
                        {PARAM_NUM_PROCS, 1, 0, 0},
@@ -156,7 +156,7 @@ smp_parse_args(int argc, char **argv)
                smp_usage(prgname, "Invalid or missing port mask\n");
 
        /* get the port numbers from the port mask */
-       for(i = 0; i < rte_eth_dev_count(); i++)
+       RTE_ETH_FOREACH_DEV(i)
                if(port_mask & (1 << i))
                        ports[num_ports++] = (uint8_t)i;
 
index 3cf1ee1dc3ff9ffe6d50ef413f81b1710796ac19..5eb503c25a3735e89c0237c0854fd706779e0c7c 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index 97a58ddaf3a2849a383060c0a72c1fe5ed7e8685..964e23c2e42648a32ef98ebaea597f398d50dd7f 100644 (file)
@@ -211,11 +211,10 @@ flush_tx_error_callback(struct rte_mbuf **unsent, uint16_t count,
 
 static inline int
 free_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[]) {
-       const uint8_t nb_ports = rte_eth_dev_count();
-       unsigned port_id;
+       uint16_t port_id;
 
        /* initialize buffers for all ports */
-       for (port_id = 0; port_id < nb_ports; port_id++) {
+       RTE_ETH_FOREACH_DEV(port_id) {
                /* skip ports that are not enabled */
                if ((portmask & (1 << port_id)) == 0)
                        continue;
@@ -228,12 +227,11 @@ free_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[]) {
 static inline int
 configure_tx_buffers(struct rte_eth_dev_tx_buffer *tx_buffer[])
 {
-       const uint8_t nb_ports = rte_eth_dev_count();
-       unsigned port_id;
+       uint16_t port_id;
        int ret;
 
        /* initialize buffers for all ports */
-       for (port_id = 0; port_id < nb_ports; port_id++) {
+       RTE_ETH_FOREACH_DEV(port_id) {
                /* skip ports that are not enabled */
                if ((portmask & (1 << port_id)) == 0)
                        continue;
@@ -325,8 +323,7 @@ configure_eth_port(uint16_t port_id)
 static void
 print_stats(void)
 {
-       const uint8_t nb_ports = rte_eth_dev_count();
-       unsigned i;
+       uint16_t i;
        struct rte_eth_stats eth_stats;
 
        printf("\nRX thread stats:\n");
@@ -355,7 +352,7 @@ print_stats(void)
        printf(" - Pkts tx failed w/o reorder:          %"PRIu64"\n",
                                                app_stats.tx.early_pkts_tx_failed_woro);
 
-       for (i = 0; i < nb_ports; i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                rte_eth_stats_get(i, &eth_stats);
                printf("\nPort %u stats:\n", i);
                printf(" - Pkts in:   %"PRIu64"\n", eth_stats.ipackets);
@@ -383,7 +380,6 @@ int_handler(int sig_num)
 static int
 rx_thread(struct rte_ring *ring_out)
 {
-       const uint8_t nb_ports = rte_eth_dev_count();
        uint32_t seqn = 0;
        uint16_t i, ret = 0;
        uint16_t nb_rx_pkts;
@@ -395,7 +391,7 @@ rx_thread(struct rte_ring *ring_out)
 
        while (!quit_signal) {
 
-               for (port_id = 0; port_id < nb_ports; port_id++) {
+               RTE_ETH_FOREACH_DEV(port_id) {
                        if ((portmask & (1 << port_id)) != 0) {
 
                                /* receive packets */
@@ -665,7 +661,7 @@ main(int argc, char **argv)
        nb_ports_available = nb_ports;
 
        /* initialize all ports */
-       for (port_id = 0; port_id < nb_ports; port_id++) {
+       RTE_ETH_FOREACH_DEV(port_id) {
                /* skip ports that are not enabled */
                if ((portmask & (1 << port_id)) == 0) {
                        printf("\nSkipping disabled port %d\n", port_id);
index 6c2fccdcb0902b9e62d658dbd01f4a81d5dd5786..a3776946f63b45dd77da082b23e5b9db70a0ef94 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'reorder'
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 5558043f2af6164466f7a84abf299e043b5d8123..5ac543645525ce26c75a9bfc9b22a2d2b76ff925 100644 (file)
@@ -18,6 +18,7 @@ SRCS-y := main.c
 
 include $(RTE_SDK)/examples/performance-thread/common/common.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3 -g $(USER_FLAGS) $(INCLUDES) $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index c04294cfdd3ed7e0af1f9a4153eb65f9f20aac8d..4fafed16d94b12b53776e923bafe9ea3df708da9 100644 (file)
@@ -3411,7 +3411,7 @@ init_mem(unsigned nb_mbuf)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -3423,7 +3423,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -3522,7 +3522,7 @@ main(int argc, char **argv)
        nb_lcores = rte_lcore_count();
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_conf local_port_conf = port_conf;
 
                /* skip ports that are not enabled */
@@ -3654,7 +3654,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0)
                        continue;
 
@@ -3699,7 +3699,7 @@ main(int argc, char **argv)
                }
        }
 
-       check_all_ports_link_status((uint8_t)nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        if (lthreads_on) {
                printf("Starting L-Threading Model\n");
index 989e2dd40c6e1d53065ebd4662da50f47085a97d..1c1d9cdbb99046ff0da0e3c4db58132290a93d7b 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 
index fa0cbe93c82990b5b3f48f49452e984c74ac7913..d4171a21832b89ad4cfb8925a10e3de2e09e3612 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'ptpclient.c'
 )
index 83821eb8d7a0175d7b77a4e85efbb4306ac008a2..ad98a392f88c8f5fef222cfb3c1934e9894d36dc 100644 (file)
@@ -737,7 +737,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* Initialize all ports. */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((ptp_enabled_port_mask & (1 << portid)) != 0) {
                        if (port_init(portid, mbuf_pool) == 0) {
                                ptp_enabled_ports[ptp_enabled_port_nb] = portid;
index e9d30d56f3c94c34e4efe3566af49612fefbb2a1..c72ba66d6c772a0696be9a9a11850fbdac35db12 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index d2e5e19e687d0bc5ae1419bbc09ca34b33f72e1c..46dacc7efee009523c7fda09cb9b4392fffc9b0f 100644 (file)
@@ -24,8 +24,6 @@ static const struct rte_eth_conf port_conf_default = {
        },
 };
 
-static unsigned nb_ports;
-
 static struct {
        uint64_t total_cycles;
        uint64_t total_pkts;
@@ -145,7 +143,7 @@ lcore_main(void)
 {
        uint16_t port;
 
-       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())
@@ -156,7 +154,7 @@ lcore_main(void)
        printf("\nCore %u forwarding packets. [Ctrl+C to quit]\n",
                        rte_lcore_id());
        for (;;) {
-               for (port = 0; port < nb_ports; port++) {
+               RTE_ETH_FOREACH_DEV(port) {
                        struct rte_mbuf *bufs[BURST_SIZE];
                        const uint16_t nb_rx = rte_eth_rx_burst(port, 0,
                                        bufs, BURST_SIZE);
@@ -179,6 +177,7 @@ int
 main(int argc, char *argv[])
 {
        struct rte_mempool *mbuf_pool;
+       uint16_t nb_ports;
        uint16_t portid;
 
        /* init EAL */
@@ -200,7 +199,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* initialize all ports */
-       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);
index c34e11e36d214b8deea947d0ae346b0a05db27d9..2b0a25036125381fe131a60eef688103ace49f77 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index bd980ec9bb759417058578a7b133ad44d62e870a..a4a1860cbaf4db0853b729602a150cfb8e5fe4c3 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index e62cc0a59a8cafde3d1b51e8b5e9b042408ea92c..11a9b57478c558e900b3fcaa097c0a83918ceb79 100644 (file)
@@ -106,14 +106,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 static __attribute__((noreturn)) void
 lcore_main(void)
 {
-       const uint16_t nb_ports = rte_eth_dev_count();
        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())
@@ -130,7 +129,7 @@ lcore_main(void)
                 * 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];
@@ -186,7 +185,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* Initialize all ports. */
-       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 %"PRIu16 "\n",
                                        portid);
index 9bb9ec3294d5415fb873e634e15da13d7a853cb3..ef46b187e7003c4c058438738b4fd20a3405fddf 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'basicfwd.c'
 )
index d2c357a1c36828b934357ee730214a77b4a3962c..2b93446c0887f0f9c3660a49841d450538444191 100644 (file)
@@ -25,6 +25,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -55,6 +57,7 @@ $(error This application can only operate in a linuxapp environment, \
 please change the definition of the RTE_TARGET environment variable)
 endif
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -D_GNU_SOURCE
index 270739138f2be65a0b5b510a9ae7c7ff28ac74b4..cc12cd87ac95ed1c25f74c8aa51133229e275ed7 100644 (file)
@@ -1185,7 +1185,7 @@ main(int argc, char *argv[])
                vpool_array[queue_id].pool = mbuf_pool;
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        RTE_LOG(INFO, VHOST_PORT,
index 68c940aabaaa32353963cb60b951dee970499b30..24697ec6d27ff076aeb45df332ad2b92a3f15de9 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += ['hash', 'vhost']
+allow_experimental_apis = true
 sources = files(
        'main.c', 'vxlan.c', 'vxlan_setup.c'
 )
index 2dc62ebf0cdbbe5d9384a290056b40a1f68ed251..67cc55b1bc03737c7e4ef13d44e281e5dd65a7a2 100644 (file)
@@ -25,6 +25,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -56,6 +58,7 @@ please change the definition of the RTE_TARGET environment variable)
 all:
 else
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O2 -D_FILE_OFFSET_BITS=64
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -D_GNU_SOURCE
index 60d862b4208a25deb5320c32f73b8477a4e645d2..0b5221f1e6e2137521975ab04bdea049b75b7019 100644 (file)
@@ -1477,7 +1477,7 @@ main(int argc, char *argv[])
        }
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        RTE_LOG(INFO, VHOST_PORT,
index 3e6e69047b6bbe3540aea1a356885aa8d48bd745..64c84ee124b012109e893ff842b3841375477ec9 100644 (file)
@@ -7,6 +7,7 @@
 # DPDK instance, use 'make'
 
 deps += 'vhost'
+allow_experimental_apis = true
 sources = files(
        'main.c', 'virtio_net.c'
 )
index ef2a9f959781e0f7698bacae0892557927e8d367..608d0d9f4fd61a813e9ca30b2fea76c63de57e4f 100644 (file)
@@ -21,6 +21,7 @@ APP = vm_power_mgr
 SRCS-y := main.c vm_power_cli.c power_manager.c channel_manager.c
 SRCS-y += channel_monitor.c
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3 -I$(RTE_SDK)/lib/librte_power/
 CFLAGS += $(WERROR_FLAGS)
 
index 1c7b6eb2dd6ce51b118c64b1fc5dd05908a1a434..73bddd9936222c85c53c4c8b43c583a2fa274b18 100644 (file)
@@ -110,12 +110,11 @@ static int
 get_pfid(struct policy *pol)
 {
 
-       int i, x, ret = 0, nb_ports;
+       int i, x, ret = 0;
 
-       nb_ports = rte_eth_dev_count();
        for (i = 0; i < pol->pkt.nb_mac_to_monitor; i++) {
 
-               for (x = 0; x < nb_ports; x++) {
+               RTE_ETH_FOREACH_DEV(x) {
                        ret = rte_pmd_i40e_query_vfid_by_mac(x,
                                (struct ether_addr *)&(pol->pkt.vfid[i]));
                        if (ret != -EINVAL) {
index 8a1e95bd7de765216aff37db5515d693583cc100..4cde828f91d3f6ccabfd31ebd5e9e30046cf50ee 100644 (file)
@@ -176,7 +176,7 @@ parse_args(int argc, char **argv)
 }
 
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -189,7 +189,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
                if (force_quit)
                        return;
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if (force_quit)
                                return;
                        if ((port_mask & (1 << portid)) == 0)
@@ -287,7 +287,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* Initialize ports. */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct ether_addr eth;
                int w, j;
                int ret;
@@ -339,7 +339,7 @@ main(int argc, char **argv)
                return 0;
        }
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
        rte_eal_remote_launch(run_monitor, NULL, lcore_id);
 
        if (power_manager_init() < 0) {
index 87abeab93deb95f27efee8b9e9b913caad9c81e0..e2d11491954a8c5c2683405191a08f6225bd50b7 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 EXTRA_CFLAGS += -O3
index d94a18314ca860853ae93316d166f5dffc440116..72845241ef0e1ba0cea3e3b8b7eee0f0b6be7f56 100644 (file)
@@ -600,7 +600,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        printf("\nSkipping disabled port %d\n", portid);
index c34e11e36d214b8deea947d0ae346b0a05db27d9..2b0a25036125381fe131a60eef688103ace49f77 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index bf161cb2b856f70e8b0a9a551aae06acf5443738..3bd80a02391175ea497a1757469467479e503986 100644 (file)
@@ -23,6 +23,8 @@ CFLAGS += -O3 $(shell pkg-config --cflags libdpdk)
 LDFLAGS_SHARED = $(shell pkg-config --libs libdpdk)
 LDFLAGS_STATIC = -Wl,-Bstatic $(shell pkg-config --static --libs libdpdk)
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+
 build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build
        $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
 
@@ -48,6 +50,7 @@ RTE_TARGET ?= x86_64-native-linuxapp-gcc
 
 include $(RTE_SDK)/mk/rte.vars.mk
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS)
 
 # workaround for a gcc bug with noreturn attribute
index bfe72f8c876d63da59e81a362913a362f33f6f89..2016a957165d7876aa0eb6cd0cecdabe4113a93f 100644 (file)
@@ -662,7 +662,7 @@ main(int argc, char *argv[])
                rte_exit(EXIT_FAILURE, "Cannot create mbuf pool\n");
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                /* skip ports that are not enabled */
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        printf("\nSkipping disabled port %d\n", portid);
index c34e11e36d214b8deea947d0ae346b0a05db27d9..2b0a25036125381fe131a60eef688103ace49f77 100644 (file)
@@ -6,6 +6,7 @@
 # To build this example as a standalone application with an already-installed
 # DPDK instance, use 'make'
 
+allow_experimental_apis = true
 sources = files(
        'main.c'
 )
index 9cda9607b19c9121230f3db39fc66238d2a21044..bf5b44f177d37d201b7a329fb06c42f8b4d68426 100644 (file)
@@ -213,7 +213,7 @@ eth_poll_wrr_calc(struct rte_event_eth_rx_adapter *rx_adapter)
                /* Generate array of all queues to poll, the size of this
                 * array is poll_q
                 */
-               for (d = 0; d < rte_eth_dev_count(); d++) {
+               RTE_ETH_FOREACH_DEV(d) {
                        uint16_t nb_rx_queues;
                        struct eth_device_info *dev_info =
                                        &rx_adapter->eth_devices[d];
@@ -823,7 +823,7 @@ rx_adapter_ctrl(uint8_t id, int start)
 
        dev = &rte_eventdevs[rx_adapter->eventdev_id];
 
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                dev_info = &rx_adapter->eth_devices[i];
                /* if start  check for num dev queues */
                if (start && !dev_info->nb_dev_queues)
@@ -913,7 +913,7 @@ rte_event_eth_rx_adapter_create_ext(uint8_t id, uint8_t dev_id,
                return -ENOMEM;
        }
        rte_spinlock_init(&rx_adapter->rx_lock);
-       for (i = 0; i < rte_eth_dev_count(); i++)
+       RTE_ETH_FOREACH_DEV(i)
                rx_adapter->eth_devices[i].dev = &rte_eth_devices[i];
 
        event_eth_rx_adapter[id] = rx_adapter;
@@ -1184,7 +1184,7 @@ rte_event_eth_rx_adapter_stats_get(uint8_t id,
 
        dev = &rte_eventdevs[rx_adapter->eventdev_id];
        memset(stats, 0, sizeof(*stats));
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                dev_info = &rx_adapter->eth_devices[i];
                if (dev_info->internal_event_port == 0 ||
                        dev->dev_ops->eth_rx_adapter_stats_get == NULL)
@@ -1221,7 +1221,7 @@ rte_event_eth_rx_adapter_stats_reset(uint8_t id)
                return -EINVAL;
 
        dev = &rte_eventdevs[rx_adapter->eventdev_id];
-       for (i = 0; i < rte_eth_dev_count(); i++) {
+       RTE_ETH_FOREACH_DEV(i) {
                dev_info = &rx_adapter->eth_devices[i];
                if (dev_info->internal_event_port == 0 ||
                        dev->dev_ops->eth_rx_adapter_stats_reset == NULL)
index ae0dbd8f06aff1123dfb60acaa88f7344039e4d1..8884045c0bda50d192aa67eb8b9fc01d3a0b2802 100644 (file)
@@ -6,6 +6,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 # library name
 LIB = librte_latencystats.a
 
+CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3
 LDLIBS += -lm
 LDLIBS += -lpthread
index 286558dd795bed922694d954387d977655d0db02..0c96e12879e3e4c4983fc8bddb588dbf005997d0 100644 (file)
@@ -4,3 +4,4 @@
 sources = files('rte_latencystats.c')
 headers = files('rte_latencystats.h')
 deps += ['metrics', 'ethdev']
+allow_experimental_apis = true
index fc9497659165894ad8ff9f9d233808ae8a43d7a5..46c69bf058185d84200bca62f3fe77766416b52e 100644 (file)
@@ -201,7 +201,6 @@ rte_latencystats_init(uint64_t app_samp_intvl,
        uint16_t pid;
        uint16_t qid;
        struct rxtx_cbs *cbs = NULL;
-       const uint16_t nb_ports = rte_eth_dev_count();
        const char *ptr_strings[NUM_LATENCY_STATS] = {0};
        const struct rte_memzone *mz = NULL;
        const unsigned int flags = 0;
@@ -234,7 +233,7 @@ rte_latencystats_init(uint64_t app_samp_intvl,
        }
 
        /** Register Rx/Tx callbacks */
-       for (pid = 0; pid < nb_ports; pid++) {
+       RTE_ETH_FOREACH_DEV(pid) {
                struct rte_eth_dev_info dev_info;
                rte_eth_dev_info_get(pid, &dev_info);
                for (qid = 0; qid < dev_info.nb_rx_queues; qid++) {
@@ -266,10 +265,9 @@ rte_latencystats_uninit(void)
        uint16_t qid;
        int ret = 0;
        struct rxtx_cbs *cbs = NULL;
-       const uint16_t nb_ports = rte_eth_dev_count();
 
        /** De register Rx/Tx callbacks */
-       for (pid = 0; pid < nb_ports; pid++) {
+       RTE_ETH_FOREACH_DEV(pid) {
                struct rte_eth_dev_info dev_info;
                rte_eth_dev_info_get(pid, &dev_info);
                for (qid = 0; qid < dev_info.nb_rx_queues; qid++) {
index 006ed31491296bd6e549a2742acec69f7ac02732..1b913a25f31560958b6caa745c01784e36823457 100644 (file)
@@ -119,7 +119,7 @@ init_ports(int num_ports)
        if (!default_params.mp)
                return -ENOMEM;
 
-       for (portid = 0; portid < num_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                retval = port_init(portid, default_params.mp);
                if (retval)
                        return retval;
@@ -179,7 +179,7 @@ static void
 testsuite_teardown(void)
 {
        uint32_t i;
-       for (i = 0; i < rte_eth_dev_count(); i++)
+       RTE_ETH_FOREACH_DEV(i)
                rte_eth_dev_stop(i);
 
        rte_mempool_free(default_params.mp);
index 911dd762c30c82c58b08623651add6b95fe82154..0e64a581b3d3107ccf88f6b6ae3b9d8dce3f3188 100644 (file)
@@ -698,7 +698,7 @@ test_pmd_perf(void)
 
        reset_count();
        num = 0;
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if (socketid == -1) {
                        socketid = rte_eth_dev_socket_id(portid);
                        slave_id = alloc_lcore(socketid);
@@ -791,7 +791,7 @@ test_pmd_perf(void)
                        return -1;
 
        /* port tear down */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if (socketid != rte_eth_dev_socket_id(portid))
                        continue;
 
index 4b8910149cfd1d3fe6f528a30755338e04d837b0..0787e4ebf5ac0ab6a86f11d004a3ac17ab957935 100644 (file)
@@ -473,7 +473,7 @@ test_pmd_ring(void)
                return -1;
 
        /* find a port created with the --vdev=net_ring0 command line option */
-       for (port = 0; port < nb_ports; port++) {
+       RTE_ETH_FOREACH_DEV(port) {
                struct rte_eth_dev_info dev_info;
 
                rte_eth_dev_info_get(port, &dev_info);