From owner-svn-src-all@freebsd.org Wed Jul 13 05:35:30 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 21C0CB97967; Wed, 13 Jul 2016 05:35:30 +0000 (UTC) (envelope-from sephe@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 ED1191F78; Wed, 13 Jul 2016 05:35:29 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6D5ZTct000816; Wed, 13 Jul 2016 05:35:29 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6D5ZS78000810; Wed, 13 Jul 2016 05:35:28 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201607130535.u6D5ZS78000810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 13 Jul 2016 05:35:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302702 - head/sys/dev/hyperv/utilities 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.22 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: Wed, 13 Jul 2016 05:35:30 -0000 Author: sephe Date: Wed Jul 13 05:35:28 2016 New Revision: 302702 URL: https://svnweb.freebsd.org/changeset/base/302702 Log: hyperv/util: Avoid the hv_device This paves way to nuke the hv_device, which is actually an unncessary indirection. MFC after: 1 week Sponsored by: Microsoft OSTC Differential Revision: https://reviews.freebsd.org/D7028 Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c head/sys/dev/hyperv/utilities/hv_kvp.c head/sys/dev/hyperv/utilities/hv_shutdown.c head/sys/dev/hyperv/utilities/hv_timesync.c head/sys/dev/hyperv/utilities/hv_util.c head/sys/dev/hyperv/utilities/hv_util.h Modified: head/sys/dev/hyperv/utilities/hv_heartbeat.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_heartbeat.c Wed Jul 13 05:35:28 2016 (r302702) @@ -61,7 +61,7 @@ hv_heartbeat_cb(void *context) softc = (hv_util_sc*)context; buf = softc->receive_buffer; - channel = softc->hv_dev->channel; + channel = softc->channel; ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recvlen, &requestid); Modified: head/sys/dev/hyperv/utilities/hv_kvp.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_kvp.c Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_kvp.c Wed Jul 13 05:35:28 2016 (r302702) @@ -308,10 +308,6 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru { int err_ip, err_subnet, err_gway, err_dns, err_adap; int UNUSED_FLAG = 1; - struct hv_device *hv_dev; /* GUID Data Structure */ - hn_softc_t *sc; /* hn softc structure */ - char buf[HYPERV_GUID_STRLEN]; - device_t *devs; int devcnt; @@ -333,12 +329,18 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru if (devclass_get_devices(devclass_find("hn"), &devs, &devcnt) == 0) { for (devcnt = devcnt - 1; devcnt >= 0; devcnt--) { - sc = device_get_softc(devs[devcnt]); - - /* Trying to find GUID of Network Device */ - hv_dev = sc->hn_dev_obj; + /* XXX access other driver's softc? are you kidding? */ + device_t dev = devs[devcnt]; + struct hn_softc *sc = device_get_softc(dev); + struct hv_vmbus_channel *chan; + char buf[HYPERV_GUID_STRLEN]; - hyperv_guid2str(&hv_dev->device_id, buf, sizeof(buf)); + /* + * Trying to find GUID of Network Device + * TODO: need vmbus interface. + */ + chan = vmbus_get_channel(dev); + hyperv_guid2str(&chan->ch_guid_inst, buf, sizeof(buf)); if (strncmp(buf, (char *)umsg->body.kvp_ip_val.adapter_id, HYPERV_GUID_STRLEN - 1) == 0) { @@ -573,7 +575,7 @@ hv_kvp_respond_host(hv_kvp_sc *sc, int e hv_icmsg_hdrp->status = error; hv_icmsg_hdrp->icflags = HV_ICMSGHDRFLAG_TRANSACTION | HV_ICMSGHDRFLAG_RESPONSE; - error = hv_vmbus_channel_send_packet(sc->util_sc.hv_dev->channel, + error = hv_vmbus_channel_send_packet(sc->util_sc.channel, sc->rcv_buf, sc->host_msg_len, sc->host_msg_id, HV_VMBUS_PACKET_TYPE_DATA_IN_BAND, 0); @@ -624,7 +626,7 @@ hv_kvp_process_request(void *context, in sc = (hv_kvp_sc*)context; kvp_buf = sc->util_sc.receive_buffer; - channel = sc->util_sc.hv_dev->channel; + channel = sc->util_sc.channel; ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE, &recvlen, &requestid); Modified: head/sys/dev/hyperv/utilities/hv_shutdown.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_shutdown.c Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_shutdown.c Wed Jul 13 05:35:28 2016 (r302702) @@ -65,7 +65,7 @@ hv_shutdown_cb(void *context) softc = (hv_util_sc*)context; buf = softc->receive_buffer; - channel = softc->hv_dev->channel; + channel = softc->channel; ret = hv_vmbus_channel_recv_packet(channel, buf, PAGE_SIZE, &recv_len, &request_id); Modified: head/sys/dev/hyperv/utilities/hv_timesync.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_timesync.c Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_timesync.c Wed Jul 13 05:35:28 2016 (r302702) @@ -140,7 +140,7 @@ hv_timesync_cb(void *context) hv_timesync_sc *softc; softc = (hv_timesync_sc*)context; - channel = softc->util_sc.hv_dev->channel; + channel = softc->util_sc.channel; time_buf = softc->util_sc.receive_buffer; ret = hv_vmbus_channel_recv_packet(channel, time_buf, Modified: head/sys/dev/hyperv/utilities/hv_util.c ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.c Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_util.c Wed Jul 13 05:35:28 2016 (r302702) @@ -74,13 +74,11 @@ hv_negotiate_version( int hv_util_attach(device_t dev) { - struct hv_device* hv_dev; struct hv_util_sc* softc; int ret; - hv_dev = vmbus_get_devctx(dev); softc = device_get_softc(dev); - softc->hv_dev = hv_dev; + softc->channel = vmbus_get_channel(dev); softc->receive_buffer = malloc(4 * PAGE_SIZE, M_DEVBUF, M_WAITOK | M_ZERO); @@ -91,9 +89,9 @@ hv_util_attach(device_t dev) * Turn off batched reading for all util drivers before we open the * channel. */ - hv_set_channel_read_state(hv_dev->channel, FALSE); + hv_set_channel_read_state(softc->channel, FALSE); - ret = hv_vmbus_channel_open(hv_dev->channel, 4 * PAGE_SIZE, + ret = hv_vmbus_channel_open(softc->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, softc->callback, softc); @@ -110,14 +108,10 @@ error0: int hv_util_detach(device_t dev) { - struct hv_device* hv_dev; - struct hv_util_sc* softc; - - hv_dev = vmbus_get_devctx(dev); + struct hv_util_sc *sc = device_get_softc(dev); - hv_vmbus_channel_close(hv_dev->channel); - softc = device_get_softc(dev); + hv_vmbus_channel_close(sc->channel); + free(sc->receive_buffer, M_DEVBUF); - free(softc->receive_buffer, M_DEVBUF); return (0); } Modified: head/sys/dev/hyperv/utilities/hv_util.h ============================================================================== --- head/sys/dev/hyperv/utilities/hv_util.h Wed Jul 13 05:28:07 2016 (r302701) +++ head/sys/dev/hyperv/utilities/hv_util.h Wed Jul 13 05:35:28 2016 (r302702) @@ -41,7 +41,7 @@ typedef struct hv_util_sc { */ void (*callback)(void *); - struct hv_device* hv_dev; + struct hv_vmbus_channel *channel; uint8_t *receive_buffer; } hv_util_sc;