Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2011, Microsoft Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *   Haiyang Zhang <haiyangz@microsoft.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   Hank Janssen  <hjanssen@microsoft.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *   K. Y. Srinivasan <kys@microsoft.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #ifndef _HYPERV_VMBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #define _HYPERV_VMBUS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/sync_bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/hyperv-tlfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/hyperv.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "hv_trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * Timeout for services such as KVP and fcopy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define HV_UTIL_TIMEOUT 30
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * Timeout for guest-host handshake for services.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define HV_UTIL_NEGO_TIMEOUT 55
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /* Definitions for the monitored notification facility */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) union hv_monitor_trigger_group {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u64 as_uint64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		u32 pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		u32 armed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct hv_monitor_parameter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	union hv_connection_id connectionid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	u16 flagnumber;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u16 rsvdz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) union hv_monitor_trigger_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	u32 asu32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		u32 group_enable:4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		u32 rsvdz:28;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) /* struct hv_monitor_page Layout */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /* ------------------------------------------------------ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) /* | 0   | TriggerState (4 bytes) | Rsvd1 (4 bytes)     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) /* | 8   | TriggerGroup[0]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /* | 10  | TriggerGroup[1]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) /* | 18  | TriggerGroup[2]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /* | 20  | TriggerGroup[3]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /* | 28  | Rsvd2[0]                                     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* | 30  | Rsvd2[1]                                     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) /* | 38  | Rsvd2[2]                                     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /* | 40  | NextCheckTime[0][0]    | NextCheckTime[0][1] | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) /* | ...                                                | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) /* | 240 | Latency[0][0..3]                             | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /* | 340 | Rsvz3[0]                                     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /* | 440 | Parameter[0][0]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) /* | 448 | Parameter[0][1]                              | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) /* | ...                                                | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /* | 840 | Rsvd4[0]                                     | */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) /* ------------------------------------------------------ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) struct hv_monitor_page {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	union hv_monitor_trigger_state trigger_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u32 rsvdz1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	union hv_monitor_trigger_group trigger_group[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	u64 rsvdz2[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	s32 next_checktime[4][32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	u16 latency[4][32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	u64 rsvdz3[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct hv_monitor_parameter parameter[4][32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	u8 rsvdz4[1984];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) #define HV_HYPERCALL_PARAM_ALIGN	sizeof(u64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* Definition of the hv_post_message hypercall input structure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) struct hv_input_post_message {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	union hv_connection_id connectionid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	u32 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	u32 message_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	u32 payload_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	u64 payload[HV_MESSAGE_PAYLOAD_QWORD_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	VMBUS_MESSAGE_CONNECTION_ID	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	VMBUS_MESSAGE_CONNECTION_ID_4	= 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	VMBUS_MESSAGE_PORT_ID		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	VMBUS_EVENT_CONNECTION_ID	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	VMBUS_EVENT_PORT_ID		= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	VMBUS_MONITOR_CONNECTION_ID	= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	VMBUS_MONITOR_PORT_ID		= 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	VMBUS_MESSAGE_SINT		= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * Per cpu state for channel handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct hv_per_cpu_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	void *synic_message_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	void *synic_event_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	 * buffer to post messages to the host.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	void *post_msg_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 * Starting with win8, we can take channel interrupts on any CPU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	 * we will manage the tasklet that handles events messages on a per CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	 * basis.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	struct tasklet_struct msg_dpc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct hv_context {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	/* We only support running on top of Hyper-V
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 * So at this point this really can only contain the Hyper-V ID
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	u64 guestid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	struct hv_per_cpu_context __percpu *cpu_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	 * To manage allocations in a NUMA node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	 * Array indexed by numa node ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct cpumask *hv_numa_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) extern struct hv_context hv_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* Hv Interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) extern int hv_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) extern int hv_post_message(union hv_connection_id connection_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			 enum hv_message_type message_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 			 void *payload, size_t payload_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) extern int hv_synic_alloc(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) extern void hv_synic_free(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) extern void hv_synic_enable_regs(unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) extern int hv_synic_init(unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) extern void hv_synic_disable_regs(unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) extern int hv_synic_cleanup(unsigned int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /* Interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) void hv_ringbuffer_pre_init(struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		       struct page *pages, u32 pagecnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) void hv_ringbuffer_cleanup(struct hv_ring_buffer_info *ring_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int hv_ringbuffer_write(struct vmbus_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			const struct kvec *kv_list, u32 kv_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) int hv_ringbuffer_read(struct vmbus_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		       void *buffer, u32 buflen, u32 *buffer_actual_len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		       u64 *requestid, bool raw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  * The Maximum number of channels (16348) is determined by the size of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  * interrupt page, which is HV_HYP_PAGE_SIZE. 1/2 of HV_HYP_PAGE_SIZE is to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  * send endpoint interrupts, and the other is to receive endpoint interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #define MAX_NUM_CHANNELS	((HV_HYP_PAGE_SIZE >> 1) << 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /* The value here must be in multiple of 32 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) /* TODO: Need to make this configurable */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define MAX_NUM_CHANNELS_SUPPORTED	256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define MAX_CHANNEL_RELIDS					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	max(MAX_NUM_CHANNELS_SUPPORTED, HV_EVENT_FLAGS_COUNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) enum vmbus_connect_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	DISCONNECTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	CONNECTING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	CONNECTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	DISCONNECTING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #define MAX_SIZE_CHANNEL_MESSAGE	HV_MESSAGE_PAYLOAD_BYTE_COUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * The CPU that Hyper-V will interrupt for VMBUS messages, such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  * CHANNELMSG_OFFERCHANNEL and CHANNELMSG_RESCIND_CHANNELOFFER.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) #define VMBUS_CONNECT_CPU	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct vmbus_connection {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	u32 msg_conn_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	atomic_t offer_in_progress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	enum vmbus_connect_state conn_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	atomic_t next_gpadl_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct completion  unload_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 * Represents channel interrupts. Each bit position represents a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	 * channel.  When a channel sends an interrupt via VMBUS, it finds its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 * bit in the sendInterruptPage, set it and calls Hv to generate a port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	 * event. The other end receives the port event and parse the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	 * recvInterruptPage to see which bit is set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	void *int_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	void *send_int_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	void *recv_int_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	 * 2 pages - 1st page for parent->child notification and 2nd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	 * is child->parent notification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	struct hv_monitor_page *monitor_pages[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	struct list_head chn_msg_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	spinlock_t channelmsg_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	/* List of channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct list_head chn_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	struct mutex channel_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	/* Array of channels */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	struct vmbus_channel **channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	 * An offer message is handled first on the work_queue, and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	 * is further handled on handle_primary_chan_wq or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	 * handle_sub_chan_wq.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct workqueue_struct *work_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	struct workqueue_struct *handle_primary_chan_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct workqueue_struct *handle_sub_chan_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	 * The number of sub-channels and hv_sock channels that should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	 * cleaned up upon suspend: sub-channels will be re-created upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	 * resume, and hv_sock channels should not survive suspend.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	atomic_t nr_chan_close_on_suspend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	 * vmbus_bus_suspend() waits for "nr_chan_close_on_suspend" to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	 * drop to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	struct completion ready_for_suspend_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	 * The number of primary channels that should be "fixed up"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	 * upon resume: these channels are re-offered upon resume, and some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	 * fields of the channel offers (i.e. child_relid and connection_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	 * can change, so the old offermsg must be fixed up, before the resume
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 * callbacks of the VSC drivers start to further touch the channels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	atomic_t nr_chan_fixup_on_resume;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 * vmbus_bus_resume() waits for "nr_chan_fixup_on_resume" to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	 * drop to zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	struct completion ready_for_resume_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct vmbus_msginfo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	/* Bookkeeping stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	struct list_head msglist_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	/* The message itself */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	unsigned char msg[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) extern struct vmbus_connection vmbus_connection;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, u32 version);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static inline void vmbus_send_interrupt(u32 relid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	sync_set_bit(relid, vmbus_connection.send_int_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) enum vmbus_message_handler_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	/* The related handler can sleep. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	VMHT_BLOCKING = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	/* The related handler must NOT sleep. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	VMHT_NON_BLOCKING = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct vmbus_channel_message_table_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	enum vmbus_channel_message_type message_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	enum vmbus_message_handler_type handler_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	void (*message_handler)(struct vmbus_channel_message_header *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	u32 min_payload_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) extern const struct vmbus_channel_message_table_entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	channel_message_table[CHANNELMSG_COUNT];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /* General vmbus interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct hv_device *vmbus_device_create(const guid_t *type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 				      const guid_t *instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 				      struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) int vmbus_device_register(struct hv_device *child_device_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) void vmbus_device_unregister(struct hv_device *device_obj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) int vmbus_add_channel_kobj(struct hv_device *device_obj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			   struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) void vmbus_remove_channel_attr_group(struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) void vmbus_channel_map_relid(struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) void vmbus_channel_unmap_relid(struct vmbus_channel *channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct vmbus_channel *relid2channel(u32 relid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) void vmbus_free_channels(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) /* Connection interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) int vmbus_connect(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) void vmbus_disconnect(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) int vmbus_post_msg(void *buffer, size_t buflen, bool can_sleep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) void vmbus_on_event(unsigned long data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) void vmbus_on_msg_dpc(unsigned long data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) int hv_kvp_init(struct hv_util_service *srv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) void hv_kvp_deinit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) int hv_kvp_pre_suspend(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) int hv_kvp_pre_resume(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) void hv_kvp_onchannelcallback(void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) int hv_vss_init(struct hv_util_service *srv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) void hv_vss_deinit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) int hv_vss_pre_suspend(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) int hv_vss_pre_resume(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) void hv_vss_onchannelcallback(void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) int hv_fcopy_init(struct hv_util_service *srv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) void hv_fcopy_deinit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) int hv_fcopy_pre_suspend(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) int hv_fcopy_pre_resume(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void hv_fcopy_onchannelcallback(void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) void vmbus_initiate_unload(bool crash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) static inline void hv_poll_channel(struct vmbus_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 				   void (*cb)(void *))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	if (!channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	cb(channel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) enum hvutil_device_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	HVUTIL_DEVICE_INIT = 0,  /* driver is loaded, waiting for userspace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	HVUTIL_READY,            /* userspace is registered */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	HVUTIL_HOSTMSG_RECEIVED, /* message from the host was received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	HVUTIL_USERSPACE_REQ,    /* request to userspace was sent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	HVUTIL_USERSPACE_RECV,   /* reply from userspace was received */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	HVUTIL_DEVICE_DYING,     /* driver unload is in progress */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) enum delay {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	INTERRUPT_DELAY = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	MESSAGE_DELAY   = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) extern const struct vmbus_device vmbus_devs[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) static inline bool hv_is_perf_channel(struct vmbus_channel *channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	return vmbus_devs[channel->device_id].perf_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) static inline bool hv_is_alloced_cpu(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	struct vmbus_channel *channel, *sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	lockdep_assert_held(&vmbus_connection.channel_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	 * List additions/deletions as well as updates of the target CPUs are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	 * protected by channel_mutex.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	list_for_each_entry(channel, &vmbus_connection.chn_list, listentry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		if (!hv_is_perf_channel(channel))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		if (channel->target_cpu == cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 			return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		list_for_each_entry(sc, &channel->sc_list, sc_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 			if (sc->target_cpu == cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 				return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static inline void hv_set_alloced_cpu(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	cpumask_set_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static inline void hv_clear_alloced_cpu(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	if (hv_is_alloced_cpu(cpu))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	cpumask_clear_cpu(cpu, &hv_context.hv_numa_map[cpu_to_node(cpu)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) static inline void hv_update_alloced_cpus(unsigned int old_cpu,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 					  unsigned int new_cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	hv_set_alloced_cpu(new_cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	hv_clear_alloced_cpu(old_cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) #ifdef CONFIG_HYPERV_TESTING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) int hv_debug_add_dev_dir(struct hv_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) void hv_debug_rm_dev_dir(struct hv_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) void hv_debug_rm_all_dir(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) int hv_debug_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) void hv_debug_delay_test(struct vmbus_channel *channel, enum delay delay_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) #else /* CONFIG_HYPERV_TESTING */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) static inline void hv_debug_rm_dev_dir(struct hv_device *dev) {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static inline void hv_debug_rm_all_dir(void) {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) static inline void hv_debug_delay_test(struct vmbus_channel *channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 				       enum delay delay_type) {};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static inline int hv_debug_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) static inline int hv_debug_add_dev_dir(struct hv_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) #endif /* CONFIG_HYPERV_TESTING */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) #endif /* _HYPERV_VMBUS_H */