DPDK send customized pkt but fail to receive

*爱你&永不变心* 提交于 2019-12-24 08:28:13

问题


I'm trying to send customized packages with dpdk, but i find that some package structure will make it fail to receive. For example, i define the package structure like this:

union my_pkt{
   struct hdr{
       uint32_t id;
       uint32_t name_len;
       uint64_t tsc;
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

My server running dpdk can only receive 1st batch of pkts, but the returned value of rte_eth_tx_burst() shows much more packages which have been sent.
However , if i modify the structure as below:

union my_pkt{
   struct hdr{
       uint32_t id;
       uint32_t name_len;
       uint32_t tsc[2];//modify this line
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

Sending and receiving both work correctly. The only difference between two structures is that the uint64_t timestamp were replace by an uint32_t array consisting of 2 items. I debug into the i40e driver code but can not understand where it goes wrong.

Can anybody help me? thanks!


回答1:


While it is not clear from your description, you probably should add an Ethernet header at the beginning of you buffer, i.e.:

union my_pkt{
   struct hdr{
       struct ether_hdr; // Ethernet header
       uint32_t id;
       uint32_t name_len;
       uint64_t tsc;
       uint8_t name[100];
   }__attribute__((__packed__)) pkt_hdr;
   char buff[500];
};

And then fill it with destination/source MACs and type in your code.



来源:https://stackoverflow.com/questions/44160477/dpdk-send-customized-pkt-but-fail-to-receive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!