zero_copy = ret;
if (zero_copy) {
-#ifdef RTE_MBUF_SCATTER_GATHER
+#ifdef RTE_MBUF_REFCNT
RTE_LOG(ERR, VHOST_CONFIG, "Before running "
"zero copy vhost APP, please "
- "disable RTE_MBUF_SCATTER_GATHER\n"
+ "disable RTE_MBUF_REFCNT\n"
"in config file and then rebuild DPDK "
"core lib!\n"
"Otherwise please disable zero copy "
/* Copy mbuf data to buffer */
rte_memcpy((void *)(uintptr_t)buff_addr,
- (const void *)buff->pkt.data,
+ rte_pktmbuf_mtod(buff, const void *),
rte_pktmbuf_data_len(buff));
PRINT_PACKET(dev, (uintptr_t)buff_addr,
rte_pktmbuf_data_len(buff), 0);
* This current segment complete, need continue to
* check if the whole packet complete or not.
*/
- pkt = pkt->pkt.next;
+ pkt = pkt->next;
if (pkt != NULL) {
/*
* There are more segments.
uint32_t secure_len = 0;
uint16_t need_cnt;
uint32_t vec_idx = 0;
- uint32_t pkt_len = pkts[pkt_idx]->pkt.pkt_len + vq->vhost_hlen;
+ uint32_t pkt_len = pkts[pkt_idx]->pkt_len + vq->vhost_hlen;
uint16_t i, id;
do {
int i, ret;
/* Learn MAC address of guest device from packet */
- pkt_hdr = (struct ether_hdr *)m->pkt.data;
+ pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
dev_ll = ll_root_used;
struct ether_hdr *pkt_hdr;
uint64_t ret = 0;
- pkt_hdr = (struct ether_hdr *)m->pkt.data;
+ pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
/*get the used devices list*/
dev_ll = ll_root_used;
unsigned len, ret, offset = 0;
const uint16_t lcore_id = rte_lcore_id();
struct virtio_net_data_ll *dev_ll = ll_root_used;
- struct ether_hdr *pkt_hdr = (struct ether_hdr *)m->pkt.data;
+ struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
/*check if destination is local VM*/
if ((vm2vm_mode == VM2VM_SOFTWARE) && (virtio_tx_local(dev, m) == 0))
return;
}
- mbuf->pkt.data_len = m->pkt.data_len + VLAN_HLEN + offset;
- mbuf->pkt.pkt_len = m->pkt.pkt_len + VLAN_HLEN + offset;
- mbuf->pkt.nb_segs = m->pkt.nb_segs;
+ mbuf->data_len = m->data_len + VLAN_HLEN + offset;
+ mbuf->pkt_len = m->pkt_len + VLAN_HLEN + offset;
+ mbuf->nb_segs = m->nb_segs;
/* Copy ethernet header to mbuf. */
- rte_memcpy((void*)mbuf->pkt.data, (const void*)m->pkt.data, ETH_HLEN);
+ rte_memcpy(rte_pktmbuf_mtod(mbuf, void *),
+ rte_pktmbuf_mtod(m, const void *),
+ ETH_HLEN);
/* Setup vlan header. Bytes need to be re-ordered for network with htons()*/
- vlan_hdr = (struct vlan_ethhdr *) mbuf->pkt.data;
+ vlan_hdr = rte_pktmbuf_mtod(mbuf, struct vlan_ethhdr *);
vlan_hdr->h_vlan_encapsulated_proto = vlan_hdr->h_vlan_proto;
vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q);
vlan_hdr->h_vlan_TCI = htons(vlan_tag);
/* Copy the remaining packet contents to the mbuf. */
- rte_memcpy((void*) ((uint8_t*)mbuf->pkt.data + VLAN_ETH_HLEN),
- (const void*) ((uint8_t*)m->pkt.data + ETH_HLEN), (m->pkt.data_len - ETH_HLEN));
+ rte_memcpy((void *)(rte_pktmbuf_mtod(mbuf, uint8_t *) + VLAN_ETH_HLEN),
+ (const void *)(rte_pktmbuf_mtod(m, uint8_t *) + ETH_HLEN),
+ (m->data_len - ETH_HLEN));
/* Copy the remaining segments for the whole packet. */
prev = mbuf;
- while (m->pkt.next) {
+ while (m->next) {
/* Allocate an mbuf and populate the structure. */
struct rte_mbuf *next_mbuf = rte_pktmbuf_alloc(mbuf_pool);
if (unlikely(next_mbuf == NULL)) {
return;
}
- m = m->pkt.next;
- prev->pkt.next = next_mbuf;
+ m = m->next;
+ prev->next = next_mbuf;
prev = next_mbuf;
- next_mbuf->pkt.data_len = m->pkt.data_len;
+ next_mbuf->data_len = m->data_len;
/* Copy data to next mbuf. */
rte_memcpy(rte_pktmbuf_mtod(next_mbuf, void *),
- rte_pktmbuf_mtod(m, const void *), m->pkt.data_len);
+ rte_pktmbuf_mtod(m, const void *), m->data_len);
}
tx_q->m_table[len] = mbuf;
vq->used->ring[used_idx].len = 0;
/* Setup dummy mbuf. This is copied to a real mbuf if transmitted out the physical port. */
- m.pkt.data_len = desc->len;
- m.pkt.pkt_len = desc->len;
- m.pkt.data = (void*)(uintptr_t)buff_addr;
+ m.data_len = desc->len;
+ m.pkt_len = desc->len;
+ m.data_off = 0;
PRINT_PACKET(dev, (uintptr_t)buff_addr, desc->len, 0);
* while the virtio buffer in TX vring has
* more data to be copied.
*/
- cur->pkt.data_len = seg_offset;
- m->pkt.pkt_len += seg_offset;
+ cur->data_len = seg_offset;
+ m->pkt_len += seg_offset;
/* Allocate mbuf and populate the structure. */
cur = rte_pktmbuf_alloc(mbuf_pool);
if (unlikely(cur == NULL)) {
}
seg_num++;
- prev->pkt.next = cur;
+ prev->next = cur;
prev = cur;
seg_offset = 0;
seg_avail = buf_size;
* room to accomodate more
* data.
*/
- cur->pkt.data_len = seg_offset;
- m->pkt.pkt_len += seg_offset;
+ cur->data_len = seg_offset;
+ m->pkt_len += seg_offset;
/*
* Allocate an mbuf and
* populate the structure.
break;
}
seg_num++;
- prev->pkt.next = cur;
+ prev->next = cur;
prev = cur;
seg_offset = 0;
seg_avail = buf_size;
desc->len, 0);
} else {
/* The whole packet completes. */
- cur->pkt.data_len = seg_offset;
- m->pkt.pkt_len += seg_offset;
+ cur->data_len = seg_offset;
+ m->pkt_len += seg_offset;
vb_avail = 0;
}
}
if (unlikely(alloc_err == 1))
break;
- m->pkt.nb_segs = seg_num;
+ m->nb_segs = seg_num;
/*
* If this is the first received packet we need to learn
}
mbuf->buf_addr = (void *)(uintptr_t)(buff_addr - RTE_PKTMBUF_HEADROOM);
- mbuf->pkt.data = (void *)(uintptr_t)(buff_addr);
+ mbuf->data_off = RTE_PKTMBUF_HEADROOM;
mbuf->buf_physaddr = phys_addr - RTE_PKTMBUF_HEADROOM;
- mbuf->pkt.data_len = desc->len;
+ mbuf->data_len = desc->len;
MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx;
LOG_DEBUG(VHOST_DATA,
buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ?
RTE_PKTMBUF_HEADROOM : m->buf_len;
- m->pkt.data = (char *) m->buf_addr + buf_ofs;
+ m->data_off = buf_ofs;
- m->pkt.data_len = 0;
+ m->data_len = 0;
}
/*
unsigned len, ret, offset = 0;
struct vpool *vpool;
struct virtio_net_data_ll *dev_ll = ll_root_used;
- struct ether_hdr *pkt_hdr = (struct ether_hdr *)m->pkt.data;
+ struct ether_hdr *pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh];
/*Add packet to the port tx queue*/
}
}
- mbuf->pkt.nb_segs = m->pkt.nb_segs;
- mbuf->pkt.next = m->pkt.next;
- mbuf->pkt.data_len = m->pkt.data_len + offset;
- mbuf->pkt.pkt_len = mbuf->pkt.data_len;
+ mbuf->nb_segs = m->nb_segs;
+ mbuf->next = m->next;
+ mbuf->data_len = m->data_len + offset;
+ mbuf->pkt_len = mbuf->data_len;
if (unlikely(need_copy)) {
/* Copy the packet contents to the mbuf. */
- rte_memcpy((void *)((uint8_t *)mbuf->pkt.data),
- (const void *) ((uint8_t *)m->pkt.data),
- m->pkt.data_len);
+ rte_memcpy(rte_pktmbuf_mtod(mbuf, void *),
+ rte_pktmbuf_mtod(m, void *),
+ m->data_len);
} else {
- mbuf->pkt.data = m->pkt.data;
+ mbuf->data_off = m->data_off;
mbuf->buf_physaddr = m->buf_physaddr;
mbuf->buf_addr = m->buf_addr;
}
mbuf->ol_flags = PKT_TX_VLAN_PKT;
- mbuf->pkt.vlan_macip.f.vlan_tci = vlan_tag;
- mbuf->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr);
- mbuf->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr);
+ mbuf->vlan_tci = vlan_tag;
+ mbuf->l2_len = sizeof(struct ether_hdr);
+ mbuf->l3_len = sizeof(struct ipv4_hdr);
MBUF_HEADROOM_UINT32(mbuf) = (uint32_t)desc_idx;
tx_q->m_table[len] = mbuf;
LOG_DEBUG(VHOST_DATA,
"(%"PRIu64") in tx_route_zcp: pkt: nb_seg: %d, next:%s\n",
dev->device_fh,
- mbuf->pkt.nb_segs,
- (mbuf->pkt.next == NULL) ? "null" : "non-null");
+ mbuf->nb_segs,
+ (mbuf->next == NULL) ? "null" : "non-null");
if (enable_stats) {
dev_statistics[dev->device_fh].tx_total++;
* Setup dummy mbuf. This is copied to a real mbuf if
* transmitted out the physical port.
*/
- m.pkt.data_len = desc->len;
- m.pkt.nb_segs = 1;
- m.pkt.next = NULL;
- m.pkt.data = (void *)(uintptr_t)buff_addr;
- m.buf_addr = m.pkt.data;
+ m.data_len = desc->len;
+ m.nb_segs = 1;
+ m.next = NULL;
+ m.data_off = 0;
+ m.buf_addr = (void *)(uintptr_t)buff_addr;
m.buf_physaddr = phys_addr;
/*
if (ret < 0)
rte_exit(EXIT_FAILURE, "Invalid argument\n");
- if (rte_eal_pci_probe() != 0)
- rte_exit(EXIT_FAILURE, "Error with NIC driver initialization\n");
-
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id ++)
if (rte_lcore_is_enabled(lcore_id))
lcore_ids[core_id ++] = lcore_id;