return 1;
}
+/* Generic function useful for validating any type of channel when it is about
+ * to be initialized by the server of the channel.
+ * Note that <logCtx> is only needed for callers in the EFI environment, and
+ * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
+ */
+static inline int spar_check_channel_server(uuid_le typeuuid, char *name,
+ u64 expected_min_bytes,
+ u64 actual_bytes)
+{
+ if (expected_min_bytes > 0) /* caller wants us to verify
+ * channel size */
+ if (actual_bytes < expected_min_bytes) {
+ pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
+ name, &typeuuid, expected_min_bytes,
+ actual_bytes);
+ return 0;
+ }
+ return 1;
+}
+
/* Given a file pathname <s> (with '/' or '\' separating directory nodes),
* returns a pointer to the beginning of a node within that pathname such
* that the number of nodes from that pointer to the end of the string is
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(UltraControlvmChannelProtocolGuid, \
+ "controlvm", \
+ sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
+ actualBytes))
#define MY_DEVICE_INDEX 0
#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
-#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \
- (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \
- "diag", \
- sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
- actualBytes, __FILE__, __LINE__, logCtx))
+#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(UltraDiagChannelProtocolGuid, \
+ "diag", \
+ sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
+ actualBytes))
#define MAX_MODULE_NAME_SIZE 128 /* Maximum length of module name... */
#define MAX_ADDITIONAL_INFO_SIZE 256 /* Maximum length of any additional info
* accompanying event... */
"vhba", MIN_IO_CHANNEL_SIZE, \
ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(spar_vhba_channel_protocol_uuid, \
+ "vhba", MIN_IO_CHANNEL_SIZE, actualBytes))
#define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \
"vnic", MIN_IO_CHANNEL_SIZE, \
ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
+#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(spar_vnic_channel_protocol_uuid, \
+ "vnic", MIN_IO_CHANNEL_SIZE, actualBytes))
#define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
"vswitch", MIN_IO_CHANNEL_SIZE, \
ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE))
-
+#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(UltraVswitchChannelProtocolGuid, \
+ "vswitch", MIN_IO_CHANNEL_SIZE, \
+ actualBytes))
/*
* Everything necessary to handle SCSI & NIC traffic between Guest Partition and
* IO Partition is defined below. */
ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \
+#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes) \
+ (spar_check_channel_server(UltraVbusChannelProtocolGuid, \
+ "vbus", \
+ sizeof(struct ultra_vbus_channel_protocol),\
+ actualBytes))
+
#pragma pack(push, 1) /* both GCC and VC now allow this pragma */
typedef struct _ULTRA_VBUS_HEADERINFO {
u32 structBytes; /* size of this struct in bytes */