History

scsi: ufs: Simplify response header parsing

Make the code that parses UTP transfer request headers easier to read by using u8 instead of __be32 where appropriate.

Bart Van Assche committed 3 years ago

Commit 617bfaa1 parent 67a2a893 files · +115 −108Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/scsi/scsi_bsg_ufs.h+49−3
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #ifndef SCSI_BSG_UFS_H
99 #define SCSI_BSG_UFS_H
1010
11+#include <asm/byteorder.h>
1112 #include <linux/types.h>
1213 /*
1314 * This file intended to be included by both kernel and user space
@@ -40,11 +41,56 @@ enum ufs_rpmb_op_type { · 26 unmodified lines
4041 * @dword_0: UPIU header DW-0
4142 * @dword_1: UPIU header DW-1
4243 * @dword_2: UPIU header DW-2
44+ *
45+ * @transaction_code: Type of request or response. See also enum
46+ * upiu_request_transaction and enum upiu_response_transaction.
47+ * @flags: UPIU flags. The meaning of individual flags depends on the
48+ * transaction code.
49+ * @lun: Logical unit number.
50+ * @task_tag: Task tag.
51+ * @iid: Initiator ID.
52+ * @command_set_type: 0 for SCSI command set; 1 for UFS specific.
53+ * @tm_function: Task management function in case of a task management request
54+ * UPIU.
55+ * @query_function: Query function in case of a query request UPIU.
56+ * @response: 0 for success; 1 for failure.
57+ * @status: SCSI status if this is the header of a response to a SCSI command.
58+ * @ehs_length: EHS length in units of 32 bytes.
59+ * @device_information:
60+ * @data_segment_length: data segment length.
4361 */
4462 struct utp_upiu_header {
45− __be32 dword_0;
46− __be32 dword_1;
47− __be32 dword_2;
63+ union {
64+ struct {
65+ __be32 dword_0;
66+ __be32 dword_1;
67+ __be32 dword_2;
68+ };
69+ struct {
70+ __u8 transaction_code;
71+ __u8 flags;
72+ __u8 lun;
73+ __u8 task_tag;
74+#if defined(__BIG_ENDIAN)
75+ __u8 iid: 4;
76+ __u8 command_set_type: 4;
77+#elif defined(__LITTLE_ENDIAN)
78+ __u8 command_set_type: 4;
79+ __u8 iid: 4;
80+#else
81+#error
82+#endif
83+ union {
84+ __u8 tm_function;
85+ __u8 query_function;
86+ };
87+ __u8 response;
88+ __u8 status;
89+ __u8 ehs_length;
90+ __u8 device_information;
91+ __be16 data_segment_length;
92+ };
93+ };
4894 };
4995
5096 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t