From 630a2d6c3cad3783d8d2b825c61857cea82464d9 Mon Sep 17 00:00:00 2001 From: Wojciech Zmuda Date: Wed, 20 Jul 2016 13:53:06 +0200 Subject: [PATCH] DPDK: support for priority in VLAN header. If QoS policy is set and vRouter operates in VLAN, set priority bits in the TCI field of a VLAN header for packets egressing fabric interface. Closes-bug #1604353 Change-Id: I400e835948d1a048496ab4be52ab2f251e96d49b --- dpdk/dpdk_vrouter.c | 5 ++++- dpdk/vr_dpdk_host.c | 2 ++ dpdk/vr_dpdk_interface.c | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dpdk/dpdk_vrouter.c b/dpdk/dpdk_vrouter.c index 0bbaeb5d5..dd250df3e 100644 --- a/dpdk/dpdk_vrouter.c +++ b/dpdk/dpdk_vrouter.c @@ -866,6 +866,7 @@ Usage(void) " (ex: --"SOCKET_MEM_OPT" 256,256)\n" "\n" " --"VLAN_TCI_OPT" TCI VLAN tag control information to use\n" + " It may be a value between 0 and 4095\n" " --"VLAN_NAME_OPT" NAME VLAN forwarding interface name\n" "\n" " --"BRIDGE_ENTRIES_OPT" NUM Bridge table limit\n" @@ -923,10 +924,12 @@ parse_long_opts(int opt_flow_index, char *optarg) * vr_dpdk_lcore_vroute(), dpdk_vlan_forwarding_if_add(). */ case VLAN_TCI_OPT_INDEX: - vr_dpdk.vlan_tag = (uint16_t)strtol(optarg, NULL, 0); + vr_dpdk.vlan_tag = (uint16_t)strtoul(optarg, NULL, 0); if (errno != 0) { vr_dpdk.vlan_tag = VLAN_ID_INVALID; } + if (vr_dpdk.vlan_tag > 4095) + Usage(); break; case VTEST_VLAN_OPT_INDEX: diff --git a/dpdk/vr_dpdk_host.c b/dpdk/vr_dpdk_host.c index 95ae6e4b6..4b3fc373c 100644 --- a/dpdk/vr_dpdk_host.c +++ b/dpdk/vr_dpdk_host.c @@ -1337,6 +1337,8 @@ vr_dpdk_packet_get(struct rte_mbuf *m, struct vr_interface *vif) pkt->vp_ttl = 64; pkt->vp_type = VP_TYPE_NULL; + pkt->vp_queue = 0; + pkt->vp_priority = 0; return pkt; } diff --git a/dpdk/vr_dpdk_interface.c b/dpdk/vr_dpdk_interface.c index 1b9ff52f2..d1e040b08 100644 --- a/dpdk/vr_dpdk_interface.c +++ b/dpdk/vr_dpdk_interface.c @@ -1253,9 +1253,10 @@ dpdk_if_tx(struct vr_interface *vif, struct vr_packet *pkt) * non fabric interfaces too (Emulates physical interface for some vlan test cases). * */ - if ((unlikely(vr_dpdk.vlan_tag != VLAN_ID_INVALID && vif_is_fabric(vif)) - || vr_dpdk.vtest_vlan)) { - m->vlan_tci = vr_dpdk.vlan_tag; + if (unlikely(vr_dpdk.vlan_tag != VLAN_ID_INVALID && vif_is_fabric(vif)) || + vr_dpdk.vtest_vlan) { + /* set 3 PCP bits and 12 VLAN ID bits */ + m->vlan_tci = (pkt->vp_priority << 13 | vr_dpdk.vlan_tag); if (unlikely((vif->vif_flags & VIF_FLAG_VLAN_OFFLOAD) == 0)) { /* Software VLAN TCI insert. */ if (unlikely(pkt_push(pkt, sizeof(struct vlan_hdr)) == NULL)) {