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

Function tap_write_mbufs

dpdk/drivers/net/tap/rte_eth_tap.c:524–654  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

522}
523
524static inline int
525tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,
526 struct rte_mbuf **pmbufs,
527 uint16_t *num_packets, unsigned long *num_tx_bytes)
528{
529 struct pmd_process_private *process_private;
530 int i;
531
532 process_private = rte_eth_devices[txq->out_port].process_private;
533
534 for (i = 0; i < num_mbufs; i++) {
535 struct rte_mbuf *mbuf = pmbufs[i];
536 struct iovec iovecs[mbuf->nb_segs + 2];
537 struct tun_pi pi = { .flags = 0, .proto = 0x00 };
538 struct rte_mbuf *seg = mbuf;
539 uint64_t l4_ol_flags;
540 int proto;
541 int n;
542 int j;
543 int k; /* current index in iovecs for copying segments */
544
545 if (txq->type == ETH_TUNTAP_TYPE_TUN) {
546 /*
547 * TUN and TAP are created with IFF_NO_PI disabled.
548 * For TUN PMD this mandatory as fields are used by
549 * Kernel tun.c to determine whether its IP or non IP
550 * packets.
551 *
552 * The logic fetches the first byte of data from mbuf
553 * then compares whether its v4 or v6. If first byte
554 * is 4 or 6, then protocol field is updated.
555 */
556 char *buff_data = rte_pktmbuf_mtod(seg, void *);
557 proto = (*buff_data & 0xf0);
558 pi.proto = (proto == 0x40) ?
559 rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4) :
560 ((proto == 0x60) ?
561 rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6) :
562 0x00);
563 }
564
565 k = 0;
566 iovecs[k].iov_base = &pi;
567 iovecs[k].iov_len = sizeof(pi);
568 k++;
569
570 l4_ol_flags = mbuf->ol_flags & RTE_MBUF_F_TX_L4_MASK;
571 if (txq->csum && (mbuf->ol_flags & RTE_MBUF_F_TX_IP_CKSUM ||
572 l4_ol_flags == RTE_MBUF_F_TX_UDP_CKSUM ||
573 l4_ol_flags == RTE_MBUF_F_TX_TCP_CKSUM)) {
574 unsigned int hdrlens = mbuf->l2_len + mbuf->l3_len;
575 uint16_t *l4_cksum;
576 void *l3_hdr;
577
578 if (l4_ol_flags == RTE_MBUF_F_TX_UDP_CKSUM)
579 hdrlens += sizeof(struct rte_udp_hdr);
580 else if (l4_ol_flags == RTE_MBUF_F_TX_TCP_CKSUM)
581 hdrlens += sizeof(struct rte_tcp_hdr);

Callers 1

pmd_tx_burstFunction · 0.85

Calls 7

rte_pktmbuf_copyFunction · 0.85
rte_pktmbuf_adjFunction · 0.85
rte_pktmbuf_chainFunction · 0.85
rte_ipv4_cksumFunction · 0.85
writevFunction · 0.50

Tested by

no test coverage detected