From owner-svn-src-user@freebsd.org Thu May 12 20:53:51 2016 Return-Path: Delivered-To: svn-src-user@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 4F652B39D7C for ; Thu, 12 May 2016 20:53:51 +0000 (UTC) (envelope-from ngie@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 055231A32; Thu, 12 May 2016 20:53:50 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4CKroor053377; Thu, 12 May 2016 20:53:50 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4CKroZI053376; Thu, 12 May 2016 20:53:50 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201605122053.u4CKroZI053376@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Thu, 12 May 2016 20:53:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r299570 - user/ngie/ntb-hacking/sys/dev/ntb/if_ntb X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2016 20:53:51 -0000 Author: ngie Date: Thu May 12 20:53:49 2016 New Revision: 299570 URL: https://svnweb.freebsd.org/changeset/base/299570 Log: Take two on r299569 As mjohnston noted, I was modifying the local pointer to ifp, not the address to the pointer to ifp, so my last change was a no-op. Instantiate/set ifp/qp at the end of setup_ntb_interface(..) so eventually things can be correctly assumed sane at the end of the function, or associated state is torn down properly qp dealloc on failure might need some work Modified: user/ngie/ntb-hacking/sys/dev/ntb/if_ntb/if_ntb.c Modified: user/ngie/ntb-hacking/sys/dev/ntb/if_ntb/if_ntb.c ============================================================================== --- user/ngie/ntb-hacking/sys/dev/ntb/if_ntb/if_ntb.c Thu May 12 20:21:40 2016 (r299569) +++ user/ngie/ntb-hacking/sys/dev/ntb/if_ntb/if_ntb.c Thu May 12 20:53:49 2016 (r299570) @@ -398,6 +398,7 @@ static int ntb_setup_interface(void) { struct ifnet *ifp; + struct ntb_transport_qp *qp; struct ntb_queue_handlers handlers = { ntb_net_rx_handler, ntb_net_tx_handler, ntb_net_event_handler }; int rc; @@ -408,7 +409,7 @@ ntb_setup_interface(void) return (ENXIO); } - ifp = net_softc.ifp = if_alloc(IFT_ETHER); + ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { ntb_transport_free(&net_softc); printf("ntb: Cannot allocate ifnet structure\n"); @@ -418,12 +419,12 @@ ntb_setup_interface(void) rc = ntb_transport_probe(&net_softc); if (rc != 0) { + if_free(ifp); printf("ntb: Cannot init transport: %d\n", rc); return (rc); } - net_softc.qp = ntb_transport_create_queue(ifp, net_softc.ntb, - &handlers); + qp = ntb_transport_create_queue(ifp, net_softc.ntb, &handlers); ifp->if_init = ntb_net_init; ifp->if_softc = &net_softc; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; @@ -436,12 +437,16 @@ ntb_setup_interface(void) ether_ifattach(ifp, net_softc.eaddr); ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_JUMBO_MTU; ifp->if_capenable = ifp->if_capabilities; - ifp->if_mtu = ntb_transport_max_size(net_softc.qp) - ETHER_HDR_LEN - + ifp->if_mtu = ntb_transport_max_size(qp) - ETHER_HDR_LEN - ETHER_CRC_LEN; - ntb_transport_link_up(net_softc.qp); - net_softc.bufsize = ntb_transport_max_size(net_softc.qp) + + net_softc.bufsize = ntb_transport_max_size(qp) + sizeof(struct ether_header); + + net_softc.ifp = ifp; + net_softc.qp = qp; + + ntb_transport_link_up(net_softc.qp); return (0); }