hn_nvs.c revision 307200
1/*-
2 * Copyright (c) 2009-2012,2016 Microsoft Corp.
3 * Copyright (c) 2010-2012 Citrix Inc.
4 * Copyright (c) 2012 NetApp Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice unmodified, this list of conditions, and the following
12 *    disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: stable/10/sys/dev/hyperv/netvsc/hv_net_vsc.c 307200 2016-10-13 08:01:38Z sephe $
29 */
30
31/**
32 * HyperV vmbus network VSC (virtual services client) module
33 *
34 */
35
36
37#include <sys/param.h>
38#include <sys/kernel.h>
39#include <sys/socket.h>
40#include <sys/limits.h>
41#include <sys/lock.h>
42#include <net/if.h>
43#include <net/if_arp.h>
44#include <machine/bus.h>
45#include <machine/atomic.h>
46
47#include <dev/hyperv/include/hyperv.h>
48#include <dev/hyperv/include/vmbus_xact.h>
49#include <dev/hyperv/netvsc/hv_net_vsc.h>
50#include <dev/hyperv/netvsc/hv_rndis_filter.h>
51#include <dev/hyperv/netvsc/if_hnreg.h>
52#include <dev/hyperv/netvsc/if_hnvar.h>
53
54MALLOC_DEFINE(M_NETVSC, "netvsc", "Hyper-V netvsc driver");
55
56/*
57 * Forward declarations
58 */
59static int  hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc);
60static int  hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *);
61static int  hv_nv_destroy_send_buffer(struct hn_softc *sc);
62static int  hv_nv_destroy_rx_buffer(struct hn_softc *sc);
63static int  hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu);
64static void hn_nvs_sent_none(struct hn_send_ctx *sndc,
65    struct hn_softc *, struct vmbus_channel *chan,
66    const void *, int);
67
68struct hn_send_ctx	hn_send_ctx_none =
69    HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL);
70
71static const uint32_t		hn_nvs_version[] = {
72	HN_NVS_VERSION_5,
73	HN_NVS_VERSION_4,
74	HN_NVS_VERSION_2,
75	HN_NVS_VERSION_1
76};
77
78uint32_t
79hn_chim_alloc(struct hn_softc *sc)
80{
81	int i, bmap_cnt = sc->hn_chim_bmap_cnt;
82	u_long *bmap = sc->hn_chim_bmap;
83	uint32_t ret = HN_NVS_CHIM_IDX_INVALID;
84
85	for (i = 0; i < bmap_cnt; ++i) {
86		int idx;
87
88		idx = ffsl(~bmap[i]);
89		if (idx == 0)
90			continue;
91
92		--idx; /* ffsl is 1-based */
93		KASSERT(i * LONG_BIT + idx < sc->hn_chim_cnt,
94		    ("invalid i %d and idx %d", i, idx));
95
96		if (atomic_testandset_long(&bmap[i], idx))
97			continue;
98
99		ret = i * LONG_BIT + idx;
100		break;
101	}
102	return (ret);
103}
104
105const void *
106hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact,
107    void *req, int reqlen, size_t *resplen0, uint32_t type)
108{
109	struct hn_send_ctx sndc;
110	size_t resplen, min_resplen = *resplen0;
111	const struct hn_nvs_hdr *hdr;
112	int error;
113
114	KASSERT(min_resplen >= sizeof(*hdr),
115	    ("invalid minimum response len %zu", min_resplen));
116
117	/*
118	 * Execute the xact setup by the caller.
119	 */
120	hn_send_ctx_init_simple(&sndc, hn_nvs_sent_xact, xact);
121
122	vmbus_xact_activate(xact);
123	error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC,
124	    req, reqlen, &sndc);
125	if (error) {
126		vmbus_xact_deactivate(xact);
127		return (NULL);
128	}
129	hdr = vmbus_xact_wait(xact, &resplen);
130
131	/*
132	 * Check this NVS response message.
133	 */
134	if (resplen < min_resplen) {
135		if_printf(sc->hn_ifp, "invalid NVS resp len %zu\n", resplen);
136		return (NULL);
137	}
138	if (hdr->nvs_type != type) {
139		if_printf(sc->hn_ifp, "unexpected NVS resp 0x%08x, "
140		    "expect 0x%08x\n", hdr->nvs_type, type);
141		return (NULL);
142	}
143	/* All pass! */
144	*resplen0 = resplen;
145	return (hdr);
146}
147
148static __inline int
149hn_nvs_req_send(struct hn_softc *sc, void *req, int reqlen)
150{
151
152	return (hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE,
153	    req, reqlen, &hn_send_ctx_none));
154}
155
156/*
157 * Net VSC initialize receive buffer with net VSP
158 *
159 * Net VSP:  Network virtual services client, also known as the
160 *     Hyper-V extensible switch and the synthetic data path.
161 */
162static int
163hv_nv_init_rx_buffer_with_net_vsp(struct hn_softc *sc)
164{
165	struct vmbus_xact *xact = NULL;
166	struct hn_nvs_rxbuf_conn *conn;
167	const struct hn_nvs_rxbuf_connresp *resp;
168	size_t resp_len;
169	uint32_t status;
170	int error, rxbuf_size;
171
172	/*
173	 * Limit RXBUF size for old NVS.
174	 */
175	if (sc->hn_nvs_ver <= HN_NVS_VERSION_2)
176		rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE_LEGACY;
177	else
178		rxbuf_size = NETVSC_RECEIVE_BUFFER_SIZE;
179
180	/*
181	 * Connect the RXBUF GPADL to the primary channel.
182	 *
183	 * NOTE:
184	 * Only primary channel has RXBUF connected to it.  Sub-channels
185	 * just share this RXBUF.
186	 */
187	error = vmbus_chan_gpadl_connect(sc->hn_prichan,
188	    sc->hn_rxbuf_dma.hv_paddr, rxbuf_size, &sc->hn_rxbuf_gpadl);
189	if (error) {
190		if_printf(sc->hn_ifp, "rxbuf gpadl connect failed: %d\n",
191		    error);
192		goto cleanup;
193	}
194
195	/*
196	 * Connect RXBUF to NVS.
197	 */
198
199	xact = vmbus_xact_get(sc->hn_xact, sizeof(*conn));
200	if (xact == NULL) {
201		if_printf(sc->hn_ifp, "no xact for nvs rxbuf conn\n");
202		error = ENXIO;
203		goto cleanup;
204	}
205	conn = vmbus_xact_req_data(xact);
206	conn->nvs_type = HN_NVS_TYPE_RXBUF_CONN;
207	conn->nvs_gpadl = sc->hn_rxbuf_gpadl;
208	conn->nvs_sig = HN_NVS_RXBUF_SIG;
209
210	resp_len = sizeof(*resp);
211	resp = hn_nvs_xact_execute(sc, xact, conn, sizeof(*conn), &resp_len,
212	    HN_NVS_TYPE_RXBUF_CONNRESP);
213	if (resp == NULL) {
214		if_printf(sc->hn_ifp, "exec rxbuf conn failed\n");
215		error = EIO;
216		goto cleanup;
217	}
218
219	status = resp->nvs_status;
220	vmbus_xact_put(xact);
221	xact = NULL;
222
223	if (status != HN_NVS_STATUS_OK) {
224		if_printf(sc->hn_ifp, "rxbuf conn failed: %x\n", status);
225		error = EIO;
226		goto cleanup;
227	}
228	sc->hn_flags |= HN_FLAG_RXBUF_CONNECTED;
229
230	return (0);
231
232cleanup:
233	if (xact != NULL)
234		vmbus_xact_put(xact);
235	hv_nv_destroy_rx_buffer(sc);
236	return (error);
237}
238
239/*
240 * Net VSC initialize send buffer with net VSP
241 */
242static int
243hv_nv_init_send_buffer_with_net_vsp(struct hn_softc *sc)
244{
245	struct vmbus_xact *xact = NULL;
246	struct hn_nvs_chim_conn *chim;
247	const struct hn_nvs_chim_connresp *resp;
248	size_t resp_len;
249	uint32_t status, sectsz;
250	int error;
251
252	/*
253	 * Connect chimney sending buffer GPADL to the primary channel.
254	 *
255	 * NOTE:
256	 * Only primary channel has chimney sending buffer connected to it.
257	 * Sub-channels just share this chimney sending buffer.
258	 */
259	error = vmbus_chan_gpadl_connect(sc->hn_prichan,
260  	    sc->hn_chim_dma.hv_paddr, NETVSC_SEND_BUFFER_SIZE,
261	    &sc->hn_chim_gpadl);
262	if (error) {
263		if_printf(sc->hn_ifp, "chimney sending buffer gpadl "
264		    "connect failed: %d\n", error);
265		goto cleanup;
266	}
267
268	/*
269	 * Connect chimney sending buffer to NVS
270	 */
271
272	xact = vmbus_xact_get(sc->hn_xact, sizeof(*chim));
273	if (xact == NULL) {
274		if_printf(sc->hn_ifp, "no xact for nvs chim conn\n");
275		error = ENXIO;
276		goto cleanup;
277	}
278	chim = vmbus_xact_req_data(xact);
279	chim->nvs_type = HN_NVS_TYPE_CHIM_CONN;
280	chim->nvs_gpadl = sc->hn_chim_gpadl;
281	chim->nvs_sig = HN_NVS_CHIM_SIG;
282
283	resp_len = sizeof(*resp);
284	resp = hn_nvs_xact_execute(sc, xact, chim, sizeof(*chim), &resp_len,
285	    HN_NVS_TYPE_CHIM_CONNRESP);
286	if (resp == NULL) {
287		if_printf(sc->hn_ifp, "exec chim conn failed\n");
288		error = EIO;
289		goto cleanup;
290	}
291
292	status = resp->nvs_status;
293	sectsz = resp->nvs_sectsz;
294	vmbus_xact_put(xact);
295	xact = NULL;
296
297	if (status != HN_NVS_STATUS_OK) {
298		if_printf(sc->hn_ifp, "chim conn failed: %x\n", status);
299		error = EIO;
300		goto cleanup;
301	}
302	if (sectsz == 0) {
303		if_printf(sc->hn_ifp, "zero chimney sending buffer "
304		    "section size\n");
305		return 0;
306	}
307
308	sc->hn_chim_szmax = sectsz;
309	sc->hn_chim_cnt = NETVSC_SEND_BUFFER_SIZE / sc->hn_chim_szmax;
310	if (NETVSC_SEND_BUFFER_SIZE % sc->hn_chim_szmax != 0) {
311		if_printf(sc->hn_ifp, "chimney sending sections are "
312		    "not properly aligned\n");
313	}
314	if (sc->hn_chim_cnt % LONG_BIT != 0) {
315		if_printf(sc->hn_ifp, "discard %d chimney sending sections\n",
316		    sc->hn_chim_cnt % LONG_BIT);
317	}
318
319	sc->hn_chim_bmap_cnt = sc->hn_chim_cnt / LONG_BIT;
320	sc->hn_chim_bmap = malloc(sc->hn_chim_bmap_cnt * sizeof(u_long),
321	    M_NETVSC, M_WAITOK | M_ZERO);
322
323	/* Done! */
324	sc->hn_flags |= HN_FLAG_CHIM_CONNECTED;
325	if (bootverbose) {
326		if_printf(sc->hn_ifp, "chimney sending buffer %d/%d\n",
327		    sc->hn_chim_szmax, sc->hn_chim_cnt);
328	}
329	return 0;
330
331cleanup:
332	if (xact != NULL)
333		vmbus_xact_put(xact);
334	hv_nv_destroy_send_buffer(sc);
335	return (error);
336}
337
338/*
339 * Net VSC destroy receive buffer
340 */
341static int
342hv_nv_destroy_rx_buffer(struct hn_softc *sc)
343{
344	int ret = 0;
345
346	if (sc->hn_flags & HN_FLAG_RXBUF_CONNECTED) {
347		struct hn_nvs_rxbuf_disconn disconn;
348
349		/*
350		 * Disconnect RXBUF from NVS.
351		 */
352		memset(&disconn, 0, sizeof(disconn));
353		disconn.nvs_type = HN_NVS_TYPE_RXBUF_DISCONN;
354		disconn.nvs_sig = HN_NVS_RXBUF_SIG;
355
356		/* NOTE: No response. */
357		ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn));
358		if (ret != 0) {
359			if_printf(sc->hn_ifp,
360			    "send rxbuf disconn failed: %d\n", ret);
361			return (ret);
362		}
363		sc->hn_flags &= ~HN_FLAG_RXBUF_CONNECTED;
364	}
365
366	if (sc->hn_rxbuf_gpadl != 0) {
367		/*
368		 * Disconnect RXBUF from primary channel.
369		 */
370		ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan,
371		    sc->hn_rxbuf_gpadl);
372		if (ret != 0) {
373			if_printf(sc->hn_ifp,
374			    "rxbuf disconn failed: %d\n", ret);
375			return (ret);
376		}
377		sc->hn_rxbuf_gpadl = 0;
378	}
379	return (ret);
380}
381
382/*
383 * Net VSC destroy send buffer
384 */
385static int
386hv_nv_destroy_send_buffer(struct hn_softc *sc)
387{
388	int ret = 0;
389
390	if (sc->hn_flags & HN_FLAG_CHIM_CONNECTED) {
391		struct hn_nvs_chim_disconn disconn;
392
393		/*
394		 * Disconnect chimney sending buffer from NVS.
395		 */
396		memset(&disconn, 0, sizeof(disconn));
397		disconn.nvs_type = HN_NVS_TYPE_CHIM_DISCONN;
398		disconn.nvs_sig = HN_NVS_CHIM_SIG;
399
400		/* NOTE: No response. */
401		ret = hn_nvs_req_send(sc, &disconn, sizeof(disconn));
402		if (ret != 0) {
403			if_printf(sc->hn_ifp,
404			    "send chim disconn failed: %d\n", ret);
405			return (ret);
406		}
407		sc->hn_flags &= ~HN_FLAG_CHIM_CONNECTED;
408	}
409
410	if (sc->hn_chim_gpadl != 0) {
411		/*
412		 * Disconnect chimney sending buffer from primary channel.
413		 */
414		ret = vmbus_chan_gpadl_disconnect(sc->hn_prichan,
415		    sc->hn_chim_gpadl);
416		if (ret != 0) {
417			if_printf(sc->hn_ifp,
418			    "chim disconn failed: %d\n", ret);
419			return (ret);
420		}
421		sc->hn_chim_gpadl = 0;
422	}
423
424	if (sc->hn_chim_bmap != NULL) {
425		free(sc->hn_chim_bmap, M_NETVSC);
426		sc->hn_chim_bmap = NULL;
427	}
428
429	return (ret);
430}
431
432static int
433hn_nvs_doinit(struct hn_softc *sc, uint32_t nvs_ver)
434{
435	struct vmbus_xact *xact;
436	struct hn_nvs_init *init;
437	const struct hn_nvs_init_resp *resp;
438	size_t resp_len;
439	uint32_t status;
440
441	xact = vmbus_xact_get(sc->hn_xact, sizeof(*init));
442	if (xact == NULL) {
443		if_printf(sc->hn_ifp, "no xact for nvs init\n");
444		return (ENXIO);
445	}
446	init = vmbus_xact_req_data(xact);
447	init->nvs_type = HN_NVS_TYPE_INIT;
448	init->nvs_ver_min = nvs_ver;
449	init->nvs_ver_max = nvs_ver;
450
451	resp_len = sizeof(*resp);
452	resp = hn_nvs_xact_execute(sc, xact, init, sizeof(*init), &resp_len,
453	    HN_NVS_TYPE_INIT_RESP);
454	if (resp == NULL) {
455		if_printf(sc->hn_ifp, "exec init failed\n");
456		vmbus_xact_put(xact);
457		return (EIO);
458	}
459
460	status = resp->nvs_status;
461	vmbus_xact_put(xact);
462
463	if (status != HN_NVS_STATUS_OK) {
464		if_printf(sc->hn_ifp, "nvs init failed for ver 0x%x\n",
465		    nvs_ver);
466		return (EINVAL);
467	}
468	return (0);
469}
470
471/*
472 * Send NDIS version 2 config packet containing MTU.
473 *
474 * Not valid for NDIS version 1.
475 */
476static int
477hv_nv_send_ndis_config(struct hn_softc *sc, uint32_t mtu)
478{
479	struct hn_nvs_ndis_conf conf;
480	int error;
481
482	memset(&conf, 0, sizeof(conf));
483	conf.nvs_type = HN_NVS_TYPE_NDIS_CONF;
484	conf.nvs_mtu = mtu;
485	conf.nvs_caps = HN_NVS_NDIS_CONF_VLAN;
486
487	/* NOTE: No response. */
488	error = hn_nvs_req_send(sc, &conf, sizeof(conf));
489	if (error)
490		if_printf(sc->hn_ifp, "send nvs ndis conf failed: %d\n", error);
491	return (error);
492}
493
494static int
495hn_nvs_init(struct hn_softc *sc)
496{
497	int i;
498
499	for (i = 0; i < nitems(hn_nvs_version); ++i) {
500		int error;
501
502		error = hn_nvs_doinit(sc, hn_nvs_version[i]);
503		if (!error) {
504			sc->hn_nvs_ver = hn_nvs_version[i];
505
506			/* Set NDIS version according to NVS version. */
507			sc->hn_ndis_ver = HN_NDIS_VERSION_6_30;
508			if (sc->hn_nvs_ver <= HN_NVS_VERSION_4)
509				sc->hn_ndis_ver = HN_NDIS_VERSION_6_1;
510
511			if (bootverbose) {
512				if_printf(sc->hn_ifp, "NVS version 0x%x, "
513				    "NDIS version %u.%u\n", sc->hn_nvs_ver,
514				    HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver),
515				    HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver));
516			}
517			return (0);
518		}
519	}
520	if_printf(sc->hn_ifp, "no NVS available\n");
521	return (ENXIO);
522}
523
524/*
525 * Net VSC connect to VSP
526 */
527static int
528hv_nv_connect_to_vsp(struct hn_softc *sc, int mtu)
529{
530	int ret = 0;
531	struct hn_nvs_ndis_init ndis;
532
533	ret = hn_nvs_init(sc);
534	if (ret != 0)
535		return (ret);
536
537	/*
538	 * Set the MTU if supported by this NVSP protocol version
539	 * This needs to be right after the NVSP init message per Haiyang
540	 */
541	if (sc->hn_nvs_ver >= HN_NVS_VERSION_2)
542		ret = hv_nv_send_ndis_config(sc, mtu);
543
544	/*
545	 * Initialize NDIS.
546	 */
547
548	memset(&ndis, 0, sizeof(ndis));
549	ndis.nvs_type = HN_NVS_TYPE_NDIS_INIT;
550	ndis.nvs_ndis_major = HN_NDIS_VERSION_MAJOR(sc->hn_ndis_ver);
551	ndis.nvs_ndis_minor = HN_NDIS_VERSION_MINOR(sc->hn_ndis_ver);
552
553	/* NOTE: No response. */
554	ret = hn_nvs_req_send(sc, &ndis, sizeof(ndis));
555	if (ret != 0) {
556		if_printf(sc->hn_ifp, "send nvs ndis init failed: %d\n", ret);
557		goto cleanup;
558	}
559
560	ret = hv_nv_init_rx_buffer_with_net_vsp(sc);
561	if (ret == 0)
562		ret = hv_nv_init_send_buffer_with_net_vsp(sc);
563
564cleanup:
565	return (ret);
566}
567
568/*
569 * Net VSC disconnect from VSP
570 */
571static void
572hv_nv_disconnect_from_vsp(struct hn_softc *sc)
573{
574	hv_nv_destroy_rx_buffer(sc);
575	hv_nv_destroy_send_buffer(sc);
576}
577
578/*
579 * Net VSC on device add
580 *
581 * Callback when the device belonging to this driver is added
582 */
583int
584hv_nv_on_device_add(struct hn_softc *sc, int mtu)
585{
586
587	/*
588	 * Connect with the NetVsp
589	 */
590	return (hv_nv_connect_to_vsp(sc, mtu));
591}
592
593/*
594 * Net VSC on device remove
595 */
596int
597hv_nv_on_device_remove(struct hn_softc *sc)
598{
599
600	hv_nv_disconnect_from_vsp(sc);
601
602	/* Now, we can close the channel safely */
603
604	vmbus_chan_close(sc->hn_prichan);
605
606	return (0);
607}
608
609void
610hn_nvs_sent_xact(struct hn_send_ctx *sndc,
611    struct hn_softc *sc __unused, struct vmbus_channel *chan __unused,
612    const void *data, int dlen)
613{
614
615	vmbus_xact_wakeup(sndc->hn_cbarg, data, dlen);
616}
617
618static void
619hn_nvs_sent_none(struct hn_send_ctx *sndc __unused,
620    struct hn_softc *sc __unused, struct vmbus_channel *chan __unused,
621    const void *data __unused, int dlen __unused)
622{
623	/* EMPTY */
624}
625
626void
627hn_chim_free(struct hn_softc *sc, uint32_t chim_idx)
628{
629	u_long mask;
630	uint32_t idx;
631
632	idx = chim_idx / LONG_BIT;
633	KASSERT(idx < sc->hn_chim_bmap_cnt,
634	    ("invalid chimney index 0x%x", chim_idx));
635
636	mask = 1UL << (chim_idx % LONG_BIT);
637	KASSERT(sc->hn_chim_bmap[idx] & mask,
638	    ("index bitmap 0x%lx, chimney index %u, "
639	     "bitmap idx %d, bitmask 0x%lx",
640	     sc->hn_chim_bmap[idx], chim_idx, idx, mask));
641
642	atomic_clear_long(&sc->hn_chim_bmap[idx], mask);
643}
644
645/*
646 * Net VSC on send
647 * Sends a packet on the specified Hyper-V device.
648 * Returns 0 on success, non-zero on failure.
649 */
650int
651hv_nv_on_send(struct vmbus_channel *chan, uint32_t rndis_mtype,
652    struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt)
653{
654	struct hn_nvs_rndis rndis;
655	int ret;
656
657	rndis.nvs_type = HN_NVS_TYPE_RNDIS;
658	rndis.nvs_rndis_mtype = rndis_mtype;
659	rndis.nvs_chim_idx = sndc->hn_chim_idx;
660	rndis.nvs_chim_sz = sndc->hn_chim_sz;
661
662	if (gpa_cnt) {
663		ret = hn_nvs_send_sglist(chan, gpa, gpa_cnt,
664		    &rndis, sizeof(rndis), sndc);
665	} else {
666		ret = hn_nvs_send(chan, VMBUS_CHANPKT_FLAG_RC,
667		    &rndis, sizeof(rndis), sndc);
668	}
669
670	return (ret);
671}
672