Tag: QEMU does not have image img DDC exception seq POS padding
Continuation of the previous section: [DPDK] familiar with the SDK and preliminary use (i) (QEMU Build experimental environment)
Program logic:
Operating parameters:
Key API:
Entry function:
int rte_eal_init (int argc, char **argv)
Memory Pool functions:
Rte_pktmbuf_pool_create. It is an encapsulation of the function rte_mempool_create.
struct Rte_mempool * Char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)
Name is the memory pool name. For better performance, N should be a power minus 1 for 2.
Network card operation function:
Rte_eth_dev_configure () sets the network card device. You should call this function to set it before other operations.
Rte_eth_rx_queue_setup () request and set up a packet receipt queue.
Key parameters:
struct Rte_mempool *mp; pool created by the previous article
Rte_eth_tx_queue_setup () ibid.
Rte_eth_dev_start () is set up after the start Ah, the collection, the hair of the hair.
Rte_eth_promiscuous_enable () starts promiscuous mode, not explained.
Receive package function:
Rte_eth_rx_burst () collect a large number of packages
This interface does not provide any error detection function, the upper application can be the return packet number of zero, to actively detect the link state to complete the interface anomaly and error detection mechanism.
Key parameters:
struct rte_mbuf** rx_pkts; An array of pointers, each pointer in the array points to a package to be collected, and a detailed package structure that looks at the data structure section below. The memory space pointed to by the pointer is provided by the parameter pool in the Queue_setup (mpool) function.
Const uint16_t NB_PKTS; In simple terms, it is the array size.
return value:
Number of items to be filled in the array, received.
When the return value = = Nb_pkts, the implied description, the performance of the packet has not been followed.
When the return value = = 0 o'clock, you should start the anomaly detection, check the interface status and so on.
Rte_eth_tx_burst () Send a large number of packages
Rte_pktmbuf_free () received but not sent to the package, should be free, that is, back to Mpool. Gee, but why did it have to be sent out? Strange
Other functions:
Rte_eth_dev_count ():
Returns the number of network ports that can be used by DPDK. That is (load the UiO driver, or Vfio?? After Rte_eal_init, you can use it.
RTE_SOCKET_ID ():
Returns the ID of the CPU sock, which is the CPU socket of the Lcore that is specified in the command parameter.
Look back and compare the HelloWorld. A function is used more in HelloWorld.
Rte_eal_remote_launch () is used to start multi-threading on multiple cores, as in the original example:
/**/ Rte_lcore_foreach_slave (lcore_id) { rte_eal_remote_launch (Lcore_hello, NULL, lcore_id); }
Lcore_hello (NULL);
lcore_id = rte_lcore_id ();
printf ("Hello from Master Core%u\n", lcore_id);
The main thread, running the smallest number on the core, do not know whether it can be modified.
[Email protected] ~]#PS-elf |grep-E"Uid|helloworld"UID PID PPID LWP C nlwp SZ RSS PSR stime TTY time Cmdroot2671 2531 2671 About 5 274512 3668 4 -: -pts/0 xx: to: A./helloworld-l4,5,6,7Root2671 2531 2672 0 5 274512 3668 4 -: -pts/0 xx:xx:xx./helloworld-l4,5,6,7Root2671 2531 2673 0 5 274512 3668 5 -: -pts/0 xx:xx:xx./helloworld-l4,5,6,7Root2671 2531 2674 0 5 274512 3668 6 -: -pts/0 xx:xx:xx./helloworld-l4,5,6,7Root2671 2531 2675 0 5 274512 3668 7 -: -pts/0 xx:xx:xx./helloworld-l4,5,6,7Root2778 2679 2778 0 1 28162 964 0 -: -pts/1 xx:xx:xx grep--COLOR=AUTO-E uid|Helloworld[[email protected]~]#
Data:
struct RTE_MBUF {}
GDB: Get rid of-O3
Set Breakpoints:
(GDB)Infobnum Type Disp Enb Address What1Breakpoint Keep Y0x0000000000435829 inchLcore_main at/root/src/sdk/@dpdk/dpdk-stable-16.07.1/EXAMPLES/SKELETON/BASICFWD.C:143Breakpoint already hit1 Time(GDB) L143138 for (;;) {139 /** Receive packets on a port and forward them on the paired141 * port. The mapping is 0, 1, 1, 0, 2 , 3, 3, 2, etc.142*/143 for(Port =0; Port < Nb_ports; port++) {144145 /*Get burst of RX packets, from first port of pair.*/146struct RTE_MBUF *Bufs[burst_size];147Const uint16_t NB_RX = Rte_eth_rx_burst (Port,0, (GDB)
Debug a package:
The package format is as follows:
Enter the breakpoint and look at the data structure as follows:
(GDB) P bufs[0]$ -= (struct rte_mbuf *)0x7fffd9791b00(GDB) p*bufs[0]$ += {Cacheline0 =0x7fffd9791b00, buf_addr =0x7fffd9791b80, buf_physaddr =972626816, Buf_len =2176, Rearm_data =0x7fffd9791b12 "\200", Data_off = -, {refcnt_atomic= {cnt =1}, refcnt =1}, Nb_segs =1 '\001', Port =0 '\000', Ol_flags =0, RX_DESCRIPTOR_FIELDS1 =0x7fffd9791b20, {Packet_type =0, {l2_type=0, L3_type =0, L4_type =0, Tun_type =0, Inner_l2_type =0, Inner_l3_type =0, Inner_l4_type =0}}, Pkt_len = the, Data_len = the, VLAN_TCI =0, Hash= {RSS =0, Fdir = {{{hash =0,ID=0}, lo =0}, HI =0}, sched = {lo =0, hi =0}, USR =0}, seqn =0, Vlan_tci_outer =0, cacheline1 =0X7FFFD9791B40, {UserData=0x0, Udata64 =0}, Pool =0x7fffd64436c0, next =0x0, {tx_offload =0, {L2_len =0, L3_len =0, L4_len =0, Tso_segsz =0, Outer_l3_len =0, Outer_l2_len=0}}, Priv_size =0, TimeSync =0} (GDB) x/42XB (bufs[0].buf_addr + -)0x7fffd9791c00:0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x00 0x000X7FFFD9791C08:0x00 0x01 0x00 0x01 0x08 0x06 0x00 0x010X7FFFD9791C10:0x08 0x00 0x06 0x04 0x00 0x01 0x00 0x000x7fffd9791c18:0x00 0x01 0x00 0x01 0x01 0x01 0x01 0x010X7FFFD9791C20:0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x010x7fffd9791c28:0x01 0x02(GDB) where
callback function and CPU cycle
Example Rxtx_callback adds two callback functions on top of skeleton, and calculates the CPU cycles in the callback function.
Rte_eth_add_rx_callback ()
Rte_eth_add_tx_callback ()
For CPU cycles see another blog [daily] using RDTSC instructions, measuring the speed of the program [turn]
[DPDK] familiar with the SDK and preliminary use (ii) (Skeleton source analysis)