Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 May 2009 14:11:24 GMT
From:      Alexander Motin <mav@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 162644 for review
Message-ID:  <200905241411.n4OEBOgk049244@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=162644

Change 162644 by mav@mav_mavbook on 2009/05/24 14:10:43

	Add initial ATA XPT and ATA disk devices. It allows CAM to operate
	SIMs with XPORT_ATA transport type and devices with PROTO_ATA protocol.
	To send ATA commands new opcode XPT_ATA_IO added to xpt_action.
	
	Teach SCSI drivers do not try to attach to ATA devices.
	The only exception now is pass driver, I am just not sure.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.c#1 add
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_all.h#1 add
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_da.c#1 add
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.c#1 add
.. //depot/projects/scottl-camlock/src/sys/cam/ata/ata_xpt.h#1 add
.. //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#16 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#87 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_internal.h#2 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#24 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#16 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#39 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.c#12 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#18 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.c#19 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sg.c#12 edit

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#16 (text+ko) ====

@@ -40,6 +40,7 @@
 #endif
 #include <cam/cam_debug.h>
 #include <cam/scsi/scsi_all.h>
+#include <cam/ata/ata_all.h>
 
 
 /* General allocation length definitions for CCB structures */
@@ -169,6 +170,8 @@
 				 * a device give the sector size and
 				 * volume size.
 				 */
+	XPT_ATA_IO		= 0x18 | XPT_FC_DEV_QUEUED,
+				/* Execute the requested ATA I/O operation */
 
 /* HBA engine commands 0x20->0x2F */
 	XPT_ENG_INQ		= 0x20 | XPT_FC_XPT_ONLY,
@@ -284,7 +287,9 @@
 /* Get Device Information CCB */
 struct ccb_getdev {
 	struct	  ccb_hdr ccb_h;
+	cam_proto protocol;
 	struct scsi_inquiry_data inq_data;
+	struct ata_params ident_data;
 	u_int8_t  serial_num[252];
 	u_int8_t  reserved;
 	u_int8_t  serial_num_len;
@@ -412,7 +417,9 @@
 	path_id_t			path_id;
 	target_id_t			target_id;
 	lun_id_t			target_lun;
+	cam_proto			protocol;
 	struct scsi_inquiry_data	inq_data;
+	struct ata_params		ident_data;
 	dev_result_flags		flags;
 };
 
@@ -617,6 +624,31 @@
 	u_int	   init_id;		/* initiator id of who selected */
 };
 
+/*
+ * ATA I/O Request CCB used for the XPT_ATA_IO function code.
+ */
+struct ccb_ataio {
+	struct	   ccb_hdr ccb_h;
+	union	   ccb *next_ccb;	/* Ptr for next CCB for action */
+	u_int8_t   *req_map;		/* Ptr to mapping info */
+	struct ata_cmd	cmd;
+	u_int8_t   *data_ptr;		/* Ptr to the data buf/SG list */
+	u_int32_t  dxfer_len;		/* Data transfer length */
+					/* Autosense storage */	
+	u_int16_t  sglist_cnt;		/* Number of SG list entries */
+	u_int8_t   status;		/* Returned ATA status */
+	u_int32_t  resid;		/* Transfer residual length: 2's comp */
+	u_int8_t   tag_action;		/* What to do for tag queueing */
+	/*
+	 * The tag action should be either the define below (to send a
+	 * non-tagged transaction) or one of the defined scsi tag messages
+	 * from scsi_message.h.
+	 */
+#define		CAM_TAG_ACTION_NONE	0x00
+	u_int	   tag_id;		/* tag id from initator (target mode) */
+	u_int	   init_id;		/* initiator id of who selected */
+};
+
 struct ccb_accept_tio {
 	struct	   ccb_hdr ccb_h;
 	cdb_t	   cdb_io;		/* Union for CDB bytes/pointer */
@@ -907,6 +939,7 @@
 	struct	ccb_eng_exec		cee;
 	struct 	ccb_rescan		crcn;
 	struct  ccb_debug		cdbg;
+	struct	ccb_ataio		ataio;
 };
 
 __BEGIN_DECLS
@@ -924,7 +957,14 @@
 	      u_int32_t flags, u_int tag_action, u_int tag_id,
 	      u_int init_id, u_int scsi_status, u_int8_t *data_ptr,
 	      u_int32_t dxfer_len, u_int32_t timeout);
-	
+
+static __inline void
+cam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries,
+	      void (*cbfcnp)(struct cam_periph *, union ccb *),
+	      u_int32_t flags, u_int tag_action,
+	      u_int8_t *data_ptr, u_int32_t dxfer_len,
+	      u_int32_t timeout);
+
 static __inline void
 cam_fill_csio(struct ccb_scsiio *csio, u_int32_t retries,
 	      void (*cbfcnp)(struct cam_periph *, union ccb *),
@@ -965,6 +1005,23 @@
 	csio->init_id = init_id;
 }
 
