Commit 93a84565 authored by Benjamin Romer's avatar Benjamin Romer Committed by Greg Kroah-Hartman

staging: unisys: refactor ULTRA_check_channel_client()

Rename the function ULTRA_check_channel_client() to
spar_check_channel_client(), and fix CamelCase parameter names:

pChannel => ch
expectedTypeGuid => expected_uuid
channelName => chname
expectedMinBytes => expected_min_bytes
expectedVersionId => expected_version
expectedSignature => expected_signature

Rename macros that use spar_check_channel_client:

ULTRA_CONTROLVM_CHANNEL_OK_CLIENT => SPAR_CONTROLVM_CHANNEL_OK_CLIENT
ULTRA_VHBA_CHANNEL_OK_CLIENT => SPAR_VHBA_CHANNEL_OK_CLIENT
ULTRA_VNIC_CHANNEL_OK_CLIENT => SPAR_VNIC_CHANNEL_OK_CLIENT
ULTRA_VSWITCH_CHANNEL_OK_CLIENT => SPAR_VSWITCH_CHANNEL_OK_CLIENT
ULTRA_VBUS_CHANNEL_OK_CLIENT => SPAR_VBUS_CHANNEL_OK_CLIENT
Signed-off-by: default avatarBenjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 153cf710
...@@ -43,17 +43,16 @@ ...@@ -43,17 +43,16 @@
* Return value: * Return value:
* 1 if the insertion succeeds, 0 if the queue was full. * 1 if the insertion succeeds, 0 if the queue was full.
*/ */
unsigned char unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, void *sig)
void *pSignal)
{ {
void __iomem *psignal; void __iomem *psignal;
unsigned int head, tail, nof; unsigned int head, tail, nof;
struct signal_queue_header __iomem *pqhdr = struct signal_queue_header __iomem *pqhdr =
(struct signal_queue_header __iomem *) (struct signal_queue_header __iomem *)
((char __iomem *) pChannel + readq(&pChannel->ch_space_offset)) ((char __iomem *) ch + readq(&ch->ch_space_offset))
+ Queue; + queue;
/* capture current head and tail */ /* capture current head and tail */
head = readl(&pqhdr->head); head = readl(&pqhdr->head);
...@@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, ...@@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
*/ */
psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) + psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
(head * readl(&pqhdr->signal_size)); (head * readl(&pqhdr->signal_size));
memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size)); memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));
mb(); /* channel synch */ mb(); /* channel synch */
writel(head, &pqhdr->head); writel(head, &pqhdr->head);
...@@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue, ...@@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent); writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(visor_signal_insert); EXPORT_SYMBOL_GPL(spar_signal_insert);
/* /*
* Routine Description: * Routine Description:
......
...@@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue, ...@@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue,
unsigned long flags; unsigned long flags;
spin_lock_irqsave(lock, flags); spin_lock_irqsave(lock, flags);
result = visor_signal_insert(pChannel, Queue, pSignal); result = spar_signal_insert(pChannel, Queue, pSignal);
spin_unlock_irqrestore(lock, flags); spin_unlock_irqrestore(lock, flags);
return result; return result;
} }
......
...@@ -289,89 +289,65 @@ struct signal_queue_header { ...@@ -289,89 +289,65 @@ struct signal_queue_header {
* is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
*/ */
static inline int static inline int
ULTRA_check_channel_client(void __iomem *pChannel, spar_check_channel_client(void __iomem *ch,
uuid_le expectedTypeGuid, uuid_le expected_uuid,
char *channelName, char *chname,
u64 expectedMinBytes, u64 expected_min_bytes,
u32 expectedVersionId, u32 expected_version,
u64 expectedSignature, u64 expected_signature)
char *fileName, int lineNumber, void *logCtx)
{ {
if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) { if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
uuid_le guid; uuid_le guid;
memcpy_fromio(&guid, memcpy_fromio(&guid,
&((struct channel_header __iomem *)(pChannel))->chtype, &((struct channel_header __iomem *)(ch))->chtype,
sizeof(guid)); sizeof(guid));
/* caller wants us to verify type GUID */ /* caller wants us to verify type GUID */
if (uuid_le_cmp(guid, expectedTypeGuid) != 0) { if (uuid_le_cmp(guid, expected_uuid) != 0) {
pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n", pr_err("Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL\n",
channelName, &expectedTypeGuid, chname, &expected_uuid,
&expectedTypeGuid, &guid); &expected_uuid, &guid);
return 0; return 0;
} }
} }
if (expectedMinBytes > 0) { /* caller wants us to verify if (expected_min_bytes > 0) { /* caller wants us to verify
* channel size */ * channel size */
unsigned long long bytes = unsigned long long bytes =
readq(&((struct channel_header __iomem *) readq(&((struct channel_header __iomem *)
(pChannel))->size); (ch))->size);
if (bytes < expectedMinBytes) { if (bytes < expected_min_bytes) {
pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n", pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
channelName, &expectedTypeGuid, chname, &expected_uuid,
(unsigned long long)expectedMinBytes, bytes); (unsigned long long)expected_min_bytes, bytes);
return 0; return 0;
} }
} }
if (expectedVersionId > 0) { /* caller wants us to verify if (expected_version > 0) { /* caller wants us to verify
* channel version */ * channel version */
unsigned long ver = readl(&((struct channel_header __iomem *) unsigned long ver = readl(&((struct channel_header __iomem *)
(pChannel))->version_id); (ch))->version_id);
if (ver != expectedVersionId) { if (ver != expected_version) {
pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n", pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
channelName, &expectedTypeGuid, chname, &expected_uuid,
(unsigned long)expectedVersionId, ver); (unsigned long)expected_version, ver);
return 0; return 0;
} }
} }
if (expectedSignature > 0) { /* caller wants us to verify if (expected_signature > 0) { /* caller wants us to verify
* channel signature */ * channel signature */
unsigned long long sig = unsigned long long sig =
readq(&((struct channel_header __iomem *) readq(&((struct channel_header __iomem *)
(pChannel))->signature); (ch))->signature);
if (sig != expectedSignature) { if (sig != expected_signature) {
pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n", pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
channelName, &expectedTypeGuid, chname, &expected_uuid,
expectedSignature, sig); expected_signature, sig);
return 0; return 0;
} }
} }
return 1; 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
ULTRA_check_channel_server(uuid_le typeGuid,
char *channelName,
u64 expectedMinBytes,
u64 actualBytes,
char *fileName, int lineNumber, void *logCtx)
{
if (expectedMinBytes > 0) /* caller wants us to verify
* channel size */
if (actualBytes < expectedMinBytes) {
pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8llx actual=0x%-8.8llx\n",
channelName, &typeGuid, expectedMinBytes,
actualBytes);
return 0;
}
return 1;
}
/* Given a file pathname <s> (with '/' or '\' separating directory nodes), /* Given a file pathname <s> (with '/' or '\' separating directory nodes),
* returns a pointer to the beginning of a node within that pathname such * 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 * that the number of nodes from that pointer to the end of the string is
...@@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id) ...@@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id)
* full. * full.
*/ */
unsigned char visor_signal_insert(struct channel_header __iomem *pChannel, unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
u32 Queue, void *pSignal); void *sig);
/* /*
* Routine Description: * Routine Description:
......
...@@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid = ...@@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
* channel struct withOUT needing to increment this. */ * channel struct withOUT needing to increment this. */
#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1 #define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx) \ #define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel) \
(ULTRA_check_channel_client(pChannel, \ (spar_check_channel_client(pChannel, \
UltraControlvmChannelProtocolGuid, \ UltraControlvmChannelProtocolGuid, \
"controlvm", \ "controlvm", \
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \ sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE, \ ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
__FILE__, __LINE__, logCtx))
#define ULTRA_CONTROLVM_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(UltraControlvmChannelProtocolGuid, \
"controlvm", \
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
actualBytes, __FILE__, __LINE__, logCtx))
#define MY_DEVICE_INDEX 0 #define MY_DEVICE_INDEX 0
#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */ #define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
......
...@@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid = ...@@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid =
#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \ #define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, \ (spar_check_channel_client(pChannel, \
UltraDiagChannelProtocolGuid, \ UltraDiagChannelProtocolGuid, \
"diag", \ "diag", \
sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \ sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \ ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
__FILE__, __LINE__, logCtx))
#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \ #define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \ (ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \
"diag", \ "diag", \
......
...@@ -60,37 +60,22 @@ ...@@ -60,37 +60,22 @@
#define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2 #define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1 #define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \ #define SPAR_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \ (spar_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \
"vhba", MIN_IO_CHANNEL_SIZE, \ "vhba", MIN_IO_CHANNEL_SIZE, \
ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \ ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
__FILE__, __LINE__, logCtx)) #define SPAR_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \
#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx) \ (spar_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \
(ULTRA_check_channel_server(spar_vhba_channel_protocol_uuid, \ "vnic", MIN_IO_CHANNEL_SIZE, \
"vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \ ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
__FILE__, __LINE__, logCtx)) ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
#define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \ #define SPAR_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \ (spar_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
"vnic", MIN_IO_CHANNEL_SIZE, \ "vswitch", MIN_IO_CHANNEL_SIZE, \
ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE, \ ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE))
__FILE__, __LINE__, logCtx))
#define ULTRA_VNIC_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(spar_vnic_channel_protocol_uuid, \
"vnic", MIN_IO_CHANNEL_SIZE, actualBytes, \
__FILE__, __LINE__, logCtx))
#define ULTRA_VSWITCH_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, UltraVswitchChannelProtocolGuid, \
"vswitch", MIN_IO_CHANNEL_SIZE, \
ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VSWITCH_CHANNEL_PROTOCOL_SIGNATURE, \
__FILE__, __LINE__, logCtx))
#define ULTRA_VSWITCH_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(UltraVswitchChannelProtocolGuid, \
"vswitch", MIN_IO_CHANNEL_SIZE, \
actualBytes, \
__FILE__, __LINE__, logCtx))
/* /*
* Everything necessary to handle SCSI & NIC traffic between Guest Partition and * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
* IO Partition is defined below. */ * IO Partition is defined below. */
......
...@@ -43,22 +43,13 @@ static const uuid_le UltraVbusChannelProtocolGuid = ...@@ -43,22 +43,13 @@ static const uuid_le UltraVbusChannelProtocolGuid =
* increment this. */ * increment this. */
#define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1 #define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \ #define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, \ (spar_check_channel_client(pChannel, \
UltraVbusChannelProtocolGuid, \ UltraVbusChannelProtocolGuid, \
"vbus", \ "vbus", \
sizeof(struct ultra_vbus_channel_protocol),\ sizeof(struct ultra_vbus_channel_protocol),\
ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \ ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE, \ ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \
__FILE__, __LINE__, logCtx))
#define ULTRA_VBUS_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(UltraVbusChannelProtocolGuid, \
"vbus", \
sizeof(struct ultra_vbus_channel_protocol),\
actualBytes, \
__FILE__, __LINE__, logCtx))
#pragma pack(push, 1) /* both GCC and VC now allow this pragma */ #pragma pack(push, 1) /* both GCC and VC now allow this pragma */
typedef struct _ULTRA_VBUS_HEADERINFO { typedef struct _ULTRA_VBUS_HEADERINFO {
......
...@@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes) ...@@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes)
rc = NULL; rc = NULL;
goto Away; goto Away;
} }
if (!ULTRA_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) { if (!SPAR_VBUS_CHANNEL_OK_CLIENT(pChan, NULL)) {
ERRDRV("%s channel cannot be used", __func__); ERRDRV("%s channel cannot be used", __func__);
uislib_iounmap(pChan); uislib_iounmap(pChan);
rc = NULL; rc = NULL;
...@@ -449,7 +449,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) ...@@ -449,7 +449,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
__iomem *) (dev-> __iomem *) (dev->
chanptr))-> chanptr))->
chtype); chtype);
if (!ULTRA_VHBA_CHANNEL_OK_CLIENT if (!SPAR_VHBA_CHANNEL_OK_CLIENT
(dev->chanptr, NULL)) { (dev->chanptr, NULL)) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.", LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.",
devNo); devNo);
...@@ -475,7 +475,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf) ...@@ -475,7 +475,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
__iomem *) (dev-> __iomem *) (dev->
chanptr))-> chanptr))->
chtype); chtype);
if (!ULTRA_VNIC_CHANNEL_OK_CLIENT if (!SPAR_VNIC_CHANNEL_OK_CLIENT
(dev->chanptr, NULL)) { (dev->chanptr, NULL)) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.", LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.",
devNo); devNo);
......
...@@ -83,7 +83,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo, ...@@ -83,7 +83,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo,
spin_lock_irqsave(lock, flags); spin_lock_irqsave(lock, flags);
if (!spar_channel_client_acquire_os(queueinfo->chan, channelId)) if (!spar_channel_client_acquire_os(queueinfo->chan, channelId))
goto unlock; goto unlock;
if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) { if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
queueinfo->packets_sent++; queueinfo->packets_sent++;
rc = 1; rc = 1;
} }
......
...@@ -2382,9 +2382,8 @@ visorchipset_init(void) ...@@ -2382,9 +2382,8 @@ visorchipset_init(void)
(addr, (addr,
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
UltraControlvmChannelProtocolGuid); UltraControlvmChannelProtocolGuid);
if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
(visorchannel_get_header(ControlVm_channel), visorchannel_get_header(ControlVm_channel))) {
NULL)) {
LOGINF("Channel %s (ControlVm) discovered", LOGINF("Channel %s (ControlVm) discovered",
visorchannel_id(ControlVm_channel, s)); visorchannel_id(ControlVm_channel, s));
initialize_controlvm_payload(); initialize_controlvm_payload();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment