Skip to content

Commit

Permalink
Enhance cmd parser for custom commands parsing
Browse files Browse the repository at this point in the history
Change-Id: I54bd48db5c99e0196d556fe14882a071c3f04b3b
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
  • Loading branch information
BartoszDunajski authored and Compute-Runtime-Automation committed Jan 31, 2020
1 parent 76400ff commit 36f11d4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
27 changes: 24 additions & 3 deletions unit_tests/gen_common/cmd_parse_base.inl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Intel Corporation
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -297,7 +297,13 @@ size_t CmdParse<T>::getCommandLength(void *cmd) {
if (pCmd)
return pCmd->TheStructure.Common.DwordLength + 2;
}
return getCommandLengthHwSpecific(cmd);

auto commandLengthHwSpecific = getCommandLengthHwSpecific(cmd);

if (commandLengthHwSpecific != 0) {
return commandLengthHwSpecific;
}
return getAdditionalCommandLength(cmd);
}

template <class T>
Expand Down Expand Up @@ -327,5 +333,20 @@ const char *CmdParse<T>::getCommandName(void *cmd) {

#undef RETURN_NAME_IF

return getCommandNameHwSpecific(cmd);
auto commandNameHwSpecific = getCommandNameHwSpecific(cmd);
if (strcmp(commandNameHwSpecific, "UNKNOWN") != 0) {
return commandNameHwSpecific;
}

return getAdditionalCommandName(cmd);
}

template <class T>
size_t CmdParse<T>::getAdditionalCommandLength(void *cmd) {
return 0;
}

template <class T>
const char *CmdParse<T>::getAdditionalCommandName(void *cmd) {
return "UNKNOWN";
}
4 changes: 3 additions & 1 deletion unit_tests/gen_common/gen_cmd_parse.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2019 Intel Corporation
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -90,6 +90,7 @@ template <class T>
struct CmdParse : public T {
static size_t getCommandLength(void *cmd);
static size_t getCommandLengthHwSpecific(void *cmd);
static size_t getAdditionalCommandLength(void *cmd);

static bool parseCommandBuffer(GenCmdList &_cmds, void *_buffer, size_t _length);

Expand All @@ -98,4 +99,5 @@ struct CmdParse : public T {

static const char *getCommandName(void *cmd);
static const char *getCommandNameHwSpecific(void *cmd);
static const char *getAdditionalCommandName(void *cmd);
};

0 comments on commit 36f11d4

Please sign in to comment.