/**
 * Describes functions for converting CXL protocol error CPER sections from binary and JSON format
 * into an intermediate format.
 *
 * Author: Lawrence.Tang@arm.com
 **/
#include <stdio.h>
#include <string.h>
#include "base64.h"
#include "Cper.h"
#include "../cper-utils.h"
#include "cper-section-cxl-protocol.h"

//Converts a single CXL protocol error CPER section into JSON IR.
json_object *cper_section_cxl_protocol_to_ir(void *section)
{
	EFI_CXL_PROTOCOL_ERROR_DATA *cxl_protocol_error =
		(EFI_CXL_PROTOCOL_ERROR_DATA *)section;
	json_object *section_ir = json_object_new_object();

	//Validation bits.
	json_object *validation =
		bitfield_to_ir(cxl_protocol_error->ValidBits, 7,
			       CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES);
	json_object_object_add(section_ir, "validationBits", validation);

	//Type of detecting agent.
	json_object *agent_type = integer_to_readable_pair(
		cxl_protocol_error->CxlAgentType, 2,
		CXL_PROTOCOL_ERROR_AGENT_TYPES_KEYS,
		CXL_PROTOCOL_ERROR_AGENT_TYPES_VALUES, "Unknown (Reserved)");
	json_object_object_add(section_ir, "agentType", agent_type);

	//CXL agent address, depending on the agent type.
	json_object *agent_address = json_object_new_object();
	if (cxl_protocol_error->CxlAgentType ==
	    CXL_PROTOCOL_ERROR_DEVICE_AGENT) {
		//Address is a CXL1.1 device agent.
		json_object_object_add(
			agent_address, "functionNumber",
			json_object_new_uint64(
				cxl_protocol_error->CxlAgentAddress
					.DeviceAddress.FunctionNumber));
		json_object_object_add(
			agent_address, "deviceNumber",
			json_object_new_uint64(
				cxl_protocol_error->CxlAgentAddress
					.DeviceAddress.DeviceNumber));
		json_object_object_add(
			agent_address, "busNumber",
			json_object_new_uint64(
				cxl_protocol_error->CxlAgentAddress
					.DeviceAddress.BusNumber));
		json_object_object_add(
			agent_address, "segmentNumber",
			json_object_new_uint64(
				cxl_protocol_error->CxlAgentAddress
					.DeviceAddress.SegmentNumber));
	} else if (cxl_protocol_error->CxlAgentType ==
		   CXL_PROTOCOL_ERROR_HOST_DOWNSTREAM_PORT_AGENT) {
		//Address is a CXL port RCRB base address.
		json_object_object_add(
			agent_address, "value",
			json_object_new_uint64(
				cxl_protocol_error->CxlAgentAddress
					.PortRcrbBaseAddress));
	}
	json_object_object_add(section_ir, "cxlAgentAddress", agent_address);

	//Device ID.
	json_object *device_id = json_object_new_object();
	json_object_object_add(
		device_id, "vendorID",
		json_object_new_uint64(cxl_protocol_error->DeviceId.VendorId));
	json_object_object_add(
		device_id, "deviceID",
		json_object_new_uint64(cxl_protocol_error->DeviceId.DeviceId));
	json_object_object_add(
		device_id, "subsystemVendorID",
		json_object_new_uint64(
			cxl_protocol_error->DeviceId.SubsystemVendorId));
	json_object_object_add(
		device_id, "subsystemDeviceID",
		json_object_new_uint64(
			cxl_protocol_error->DeviceId.SubsystemDeviceId));
	json_object_object_add(
		device_id, "classCode",
		json_object_new_uint64(cxl_protocol_error->DeviceId.ClassCode));
	json_object_object_add(
		device_id, "slotNumber",
		json_object_new_uint64(
			cxl_protocol_error->DeviceId.SlotNumber));
	json_object_object_add(section_ir, "deviceID", device_id);

	char *encoded;
	//Device serial & capability structure (if CXL 1.1 device).
	if (cxl_protocol_error->CxlAgentType ==
	    CXL_PROTOCOL_ERROR_DEVICE_AGENT) {
		json_object_object_add(
			section_ir, "deviceSerial",
			json_object_new_uint64(
				cxl_protocol_error->DeviceSerial));

		//The PCIe capability structure provided here could either be PCIe 1.1 Capability Structure
		//(36-byte, padded to 60 bytes) or PCIe 2.0 Capability Structure (60-byte). There does not seem
		//to be a way to differentiate these, so this is left as a b64 dump.

		int32_t encoded_len = 0;

		encoded = base64_encode(
			(UINT8 *)cxl_protocol_error->CapabilityStructure.PcieCap,
			60, &encoded_len);
		if (encoded == NULL) {
			printf("Failed to allocate encode output buffer. \n");
			return NULL;
		}
		json_object_object_add(section_ir, "capabilityStructure",
				       json_object_new_string_len(encoded,
								  encoded_len));
		free(encoded);
	}

	//CXL DVSEC & error log length.
	json_object_object_add(
		section_ir, "dvsecLength",
		json_object_new_int(cxl_protocol_error->CxlDvsecLength));
	json_object_object_add(
		section_ir, "errorLogLength",
		json_object_new_int(cxl_protocol_error->CxlErrorLogLength));

	//CXL DVSEC
	//For CXL 1.1 devices, this is the "CXL DVSEC For Flex Bus Device" structure as in CXL 1.1 spec.
	//For CXL 1.1 host downstream ports, this is the "CXL DVSEC For Flex Bus Port" structure as in CXL 1.1 spec.
	const char *cur_pos = (const char *)(cxl_protocol_error + 1);
	int32_t encoded_len = 0;

	encoded = base64_encode((UINT8 *)cur_pos,
				cxl_protocol_error->CxlDvsecLength,
				&encoded_len);
	if (encoded == NULL) {
		return NULL;
	}
	json_object_object_add(section_ir, "cxlDVSEC",
			       json_object_new_string_len(encoded,
							  encoded_len));

	free(encoded);

	cur_pos += cxl_protocol_error->CxlDvsecLength;

	//CXL Error Log
	//This is the "CXL RAS Capability Structure" as in CXL 1.1 spec.

	encoded_len = 0;
	encoded = base64_encode((UINT8 *)cur_pos,
				cxl_protocol_error->CxlErrorLogLength,
				&encoded_len);

	if (encoded == NULL) {
		printf("Failed to allocate encode output buffer. \n");
		return NULL;
	}
	json_object_object_add(section_ir, "cxlErrorLog",
			       json_object_new_string_len(encoded,
							  encoded_len));
	free(encoded);

	return section_ir;
}

//Converts a single CXL protocol CPER-JSON section into CPER binary, outputting to the given stream.
void ir_section_cxl_protocol_to_cper(json_object *section, FILE *out)
{
	EFI_CXL_PROTOCOL_ERROR_DATA *section_cper =
		(EFI_CXL_PROTOCOL_ERROR_DATA *)calloc(
			1, sizeof(EFI_CXL_PROTOCOL_ERROR_DATA));

	//Validation bits.
	section_cper->ValidBits = ir_to_bitfield(
		json_object_object_get(section, "validationBits"), 7,
		CXL_PROTOCOL_ERROR_VALID_BITFIELD_NAMES);

	//Detecting agent type.
	section_cper->CxlAgentType = readable_pair_to_integer(
		json_object_object_get(section, "agentType"));

	//Based on the agent type, set the address.
	json_object *address =
		json_object_object_get(section, "cxlAgentAddress");
	if (section_cper->CxlAgentType == CXL_PROTOCOL_ERROR_DEVICE_AGENT) {
		//Address is split by function, device, bus & segment.
		UINT64 function = json_object_get_uint64(
			json_object_object_get(address, "functionNumber"));
		UINT64 device = json_object_get_uint64(
			json_object_object_get(address, "deviceNumber"));
		UINT64 bus = json_object_get_uint64(
			json_object_object_get(address, "busNumber"));
		UINT64 segment = json_object_get_uint64(
			json_object_object_get(address, "segmentNumber"));
		section_cper->CxlAgentAddress.DeviceAddress.FunctionNumber =
			function;
		section_cper->CxlAgentAddress.DeviceAddress.DeviceNumber =
			device;
		section_cper->CxlAgentAddress.DeviceAddress.BusNumber = bus;
		section_cper->CxlAgentAddress.DeviceAddress.SegmentNumber =
			segment;
	} else if (section_cper->CxlAgentType ==
		   CXL_PROTOCOL_ERROR_HOST_DOWNSTREAM_PORT_AGENT) {
		//Plain RCRB base address.
		section_cper->CxlAgentAddress.PortRcrbBaseAddress =
			json_object_get_uint64(
				json_object_object_get(address, "value"));
	}

	//Device ID information.
	json_object *device_id = json_object_object_get(section, "deviceID");
	section_cper->DeviceId.VendorId = json_object_get_uint64(
		json_object_object_get(device_id, "vendorID"));
	section_cper->DeviceId.DeviceId = json_object_get_uint64(
		json_object_object_get(device_id, "deviceID"));
	section_cper->DeviceId.SubsystemVendorId = json_object_get_uint64(
		json_object_object_get(device_id, "subsystemVendorID"));
	section_cper->DeviceId.SubsystemDeviceId = json_object_get_uint64(
		json_object_object_get(device_id, "subsystemDeviceID"));
	section_cper->DeviceId.ClassCode = json_object_get_uint64(
		json_object_object_get(device_id, "classCode"));
	section_cper->DeviceId.SlotNumber = json_object_get_uint64(
		json_object_object_get(device_id, "slotNumber"));

	//If CXL 1.1 device, the serial number & PCI capability structure.
	UINT8 *decoded;
	if (section_cper->CxlAgentType == CXL_PROTOCOL_ERROR_DEVICE_AGENT) {
		section_cper->DeviceSerial = json_object_get_uint64(
			json_object_object_get(section, "deviceSerial"));

		json_object *encoded =
			json_object_object_get(section, "capabilityStructure");

		int32_t decoded_len = 0;

		decoded = base64_decode(json_object_get_string(encoded),
					json_object_get_string_len(encoded),
					&decoded_len);

		if (decoded == NULL) {
			printf("Failed to allocate decode output buffer. \n");
		} else {
			memcpy(section_cper->CapabilityStructure.PcieCap,
			       decoded, decoded_len);
			free(decoded);
		}
	}

	//DVSEC length & error log length.
	section_cper->CxlDvsecLength = (UINT16)json_object_get_int(
		json_object_object_get(section, "dvsecLength"));
	section_cper->CxlErrorLogLength = (UINT16)json_object_get_int(
		json_object_object_get(section, "errorLogLength"));

	//Write header to stream.
	fwrite(section_cper, sizeof(EFI_CXL_PROTOCOL_ERROR_DATA), 1, out);
	fflush(out);

	//DVSEC out to stream.
	json_object *encoded = json_object_object_get(section, "cxlDVSEC");

	int32_t decoded_len = 0;

	decoded = base64_decode(json_object_get_string(encoded),
				json_object_get_string_len(encoded),
				&decoded_len);
	if (decoded == NULL) {
		printf("Failed to allocate decode output buffer. \n");
	} else {
		fwrite(decoded, decoded_len, 1, out);
		fflush(out);
		free(decoded);
	}

	//Error log out to stream.
	encoded = json_object_object_get(section, "cxlErrorLog");
	decoded_len = 0;

	decoded = base64_decode(json_object_get_string(encoded),
				json_object_get_string_len(encoded),
				&decoded_len);
	if (decoded == NULL) {
		printf("Failed to allocate decode output buffer. \n");
	} else {
		fwrite(decoded, decoded_len, 1, out);
		fflush(out);
		free(decoded);
	}

	free(section_cper);
}
