hyperv/hn: Set hash per-packet-info for each packet transmission

So that the host could dispatch the TX done back to this TX ring's
owner channel

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5498
This commit is contained in:
Sepherosa Ziehau 2016-03-01 04:59:18 +00:00
parent a49d0aa92a
commit 4663ccd32e
3 changed files with 25 additions and 0 deletions

View File

@ -1039,6 +1039,7 @@ struct hn_tx_ring {
struct buf_ring *hn_mbuf_br;
int hn_oactive;
int hn_tx_idx;
struct mtx hn_tx_lock;
struct hn_softc *hn_sc;

View File

@ -138,6 +138,7 @@ __FBSDID("$FreeBSD$");
#define HN_RNDIS_MSG_LEN \
(sizeof(rndis_msg) + \
RNDIS_HASH_PPI_SIZE + \
RNDIS_VLAN_PPI_SIZE + \
RNDIS_TSO_PPI_SIZE + \
RNDIS_CSUM_PPI_SIZE)
@ -737,6 +738,7 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0)
rndis_msg *rndis_mesg;
rndis_packet *rndis_pkt;
rndis_per_packet_info *rppi;
struct ndis_hash_info *hash_info;
uint32_t rndis_msg_size;
packet = &txd->netvsc_pkt;
@ -761,6 +763,18 @@ hn_encap(struct hn_tx_ring *txr, struct hn_txdesc *txd, struct mbuf **m_head0)
rndis_msg_size = RNDIS_MESSAGE_SIZE(rndis_packet);
/*
* Set the hash info for this packet, so that the host could
* dispatch the TX done event for this packet back to this TX
* ring's channel.
*/
rndis_msg_size += RNDIS_HASH_PPI_SIZE;
rppi = hv_set_rppi_data(rndis_mesg, RNDIS_HASH_PPI_SIZE,
nbl_hash_value);
hash_info = (struct ndis_hash_info *)((uint8_t *)rppi +
rppi->per_packet_info_offset);
hash_info->hash = txr->hn_tx_idx;
if (m_head->m_flags & M_VLANTAG) {
ndis_8021q_info *rppi_vlan_info;
@ -2148,6 +2162,7 @@ hn_create_tx_ring(struct hn_softc *sc, int id)
int error, i;
txr->hn_sc = sc;
txr->hn_tx_idx = id;
#ifndef HN_USE_TXDESC_BUFRING
mtx_init(&txr->hn_txlist_spin, "hn txlist", NULL, MTX_SPIN);

View File

@ -608,6 +608,8 @@ typedef enum ndis_per_pkt_infotype_ {
max_perpkt_info
} ndis_per_pkt_infotype;
#define nbl_hash_value pkt_cancel_id
typedef struct ndis_8021q_info_ {
union {
struct {
@ -620,6 +622,10 @@ typedef struct ndis_8021q_info_ {
} u1;
} ndis_8021q_info;
struct ndis_hash_info {
uint32_t hash;
} __packed;
struct rndis_object_header {
uint8_t type;
uint8_t revision;
@ -713,6 +719,9 @@ typedef struct rndis_tcp_tso_info_ {
};
} rndis_tcp_tso_info;
#define RNDIS_HASH_PPI_SIZE (sizeof(rndis_per_packet_info) + \
sizeof(struct ndis_hash_info))
#define RNDIS_VLAN_PPI_SIZE (sizeof(rndis_per_packet_info) + \
sizeof(ndis_8021q_info))