2 * Copyright (c) 2009-2012,2016 Microsoft Corp.
3 * Copyright (c) 2010-2012 Citrix Inc.
4 * Copyright (c) 2012 NetApp Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
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.
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.
34 struct hn_nvs_sendctx;
38 typedef void (*hn_nvs_sent_t)
39 (struct hn_nvs_sendctx *, struct hn_softc *,
40 struct vmbus_channel *, const void *, int);
42 struct hn_nvs_sendctx {
47 #define HN_NVS_SENDCTX_INITIALIZER(cb, cbarg) \
54 hn_nvs_sendctx_init(struct hn_nvs_sendctx *sndc, hn_nvs_sent_t cb, void *cbarg)
58 sndc->hn_cbarg = cbarg;
62 hn_nvs_send(struct vmbus_channel *chan, uint16_t flags,
63 void *nvs_msg, int nvs_msglen, struct hn_nvs_sendctx *sndc)
66 return (vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, flags,
67 nvs_msg, nvs_msglen, (uint64_t)(uintptr_t)sndc));
71 hn_nvs_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen,
72 void *nvs_msg, int nvs_msglen, struct hn_nvs_sendctx *sndc)
75 return (vmbus_chan_send_sglist(chan, sg, sglen, nvs_msg, nvs_msglen,
76 (uint64_t)(uintptr_t)sndc));
80 hn_nvs_send_rndis_sglist(struct vmbus_channel *chan, uint32_t rndis_mtype,
81 struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt)
83 struct hn_nvs_rndis rndis;
85 rndis.nvs_type = HN_NVS_TYPE_RNDIS;
86 rndis.nvs_rndis_mtype = rndis_mtype;
87 rndis.nvs_chim_idx = HN_NVS_CHIM_IDX_INVALID;
88 rndis.nvs_chim_sz = 0;
90 return (hn_nvs_send_sglist(chan, gpa, gpa_cnt,
91 &rndis, sizeof(rndis), sndc));
94 int hn_nvs_attach(struct hn_softc *sc, int mtu);
95 void hn_nvs_detach(struct hn_softc *sc);
96 int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch);
97 void hn_nvs_sent_xact(struct hn_nvs_sendctx *sndc,
98 struct hn_softc *sc, struct vmbus_channel *chan,
99 const void *data, int dlen);
100 int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan,
101 struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa,
104 extern struct hn_nvs_sendctx hn_nvs_sendctx_none;
106 #endif /* !_HN_NVS_H_ */