From owner-svn-src-head@freebsd.org Wed Dec 21 03:09:08 2016 Return-Path: Delivered-To: svn-src-head@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 B64EDC89EA0; Wed, 21 Dec 2016 03:09:08 +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 7744B1D43; Wed, 21 Dec 2016 03:09:08 +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 uBL397hl013067; Wed, 21 Dec 2016 03:09:07 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBL3970F013066; Wed, 21 Dec 2016 03:09:07 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201612210309.uBL3970F013066@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 21 Dec 2016 03:09:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310347 - head/sys/dev/hyperv/storvsc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Dec 2016 03:09:08 -0000 Author: sephe Date: Wed Dec 21 03:09:07 2016 New Revision: 310347 URL: https://svnweb.freebsd.org/changeset/base/310347 Log: hyperv/storvsc: The max channel in PDU actually means the max sub-chans. Use proper name for local variables. PDU fields' name was not changed yet. While I'm here, make # of usable channels tunable. This eases further testing. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8851 Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Dec 21 01:48:54 2016 (r310346) +++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Wed Dec 21 03:09:07 2016 (r310347) @@ -147,6 +147,10 @@ static u_int hv_storvsc_max_io = 512; SYSCTL_UINT(_hw_storvsc, OID_AUTO, max_io, CTLFLAG_RDTUN, &hv_storvsc_max_io, 0, "Hyper-V storage max io limit"); +static int hv_storvsc_chan_cnt = 0; +SYSCTL_INT(_hw_storvsc, OID_AUTO, chan_cnt, CTLFLAG_RDTUN, + &hv_storvsc_chan_cnt, 0, "# of channels to use"); + #define STORVSC_MAX_IO \ vmbus_chan_prplist_nelem(hv_storvsc_ringbuffer_size, \ STORVSC_DATA_SEGCNT_MAX, VSTOR_PKT_SIZE) @@ -385,16 +389,16 @@ storvsc_subchan_attach(struct storvsc_so * @param max_chans the max channels supported by vmbus */ static void -storvsc_send_multichannel_request(struct storvsc_softc *sc, int max_chans) +storvsc_send_multichannel_request(struct storvsc_softc *sc, int max_subch) { struct vmbus_channel **subchan; struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - int request_channels_cnt = 0; + int request_subch; int ret, i; - /* get multichannels count that need to create */ - request_channels_cnt = MIN(max_chans, mp_ncpus); + /* get sub-channel count that need to create */ + request_subch = MIN(max_subch, mp_ncpus - 1); request = &sc->hs_init_req; @@ -407,7 +411,7 @@ storvsc_send_multichannel_request(struct vstor_packet->operation = VSTOR_OPERATION_CREATE_MULTI_CHANNELS; vstor_packet->flags = REQUEST_COMPLETION_FLAG; - vstor_packet->u.multi_channels_cnt = request_channels_cnt; + vstor_packet->u.multi_channels_cnt = request_subch; ret = vmbus_chan_send(sc->hs_chan, VMBUS_CHANPKT_TYPE_INBAND, VMBUS_CHANPKT_FLAG_RC, @@ -424,17 +428,17 @@ storvsc_send_multichannel_request(struct } /* Update channel count */ - sc->hs_nchan = request_channels_cnt + 1; + sc->hs_nchan = request_subch + 1; /* Wait for sub-channels setup to complete. */ - subchan = vmbus_subchan_get(sc->hs_chan, request_channels_cnt); + subchan = vmbus_subchan_get(sc->hs_chan, request_subch); /* Attach the sub-channels. */ - for (i = 0; i < request_channels_cnt; ++i) + for (i = 0; i < request_subch; ++i) storvsc_subchan_attach(sc, subchan[i]); /* Release the sub-channels. */ - vmbus_subchan_rel(subchan, request_channels_cnt); + vmbus_subchan_rel(subchan, request_subch); if (bootverbose) printf("Storvsc create multi-channel success!\n"); @@ -452,11 +456,11 @@ hv_storvsc_channel_init(struct storvsc_s int ret = 0, i; struct hv_storvsc_request *request; struct vstor_packet *vstor_packet; - uint16_t max_chans = 0; - boolean_t support_multichannel = FALSE; + uint16_t max_subch; + boolean_t support_multichannel; uint32_t version; - max_chans = 0; + max_subch = 0; support_multichannel = FALSE; request = &sc->hs_init_req; @@ -550,14 +554,21 @@ hv_storvsc_channel_init(struct storvsc_s goto cleanup; } + max_subch = vstor_packet->u.chan_props.max_channel_cnt; + if (hv_storvsc_chan_cnt > 0 && hv_storvsc_chan_cnt < (max_subch + 1)) + max_subch = hv_storvsc_chan_cnt - 1; + /* multi-channels feature is supported by WIN8 and above version */ - max_chans = vstor_packet->u.chan_props.max_channel_cnt; version = VMBUS_GET_VERSION(device_get_parent(sc->hs_dev), sc->hs_dev); if (version != VMBUS_VERSION_WIN7 && version != VMBUS_VERSION_WS2008 && (vstor_packet->u.chan_props.flags & HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) { support_multichannel = TRUE; } + if (bootverbose) { + device_printf(sc->hs_dev, "max chans %d%s\n", max_subch + 1, + support_multichannel ? ", multi-chan capable" : ""); + } memset(vstor_packet, 0, sizeof(struct vstor_packet)); vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION; @@ -581,8 +592,8 @@ hv_storvsc_channel_init(struct storvsc_s * If multi-channel is supported, send multichannel create * request to host. */ - if (support_multichannel) - storvsc_send_multichannel_request(sc, max_chans); + if (support_multichannel && max_subch > 0) + storvsc_send_multichannel_request(sc, max_subch); cleanup: sema_destroy(&request->synch_sema); return (ret);