From owner-svn-src-all@freebsd.org Thu Oct 6 01:14:11 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F21FAF65F3; Thu, 6 Oct 2016 01:14:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 30812ADB; Thu, 6 Oct 2016 01:14:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u961EAHL010090; Thu, 6 Oct 2016 01:14:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u961EAET010088; Thu, 6 Oct 2016 01:14:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201610060114.u961EAET010088@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 6 Oct 2016 01:14:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r306747 - head/sys/cam X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Oct 2016 01:14:11 -0000 Author: mav Date: Thu Oct 6 01:14:10 2016 New Revision: 306747 URL: https://svnweb.freebsd.org/changeset/base/306747 Log: Fix ABI compat shims, broken by adding NVMe support. MFC after: 1 week Modified: head/sys/cam/cam_compat.c head/sys/cam/cam_compat.h Modified: head/sys/cam/cam_compat.c ============================================================================== --- head/sys/cam/cam_compat.c Thu Oct 6 01:01:00 2016 (r306746) +++ head/sys/cam/cam_compat.c Thu Oct 6 01:14:10 2016 (r306747) @@ -149,7 +149,24 @@ cam_compat_handle_0x17(struct cdev *dev, ccbb = (uint8_t *)&hdr[1]; ccbb17 = (uint8_t *)&hdr17[1]; - bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN); + if (ccb->ccb_h.func_code == XPT_SET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x17 *cts17; + + cts = &ccb->cts; + cts17 = (struct ccb_trans_settings_0x17 *)hdr17; + cts->type = cts17->type; + cts->protocol = cts17->protocol; + cts->protocol_version = cts17->protocol_version; + cts->transport = cts17->transport; + cts->transport_version = cts17->transport_version; + bcopy(&cts17->proto_specific, &cts->proto_specific, + sizeof(cts17->proto_specific)); + bcopy(&cts17->xport_specific, &cts->xport_specific, + sizeof(cts17->xport_specific)); + } else { + bcopy(ccbb17, ccbb, CAM_0X17_DATA_LEN); + } error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); @@ -205,6 +222,21 @@ cam_compat_handle_0x17(struct cdev *dev, cpi17->hba_device = cpi->hba_device; cpi17->hba_subvendor = cpi->hba_subvendor; cpi17->hba_subdevice = cpi->hba_subdevice; + } else if (ccb->ccb_h.func_code == XPT_GET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x17 *cts17; + + cts = &ccb->cts; + cts17 = (struct ccb_trans_settings_0x17 *)hdr17; + cts17->type = cts17->type; + cts17->protocol = cts->protocol; + cts17->protocol_version = cts->protocol_version; + cts17->transport = cts->transport; + cts17->transport_version = cts->transport_version; + bcopy(&cts->proto_specific, &cts17->proto_specific, + sizeof(cts17->proto_specific)); + bcopy(&cts->xport_specific, &cts17->xport_specific, + sizeof(cts17->xport_specific)); } else if (ccb->ccb_h.func_code == XPT_DEV_MATCH) { /* Copy the rest of the header over */ bcopy(ccbb, ccbb17, CAM_0X17_DATA_LEN); @@ -257,7 +289,24 @@ cam_compat_handle_0x18(struct cdev *dev, ccbb = (uint8_t *)&hdr[1]; ccbb18 = (uint8_t *)&hdr18[1]; - bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN); + if (ccb->ccb_h.func_code == XPT_SET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x18 *cts18; + + cts = &ccb->cts; + cts18 = (struct ccb_trans_settings_0x18 *)hdr18; + cts->type = cts18->type; + cts->protocol = cts18->protocol; + cts->protocol_version = cts18->protocol_version; + cts->transport = cts18->transport; + cts->transport_version = cts18->transport_version; + bcopy(&cts18->proto_specific, &cts->proto_specific, + sizeof(cts18->proto_specific)); + bcopy(&cts18->xport_specific, &cts->xport_specific, + sizeof(cts18->xport_specific)); + } else { + bcopy(ccbb18, ccbb, CAM_0X18_DATA_LEN); + } error = (cbfnp)(dev, cmd, (caddr_t)ccb, flag, td); @@ -280,10 +329,27 @@ cam_compat_handle_0x18(struct cdev *dev, hdr18->sim_priv = hdr->sim_priv; hdr18->timeout = hdr->timeout; - bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); - - if (ccb->ccb_h.func_code == XPT_DEV_MATCH) + if (ccb->ccb_h.func_code == XPT_GET_TRAN_SETTINGS) { + struct ccb_trans_settings *cts; + struct ccb_trans_settings_0x18 *cts18; + + cts = &ccb->cts; + cts18 = (struct ccb_trans_settings_0x18 *)hdr18; + cts18->type = cts18->type; + cts18->protocol = cts->protocol; + cts18->protocol_version = cts->protocol_version; + cts18->transport = cts->transport; + cts18->transport_version = cts->transport_version; + bcopy(&cts->proto_specific, &cts18->proto_specific, + sizeof(cts18->proto_specific)); + bcopy(&cts->xport_specific, &cts18->xport_specific, + sizeof(cts18->xport_specific)); + } else if (ccb->ccb_h.func_code == XPT_DEV_MATCH) { + bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); cam_compat_translate_dev_match_0x18(ccb); + } else { + bcopy(ccbb, ccbb18, CAM_0X18_DATA_LEN); + } xpt_free_ccb(ccb); Modified: head/sys/cam/cam_compat.h ============================================================================== --- head/sys/cam/cam_compat.h Thu Oct 6 01:01:00 2016 (r306746) +++ head/sys/cam/cam_compat.h Thu Oct 6 01:14:10 2016 (r306747) @@ -43,8 +43,8 @@ int cam_compat_ioctl(struct cdev *dev, u #define CAM_VERSION_0x16 0x16 /* The size of the union ccb didn't change when going to 0x17 */ -#define CAMIOCOMMAND_0x16 _IOWR(CAM_VERSION_0x16, 2, union ccb) -#define CAMGETPASSTHRU_0x16 _IOWR(CAM_VERSION_0x16, 3, union ccb) +#define CAMIOCOMMAND_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 2, CAM_0X17_LEN) +#define CAMGETPASSTHRU_0x16 _IOC(IOC_INOUT, CAM_VERSION_0x16, 3, CAM_0X17_LEN) #define CAM_SCATTER_VALID_0x16 0x00000010 #define CAM_SG_LIST_PHYS_0x16 0x00040000 @@ -110,8 +110,30 @@ struct ccb_pathinq_0x17 { u_int16_t hba_subdevice; /* HBA subdevice ID */ }; -#define CAM_0X17_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x17)) -#define CAM_0X17_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x17)) +struct ccb_trans_settings_0x17 { + struct ccb_hdr_0x17 ccb_h; + cts_type type; /* Current or User settings */ + cam_proto protocol; + u_int protocol_version; + cam_xport transport; + u_int transport_version; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_ata ata; + struct ccb_trans_settings_scsi scsi; + } proto_specific; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_spi spi; + struct ccb_trans_settings_fc fc; + struct ccb_trans_settings_sas sas; + struct ccb_trans_settings_pata ata; + struct ccb_trans_settings_sata sata; + } xport_specific; +}; + +#define CAM_0X17_DATA_LEN CAM_0X18_DATA_LEN +#define CAM_0X17_LEN (sizeof(struct ccb_hdr_0x17) + CAM_0X17_DATA_LEN) #define CAMIOCOMMAND_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 2, CAM_0X17_LEN) #define CAMGETPASSTHRU_0x17 _IOC(IOC_INOUT, CAM_VERSION_0x17, 3, CAM_0X17_LEN) @@ -146,6 +168,28 @@ typedef enum { CAM_EXTLUN_VALID_0x18 = 0x00000001,/* 64bit lun field is valid */ } ccb_xflags_0x18; +struct ccb_trans_settings_0x18 { + struct ccb_hdr_0x18 ccb_h; + cts_type type; /* Current or User settings */ + cam_proto protocol; + u_int protocol_version; + cam_xport transport; + u_int transport_version; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_ata ata; + struct ccb_trans_settings_scsi scsi; + } proto_specific; + union { + u_int valid; /* Which fields to honor */ + struct ccb_trans_settings_spi spi; + struct ccb_trans_settings_fc fc; + struct ccb_trans_settings_sas sas; + struct ccb_trans_settings_pata ata; + struct ccb_trans_settings_sata sata; + } xport_specific; +}; + struct dev_match_result_0x18 { dev_match_type type; union { @@ -169,8 +213,8 @@ struct dev_match_result_0x18 { } result; }; -#define CAM_0X18_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr) + sizeof(struct ccb_hdr_0x18)) -#define CAM_0X18_DATA_LEN (sizeof(union ccb) - sizeof(struct ccb_hdr_0x18)) +#define CAM_0X18_DATA_LEN (sizeof(union ccb) - 2*sizeof(void *) - sizeof(struct ccb_hdr)) +#define CAM_0X18_LEN (sizeof(struct ccb_hdr_0x18) + CAM_0X18_DATA_LEN) #define CAMIOCOMMAND_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 2, CAM_0X18_LEN) #define CAMGETPASSTHRU_0x18 _IOC(IOC_INOUT, CAM_VERSION_0x18, 3, CAM_0X18_LEN)