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: Benjamin Romer <benjamin.romer@unisys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Benjamin Romer 2014-10-23 14:30:05 -04:00 committed by Greg Kroah-Hartman
parent 153cf71072
commit 93a8456556
10 changed files with 73 additions and 130 deletions

View File

@ -43,17 +43,16 @@
* Return value:
* 1 if the insertion succeeds, 0 if the queue was full.
*/
unsigned char
visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
void *pSignal)
unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
void *sig)
{
void __iomem *psignal;
unsigned int head, tail, nof;
struct signal_queue_header __iomem *pqhdr =
(struct signal_queue_header __iomem *)
((char __iomem *) pChannel + readq(&pChannel->ch_space_offset))
+ Queue;
((char __iomem *) ch + readq(&ch->ch_space_offset))
+ queue;
/* capture current head and tail */
head = readl(&pqhdr->head);
@ -74,7 +73,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
*/
psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
(head * readl(&pqhdr->signal_size));
memcpy_toio(psignal, pSignal, readl(&pqhdr->signal_size));
memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));
mb(); /* channel synch */
writel(head, &pqhdr->head);
@ -82,7 +81,7 @@ visor_signal_insert(struct channel_header __iomem *pChannel, u32 Queue,
writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
return 1;
}
EXPORT_SYMBOL_GPL(visor_signal_insert);
EXPORT_SYMBOL_GPL(spar_signal_insert);
/*
* Routine Description:

View File

@ -49,7 +49,7 @@ SignalInsert_withLock(struct channel_header __iomem *pChannel, u32 Queue,
unsigned long 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);
return result;
}

View File

@ -289,89 +289,65 @@ struct signal_queue_header {
* is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
*/
static inline int
ULTRA_check_channel_client(void __iomem *pChannel,
uuid_le expectedTypeGuid,
char *channelName,
u64 expectedMinBytes,
u32 expectedVersionId,
u64 expectedSignature,
char *fileName, int lineNumber, void *logCtx)
spar_check_channel_client(void __iomem *ch,
uuid_le expected_uuid,
char *chname,
u64 expected_min_bytes,
u32 expected_version,
u64 expected_signature)
{
if (uuid_le_cmp(expectedTypeGuid, NULL_UUID_LE) != 0) {
if (uuid_le_cmp(expected_uuid, NULL_UUID_LE) != 0) {
uuid_le guid;
memcpy_fromio(&guid,
&((struct channel_header __iomem *)(pChannel))->chtype,
sizeof(guid));
&((struct channel_header __iomem *)(ch))->chtype,
sizeof(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",
channelName, &expectedTypeGuid,
&expectedTypeGuid, &guid);
chname, &expected_uuid,
&expected_uuid, &guid);
return 0;
}
}
if (expectedMinBytes > 0) { /* caller wants us to verify
if (expected_min_bytes > 0) { /* caller wants us to verify
* channel size */
unsigned long long bytes =
readq(&((struct channel_header __iomem *)
(pChannel))->size);
if (bytes < expectedMinBytes) {
(ch))->size);
if (bytes < expected_min_bytes) {
pr_err("Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx\n",
channelName, &expectedTypeGuid,
(unsigned long long)expectedMinBytes, bytes);
chname, &expected_uuid,
(unsigned long long)expected_min_bytes, bytes);
return 0;
}
}
if (expectedVersionId > 0) { /* caller wants us to verify
if (expected_version > 0) { /* caller wants us to verify
* channel version */
unsigned long ver = readl(&((struct channel_header __iomem *)
(pChannel))->version_id);
if (ver != expectedVersionId) {
(ch))->version_id);
if (ver != expected_version) {
pr_err("Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8lx\n",
channelName, &expectedTypeGuid,
(unsigned long)expectedVersionId, ver);
chname, &expected_uuid,
(unsigned long)expected_version, ver);
return 0;
}
}
if (expectedSignature > 0) { /* caller wants us to verify
if (expected_signature > 0) { /* caller wants us to verify
* channel signature */
unsigned long long sig =
readq(&((struct channel_header __iomem *)
(pChannel))->signature);
if (sig != expectedSignature) {
(ch))->signature);
if (sig != expected_signature) {
pr_err("Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8llx actual=0x%-8.8llx\n",
channelName, &expectedTypeGuid,
expectedSignature, sig);
chname, &expected_uuid,
expected_signature, sig);
return 0;
}
}
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),
* 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
@ -530,8 +506,8 @@ spar_channel_client_release_os(void __iomem *ch, u8 *id)
* full.
*/
unsigned char visor_signal_insert(struct channel_header __iomem *pChannel,
u32 Queue, void *pSignal);
unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
void *sig);
/*
* Routine Description:

View File

@ -45,19 +45,13 @@ static const uuid_le UltraControlvmChannelProtocolGuid =
* channel struct withOUT needing to increment this. */
#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_CONTROLVM_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, \
UltraControlvmChannelProtocolGuid, \
"controlvm", \
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
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 SPAR_CONTROLVM_CHANNEL_OK_CLIENT(pChannel) \
(spar_check_channel_client(pChannel, \
UltraControlvmChannelProtocolGuid, \
"controlvm", \
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL), \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE))
#define MY_DEVICE_INDEX 0
#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */

