From owner-svn-soc-all@freebsd.org Sun May 22 19:37:59 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 D6AE8B46627 for ; Sun, 22 May 2016 19:37:59 +0000 (UTC) (envelope-from iateaca@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 BB89B17F2 for ; Sun, 22 May 2016 19:37:59 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u4MJbxtC040699 for ; Sun, 22 May 2016 19:37:59 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4MJbwXP040671 for svn-soc-all@FreeBSD.org; Sun, 22 May 2016 19:37:58 GMT (envelope-from iateaca@FreeBSD.org) Date: Sun, 22 May 2016 19:37:58 GMT Message-Id: <201605221937.u4MJbwXP040671@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to iateaca@FreeBSD.org using -f From: iateaca@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r303606 - soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve 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: Sun, 22 May 2016 19:37:59 -0000 Author: iateaca Date: Sun May 22 19:37:57 2016 New Revision: 303606 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303606 Log: add hda_codec module design the interface of communication between the hda controller and codec using data set design the concept of hda_codec_class and hda_codec_inst when CORBWP is set load from the system memory the VERB command using DMA M bhyve/Makefile A bhyve/hda_codec.c M bhyve/pci_hda.c A bhyve/pci_hda.h Added: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/Makefile soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/Makefile ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/Makefile Sun May 22 18:20:45 2016 (r303605) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/Makefile Sun May 22 19:37:57 2016 (r303606) @@ -20,6 +20,7 @@ consport.c \ dbgport.c \ fwctl.c \ + hda_codec.c \ inout.c \ ioapic.c \ mem.c \ Added: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/hda_codec.c Sun May 22 19:37:57 2016 (r303606) @@ -0,0 +1,18 @@ + +#include "pci_hda.h" + +static int +hda_codec_init(struct hda_codec_inst *hci, const char *opts) +{ + DPRINTF("cad: 0x%x opts: %s\n", hci->cad, opts); + + return 0; +} + +struct hda_codec_class hda_codec = { + .name = "hda_codec", + .init = hda_codec_init, +}; + +HDA_EMUL_SET(hda_codec); + Modified: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c ============================================================================== --- soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sun May 22 18:20:45 2016 (r303605) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.c Sun May 22 19:37:57 2016 (r303606) @@ -1,28 +1,10 @@ -#include -#include -#include -#include -#include - +#include "pci_hda.h" #include "bhyverun.h" #include "pci_emul.h" #include "hdac_reg.h" /* - * HDA Debug Log - */ -#define DEBUG_HDA 1 -#if DEBUG_HDA == 1 -static FILE *dbg; -#define DPRINTF(fmt, arg...) \ -do {fprintf(dbg, "%s-%d: " fmt, __func__, __LINE__, ##arg); \ -fflush(dbg); } while (0) -#else -#define DPRINTF(fmt, arg...) -#endif - -/* * HDA defines */ #define INTEL_VENDORID 0x8086 @@ -30,6 +12,7 @@ #define HDA_OSS_NO 0x04 #define HDA_ISS_NO 0x04 +#define HDA_CODEC_MAX 0x10 #define HDA_LAST_OFFSET (0x80 + ((HDA_ISS_NO) * 0x20) + ((HDA_OSS_NO) * 0x20)) #define HDA_CORB_ENTRY_LEN 0x04 #define HDA_RIRB_ENTRY_LEN 0x08 @@ -57,6 +40,9 @@ struct hda_codec_cmd_ctl corb; struct hda_codec_cmd_ctl rirb; + + struct hda_codec_inst *codecs[HDA_CODEC_MAX]; + uint8_t codecs_no; }; /* @@ -70,6 +56,11 @@ hda_set_field_by_offset(struct hda_softc *sc, uint32_t offset, uint32_t mask, uint32_t value); static struct hda_softc *hda_init(const char *opts); +static int +hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec); +static struct hda_codec_class * +hda_find_codec_class(const char *name); + static void hda_reset_regs(struct hda_softc *sc); static uint32_t hda_read(struct hda_softc *sc, uint32_t offset); @@ -98,6 +89,8 @@ static void hda_set_gctl(struct hda_softc *sc, uint32_t offset, uint32_t old); static void +hda_set_corbwp(struct hda_softc *sc, uint32_t offset, uint32_t old); +static void hda_set_corbctl(struct hda_softc *sc, uint32_t offset, uint32_t old); static void hda_set_rirbctl(struct hda_softc *sc, uint32_t offset, uint32_t old); @@ -121,6 +114,7 @@ static const hda_set_reg_handler hda_set_reg_table[] = { [HDAC_GCTL] = hda_set_gctl, + [HDAC_CORBWP] = hda_set_corbwp, [HDAC_CORBCTL] = hda_set_corbctl, [HDAC_RIRBCTL] = hda_set_rirbctl, @@ -166,6 +160,12 @@ PCI_EMUL_SET(pci_de_hda); +SET_DECLARE(hda_codec_class_set, struct hda_codec_class); + +#if DEBUG_HDA == 1 +FILE *dbg; +#endif + /* * HDA module function definitions */ @@ -204,6 +204,8 @@ static struct hda_softc *hda_init(const char *opts) { struct hda_softc *sc = NULL; + struct hda_codec_class *codec = NULL; + int err; #if DEBUG_HDA == 1 dbg = fopen("/tmp/bhyve_hda.log", "w+"); @@ -217,9 +219,58 @@ hda_reset_regs(sc); + /* + * TODO search all the codecs declared in opts + * For now we play with one single codec + */ + codec = hda_find_codec_class("hda_codec"); + if (codec) { + err = hda_codec_constructor(sc, codec); + assert(!err); + } + return sc; } +static int +hda_codec_constructor(struct hda_softc *sc, struct hda_codec_class *codec) +{ + struct hda_codec_inst *hci = NULL; + int err; + + if (sc->codecs_no >= HDA_CODEC_MAX) + return -1; + + hci = calloc(1, sizeof(struct hda_codec_inst)); + if (!hci) + return -1; + + hci->hda = sc; + hci->cad = sc->codecs_no; + + sc->codecs[sc->codecs_no++] = hci; + + err = codec->init(hci, NULL); + assert(!err); + + return 0; +} + +static struct hda_codec_class * +hda_find_codec_class(const char *name) +{ + struct hda_codec_class **pdpp = NULL, *pdp = NULL; + + SET_FOREACH(pdpp, hda_codec_class_set) { + pdp = *pdpp; + if (!strcmp(pdp->name, name)) { + return (pdp); + } + } + + return NULL; +} + static void hda_reset_regs(struct hda_softc *sc) { DPRINTF("Reset the HDA controller registers ...\n"); @@ -395,12 +446,40 @@ if (!(value & HDAC_GCTL_CRST)) { hda_reset_regs(sc); + hda_set_reg_by_offset(sc, HDAC_STATESTS, 0x0001); } return; } static void +hda_set_corbwp(struct hda_softc *sc, uint32_t offset, uint32_t old) +{ + struct hda_codec_cmd_ctl *corb = &sc->corb; + uint32_t value = sc->regs[offset]; + uint32_t verb = 0; + + corb->wp = value; + + /* + * TODO do it in loop + */ + if (corb->wp != corb->rp && corb->run) { + corb->rp++; + verb = hda_dma_ld_dword(corb->dma_vaddr + HDA_CORB_ENTRY_LEN * corb->rp); + + /* + * TODO get cad from verb and send command to codec[cad] + */ + DPRINTF("VERB: 0x%x\n", verb); + } + + hda_set_reg_by_offset(sc, HDAC_CORBRP, corb->rp); + + return; +} + +static void hda_set_corbctl(struct hda_softc *sc, uint32_t offset, uint32_t old) { uint32_t value = sc->regs[offset]; Added: soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/iateaca/bhyve-hda-head/usr.sbin/bhyve/pci_hda.h Sun May 22 19:37:57 2016 (r303606) @@ -0,0 +1,43 @@ + +#ifndef _HDA_EMUL_H_ +#define _HDA_EMUL_H_ + +#include +#include +#include +#include +#include + +#include +#include +#include + +/* + * HDA Debug Log + */ +#define DEBUG_HDA 1 +#if DEBUG_HDA == 1 +extern FILE *dbg; +#define DPRINTF(fmt, arg...) \ +do {fprintf(dbg, "%s-%d: " fmt, __func__, __LINE__, ##arg); \ +fflush(dbg); } while (0) +#else +#define DPRINTF(fmt, arg...) +#endif + +struct hda_softc; + +struct hda_codec_inst { + struct hda_softc *hda; + uint8_t cad; + void *priv; +}; + +struct hda_codec_class { + char *name; + int (*init)(struct hda_codec_inst *hci, const char *opts); +}; + +#define HDA_EMUL_SET(x) DATA_SET(hda_codec_class_set, x); + +#endif /* _HDA_EMUL_H_ */ From owner-svn-soc-all@freebsd.org Mon May 23 13:33:37 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 DDA74B461CB for ; Mon, 23 May 2016 13:33:37 +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 D122F1CBF for ; Mon, 23 May 2016 13:33:37 +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 u4NDXbWZ034231 for ; Mon, 23 May 2016 13:33:37 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4NDXaxR034227 for svn-soc-all@FreeBSD.org; Mon, 23 May 2016 13:33:36 GMT (envelope-from vincenzo@FreeBSD.org) Date: Mon, 23 May 2016 13:33:36 GMT Message-Id: <201605231333.u4NDXaxR034227@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: r303683 - in soc2016/vincenzo/head/sys: dev/netmap modules/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:33:38 -0000 Author: vincenzo Date: Mon May 23 13:33:35 2016 New Revision: 303683 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303683 Log: Add driver stub for ptnet driver, as a new file Also add the new file to the netmap Makefile. Added: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h soc2016/vincenzo/head/sys/modules/netmap/Makefile Added: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon May 23 13:33:35 2016 (r303683) @@ -0,0 +1,185 @@ +/*- + * Copyright (c) 2016, Vincenzo Maffione + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* Driver for ptnet paravirtualized network device. */ + +#include +//__FBSDID("$FreeBSD: releng/10.2/sys/dev/netmap/netmap_ptnet.c xxx $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#include "opt_inet.h" +#include "opt_inet6.h" + +#include +#include +#include +#include +#include + +struct ptnet_softc { + struct ifnet *ifp; +}; + +static int ptnet_probe(device_t); +static int ptnet_attach(device_t); +static int ptnet_detach(device_t); +static int ptnet_suspend(device_t); +static int ptnet_resume(device_t); +static int ptnet_shutdown(device_t); + +static device_method_t ptnet_methods[] = { + DEVMETHOD(device_probe, ptnet_probe), + DEVMETHOD(device_attach, ptnet_attach), + DEVMETHOD(device_detach, ptnet_detach), + DEVMETHOD(device_suspend, ptnet_suspend), + DEVMETHOD(device_resume, ptnet_resume), + DEVMETHOD(device_shutdown, ptnet_shutdown), + DEVMETHOD_END +}; + +static driver_t ptnet_driver = { + "ptnet", + ptnet_methods, + sizeof(struct ptnet_softc) +}; +static devclass_t ptnet_devclass; + +DRIVER_MODULE(ptnet, pci, ptnet_driver, ptnet_devclass, 0, 0); +MODULE_VERSION(ptnet, 1); +MODULE_DEPEND(ptnet, netmap, 1, 1, 1); + +static int +ptnet_probe(device_t dev) +{ + printf("%s\n", __func__); + + if (pci_get_vendor(dev) != PTNETMAP_PCI_VENDOR_ID || + pci_get_device(dev) != PTNETMAP_PCI_NETIF_ID) { + return (ENXIO); + } + + device_set_desc(dev, "ptnet network adapter"); + + return (BUS_PROBE_DEFAULT); +} + +static int +ptnet_attach(device_t dev) +{ + struct ptnet_softc *sc; + + printf("%s\n", __func__); + + sc = device_get_softc(dev); + sc->ifp = NULL; + + return (0); +} + +static int +ptnet_detach(device_t dev) +{ + printf("%s\n", __func__); + + return (0); +} + +static int +ptnet_suspend(device_t dev) +{ + struct ptnet_softc *sc; + + sc = device_get_softc(dev); + (void)sc; + + return (0); +} + +static int +ptnet_resume(device_t dev) +{ + struct ptnet_softc *sc; + + sc = device_get_softc(dev); + (void)sc; + + return (0); +} + +static int +ptnet_shutdown(device_t dev) +{ + /* + * Suspend already does all of what we need to + * do here; we just never expect to be resumed. + */ + return (ptnet_suspend(dev)); +} Modified: soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon May 23 12:58:24 2016 (r303682) +++ soc2016/vincenzo/head/sys/dev/netmap/netmap_virt.h Mon May 23 13:33:35 2016 (r303683) @@ -252,7 +252,6 @@ #endif /* NETMAP_VIRT_CSB */ - #if defined(NETMAP_API) && !defined(NETMAP_VIRT_PTNETMAP) #define NETMAP_VIRT_PTNETMAP Modified: soc2016/vincenzo/head/sys/modules/netmap/Makefile ============================================================================== --- soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon May 23 12:58:24 2016 (r303682) +++ soc2016/vincenzo/head/sys/modules/netmap/Makefile Mon May 23 13:33:35 2016 (r303683) @@ -21,6 +21,7 @@ SRCS += netmap_pipe.c SRCS += netmap_monitor.c SRCS += ptnetmap.c +SRCS += if_ptnet.c SRCS += opt_inet.h opt_inet6.h .include 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); } From owner-svn-soc-all@freebsd.org Tue May 24 17:01:51 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 3235DB4894E for ; Tue, 24 May 2016 17:01:51 +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 0E39D1AE2 for ; Tue, 24 May 2016 17:01:51 +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 u4OH1oGN064433 for ; Tue, 24 May 2016 17:01:50 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4OH1oe2064335 for svn-soc-all@FreeBSD.org; Tue, 24 May 2016 17:01:50 GMT (envelope-from vincenzo@FreeBSD.org) Date: Tue, 24 May 2016 17:01:50 GMT Message-Id: <201605241701.u4OH1oe2064335@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: r303799 - 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: Tue, 24 May 2016 17:01:51 -0000 Author: vincenzo Date: Tue May 24 17:01:49 2016 New Revision: 303799 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303799 Log: ptnet_attach: initialize ifmedia struct 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 Tue May 24 16:41:37 2016 (r303798) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Tue May 24 17:01:49 2016 (r303799) @@ -87,6 +87,7 @@ struct ptnet_softc { device_t dev; struct ifnet *ifp; + struct ifmedia media; }; static int ptnet_probe(device_t); @@ -96,6 +97,12 @@ static int ptnet_resume(device_t); static int ptnet_shutdown(device_t); +static void ptnet_init(void *opaque); +static void ptnet_start(struct ifnet *ifp); + +static int ptnet_media_change(struct ifnet *ifp); +static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); + static device_method_t ptnet_methods[] = { DEVMETHOD(device_probe, ptnet_probe), DEVMETHOD(device_attach, ptnet_attach), @@ -152,13 +159,18 @@ 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; + ifp->if_init = ptnet_init; + ifp->if_start = ptnet_start; IFQ_SET_MAXLEN(&ifp->if_snd, 255); ifp->if_snd.ifq_drv_maxlen = 255; IFQ_SET_READY(&ifp->if_snd); + ifmedia_init(&sc->media, IFM_IMASK, ptnet_media_change, + ptnet_media_status); + ifmedia_add(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL); + ifmedia_set(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX); + return (0); } @@ -201,3 +213,45 @@ */ return (ptnet_suspend(dev)); } + +static void +ptnet_init(void *opaque) +{ + struct ptnet_softc *sc = opaque; + (void)sc; +} + +static void +ptnet_start(struct ifnet *ifp) +{ +} + +static int +ptnet_media_change(struct ifnet *ifp) +{ + struct ptnet_softc *sc = ifp->if_softc; + struct ifmedia *ifm = &sc->media; + + if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER) { + return (EINVAL); + } + + return (0); +} + + +static void +ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr) +{ + ifmr->ifm_status = IFM_AVALID; + ifmr->ifm_active = IFM_ETHER; + + //lock + if (1) { + ifmr->ifm_status |= IFM_ACTIVE; + ifmr->ifm_active |= IFM_10G_T | IFM_FDX; + } else { + ifmr->ifm_active |= IFM_NONE; + } + //unlock +} From owner-svn-soc-all@freebsd.org Tue May 24 17:02:44 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 0A851B48A8B for ; Tue, 24 May 2016 17:02:44 +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 F2E221BB3 for ; Tue, 24 May 2016 17:02:43 +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 u4OH2hUH077955 for ; Tue, 24 May 2016 17:02:43 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4OH2hl4077897 for svn-soc-all@FreeBSD.org; Tue, 24 May 2016 17:02:43 GMT (envelope-from vincenzo@FreeBSD.org) Date: Tue, 24 May 2016 17:02:43 GMT Message-Id: <201605241702.u4OH2hl4077897@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: r303800 - 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: Tue, 24 May 2016 17:02:44 -0000 Author: vincenzo Date: Tue May 24 17:02:42 2016 New Revision: 303800 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303800 Log: ptnet_attach: attach the ethernet device 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 Tue May 24 17:01:49 2016 (r303799) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Tue May 24 17:02:42 2016 (r303800) @@ -86,8 +86,11 @@ struct ptnet_softc { device_t dev; - struct ifnet *ifp; - struct ifmedia media; + struct ifnet *ifp; + struct ifmedia media; + struct mtx core_mtx; + char core_mtx_name[16]; + char hwaddr[ETHER_ADDR_LEN]; }; static int ptnet_probe(device_t); @@ -171,6 +174,14 @@ ifmedia_add(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL); ifmedia_set(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX); + memset(sc->hwaddr, 0, sizeof(sc->hwaddr)); + ether_ifattach(ifp, sc->hwaddr); + + ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); + ifp->if_capabilities |= IFCAP_JUMBO_MTU | IFCAP_VLAN_MTU; + + ifp->if_capenable = ifp->if_capabilities; + return (0); } From owner-svn-soc-all@freebsd.org Tue May 24 17:04:02 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 EC6B9B48AD5 for ; Tue, 24 May 2016 17:04:02 +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 E09A71BF0 for ; Tue, 24 May 2016 17:04:02 +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 u4OH42Fv079847 for ; Tue, 24 May 2016 17:04:02 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4OH42jA079845 for svn-soc-all@FreeBSD.org; Tue, 24 May 2016 17:04:02 GMT (envelope-from vincenzo@FreeBSD.org) Date: Tue, 24 May 2016 17:04:02 GMT Message-Id: <201605241704.u4OH42jA079845@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: r303801 - 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: Tue, 24 May 2016 17:04:03 -0000 Author: vincenzo Date: Tue May 24 17:04:01 2016 New Revision: 303801 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303801 Log: ptnet: add core lock 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 Tue May 24 17:02:42 2016 (r303800) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Tue May 24 17:04:01 2016 (r303801) @@ -93,6 +93,18 @@ char hwaddr[ETHER_ADDR_LEN]; }; +#define PTNET_CORE_LOCK_INIT(_sc) do { \ + snprintf((_sc)->core_mtx_name, sizeof((_sc)->core_mtx_name), \ + "%s", device_get_nameunit(sc->dev)); \ + mtx_init(&(_sc)->core_mtx, (_sc)->core_mtx_name, \ + "ptnet core lock", MTX_DEF); \ + } while (0) + +#define PTNET_CORE_LOCK_FINI(_sc) mtx_destroy(&(_sc)->core_mtx) + +#define PTNET_CORE_LOCK(_sc) mtx_lock(&(_sc)->core_mtx) +#define PTNET_CORE_UNLOCK(_sc) mtx_unlock(&(_sc)->core_mtx) + static int ptnet_probe(device_t); static int ptnet_attach(device_t); static int ptnet_detach(device_t); @@ -152,6 +164,9 @@ sc = device_get_softc(dev); sc->dev = dev; + + PTNET_CORE_LOCK_INIT(sc); + sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "Failed to allocate ifnet\n"); @@ -188,8 +203,12 @@ static int ptnet_detach(device_t dev) { + struct ptnet_softc *sc = device_get_softc(dev); + printf("%s\n", __func__); + PTNET_CORE_LOCK_FINI(sc); + return (0); } @@ -257,12 +276,10 @@ ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; - //lock if (1) { ifmr->ifm_status |= IFM_ACTIVE; ifmr->ifm_active |= IFM_10G_T | IFM_FDX; } else { ifmr->ifm_active |= IFM_NONE; } - //unlock } From owner-svn-soc-all@freebsd.org Thu May 26 15:33:32 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 82823B4B668 for ; Thu, 26 May 2016 15:33:32 +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 76AC018AD for ; Thu, 26 May 2016 15:33:32 +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 u4QFXWNs021162 for ; Thu, 26 May 2016 15:33:32 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFXVPs021146 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:33:31 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:33:31 GMT Message-Id: <201605261533.u4QFXVPs021146@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: r303931 - 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: Thu, 26 May 2016 15:33:32 -0000 Author: vincenzo Date: Thu May 26 15:33:31 2016 New Revision: 303931 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303931 Log: ptnet: implement detach function 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 Thu May 26 14:26:49 2016 (r303930) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:33:31 2016 (r303931) @@ -207,6 +207,17 @@ printf("%s\n", __func__); + if (device_is_attached(dev)) { + ether_ifdetach(sc->ifp); + } + + ifmedia_removeall(&sc->media); + + if (sc->ifp) { + if_free(sc->ifp); + sc->ifp = NULL; + } + PTNET_CORE_LOCK_FINI(sc); return (0); From owner-svn-soc-all@freebsd.org Thu May 26 15:33:56 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 783CAB4B69A for ; Thu, 26 May 2016 15:33:56 +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 5284A18C9 for ; Thu, 26 May 2016 15:33:56 +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 u4QFXu3u021643 for ; Thu, 26 May 2016 15:33:56 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFXtwE021636 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:33:55 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:33:55 GMT Message-Id: <201605261533.u4QFXtwE021636@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: r303932 - 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: Thu, 26 May 2016 15:33:56 -0000 Author: vincenzo Date: Thu May 26 15:33:55 2016 New Revision: 303932 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303932 Log: ptnet: alloc I/O PCI bar 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 Thu May 26 15:33:31 2016 (r303931) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:33:55 2016 (r303932) @@ -84,6 +84,10 @@ #include #include +#ifndef PTNET_CSB_ALLOC +#error "No support for on-device CSB" +#endif + struct ptnet_softc { device_t dev; struct ifnet *ifp; @@ -91,6 +95,8 @@ struct mtx core_mtx; char core_mtx_name[16]; char hwaddr[ETHER_ADDR_LEN]; + struct resource *iomem; + struct resource *msix_mem; }; #define PTNET_CORE_LOCK_INIT(_sc) do { \ @@ -142,7 +148,7 @@ static int ptnet_probe(device_t dev) { - printf("%s\n", __func__); + device_printf(dev, "%s\n", __func__); if (pci_get_vendor(dev) != PTNETMAP_PCI_VENDOR_ID || pci_get_device(dev) != PTNETMAP_PCI_NETIF_ID) { @@ -159,14 +165,25 @@ { struct ptnet_softc *sc; struct ifnet *ifp; + int rid; - printf("%s\n", __func__); + device_printf(dev, "%s\n", __func__); sc = device_get_softc(dev); sc->dev = dev; - PTNET_CORE_LOCK_INIT(sc); + /* Setup PCI resources. */ + pci_enable_busmaster(dev); + + rid = PCIR_BAR(PTNETMAP_IO_PCI_BAR); + sc->iomem = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, + RF_ACTIVE); + if (!sc->iomem) { + device_printf(dev, "Failed to map I/O BAR"); + return (ENXIO); + } + /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "Failed to allocate ifnet\n"); @@ -197,6 +214,8 @@ ifp->if_capenable = ifp->if_capabilities; + PTNET_CORE_LOCK_INIT(sc); + return (0); } @@ -220,6 +239,9 @@ PTNET_CORE_LOCK_FINI(sc); + bus_release_resource(dev, SYS_RES_IOPORT, + PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem); + return (0); } From owner-svn-soc-all@freebsd.org Thu May 26 15:34:26 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 CCF06B4B6CA for ; Thu, 26 May 2016 15:34:26 +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 A7C0B18F0 for ; Thu, 26 May 2016 15:34:26 +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 u4QFYQLM022503 for ; Thu, 26 May 2016 15:34:26 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFYQfh022501 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:34:26 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:34:26 GMT Message-Id: <201605261534.u4QFYQfh022501@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: r303933 - 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: Thu, 26 May 2016 15:34:26 -0000 Author: vincenzo Date: Thu May 26 15:34:25 2016 New Revision: 303933 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303933 Log: ptnet: carry out features negotiation 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 Thu May 26 15:33:55 2016 (r303932) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:34:25 2016 (r303933) @@ -95,8 +95,13 @@ struct mtx core_mtx; char core_mtx_name[16]; char hwaddr[ETHER_ADDR_LEN]; + + /* PCI BARs support. */ struct resource *iomem; struct resource *msix_mem; + + /* Mirror of PTFEAT register. */ + uint32_t ptfeatures; }; #define PTNET_CORE_LOCK_INIT(_sc) do { \ @@ -163,9 +168,10 @@ static int ptnet_attach(device_t dev) { + uint32_t ptfeatures = NET_PTN_FEATURES_BASE; struct ptnet_softc *sc; struct ifnet *ifp; - int rid; + int err, rid; device_printf(dev, "%s\n", __func__); @@ -183,11 +189,24 @@ return (ENXIO); } + /* Check if we are supported by the hypervisor. If not, + * bail out immediately. */ + bus_write_4(sc->iomem, PTNET_IO_PTFEAT, ptfeatures); /* wanted */ + ptfeatures = bus_read_4(sc->iomem, PTNET_IO_PTFEAT); /* acked */ + if (!(ptfeatures & NET_PTN_FEATURES_BASE)) { + device_printf(dev, "Hypervisor does not support netmap " + "passthorugh"); + err = ENXIO; + goto err_path; + } + sc->ptfeatures = ptfeatures; + /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { device_printf(dev, "Failed to allocate ifnet\n"); - return (ENOMEM); + err = ENOMEM; + goto err_path; } if_initname(ifp, device_get_name(dev), device_get_unit(dev)); @@ -217,6 +236,10 @@ PTNET_CORE_LOCK_INIT(sc); return (0); + +err_path: + ptnet_detach(dev); + return err; } static int @@ -224,23 +247,22 @@ { struct ptnet_softc *sc = device_get_softc(dev); - printf("%s\n", __func__); - - if (device_is_attached(dev)) { - ether_ifdetach(sc->ifp); - } - - ifmedia_removeall(&sc->media); + device_printf(dev, "%s\n", __func__); if (sc->ifp) { + ether_ifdetach(sc->ifp); + ifmedia_removeall(&sc->media); if_free(sc->ifp); sc->ifp = NULL; } PTNET_CORE_LOCK_FINI(sc); - bus_release_resource(dev, SYS_RES_IOPORT, - PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem); + if (sc->iomem) { + bus_release_resource(dev, SYS_RES_IOPORT, + PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem); + sc->iomem = NULL; + } return (0); } From owner-svn-soc-all@freebsd.org Thu May 26 15:34:51 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 25ABAB4B6E7 for ; Thu, 26 May 2016 15:34:51 +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 00A5C1946 for ; Thu, 26 May 2016 15:34:51 +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 u4QFYo6D023233 for ; Thu, 26 May 2016 15:34:50 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4QFYoNi023217 for svn-soc-all@FreeBSD.org; Thu, 26 May 2016 15:34:50 GMT (envelope-from vincenzo@FreeBSD.org) Date: Thu, 26 May 2016 15:34:50 GMT Message-Id: <201605261534.u4QFYoNi023217@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: r303934 - 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: Thu, 26 May 2016 15:34:51 -0000 Author: vincenzo Date: Thu May 26 15:34:49 2016 New Revision: 303934 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303934 Log: ptnet: allocate CSB 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 Thu May 26 15:34:25 2016 (r303933) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Thu May 26 15:34:49 2016 (r303934) @@ -96,12 +96,14 @@ char core_mtx_name[16]; char hwaddr[ETHER_ADDR_LEN]; + /* Mirror of PTFEAT register. */ + uint32_t ptfeatures; + /* PCI BARs support. */ struct resource *iomem; struct resource *msix_mem; - /* Mirror of PTFEAT register. */ - uint32_t ptfeatures; + struct ptnet_csb *csb; }; #define PTNET_CORE_LOCK_INIT(_sc) do { \ @@ -169,6 +171,9 @@ ptnet_attach(device_t dev) { uint32_t ptfeatures = NET_PTN_FEATURES_BASE; +#if 0 + unsigned int num_rx_rings, num_tx_rings; +#endif struct ptnet_softc *sc; struct ifnet *ifp; int err, rid; @@ -184,8 +189,8 @@ rid = PCIR_BAR(PTNETMAP_IO_PCI_BAR); sc->iomem = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); - if (!sc->iomem) { - device_printf(dev, "Failed to map I/O BAR"); + if (sc->iomem == NULL) { + device_printf(dev, "Failed to map I/O BAR\n"); return (ENXIO); } @@ -195,11 +200,21 @@ ptfeatures = bus_read_4(sc->iomem, PTNET_IO_PTFEAT); /* acked */ if (!(ptfeatures & NET_PTN_FEATURES_BASE)) { device_printf(dev, "Hypervisor does not support netmap " - "passthorugh"); + "passthorugh\n"); err = ENXIO; goto err_path; } sc->ptfeatures = ptfeatures; +#if 0 + num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); + num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); +#endif + sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, M_NOWAIT | M_ZERO); + if (sc->csb == NULL) { + device_printf(dev, "Failed to allocate CSB\n"); + err = ENOMEM; + goto err_path; + } /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); @@ -256,6 +271,11 @@ sc->ifp = NULL; } + if (sc->csb) { + free(sc->csb, M_DEVBUF); + sc->csb = NULL; + } + PTNET_CORE_LOCK_FINI(sc); if (sc->iomem) { From owner-svn-soc-all@freebsd.org Fri May 27 14:39:42 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 8304CB4B689 for ; Fri, 27 May 2016 14:39:42 +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 695A612B3 for ; Fri, 27 May 2016 14:39:42 +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 u4REdg93044722 for ; Fri, 27 May 2016 14:39:42 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4REdfnN044703 for svn-soc-all@FreeBSD.org; Fri, 27 May 2016 14:39:41 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 27 May 2016 14:39:41 GMT Message-Id: <201605271439.u4REdfnN044703@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: r304038 - 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: Fri, 27 May 2016 14:39:42 -0000 Author: vincenzo Date: Fri May 27 14:39:41 2016 New Revision: 304038 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304038 Log: ptnet: CSB allocation 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 Fri May 27 12:02:12 2016 (r304037) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri May 27 14:39:41 2016 (r304038) @@ -47,6 +47,8 @@ #include #include +#include +#include #include #include @@ -209,13 +211,24 @@ num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); #endif - sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, M_NOWAIT | M_ZERO); + /* Allocate CSB and carry out CSB allocation protocol (CSBBAH first, + * then CSBBAL). */ + sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, + M_NOWAIT | M_ZERO); if (sc->csb == NULL) { device_printf(dev, "Failed to allocate CSB\n"); err = ENOMEM; goto err_path; } + { + vm_paddr_t paddr = vtophys(sc->csb); + + bus_write_4(sc->iomem, PTNET_IO_CSBBAH, + (paddr >> 32) & 0xffffffff); + bus_write_4(sc->iomem, PTNET_IO_CSBBAL, paddr & 0xffffffff); + } + /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -272,6 +285,8 @@ } if (sc->csb) { + bus_write_4(sc->iomem, PTNET_IO_CSBBAH, 0); + bus_write_4(sc->iomem, PTNET_IO_CSBBAL, 0); free(sc->csb, M_DEVBUF); sc->csb = NULL; } From owner-svn-soc-all@freebsd.org Fri May 27 14:39:58 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 2D795B4B6A8 for ; Fri, 27 May 2016 14:39:58 +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 21B4512C9 for ; Fri, 27 May 2016 14:39:58 +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 u4REdwQP045062 for ; Fri, 27 May 2016 14:39:58 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4REdvro045036 for svn-soc-all@FreeBSD.org; Fri, 27 May 2016 14:39:57 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 27 May 2016 14:39:57 GMT Message-Id: <201605271439.u4REdvro045036@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: r304039 - 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: Fri, 27 May 2016 14:39:58 -0000 Author: vincenzo Date: Fri May 27 14:39:57 2016 New Revision: 304039 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304039 Log: ptnet: read MAC address from I/O registers 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 Fri May 27 14:39:41 2016 (r304038) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri May 27 14:39:57 2016 (r304039) @@ -178,6 +178,7 @@ #endif struct ptnet_softc *sc; struct ifnet *ifp; + uint32_t macreg; int err, rid; device_printf(dev, "%s\n", __func__); @@ -253,7 +254,15 @@ ifmedia_add(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX, 0, NULL); ifmedia_set(&sc->media, IFM_ETHER | IFM_10G_T | IFM_FDX); - memset(sc->hwaddr, 0, sizeof(sc->hwaddr)); + macreg = bus_read_4(sc->iomem, PTNET_IO_MAC_HI); + sc->hwaddr[0] = (macreg >> 8) & 0xff; + sc->hwaddr[1] = macreg & 0xff; + macreg = bus_read_4(sc->iomem, PTNET_IO_MAC_LO); + sc->hwaddr[2] = (macreg >> 24) & 0xff; + sc->hwaddr[3] = (macreg >> 16) & 0xff; + sc->hwaddr[4] = (macreg >> 8) & 0xff; + sc->hwaddr[5] = macreg & 0xff; + ether_ifattach(ifp, sc->hwaddr); ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); From owner-svn-soc-all@freebsd.org Fri May 27 14:40:16 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 ECE1DB4B6CE for ; Fri, 27 May 2016 14:40:16 +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 E0F8012EA for ; Fri, 27 May 2016 14:40:16 +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 u4REeGNs045657 for ; Fri, 27 May 2016 14:40:16 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4REeGXO045655 for svn-soc-all@FreeBSD.org; Fri, 27 May 2016 14:40:16 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 27 May 2016 14:40:16 GMT Message-Id: <201605271440.u4REeGXO045655@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: r304040 - 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: Fri, 27 May 2016 14:40:17 -0000 Author: vincenzo Date: Fri May 27 14:40:15 2016 New Revision: 304040 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304040 Log: freebsd: ptnet: setup MSI-X PCI BAR 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 Fri May 27 14:39:57 2016 (r304039) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri May 27 14:40:15 2016 (r304040) @@ -105,6 +105,8 @@ struct resource *iomem; struct resource *msix_mem; + unsigned int num_rings; + struct ptnet_csb *csb; }; @@ -133,6 +135,9 @@ static int ptnet_media_change(struct ifnet *ifp); static void ptnet_media_status(struct ifnet *ifp, struct ifmediareq *ifmr); +static int ptnet_irqs_init(struct ptnet_softc *sc); +static void ptnet_irqs_fini(struct ptnet_softc *sc); + static device_method_t ptnet_methods[] = { DEVMETHOD(device_probe, ptnet_probe), DEVMETHOD(device_attach, ptnet_attach), @@ -173,9 +178,7 @@ ptnet_attach(device_t dev) { uint32_t ptfeatures = NET_PTN_FEATURES_BASE; -#if 0 unsigned int num_rx_rings, num_tx_rings; -#endif struct ptnet_softc *sc; struct ifnet *ifp; uint32_t macreg; @@ -208,10 +211,11 @@ goto err_path; } sc->ptfeatures = ptfeatures; -#if 0 + num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); num_rx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_RX_RINGS); -#endif + sc->num_rings = num_tx_rings + num_rx_rings; + /* Allocate CSB and carry out CSB allocation protocol (CSBBAH first, * then CSBBAL). */ sc->csb = malloc(sizeof(struct ptnet_csb), M_DEVBUF, @@ -230,6 +234,11 @@ bus_write_4(sc->iomem, PTNET_IO_CSBBAL, paddr & 0xffffffff); } + err = ptnet_irqs_init(sc); + if (err) { + goto err_path; + } + /* Setup Ethernet interface. */ sc->ifp = ifp = if_alloc(IFT_ETHER); if (ifp == NULL) { @@ -293,6 +302,8 @@ sc->ifp = NULL; } + ptnet_irqs_fini(sc); + if (sc->csb) { bus_write_4(sc->iomem, PTNET_IO_CSBBAH, 0); bus_write_4(sc->iomem, PTNET_IO_CSBBAL, 0); @@ -300,14 +311,14 @@ sc->csb = NULL; } - PTNET_CORE_LOCK_FINI(sc); - if (sc->iomem) { bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(PTNETMAP_IO_PCI_BAR), sc->iomem); sc->iomem = NULL; } + PTNET_CORE_LOCK_FINI(sc); + return (0); } @@ -343,6 +354,53 @@ return (ptnet_suspend(dev)); } +static int +ptnet_irqs_init(struct ptnet_softc *sc) +{ + int rid = PCIR_BAR(PTNETMAP_MSIX_PCI_BAR); + int nvecs = sc->num_rings; + int err = ENOSPC; + + sc->msix_mem = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, + &rid, RF_ACTIVE); + if (sc->msix_mem == NULL) { + device_printf(sc->dev, "Failed to allocate MSIX PCI BAR\n"); + return (ENXIO); + } + + if (pci_msix_count(sc->dev) < nvecs) { + device_printf(sc->dev, "Not enough MSI-X vectors\n"); + goto err_path; + } + + err = pci_alloc_msix(sc->dev, &nvecs); + if (err) { + device_printf(sc->dev, "Failed to allocate MSI-X vectors\n"); + goto err_path; + } + + device_printf(sc->dev, "Allocated %d MSI-X vectors\n", nvecs); + + return 0; +err_path: + ptnet_irqs_fini(sc); + return err; +} + +static void +ptnet_irqs_fini(struct ptnet_softc *sc) +{ + if (sc->msix_mem == NULL) { + return; + } + + pci_release_msi(sc->dev); + + bus_release_resource(sc->dev, SYS_RES_MEMORY, + PCIR_BAR(PTNETMAP_MSIX_PCI_BAR), sc->msix_mem); + sc->msix_mem = NULL; +} + static void ptnet_init(void *opaque) { From owner-svn-soc-all@freebsd.org Fri May 27 20:49:25 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 3B1FAB4D5B1 for ; Fri, 27 May 2016 20:49:25 +0000 (UTC) (envelope-from yuanxunzhang@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 2E71412FC for ; Fri, 27 May 2016 20:49:25 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u4RKnPAU073458 for ; Fri, 27 May 2016 20:49:25 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4RKnNVG073383 for svn-soc-all@FreeBSD.org; Fri, 27 May 2016 20:49:23 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Fri, 27 May 2016 20:49:23 GMT Message-Id: <201605272049.u4RKnNVG073383@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r304058 - soc2016/yuanxunzhang/head/usr.sbin/eaps 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: Fri, 27 May 2016 20:49:25 -0000 Author: yuanxunzhang Date: Fri May 27 20:49:22 2016 New Revision: 304058 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304058 Log: Add the EAPS commands module. Added: soc2016/yuanxunzhang/head/usr.sbin/eaps/ soc2016/yuanxunzhang/head/usr.sbin/eaps/Makefile soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.8 soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords Added: soc2016/yuanxunzhang/head/usr.sbin/eaps/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/Makefile Fri May 27 20:49:22 2016 (r304058) @@ -0,0 +1,19 @@ +# @(#)Makefile 8.2 (Berkeley) 4/18/94 +# $FreeBSD$ + +.include + +PROG= eaps +MAN= eaps.8 +SRCS= eaps.c keywords.h +WARNS?= 3 +CLEANFILES+=keywords.h + +keywords.h: keywords + LC_ALL=C awk '!/^#|^$$/ { \ + printf "#define\tK_%s\t%d\n\t{\"%s\", K_%s},\n", \ + toupper($$1), ++L, $$1, toupper($$1); \ + }' < ${.CURDIR}/keywords > ${.TARGET} || (rm -f ${.TARGET}; false) + +.include + Added: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.8 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.8 Fri May 27 20:49:22 2016 (r304058) @@ -0,0 +1,36 @@ +.\" Copyright (c) 1985, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)eaps.8 8.2 (Berkeley) 5/27/2016 +.\" $FreeBSD$ +.\" +.Dd May 27, 2016 +.Dt EAPS 8 +.Os +.Sh NAME +.Nm eaps +.Nd Ethernet Automatic Protection Switching \ No newline at end of file Added: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Fri May 27 20:49:22 2016 (r304058) @@ -0,0 +1,78 @@ +/* + * Copyright (c) 1984, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Sun Microsystems, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +#ifndef lint +static char const copyright[] = +"@(#) Copyright (c) 1984, 1993\n\ + The Regents of the University of California. All rights reserved.\n"; +#endif /* not lint */ + +#ifndef lint +static char const sccsid[] = "@(#)from: eaps.c 8.2 (Berkeley) 1/2/94"; +#endif /* not lint */ +#endif +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * eaps - display, and configure eaps + */ + +static void +usage(void) +{ + errx(EX_USAGE, "usage: eaps command args"); +} + +int +main(int argc, char *argv[]) +{ + int rtn = 0; + usage(); + return rtn; +} \ No newline at end of file Added: soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/keywords Fri May 27 20:49:22 2016 (r304058) @@ -0,0 +1,5 @@ +# @(#)keywords 8.2 (Berkeley) 5/27/2016 +# $FreeBSD$ + +create +delete From owner-svn-soc-all@freebsd.org Sat May 28 05:31:27 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 578C3B4D496 for ; Sat, 28 May 2016 05:31:27 +0000 (UTC) (envelope-from yuanxunzhang@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 446531720 for ; Sat, 28 May 2016 05:31:27 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u4S5VRka084809 for ; Sat, 28 May 2016 05:31:27 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4S5VQwr084773 for svn-soc-all@FreeBSD.org; Sat, 28 May 2016 05:31:26 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Sat, 28 May 2016 05:31:26 GMT Message-Id: <201605280531.u4S5VQwr084773@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r304090 - soc2016/yuanxunzhang/head/usr.sbin 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: Sat, 28 May 2016 05:31:27 -0000 Author: yuanxunzhang Date: Sat May 28 05:31:25 2016 New Revision: 304090 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304090 Log: modify usr.sbin makefile Modified: soc2016/yuanxunzhang/head/usr.sbin/Makefile Modified: soc2016/yuanxunzhang/head/usr.sbin/Makefile ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/Makefile Sat May 28 03:34:00 2016 (r304089) +++ soc2016/yuanxunzhang/head/usr.sbin/Makefile Sat May 28 05:31:25 2016 (r304090) @@ -25,6 +25,7 @@ digictl \ diskinfo \ dumpcis \ + eaps \ extattr \ extattrctl \ fifolog \ From owner-svn-soc-all@freebsd.org Sat May 28 06:06:01 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 450F4B4D801 for ; Sat, 28 May 2016 06:06:01 +0000 (UTC) (envelope-from yuanxunzhang@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 285051F51 for ; Sat, 28 May 2016 06:06:01 +0000 (UTC) (envelope-from yuanxunzhang@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u4S661HG079772 for ; Sat, 28 May 2016 06:06:01 GMT (envelope-from yuanxunzhang@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u4S660ZZ079535 for svn-soc-all@FreeBSD.org; Sat, 28 May 2016 06:06:00 GMT (envelope-from yuanxunzhang@FreeBSD.org) Date: Sat, 28 May 2016 06:06:00 GMT Message-Id: <201605280606.u4S660ZZ079535@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to yuanxunzhang@FreeBSD.org using -f From: yuanxunzhang@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r304091 - soc2016/yuanxunzhang/head/usr.sbin/eaps 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: Sat, 28 May 2016 06:06:01 -0000 Author: yuanxunzhang Date: Sat May 28 06:05:59 2016 New Revision: 304091 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=304091 Log: slove complie problem Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Modified: soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c ============================================================================== --- soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Sat May 28 05:31:25 2016 (r304090) +++ soc2016/yuanxunzhang/head/usr.sbin/eaps/eaps.c Sat May 28 06:05:59 2016 (r304091) @@ -56,6 +56,7 @@ #include #include #include +#include #include #include