提交 372e15c5 编写于 作者: L Leon Romanovsky 提交者: Doug Ledford

RDMA/uverbs: Reduce number of command header flags checks

Simplify the code by directly checking the availability of extended
command flog instead of doing multiple shift operations.
Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: NDoug Ledford <dledford@redhat.com>
上级 cd35cf4b
...@@ -657,19 +657,12 @@ static bool verify_command_idx(u32 command, bool extended) ...@@ -657,19 +657,12 @@ static bool verify_command_idx(u32 command, bool extended)
static ssize_t process_hdr(struct ib_uverbs_cmd_hdr *hdr, static ssize_t process_hdr(struct ib_uverbs_cmd_hdr *hdr,
u32 *command, bool *extended) u32 *command, bool *extended)
{ {
u32 flags; if (hdr->command & ~(u32)(IB_USER_VERBS_CMD_FLAG_EXTENDED |
if (hdr->command & ~(u32)(IB_USER_VERBS_CMD_FLAGS_MASK |
IB_USER_VERBS_CMD_COMMAND_MASK)) IB_USER_VERBS_CMD_COMMAND_MASK))
return -EINVAL; return -EINVAL;
*command = hdr->command & IB_USER_VERBS_CMD_COMMAND_MASK; *command = hdr->command & IB_USER_VERBS_CMD_COMMAND_MASK;
flags = (hdr->command & *extended = hdr->command & IB_USER_VERBS_CMD_FLAG_EXTENDED;
IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
*extended = flags & IB_USER_VERBS_CMD_FLAG_EXTENDED;
if (flags & ~IB_USER_VERBS_CMD_FLAG_EXTENDED)
return -EINVAL;
if (!verify_command_idx(*command, *extended)) if (!verify_command_idx(*command, *extended))
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -141,10 +141,7 @@ struct ib_uverbs_cq_moderation_caps { ...@@ -141,10 +141,7 @@ struct ib_uverbs_cq_moderation_caps {
*/ */
#define IB_USER_VERBS_CMD_COMMAND_MASK 0xff #define IB_USER_VERBS_CMD_COMMAND_MASK 0xff
#define IB_USER_VERBS_CMD_FLAGS_MASK 0xff000000u #define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80000000u
#define IB_USER_VERBS_CMD_FLAGS_SHIFT 24
#define IB_USER_VERBS_CMD_FLAG_EXTENDED 0x80
struct ib_uverbs_cmd_hdr { struct ib_uverbs_cmd_hdr {
__u32 command; __u32 command;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册