MCPcopy Create free account
hub / github.com/axboe/liburing / do_tx

Function do_tx

examples/send-zerocopy.c:334–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334static void do_tx(struct thread_data *td, int domain, int type, int protocol)
335{
336 const int notif_slack = 128;
337 struct io_uring ring;
338 struct iovec iov;
339 uint64_t tstart;
340 int i, fd, ret;
341 int compl_cqes = 0;
342 int ring_flags = IORING_SETUP_COOP_TASKRUN | IORING_SETUP_SINGLE_ISSUER;
343 unsigned loop = 0;
344
345 if (cfg_defer_taskrun)
346 ring_flags |= IORING_SETUP_DEFER_TASKRUN;
347
348 fd = socket(domain, type, protocol);
349 if (fd == -1)
350 t_error(1, errno, "socket t");
351
352 if (cfg_ifname) {
353 struct ifreq ifr;
354
355 memset(&ifr, 0, sizeof(ifr));
356 strncpy(ifr.ifr_name, cfg_ifname, sizeof(ifr.ifr_name) - 1);
357
358 if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0)
359 t_error(1, errno, "Binding to device failed\n");
360 }
361
362 if (connect(fd, (void *)&td->dst_addr, cfg_alen))
363 t_error(1, errno, "connect, idx %i", td->idx);
364
365 ret = io_uring_queue_init(512, &ring, ring_flags);
366 if (ret)
367 t_error(1, ret, "io_uring: queue init");
368
369 set_cpu_affinity();
370 set_iowq_affinity(&ring);
371
372 if (cfg_fixed_files) {
373 ret = io_uring_register_files(&ring, &fd, 1);
374 if (ret < 0)
375 t_error(1, ret, "io_uring: files registration");
376 }
377 if (cfg_reg_ringfd) {
378 ret = io_uring_register_ring_fd(&ring);
379 if (ret < 0)
380 t_error(1, ret, "io_uring: io_uring_register_ring_fd");
381 }
382
383 iov.iov_base = payload;
384 iov.iov_len = cfg_payload_len + PATTERN_SIZE;
385
386 ret = io_uring_register_buffers(&ring, &iov, 1);
387 if (ret)
388 t_error(1, ret, "io_uring: buffer registration");
389
390 if (cfg_rx_poll) {
391 struct io_uring_sqe *sqe;

Callers 1

do_testFunction · 0.85

Calls 13

io_uring_queue_initFunction · 0.85
set_cpu_affinityFunction · 0.85
set_iowq_affinityFunction · 0.85
io_uring_register_filesFunction · 0.85
io_uring_submitFunction · 0.85
wait_cqe_fastFunction · 0.85
io_uring_queue_exitFunction · 0.85
t_errorFunction · 0.70
gettimeofday_msFunction · 0.70

Tested by

no test coverage detected