examples/l2fwd-event: setup service core
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Wed, 30 Oct 2019 16:26:48 +0000 (21:56 +0530)
committerJerin Jacob <jerinj@marvell.com>
Mon, 4 Nov 2019 17:09:26 +0000 (18:09 +0100)
Setup service cores for eventdev and Rx/Tx adapter when they don't have
internal port capability.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Acked-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
examples/l2fwd-event/l2fwd_event.c
examples/l2fwd-event/l2fwd_event.h
examples/l2fwd-event/main.c

index 33c7027..562d612 100644 (file)
 
 #include "l2fwd_event.h"
 
+static inline int
+l2fwd_event_service_enable(uint32_t service_id)
+{
+       uint8_t min_service_count = UINT8_MAX;
+       uint32_t slcore_array[RTE_MAX_LCORE];
+       unsigned int slcore = 0;
+       uint8_t service_count;
+       int32_t slcore_count;
+
+       if (!rte_service_lcore_count())
+               return -ENOENT;
+
+       slcore_count = rte_service_lcore_list(slcore_array, RTE_MAX_LCORE);
+       if (slcore_count < 0)
+               return -ENOENT;
+       /* Get the core which has least number of services running. */
+       while (slcore_count--) {
+               /* Reset default mapping */
+               rte_service_map_lcore_set(service_id,
+                               slcore_array[slcore_count], 0);
+               service_count = rte_service_lcore_count_services(
+                               slcore_array[slcore_count]);
+               if (service_count < min_service_count) {
+                       slcore = slcore_array[slcore_count];
+                       min_service_count = service_count;
+               }
+       }
+       if (rte_service_map_lcore_set(service_id, slcore, 1))
+               return -ENOENT;
+       rte_service_lcore_start(slcore);
+
+       return 0;
+}
+
+void
+l2fwd_event_service_setup(struct l2fwd_resources *rsrc)
+{
+       struct l2fwd_event_resources *evt_rsrc = rsrc->evt_rsrc;
+       struct rte_event_dev_info evdev_info;
+       uint32_t service_id, caps;
+       int ret, i;
+
+       rte_event_dev_info_get(evt_rsrc->event_d_id, &evdev_info);
+       if (evdev_info.event_dev_cap  & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED) {
+               ret = rte_event_dev_service_id_get(evt_rsrc->event_d_id,
+                               &service_id);
+               if (ret != -ESRCH && ret != 0)
+                       rte_panic("Error in starting eventdev service\n");
+               l2fwd_event_service_enable(service_id);
+       }
+
+       for (i = 0; i < evt_rsrc->rx_adptr.nb_rx_adptr; i++) {
+               ret = rte_event_eth_rx_adapter_caps_get(evt_rsrc->event_d_id,
+                               evt_rsrc->rx_adptr.rx_adptr[i], &caps);
+               if (ret < 0)
+                       rte_panic("Failed to get Rx adapter[%d] caps\n",
+                                 evt_rsrc->rx_adptr.rx_adptr[i]);
+               ret = rte_event_eth_rx_adapter_service_id_get(
+                               evt_rsrc->event_d_id,
+                               &service_id);
+               if (ret != -ESRCH && ret != 0)
+                       rte_panic("Error in starting Rx adapter[%d] service\n",
+                                 evt_rsrc->rx_adptr.rx_adptr[i]);
+               l2fwd_event_service_enable(service_id);
+       }
+
+       for (i = 0; i < evt_rsrc->tx_adptr.nb_tx_adptr; i++) {
+               ret = rte_event_eth_tx_adapter_caps_get(evt_rsrc->event_d_id,
+                               evt_rsrc->tx_adptr.tx_adptr[i], &caps);
+               if (ret < 0)
+                       rte_panic("Failed to get Rx adapter[%d] caps\n",
+                                 evt_rsrc->tx_adptr.tx_adptr[i]);
+               ret = rte_event_eth_tx_adapter_service_id_get(
+                               evt_rsrc->event_d_id,
+                               &service_id);
+               if (ret != -ESRCH && ret != 0)
+                       rte_panic("Error in starting Rx adapter[%d] service\n",
+                                 evt_rsrc->tx_adptr.tx_adptr[i]);
+               l2fwd_event_service_enable(service_id);
+       }
+}
+
 static void
 l2fwd_event_capability_setup(struct l2fwd_event_resources *evt_rsrc)
 {
index 1d7090d..ebfbfe4 100644 (file)
@@ -66,5 +66,6 @@ struct l2fwd_event_resources {
 void l2fwd_event_resource_setup(struct l2fwd_resources *rsrc);
 void l2fwd_event_set_generic_ops(struct event_setup_ops *ops);
 void l2fwd_event_set_internal_port_ops(struct event_setup_ops *ops);
+void l2fwd_event_service_setup(struct l2fwd_resources *rsrc);
 
 #endif /* __L2FWD_EVENT_H__ */
index 2a1fe4e..1ae18bb 100644 (file)
@@ -471,6 +471,9 @@ main(int argc, char **argv)
                                  port_id);
        }
 
+       if (rsrc->event_mode)
+               l2fwd_event_service_setup(rsrc);
+
        check_all_ports_link_status(rsrc, rsrc->enabled_port_mask);
 
        /* launch per-lcore init on every lcore */