15630257fSFerruh Yigit.. SPDX-License-Identifier: BSD-3-Clause 25630257fSFerruh Yigit Copyright(c) 2017 Intel Corporation. 321698354SHarry van Haaren 421698354SHarry van HaarenService Cores 521698354SHarry van Haaren============= 621698354SHarry van Haaren 721698354SHarry van HaarenDPDK has a concept known as service cores, which enables a dynamic way of 821698354SHarry van Haarenperforming work on DPDK lcores. Service core support is built into the EAL, and 921698354SHarry van Haarenan API is provided to optionally allow applications to control how the service 1021698354SHarry van Haarencores are used at runtime. 1121698354SHarry van Haaren 1221698354SHarry van HaarenThe service cores concept is built up out of services (components of DPDK that 1321698354SHarry van Haarenrequire CPU cycles to operate) and service cores (DPDK lcores, tasked with 1421698354SHarry van Haarenrunning services). The power of the service core concept is that the mapping 1521698354SHarry van Haarenbetween service cores and services can be configured to abstract away the 1621698354SHarry van Haarendifference between platforms and environments. 1721698354SHarry van Haaren 1821698354SHarry van HaarenFor example, the Eventdev has hardware and software PMDs. Of these the software 1921698354SHarry van HaarenPMD requires an lcore to perform the scheduling operations, while the hardware 2021698354SHarry van HaarenPMD does not. With service cores, the application would not directly notice 2121698354SHarry van Haarenthat the scheduling is done in software. 2221698354SHarry van Haaren 2321698354SHarry van HaarenFor detailed information about the service core API, please refer to the docs. 2421698354SHarry van Haaren 2521698354SHarry van HaarenService Core Initialization 2621698354SHarry van Haaren~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2721698354SHarry van Haaren 2821698354SHarry van HaarenThere are two methods to having service cores in a DPDK application, either by 2921698354SHarry van Haarenusing the service coremask, or by dynamically adding cores using the API. 3021698354SHarry van HaarenThe simpler of the two is to pass the `-s` coremask argument to EAL, which will 31fc49ed25SRoy Franztake any cores available in the main DPDK coremask, and if the bits are also set 3221698354SHarry van Haarenin the service coremask the cores become service-cores instead of DPDK 3321698354SHarry van Haarenapplication lcores. 3421698354SHarry van Haaren 3521698354SHarry van HaarenEnabling Services on Cores 3621698354SHarry van Haaren~~~~~~~~~~~~~~~~~~~~~~~~~~ 3721698354SHarry van Haaren 3821698354SHarry van HaarenEach registered service can be individually mapped to a service core, or set of 3921698354SHarry van Haarenservice cores. Enabling a service on a particular core means that the lcore in 4021698354SHarry van Haarenquestion will run the service. Disabling that core on the service stops the 4121698354SHarry van Haarenlcore in question from running the service. 4221698354SHarry van Haaren 4321698354SHarry van HaarenUsing this method, it is possible to assign specific workloads to each 4421698354SHarry van Haarenservice core, and map N workloads to M number of service cores. Each service 4521698354SHarry van Haarenlcore loops over the services that are enabled for that core, and invokes the 4621698354SHarry van Haarenfunction to run the service. 4721698354SHarry van Haaren 4821698354SHarry van HaarenService Core Statistics 4921698354SHarry van Haaren~~~~~~~~~~~~~~~~~~~~~~~ 5021698354SHarry van Haaren 5121698354SHarry van HaarenThe service core library is capable of collecting runtime statistics like number 5221698354SHarry van Haarenof calls to a specific service, and number of cycles used by the service. The 5321698354SHarry van Haarencycle count collection is dynamically configurable, allowing any application to 5421698354SHarry van Haarenprofile the services running on the system at any time. 55*841e87dfSArnaud Fiorini 56*841e87dfSArnaud FioriniService Core Tracing 57*841e87dfSArnaud Fiorini~~~~~~~~~~~~~~~~~~~~ 58*841e87dfSArnaud Fiorini 59*841e87dfSArnaud FioriniThe service core library is instrumented with tracepoints using the DPDK Trace 60*841e87dfSArnaud FioriniLibrary. These tracepoints allow you to track the service and logical cores 61*841e87dfSArnaud Fiorinistate. To activate tracing when launching a DPDK program it is necessary to use the 62*841e87dfSArnaud Fiorini``--trace`` option to specify a regular expression to select which tracepoints 63*841e87dfSArnaud Fiorinito enable. Here is an example if you want to only specify service core tracing:: 64*841e87dfSArnaud Fiorini 65*841e87dfSArnaud Fiorini ./dpdk/examples/service_cores/build/service_cores --trace="lib.eal.thread*" --trace="lib.eal.service*" 66*841e87dfSArnaud Fiorini 67*841e87dfSArnaud FioriniSee the :doc:`trace_lib` documentation for details. 68