linux/drivers/hv/hv_util.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2010, Microsoft Corporation.
 *
 * Authors:
 *   Haiyang Zhang <[email protected]>
 *   Hank Janssen  <[email protected]>
 */
#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sysctl.h>
#include <linux/reboot.h>
#include <linux/hyperv.h>
#include <linux/clockchips.h>
#include <linux/ptp_clock_kernel.h>
#include <asm/mshyperv.h>

#include "hyperv_vmbus.h"

#define SD_MAJOR
#define SD_MINOR
#define SD_MINOR_1
#define SD_MINOR_2
#define SD_VERSION_3_1
#define SD_VERSION_3_2
#define SD_VERSION

#define SD_MAJOR_1
#define SD_VERSION_1

#define TS_MAJOR
#define TS_MINOR
#define TS_VERSION

#define TS_MAJOR_1
#define TS_VERSION_1

#define TS_MAJOR_3
#define TS_VERSION_3

#define HB_MAJOR
#define HB_MINOR
#define HB_VERSION

#define HB_MAJOR_1
#define HB_VERSION_1

static int sd_srv_version;
static int ts_srv_version;
static int hb_srv_version;

#define SD_VER_COUNT
static const int sd_versions[] =;

#define TS_VER_COUNT
static const int ts_versions[] =;

#define HB_VER_COUNT
static const int hb_versions[] =;

#define FW_VER_COUNT
static const int fw_versions[] =;

/*
 * Send the "hibernate" udev event in a thread context.
 */
struct hibernate_work_context {};

static struct hibernate_work_context hibernate_context;
static bool hibernation_supported;

static void send_hibernate_uevent(struct work_struct *work)
{}

static int hv_shutdown_init(struct hv_util_service *srv)
{}

static void shutdown_onchannelcallback(void *context);
static struct hv_util_service util_shutdown =;

static int hv_timesync_init(struct hv_util_service *srv);
static int hv_timesync_pre_suspend(void);
static void hv_timesync_deinit(void);

static void timesync_onchannelcallback(void *context);
static struct hv_util_service util_timesynch =;

static void heartbeat_onchannelcallback(void *context);
static struct hv_util_service util_heartbeat =;

static struct hv_util_service util_kvp =;

static struct hv_util_service util_vss =;

static void perform_shutdown(struct work_struct *dummy)
{}

static void perform_restart(struct work_struct *dummy)
{}

/*
 * Perform the shutdown operation in a thread context.
 */
static DECLARE_WORK(shutdown_work, perform_shutdown);

/*
 * Perform the restart operation in a thread context.
 */
static DECLARE_WORK(restart_work, perform_restart);

static void shutdown_onchannelcallback(void *context)
{}

/*
 * Set the host time in a process context.
 */
static struct work_struct adj_time_work;

/*
 * The last time sample, received from the host. PTP device responds to
 * requests by using this data and the current partition-wide time reference
 * count.
 */
static struct {} host_ts;

static bool timesync_implicit;

module_param(timesync_implicit, bool, 0644);
MODULE_PARM_DESC();

static inline u64 reftime_to_ns(u64 reftime)
{}

/*
 * Hard coded threshold for host timesync delay: 600 seconds
 */
static const u64 HOST_TIMESYNC_DELAY_THRESH =;

static int hv_get_adj_host_time(struct timespec64 *ts)
{}

static void hv_set_host_time(struct work_struct *work)
{}

/*
 * Due to a bug on Hyper-V hosts, the sync flag may not always be sent on resume.
 * Force a sync if the guest is behind.
 */
static inline bool hv_implicit_sync(u64 host_time)
{}

/*
 * Synchronize time with host after reboot, restore, etc.
 *
 * ICTIMESYNCFLAG_SYNC flag bit indicates reboot, restore events of the VM.
 * After reboot the flag ICTIMESYNCFLAG_SYNC is included in the first time
 * message after the timesync channel is opened. Since the hv_utils module is
 * loaded after hv_vmbus, the first message is usually missed. This bit is
 * considered a hard request to discipline the clock.
 *
 * ICTIMESYNCFLAG_SAMPLE bit indicates a time sample from host. This is
 * typically used as a hint to the guest. The guest is under no obligation
 * to discipline the clock.
 */
static inline void adj_guesttime(u64 hosttime, u64 reftime, u8 adj_flags)
{}

/*
 * Time Sync Channel message handler.
 */
static void timesync_onchannelcallback(void *context)
{}

/*
 * Heartbeat functionality.
 * Every two seconds, Hyper-V send us a heartbeat request message.
 * we respond to this message, and Hyper-V knows we are alive.
 */
static void heartbeat_onchannelcallback(void *context)
{}

#define HV_UTIL_RING_SEND_SIZE
#define HV_UTIL_RING_RECV_SIZE

static int util_probe(struct hv_device *dev,
			const struct hv_vmbus_device_id *dev_id)
{}

static void util_remove(struct hv_device *dev)
{}

/*
 * When we're in util_suspend(), all the userspace processes have been frozen
 * (refer to hibernate() -> freeze_processes()). The userspace is thawed only
 * after the whole resume procedure, including util_resume(), finishes.
 */
static int util_suspend(struct hv_device *dev)
{}

static int util_resume(struct hv_device *dev)
{}

static const struct hv_vmbus_device_id id_table[] =;

MODULE_DEVICE_TABLE(vmbus, id_table);

/* The one and only one */
static  struct hv_driver util_drv =;

static int hv_ptp_enable(struct ptp_clock_info *info,
			 struct ptp_clock_request *request, int on)
{}

static int hv_ptp_settime(struct ptp_clock_info *p, const struct timespec64 *ts)
{}

static int hv_ptp_adjfine(struct ptp_clock_info *ptp, long delta)
{}
static int hv_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
{}

static int hv_ptp_gettime(struct ptp_clock_info *info, struct timespec64 *ts)
{}

static struct ptp_clock_info ptp_hyperv_info =;

static struct ptp_clock *hv_ptp_clock;

static int hv_timesync_init(struct hv_util_service *srv)
{}

static void hv_timesync_cancel_work(void)
{}

static int hv_timesync_pre_suspend(void)
{}

static void hv_timesync_deinit(void)
{}

static int __init init_hyperv_utils(void)
{}

static void exit_hyperv_utils(void)
{}

module_init();
module_exit(exit_hyperv_utils);

MODULE_DESCRIPTION();
MODULE_LICENSE();