### Starting Service with Defaults Source: https://doc.dpdk.org/api/rte__service__component_8h_source.html Initializes and starts the DPDK service framework using default configurations. This is a convenient function for basic service setup. ```c int32_t rte_service_start_with_defaults(void); ``` -------------------------------- ### Start ML Device Source: https://doc.dpdk.org/api/rte__mldev_8h_source.html Starts the ML device, making it ready to process operations. This should be called after configuration and queue pair setup. ```c __rte_experimental int rte_ml_dev_start(int16_t dev_id); ``` -------------------------------- ### ML Device API Setup Order Source: https://doc.dpdk.org/api/rte__mldev_8h.html The functions to set up an ML device must be invoked in this specific order: configure, queue pair setup, and then start. ```c - rte_ml_dev_configure() - rte_ml_dev_queue_pair_setup() - rte_ml_dev_start() ``` -------------------------------- ### setup_port_queue Source: https://doc.dpdk.org/api/dts/api.testpmd.html Configures a specific queue (RX or TX) on a given port. Note that the setup action only takes full effect when the queue is subsequently started. ```APIDOC ## setup_port_queue ### Description Configures a specific queue (RX or TX) on a given port. Note that the setup action only takes full effect when the queue is subsequently started. ### Method None (Python function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **port_id** (_int_) – ID of the port where the queue resides. * **queue_id** (_int_) – ID of the queue to setup. * **is_rx_queue** (_bool_) – Type of queue to setup. If `True` an RX queue will be setup, otherwise a TX queue will be setup. ### Request Example ```python # Example of calling the function (actual execution depends on the testpmd environment) # setup_port_queue(port_id=0, queue_id=0, is_rx_queue=True) ``` ### Response #### Success Response None (This function returns None upon successful execution) #### Response Example ```json null ``` ``` -------------------------------- ### Setup Tx Adapter Source: https://doc.dpdk.org/api/examples_2l2fwd-event_2l2fwd_event_generic_8c-example.html Sets up the Tx adapter, including creating the adapter, adding queues, retrieving the service ID, and starting the adapter. This function is called after the Rx adapter is configured. ```c /* Tx adapter setup */ evt_rsrc->tx_adptr.nb_tx_adptr = 1; evt_rsrc->tx_adptr.tx_adptr = (uint8_t *)malloc(sizeof(uint8_t) * evt_rsrc->tx_adptr.nb_tx_adptr); if (!evt_rsrc->tx_adptr.tx_adptr) { free(evt_rsrc->rx_adptr.rx_adptr); free(evt_rsrc->evp.event_p_id); free(evt_rsrc->evq.event_q_id); te_panic("Failed to allocate memery for Rx adapter\n"); } ret = rte_event_eth_tx_adapter_create(tx_adptr_id, event_d_id, &evt_rsrc->def_p_conf); if (ret) te_panic("Failed to create tx adapter\n"); RTE_ETH_FOREACH_DEV(port_id) { if ((rsrc->enabled_port_mask & (1 << port_id)) == 0) continue; ret = rte_event_eth_tx_adapter_queue_add(tx_adptr_id, port_id, -1); if (ret) te_panic("Failed to add queues to Tx adapter\n"); } ret = rte_event_eth_tx_adapter_service_id_get(tx_adptr_id, &service_id); if (ret != -ESRCH && ret != 0) te_panic("Failed to get Tx adapter service ID\n"); rte_service_runstate_set(service_id, 1); te_service_set_runstate_mapped_check(service_id, 0); evt_rsrc->tx_adptr.service_id = service_id; /* Extra port created. 8< */ ret = rte_event_eth_tx_adapter_event_port_get(tx_adptr_id, &tx_port_id); if (ret) te_panic("Failed to get Tx adapter port id: %d\n", ret); ret = rte_event_port_link(event_d_id, tx_port_id, &evt_rsrc->evq.event_q_id[ evt_rsrc->evq.nb_queues - 1], NULL, 1); if (ret != 1) te_panic("Unable to link Tx adapter port to Tx queue:err=%d\n", ret); /* >8 End of extra port created. */ ret = rte_event_eth_tx_adapter_start(tx_adptr_id); if (ret) te_panic("Tx adapter[%d] start Failed\n", tx_adptr_id); evt_rsrc->tx_adptr.tx_adptr[0] = tx_adptr_id; ``` -------------------------------- ### Configure DPDK Event Device RX/TX Adapters in C Source: https://doc.dpdk.org/api/examples_2l3fwd_2l3fwd_event_generic_8c-example.html This snippet demonstrates the setup of DPDK event device RX and TX adapters. It covers creating an RX adapter, adding Ethernet queues to it, starting the adapter, and initializing the TX adapter. ```c static void l3fwd_rx_tx_adapter_setup_generic(void) { struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc(); struct rte_event_eth_rx_adapter_queue_conf eth_q_conf; uint8_t event_d_id = evt_rsrc->event_d_id; uint8_t rx_adptr_id = 0; uint8_t tx_adptr_id = 0; uint8_t tx_port_id = 0; uint16_t port_id; uint32_t service_id; int32_t ret, i = 0; memset(ð_q_conf, 0, sizeof(eth_q_conf)); eth_q_conf.ev.priority = RTE_EVENT_DEV_PRIORITY_NORMAL; /* Rx adapter setup */ evt_rsrc->rx_adptr.nb_rx_adptr = 1; evt_rsrc->rx_adptr.rx_adptr = (uint8_t *)malloc(sizeof(uint8_t) * evt_rsrc->rx_adptr.nb_rx_adptr); if (!evt_rsrc->rx_adptr.rx_adptr) { free(evt_rsrc->evp.event_p_id); free(evt_rsrc->evq.event_q_id); rte_panic("Failed to allocate memory for Rx adapter\n"); } ret = rte_event_eth_rx_adapter_create(rx_adptr_id, event_d_id, &evt_rsrc->def_p_conf); if (ret) rte_panic("Failed to create rx adapter\n"); /* Configure user requested sched type */ eth_q_conf.ev.sched_type = evt_rsrc->sched_type; RTE_ETH_FOREACH_DEV(port_id) { if ((evt_rsrc->port_mask & (1 << port_id)) == 0) continue; eth_q_conf.ev.queue_id = evt_rsrc->evq.event_q_id[i]; ret = rte_event_eth_rx_adapter_queue_add(rx_adptr_id, port_id, -1, ð_q_conf); if (ret) rte_panic("Failed to add queues to Rx adapter\n"); if (i < evt_rsrc->evq.nb_queues) i++; } ret = rte_event_eth_rx_adapter_service_id_get(rx_adptr_id, &service_id); if (ret != -ESRCH && ret != 0) rte_panic("Error getting the service ID for rx adptr\n"); rte_service_runstate_set(service_id, 1); rte_service_set_runstate_mapped_check(service_id, 0); evt_rsrc->rx_adptr.service_id = service_id; ret = rte_event_eth_rx_adapter_start(rx_adptr_id); if (ret) rte_panic("Rx adapter[%d] start Failed\n", rx_adptr_id); evt_rsrc->rx_adptr.rx_adptr[0] = rx_adptr_id; /* Tx adapter setup */ evt_rsrc->tx_adptr.nb_tx_adptr = 1; evt_rsrc->tx_adptr.tx_adptr = (uint8_t *)malloc(sizeof(uint8_t) * evt_rsrc->tx_adptr.nb_tx_adptr); if (!evt_rsrc->tx_adptr.tx_adptr) { free(evt_rsrc->rx_adptr.rx_adptr); free(evt_rsrc->evp.event_p_id); ``` -------------------------------- ### Configure and Create Rx and Tx Adapters Source: https://doc.dpdk.org/api/examples_2eventdev_pipeline_2pipeline_worker_tx_8c-example.html This snippet shows the process of creating and configuring Rx and Tx adapters for an event device. It includes setting queue configurations, getting adapter capabilities, and starting the adapters. ```c adptr_p_conf.enqueue_depth = dev_info.max_event_port_enqueue_depth; struct rte_event_eth_rx_adapter_queue_conf queue_conf; memset(&queue_conf, 0, sizeof(queue_conf)); queue_conf.ev.sched_type = cdata.queue_type; for (i = 0; i < nb_ports; i++) { uint32_t cap; uint32_t service_id; ret = rte_event_eth_rx_adapter_create(i, evdev_id, &adptr_p_conf); if (ret) rte_exit(EXIT_FAILURE, "failed to create rx adapter[%d]", i); ret = rte_event_eth_rx_adapter_caps_get(evdev_id, i, &cap); if (ret) rte_exit(EXIT_FAILURE, "failed to get event rx adapter " "capabilities"); queue_conf.ev.queue_id = cdata.rx_stride ? (i * cdata.rx_stride) : (uint8_t)cdata.qid[0]; ret = rte_event_eth_rx_adapter_queue_add(i, i, -1, &queue_conf); if (ret) rte_exit(EXIT_FAILURE, "Failed to add queues to Rx adapter"); /* Producer needs to be scheduled. */ if (!(cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT)) { ret = rte_event_eth_rx_adapter_service_id_get(i, &service_id); if (ret != -ESRCH && ret != 0) { rte_exit(EXIT_FAILURE, "Error getting the service ID for rx adptr\n"); } rte_service_runstate_set(service_id, 1); rte_service_set_runstate_mapped_check(service_id, 0); adptr_services->nb_rx_adptrs++; adptr_services->rx_adpt_arr = rte_realloc( adptr_services->rx_adpt_arr, adptr_services->nb_rx_adptrs * sizeof(uint32_t), 0); adptr_services->rx_adpt_arr[ adptr_services->nb_rx_adptrs - 1] = service_id; } ret = rte_event_eth_rx_adapter_start(i); if (ret) rte_exit(EXIT_FAILURE, "Rx adapter[%d] start failed", i); } /* We already know that Tx adapter has INTERNAL port cap*/ ret = rte_event_eth_tx_adapter_create(cdata.tx_adapter_id, evdev_id, &adptr_p_conf); if (ret) rte_exit(EXIT_FAILURE, "failed to create tx adapter[%d]", cdata.tx_adapter_id); for (i = 0; i < nb_ports; i++) { ret = rte_event_eth_tx_adapter_queue_add(cdata.tx_adapter_id, i, -1); if (ret) rte_exit(EXIT_FAILURE, "Failed to add queues to Tx adapter"); } ret = rte_event_eth_tx_adapter_start(cdata.tx_adapter_id); if (ret) rte_exit(EXIT_FAILURE, "Tx adapter[%d] start failed", cdata.tx_adapter_id); if (adptr_services->nb_rx_adptrs) { struct rte_service_spec service; memset(&service, 0, sizeof(struct rte_service_spec)); snprintf(service.name, sizeof(service.name), "rx_service"); service.callback = service_rx_adapter; service.callback_userdata = (void *)adptr_services; int32_t ret = rte_service_component_register(&service, &fdata->rxadptr_service_id); if (ret) rte_exit(EXIT_FAILURE, "Rx adapter service register failed"); rte_service_runstate_set(fdata->rxadptr_service_id, 1); rte_service_component_runstate_set(fdata->rxadptr_service_id, 1); rte_service_set_runstate_mapped_check(fdata->rxadptr_service_id, 0); } else { memset(fdata->rx_core, 0, sizeof(unsigned int) * MAX_NUM_CORE); rte_free(adptr_services); } if (!adptr_services->nb_rx_adptrs && (dev_info.event_dev_cap & RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED)) fdata->cap.scheduler = NULL; } ``` -------------------------------- ### Configure and Start Crypto Device Source: https://doc.dpdk.org/api/examples_2pipeline_2obj_8c-example.html Configures and starts a crypto device with specified parameters, including queue pairs and queue size. It finds the device by name, checks capabilities, and sets up the device and its queue pairs before starting it. ```c int cryptodev_config(const char *name, struct cryptodev_params *params) { struct rte_cryptodev_info dev_info; struct rte_cryptodev_config dev_conf; struct rte_cryptodev_qp_conf queue_conf; uint8_t dev_id; uint32_t socket_id, i; int status; /* Check input parameters. */ if (!name || !params->n_queue_pairs || !params->queue_size) return -EINVAL; /* Find the crypto device. */ status = rte_cryptodev_get_dev_id(name); if (status < 0) return -EINVAL; dev_id = (uint8_t)status; rte_cryptodev_info_get(dev_id, &dev_info); if (params->n_queue_pairs > dev_info.max_nb_queue_pairs) return -EINVAL; socket_id = rte_cryptodev_socket_id(dev_id); /* Configure the crypto device. */ memset(&dev_conf, 0, sizeof(dev_conf)); dev_conf.socket_id = socket_id; dev_conf.nb_queue_pairs = params->n_queue_pairs; dev_conf.ff_disable = 0; status = rte_cryptodev_configure(dev_id, &dev_conf); if (status) return status; /* Configure the crypto device queue pairs. */ memset(&queue_conf, 0, sizeof(queue_conf)); queue_conf.nb_descriptors = params->queue_size; queue_conf.mp_session = NULL; for (i = 0; i < params->n_queue_pairs; i++) { status = rte_cryptodev_queue_pair_setup(dev_id, i, &queue_conf, socket_id); if (status) return status; } /* Start the crypto device. */ status = rte_cryptodev_start(dev_id); if (status) return status; return 0; } ``` -------------------------------- ### ML Device Configuration and Management Source: https://doc.dpdk.org/api/rte__mldev_8h.html APIs for configuring and managing ML devices and their queue pairs. The setup process involves configuring the device, setting up queue pairs, and then starting the device. ```APIDOC ## rte_ml_dev_configure() ### Description Configures an ML device. ### Method (Not specified, assumed to be a function call in an SDK) ### Endpoint (Not applicable) ### Parameters (Not specified) ## rte_ml_dev_queue_pair_setup() ### Description Sets up a queue pair for an ML device. ### Method (Not specified, assumed to be a function call in an SDK) ### Endpoint (Not applicable) ### Parameters (Not specified) ## rte_ml_dev_start() ### Description Starts an ML device. ### Method (Not specified, assumed to be a function call in an SDK) ### Endpoint (Not applicable) ### Parameters (Not specified) ## rte_ml_dev_stop() ### Description Stops an ML device. ### Method (Not specified, assumed to be a function call in an SDK) ### Endpoint (Not applicable) ### Parameters (Not specified) ``` -------------------------------- ### Start Crypto Adapter Source: https://doc.dpdk.org/api/examples_2ipsec-secgw_2event_helper_8c-example.html Starts all configured event crypto adapters. This function should be called after initialization. ```c static int eh_start_crypto_adapter(struct eventmode_conf *em_conf) { uint8_t cdev_id, n; int ret; if (!em_conf->enable_event_crypto_adapter) return 0; n = rte_cryptodev_count(); for (cdev_id = 0; cdev_id != n; cdev_id++) { ret = rte_event_crypto_adapter_start(cdev_id); if (ret < 0) { EH_LOG_ERR("Failed to start event crypto device %d (%d)", cdev_id, ret); return ret; } } return 0; } ``` -------------------------------- ### Create Fragment Table and Setup RX Callbacks Source: https://doc.dpdk.org/api/examples_2ipsec-secgw_2ipsec-secgw_8c-example.html Initializes a fragment table for IP packet reassembly and installs RX callbacks for all queues on a given port. This is essential for handling fragmented IP packets. ```c static int reassemble_lcore_init(struct lcore_conf *lc, uint32_t cid) { const struct rte_eth_rxtx_callback *cb; struct rxq_conf *rxq; uint32_t i; sid = rte_lcore_to_socket_id(cid); frag_cycles = (rte_get_tsc_hz() + NS_PER_S - 1) / NS_PER_S * frag_ttl_ns; lc->frag.tbl = rte_ip_frag_table_create(frag_tbl_sz, FRAG_TBL_BUCKET_ENTRIES, frag_tbl_sz, frag_cycles, sid); if (lc->frag.tbl == NULL) { printf("%s(%u): failed to create fragment table of size: %u, " "error code: %d\n", __func__, cid, frag_tbl_sz, rte_errno); return -ENOMEM; } /* setup reassemble RX callbacks for all queues */ for (i = 0; i != lc->nb_rx_queue; i++) { rxq = lc->rx_queue_list + i; cb = rte_eth_add_rx_callback(rxq->port_id, rxq->queue_id, rx_callback, lc); if (cb == NULL) { printf("%s(%u): failed to install RX callback for " "portid=%u, queueid=%u, error code: %d\n", __func__, cid, rxq->port_id, rxq->queue_id, rte_errno); return -ENOMEM; } } return 0; } ``` -------------------------------- ### DPDK MACsec Example Initialization and Configuration Source: https://doc.dpdk.org/api/examples_2l2fwd-macsec_2main_8c-example.html This C code snippet shows the initialization of DPDK, configuration of network ports, and setup for MACsec. It defines constants for buffer sizes, queue descriptors, and memory pool configurations. ```c #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile bool force_quit; /* MAC updating enabled by default */ static int mac_updating; /* Ports set in promiscuous mode on by default. */ static int promiscuous_on = 1; #define RTE_LOGTYPE_L2FWD RTE_LOGTYPE_USER1 #define MAX_PKT_BURST 32 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ #define MEMPOOL_CACHE_SIZE 256 #define SESSION_POOL_CACHE_SIZE 0 /* Configurable number of RX/TX ring descriptors */ #define RX_DESC_DEFAULT 1024 #define TX_DESC_DEFAULT 1024 static uint16_t nb_rxd = RX_DESC_DEFAULT; static uint16_t nb_txd = TX_DESC_DEFAULT; /* ethernet addresses of ports */ static struct rte_ether_addr l2fwd_ports_eth_addr[RTE_MAX_ETHPORTS]; /* Ethernet header configuration for MACsec flow on each port. */ static struct rte_ether_hdr port_ether_hdr_config[RTE_MAX_ETHPORTS]; /* mask of enabled ports */ static uint32_t l2fwd_enabled_port_mask; /* list of enabled ports */ static uint32_t l2fwd_dst_ports[RTE_MAX_ETHPORTS]; struct __rte_cache_aligned port_pair_params { #define NUM_PORTS 2 uint16_t port[NUM_PORTS]; }; static struct port_pair_params port_pair_params_array[RTE_MAX_ETHPORTS / 2]; static struct port_pair_params *port_pair_params; static uint16_t nb_port_pair_params; static unsigned int l2fwd_rx_queue_per_lcore = 1; #define MAX_RX_QUEUE_PER_LCORE 16 #define MAX_TX_QUEUE_PER_PORT 16 /* List of queues to be polled for a given lcore. 8< */ struct __rte_cache_aligned lcore_queue_conf { unsigned int n_rx_port; unsigned int rx_port_list[MAX_RX_QUEUE_PER_LCORE]; }; struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE]; /* >8 End of list of queues to be polled for a given lcore. */ static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; static struct rte_eth_conf port_conf = { .txmode = { .mq_mode = RTE_ETH_MQ_TX_NONE, }, }; /* Mempools for mbuf and security session */ struct rte_mempool *l2fwd_pktmbuf_pool; /* Per-port statistics struct */ struct __rte_cache_aligned l2fwd_port_statistics { uint64_t tx; uint64_t rx; uint64_t dropped; }; struct l2fwd_port_statistics port_statistics[RTE_MAX_ETHPORTS]; #define MAX_TIMER_PERIOD 86400 /* 1 day max */ /* A tsc-based timer responsible for triggering statistics printout */ static uint64_t timer_period = 10; /* default period is 10 seconds */ #define MCS_MAX_KEY_LEN 32 #define MCS_SALT_LEN 12 struct l2fwd_key { uint8_t data[MCS_MAX_KEY_LEN]; ``` -------------------------------- ### Initialize and Start Network Device Source: https://doc.dpdk.org/api/examples_2ipv4_multicast_2main_8c-example.html Initializes and starts a network device. Includes error handling for the start operation. ```c ret = rte_eth_dev_start(portid); if (ret < 0) rte_exit(EXIT_FAILURE, "rte_eth_dev_start: err=%d, port=%d\n", ret, portid); ``` -------------------------------- ### Cryptodev Start Source: https://doc.dpdk.org/api/globals_func_r.html Starts a crypto device, making it ready for operation. ```APIDOC ## rte_cryptodev_start() ### Description Initializes and starts a crypto device, preparing it to process cryptographic operations. ### Method (Not specified in source, likely a function call) ### Endpoint (Not applicable, this is an SDK function) ### Parameters (Not specified in source) ### Request Example (Not applicable) ### Response (Not specified in source) ``` -------------------------------- ### PQoS Initialization and Configuration Example Source: https://doc.dpdk.org/api/examples_2l2fwd-cat_2cat_8c-example.html This C code snippet demonstrates the initialization of the PQoS library, retrieval of capabilities (including L3CA), CPU socket information, validation and configuration of CAT, signal handling, and setting an exit function. It includes error handling and resource deallocation. ```c #include #include #include #include #include #include "pqos.h" #define STDOUT_FILENO 1 #define PQOS_RETVAL_OK 0 #define PQOS_REQUIRE_CDP_ANY 1 #define PQOS_CAP_TYPE_L3CA 1 #define PQOS_MAX_SOCKETS 16 /* Placeholder definitions for functions and variables used in the example */ struct pqos_config cfg; struct pqos_cap *m_cap = NULL; const struct pqos_cpu *m_cpu = NULL; const struct pqos_cap_l3ca *m_cap_l3ca = NULL; int m_sock_count; socket_t m_sockets[PQOS_MAX_SOCKETS]; int cat_validate() { return 0; } int cat_set() { return 0; } void cat_fini() {} void print_cat_config() {} void signal_handler(int signum) {} int args_num = 1; typedef int socket_t; /* PQoS Initialization - Check and initialize CAT capability */ int main(int argc, char **argv) { int ret; cfg.fd_log = STDOUT_FILENO; cfg.verbose = 0; #if PQOS_VERSION <= 103 cfg.cdp_cfg = PQOS_REQUIRE_CDP_ANY; #endif ret = pqos_init(&cfg); if (ret != PQOS_RETVAL_OK) { printf("PQOS: Error initializing PQoS library!\n"); ret = -EFAULT; goto err; } /* Get capability and CPU info pointer */ ret = pqos_cap_get(&m_cap, &m_cpu); if (ret != PQOS_RETVAL_OK || m_cap == NULL || m_cpu == NULL) { printf("PQOS: Error retrieving PQoS capabilities!\n"); ret = -EFAULT; goto err; } /* Get L3CA capabilities */ ret = pqos_cap_get_type(m_cap, PQOS_CAP_TYPE_L3CA, &m_cap_l3ca); if (ret != PQOS_RETVAL_OK || m_cap_l3ca == NULL) { printf("PQOS: Error retrieving PQOS_CAP_TYPE_L3CA " "capabilities!\n"); ret = -EFAULT; goto err; } /* Get CPU socket information */ #if PQOS_VERSION <= 103 ret = pqos_cpu_get_sockets(m_cpu, PQOS_MAX_SOCKETS, &m_sock_count, m_sockets); if (ret != PQOS_RETVAL_OK) { #else m_sockets = pqos_cpu_get_sockets(m_cpu, &m_sock_count); if (m_sockets == NULL) { #endif printf("PQOS: Error retrieving CPU socket information!\n"); ret = -EFAULT; goto err; } /* Validate cmd line configuration */ ret = cat_validate(); if (ret != 0) { printf("PQOS: Requested CAT configuration is not valid!\n"); goto err; } /* configure system */ ret = cat_set(); if (ret != 0) { printf("PQOS: Failed to configure CAT!\n"); goto err; } signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); ret = atexit(cat_exit); if (ret != 0) { printf("PQOS: Cannot set exit function\n"); goto err; } /* Print CAT configuration */ print_cat_config(); return args_num; err: /* deallocate all the resources */ cat_fini(); return ret; } ``` -------------------------------- ### Topology.setup Source: https://doc.dpdk.org/api/dts/api.test.html Sets up the testbed topology, establishing the necessary network connections and configurations. ```APIDOC ## setup ### Description Initializes and configures the testbed topology. This involves setting up network links, ensuring ports are ready, and preparing the environment for testing. ### Usage This method should be called before starting any tests that rely on the defined topology. ``` -------------------------------- ### _Topology.setup Source: https://doc.dpdk.org/api/dts/framework.testbed_model.topology.html Initializes and sets up all ports within the topology, binding them to the correct kernel drivers to obtain MAC addresses and logical names. ```APIDOC ## _Topology.setup ### Description Setup topology ports. Binds all the ports to the right kernel driver to retrieve MAC addresses and logical names. ### Method `setup` ### Returns None ``` -------------------------------- ### Get Base Address of Hardware Session Source: https://doc.dpdk.org/api/rte__pmd__cnxk_8h_source.html Retrieves the base address for hardware IPsec sessions. Use this to get the starting point for SA management. ```c union rte_pmd_cnxk_ipsec_hw_sa *rte_pmd_cnxk_hw_session_base_get(uint16_t portid, bool inb); ``` -------------------------------- ### Main Application Entry Point Source: https://doc.dpdk.org/api/examples_2ip_fragmentation_2main_8c-example.html Initializes the DPDK environment, parses command-line arguments, and configures network ports. It then calls init_mem to set up necessary data structures. ```c int main(int argc, char **argv) { struct lcore_queue_conf *qconf; struct rte_eth_dev_info dev_info; struct rte_eth_txconf *txconf; struct rx_queue *rxq; int socket, ret; uint16_t nb_ports; uint16_t queueid = 0; unsigned lcore_id = 0, rx_lcore_id = 0; uint32_t n_tx_queue, nb_lcores; uint16_t portid; /* init EAL */ ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "rte_eal_init failed"); argc -= ret; argv += ret; /* parse application arguments (after the EAL ones) */ ret = parse_args(argc, argv); if (ret < 0) te_exit(EXIT_FAILURE, "Invalid arguments"); nb_ports = rte_eth_dev_count_avail(); if (nb_ports == 0) te_exit(EXIT_FAILURE, "No ports found!\n"); nb_lcores = rte_lcore_count(); /* initialize structures (mempools, lpm etc.) */ if (init_mem() < 0) rte_panic("Cannot initialize memory structures!\n"); /* check if portmask has non-existent ports */ if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned))) te_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n"); /* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) { struct rte_eth_conf local_port_conf = port_conf; struct rte_eth_rxconf rxq_conf; /* skip ports that are not enabled */ if ((enabled_port_mask & (1 << portid)) == 0) { printf("Skipping disabled port %d\n", portid); continue; } qconf = &lcore_queue_conf[rx_lcore_id]; /* limit the frame size to the maximum supported by NIC */ ret = rte_eth_dev_info_get(portid, &dev_info); if (ret != 0) te_exit(EXIT_FAILURE, "Error during getting device (port %u) info: %s\n", portid, strerror(-ret)); local_port_conf.rxmode.mtu = RTE_MIN( dev_info.max_mtu, local_port_conf.rxmode.mtu); /* get the lcore_id for this port */ while (rte_lcore_is_enabled(rx_lcore_id) == 0 || qconf->n_rx_queue == (unsigned)rx_queue_per_lcore) { rx_lcore_id ++; if (rx_lcore_id >= RTE_MAX_LCORE) te_exit(EXIT_FAILURE, "Not enough cores\n"); qconf = &lcore_queue_conf[rx_lcore_id]; } socket = (int) rte_lcore_to_socket_id(rx_lcore_id); if (socket == SOCKET_ID_ANY) socket = 0; rxq = &qconf->rx_queue_list[qconf->n_rx_queue]; rxq->portid = portid; rxq->direct_pool = socket_direct_pool[socket]; rxq->indirect_pool = socket_indirect_pool[socket]; rxq->lpm = socket_lpm[socket]; rxq->lpm6 = socket_lpm6[socket]; qconf->n_rx_queue++; /* init port */ printf("Initializing port %d on lcore %u...", portid, rx_lcore_id); fflush(stdout); n_tx_queue = nb_lcores; if (n_tx_queue > MAX_TX_QUEUE_PER_PORT) n_tx_queue = MAX_TX_QUEUE_PER_PORT; ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue, &local_port_conf); if (ret < 0) { printf("\n"); te_exit(EXIT_FAILURE, "Cannot configure device: " "err=%d, port=%d\n", ret, portid); } /* set the mtu to the maximum received packet size */ ret = rte_eth_dev_set_mtu(portid, local_port_conf.rxmode.mtu); if (ret < 0) { printf("\n"); te_exit(EXIT_FAILURE, "Set MTU failed: " "err=%d, port=%d\n", ret, portid); } ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd, &nb_txd); if (ret < 0) { printf("\n"); te_exit(EXIT_FAILURE, "Cannot adjust number of " "descriptors: err=%d, port=%d\n", ret, portid); } /* init one RX queue */ ``` -------------------------------- ### rte_dma_next_dev Source: https://doc.dpdk.org/api/rte__dmadev_8h.html Gets the next available DMA device ID starting from a given ID. ```APIDOC ## rte_dma_next_dev ### Description Finds the next available DMA device ID, starting the search from `start_dev_id`. ### Function Signature ```c int16_t rte_dma_next_dev(int16_t start_dev_id) ``` ### Parameters * **start_dev_id** (int16_t) - The device ID to start searching from. Use -1 to start from the beginning. ### Returns The ID of the next available DMA device, or -1 if no more devices are found. ``` -------------------------------- ### DPDKBuildEnvironment.setup Source: https://doc.dpdk.org/api/dts/api.test.html Sets up the DPDK build environment, preparing it for compiling DPDK. ```APIDOC ## setup ### Description Configures the necessary environment variables, paths, and tools required for building DPDK. This ensures that the build process can proceed successfully. ### Usage Call this method before starting the DPDK build process. ``` -------------------------------- ### Node.setup Source: https://doc.dpdk.org/api/dts/api.html Sets up the node, likely involving initialization of its main session and configuration. ```APIDOC ## Node.setup ### Description Sets up the node, likely involving initialization of its main session and configuration. ### Method Not specified (likely a method call within a Python SDK) ### Endpoint N/A ### Parameters None explicitly documented. ### Request Example N/A ### Response None explicitly documented. ``` -------------------------------- ### Get IO virtual address at start Source: https://doc.dpdk.org/api/rte__mbuf__core_8h.html Returns the IO virtual address pointing to the beginning of the mbuf's data. This is a convenience macro for accessing the start of mbuf data using IO addresses. ```c #define rte_pktmbuf_iova(m) \ rte_pktmbuf_iova_offset(m, 0) ``` -------------------------------- ### Main Application Entry Point Source: https://doc.dpdk.org/api/examples_2flow_filtering_2main_8c-example.html Initializes the DPDK EAL, parses application arguments, checks for available network ports, allocates a memory pool for mbufs, and sets up signal handlers. This is the starting point of the application. ```c int main(int argc, char **argv) { int ret; uint16_t nr_ports; struct rte_flow_error error; /* Initialize EAL. 8< */ ret = rte_eal_init(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, ":: invalid EAL arguments\n"); /* >8 End of Initialization of EAL. */ argc -= ret; argv += ret; force_quit = false; signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); /* Parse application arguments (after the EAL ones) */ ret = flow_filtering_parse_args(argc, argv); if (ret < 0) rte_exit(EXIT_FAILURE, "Invalid flow filtering arguments\n"); nr_ports = rte_eth_dev_count_avail(); if (nr_ports == 0) rte_exit(EXIT_FAILURE, ":: no Ethernet ports found\n"); port_id = 0; if (nr_ports != 1) { printf(":: warn: %d ports detected, but we use only one: port %u\n", nr_ports, port_id); } /* Allocates a mempool to hold the mbufs. 8< */ mbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", 4096, 128, 0, RTE_MBUF_DEFAULT_BUF_SIZE, rte_socket_id()); /* >8 End of allocating a mempool to hold the mbufs. */ if (mbuf_pool == NULL) rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); return 0; } ``` -------------------------------- ### rte_event_dev_start Source: https://doc.dpdk.org/api/rte__eventdev_8h_source.html Starts an event device, enabling event processing. This function must be called after configuration and setup. ```APIDOC ## rte_event_dev_start ### Description Starts an event device, enabling event processing. This function must be called after configuration and setup. ### Function Signature ```c int rte_event_dev_start(uint8_t dev_id); ``` ### Parameters * **dev_id** (uint8_t) - The event device identifier. ``` -------------------------------- ### Start Network Device Source: https://doc.dpdk.org/api/examples_2pipeline_2obj_8c-example.html Starts a network device after configuration. It also includes optional setup for RSS (Receive Side Scaling) and attempts to set the link up. If setting the link up fails but is not unsupported, it stops the device. ```c /* Port start */ status = rte_eth_dev_start(port_id); if (status < 0) return -EINVAL; if (rss) { status = rss_setup(port_id, port_info.reta_size, rss); if (status) { rte_eth_dev_stop(port_id); return -EINVAL; } } /* Port link up */ status = rte_eth_dev_set_link_up(port_id); if ((status < 0) && (status != -ENOTSUP)) { rte_eth_dev_stop(port_id); return -EINVAL; } return 0; } ``` -------------------------------- ### DPDKRuntimeEnvironment.setup Source: https://doc.dpdk.org/api/dts/api.test.html Sets up the DPDK runtime environment, preparing it for application execution. ```APIDOC ## setup ### Description Configures and initializes the DPDK runtime environment. This typically involves loading necessary modules, setting up network interfaces, and preparing the system for DPDK applications. ### Usage This method should be called before running any DPDK applications. ``` -------------------------------- ### rte_regexdev_start Source: https://doc.dpdk.org/api/rte__regexdev_8h_source.html Starts a RegexDev device, making it ready for operation. This function should be called after configuration and queue pair setup. ```APIDOC ## rte_regexdev_start ### Description Starts a RegexDev device, making it ready for operation. ### Method int ### Parameters #### Path Parameters - **dev_id** (uint8_t) - The identifier of the RegexDev device to start. ### Response #### Success Response (0) Returns 0 on success. #### Error Response Returns a negative return value on failure. ``` -------------------------------- ### _DPDKBuildEnvironment.setup Source: https://doc.dpdk.org/api/dts/framework.remote_session.dpdk.html Sets up the DPDK build on the target node. This involves configuring build internals, copying DPDK sources, building DPDK (or using existing ones), and binding necessary drivers. ```APIDOC ## setup ### Description Set up the DPDK build on the target node. DPDK setup includes setting all internals needed for the build, the copying of DPDK sources and then building DPDK or using the exist ones from the dpdk_location. The drivers are bound to those that DPDK needs. ### Method None (Method of the _DPDKBuildEnvironment class) ### Endpoint None ### Parameters None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Event Queue Management Source: https://doc.dpdk.org/api/rte__eventdev_8h.html Functions for managing event queues, including getting default configurations, setup, and attribute retrieval/setting. ```APIDOC ## rte_event_queue_default_conf_get ### Description Retrieves the default configuration for an event queue. ### Function Signature `int rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id, struct rte_event_queue_conf *queue_conf)` ## rte_event_queue_setup ### Description Sets up an event queue with the specified configuration. ### Function Signature `int rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id, const struct rte_event_queue_conf *queue_conf)` ## rte_event_queue_attr_get ### Description Retrieves an attribute value for an event queue. ### Function Signature `int rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, uint32_t *attr_value)` ## rte_event_queue_attr_set ### Description Sets an attribute value for an event queue. ### Function Signature `int rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id, uint64_t attr_value)` ``` -------------------------------- ### Getting mbuf headroom Source: https://doc.dpdk.org/api/rte__mbuf_8h_source.html Returns the amount of available headroom in the mbuf's data buffer. This is the space before the actual data starts. ```c static inline uint16_t rte_pktmbuf_headroom(const struct rte_mbuf *m) { __rte_mbuf_sanity_check(m, 0); return m->data_off; } ``` -------------------------------- ### Event Port Management Source: https://doc.dpdk.org/api/rte__eventdev_8h.html Functions for managing event ports, including getting default configurations, setup, linking/unlinking, and attribute retrieval. ```APIDOC ## rte_event_port_default_conf_get ### Description Retrieves the default configuration for an event port. ### Function Signature `int rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id, struct rte_event_port_conf *port_conf)` ## rte_event_port_setup ### Description Sets up an event port with the specified configuration. ### Function Signature `int rte_event_port_setup(uint8_t dev_id, uint8_t port_id, const struct rte_event_port_conf *port_conf)` ## rte_event_port_quiesce ### Description Quiesces an event port, optionally with a release callback. ### Function Signature `void rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id, rte_eventdev_port_flush_t release_cb, void *args)` ## rte_event_port_attr_get ### Description Retrieves an attribute value for an event port. ### Function Signature `int rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id, uint32_t *attr_value)` ## rte_event_port_link ### Description Links an event port to one or more event queues. ### Function Signature `int rte_event_port_link(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links)` ## rte_event_port_unlink ### Description Unlinks an event port from one or more event queues. ### Function Signature `int rte_event_port_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint16_t nb_unlinks)` ## rte_event_port_profile_links_set ### Description Sets up profile-based links for an event port. ### Function Signature `int rte_event_port_profile_links_set(uint8_t dev_id, uint8_t port_id, const uint8_t queues[], const uint8_t priorities[], uint16_t nb_links, uint8_t profile_id)` ## rte_event_port_profile_unlink ### Description Unlinks profile-based links from an event port. ### Function Signature `int rte_event_port_profile_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint16_t nb_unlinks, uint8_t profile_id)` ## rte_event_port_unlinks_in_progress ### Description Checks if unlinking operations are in progress for an event port. ### Function Signature `int rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id)` ## rte_event_port_links_get ### Description Retrieves the current links of an event port. ### Function Signature `int rte_event_port_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint8_t priorities[])` ## rte_event_port_profile_links_get ### Description Retrieves the profile-based links of an event port. ### Function Signature `int rte_event_port_profile_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[], uint8_t priorities[], uint8_t profile_id)` ``` -------------------------------- ### _DPDKRuntimeEnvironment.setup Source: https://doc.dpdk.org/api/dts/framework.remote_session.dpdk.html Sets up the DPDK runtime environment on the target node. ```APIDOC ## setup ### Description Set up the DPDK runtime on the target node. ### Method None (Method of the _DPDKRuntimeEnvironment class) ### Endpoint None ### Parameters None ### Request Example None ### Response #### Success Response None #### Response Example None ``` -------------------------------- ### Get Memory Range Information Source: https://doc.dpdk.org/api/rte__mempool_8h_source.html Retrieves information about the memory range used by a memory pool, including start address, length, and contiguity. ```c __rte_experimental int rte_mempool_get_mem_range(const struct rte_mempool *mp, struct rte_mempool_mem_range_info *mem_range); ``` -------------------------------- ### Get Port Number of RX Queues Source: https://doc.dpdk.org/api/examples_2l3fwd-graph_2main_8c-example.html Determines the number of receive queues for a given port, ensuring they are sequentially numbered starting from 0. ```c static uint16_t get_port_n_rx_queues(const uint16_t port) { int queue = -1; uint16_t i; for (i = 0; i < nb_lcore_params; ++i) { if (lcore_params[i].port_id == port) { if (lcore_params[i].queue_id == queue + 1) queue = lcore_params[i].queue_id; else rte_exit(EXIT_FAILURE, "Queue ids of the port %d must be" " in sequence and must start with 0\n", lcore_params[i].port_id); } } return (uint16_t)(++queue); } ``` -------------------------------- ### Initialize and Run CLI Source: https://doc.dpdk.org/api/examples_2vm_power_manager_2vm_power_cli_8c-example.html Initializes a new command-line interface instance with the defined context and prompt, then enters the interactive mode and exits cleanly. ```c void run_cli(__rte_unused void *arg) { struct cmdline *cl; cl = cmdline_stdin_new(main_ctx, "vmpower> "); if (cl == NULL) return; cmdline_interact(cl); cmdline_stdin_exit(cl); } ``` -------------------------------- ### Get Mbuf Base Data Address Source: https://doc.dpdk.org/api/rte__mbuf_8h_source.html Returns the base address of the mbuf's data buffer, which is the start of the allocated buffer space for the mbuf. ```c static inline char * rte_mbuf_to_baddr(struct rte_mbuf *md) { return rte_mbuf_buf_addr(md, md->pool); } ``` -------------------------------- ### rte_event_eth_rx_adapter_runtime_params_init Source: https://doc.dpdk.org/api/rte__event__eth__rx__adapter_8h.html Initializes the runtime configuration parameters for an Ethernet RX adapter with default values. This is a convenient way to get a starting point for adapter configuration. ```APIDOC ## rte_event_eth_rx_adapter_runtime_params_init() ### Description Initialize the adapter runtime configuration parameters with default values. ### Parameters #### Request Body - **params** (struct rte_event_eth_rx_adapter_runtime_params *) - Required - A pointer to structure of type struct rte_event_eth_rx_adapter_runtime_params. ### Returns - 0: Success - <0: Error code on failure. ```