Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
igb: Filter with the second VLAN tag for extended VLAN
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
  • Loading branch information
akihikodaki authored and jasowang committed May 23, 2023
1 parent 7e64a9c commit 6aa262f
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions hw/net/igb_core.c
Expand Up @@ -69,7 +69,7 @@ typedef struct IGBTxPktVmdqCallbackContext {

typedef struct L2Header {
struct eth_header eth;
struct vlan_header vlan;
struct vlan_header vlan[2];
} L2Header;

static ssize_t
Expand Down Expand Up @@ -1001,7 +1001,7 @@ static uint16_t igb_receive_assign(IGBCore *core, const L2Header *l2_header,
uint32_t f, ra[2], *macp, rctl = core->mac[RCTL];
uint16_t queues = 0;
uint16_t oversized = 0;
uint16_t vid = be16_to_cpu(l2_header->vlan.h_tci) & VLAN_VID_MASK;
size_t vlan_num = 0;
int i;

memset(rss_info, 0, sizeof(E1000E_RSSInfo));
Expand All @@ -1010,8 +1010,19 @@ static uint16_t igb_receive_assign(IGBCore *core, const L2Header *l2_header,
*external_tx = true;
}

if (e1000x_is_vlan_packet(ehdr, core->mac[VET] & 0xffff) &&
!e1000x_rx_vlan_filter(core->mac, PKT_GET_VLAN_HDR(ehdr))) {
if (core->mac[CTRL_EXT] & BIT(26)) {
if (be16_to_cpu(ehdr->h_proto) == core->mac[VET] >> 16 &&
be16_to_cpu(l2_header->vlan[0].h_proto) == (core->mac[VET] & 0xffff)) {
vlan_num = 2;
}
} else {
if (be16_to_cpu(ehdr->h_proto) == (core->mac[VET] & 0xffff)) {
vlan_num = 1;
}
}

if (vlan_num &&
!e1000x_rx_vlan_filter(core->mac, l2_header->vlan + vlan_num - 1)) {
return queues;
}

Expand Down Expand Up @@ -1065,7 +1076,9 @@ static uint16_t igb_receive_assign(IGBCore *core, const L2Header *l2_header,
if (e1000x_vlan_rx_filter_enabled(core->mac)) {
uint16_t mask = 0;

if (e1000x_is_vlan_packet(ehdr, core->mac[VET] & 0xffff)) {
if (vlan_num) {
uint16_t vid = be16_to_cpu(l2_header->vlan[vlan_num - 1].h_tci) & VLAN_VID_MASK;

for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) {
if ((core->mac[VLVF0 + i] & E1000_VLVF_VLANID_MASK) == vid &&
(core->mac[VLVF0 + i] & E1000_VLVF_VLANID_ENABLE)) {
Expand Down

0 comments on commit 6aa262f

Please sign in to comment.