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

Unified · Split

3 files
  1. drivers/ufs/core/ufshcd.c +60 −93
  2. include/uapi/scsi/scsi_bsg_ufs.h +49 −3
  3. include/ufs/ufs.h +6 −12
drivers/ufs/core/ufshcd.c+60−93
@@ -882,35 +882,7 @@ static inline u32 ufshcd_get_dme_attr_val(struct ufs_hba *hba) · 881 unmodified lines
882static inline enum upiu_response_transaction882static inline enum upiu_response_transaction
883ufshcd_get_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr)883ufshcd_get_req_rsp(struct utp_upiu_rsp *ucd_rsp_ptr)
884{884{
885 return be32_to_cpu(ucd_rsp_ptr->header.dword_0) >> 24;885 return ucd_rsp_ptr->header.transaction_code;
886}
887
888/**
889 * ufshcd_get_rsp_upiu_result - Get the result from response UPIU
890 * @ucd_rsp_ptr: pointer to response UPIU
891 *
892 * This function gets the response status and scsi_status from response UPIU
893 *
894 * Return: the response result code.
895 */
896static inline int
897ufshcd_get_rsp_upiu_result(struct utp_upiu_rsp *ucd_rsp_ptr)
898{
899 return be32_to_cpu(ucd_rsp_ptr->header.dword_1) & MASK_RSP_UPIU_RESULT;
900}
901
902/*
903 * ufshcd_get_rsp_upiu_data_seg_len - Get the data segment length
904 * from response UPIU
905 * @ucd_rsp_ptr: pointer to response UPIU
906 *
907 * Return: the data segment length.
908 */
909static inline unsigned int
910ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr)
911{
912 return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &
913 MASK_RSP_UPIU_DATA_SEG_LEN;
914}886}
915 887
916/**888/**
@@ -924,8 +896,7 @@ ufshcd_get_rsp_upiu_data_seg_len(struct utp_upiu_rsp *ucd_rsp_ptr) · 7 unmodified lines
924 */896 */
925static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)897static inline bool ufshcd_is_exception_event(struct utp_upiu_rsp *ucd_rsp_ptr)
926{898{
927 return be32_to_cpu(ucd_rsp_ptr->header.dword_2) &899 return ucd_rsp_ptr->header.device_information & 1;
928 MASK_RSP_EXCEPTION_EVENT;
929}900}
930 901
931/**902/**
@@ -2224,10 +2195,11 @@ void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag, · 1292 unmodified lines
2224static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)2195static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
2225{2196{
2226 u8 *const sense_buffer = lrbp->cmd->sense_buffer;2197 u8 *const sense_buffer = lrbp->cmd->sense_buffer;
2198 u16 resp_len;
2227 int len;2199 int len;
2228 2200
2229 if (sense_buffer &&2201 resp_len = be16_to_cpu(lrbp->ucd_rsp_ptr->header.data_segment_length);
2230 ufshcd_get_rsp_upiu_data_seg_len(lrbp->ucd_rsp_ptr)) {2202 if (sense_buffer && resp_len) {
2231 int len_to_copy;2203 int len_to_copy;
2232 2204
2233 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);2205 len = be16_to_cpu(lrbp->ucd_rsp_ptr->sr.sense_data_len);
@@ -2262,8 +2234,8 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 28 unmodified lines
2262 u16 buf_len;2234 u16 buf_len;
2263 2235
2264 /* data segment length */2236 /* data segment length */
2265 resp_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) &2237 resp_len = be16_to_cpu(lrbp->ucd_rsp_ptr->header
2266 MASK_QUERY_DATA_SEG_LEN;2238 .data_segment_length);
2267 buf_len = be16_to_cpu(2239 buf_len = be16_to_cpu(
2268 hba->dev_cmd.query.request.upiu_req.length);2240 hba->dev_cmd.query.request.upiu_req.length);
2269 if (likely(buf_len >= resp_len)) {2241 if (likely(buf_len >= resp_len)) {
@@ -2636,15 +2608,13 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u8 upiu_flags) · 366 unmodified lines
2636 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;2608 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
2637 unsigned short cdb_len;2609 unsigned short cdb_len;
2638 2610
2639 /* command descriptor fields */2611 ucd_req_ptr->header = (struct utp_upiu_header){
2640 ucd_req_ptr->header.dword_0 = upiu_header_dword(2612 .transaction_code = UPIU_TRANSACTION_COMMAND,
2641 UPIU_TRANSACTION_COMMAND, upiu_flags,2613 .flags = upiu_flags,
2642 lrbp->lun, lrbp->task_tag);2614 .lun = lrbp->lun,
2643 ucd_req_ptr->header.dword_1 = upiu_header_dword(2615 .task_tag = lrbp->task_tag,
2644 UPIU_COMMAND_SET_TYPE_SCSI, 0, 0, 0);2616 .command_set_type = UPIU_COMMAND_SET_TYPE_SCSI,
2645 2617 };
2646 /* Total EHS length and Data segment length will be zero */
2647 ucd_req_ptr->header.dword_2 = 0;
2648 2618
2649 ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length);2619 ucd_req_ptr->sc.exp_data_transfer_len = cpu_to_be32(cmd->sdb.length);
2650 2620
@@ -2669,18 +2639,19 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, · 18 unmodified lines
2669 u16 len = be16_to_cpu(query->request.upiu_req.length);2639 u16 len = be16_to_cpu(query->request.upiu_req.length);
2670 2640
2671 /* Query request header */2641 /* Query request header */
2672 ucd_req_ptr->header.dword_0 = upiu_header_dword(2642 ucd_req_ptr->header = (struct utp_upiu_header){
2673 UPIU_TRANSACTION_QUERY_REQ, upiu_flags,2643 .transaction_code = UPIU_TRANSACTION_QUERY_REQ,
2674 lrbp->lun, lrbp->task_tag);2644 .flags = upiu_flags,
2675 ucd_req_ptr->header.dword_1 = upiu_header_dword(2645 .lun = lrbp->lun,
2676 0, query->request.query_func, 0, 0);2646 .task_tag = lrbp->task_tag,
2677 2647 .query_function = query->request.query_func,
2678 /* Data segment length only need for WRITE_DESC */2648 /* Data segment length only need for WRITE_DESC */
2679 if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)2649 .data_segment_length =
2680 ucd_req_ptr->header.dword_2 =2650 query->request.upiu_req.opcode ==
2681 upiu_header_dword(0, 0, len >> 8, (u8)len);2651 UPIU_QUERY_OPCODE_WRITE_DESC ?
2682 else2652 cpu_to_be16(len) :
2683 ucd_req_ptr->header.dword_2 = 0;2653 0,
2654 };
2684 2655
2685 /* Copy the Query Request buffer as is */2656 /* Copy the Query Request buffer as is */
2686 memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,2657 memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,
@@ -2699,12 +2670,10 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp) · 12 unmodified lines
2699 2670
2700 memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));2671 memset(ucd_req_ptr, 0, sizeof(struct utp_upiu_req));
2701 2672
2702 /* command descriptor fields */2673 ucd_req_ptr->header = (struct utp_upiu_header){
2703 ucd_req_ptr->header.dword_0 = upiu_header_dword(2674 .transaction_code = UPIU_TRANSACTION_NOP_OUT,
2704 UPIU_TRANSACTION_NOP_OUT, 0, 0, lrbp->task_tag);2675 .task_tag = lrbp->task_tag,
2705 /* clear rest of the fields of basic header */2676 };
2706 ucd_req_ptr->header.dword_1 = 0;
2707 ucd_req_ptr->header.dword_2 = 0;
2708 2677
2709 memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));2678 memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
2710}2679}
@@ -3008,13 +2977,6 @@ static int ufshcd_clear_cmd(struct ufs_hba *hba, u32 task_tag) · 297 unmodified lines
3008 mask, ~mask, 1000, 1000);2977 mask, ~mask, 1000, 1000);
3009}2978}
3010 2979
3011static int
3012ufshcd_check_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
3013{
3014 return ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) >>
3015 UPIU_RSP_CODE_OFFSET;
3016}
3017
3018/**2980/**
3019 * ufshcd_dev_cmd_completion() - handles device management command responses2981 * ufshcd_dev_cmd_completion() - handles device management command responses
3020 * @hba: per adapter instance2982 * @hba: per adapter instance
@@ -3039,11 +3001,13 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) · 18 unmodified lines
3039 __func__, resp);3001 __func__, resp);
3040 }3002 }
3041 break;3003 break;
3042 case UPIU_TRANSACTION_QUERY_RSP:3004 case UPIU_TRANSACTION_QUERY_RSP: {
3043 err = ufshcd_check_query_response(hba, lrbp);3005 u8 response = lrbp->ucd_rsp_ptr->header.response;
3044 if (!err)3006
3007 if (response == 0)
3045 err = ufshcd_copy_query_response(hba, lrbp);3008 err = ufshcd_copy_query_response(hba, lrbp);
3046 break;3009 break;
3010 }
3047 case UPIU_TRANSACTION_REJECT_UPIU:3011 case UPIU_TRANSACTION_REJECT_UPIU:
3048 /* TODO: handle Reject UPIU Response */3012 /* TODO: handle Reject UPIU Response */
3049 err = -EPERM;3013 err = -EPERM;
@@ -5244,7 +5208,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, · 2194 unmodified lines
5244 u8 upiu_flags;5208 u8 upiu_flags;
5245 u32 resid;5209 u32 resid;
5246 5210
5247 upiu_flags = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_0) >> 16;5211 upiu_flags = lrbp->ucd_rsp_ptr->header.flags;
5248 resid = be32_to_cpu(lrbp->ucd_rsp_ptr->sr.residual_transfer_count);5212 resid = be32_to_cpu(lrbp->ucd_rsp_ptr->sr.residual_transfer_count);
5249 /*5213 /*
5250 * Test !overflow instead of underflow to support UFS devices that do5214 * Test !overflow instead of underflow to support UFS devices that do
@@ -5257,8 +5221,8 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, · 6 unmodified lines
5257 ocs = ufshcd_get_tr_ocs(lrbp, cqe);5221 ocs = ufshcd_get_tr_ocs(lrbp, cqe);
5258 5222
5259 if (hba->quirks & UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR) {5223 if (hba->quirks & UFSHCD_QUIRK_BROKEN_OCS_FATAL_ERROR) {
5260 if (be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_1) &5224 if (lrbp->ucd_rsp_ptr->header.response ||
5261 MASK_RSP_UPIU_RESULT)5225 lrbp->ucd_rsp_ptr->header.status)
5262 ocs = OCS_SUCCESS;5226 ocs = OCS_SUCCESS;
5263 }5227 }
5264 5228
@@ -5267,17 +5231,11 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, · 2 unmodified lines
5267 hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);5231 hba->ufs_stats.last_hibern8_exit_tstamp = ktime_set(0, 0);
5268 switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {5232 switch (ufshcd_get_req_rsp(lrbp->ucd_rsp_ptr)) {
5269 case UPIU_TRANSACTION_RESPONSE:5233 case UPIU_TRANSACTION_RESPONSE:
5270 /*
5271 * get the response UPIU result to extract
5272 * the SCSI command status
5273 */
5274 result = ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr);
5275
5276 /*5234 /*
5277 * get the result based on SCSI status response5235 * get the result based on SCSI status response
5278 * to notify the SCSI midlayer of the command status5236 * to notify the SCSI midlayer of the command status
5279 */5237 */
5280 scsi_status = result & MASK_SCSI_STATUS;5238 scsi_status = lrbp->ucd_rsp_ptr->header.status;
5281 result = ufshcd_scsi_cmd_status(lrbp, scsi_status);5239 result = ufshcd_scsi_cmd_status(lrbp, scsi_status);
5282 5240
5283 /*5241 /*
@@ -6967,7 +6925,7 @@ static int __ufshcd_issue_tm_cmd(struct ufs_hba *hba, · 1683 unmodified lines
6967 WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n",6925 WARN_ONCE(task_tag < 0 || task_tag >= hba->nutmrs, "Invalid tag %d\n",
6968 task_tag);6926 task_tag);
6969 hba->tmf_rqs[req->tag] = req;6927 hba->tmf_rqs[req->tag] = req;
6970 treq->upiu_req.req_header.dword_0 |= cpu_to_be32(task_tag);6928 treq->upiu_req.req_header.task_tag = task_tag;
6971 6929
6972 memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq));6930 memcpy(hba->utmrdl_base_addr + task_tag, treq, sizeof(*treq));
6973 ufshcd_vops_setup_task_mgmt(hba, task_tag, tm_function);6931 ufshcd_vops_setup_task_mgmt(hba, task_tag, tm_function);
@@ -7034,9 +6992,9 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id, · 60 unmodified lines
7034 treq.header.ocs = OCS_INVALID_COMMAND_STATUS;6992 treq.header.ocs = OCS_INVALID_COMMAND_STATUS;
7035 6993
7036 /* Configure task request UPIU */6994 /* Configure task request UPIU */
7037 treq.upiu_req.req_header.dword_0 = cpu_to_be32(lun_id << 8) |6995 treq.upiu_req.req_header.transaction_code = UPIU_TRANSACTION_TASK_REQ;
7038 cpu_to_be32(UPIU_TRANSACTION_TASK_REQ << 24);6996 treq.upiu_req.req_header.lun = lun_id;
7039 treq.upiu_req.req_header.dword_1 = cpu_to_be32(tm_function << 16);6997 treq.upiu_req.req_header.tm_function = tm_function;
7040 6998
7041 /*6999 /*
7042 * The host shall provide the same value for LUN field in the basic7000 * The host shall provide the same value for LUN field in the basic
@@ -7110,7 +7068,7 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 67 unmodified lines
7110 lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;7068 lrbp->command_type = UTP_CMD_TYPE_UFS_STORAGE;
7111 7069
7112 /* update the task tag in the request upiu */7070 /* update the task tag in the request upiu */
7113 req_upiu->header.dword_0 |= cpu_to_be32(tag);7071 req_upiu->header.task_tag = tag;
7114 7072
7115 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE, 0);7073 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE, 0);
7116 7074
@@ -7143,8 +7101,8 @@ static int ufshcd_issue_devman_upiu_cmd(struct ufs_hba *hba, · 26 unmodified lines
7143 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));7101 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));
7144 if (desc_buff && desc_op == UPIU_QUERY_OPCODE_READ_DESC) {7102 if (desc_buff && desc_op == UPIU_QUERY_OPCODE_READ_DESC) {
7145 u8 *descp = (u8 *)lrbp->ucd_rsp_ptr + sizeof(*rsp_upiu);7103 u8 *descp = (u8 *)lrbp->ucd_rsp_ptr + sizeof(*rsp_upiu);
7146 u16 resp_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) &7104 u16 resp_len = be16_to_cpu(lrbp->ucd_rsp_ptr->header
7147 MASK_QUERY_DATA_SEG_LEN;7105 .data_segment_length);
7148 7106
7149 if (*buff_len >= resp_len) {7107 if (*buff_len >= resp_len) {
7150 memcpy(desc_buff, descp, resp_len);7108 memcpy(desc_buff, descp, resp_len);
@@ -7192,7 +7150,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba, · 41 unmodified lines
7192 enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY;7150 enum dev_cmd_type cmd_type = DEV_CMD_TYPE_QUERY;
7193 struct utp_task_req_desc treq = { };7151 struct utp_task_req_desc treq = { };
7194 enum utp_ocs ocs_value;7152 enum utp_ocs ocs_value;
7195 u8 tm_f = be32_to_cpu(req_upiu->header.dword_1) >> 16 & MASK_TM_FUNC;7153 u8 tm_f = req_upiu->header.tm_function;
7196 7154
7197 switch (msgcode) {7155 switch (msgcode) {
7198 case UPIU_TRANSACTION_NOP_OUT:7156 case UPIU_TRANSACTION_NOP_OUT:
@@ -7284,7 +7242,9 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r · 85 unmodified lines
7284 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2);7242 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, dir, 2);
7285 7243
7286 /* update the task tag and LUN in the request upiu */7244 /* update the task tag and LUN in the request upiu */
7287 req_upiu->header.dword_0 |= cpu_to_be32(upiu_flags << 16 | UFS_UPIU_RPMB_WLUN << 8 | tag);7245 req_upiu->header.flags = upiu_flags;
7246 req_upiu->header.lun = UFS_UPIU_RPMB_WLUN;
7247 req_upiu->header.task_tag = tag;
7288 7248
7289 /* copy the UPIU(contains CDB) request as it is */7249 /* copy the UPIU(contains CDB) request as it is */
7290 memcpy(lrbp->ucd_req_ptr, req_upiu, sizeof(*lrbp->ucd_req_ptr));7250 memcpy(lrbp->ucd_req_ptr, req_upiu, sizeof(*lrbp->ucd_req_ptr));
@@ -7306,9 +7266,10 @@ int ufshcd_advanced_rpmb_req_handler(struct ufs_hba *hba, struct utp_upiu_req *r · 15 unmodified lines
7306 /* Just copy the upiu response as it is */7266 /* Just copy the upiu response as it is */
7307 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));7267 memcpy(rsp_upiu, lrbp->ucd_rsp_ptr, sizeof(*rsp_upiu));
7308 /* Get the response UPIU result */7268 /* Get the response UPIU result */
7309 result = ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr);7269 result = (lrbp->ucd_rsp_ptr->header.response << 8) |
7270 lrbp->ucd_rsp_ptr->header.status;
7310 7271
7311 ehs_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) >> 24;7272 ehs_len = lrbp->ucd_rsp_ptr->header.ehs_length;
7312 /*7273 /*
7313 * Since the bLength in EHS indicates the total size of the EHS Header and EHS Data7274 * Since the bLength in EHS indicates the total size of the EHS Header and EHS Data
7314 * in 32 Byte units, the value of the bLength Request/Response for Advanced RPMB7275 * in 32 Byte units, the value of the bLength Request/Response for Advanced RPMB
@@ -10594,6 +10555,12 @@ static void ufshcd_check_header_layout(void) · 3279 unmodified lines
10594 BUILD_BUG_ON(((__le32 *)&(struct request_desc_header){10555 BUILD_BUG_ON(((__le32 *)&(struct request_desc_header){
10595 .dunu = cpu_to_le32(0xbadcafe)})[3] !=10556 .dunu = cpu_to_le32(0xbadcafe)})[3] !=
10596 cpu_to_le32(0xbadcafe));10557 cpu_to_le32(0xbadcafe));
10558
10559 BUILD_BUG_ON(((u8 *)&(struct utp_upiu_header){
10560 .iid = 0xf })[4] != 0xf0);
10561
10562 BUILD_BUG_ON(((u8 *)&(struct utp_upiu_header){
10563 .command_set_type = 0xf })[4] != 0xf);
10597}10564}
10598 10565
10599/*10566/*
include/uapi/scsi/scsi_bsg_ufs.h+49−3
@@ -8,6 +8,7 @@ · 7 unmodified lines
8#ifndef SCSI_BSG_UFS_H8#ifndef SCSI_BSG_UFS_H
9#define SCSI_BSG_UFS_H9#define SCSI_BSG_UFS_H
10 10
11#include <asm/byteorder.h>
11#include <linux/types.h>12#include <linux/types.h>
12/*13/*
13 * This file intended to be included by both kernel and user space14 * This file intended to be included by both kernel and user space
@@ -40,11 +41,56 @@ enum ufs_rpmb_op_type { · 26 unmodified lines
40 * @dword_0: UPIU header DW-041 * @dword_0: UPIU header DW-0
41 * @dword_1: UPIU header DW-142 * @dword_1: UPIU header DW-1
42 * @dword_2: UPIU header DW-243 * @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.
43 */61 */
44struct utp_upiu_header {62struct utp_upiu_header {
45 __be32 dword_0;63 union {
46 __be32 dword_1;64 struct {
47 __be32 dword_2;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 };
48};94};
49 95
50/**96/**
include/ufs/ufs.h+6−12
@@ -15,6 +15,12 @@ · 14 unmodified lines
15#include <linux/types.h>15#include <linux/types.h>
16#include <uapi/scsi/scsi_bsg_ufs.h>16#include <uapi/scsi/scsi_bsg_ufs.h>
17 17
18/*
19 * Using static_assert() is not allowed in UAPI header files. Hence the check
20 * in this header file of the size of struct utp_upiu_header.
21 */
22static_assert(sizeof(struct utp_upiu_header) == 12);
23
18#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))24#define GENERAL_UPIU_REQUEST_SIZE (sizeof(struct utp_upiu_req))
19#define QUERY_DESC_MAX_SIZE 25525#define QUERY_DESC_MAX_SIZE 255
20#define QUERY_DESC_MIN_SIZE 226#define QUERY_DESC_MIN_SIZE 2
@@ -23,11 +29,6 @@ · 2 unmodified lines
23 (sizeof(struct utp_upiu_header)))29 (sizeof(struct utp_upiu_header)))
24#define UFS_SENSE_SIZE 1830#define UFS_SENSE_SIZE 18
25 31
26static inline __be32 upiu_header_dword(u8 byte3, u8 byte2, u8 byte1, u8 byte0)
27{
28 return cpu_to_be32(byte3 << 24 | byte2 << 16 | byte1 << 8 | byte0);
29}
30
31/*32/*
32 * UFS device may have standard LUs and LUN id could be from 0x00 to33 * UFS device may have standard LUs and LUN id could be from 0x00 to
33 * 0x7F. Standard LUs use "Peripheral Device Addressing Format".34 * 0x7F. Standard LUs use "Peripheral Device Addressing Format".
@@ -477,14 +478,7 @@ enum { · 443 unmodified lines
477#define UPIU_RSP_CODE_OFFSET 8478#define UPIU_RSP_CODE_OFFSET 8
478 479
479enum {480enum {
480 MASK_SCSI_STATUS = 0xFF,
481 MASK_TASK_RESPONSE = 0xFF00,
482 MASK_RSP_UPIU_RESULT = 0xFFFF,
483 MASK_QUERY_DATA_SEG_LEN = 0xFFFF,
484 MASK_RSP_UPIU_DATA_SEG_LEN = 0xFFFF,
485 MASK_RSP_EXCEPTION_EVENT = 0x10000,
486 MASK_TM_SERVICE_RESP = 0xFF,481 MASK_TM_SERVICE_RESP = 0xFF,
487 MASK_TM_FUNC = 0xFF,
488};482};
489 483
490/* Task management service response */484/* Task management service response */

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