hyperv/vmbus: Save event flag location and evet flag mask.

This avoids unnecessary access to the vmbus_softc struct on sending path.

MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D7257
This commit is contained in:
Sepherosa Ziehau 2016-07-21 05:30:31 +00:00
parent 3a31c31c22
commit f617e011c9
2 changed files with 21 additions and 13 deletions

View file

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <dev/hyperv/vmbus/vmbus_reg.h>
#include <dev/hyperv/vmbus/vmbus_var.h>
static void vmbus_chan_signal_tx(struct hv_vmbus_channel *chan);
static void vmbus_chan_update_evtflagcnt(struct vmbus_softc *,
const struct hv_vmbus_channel *);
@ -77,18 +76,13 @@ vmbus_chan_msgprocs[VMBUS_CHANMSG_TYPE_MAX] = {
VMBUS_CHANMSG_PROC_WAKEUP(GPADL_DISCONNRESP)
};
/**
* @brief Trigger an event notification on the specified channel
/*
* Notify host that there are data pending on our TX bufring.
*/
static void
vmbus_chan_signal_tx(struct hv_vmbus_channel *chan)
static __inline void
vmbus_chan_signal_tx(const struct hv_vmbus_channel *chan)
{
struct vmbus_softc *sc = chan->ch_vmbus;
uint32_t chanid = chan->ch_id;
atomic_set_long(&sc->vmbus_tx_evtflags[chanid >> VMBUS_EVTFLAG_SHIFT],
1UL << (chanid & VMBUS_EVTFLAG_MASK));
atomic_set_long(chan->ch_evtflag, chan->ch_evtflag_mask);
if (chan->ch_flags & VMBUS_CHAN_FLAG_HASMNF)
atomic_set_int(chan->ch_montrig, chan->ch_montrig_mask);
else
@ -1120,6 +1114,13 @@ vmbus_chan_msgproc_choffer(struct vmbus_softc *sc,
1 << (offer->chm_montrig % VMBUS_MONTRIG_LEN);
}
/*
* Setup event flag.
*/
chan->ch_evtflag =
&sc->vmbus_tx_evtflags[chan->ch_id >> VMBUS_EVTFLAG_SHIFT];
chan->ch_evtflag_mask = 1UL << (chan->ch_id & VMBUS_EVTFLAG_MASK);
/* Select default cpu for this channel. */
vmbus_chan_cpu_default(chan);

View file

@ -77,12 +77,19 @@ typedef struct hv_vmbus_channel {
uint32_t ch_id; /* channel id */
/*
* These are based on the offer_msg.monitor_id.
* These are based on the vmbus_chanmsg_choffer.chm_montrig.
* Save it here for easy access.
*/
volatile uint32_t *ch_montrig; /* MNF trigger */
volatile uint32_t *ch_montrig; /* MNF trigger loc. */
uint32_t ch_montrig_mask;/* MNF trig mask */
/*
* These are based on the vmbus_chanmsg_choffer.chm_chanid.
* Save it here for easy access.
*/
volatile u_long *ch_evtflag; /* event flag loc. */
u_long ch_evtflag_mask;/* event flag */
/*
* TX bufring; at the beginning of ch_bufring.
*/