* Check if the destination MAC of a packet is one local VM, * and get its vlan tag, and offset if it is. */
| 1168 | * and get its vlan tag, and offset if it is. |
| 1169 | */ |
| 1170 | static __rte_always_inline int |
| 1171 | find_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 | |
| 1204 | static void virtio_tx_offload(struct rte_mbuf *m) |
| 1205 | { |
no test coverage detected