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

Function find_local_dest

dpdk/examples/vhost/main.c:1170–1202  ·  view source on GitHub ↗

* Check if the destination MAC of a packet is one local VM, * and get its vlan tag, and offset if it is. */

Source from the content-addressed store, hash-verified

1168 * and get its vlan tag, and offset if it is.
1169 */
1170static __rte_always_inline int
1171find_local_dest(struct vhost_dev *vdev, struct rte_mbuf *m,
1172 uint32_t *offset, uint16_t *vlan_tag)
1173{
1174 struct vhost_dev *dst_vdev;
1175 struct rte_ether_hdr *pkt_hdr =
1176 rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
1177
1178 dst_vdev = find_vhost_dev(&pkt_hdr->dst_addr);
1179 if (!dst_vdev)
1180 return 0;
1181
1182 if (vdev->vid == dst_vdev->vid) {
1183 RTE_LOG_DP(DEBUG, VHOST_DATA,
1184 "(%d) TX: src and dst MAC is same. Dropping packet.\n",
1185 vdev->vid);
1186 return -1;
1187 }
1188
1189 /*
1190 * HW vlan strip will reduce the packet length
1191 * by minus length of vlan tag, so need restore
1192 * the packet length by plus it.
1193 */
1194 *offset = RTE_VLAN_HLEN;
1195 *vlan_tag = vlan_tags[vdev->vid];
1196
1197 RTE_LOG_DP(DEBUG, VHOST_DATA,
1198 "(%d) TX: pkt to local VM device id: (%d), vlan tag: %u.\n",
1199 vdev->vid, dst_vdev->vid, *vlan_tag);
1200
1201 return 0;
1202}
1203
1204static void virtio_tx_offload(struct rte_mbuf *m)
1205{

Callers 1

virtio_tx_routeFunction · 0.85

Calls 1

find_vhost_devFunction · 0.85

Tested by

no test coverage detected