isci: Convert SATA fis data structures to Linux native

Converting of sata_fis_reg_d2h to dev_to_host_fis
Converting of sata_fis_reg_h2d to host_to_dev_fis

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
diff --git a/drivers/scsi/isci/core/intel_sata.h b/drivers/scsi/isci/core/intel_sata.h
index 47390d5..977354d 100644
--- a/drivers/scsi/isci/core/intel_sata.h
+++ b/drivers/scsi/isci/core/intel_sata.h
@@ -101,62 +101,6 @@
 	u32 error:8;
 };
 
-
-/**
- * struct sata_fis_reg_h2d - This is the definition for a SATA Host to Device
- *    Register FIS.
- *
- *
- */
-struct sata_fis_reg_h2d {
-	u32 fis_type:8; /* word 0 */
-	u32 pm_port:4;
-	u32 reserved0:3;
-	u32 command_flag:1;
-	u32 command:8;
-	u32 features:8;
-	u32 lba_low:8; /* word 1 */
-	u32 lba_mid:8;
-	u32 lba_high:8;
-	u32 device:8;
-	u32 lba_low_exp:8; /* word 2 */
-	u32 lba_mid_exp:8;
-	u32 lba_high_exp:8;
-	u32 features_exp:8;
-	u32 sector_count:8; /* word 3 */
-	u32 sector_count_exp:8;
-	u32 reserved1:8;
-	u32 control:8;
-	u32 reserved2;          /* word 4 */
-};
-
-/**
- * struct sata_fis_reg_d2h - SATA Device To Host FIS
- *
- *
- */
-struct sata_fis_reg_d2h {
-	u32 fis_type:8;   /* word 0 */
-	u32 pm_port:4;
-	u32 reserved0:2;
-	u32 irq:1;
-	u32 reserved1:1;
-	u32 status:8;
-	u32 error:8;
-	u8 lba_low;          /* word 1 */
-	u8 lba_mid;
-	u8 lba_high;
-	u8 device;
-	u8 lba_low_exp;      /* word 2 */
-	u8 lba_mid_exp;
-	u8 lba_high_exp;
-	u8 reserved;
-	u8 sector_count;     /* word 3 */
-	u8 sector_count_exp;
-	u16 reserved2;
-	u32 reserved3;
-};
-
 /**
  *
  *
diff --git a/drivers/scsi/isci/core/scic_phy.h b/drivers/scsi/isci/core/scic_phy.h
index 784c5b5..6fe39cce 100644
--- a/drivers/scsi/isci/core/scic_phy.h
+++ b/drivers/scsi/isci/core/scic_phy.h
@@ -64,11 +64,11 @@
  */
 
 
+#include <scsi/sas.h>
+#include <scsi/libsas.h>
 #include "sci_status.h"
-
 #include "intel_sata.h"
 #include "intel_sas.h"
-#include <scsi/libsas.h>
 
 struct scic_sds_phy;
 struct scic_sds_port;
@@ -141,7 +141,7 @@
 	 * This field delineates the signature FIS received from the
 	 * attached target.
 	 */
-	struct sata_fis_reg_d2h signature_fis;
+	struct dev_to_host_fis signature_fis;
 
 	/**
 	 * This field specifies to the user if a port selector is connected
diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c
index d7c37dc..0b76fc7 100644
--- a/drivers/scsi/isci/core/scic_sds_controller.c
+++ b/drivers/scsi/isci/core/scic_sds_controller.c
@@ -54,6 +54,7 @@
  */
 
 #include <linux/device.h>
+#include <scsi/sas.h>
 #include "scic_controller.h"
 #include "scic_phy.h"
 #include "scic_port.h"
@@ -1754,17 +1755,11 @@
 	void *frame_header,
 	void *frame_buffer)
 {
-	memcpy(
-		response_buffer,
-		frame_header,
-		sizeof(u32)
-		);
+	memcpy(response_buffer, frame_header, sizeof(u32));
 
-	memcpy(
-		(char *)((char *)response_buffer + sizeof(u32)),
-		frame_buffer,
-		sizeof(struct sata_fis_reg_d2h) - sizeof(u32)
-		);
+	memcpy(response_buffer + sizeof(u32),
+	       frame_buffer,
+	       sizeof(struct dev_to_host_fis) - sizeof(u32));
 }
 
 /**
diff --git a/drivers/scsi/isci/core/scic_sds_phy.c b/drivers/scsi/isci/core/scic_sds_phy.c
index c935c04..1b35b1a 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.c
+++ b/drivers/scsi/isci/core/scic_sds_phy.c
@@ -53,6 +53,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <scsi/sas.h>
 #include "intel_ata.h"
 #include "intel_sata.h"
 #include "sci_base_state.h"
@@ -620,11 +621,9 @@
 	struct scic_sata_phy_properties *properties)
 {
 	if (sci_phy->protocol == SCIC_SDS_PHY_PROTOCOL_SATA) {
-		memcpy(
-			&properties->signature_fis,
-			&sci_phy->phy_type.sata.signature_fis_buffer,
-			sizeof(struct sata_fis_reg_d2h)
-			);
+		memcpy(&properties->signature_fis,
+		       &sci_phy->phy_type.sata.signature_fis_buffer,
+		       sizeof(struct dev_to_host_fis));
 
 		/* / @todo add support for port selectors. */
 		properties->is_port_selector_present = false;