+static __inline void
+cam_fill_ataio(struct ccb_ataio *ataio, u_int32_t retries,
+	      void (*cbfcnp)(struct cam_periph *, union ccb *),
+	      u_int32_t flags, u_int tag_action,
+	      u_int8_t *data_ptr, u_int32_t dxfer_len,
+	      u_int32_t timeout)
+{
+	ataio->ccb_h.func_code = XPT_ATA_IO;
+	ataio->ccb_h.flags = flags;
+	ataio->ccb_h.retry_count = retries;
+	ataio->ccb_h.cbfcnp = cbfcnp;
+	ataio->ccb_h.timeout = timeout;
+	ataio->data_ptr = data_ptr;
+	ataio->dxfer_len = dxfer_len;
+	ataio->tag_action = tag_action;
+}
+
 void cam_calc_geometry(struct ccb_calc_geometry *ccg, int extended);
 
 __END_DECLS

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#87 (text+ko) ====

@@ -1686,9 +1686,14 @@
 			device->target->target_id;
 		cdm->matches[j].result.device_result.target_lun =
 			device->lun_id;
+		cdm->matches[j].result.device_result.protocol =
+			device->protocol;
 		bcopy(&device->inq_data,
 		      &cdm->matches[j].result.device_result.inq_data,
 		      sizeof(struct scsi_inquiry_data));
+		bcopy(&device->ident_data,
+		      &cdm->matches[j].result.device_result.ident_data,
+		      sizeof(struct ata_params));
 
 		/* Let the user know whether this device is unconfigured */
 		if (device->flags & CAM_DEV_UNCONFIGURED)
@@ -2446,6 +2451,10 @@
 		start_ccb->csio.sense_resid = 0;
 		start_ccb->csio.resid = 0;
 		/* FALLTHROUGH */
+	case XPT_ATA_IO:
+		if (start_ccb->ccb_h.func_code == XPT_ATA_IO) {
+			start_ccb->ataio.status = 0;
+		}
 	case XPT_RESET_DEV:
 	case XPT_ENG_EXEC:
 	{
@@ -2584,7 +2593,9 @@
 			cgd = &start_ccb->cgd;
 			bus = cgd->ccb_h.path->bus;
 			tar = cgd->ccb_h.path->target;
+			cgd->protocol = dev->protocol;
 			cgd->inq_data = dev->inq_data;
+			cgd->ident_data = dev->ident_data;
 			cgd->ccb_h.status = CAM_REQ_CMP;
 			cgd->serial_num_len = dev->serial_num_len;
 			if ((dev->serial_num_len > 0)
@@ -3782,8 +3793,12 @@
 		case XPORT_SPI:
 		case XPORT_SAS:
 		case XPORT_FC:
+		case XPORT_USB:
 			new_bus->xport = scsi_get_xport();
 			break;
+		case XPORT_ATA:
+			new_bus->xport = ata_get_xport();
+			break;
 		default:
 			new_bus->xport = &xport_default;
 			break;

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_internal.h#2 (text+ko) ====

@@ -64,6 +64,7 @@
 	cam_xport	 transport;
 	u_int		 transport_version;
 	struct		 scsi_inquiry_data inq_data;
+	struct		 ata_params ident_data;
 	u_int8_t	 inq_flags;	/*
 					 * Current settings for inquiry flags.
 					 * This allows us to override settings
@@ -134,6 +135,7 @@
 };
 
 struct xpt_xport *	scsi_get_xport(void);
+struct xpt_xport *	ata_get_xport(void);
 
 struct cam_ed *		xpt_alloc_device(struct cam_eb *bus,
 					 struct cam_et *target,

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#24 (text+ko) ====

@@ -496,6 +496,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		if (SID_TYPE(&cgd->inq_data) != T_CDROM
 		    && SID_TYPE(&cgd->inq_data) != T_WORM)
 			break;

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#16 (text+ko) ====

@@ -287,6 +287,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		if (SID_TYPE(&cgd->inq_data)!= T_CHANGER)
 			break;
 

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#39 (text+ko) ====

@@ -1028,6 +1028,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		if (SID_TYPE(&cgd->inq_data) != T_DIRECT
 		    && SID_TYPE(&cgd->inq_data) != T_RBC
 		    && SID_TYPE(&cgd->inq_data) != T_OPTICAL)

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.c#12 (text+ko) ====

@@ -366,6 +366,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		if (SID_TYPE(&cgd->inq_data) != T_PROCESSOR)
 			break;
 

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#18 (text+ko) ====

@@ -1398,6 +1398,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		if (SID_TYPE(&cgd->inq_data) != T_SEQUENTIAL)
 			break;
 

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.c#19 (text+ko) ====

@@ -251,6 +251,9 @@
 			break;
 		}
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		inq_len = cgd->inq_data.additional_length + 4;
 
 		/*

==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sg.c#12 (text+ko) ====

@@ -226,6 +226,9 @@
 		if (cgd == NULL)
 			break;
 
+		if (cgd->protocol != PROTO_SCSI)
+			break;
+
 		/*
 		 * Allocate a peripheral instance for this device and
 		 * start the probe process.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905241411.n4OEBOgk049244>