From owner-svn-src-all@freebsd.org Mon Sep 12 05:59:41 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 16A32BD7330; Mon, 12 Sep 2016 05:59:41 +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 C39AF842; Mon, 12 Sep 2016 05:59:40 +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 u8C5xemm079229; Mon, 12 Sep 2016 05:59:40 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u8C5xe06079228; Mon, 12 Sep 2016 05:59:40 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201609120559.u8C5xe06079228@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Mon, 12 Sep 2016 05:59:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r305729 - head/sys/dev/hyperv/netvsc 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.23 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: Mon, 12 Sep 2016 05:59:41 -0000 Author: sephe Date: Mon Sep 12 05:59:39 2016 New Revision: 305729 URL: https://svnweb.freebsd.org/changeset/base/305729 Log: hyperv/hn: Reorganize RNDIS attach MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7830 Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Modified: head/sys/dev/hyperv/netvsc/hv_rndis_filter.c ============================================================================== --- head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Sep 12 05:37:44 2016 (r305728) +++ head/sys/dev/hyperv/netvsc/hv_rndis_filter.c Mon Sep 12 05:59:39 2016 (r305729) @@ -78,7 +78,6 @@ static void hv_rf_receive_data(struct hn static int hv_rf_query_device_mac(struct hn_softc *sc, uint8_t *eaddr); static int hv_rf_query_device_link_status(struct hn_softc *sc, uint32_t *link_status); -static int hv_rf_init_device(struct hn_softc *sc); static int hn_rndis_query(struct hn_softc *sc, uint32_t oid, const void *idata, size_t idlen, void *odata, size_t *odlen0); @@ -922,11 +921,8 @@ hn_rndis_set_rxfilter(struct hn_softc *s return (error); } -/* - * RNDIS filter init device - */ static int -hv_rf_init_device(struct hn_softc *sc) +hn_rndis_init(struct hn_softc *sc) { struct rndis_init_req *req; const struct rndis_init_comp *comp; @@ -1007,9 +1003,26 @@ hv_rf_halt_device(struct hn_softc *sc) return (0); } -/* - * RNDIS filter on device add - */ +static int +hn_rndis_attach(struct hn_softc *sc) +{ + int error; + + /* + * Initialize RNDIS. + */ + error = hn_rndis_init(sc); + if (error) + return (error); + + /* + * Configure NDIS offload settings. + * XXX no offloading, if error happened? + */ + hn_rndis_conf_offload(sc); + return (0); +} + int hv_rf_on_device_add(struct hn_softc *sc, void *additl_info, int *nchan0, int mtu) @@ -1023,28 +1036,15 @@ hv_rf_on_device_add(struct hn_softc *sc, if (ret != 0) return (ret); - /* - * Initialize the rndis device - */ - - /* Send the rndis initialization message */ - ret = hv_rf_init_device(sc); - if (ret != 0) { - /* - * TODO: If rndis init failed, we will need to shut down - * the channel - */ - } + ret = hn_rndis_attach(sc); + if (ret != 0) + return (ret); /* Get the mac address */ ret = hv_rf_query_device_mac(sc, dev_info->mac_addr); if (ret != 0) { /* TODO: shut down rndis device and the channel */ } - - /* Configure NDIS offload settings */ - hn_rndis_conf_offload(sc); - hv_rf_query_device_link_status(sc, &dev_info->link_state); if (sc->hn_ndis_ver < HN_NDIS_VERSION_6_30 || nchan == 1) {