linux/drivers/gpu/drm/xe/xe_gt_sriov_vf.c

// SPDX-License-Identifier: MIT
/*
 * Copyright © 2023-2024 Intel Corporation
 */

#include <linux/bitfield.h>
#include <linux/bsearch.h>

#include <drm/drm_managed.h>
#include <drm/drm_print.h>

#include "abi/guc_actions_sriov_abi.h"
#include "abi/guc_communication_mmio_abi.h"
#include "abi/guc_klvs_abi.h"
#include "abi/guc_relay_actions_abi.h"
#include "regs/xe_gt_regs.h"
#include "regs/xe_gtt_defs.h"

#include "xe_assert.h"
#include "xe_device.h"
#include "xe_ggtt.h"
#include "xe_gt_sriov_printk.h"
#include "xe_gt_sriov_vf.h"
#include "xe_gt_sriov_vf_types.h"
#include "xe_guc.h"
#include "xe_guc_hxg_helpers.h"
#include "xe_guc_relay.h"
#include "xe_mmio.h"
#include "xe_sriov.h"
#include "xe_uc_fw.h"
#include "xe_wopcm.h"

#define make_u64_from_u32(hi, lo)

static int guc_action_vf_reset(struct xe_guc *guc)
{}

static int vf_reset_guc_state(struct xe_gt *gt)
{}

static int guc_action_match_version(struct xe_guc *guc,
				    u32 wanted_branch, u32 wanted_major, u32 wanted_minor,
				    u32 *branch, u32 *major, u32 *minor, u32 *patch)
{}

static void vf_minimum_guc_version(struct xe_gt *gt, u32 *branch, u32 *major, u32 *minor)
{}

static void vf_wanted_guc_version(struct xe_gt *gt, u32 *branch, u32 *major, u32 *minor)
{}

static int vf_handshake_with_guc(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_bootstrap - Query and setup GuC ABI interface version.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 * It requires functional `GuC MMIO based communication`_.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int xe_gt_sriov_vf_bootstrap(struct xe_gt *gt)
{}

static int guc_action_query_single_klv(struct xe_guc *guc, u32 key,
				       u32 *value, u32 value_len)
{}

static int guc_action_query_single_klv32(struct xe_guc *guc, u32 key, u32 *value32)
{}

static int guc_action_query_single_klv64(struct xe_guc *guc, u32 key, u64 *value64)
{}

static bool has_gmdid(struct xe_device *xe)
{}

/**
 * xe_gt_sriov_vf_gmdid - Query GMDID over MMIO.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: value of GMDID KLV on success or 0 on failure.
 */
u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt)
{}

static int vf_get_ggtt_info(struct xe_gt *gt)
{}

static int vf_get_lmem_info(struct xe_gt *gt)
{}

static int vf_get_submission_cfg(struct xe_gt *gt)
{}

static void vf_cache_gmdid(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_query_config - Query SR-IOV config data over MMIO.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int xe_gt_sriov_vf_query_config(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_guc_ids - VF GuC context IDs configuration.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: number of GuC context IDs assigned to VF.
 */
u16 xe_gt_sriov_vf_guc_ids(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_lmem - VF LMEM configuration.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: size of the LMEM assigned to VF.
 */
u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt)
{}

static int vf_balloon_ggtt(struct xe_gt *gt)
{}

static void deballoon_ggtt(struct drm_device *drm, void *arg)
{}

/**
 * xe_gt_sriov_vf_prepare_ggtt - Prepare a VF's GGTT configuration.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int xe_gt_sriov_vf_prepare_ggtt(struct xe_gt *gt)
{}

static int relay_action_handshake(struct xe_gt *gt, u32 *major, u32 *minor)
{}

static void vf_connect_pf(struct xe_gt *gt, u16 major, u16 minor)
{}

static void vf_disconnect_pf(struct xe_gt *gt)
{}

static int vf_handshake_with_pf(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_connect - Establish connection with the PF driver.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int xe_gt_sriov_vf_connect(struct xe_gt *gt)
{}

static bool vf_is_negotiated(struct xe_gt *gt, u16 major, u16 minor)
{}

static int vf_prepare_runtime_info(struct xe_gt *gt, unsigned int num_regs)
{}

static int vf_query_runtime_info(struct xe_gt *gt)
{}

static void vf_show_runtime_info(struct xe_gt *gt)
{}

/**
 * xe_gt_sriov_vf_query_runtime - Query SR-IOV runtime data.
 * @gt: the &xe_gt
 *
 * This function is for VF use only.
 *
 * Return: 0 on success or a negative error code on failure.
 */
int xe_gt_sriov_vf_query_runtime(struct xe_gt *gt)
{}

static int vf_runtime_reg_cmp(const void *a, const void *b)
{}

static struct vf_runtime_reg *vf_lookup_reg(struct xe_gt *gt, u32 addr)
{}

/**
 * xe_gt_sriov_vf_read32 - Get a register value from the runtime data.
 * @gt: the &xe_gt
 * @reg: the register to read
 *
 * This function is for VF use only.
 * This function shall be called after VF has connected to PF.
 * This function is dedicated for registers that VFs can't read directly.
 *
 * Return: register value obtained from the PF or 0 if not found.
 */
u32 xe_gt_sriov_vf_read32(struct xe_gt *gt, struct xe_reg reg)
{}

/**
 * xe_gt_sriov_vf_print_config - Print VF self config.
 * @gt: the &xe_gt
 * @p: the &drm_printer
 *
 * This function is for VF use only.
 */
void xe_gt_sriov_vf_print_config(struct xe_gt *gt, struct drm_printer *p)
{}

/**
 * xe_gt_sriov_vf_print_runtime - Print VF's runtime regs received from PF.
 * @gt: the &xe_gt
 * @p: the &drm_printer
 *
 * This function is for VF use only.
 */
void xe_gt_sriov_vf_print_runtime(struct xe_gt *gt, struct drm_printer *p)
{}

/**
 * xe_gt_sriov_vf_print_version - Print VF ABI versions.
 * @gt: the &xe_gt
 * @p: the &drm_printer
 *
 * This function is for VF use only.
 */
void xe_gt_sriov_vf_print_version(struct xe_gt *gt, struct drm_printer *p)
{}