From owner-svn-soc-all@freebsd.org Mon May 23 13:37:39 2016 Return-Path: Delivered-To: svn-soc-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 A5E41B462AE for ; Mon, 23 May 2016 13:37:39 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (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 9A0AA1D2F for ; Mon, 23 May 2016 13:37:39 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u4NDbdlZ039840 for ; Mon, 23 May 2016 13:37:39 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4NDbdTS039789 for svn-soc-all@FreeBSD.org; Mon, 23 May 2016 13:37:39 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 23 May 2016 13:37:39 GMT Message-Id: <201605231337.u4NDbdTS039789@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r303684 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2016 13:37:39 -0000 Author: vincenzo Date: Mon May 23 13:37:38 2016 New Revision: 303684 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303684 Log: ptnet: attach: allocate ethernet interface data structure The if_alloc() function is called to allocate an Ethernet interface to represent the ptnet device. Although ptnet does not have a link speed, we assume 10 Gbps. Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon May 23 13:33:35 2016 (r303683) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon May 23 13:37:38 2016 (r303684) @@ -85,7 +85,8 @@ #include struct ptnet_softc { - struct ifnet *ifp; + device_t dev; + struct ifnet *ifp; }; static int ptnet_probe(device_t); @@ -135,11 +136,28 @@ ptnet_attach(device_t dev) { struct ptnet_softc *sc; + struct ifnet *ifp; printf("%s\n", __func__); sc = device_get_softc(dev); - sc->ifp = NULL; + sc->dev = dev; + sc->ifp = ifp = if_alloc(IFT_ETHER); + if (ifp == NULL) { + device_printf(dev, "Failed to allocate ifnet\n"); + return (ENOMEM); + } + + if_initname(ifp, device_get_name(dev), device_get_unit(dev)); + if_initbaudrate(ifp, IF_Gbps(10)); + ifp->if_softc = sc; + ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX; + ifp->if_init = NULL; + ifp->if_start = NULL; + + IFQ_SET_MAXLEN(&ifp->if_snd, 255); + ifp->if_snd.ifq_drv_maxlen = 255; + IFQ_SET_READY(&ifp->if_snd); return (0); }