Author: sephe Date: Thu Sep 1 07:04:47 2016 New Revision: 305179 URL: https://svnweb.freebsd.org/changeset/base/305179
Log: hyperv/hn: Fix VLAN tag construction. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7716 Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/if_hnvar.h head/sys/dev/hyperv/netvsc/ndis.h Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Sep 1 06:35:13 2016 (r305178) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Sep 1 07:04:47 2016 (r305179) @@ -1412,8 +1412,11 @@ netvsc_recv(struct hn_rx_ring *rxr, cons } } skip: - if (info->vlan_info != NULL) { - m_new->m_pkthdr.ether_vtag = info->vlan_info->u1.s1.vlan_id; + if (info->vlan_info != HN_NDIS_VLAN_INFO_INVALID) { + m_new->m_pkthdr.ether_vtag = EVL_MAKETAG( + NDIS_VLAN_INFO_ID(info->vlan_info), + NDIS_VLAN_INFO_PRI(info->vlan_info), + NDIS_VLAN_INFO_CFI(info->vlan_info)); m_new->m_flags |= M_VLANTAG; } Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Sep 1 06:35:13 2016 (r305178) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Sep 1 07:04:47 2016 (r305179) @@ -156,7 +156,7 @@ hv_rf_find_recvinfo(const rndis_packet * const struct rndis_pktinfo *pi; uint32_t mask = 0, len; - info->vlan_info = NULL; + info->vlan_info = HN_NDIS_VLAN_INFO_INVALID; info->csum_info = NULL; info->hash_info = NULL; info->hash_value = NULL; @@ -193,9 +193,9 @@ hv_rf_find_recvinfo(const rndis_packet * switch (pi->rm_type) { case ieee_8021q_info: - if (__predict_false(dlen < sizeof(ndis_8021q_info))) + if (__predict_false(dlen < NDIS_VLAN_INFO_SIZE)) return (EINVAL); - info->vlan_info = data; + info->vlan_info = *((const uint32_t *)data); mask |= HV_RF_RECVINFO_VLAN; break; Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Thu Sep 1 06:35:13 2016 (r305178) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Thu Sep 1 07:04:47 2016 (r305179) @@ -55,8 +55,10 @@ struct rndix_hash_value; struct ndis_8021q_info_; struct rndis_tcp_ip_csum_info_; +#define HN_NDIS_VLAN_INFO_INVALID 0xffffffff + struct hn_recvinfo { - const struct ndis_8021q_info_ *vlan_info; + uint32_t vlan_info; const struct rndis_tcp_ip_csum_info_ *csum_info; const struct rndis_hash_info *hash_info; const struct rndis_hash_value *hash_value; Modified: head/sys/dev/hyperv/netvsc/ndis.h ============================================================================== --- head/sys/dev/hyperv/netvsc/ndis.h Thu Sep 1 06:35:13 2016 (r305178) +++ head/sys/dev/hyperv/netvsc/ndis.h Thu Sep 1 07:04:47 2016 (r305179) @@ -203,4 +203,20 @@ struct ndis_rssprm_toeplitz { uint32_t rss_ind[NDIS_HASH_INDCNT]; }; +/* + * Per-packet-info + */ + +/* VLAN */ +#define NDIS_VLAN_INFO_SIZE sizeof(uint32_t) +#define NDIS_VLAN_INFO_PRI_MASK 0x0007 +#define NDIS_VLAN_INFO_CFI_MASK 0x0008 +#define NDIS_VLAN_INFO_ID_MASK 0xfff0 +#define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ + (((pri) & NVIS_VLAN_INFO_PRI_MASK) | \ + (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) +#define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) +#define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) +#define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK) + #endif /* !_NET_NDIS_H_ */ _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"