vmbus.c (300834) | vmbus.c (300988) |
---|---|
1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * VM Bus Driver Implementation 31 */ 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009-2012,2016 Microsoft Corp. 3 * Copyright (c) 2012 NetApp Inc. 4 * Copyright (c) 2012 Citrix Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29/* 30 * VM Bus Driver Implementation 31 */ 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c 300834 2016-05-27 07:29:31Z sephe $"); | 33__FBSDID("$FreeBSD: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c 300988 2016-05-30 08:42:35Z sephe $"); |
34 35#include <sys/param.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/malloc.h> 40#include <sys/module.h> 41#include <sys/proc.h> --- 33 unchanged lines hidden (view full) --- 75extern inthand_t IDTVEC(hv_vmbus_callback); 76 77static void 78vmbus_msg_task(void *xsc, int pending __unused) 79{ 80 struct vmbus_softc *sc = xsc; 81 hv_vmbus_message *msg; 82 | 34 35#include <sys/param.h> 36#include <sys/bus.h> 37#include <sys/kernel.h> 38#include <sys/lock.h> 39#include <sys/malloc.h> 40#include <sys/module.h> 41#include <sys/proc.h> --- 33 unchanged lines hidden (view full) --- 75extern inthand_t IDTVEC(hv_vmbus_callback); 76 77static void 78vmbus_msg_task(void *xsc, int pending __unused) 79{ 80 struct vmbus_softc *sc = xsc; 81 hv_vmbus_message *msg; 82 |
83 msg = VMBUS_PCPU_GET(sc, message, curcpu) + HV_VMBUS_MESSAGE_SINT; | 83 msg = VMBUS_PCPU_GET(sc, message, curcpu) + VMBUS_SINT_MESSAGE; |
84 for (;;) { 85 const hv_vmbus_channel_msg_table_entry *entry; 86 hv_vmbus_channel_msg_header *hdr; 87 hv_vmbus_channel_msg_type msg_type; 88 89 if (msg->header.message_type == HV_MESSAGE_TYPE_NONE) 90 break; /* no message */ 91 --- 47 unchanged lines hidden (view full) --- 139 * The Windows team has advised that we check for events 140 * before checking for messages. This is the way they do it 141 * in Windows when running as a guest in Hyper-V 142 */ 143 sc->vmbus_event_proc(sc, cpu); 144 145 /* Check if there are actual msgs to be process */ 146 msg_base = VMBUS_PCPU_GET(sc, message, cpu); | 84 for (;;) { 85 const hv_vmbus_channel_msg_table_entry *entry; 86 hv_vmbus_channel_msg_header *hdr; 87 hv_vmbus_channel_msg_type msg_type; 88 89 if (msg->header.message_type == HV_MESSAGE_TYPE_NONE) 90 break; /* no message */ 91 --- 47 unchanged lines hidden (view full) --- 139 * The Windows team has advised that we check for events 140 * before checking for messages. This is the way they do it 141 * in Windows when running as a guest in Hyper-V 142 */ 143 sc->vmbus_event_proc(sc, cpu); 144 145 /* Check if there are actual msgs to be process */ 146 msg_base = VMBUS_PCPU_GET(sc, message, cpu); |
147 msg = msg_base + HV_VMBUS_TIMER_SINT; | |
148 149 /* we call eventtimer process the message */ | 147 148 /* we call eventtimer process the message */ |
149 msg = msg_base + VMBUS_SINT_TIMER; |
|
150 if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) { 151 msg->header.message_type = HV_MESSAGE_TYPE_NONE; 152 153 /* call intrrupt handler of event timer */ | 150 if (msg->header.message_type == HV_MESSAGE_TIMER_EXPIRED) { 151 msg->header.message_type = HV_MESSAGE_TYPE_NONE; 152 153 /* call intrrupt handler of event timer */ |
154 hv_et_intr(frame); | 154 vmbus_et_intr(frame); |
155 156 /* 157 * Make sure the write to message_type (ie set to 158 * HV_MESSAGE_TYPE_NONE) happens before we read the 159 * message_pending and EOMing. Otherwise, the EOMing will 160 * not deliver any more messages 161 * since there is no empty slot 162 * --- 7 unchanged lines hidden (view full) --- 170 /* 171 * This will cause message queue rescan to possibly 172 * deliver another msg from the hypervisor 173 */ 174 wrmsr(MSR_HV_EOM, 0); 175 } 176 } 177 | 155 156 /* 157 * Make sure the write to message_type (ie set to 158 * HV_MESSAGE_TYPE_NONE) happens before we read the 159 * message_pending and EOMing. Otherwise, the EOMing will 160 * not deliver any more messages 161 * since there is no empty slot 162 * --- 7 unchanged lines hidden (view full) --- 170 /* 171 * This will cause message queue rescan to possibly 172 * deliver another msg from the hypervisor 173 */ 174 wrmsr(MSR_HV_EOM, 0); 175 } 176 } 177 |
178 msg = msg_base + HV_VMBUS_MESSAGE_SINT; | 178 msg = msg_base + VMBUS_SINT_MESSAGE; |
179 if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) { 180 taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu), 181 VMBUS_PCPU_PTR(sc, message_task, cpu)); 182 } 183 184 return (FILTER_HANDLED); 185} 186 --- 62 unchanged lines hidden (view full) --- 249 ((VMBUS_PCPU_GET(sc, event_flag_dma.hv_paddr, cpu) >> PAGE_SHIFT) << 250 MSR_HV_SIEFP_PGSHIFT); 251 wrmsr(MSR_HV_SIEFP, val); 252 253 254 /* 255 * Configure and unmask SINT for message and event flags. 256 */ | 179 if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) { 180 taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu), 181 VMBUS_PCPU_PTR(sc, message_task, cpu)); 182 } 183 184 return (FILTER_HANDLED); 185} 186 --- 62 unchanged lines hidden (view full) --- 249 ((VMBUS_PCPU_GET(sc, event_flag_dma.hv_paddr, cpu) >> PAGE_SHIFT) << 250 MSR_HV_SIEFP_PGSHIFT); 251 wrmsr(MSR_HV_SIEFP, val); 252 253 254 /* 255 * Configure and unmask SINT for message and event flags. 256 */ |
257 sint = MSR_HV_SINT0 + HV_VMBUS_MESSAGE_SINT; | 257 sint = MSR_HV_SINT0 + VMBUS_SINT_MESSAGE; |
258 orig = rdmsr(sint); 259 val = sc->vmbus_idtvec | MSR_HV_SINT_AUTOEOI | 260 (orig & MSR_HV_SINT_RSVD_MASK); 261 wrmsr(sint, val); 262 263 /* 264 * Configure and unmask SINT for timer. 265 */ | 258 orig = rdmsr(sint); 259 val = sc->vmbus_idtvec | MSR_HV_SINT_AUTOEOI | 260 (orig & MSR_HV_SINT_RSVD_MASK); 261 wrmsr(sint, val); 262 263 /* 264 * Configure and unmask SINT for timer. 265 */ |
266 sint = MSR_HV_SINT0 + HV_VMBUS_TIMER_SINT; | 266 sint = MSR_HV_SINT0 + VMBUS_SINT_TIMER; |
267 orig = rdmsr(sint); 268 val = sc->vmbus_idtvec | MSR_HV_SINT_AUTOEOI | 269 (orig & MSR_HV_SINT_RSVD_MASK); 270 wrmsr(sint, val); 271 272 /* 273 * All done; enable SynIC. 274 */ --- 12 unchanged lines hidden (view full) --- 287 * Disable SynIC. 288 */ 289 orig = rdmsr(MSR_HV_SCONTROL); 290 wrmsr(MSR_HV_SCONTROL, (orig & MSR_HV_SCTRL_RSVD_MASK)); 291 292 /* 293 * Mask message and event flags SINT. 294 */ | 267 orig = rdmsr(sint); 268 val = sc->vmbus_idtvec | MSR_HV_SINT_AUTOEOI | 269 (orig & MSR_HV_SINT_RSVD_MASK); 270 wrmsr(sint, val); 271 272 /* 273 * All done; enable SynIC. 274 */ --- 12 unchanged lines hidden (view full) --- 287 * Disable SynIC. 288 */ 289 orig = rdmsr(MSR_HV_SCONTROL); 290 wrmsr(MSR_HV_SCONTROL, (orig & MSR_HV_SCTRL_RSVD_MASK)); 291 292 /* 293 * Mask message and event flags SINT. 294 */ |
295 sint = MSR_HV_SINT0 + HV_VMBUS_MESSAGE_SINT; | 295 sint = MSR_HV_SINT0 + VMBUS_SINT_MESSAGE; |
296 orig = rdmsr(sint); 297 wrmsr(sint, orig | MSR_HV_SINT_MASKED); 298 299 /* 300 * Mask timer SINT. 301 */ | 296 orig = rdmsr(sint); 297 wrmsr(sint, orig | MSR_HV_SINT_MASKED); 298 299 /* 300 * Mask timer SINT. 301 */ |
302 sint = MSR_HV_SINT0 + HV_VMBUS_TIMER_SINT; | 302 sint = MSR_HV_SINT0 + VMBUS_SINT_TIMER; |
303 orig = rdmsr(sint); 304 wrmsr(sint, orig | MSR_HV_SINT_MASKED); 305 306 /* 307 * Teardown SynIC message. 308 */ 309 orig = rdmsr(MSR_HV_SIMP); 310 wrmsr(MSR_HV_SIMP, (orig & MSR_HV_SIMP_RSVD_MASK)); --- 453 unchanged lines hidden --- | 303 orig = rdmsr(sint); 304 wrmsr(sint, orig | MSR_HV_SINT_MASKED); 305 306 /* 307 * Teardown SynIC message. 308 */ 309 orig = rdmsr(MSR_HV_SIMP); 310 wrmsr(MSR_HV_SIMP, (orig & MSR_HV_SIMP_RSVD_MASK)); --- 453 unchanged lines hidden --- |