Date: Thu, 27 Oct 2016 05:26:04 +0000 (UTC) From: Sepherosa Ziehau <sephe@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307990 - head/sys/dev/hyperv/netvsc Message-ID: <201610270526.u9R5Q4WY009793@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sephe Date: Thu Oct 27 05:26:04 2016 New Revision: 307990 URL: https://svnweb.freebsd.org/changeset/base/307990 Log: hyperv/hn: Move send context to NVS domain. Since all sends are encapsulated in NVS messages. MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8346 Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c head/sys/dev/hyperv/netvsc/hv_net_vsc.h head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c head/sys/dev/hyperv/netvsc/hv_rndis_filter.c head/sys/dev/hyperv/netvsc/if_hnvar.h Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 27 05:13:00 2016 (r307989) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.c Thu Oct 27 05:26:04 2016 (r307990) @@ -39,18 +39,24 @@ #include <sys/socket.h> #include <sys/limits.h> #include <sys/lock.h> +#include <sys/taskqueue.h> + #include <net/if.h> #include <net/if_var.h> -#include <net/if_arp.h> -#include <machine/bus.h> -#include <machine/atomic.h> +#include <net/if_media.h> + +#include <netinet/in.h> +#include <netinet/tcp_lro.h> #include <dev/hyperv/include/hyperv.h> +#include <dev/hyperv/include/hyperv_busdma.h> +#include <dev/hyperv/include/vmbus.h> #include <dev/hyperv/include/vmbus_xact.h> -#include <dev/hyperv/netvsc/hv_net_vsc.h> -#include <dev/hyperv/netvsc/hv_rndis_filter.h> + +#include <dev/hyperv/netvsc/ndis.h> #include <dev/hyperv/netvsc/if_hnreg.h> #include <dev/hyperv/netvsc/if_hnvar.h> +#include <dev/hyperv/netvsc/hv_net_vsc.h> /* * Forward declarations @@ -59,12 +65,12 @@ static int hn_nvs_conn_chim(struct hn_s static int hn_nvs_conn_rxbuf(struct hn_softc *); static int hn_nvs_disconn_chim(struct hn_softc *sc); static int hn_nvs_disconn_rxbuf(struct hn_softc *sc); -static void hn_nvs_sent_none(struct hn_send_ctx *sndc, +static void hn_nvs_sent_none(struct hn_nvs_sendctx *sndc, struct hn_softc *, struct vmbus_channel *chan, const void *, int); -struct hn_send_ctx hn_send_ctx_none = - HN_SEND_CTX_INITIALIZER(hn_nvs_sent_none, NULL); +struct hn_nvs_sendctx hn_nvs_sendctx_none = + HN_NVS_SENDCTX_INITIALIZER(hn_nvs_sent_none, NULL); static const uint32_t hn_nvs_version[] = { HN_NVS_VERSION_5, @@ -77,7 +83,7 @@ static const void * hn_nvs_xact_execute(struct hn_softc *sc, struct vmbus_xact *xact, void *req, int reqlen, size_t *resplen0, uint32_t type) { - struct hn_send_ctx sndc; + struct hn_nvs_sendctx sndc; size_t resplen, min_resplen = *resplen0; const struct hn_nvs_hdr *hdr; int error; @@ -88,7 +94,7 @@ hn_nvs_xact_execute(struct hn_softc *sc, /* * Execute the xact setup by the caller. */ - hn_send_ctx_init(&sndc, hn_nvs_sent_xact, xact); + hn_nvs_sendctx_init(&sndc, hn_nvs_sent_xact, xact); vmbus_xact_activate(xact); error = hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_RC, @@ -121,7 +127,7 @@ hn_nvs_req_send(struct hn_softc *sc, voi { return (hn_nvs_send(sc->hn_prichan, VMBUS_CHANPKT_FLAG_NONE, - req, reqlen, &hn_send_ctx_none)); + req, reqlen, &hn_nvs_sendctx_none)); } static int @@ -604,7 +610,7 @@ hn_nvs_detach(struct hn_softc *sc) } void -hn_nvs_sent_xact(struct hn_send_ctx *sndc, +hn_nvs_sent_xact(struct hn_nvs_sendctx *sndc, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data, int dlen) { @@ -613,7 +619,7 @@ hn_nvs_sent_xact(struct hn_send_ctx *snd } static void -hn_nvs_sent_none(struct hn_send_ctx *sndc __unused, +hn_nvs_sent_none(struct hn_nvs_sendctx *sndc __unused, struct hn_softc *sc __unused, struct vmbus_channel *chan __unused, const void *data __unused, int dlen __unused) { @@ -670,3 +676,12 @@ done: vmbus_xact_put(xact); return (error); } + +int +hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, + struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) +{ + + return hn_nvs_send_rndis_sglist(chan, HN_NVS_RNDIS_MTYPE_CTRL, + sndc, gpa, gpa_cnt); +} Modified: head/sys/dev/hyperv/netvsc/hv_net_vsc.h ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 27 05:13:00 2016 (r307989) +++ head/sys/dev/hyperv/netvsc/hv_net_vsc.h Thu Oct 27 05:26:04 2016 (r307990) @@ -31,31 +31,76 @@ #ifndef __HV_NET_VSC_H__ #define __HV_NET_VSC_H__ -#include <sys/param.h> -#include <sys/kernel.h> -#include <sys/lock.h> -#include <sys/malloc.h> -#include <sys/queue.h> -#include <sys/taskqueue.h> -#include <sys/sema.h> -#include <sys/sx.h> - -#include <machine/bus.h> -#include <sys/bus.h> -#include <sys/bus_dma.h> - -#include <netinet/in.h> -#include <netinet/tcp_lro.h> - -#include <net/ethernet.h> -#include <net/if.h> -#include <net/if_media.h> - -#include <dev/hyperv/include/hyperv.h> -#include <dev/hyperv/include/hyperv_busdma.h> -#include <dev/hyperv/include/vmbus.h> +struct hn_nvs_sendctx; +struct vmbus_channel; +struct hn_softc; + +typedef void (*hn_nvs_sent_t) + (struct hn_nvs_sendctx *, struct hn_softc *, + struct vmbus_channel *, const void *, int); + +struct hn_nvs_sendctx { + hn_nvs_sent_t hn_cb; + void *hn_cbarg; +}; + +#define HN_NVS_SENDCTX_INITIALIZER(cb, cbarg) \ +{ \ + .hn_cb = cb, \ + .hn_cbarg = cbarg \ +} + +static __inline void +hn_nvs_sendctx_init(struct hn_nvs_sendctx *sndc, hn_nvs_sent_t cb, void *cbarg) +{ + + sndc->hn_cb = cb; + sndc->hn_cbarg = cbarg; +} + +static __inline int +hn_nvs_send(struct vmbus_channel *chan, uint16_t flags, + void *nvs_msg, int nvs_msglen, struct hn_nvs_sendctx *sndc) +{ + + return (vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, flags, + nvs_msg, nvs_msglen, (uint64_t)(uintptr_t)sndc)); +} + +static __inline int +hn_nvs_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, + void *nvs_msg, int nvs_msglen, struct hn_nvs_sendctx *sndc) +{ + + return (vmbus_chan_send_sglist(chan, sg, sglen, nvs_msg, nvs_msglen, + (uint64_t)(uintptr_t)sndc)); +} + +static __inline int +hn_nvs_send_rndis_sglist(struct vmbus_channel *chan, uint32_t rndis_mtype, + struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) +{ + struct hn_nvs_rndis rndis; + + rndis.nvs_type = HN_NVS_TYPE_RNDIS; + rndis.nvs_rndis_mtype = rndis_mtype; + rndis.nvs_chim_idx = HN_NVS_CHIM_IDX_INVALID; + rndis.nvs_chim_sz = 0; + + return (hn_nvs_send_sglist(chan, gpa, gpa_cnt, + &rndis, sizeof(rndis), sndc)); +} + +int hn_nvs_attach(struct hn_softc *sc, int mtu); +void hn_nvs_detach(struct hn_softc *sc); +int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch); +void hn_nvs_sent_xact(struct hn_nvs_sendctx *sndc, + struct hn_softc *sc, struct vmbus_channel *chan, + const void *data, int dlen); +int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, + struct hn_nvs_sendctx *sndc, struct vmbus_gpa *gpa, + int gpa_cnt); -#include <dev/hyperv/netvsc/ndis.h> +extern struct hn_nvs_sendctx hn_nvs_sendctx_none; #endif /* __HV_NET_VSC_H__ */ - Modified: head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 27 05:13:00 2016 (r307989) +++ head/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c Thu Oct 27 05:26:04 2016 (r307990) @@ -174,7 +174,7 @@ struct hn_txdesc { struct hn_tx_ring *txr; int refs; uint32_t flags; /* HN_TXD_FLAG_ */ - struct hn_send_ctx send_ctx; + struct hn_nvs_sendctx send_ctx; uint32_t chim_index; int chim_size; @@ -412,37 +412,13 @@ hn_set_lro_lenlim(struct hn_softc *sc, i } #endif -static __inline int -hn_nvs_send_rndis_sglist1(struct vmbus_channel *chan, uint32_t rndis_mtype, - struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) -{ - struct hn_nvs_rndis rndis; - - rndis.nvs_type = HN_NVS_TYPE_RNDIS; - rndis.nvs_rndis_mtype = rndis_mtype; - rndis.nvs_chim_idx = HN_NVS_CHIM_IDX_INVALID; - rndis.nvs_chim_sz = 0; - - return (hn_nvs_send_sglist(chan, gpa, gpa_cnt, - &rndis, sizeof(rndis), sndc)); -} - -int -hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, - struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, int gpa_cnt) -{ - - return hn_nvs_send_rndis_sglist1(chan, HN_NVS_RNDIS_MTYPE_CTRL, - sndc, gpa, gpa_cnt); -} - static int hn_sendpkt_rndis_sglist(struct hn_tx_ring *txr, struct hn_txdesc *txd) { KASSERT(txd->chim_index == HN_NVS_CHIM_IDX_INVALID && txd->chim_size == 0, ("invalid rndis sglist txd")); - return (hn_nvs_send_rndis_sglist1(txr->hn_chan, HN_NVS_RNDIS_MTYPE_DATA, + return (hn_nvs_send_rndis_sglist(txr->hn_chan, HN_NVS_RNDIS_MTYPE_DATA, &txd->send_ctx, txr->hn_gpa, txr->hn_gpa_cnt)); } @@ -1190,7 +1166,7 @@ hn_txeof(struct hn_tx_ring *txr) } static void -hn_tx_done(struct hn_send_ctx *sndc, struct hn_softc *sc, +hn_tx_done(struct hn_nvs_sendctx *sndc, struct hn_softc *sc, struct vmbus_channel *chan, const void *data __unused, int dlen __unused) { struct hn_txdesc *txd = sndc->hn_cbarg; @@ -1429,7 +1405,7 @@ done: txd->m = m_head; /* Set the completion routine */ - hn_send_ctx_init(&txd->send_ctx, hn_tx_done, txd); + hn_nvs_sendctx_init(&txd->send_ctx, hn_tx_done, txd); return 0; } @@ -4070,9 +4046,9 @@ static void hn_nvs_handle_comp(struct hn_softc *sc, struct vmbus_channel *chan, const struct vmbus_chanpkt_hdr *pkt) { - struct hn_send_ctx *sndc; + struct hn_nvs_sendctx *sndc; - sndc = (struct hn_send_ctx *)(uintptr_t)pkt->cph_xactid; + sndc = (struct hn_nvs_sendctx *)(uintptr_t)pkt->cph_xactid; sndc->hn_cb(sndc, sc, chan, VMBUS_CHANPKT_CONST_DATA(pkt), VMBUS_CHANPKT_DATALEN(pkt)); /* Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 27 05:13:00 2016 (r307989) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Thu Oct 27 05:26:04 2016 (r307990) @@ -34,26 +34,30 @@ __FBSDID("$FreeBSD$"); #include <sys/socket.h> #include <sys/lock.h> #include <sys/mutex.h> +#include <sys/taskqueue.h> + +#include <machine/atomic.h> + +#include <net/ethernet.h> #include <net/if.h> -#include <net/if_arp.h> #include <net/if_var.h> -#include <net/ethernet.h> +#include <net/if_media.h> #include <net/rndis.h> + #include <netinet/in.h> #include <netinet/ip.h> -#include <sys/types.h> -#include <machine/atomic.h> -#include <sys/sema.h> -#include <vm/vm.h> -#include <vm/vm_param.h> -#include <vm/pmap.h> +#include <netinet/tcp_lro.h> #include <dev/hyperv/include/hyperv.h> +#include <dev/hyperv/include/hyperv_busdma.h> +#include <dev/hyperv/include/vmbus.h> #include <dev/hyperv/include/vmbus_xact.h> + +#include <dev/hyperv/netvsc/ndis.h> +#include <dev/hyperv/netvsc/if_hnreg.h> +#include <dev/hyperv/netvsc/if_hnvar.h> #include <dev/hyperv/netvsc/hv_net_vsc.h> #include <dev/hyperv/netvsc/hv_rndis_filter.h> -#include <dev/hyperv/netvsc/if_hnreg.h> -#include <dev/hyperv/netvsc/ndis.h> #define HV_RF_RECVINFO_VLAN 0x1 #define HV_RF_RECVINFO_CSUM 0x2 @@ -549,7 +553,7 @@ hn_rndis_get_linkstatus(struct hn_softc static const void * hn_rndis_xact_exec1(struct hn_softc *sc, struct vmbus_xact *xact, size_t reqlen, - struct hn_send_ctx *sndc, size_t *comp_len) + struct hn_nvs_sendctx *sndc, size_t *comp_len) { struct vmbus_gpa gpa[HN_XACT_REQ_PGCNT]; int gpa_cnt, error; @@ -608,7 +612,7 @@ hn_rndis_xact_execute(struct hn_softc *s /* * Execute the xact setup by the caller. */ - comp = hn_rndis_xact_exec1(sc, xact, reqlen, &hn_send_ctx_none, + comp = hn_rndis_xact_exec1(sc, xact, reqlen, &hn_nvs_sendctx_none, &comp_len); if (comp == NULL) return (NULL); @@ -1214,7 +1218,7 @@ hn_rndis_halt(struct hn_softc *sc) { struct vmbus_xact *xact; struct rndis_halt_req *halt; - struct hn_send_ctx sndc; + struct hn_nvs_sendctx sndc; size_t comp_len; xact = vmbus_xact_get(sc->hn_xact, sizeof(*halt)); @@ -1228,7 +1232,7 @@ hn_rndis_halt(struct hn_softc *sc) halt->rm_rid = hn_rndis_rid(sc); /* No RNDIS completion; rely on NVS message send completion */ - hn_send_ctx_init(&sndc, hn_nvs_sent_xact, xact); + hn_nvs_sendctx_init(&sndc, hn_nvs_sent_xact, xact); hn_rndis_xact_exec1(sc, xact, sizeof(*halt), &sndc, &comp_len); vmbus_xact_put(xact); Modified: head/sys/dev/hyperv/netvsc/if_hnvar.h ============================================================================== --- head/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 27 05:13:00 2016 (r307989) +++ head/sys/dev/hyperv/netvsc/if_hnvar.h Thu Oct 27 05:26:04 2016 (r307990) @@ -51,25 +51,6 @@ #define HN_GPACNT_MAX 32 -struct vmbus_channel; -struct hn_softc; -struct hn_send_ctx; - -typedef void (*hn_sent_callback_t) - (struct hn_send_ctx *, struct hn_softc *, - struct vmbus_channel *, const void *, int); - -struct hn_send_ctx { - hn_sent_callback_t hn_cb; - void *hn_cbarg; -}; - -#define HN_SEND_CTX_INITIALIZER(cb, cbarg) \ -{ \ - .hn_cb = cb, \ - .hn_cbarg = cbarg \ -} - #define HN_NDIS_VLAN_INFO_INVALID 0xffffffff #define HN_NDIS_RXCSUM_INFO_INVALID 0 #define HN_NDIS_HASH_INFO_INVALID 0 @@ -261,33 +242,6 @@ struct hn_softc { #define HN_LINK_FLAG_LINKUP 0x0001 #define HN_LINK_FLAG_NETCHG 0x0002 -static __inline void -hn_send_ctx_init(struct hn_send_ctx *sndc, hn_sent_callback_t cb, void *cbarg) -{ - - sndc->hn_cb = cb; - sndc->hn_cbarg = cbarg; -} - -static __inline int -hn_nvs_send(struct vmbus_channel *chan, uint16_t flags, - void *nvs_msg, int nvs_msglen, struct hn_send_ctx *sndc) -{ - - return (vmbus_chan_send(chan, VMBUS_CHANPKT_TYPE_INBAND, flags, - nvs_msg, nvs_msglen, (uint64_t)(uintptr_t)sndc)); -} - -static __inline int -hn_nvs_send_sglist(struct vmbus_channel *chan, struct vmbus_gpa sg[], int sglen, - void *nvs_msg, int nvs_msglen, struct hn_send_ctx *sndc) -{ - - return (vmbus_chan_send_sglist(chan, sg, sglen, nvs_msg, nvs_msglen, - (uint64_t)(uintptr_t)sndc)); -} - -struct vmbus_xact; struct rndis_packet_msg; int hn_rndis_attach(struct hn_softc *sc, int mtu); @@ -302,21 +256,10 @@ int hn_rndis_get_linkstatus(struct hn_s /* filter: NDIS_PACKET_TYPE_. */ int hn_rndis_set_rxfilter(struct hn_softc *sc, uint32_t filter); -int hn_nvs_attach(struct hn_softc *sc, int mtu); -void hn_nvs_detach(struct hn_softc *sc); -int hn_nvs_alloc_subchans(struct hn_softc *sc, int *nsubch); -void hn_nvs_sent_xact(struct hn_send_ctx *sndc, struct hn_softc *sc, - struct vmbus_channel *chan, const void *data, int dlen); -int hn_nvs_send_rndis_ctrl(struct vmbus_channel *chan, - struct hn_send_ctx *sndc, struct vmbus_gpa *gpa, - int gpa_cnt); - int hn_rxpkt(struct hn_rx_ring *rxr, const void *data, int dlen, const struct hn_recvinfo *info); void hn_chan_rollup(struct hn_rx_ring *rxr, struct hn_tx_ring *txr); void hn_link_status_update(struct hn_softc *sc); void hn_network_change(struct hn_softc *sc); -extern struct hn_send_ctx hn_send_ctx_none; - #endif /* !_IF_HNVAR_H_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610270526.u9R5Q4WY009793>