diff --git a/drivers/scsi/isci/core/scic_sds_phy.h b/drivers/scsi/isci/core/scic_sds_phy.h
index fca95c1..c9fa207 100644
--- a/drivers/scsi/isci/core/scic_sds_phy.h
+++ b/drivers/scsi/isci/core/scic_sds_phy.h
@@ -280,7 +280,7 @@
 		} sas;
 
 		struct {
-			struct sata_fis_reg_d2h signature_fis_buffer;
+			struct dev_to_host_fis signature_fis_buffer;
 
 		} sata;
 
diff --git a/drivers/scsi/isci/core/scic_sds_request.c b/drivers/scsi/isci/core/scic_sds_request.c
index ffc1607..1306765 100644
--- a/drivers/scsi/isci/core/scic_sds_request.c
+++ b/drivers/scsi/isci/core/scic_sds_request.c
@@ -53,7 +53,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
+#include <scsi/sas.h>
 #include "intel_sas.h"
 #include "intel_sata.h"
 #include "intel_sat.h"
@@ -1742,7 +1742,7 @@
 		scic_sds_ssp_io_request_assign_buffers(sci_req);
 	} else if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) {
 		scic_sds_stp_request_assign_buffers(sci_req);
-		memset(sci_req->command_buffer, 0, sizeof(struct sata_fis_reg_h2d));
+		memset(sci_req->command_buffer, 0, sizeof(struct host_to_dev_fis));
 	} else if (dev_is_expander(dev)) {
 		scic_sds_smp_request_assign_buffers(sci_req);
 		memset(sci_req->command_buffer, 0, sizeof(struct smp_request));
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.c b/drivers/scsi/isci/core/scic_sds_stp_request.c
index 8c98023..1cd111c 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.c
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.c
@@ -79,7 +79,7 @@
  * request memory
  */
 #define scic_sds_stp_request_get_h2d_reg_buffer(memory)	\
-	((struct sata_fis_reg_h2d *)(\
+	((struct host_to_dev_fis *)(\
 		 ((char *)(memory)) + sizeof(struct scic_sds_stp_request) \
 		 ))
 
@@ -90,9 +90,9 @@
  * request memory
  */
 #define scic_sds_stp_request_get_response_buffer(memory) \
-	((struct sata_fis_reg_d2h *)(\
+	((struct dev_to_host_fis *)(\
 		 ((char *)(scic_sds_stp_request_get_h2d_reg_buffer(memory))) \
-		 + sizeof(struct sata_fis_reg_h2d) \
+		 + sizeof(struct host_to_dev_fis) \
 		 ))
 
 /**
@@ -127,8 +127,8 @@
 u32 scic_sds_stp_request_get_object_size(void)
 {
 	return sizeof(struct scic_sds_stp_request)
-	       + sizeof(struct sata_fis_reg_h2d)
-	       + sizeof(struct sata_fis_reg_d2h)
+	       + sizeof(struct host_to_dev_fis)
+	       + sizeof(struct dev_to_host_fis)
 	       + sizeof(struct scu_task_context)
 	       + SMP_CACHE_BYTES
 	       + sizeof(struct scu_sgl_element_pair) * SCU_MAX_SGL_ELEMENT_PAIRS;
@@ -205,7 +205,7 @@
 	task_context->task_phase = 0x01;
 
 	task_context->ssp_command_iu_length =
-		(sizeof(struct sata_fis_reg_h2d) - sizeof(u32)) / sizeof(u32);
+		(sizeof(struct host_to_dev_fis) - sizeof(u32)) / sizeof(u32);
 
 	/* Set the first word of the H2D REG FIS */
 	task_context->type.words[0] = *(u32 *)sds_request->command_buffer;
@@ -354,7 +354,8 @@
 	task_context->priority              = SCU_TASK_PRIORITY_NORMAL;
 	task_context->task_type             = SCU_TASK_TYPE_SATA_RAW_FRAME;
 	task_context->type.stp.fis_type     = SATA_FIS_TYPE_REGH2D;
-	task_context->transfer_length_bytes = sizeof(struct sata_fis_reg_h2d) - sizeof(u32);
+	task_context->transfer_length_bytes =
+		sizeof(struct host_to_dev_fis) - sizeof(u32);
 }
 
 void scic_stp_io_request_set_ncq_tag(
@@ -1749,7 +1750,7 @@
 {
 	struct scic_sds_request *sci_req = object;
 	struct scu_task_context *task_context;
-	struct sata_fis_reg_h2d *h2d_fis;
+	struct host_to_dev_fis *h2d_fis;
 	enum sci_status status;
 
 	/* Clear the SRST bit */
diff --git a/drivers/scsi/isci/core/scic_sds_stp_request.h b/drivers/scsi/isci/core/scic_sds_stp_request.h
index 6724c1d..807bc4e 100644
--- a/drivers/scsi/isci/core/scic_sds_stp_request.h
+++ b/drivers/scsi/isci/core/scic_sds_stp_request.h
@@ -69,7 +69,7 @@
 struct scic_sds_stp_request {
 	struct scic_sds_request parent;
 
-	struct sata_fis_reg_d2h d2h_reg_fis;
+	struct dev_to_host_fis d2h_reg_fis;
 
 	union {
 		u32 ncq;
diff --git a/drivers/scsi/isci/phy.h b/drivers/scsi/isci/phy.h
index 44b727f..3fe1a8a 100644
--- a/drivers/scsi/isci/phy.h
+++ b/drivers/scsi/isci/phy.h
@@ -59,6 +59,7 @@
 
 #include "port.h"
 #include "host.h"
+#include <scsi/sas.h>
 #include <scsi/libsas.h>
 
 
@@ -79,10 +80,8 @@
 	u8 sas_addr[SAS_ADDR_SIZE];
 
 	union {
-
 		u8 aif[sizeof(struct sci_sas_identify_address_frame)];
-		u8 fis[sizeof(struct sata_fis_reg_d2h)];
-
+		struct dev_to_host_fis fis;
 	} frame_rcvd;
 };
 
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c
index 30d6ad8..5b38f2f 100644
--- a/drivers/scsi/isci/port.c
+++ b/drivers/scsi/isci/port.c
@@ -205,11 +205,8 @@
 		 */
 		BUG_ON(call_status != SCI_SUCCESS);
 
-		memcpy(isci_phy->frame_rcvd.fis,
-		       &sata_phy_properties.signature_fis,
-		       sizeof(struct sata_fis_reg_d2h));
-
-		isci_phy->sas_phy.frame_rcvd_size = sizeof(struct sata_fis_reg_d2h);
+		isci_phy->frame_rcvd.fis = sata_phy_properties.signature_fis;
+		isci_phy->sas_phy.frame_rcvd_size = sizeof(struct dev_to_host_fis);
 
 		/*
 		 * For direct-attached SATA devices, the SCI core will
diff --git a/drivers/scsi/isci/sata.c b/drivers/scsi/isci/sata.c
index 53ce0c2..0837450 100644
--- a/drivers/scsi/isci/sata.c
+++ b/drivers/scsi/isci/sata.c
@@ -53,6 +53,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <scsi/sas.h>
 #include "isci.h"
 #include "remote_device.h"
 #include "scic_io_request.h"
@@ -142,11 +143,10 @@
  *
  * none.
  */
-void isci_request_process_stp_response(
-	struct sas_task *task,
-	void *response_buffer)
+void isci_request_process_stp_response(struct sas_task *task,
+				       void *response_buffer)
 {
-	struct sata_fis_reg_d2h *d2h_reg_fis = (struct sata_fis_reg_d2h *)response_buffer;
+	struct dev_to_host_fis *d2h_reg_fis = response_buffer;
 	struct task_status_struct *ts = &task->task_status;
 	struct ata_task_resp *resp = (void *)&ts->buf[0];
 
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 95f3867..f9a1c41 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -1452,10 +1452,8 @@
 
 		memcpy(&tmf->resp.d2h_fis,
 		       scic_stp_io_request_get_d2h_reg_address(
-			       request->sci_request_handle
-			       ),
-		       sizeof(struct sata_fis_reg_d2h)
-		       );
+			       request->sci_request_handle),
+		       sizeof(struct dev_to_host_fis));
 	}
 
 	/* Manage the timer if it is still running. */