MCPcopy Create free account
hub / github.com/F-Stack/f-stack / start_polling_recv_file

Function start_polling_recv_file

dpdk/examples/ntb/ntb_fwd.c:289–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287
288#define RECV_FILE_LEN 30
289static int
290start_polling_recv_file(void *param)
291{
292 struct rte_rawdev_buf *pkts_recv[NTB_MAX_PKT_BURST];
293 struct ntb_fwd_lcore_conf *conf = param;
294 struct rte_mbuf *mbuf;
295 char filepath[RECV_FILE_LEN];
296 uint64_t val, size, file_len;
297 uint16_t nb_rx, i, file_no;
298 size_t queue_id = 0;
299 FILE *file;
300 int ret;
301
302 for (i = 0; i < NTB_MAX_PKT_BURST; i++)
303 pkts_recv[i] = (struct rte_rawdev_buf *)
304 malloc(sizeof(struct rte_rawdev_buf));
305
306 file_no = 0;
307 while (!conf->stopped) {
308 snprintf(filepath, RECV_FILE_LEN, "ntb_recv_file%d", file_no);
309 file = fopen(filepath, "w");
310 if (file == NULL) {
311 printf("Fail to open the file.\n");
312 return -EINVAL;
313 }
314
315 rte_rawdev_get_attr(dev_id, "spad_user_0", &val);
316 size = val << 32;
317 rte_rawdev_get_attr(dev_id, "spad_user_1", &val);
318 size |= val;
319
320 if (!size) {
321 fclose(file);
322 continue;
323 }
324
325 file_len = 0;
326 nb_rx = NTB_MAX_PKT_BURST;
327 while (file_len < size && !conf->stopped) {
328 ret = rte_rawdev_dequeue_buffers(dev_id, pkts_recv,
329 pkt_burst, (void *)queue_id);
330 if (ret < 0) {
331 printf("Dequeue failed with err %d\n", ret);
332 fclose(file);
333 goto clean;
334 }
335 nb_rx = ret;
336 ntb_port_stats[0].rx += nb_rx;
337 for (i = 0; i < nb_rx; i++) {
338 mbuf = pkts_recv[i]->buf_addr;
339 fwrite(rte_pktmbuf_mtod(mbuf, void *), 1,
340 mbuf->data_len, file);
341 file_len += mbuf->data_len;
342 rte_pktmbuf_free(mbuf);
343 pkts_recv[i]->buf_addr = NULL;
344 }
345 }
346

Callers

nothing calls this directly

Calls 7

mallocFunction · 0.85
snprintfFunction · 0.85
rte_rawdev_get_attrFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected