Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 2013 16:25:53 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256276 - in head/sys/dev/hyperv: storvsc vmbus
Message-ID:  <201310101625.r9AGPruq026761@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Thu Oct 10 16:25:53 2013
New Revision: 256276
URL: http://svnweb.freebsd.org/changeset/base/256276

Log:
  In sys/dev/hyperv, fix a number of gcc warnings about usage of anonymous
  union members in strict C99, by giving them names.  While here, add some
  FreeBSD keywords where they were missing.
  
  Approved by:	re (gjb)
  Reviewed by:	grehan

Modified:
  head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
  head/sys/dev/hyperv/storvsc/hv_vstorage.h
  head/sys/dev/hyperv/vmbus/hv_channel.c
  head/sys/dev/hyperv/vmbus/hv_hv.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h

Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c	Thu Oct 10 16:25:53 2013	(r256276)
@@ -32,6 +32,8 @@
  * converted into VSCSI protocol messages which are delivered to the parent
  * partition StorVSP driver over the Hyper-V VMBUS.
  */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -322,10 +324,10 @@ hv_storvsc_channel_init(struct hv_device
 	vstor_packet->operation = VSTOR_OPERATION_QUERYPROTOCOLVERSION;
 	vstor_packet->flags = REQUEST_COMPLETION_FLAG;
 
-	vstor_packet->version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
+	vstor_packet->u.version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
 
 	/* revision is only significant for Windows guests */
-	vstor_packet->version.revision = 0;
+	vstor_packet->u.version.revision = 0;
 
 	ret = hv_vmbus_channel_send_packet(
 			dev->channel,
@@ -532,11 +534,11 @@ hv_storvsc_io_request(struct hv_device *
 
 	vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
 
-	vstor_packet->vm_srb.length = sizeof(struct vmscsi_req);
+	vstor_packet->u.vm_srb.length = sizeof(struct vmscsi_req);
 	
-	vstor_packet->vm_srb.sense_info_len = SENSE_BUFFER_SIZE;
+	vstor_packet->u.vm_srb.sense_info_len = SENSE_BUFFER_SIZE;
 
-	vstor_packet->vm_srb.transfer_len = request->data_buf.length;
+	vstor_packet->u.vm_srb.transfer_len = request->data_buf.length;
 
 	vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB;
 
@@ -583,7 +585,7 @@ hv_storvsc_on_iocompletion(struct storvs
 {
 	struct vmscsi_req *vm_srb;
 
-	vm_srb = &vstor_packet->vm_srb;
+	vm_srb = &vstor_packet->u.vm_srb;
 
 	request->sense_info_len = 0;
 	if (((vm_srb->scsi_status & 0xFF) == SCSI_STATUS_CHECK_COND) &&
@@ -594,7 +596,7 @@ hv_storvsc_on_iocompletion(struct storvs
 				("vm_srb->sense_info_len <= "
 				 "request->sense_info_len"));
 
-		memcpy(request->sense_data, vm_srb->sense_data,
+		memcpy(request->sense_data, vm_srb->u.sense_data,
 			vm_srb->sense_info_len);
 
 		request->sense_info_len = vm_srb->sense_info_len;
@@ -1298,35 +1300,35 @@ create_storvsc_request(union ccb *ccb, s
 	uint32_t pfn;
 	
 	/* refer to struct vmscsi_req for meanings of these two fields */
-	reqp->vstor_packet.vm_srb.port =
+	reqp->vstor_packet.u.vm_srb.port =
 		cam_sim_unit(xpt_path_sim(ccb->ccb_h.path));
-	reqp->vstor_packet.vm_srb.path_id =
+	reqp->vstor_packet.u.vm_srb.path_id =
 		cam_sim_bus(xpt_path_sim(ccb->ccb_h.path));
 
-	reqp->vstor_packet.vm_srb.target_id = ccb->ccb_h.target_id;
-	reqp->vstor_packet.vm_srb.lun = ccb->ccb_h.target_lun;
+	reqp->vstor_packet.u.vm_srb.target_id = ccb->ccb_h.target_id;
+	reqp->vstor_packet.u.vm_srb.lun = ccb->ccb_h.target_lun;
 
-	reqp->vstor_packet.vm_srb.cdb_len = csio->cdb_len;
+	reqp->vstor_packet.u.vm_srb.cdb_len = csio->cdb_len;
 	if(ccb->ccb_h.flags & CAM_CDB_POINTER) {
-		memcpy(&reqp->vstor_packet.vm_srb.cdb, csio->cdb_io.cdb_ptr,
+		memcpy(&reqp->vstor_packet.u.vm_srb.u.cdb, csio->cdb_io.cdb_ptr,
 			csio->cdb_len);
 	} else {
-		memcpy(&reqp->vstor_packet.vm_srb.cdb, csio->cdb_io.cdb_bytes,
+		memcpy(&reqp->vstor_packet.u.vm_srb.u.cdb, csio->cdb_io.cdb_bytes,
 			csio->cdb_len);
 	}
 
 	switch (ccb->ccb_h.flags & CAM_DIR_MASK) {
     	case CAM_DIR_OUT: 
-    		reqp->vstor_packet.vm_srb.data_in = WRITE_TYPE;
+    		reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE;
     		break;
     	case CAM_DIR_IN:
-    		reqp->vstor_packet.vm_srb.data_in = READ_TYPE;
+    		reqp->vstor_packet.u.vm_srb.data_in = READ_TYPE;
     		break;
     	case CAM_DIR_NONE:
-    		reqp->vstor_packet.vm_srb.data_in = UNKNOWN_TYPE;
+    		reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
     		break;
     	default:
-    		reqp->vstor_packet.vm_srb.data_in = UNKNOWN_TYPE;
+    		reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
     		break;
 	}
 
@@ -1375,7 +1377,7 @@ storvsc_io_done(struct hv_storvsc_reques
 	union ccb *ccb = reqp->ccb;
 	struct ccb_scsiio *csio = &ccb->csio;
 	struct storvsc_softc *sc = reqp->softc;
-	struct vmscsi_req *vm_srb = &reqp->vstor_packet.vm_srb;
+	struct vmscsi_req *vm_srb = &reqp->vstor_packet.u.vm_srb;
 	
 	if (reqp->retries > 0) {
 		mtx_lock(&sc->hs_lock);

Modified: head/sys/dev/hyperv/storvsc/hv_vstorage.h
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_vstorage.h	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/storvsc/hv_vstorage.h	Thu Oct 10 16:25:53 2013	(r256276)
@@ -24,6 +24,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
  */
 
 #ifndef __HV_VSTORAGE_H__
@@ -107,7 +109,7 @@ struct vmscsi_req {
 	    uint8_t sense_data[SENSE_BUFFER_SIZE];
 
 	    uint8_t reserved_array[MAX_DATA_BUFFER_LENGTH_WITH_PADDING];
-	};
+	} u;
 
 } __packed;
 
@@ -191,7 +193,7 @@ struct vstor_packet {
 	     * Used during version negotiations.
 	     */
 	    struct vmstor_proto_ver version;
-	};
+	} u;
 
 } __packed;
 

Modified: head/sys/dev/hyperv/vmbus/hv_channel.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_channel.c	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/vmbus/hv_channel.c	Thu Oct 10 16:25:53 2013	(r256276)
@@ -26,6 +26,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
 #include <sys/param.h>
 #include <sys/malloc.h>
 #include <sys/systm.h>
@@ -70,7 +73,7 @@ vmbus_channel_set_event(hv_vmbus_channel
 
 		synch_set_bit(channel->monitor_bit,
 			(uint32_t *)&monitor_page->
-				trigger_group[channel->monitor_group].pending);
+				trigger_group[channel->monitor_group].u.pending);
 	} else {
 		hv_vmbus_set_event(channel->offer_msg.child_rel_id);
 	}

Modified: head/sys/dev/hyperv/vmbus/hv_hv.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_hv.c	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/vmbus/hv_hv.c	Thu Oct 10 16:25:53 2013	(r256276)
@@ -240,8 +240,8 @@ hv_vmbus_init(void) 
 	if (virt_addr == NULL)
 	    goto cleanup;
 
-	hypercall_msr.enable = 1;
-	hypercall_msr.guest_physical_address =
+	hypercall_msr.u.enable = 1;
+	hypercall_msr.u.guest_physical_address =
 	    (hv_get_phys_addr(virt_addr) >> PAGE_SHIFT);
 	wrmsr(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64_t);
 
@@ -251,7 +251,7 @@ hv_vmbus_init(void) 
 	hypercall_msr.as_uint64_t = 0;
 	hypercall_msr.as_uint64_t = rdmsr(HV_X64_MSR_HYPERCALL);
 
-	if (!hypercall_msr.enable)
+	if (!hypercall_msr.u.enable)
 	    goto cleanup;
 
 	hv_vmbus_g_context.hypercall_page = virt_addr;
@@ -284,7 +284,7 @@ hv_vmbus_init(void) 
 
 	cleanup:
 	if (virt_addr != NULL) {
-	    if (hypercall_msr.enable) {
+	    if (hypercall_msr.u.enable) {
 		hypercall_msr.as_uint64_t = 0;
 		wrmsr(HV_X64_MSR_HYPERCALL,
 					hypercall_msr.as_uint64_t);
@@ -426,8 +426,8 @@ hv_vmbus_synic_init(void *arg)
 	 */
 
 	simp.as_uint64_t = rdmsr(HV_X64_MSR_SIMP);
-	simp.simp_enabled = 1;
-	simp.base_simp_gpa = ((hv_get_phys_addr(
+	simp.u.simp_enabled = 1;
+	simp.u.base_simp_gpa = ((hv_get_phys_addr(
 	    hv_vmbus_g_context.syn_ic_msg_page[cpu])) >> PAGE_SHIFT);
 
 	wrmsr(HV_X64_MSR_SIMP, simp.as_uint64_t);
@@ -436,23 +436,23 @@ hv_vmbus_synic_init(void *arg)
 	 * Setup the Synic's event page
 	 */
 	siefp.as_uint64_t = rdmsr(HV_X64_MSR_SIEFP);
-	siefp.siefp_enabled = 1;
-	siefp.base_siefp_gpa = ((hv_get_phys_addr(
+	siefp.u.siefp_enabled = 1;
+	siefp.u.base_siefp_gpa = ((hv_get_phys_addr(
 	    hv_vmbus_g_context.syn_ic_event_page[cpu])) >> PAGE_SHIFT);
 
 	wrmsr(HV_X64_MSR_SIEFP, siefp.as_uint64_t);
 
 	/*HV_SHARED_SINT_IDT_VECTOR + 0x20; */
-	shared_sint.vector = setup_args->vector;
-	shared_sint.masked = FALSE;
-	shared_sint.auto_eoi = FALSE;
+	shared_sint.u.vector = setup_args->vector;
+	shared_sint.u.masked = FALSE;
+	shared_sint.u.auto_eoi = FALSE;
 
 	wrmsr(HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT,
 	    shared_sint.as_uint64_t);
 
 	/* Enable the global synic bit */
 	sctrl.as_uint64_t = rdmsr(HV_X64_MSR_SCONTROL);
-	sctrl.enable = 1;
+	sctrl.u.enable = 1;
 
 	wrmsr(HV_X64_MSR_SCONTROL, sctrl.as_uint64_t);
 
@@ -480,7 +480,7 @@ void hv_vmbus_synic_cleanup(void *arg)
 	shared_sint.as_uint64_t = rdmsr(
 	    HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT);
 
-	shared_sint.masked = 1;
+	shared_sint.u.masked = 1;
 
 	/*
 	 * Disable the interrupt
@@ -490,14 +490,14 @@ void hv_vmbus_synic_cleanup(void *arg)
 	    shared_sint.as_uint64_t);
 
 	simp.as_uint64_t = rdmsr(HV_X64_MSR_SIMP);
-	simp.simp_enabled = 0;
-	simp.base_simp_gpa = 0;
+	simp.u.simp_enabled = 0;
+	simp.u.base_simp_gpa = 0;
 
 	wrmsr(HV_X64_MSR_SIMP, simp.as_uint64_t);
 
 	siefp.as_uint64_t = rdmsr(HV_X64_MSR_SIEFP);
-	siefp.siefp_enabled = 0;
-	siefp.base_siefp_gpa = 0;
+	siefp.u.siefp_enabled = 0;
+	siefp.u.base_siefp_gpa = 0;
 
 	wrmsr(HV_X64_MSR_SIEFP, siefp.as_uint64_t);
 }

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c	Thu Oct 10 16:25:53 2013	(r256276)
@@ -29,6 +29,8 @@
 /*
  * VM Bus Driver Implementation
  */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -113,7 +115,7 @@ vmbus_msg_swintr(void *dummy)
 	     */
 	    wmb();
 
-	    if (msg->header.message_flags.message_pending) {
+	    if (msg->header.message_flags.u.message_pending) {
 			/*
 			 * This will cause message queue rescan to possibly
 			 * deliver another msg from the hypervisor

Modified: head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
==============================================================================
--- head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Thu Oct 10 16:11:45 2013	(r256275)
+++ head/sys/dev/hyperv/vmbus/hv_vmbus_priv.h	Thu Oct 10 16:25:53 2013	(r256276)
@@ -24,6 +24,8 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
  */
 
 #ifndef __HYPERV_PRIV_H__
@@ -285,7 +287,7 @@ typedef union {
 	struct {
 		uint8_t	message_pending:1;
 		uint8_t	reserved:7;
-	};
+	} u;
 } hv_vmbus_msg_flags;
 
 typedef uint64_t hv_vmbus_partition_id;
@@ -393,7 +395,7 @@ typedef union {
 		 */
 		uint64_t os_id			: 8;
 		uint64_t vendor_id		: 16;
-	};
+	} u;
 } hv_vmbus_x64_msr_guest_os_id_contents;
 
 /*
@@ -407,7 +409,7 @@ typedef union {
 		uint64_t enable :1;
 		uint64_t reserved :11;
 		uint64_t guest_physical_address :52;
-	};
+	} u;
 } hv_vmbus_x64_msr_hypercall_contents;
 
 typedef union {
@@ -415,7 +417,7 @@ typedef union {
 	struct {
 		uint32_t group_enable :4;
 		uint32_t rsvd_z :28;
-	};
+	} u;
 } hv_vmbus_monitor_trigger_state;
 
 typedef union {
@@ -423,7 +425,7 @@ typedef union {
 	struct {
 		uint32_t pending;
 		uint32_t armed;
-	};
+	} u;
 } hv_vmbus_monitor_trigger_group;
 
 typedef struct {
@@ -499,7 +501,7 @@ typedef union {
 		uint64_t simp_enabled	: 1;
 		uint64_t preserved	: 11;
 		uint64_t base_simp_gpa	: 52;
-	};
+	} u;
 } hv_vmbus_synic_simp;
 
 /*
@@ -511,7 +513,7 @@ typedef union {
 		uint64_t siefp_enabled	: 1;
 		uint64_t preserved	: 11;
 		uint64_t base_siefp_gpa	: 52;
-	};
+	} u;
 } hv_vmbus_synic_siefp;
 
 /*
@@ -525,7 +527,7 @@ typedef union {
 		uint64_t masked		: 1;
 		uint64_t auto_eoi	: 1;
 		uint64_t reserved2	: 46;
-	};
+	} u;
 } hv_vmbus_synic_sint;
 
 /*
@@ -536,7 +538,7 @@ typedef union _hv_vmbus_synic_scontrol {
     struct {
         uint64_t enable		: 1;
         uint64_t reserved	: 63;
-    };
+    } u;
 } hv_vmbus_synic_scontrol;
 
 /*



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