#!/bin/bash
#
# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.
#
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES.
# SPDX-License-Identifier: LicenseRef-NVIDIA-Proprietary
#
# emulation-manager-wrapper — real hardware placeholder
#
# The production implementation must resolve pci/<manager-BDF>,pf<N> to the
# satellite PF VHCA ID, then perform HCA_CAP SET plus QUERY readback for:
#   - virtio_net_device_emulation_manager
#   - nvme_device_emulation_manager
#
# That target resolution and public real HCA_CAP backend are not available in
# this POC. Do not replace this with debugfs or guessed mlxreg paths.

source "$(dirname "$0")/_lib.sh"
trace "$@"

OP="$1"; shift
TARGET="$1"; shift

require_pf_target() {
    case "$TARGET" in
        pci/*,pf*) ;;
        *)
            echo "Error: emulation manager requires delegated PF target pci/<BDF>,pf<N>, got '$TARGET'" >&2
            exit 2
            ;;
    esac

    local suffix="${TARGET#*,}"
    suffix="${suffix#pf}"
    case "$suffix" in
        ''|*[!0-9]*)
            echo "Error: emulation manager target must be PF-only pci/<BDF>,pf<N>, got '$TARGET'" >&2
            exit 2
            ;;
    esac
}

case "$OP" in
    GET|SET) ;;
    *)
        echo "Error: unsupported operation '$OP'" >&2
        exit 2
        ;;
esac

require_pf_target

echo "Error: typed emulation manager real backend unsupported: satellite PF/vhca_id resolution and public HCA_CAP set/query backend are not available" >&2
exit 6