View File

@ -59,13 +59,12 @@ static const uuid_le UltraDiagChannelProtocolGuid =
#define ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_DIAG_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, \
(spar_check_channel_client(pChannel, \
UltraDiagChannelProtocolGuid, \
"diag", \
sizeof(ULTRA_DIAG_CHANNEL_PROTOCOL), \
ULTRA_DIAG_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE, \
__FILE__, __LINE__, logCtx))
ULTRA_DIAG_CHANNEL_PROTOCOL_SIGNATURE))
#define ULTRA_DIAG_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(UltraDiagChannelProtocolGuid, \
"diag", \

View File

@ -60,37 +60,22 @@
#define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \
"vhba", MIN_IO_CHANNEL_SIZE, \
ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE, \
__FILE__, __LINE__, logCtx))
#define ULTRA_VHBA_CHANNEL_OK_SERVER(actualBytes, logCtx) \
(ULTRA_check_channel_server(spar_vhba_channel_protocol_uuid, \
"vhba", MIN_IO_CHANNEL_SIZE, actualBytes, \
__FILE__, __LINE__, logCtx))
#define ULTRA_VNIC_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, spar_vnic_channel_protocol_uuid, \
"vnic", MIN_IO_CHANNEL_SIZE, \
ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VNIC_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))
#define SPAR_VHBA_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(spar_check_channel_client(pChannel, spar_vhba_channel_protocol_uuid, \
"vhba", MIN_IO_CHANNEL_SIZE, \
ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE))
#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 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))
/*
* Everything necessary to handle SCSI & NIC traffic between Guest Partition and
* IO Partition is defined below. */

View File

@ -43,22 +43,13 @@ static const uuid_le UltraVbusChannelProtocolGuid =
* increment this. */
#define ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID 1
#define ULTRA_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(ULTRA_check_channel_client(pChannel, \
UltraVbusChannelProtocolGuid, \
"vbus", \
sizeof(struct ultra_vbus_channel_protocol),\
#define SPAR_VBUS_CHANNEL_OK_CLIENT(pChannel, logCtx) \
(spar_check_channel_client(pChannel, \
UltraVbusChannelProtocolGuid, \
"vbus", \
sizeof(struct ultra_vbus_channel_protocol),\
ULTRA_VBUS_CHANNEL_PROTOCOL_VERSIONID, \
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))
ULTRA_VBUS_CHANNEL_PROTOCOL_SIGNATURE)) \
#pragma pack(push, 1) /* both GCC and VC now allow this pragma */
typedef struct _ULTRA_VBUS_HEADERINFO {

View File

@ -142,7 +142,7 @@ init_vbus_channel(u64 channelAddr, u32 channelBytes)
rc = NULL;
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__);
uislib_iounmap(pChan);
rc = NULL;
@ -449,7 +449,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
__iomem *) (dev->
chanptr))->
chtype);
if (!ULTRA_VHBA_CHANNEL_OK_CLIENT
if (!SPAR_VHBA_CHANNEL_OK_CLIENT
(dev->chanptr, NULL)) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed:[CLIENT]VHBA dev %d chan invalid.",
devNo);
@ -475,7 +475,7 @@ create_device(CONTROLVM_MESSAGE *msg, char *buf)
__iomem *) (dev->
chanptr))->
chtype);
if (!ULTRA_VNIC_CHANNEL_OK_CLIENT
if (!SPAR_VNIC_CHANNEL_OK_CLIENT
(dev->chanptr, NULL)) {
LOGERR("CONTROLVM_DEVICE_CREATE Failed: VNIC[CLIENT] dev %d chan invalid.",
devNo);

View File

@ -83,7 +83,7 @@ do_locked_client_insert(struct uisqueue_info *queueinfo,
spin_lock_irqsave(lock, flags);
if (!spar_channel_client_acquire_os(queueinfo->chan, channelId))
goto unlock;
if (visor_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
if (spar_signal_insert(queueinfo->chan, whichqueue, pSignal)) {
queueinfo->packets_sent++;
rc = 1;
}

View File

@ -2382,9 +2382,8 @@ visorchipset_init(void)
(addr,
sizeof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL),
UltraControlvmChannelProtocolGuid);
if (ULTRA_CONTROLVM_CHANNEL_OK_CLIENT
(visorchannel_get_header(ControlVm_channel),
NULL)) {
if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
visorchannel_get_header(ControlVm_channel))) {
LOGINF("Channel %s (ControlVm) discovered",
visorchannel_id(ControlVm_channel, s));
initialize_controlvm_payload();