From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 03:25:28 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 76FB1D01 for ; Sun, 7 Jun 2015 03:25:28 +0000 (UTC) (envelope-from btw@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 65B6211D0 for ; Sun, 7 Jun 2015 03:25:28 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t573PSLK029526 for ; Sun, 7 Jun 2015 03:25:28 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t573PRuA029524 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 03:25:27 GMT (envelope-from btw@FreeBSD.org) Date: Sun, 7 Jun 2015 03:25:27 GMT Message-Id: <201506070325.t573PRuA029524@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286764 - soc2015/btw/head/sys/dev/re 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.20 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, 07 Jun 2015 03:25:28 -0000 Author: btw Date: Sun Jun 7 03:25:26 2015 New Revision: 286764 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286764 Log: Convert re(4) to use the per-ring counters. Modified: soc2015/btw/head/sys/dev/re/if_re.c Modified: soc2015/btw/head/sys/dev/re/if_re.c ============================================================================== --- soc2015/btw/head/sys/dev/re/if_re.c Sat Jun 6 22:03:24 2015 (r286763) +++ soc2015/btw/head/sys/dev/re/if_re.c Sun Jun 7 03:25:26 2015 (r286764) @@ -1230,6 +1230,7 @@ .ifat_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST, .ifat_capabilities = IFCAP_LINKSTATE, .ifat_mediamask = MII_MEDIA_MASK, + .ifat_nrings = 1, }; u_char eaddr[ETHER_ADDR_LEN]; u_int16_t as[ETHER_ADDR_LEN / 2]; @@ -2152,6 +2153,7 @@ { struct mbuf *m; if_t ifp; + ifring_t *ifrs, ifr; int i, rxerr, total_len; struct rl_desc *cur_rx; u_int32_t rxstat, rxvlan; @@ -2160,6 +2162,8 @@ RL_LOCK_ASSERT(sc); ifp = sc->rl_ifp; + ifrs = if_getsoftc(ifp, IF_RING); + ifr = ifrs[0]; #ifdef DEV_NETMAP if (netmap_rx_irq(ifp, 0, &rx_npkts)) return 0; @@ -2321,6 +2325,7 @@ if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len); m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ifring = ifr; /* Do RX checksumming if enabled */ From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 07:14:53 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A8CFD411 for ; Sun, 7 Jun 2015 07:14:53 +0000 (UTC) (envelope-from pratiksinghal@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 963AB152F for ; Sun, 7 Jun 2015 07:14:53 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t577Ersj085206 for ; Sun, 7 Jun 2015 07:14:53 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t577Eqd4085190 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 07:14:52 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Sun, 7 Jun 2015 07:14:52 GMT Message-Id: <201506070714.t577Eqd4085190@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286767 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 07 Jun 2015 07:14:53 -0000 Author: pratiksinghal Date: Sun Jun 7 07:14:52 2015 New Revision: 286767 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286767 Log: Added the call statements for DMA transfer Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.h Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 06:30:25 2015 (r286766) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 07:14:52 2015 (r286767) @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -48,6 +49,7 @@ #include #include + #include #include @@ -55,7 +57,7 @@ #define A10_MMC_IRQRES 1 #define A10_MMC_RESSZ 2 #define A10_MMC_NDESC 16 -#define AWIN_MMC_DMA_FTRGLEVEL_A20 0x20070008 +#define A10_MMC_DMA_FTRGLEVEL_A20 0x20070008 struct a10_mmc_softc { bus_space_handle_t a10_bsh; @@ -71,6 +73,7 @@ struct mtx a10_mtx; struct resource * a10_res[A10_MMC_RESSZ]; uint32_t a10_intr; + uint32_t a10_idst ; uint32_t a10_intr_wait; void * a10_intrhand; int a10_use_dma ; @@ -80,7 +83,7 @@ bus_dma_segment_t* a10_dma_segs ; int a10_dma_nsegs ; bus_size_t a10_dma_size ; - int a10_dma_cb_arg ; /* Stores the number of segments */ + struct a10_mmc_cb a10_dma_cb_arg ; bus_dmamap_t a10_dma_map ; bus_dma_tag_t a10_dma_tag ; int a10_dma_ndesc; @@ -258,26 +261,26 @@ struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; struct mmc_command* cmd = sc->a10_req->cmd ; int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; - bus_addr_t desc_paddr = sc->a10_dma_map->segments[0].ds_addr ; - bus_size_t off ; + bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; + bus_size_t off = 0 ; int desc, rem,seg ; uint32_t val ; desc = 0 ; /* Pick a segment and program all the descriptors in the segment. */ - for(seg = 0; seg < sc->a10_dma_cb_arg ; seg++) + for(seg = 0; seg < sc->a10_dma_cb_arg.nsegs ; seg++) { - bus_addr_t paddr = sc->a10_dma_map->segments[seg].ds_addr; - bus_size_t len = sc->a10_dma_map->segments[seg].ds_len ; + bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[seg].ds_addr; + bus_size_t len = (sc->a10_dma_cb_arg).segs[seg].ds_len ; rem = min(len,cmd->data->len) ; while(rem > 0) { if(desc == sc->a10_dma_ndesc) break ; len = min(sc->a10_dma_xfer_len, rem) ; - dma[desc].buff_size = hotle32(len) ; - dma[desc].addr = hotle32(paddr + off) ; + dma[desc].buff_size = htole32(len) ; + dma[desc].buff_addr = htole32(paddr + off) ; dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; cmd->data->len -= len ; @@ -294,7 +297,7 @@ } else { dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_DIC) ; - dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) + dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) ; } desc++ ; } @@ -302,8 +305,11 @@ if(desc == sc->a10_dma_ndesc) { device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer") ; + return EIO ; } + bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; + val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; val |= A10_MMC_DMA_ENABLE ; val |= A10_MMC_INT_ENABLE ; @@ -338,8 +344,9 @@ return ; } - /* This is because, we can't get the number of segments alloted from bus_dmamap_t */ - *(int*)arg = nsegs ; + (*(struct a10_mmc_cb*)arg).nsegs = nsegs ; + (*(struct a10_mmc_cb*)arg).addr = segs[0].ds_addr ; + (*(struct a10_mmc_cb*)arg).segs = segs; } static int @@ -404,6 +411,7 @@ sc->a10_req = NULL; sc->a10_intr = 0; sc->a10_resid = 0; + sc->a10_idst = 0 ; sc->a10_intr_wait = 0; req->done(req); } @@ -485,12 +493,13 @@ { struct a10_mmc_softc *sc; struct mmc_data *data; - uint32_t imask, rint; + uint32_t imask, rint,idst; sc = (struct a10_mmc_softc *)arg; A10_MMC_LOCK(sc); rint = A10_MMC_READ_4(sc, A10_MMC_RINTR); imask = A10_MMC_READ_4(sc, A10_MMC_IMASK); + idst = A10_MMC_READ_4(sc, A10_MMC_IDST) ; if (imask == 0 && rint == 0) { A10_MMC_UNLOCK(sc); return; @@ -506,6 +515,33 @@ A10_MMC_UNLOCK(sc); return; } + + if(sc->a10_use_dma == 1) { + if(idst) { + uint32_t comp = 0 ; + sc->a10_idst = idst ; + + if(idst & A10_MMC_IDMAC_ERROR) + sc->a10_req->cmd->error = EIO ; + if(!(idst & A10_MMC_IDMAC_COMPLETE)) + sc->a10_req->cmd->error = ETIMEDOUT ; + else + comp = 1 ; + + data = sc->a10_req->cmd->data ; + + if(data->flags&MMC_DATA_WRITE) + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; + else + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; + if(comp == 0) + a10_mmc_req_done(sc) ; + else + a10_mmc_req_ok(sc) ; + } + return ; + } + if (rint & A10_MMC_INT_ERR_BIT) { device_printf(sc->a10_dev, "error rint: 0x%08X\n", rint); if (rint & A10_MMC_RESP_TIMEOUT) @@ -521,12 +557,8 @@ sc->a10_intr |= rint; data = sc->a10_req->cmd->data; if (data != NULL && (rint & (A10_MMC_DATA_OVER | - A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) { - if(sc->a10_use_dma == 0) + A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) a10_mmc_pio_transfer(sc, data); - else { - a10_mmc_prepare_dma(sc) ; - } if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) a10_mmc_req_ok(sc); @@ -562,6 +594,7 @@ sc->a10_intr = 0; sc->a10_resid = 0; + sc->a10_idst = 0 ; sc->a10_intr_wait = A10_MMC_CMD_DONE; cmd->error = MMC_ERR_NONE; if (cmd->data != NULL) { @@ -579,7 +612,11 @@ } A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); - A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); + if(sc->a10_use_dma == 1) { + a10_mmc_prepare_dma(sc) ; + A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); + } + callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, a10_mmc_timeout, sc); A10_MMC_UNLOCK(sc); Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.h ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.h Sun Jun 7 06:30:25 2015 (r286766) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.h Sun Jun 7 07:14:52 2015 (r286767) @@ -175,6 +175,11 @@ #define A10_MMC_IDMAC_RD (6U << 13) #define A10_MMC_IDMAC_WR (7U << 13) #define A10_MMC_IDMAC_DESC_CLOSE (8U << 13) +#define A10_MMC_IDMAC_ERROR \ + (A10_MMC_IDMAC_FATAL_BUS_ERR | A10_MMC_IDMAC_CARD_ERR_SUM | A10_MMC_IDMAC_DES_INVALID | \ + A10_MMC_IDMAC_ABNORMAL_INT_SUM) +#define A10_MMC_IDMAC_COMPLETE \ + (A10_MMC_IDMAC_TRANSMIT_INT | A10_MMC_IDMAC_RECEIVE_INT) /* Used to make the descriptor table for suppoting DMA Access */ struct a10_mmc_dma_desc { @@ -190,4 +195,12 @@ uint32_t buff_addr ; uint32_t next; } ; + +struct a10_mmc_cb +{ + uint32_t nsegs ; + bus_addr_t addr ; + bus_dma_segment_t* segs ; +} ; + #endif /* _A10_MMC_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 07:18:53 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4F0C144B for ; Sun, 7 Jun 2015 07:18:53 +0000 (UTC) (envelope-from pratiksinghal@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 3CEBA154E for ; Sun, 7 Jun 2015 07:18:53 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t577Irh2088586 for ; Sun, 7 Jun 2015 07:18:53 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t577Iqiv088584 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 07:18:52 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Sun, 7 Jun 2015 07:18:52 GMT Message-Id: <201506070718.t577Iqiv088584@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286768 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 07 Jun 2015 07:18:53 -0000 Author: pratiksinghal Date: Sun Jun 7 07:18:52 2015 New Revision: 286768 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286768 Log: Fixed a minor error Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 07:14:52 2015 (r286767) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 07:18:52 2015 (r286768) @@ -612,10 +612,9 @@ } A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); - if(sc->a10_use_dma == 1) { + if(sc->a10_use_dma == 1) a10_mmc_prepare_dma(sc) ; - A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); - } + A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, a10_mmc_timeout, sc); From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 11:50:04 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 06608DAC for ; Sun, 7 Jun 2015 11:50:04 +0000 (UTC) (envelope-from def@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 E625D1184 for ; Sun, 7 Jun 2015 11:50:03 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57Bo3IJ042561 for ; Sun, 7 Jun 2015 11:50:03 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57Bo0CT042516 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 11:50:00 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 11:50:00 GMT Message-Id: <201506071150.t57Bo0CT042516@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286773 - in soc2013/def/crashdump-head: sbin/cryptcore sbin/savecore sys/amd64/amd64 sys/ddb sys/kern sys/sys 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.20 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, 07 Jun 2015 11:50:04 -0000 Author: def Date: Sun Jun 7 11:49:59 2015 New Revision: 286773 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286773 Log: Dump an encrypted key of arbitrary size separately from a header. Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c soc2013/def/crashdump-head/sbin/savecore/savecore.c soc2013/def/crashdump-head/sys/amd64/amd64/minidump_machdep.c soc2013/def/crashdump-head/sys/ddb/db_textdump.c soc2013/def/crashdump-head/sys/kern/kern_dump.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/conf.h soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 11:49:59 2015 (r286773) @@ -30,8 +30,8 @@ static void cryptcore_genkey(const char *pubkeyfile) { - uint8_t buf[KERNELDUMP_KEY_SIZE + KERNELDUMP_IV_SIZE]; - uint8_t ciphertext[KERNELDUMP_CIPHERTEXT_SIZE]; + uint8_t key[KERNELDUMP_KEY_SIZE]; + uint8_t *encryptedkey; FILE *fp; RSA *pubkey; int pubkeysize; @@ -49,43 +49,41 @@ fclose(fp); if (pubkey == NULL) pjdlog_exitx(1, "Unable to read data from %s.", pubkeyfile); + pubkeysize = RSA_size(pubkey); - if (pubkeysize > (int)sizeof(ciphertext)) { - pjdlog_exitx(1, "The maximum RSA modulus size is %lub.", - 8 * sizeof(ciphertext)); - } + encryptedkey = (uint8_t *)calloc(1, pubkeysize); + if (encryptedkey == NULL) + pjdlog_exitx(1, "Unable to allocate encrypted key"); - arc4random_buf(buf, sizeof(buf)); - if (RSA_public_encrypt(sizeof(buf), buf, ciphertext, pubkey, + arc4random_buf(key, sizeof(key)); + if (RSA_public_encrypt(sizeof(key), key, encryptedkey, pubkey, RSA_PKCS1_PADDING) != pubkeysize) { - pjdlog_exitx(1, "Unable to encrypt the one-time key."); + pjdlog_errno(LOG_ERR, "Unable to encrypt the one-time key"); + goto failed; } /* * From this moment on keys have to be erased before exit. */ - if (sysctlbyname("security.ekcd.keymaterial", NULL, NULL, buf, + if (sysctlbyname("security.ekcd.keymaterial", NULL, NULL, key, KERNELDUMP_KEY_SIZE) != 0) { pjdlog_errno(LOG_ERR, "Unable to set key material"); goto failed; } - if (sysctlbyname("security.ekcd.iv", NULL, NULL, - buf + KERNELDUMP_KEY_SIZE, KERNELDUMP_IV_SIZE) != 0) { - pjdlog_errno(LOG_ERR, "Unable to set IV"); - goto failed; - } - if (sysctlbyname("security.ekcd.ciphertext", NULL, NULL, ciphertext, - pubkeysize) != 0) { - pjdlog_errno(LOG_ERR, "Unable to set ciphertext"); + if (sysctlbyname("security.ekcd.encryptedkey", NULL, NULL, + encryptedkey, pubkeysize) != 0) { + pjdlog_errno(LOG_ERR, "Unable to set encrypted key"); goto failed; } - bzero(buf, sizeof(buf)); + bzero(key, sizeof(key)); + free(encryptedkey); RSA_free(pubkey); return; failed: - bzero(buf, sizeof(buf)); + bzero(key, sizeof(key)); + free(encryptedkey); RSA_free(pubkey); exit(1); } @@ -94,10 +92,10 @@ cryptcore_decrypt(const char *privkeyfile, const char *keyfile, const char *input, const char *output) { - uint8_t buf[KERNELDUMP_BUFFER_SIZE]; - uint8_t ciphertext[KERNELDUMP_CIPHERTEXT_SIZE]; + uint8_t buf[KERNELDUMP_BUFFER_SIZE], key[KERNELDUMP_KEY_SIZE]; EVP_CIPHER_CTX ctx; FILE *fp; + struct kerneldumpkey *kdk; RSA *privkey; int err, fd, ofd, privkeysize, size; size_t bufused, bytes; @@ -109,19 +107,29 @@ ofd = -1; fd = -1; + privkey = RSA_new(); if (privkey == NULL) pjdlog_exitx(1, "Unable to allocate an RSA structure."); EVP_CIPHER_CTX_init(&ctx); + kdk = (struct kerneldumpkey *)calloc(1, sizeof(struct kerneldumpkey)); + if (kdk == NULL) + pjdlog_exit(1, "Unable to allocate kernel dump key"); + fd = open(keyfile, O_RDONLY); if (fd == -1) pjdlog_exit(1, "Unable to open %s", keyfile); - size = (int)read(fd, ciphertext, sizeof(ciphertext)); + size = (int)read(fd, kdk, sizeof(struct kerneldumpkey)); + if (size == sizeof(struct kerneldumpkey)) { + kdk = (struct kerneldumpkey *)realloc(kdk, kdk->kdk_size); + size += read(fd, &kdk->kdk_encryptedkey, + kdk->kdk_size - sizeof(struct kerneldumpkey)); + } err = errno; close(fd); fd = -1; - if (size != sizeof(ciphertext)) { + if (size != (int)kdk->kdk_size) { errno = err; pjdlog_exit(1, "Unable to read data from %s", keyfile); } @@ -133,19 +141,19 @@ fclose(fp); if (privkey == NULL) pjdlog_exitx(1, "Unable to read data from %s.", privkeyfile); + /* * From this moment on keys have to be erased before exit. */ privkeysize = RSA_size(privkey); - if (privkeysize > (int)sizeof(ciphertext)) { - pjdlog_error("The maximum RSA modulus size is %lub.", - 8 * sizeof(ciphertext)); + if (privkeysize != kdk->kdk_encryptedkeylen) { + pjdlog_error("RSA modulus size mismatch: equals %db and should be %db.", + 8 * privkeysize, 8 * kdk->kdk_encryptedkeylen); goto failed; } - - if (RSA_private_decrypt(sizeof(ciphertext), ciphertext, buf, privkey, - RSA_PKCS1_PADDING) != KERNELDUMP_KEY_SIZE + KERNELDUMP_IV_SIZE) { - pjdlog_error("Unable to decrypt key and IV."); + if (RSA_private_decrypt(kdk->kdk_encryptedkeylen, kdk->kdk_encryptedkey, + key, privkey, RSA_PKCS1_PADDING) != sizeof(key)) { + pjdlog_error("Unable to decrypt key."); goto failed; } @@ -160,9 +168,8 @@ goto failed; } - EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, buf, - buf + KERNELDUMP_KEY_SIZE); - EVP_CIPHER_CTX_set_key_length(&ctx, KERNELDUMP_KEY_SIZE); + EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, key, kdk->kdk_iv); + EVP_CIPHER_CTX_set_key_length(&ctx, sizeof(key)); EVP_CIPHER_CTX_set_padding(&ctx, 0); bufused = 0; @@ -186,6 +193,7 @@ bufused = 0; } + bzero(key, sizeof(key)); bzero(buf, sizeof(buf)); EVP_CIPHER_CTX_cleanup(&ctx); RSA_free(privkey); @@ -199,6 +207,7 @@ close(ofd); if (fd >= 0) close(fd); + bzero(key, sizeof(key)); bzero(buf, sizeof(buf)); EVP_CIPHER_CTX_cleanup(&ctx); RSA_free(privkey); Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 11:49:59 2015 (r286773) @@ -74,6 +74,7 @@ #include #include #include +#include #include #include #include @@ -183,22 +184,26 @@ fclose(fp); } -static void -writekey(const char *keyname, struct kerneldumpheader *kdh) +static bool +writekey(const char *keyname, struct kerneldumpkey *kdk) { int fd; fd = open(keyname, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (fd == -1) { syslog(LOG_ERR, "Unable to open %s to write the key.", keyname); - exit(1); + return (false); } - if (write(fd, kdh->ciphertext, KERNELDUMP_CIPHERTEXT_SIZE) != - KERNELDUMP_CIPHERTEXT_SIZE) { + + if (write(fd, kdk, kerneldumpkey_size(kdk)) != + (ssize_t)kerneldumpkey_size(kdk)) { syslog(LOG_ERR, "Unable to write the key to %s.", keyname); - exit(1); + close(fd); + return (false); } + close(fd); + return (true); } static off_t @@ -452,6 +457,7 @@ static void DoFile(const char *savedir, const char *device) { + struct kerneldumpkey *kdk; xo_handle_t *xostdout, *xoinfo; static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX]; static char keyname[PATH_MAX]; @@ -464,6 +470,7 @@ int bounds, status; u_int sectorsize, xostyle; int istextdump; + uint32_t dumpkeysize; bounds = getbounds(); mediasize = 0; @@ -587,7 +594,8 @@ goto closefd; } dumpsize = dtoh64(kdhl.dumplength); - firsthd = lasthd - dumpsize - sizeof kdhf; + dumpkeysize = dtoh32(kdhl.dumpkeysize); + firsthd = lasthd - dumpsize - sizeof kdhf - dumpkeysize; lseek(fd, firsthd, SEEK_SET); error = read(fd, &kdhf, sizeof kdhf); if (error != sizeof kdhf) { @@ -654,10 +662,6 @@ } oumask = umask(S_IRWXG|S_IRWXO); /* Restrict access to the core file.*/ - if (encrypted) { - snprintf(keyname, sizeof(keyname), "key.%d", bounds); - writekey(keyname, &kdhl); - } if (compress) { snprintf(corename, sizeof(corename), "%s.%d.gz", istextdump ? "textdump.tar" : "vmcore", bounds); @@ -701,6 +705,28 @@ xo_finish_h(xoinfo); fclose(info); + if (encrypted) { + kdk = (struct kerneldumpkey *)calloc(1, dumpkeysize); + if (kdk == NULL) { + syslog(LOG_ERR, "Unable to allocate kernel dump key."); + nerr++; + goto closefd; + } + + error = read(fd, kdk, dumpkeysize); + if (error != (int)dumpkeysize) { + syslog(LOG_ERR, "Unable to read kernel dump key."); + nerr++; + goto closefd; + } + + snprintf(keyname, sizeof(keyname), "key.%d", bounds); + if (!writekey(keyname, kdk)) { + nerr++; + goto closefd; + } + } + syslog(LOG_NOTICE, "writing %s%score to %s/%s", encrypted ? "encrypted " : "", compress ? "compressed " : "", savedir, corename); Modified: soc2013/def/crashdump-head/sys/amd64/amd64/minidump_machdep.c ============================================================================== --- soc2013/def/crashdump-head/sys/amd64/amd64/minidump_machdep.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/amd64/amd64/minidump_machdep.c Sun Jun 7 11:49:59 2015 (r286773) @@ -320,12 +320,14 @@ dumpsize += PAGE_SIZE; /* Determine dump offset on device. */ - if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) { + if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2 + + kerneldumpkey_size(di->kdk)) { error = E2BIG; goto fail; } dumplo = di->mediaoffset + di->mediasize - dumpsize; dumplo -= sizeof(kdh) * 2; + dumplo -= kerneldumpkey_size(di->kdk); progress = dumpsize; /* Initialize mdhdr */ @@ -339,17 +341,24 @@ mdhdr.dmapbase = DMAP_MIN_ADDRESS; mdhdr.dmapend = DMAP_MAX_ADDRESS; - mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize); + mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, + kerneldumpkey_size(di->kdk), di->blocksize); printf("Dumping %llu out of %ju MB:", (long long)dumpsize >> 20, ptoa((uintmax_t)physmem) / 1048576); /* Dump leader */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; dumplo += sizeof(kdh); + /* Dump key */ + error = dump_write_key(di, di->kdk, 0, dumplo); + if (error) + goto fail; + dumplo += kerneldumpkey_size(di->kdk); + /* Dump my header */ bzero(&fakepd, sizeof(fakepd)); bcopy(&mdhdr, &fakepd, sizeof(mdhdr)); @@ -433,7 +442,7 @@ goto fail; /* Dump trailer */ - error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh)); + error = dump_write_header(di, &kdh, 0, dumplo); if (error) goto fail; dumplo += sizeof(kdh); Modified: soc2013/def/crashdump-head/sys/ddb/db_textdump.c ============================================================================== --- soc2013/def/crashdump-head/sys/ddb/db_textdump.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/ddb/db_textdump.c Sun Jun 7 11:49:59 2015 (r286773) @@ -456,7 +456,8 @@ */ textdump_offset = di->mediasize - sizeof(kdh); textdump_saveoff(&trailer_offset); - mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, TEXTDUMP_BLOCKSIZE); + mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, + kerneldumpkey_size(di->kdk), TEXTDUMP_BLOCKSIZE); (void)textdump_writenextblock(di, (char *)&kdh); /* @@ -482,7 +483,7 @@ */ dumplen = trailer_offset - (textdump_offset + TEXTDUMP_BLOCKSIZE); mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, dumplen, - TEXTDUMP_BLOCKSIZE); + kerneldumpkey_size(di->kdk), TEXTDUMP_BLOCKSIZE); (void)textdump_writenextblock(di, (char *)&kdh); textdump_restoreoff(trailer_offset); (void)textdump_writenextblock(di, (char *)&kdh); Modified: soc2013/def/crashdump-head/sys/kern/kern_dump.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_dump.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/kern/kern_dump.c Sun Jun 7 11:49:59 2015 (r286773) @@ -330,7 +330,7 @@ dumplo -= sizeof(kdh) * 2; mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION, dumpsize, - di->blocksize); + kerneldumpkey_size(di->kdk), di->blocksize); printf("Dumping %ju MB (%d chunks)\n", (uintmax_t)dumpsize >> 20, ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS); Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 11:49:59 2015 (r286773) @@ -138,28 +138,35 @@ &show_busybufs, 0, ""); #ifdef EKCD -static struct kerneldumpkey dumperkey; -static struct kerneldumpbuffer dumperbuffer; +MALLOC_DEFINE(M_KDK, "kerneldumpkey", "Kernel dump key structure"); + +static struct kerneldumpcrypto { + int kdc_enable; + uint8_t kdc_key[KERNELDUMP_KEY_SIZE]; + uint8_t kdc_iv[KERNELDUMP_IV_SIZE]; + keyInstance kdc_ki; + cipherInstance kdc_ci; + off_t kdc_offset; + uint8_t kdc_buf[KERNELDUMP_BUFFER_SIZE]; + size_t kdc_bufused; +} dumpcrypto; + +static struct kerneldumpkey *dumpkey; static int kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS); -static int kerneldump_sysctl_iv(SYSCTL_HANDLER_ARGS); +static int kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS); SYSCTL_NODE(_security, OID_AUTO, ekcd, CTLFLAG_RW, 0, "Encrypted kernel crash dumps"); -SYSCTL_INT(_security_ekcd, OID_AUTO, enable, CTLFLAG_RW, &dumperkey.kdk_enable, +SYSCTL_INT(_security_ekcd, OID_AUTO, enable, CTLFLAG_RW, &dumpcrypto.kdc_enable, 0, "Enable encrypted kernel crash dumps"); SYSCTL_PROC(_security_ekcd, OID_AUTO, keymaterial, CTLTYPE_OPAQUE | CTLFLAG_WR, - NULL, 0, kerneldump_sysctl_keymaterial, "", - "Key material used to encrypt a crash dump"); - -SYSCTL_PROC(_security_ekcd, OID_AUTO, iv, CTLTYPE_OPAQUE | CTLFLAG_WR, NULL, 0, - kerneldump_sysctl_iv, "", "IV used to encrypt a crash dump"); + NULL, 0, kerneldump_sysctl_keymaterial, "", "Key material"); -SYSCTL_OPAQUE(_security_ekcd, OID_AUTO, ciphertext, CTLFLAG_WR, - &dumperkey.kdk_ciphertext, KERNELDUMP_CIPHERTEXT_SIZE, "", - "Encrypted key material and IV"); +SYSCTL_PROC(_security_ekcd, OID_AUTO, encryptedkey, CTLTYPE_OPAQUE | CTLFLAG_WR, + NULL, 0, kerneldump_sysctl_encryptedkey, "", "Encrypted key material"); #endif /* EKCD */ /* @@ -849,56 +856,87 @@ #ifdef EKCD static int -kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS) +kerneldump_crypto_init(struct dumperinfo *di, struct kerneldumpcrypto *kdc, + struct kerneldumpkey *kdk) { int error; - error = sysctl_handle_opaque(oidp, &dumperkey.kdk_keymaterial, - KERNELDUMP_KEY_SIZE, req); - if (error != 0) - return (error); - - if (req->newptr != NULL) { - rijndael_makeKey(&dumperkey.kdk_ki, DIR_ENCRYPT, - 8 * KERNELDUMP_KEY_SIZE, dumperkey.kdk_keymaterial); + if (kdc == NULL) { + printf("Attempt to use an invalid kernel dump crypto."); + return (EINVAL); } + error = rijndael_makeKey(&kdc->kdc_ki, DIR_ENCRYPT, + 8 * KERNELDUMP_KEY_SIZE, kdc->kdc_key); + if (error <= 0) + return (EINVAL); + + error = rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, kdc->kdc_iv); + if (error <= 0) + return (EINVAL); + + kdc->kdc_offset = 0; + kdc->kdc_bufused = 0; + + di->kdc = kdc; + di->kdk = kdk; + return (0); } static int -kerneldump_sysctl_iv(SYSCTL_HANDLER_ARGS) +kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS) { int error; - error = sysctl_handle_opaque(oidp, &dumperkey.kdk_iv, - KERNELDUMP_IV_SIZE, req); - if (error != 0) + error = sysctl_handle_opaque(oidp, dumpcrypto.kdc_key, + sizeof(dumpcrypto.kdc_key), req); + if (req->newptr == NULL || error != 0) return (error); - if (req->newptr != NULL) { - rijndael_cipherInit(&dumperkey.kdk_ci, MODE_CBC, - dumperkey.kdk_iv); - } + arc4rand(dumpcrypto.kdc_iv, sizeof(dumpcrypto.kdc_iv), 0); - return (0); + return (kerneldump_crypto_init(&dumper, &dumpcrypto, dumpkey)); } -static void -kerneldump_crypto_init(struct dumperinfo *di, struct kerneldumpkey *kdk, - struct kerneldumpbuffer *kdb) +static int +kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS) { + struct kerneldumpkey *kdk; + size_t kdksize; + int error; - if (kdk == NULL || kdb == NULL) { - printf("Attempt to use an invalid kernel dump key or buffer."); - return; + if (req->newptr == NULL) { + if (dumpkey == NULL) + return (0); + + return (sysctl_handle_opaque(oidp, dumpkey->kdk_encryptedkey, + dumpkey->kdk_encryptedkeylen, req)); } - bzero(kdk, sizeof(struct kerneldumpkey)); - bzero(kdb, sizeof(struct kerneldumpbuffer)); + kdksize = ((sizeof(*kdk) + req->newlen + KERNELDUMP_BLOCK_SIZE - 1) / + KERNELDUMP_BLOCK_SIZE) * KERNELDUMP_BLOCK_SIZE; - di->kdk = kdk; - di->kdb = kdb; + kdk = (struct kerneldumpkey *)malloc(kdksize, M_KDK, M_WAITOK); + if (kdk == NULL) + return (ENOMEM); + + kdk->kdk_size = kdksize; + bcopy(dumpcrypto.kdc_iv, kdk->kdk_iv, sizeof(kdk->kdk_iv)); + kdk->kdk_encryptedkeylen = req->newlen; + + error = sysctl_handle_opaque(oidp, kdk->kdk_encryptedkey, + kdk->kdk_encryptedkeylen, req); + if (error != 0) { + free(kdk, M_KDK); + return (error); + } + + free(dumpkey, M_KDK); + dumpkey = kdk; + dumper.kdk = dumpkey; + + return (0); } #endif /* EKCD */ @@ -927,7 +965,9 @@ dumper = *di; #ifdef EKCD - kerneldump_crypto_init(&dumper, &dumperkey, &dumperbuffer); + error = kerneldump_crypto_init(&dumper, &dumpcrypto, dumpkey); + if (error != 0) + return (error); #endif wantcopy = strlcpy(dumpdevname, devname, sizeof(dumpdevname)); @@ -943,64 +983,54 @@ dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, off_t offset, size_t length) { + struct kerneldumpcrypto *kdc; struct kerneldumpkey *kdk; - struct kerneldumpbuffer *kdb; int error; size_t len; + kdc = di->kdc; kdk = di->kdk; - kdb = di->kdb; /* Data have to be written continuously. */ - if (kdb->kdb_offset != 0 && kdb->kdb_offset != offset && - kdb->kdb_offset + kdb->kdb_used != offset) { + if (kdc->kdc_offset != 0 && kdc->kdc_offset != offset && + kdc->kdc_offset + kdc->kdc_bufused != offset) { return (EINVAL); } - /* Write kernel dump headers. */ - if (kdb->kdb_offset == 0 || kdb->kdb_offset == di->mediaoffset + - di->mediasize - sizeof(struct kerneldumpheader)) { - kdb->kdb_offset = offset + length; - return (di->dumper(di->priv, virtual, physical, offset, - length)); - } - - while (kdb->kdb_used + length >= KERNELDUMP_BUFFER_SIZE) { - len = KERNELDUMP_BUFFER_SIZE - kdb->kdb_used; - memcpy(kdb->kdb_buf + kdb->kdb_used, virtual, len); - kdb->kdb_used += len; + while (kdc->kdc_bufused + length >= KERNELDUMP_BUFFER_SIZE) { + len = KERNELDUMP_BUFFER_SIZE - kdc->kdc_bufused; + memcpy(kdc->kdc_buf + kdc->kdc_bufused, virtual, len); + kdc->kdc_bufused += len; - error = rijndael_blockEncrypt(&kdk->kdk_ci, &kdk->kdk_ki, - kdb->kdb_buf, 8 * KERNELDUMP_BUFFER_SIZE, kdb->kdb_buf); + error = rijndael_blockEncrypt(&kdc->kdc_ci, &kdc->kdc_ki, + kdc->kdc_buf, 8 * KERNELDUMP_BUFFER_SIZE, kdc->kdc_buf); if (error <= 0) return (EIO); - error = rijndael_cipherInit(&kdk->kdk_ci, MODE_CBC, - kdb->kdb_buf + KERNELDUMP_BUFFER_SIZE - KERNELDUMP_IV_SIZE); + error = rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, + kdc->kdc_buf + KERNELDUMP_BUFFER_SIZE - KERNELDUMP_IV_SIZE); if (error <= 0) return (EIO); - error = di->dumper(di->priv, kdb->kdb_buf, physical, - kdb->kdb_offset, KERNELDUMP_BUFFER_SIZE); + error = di->dumper(di->priv, kdc->kdc_buf, physical, + kdc->kdc_offset, KERNELDUMP_BUFFER_SIZE); if (error != 0) return (error); - kdb->kdb_used = 0; - kdb->kdb_offset += KERNELDUMP_BUFFER_SIZE; + kdc->kdc_bufused = 0; + kdc->kdc_offset += KERNELDUMP_BUFFER_SIZE; virtual = (void *)((char *)virtual + len); length -= len; } if (length > 0) { - memcpy(kdb->kdb_buf + kdb->kdb_used, virtual, length); - kdb->kdb_used += length; + memcpy(kdc->kdc_buf + kdc->kdc_bufused, virtual, length); + kdc->kdc_bufused += length; } return (0); } -/* Call dumper with bounds checking. */ -int -dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, - off_t offset, size_t length) +static int +dump_check_bounds(struct dumperinfo *di, off_t offset, size_t length) { if (length != 0 && (offset < di->mediaoffset || @@ -1011,8 +1041,23 @@ (uintmax_t)length, (intmax_t)di->mediasize); return (ENOSPC); } + + return (0); +} + +/* Call dumper with bounds checking. */ +int +dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, + off_t offset, size_t length) +{ + int error; + + error = dump_check_bounds(di, offset, length); + if (error != 0) + return (error); + #ifdef EKCD - if (di->kdk->kdk_enable == 1) { + if (di->kdc->kdc_enable == 1) { return (dump_encrypted_write(di, virtual, physical, offset, length)); } @@ -1020,9 +1065,50 @@ return (di->dumper(di->priv, virtual, physical, offset, length)); } +int +dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + vm_offset_t physical, off_t offset) +{ + int error; + + error = dump_check_bounds(di, offset, sizeof(*kdh)); + if (error != 0) + return (error); + + error = di->dumper(di->priv, kdh, physical, offset, sizeof(*kdh)); + if (error != 0) + return (error); + + if (di->kdc->kdc_enable == 1) + di->kdc->kdc_offset = offset + sizeof(*kdh); + + return (0); +} + +int +dump_write_key(struct dumperinfo *di, struct kerneldumpkey *kdk, + vm_offset_t physical, off_t offset) +{ + int error; + + error = dump_check_bounds(di, offset, kerneldumpkey_size(kdk)); + if (error != 0) + return (error); + + error = di->dumper(di->priv, kdk, physical, offset, + kerneldumpkey_size(kdk)); + if (error != 0) + return (error); + + if (di->kdc->kdc_enable == 1) + di->kdc->kdc_offset = offset + kerneldumpkey_size(kdk); + + return (0); +} + void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, - uint64_t dumplen, uint32_t blksz) + uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz) { bzero(kdh, sizeof(*kdh)); @@ -1032,14 +1118,11 @@ kdh->architectureversion = htod32(archver); kdh->dumplength = htod64(dumplen); kdh->dumptime = htod64(time_second); + kdh->dumpkeysize = htod32(dumpkeysize); kdh->blocksize = htod32(blksz); strncpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname)); strncpy(kdh->versionstring, version, sizeof(kdh->versionstring)); if (panicstr != NULL) strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); -#ifdef EKCD - memcpy(kdh->ciphertext, dumperkey.kdk_ciphertext, - KERNELDUMP_CIPHERTEXT_SIZE); -#endif kdh->parity = kerneldump_parity(kdh); } Modified: soc2013/def/crashdump-head/sys/sys/conf.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/conf.h Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/sys/conf.h Sun Jun 7 11:49:59 2015 (r286773) @@ -309,8 +309,9 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn); /* EKCD structures. */ +struct kerneldumpheader; +struct kerneldumpcrypto; struct kerneldumpkey; -struct kerneldumpbuffer; struct dumperinfo { dumper_t *dumper; /* Dumping function. */ @@ -319,12 +320,16 @@ u_int maxiosize; /* Max size allowed for an individual I/O */ off_t mediaoffset; /* Initial offset in bytes. */ off_t mediasize; /* Space available in bytes. */ - struct kerneldumpkey *kdk; /* Kernel dump key. */ - struct kerneldumpbuffer *kdb; /* Kernel dump buffer. */ + struct kerneldumpcrypto *kdc; /* Kernel dump crypto. */ + struct kerneldumpkey *kdk; /* Kernel dump key. */ }; int set_dumper(struct dumperinfo *, const char *_devname, struct thread *td); int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t); +int dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + vm_offset_t physical, off_t offset); +int dump_write_key(struct dumperinfo *di, struct kerneldumpkey *kdk, + vm_offset_t physical, off_t offset); int doadump(boolean_t); extern int dumping; /* system is dumping */ Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 10:57:02 2015 (r286772) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 11:49:59 2015 (r286773) @@ -56,8 +56,8 @@ #define htod64(x) (x) #endif +#define KERNELDUMP_BLOCK_SIZE 512 #define KERNELDUMP_BUFFER_SIZE 1024 -#define KERNELDUMP_CIPHERTEXT_SIZE 512 #define KERNELDUMP_IV_SIZE 16 #define KERNELDUMP_KEY_SIZE 32 @@ -85,14 +85,29 @@ #define KERNELDUMP_TEXT_VERSION 1 uint64_t dumplength; /* excl headers */ uint64_t dumptime; + uint32_t dumpkeysize; uint32_t blocksize; char hostname[64]; char versionstring[192]; char panicstring[192]; - char ciphertext[KERNELDUMP_CIPHERTEXT_SIZE]; uint32_t parity; + char pad[508]; }; +struct kerneldumpkey { + uint32_t kdk_size; + uint8_t kdk_iv[KERNELDUMP_IV_SIZE]; + int kdk_encryptedkeylen; + uint8_t kdk_encryptedkey[]; +}; + +static __inline size_t +kerneldumpkey_size(struct kerneldumpkey *kdk) +{ + + return (kdk->kdk_size); +} + /* * Parity calculation is endian insensitive. */ @@ -110,28 +125,13 @@ } #ifdef _KERNEL -struct kerneldumpkey { - int kdk_enable; - uint8_t kdk_keymaterial[KERNELDUMP_KEY_SIZE]; - uint8_t kdk_iv[KERNELDUMP_IV_SIZE]; - uint8_t kdk_ciphertext[KERNELDUMP_CIPHERTEXT_SIZE]; - keyInstance kdk_ki; - cipherInstance kdk_ci; -}; - -struct kerneldumpbuffer { - uint8_t kdb_buf[KERNELDUMP_BUFFER_SIZE]; - size_t kdb_used; - off_t kdb_offset; -}; - struct dump_pa { vm_paddr_t pa_start; vm_paddr_t pa_size; }; void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, - uint64_t dumplen, uint32_t blksz); + uint64_t dumplen, uint32_t dumpkeysize, uint32_t blksz); int dumpsys_generic(struct dumperinfo *); From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 12:39:51 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7A432BDA for ; Sun, 7 Jun 2015 12:39:51 +0000 (UTC) (envelope-from def@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 5D4D61D2C for ; Sun, 7 Jun 2015 12:39:51 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57CdpXM088489 for ; Sun, 7 Jun 2015 12:39:51 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57Cdo3e088139 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 12:39:50 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 12:39:50 GMT Message-Id: <201506071239.t57Cdo3e088139@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286778 - soc2013/def/crashdump-head/sbin/savecore 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.20 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, 07 Jun 2015 12:39:51 -0000 Author: def Date: Sun Jun 7 12:39:50 2015 New Revision: 286778 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286778 Log: Remove encrypted flag and detect an encrypted dump. Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 11:38:26 2015 (r286777) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 12:39:50 2015 (r286778) @@ -90,7 +90,7 @@ #define STATUS_GOOD 1 #define STATUS_UNKNOWN 2 -static int checkfor, compress, clear, encrypted, force, keep, verbose; /* flags */ +static int checkfor, compress, clear, force, keep, verbose; /* flags */ static int nfound, nsaved, nerr; /* statistics */ static int maxdumps; @@ -315,8 +315,8 @@ #define BLOCKMASK (~(BLOCKSIZE-1)) static int -DoRegularFile(int fd, off_t dumpsize, char *buf, const char *device, - const char *filename, FILE *fp) +DoRegularFile(int fd, bool isencrypted, off_t dumpsize, char *buf, + const char *device, const char *filename, FILE *fp) { int he, hs, nr, nw, wl; off_t dmpcnt, origsize; @@ -338,7 +338,7 @@ nerr++; return (-1); } - if (compress || encrypted) { + if (compress || isencrypted) { nw = fwrite(buf, 1, wl, fp); } else { for (nw = 0; nw < nr; nw = he) { @@ -471,6 +471,7 @@ u_int sectorsize, xostyle; int istextdump; uint32_t dumpkeysize; + bool isencrypted; bounds = getbounds(); mediasize = 0; @@ -705,7 +706,9 @@ xo_finish_h(xoinfo); fclose(info); - if (encrypted) { + isencrypted = false; + if (dumpkeysize > 0) { + isencrypted = true; kdk = (struct kerneldumpkey *)calloc(1, dumpkeysize); if (kdk == NULL) { syslog(LOG_ERR, "Unable to allocate kernel dump key."); @@ -728,7 +731,7 @@ } syslog(LOG_NOTICE, "writing %s%score to %s/%s", - encrypted ? "encrypted " : "", compress ? "compressed " : "", + isencrypted ? "encrypted " : "", compress ? "compressed " : "", savedir, corename); if (istextdump) { @@ -736,9 +739,10 @@ corename, fp) < 0) goto closeall; } else { - if (DoRegularFile(fd, dumpsize, buf, device, corename, fp) - < 0) + if (DoRegularFile(fd, isencrypted, dumpsize, buf, device, + corename, fp) < 0) { goto closeall; + } } if (verbose) printf("\n"); @@ -811,7 +815,7 @@ struct fstab *fsp; int i, ch, error; - checkfor = compress = clear = encrypted = force = keep = verbose = 0; + checkfor = compress = clear = force = keep = verbose = 0; nfound = nsaved = nerr = 0; openlog("savecore", LOG_PERROR, LOG_DAEMON); @@ -821,7 +825,7 @@ if (argc < 0) exit(1); - while ((ch = getopt(argc, argv, "Ccefkm:vz")) != -1) + while ((ch = getopt(argc, argv, "Ccfkm:vz")) != -1) switch(ch) { case 'C': checkfor = 1; @@ -829,9 +833,6 @@ case 'c': clear = 1; break; - case 'e': - encrypted = 1; - break; case 'f': force = 1; break; From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 13:15:30 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D8884307 for ; Sun, 7 Jun 2015 13:15:30 +0000 (UTC) (envelope-from def@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 C704C164D for ; Sun, 7 Jun 2015 13:15:30 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57DFU1b025997 for ; Sun, 7 Jun 2015 13:15:30 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57DFUwg025981 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 13:15:30 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 13:15:30 GMT Message-Id: <201506071315.t57DFUwg025981@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286779 - soc2013/def/crashdump-head/sbin/savecore 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.20 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, 07 Jun 2015 13:15:30 -0000 Author: def Date: Sun Jun 7 13:15:29 2015 New Revision: 286779 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286779 Log: Remove encrypted flag from usage. Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c Modified: soc2013/def/crashdump-head/sbin/savecore/savecore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 12:39:50 2015 (r286778) +++ soc2013/def/crashdump-head/sbin/savecore/savecore.c Sun Jun 7 13:15:29 2015 (r286779) @@ -804,7 +804,7 @@ xo_error("%s\n%s\n%s\n", "usage: savecore -c [-v] [device ...]", " savecore -C [-v] [device ...]", - " savecore [-efkvz] [-m maxdumps] [directory [device ...]]"); + " savecore [-fkvz] [-m maxdumps] [directory [device ...]]"); exit(1); } From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 13:18:15 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1EAE2328 for ; Sun, 7 Jun 2015 13:18:15 +0000 (UTC) (envelope-from def@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 0D5DE165A for ; Sun, 7 Jun 2015 13:18:15 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57DIEcE027355 for ; Sun, 7 Jun 2015 13:18:14 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57DIExd027338 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 13:18:14 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 13:18:14 GMT Message-Id: <201506071318.t57DIExd027338@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286780 - in soc2013/def/crashdump-head/sys: kern sys 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.20 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, 07 Jun 2015 13:18:15 -0000 Author: def Date: Sun Jun 7 13:18:13 2015 New Revision: 286780 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286780 Log: Return proper size when kernel dump key is NULL. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 13:15:29 2015 (r286779) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 13:18:13 2015 (r286780) @@ -71,6 +71,8 @@ #include #include +#include + #include #include Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 13:15:29 2015 (r286779) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 13:18:13 2015 (r286780) @@ -38,11 +38,9 @@ #ifndef _SYS_KERNELDUMP_H #define _SYS_KERNELDUMP_H -#include +#include -#ifdef _KERNEL -#include -#endif +#include #if BYTE_ORDER == LITTLE_ENDIAN #define dtoh32(x) __bswap32(x) @@ -105,6 +103,8 @@ kerneldumpkey_size(struct kerneldumpkey *kdk) { + if (kdk == NULL) + return (0); return (kdk->kdk_size); } From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 13:37:09 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3F1E082F for ; Sun, 7 Jun 2015 13:37:09 +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 137761AA3 for ; Sun, 7 Jun 2015 13:37:09 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57Db8VI047180 for ; Sun, 7 Jun 2015 13:37:08 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57Db8e6047169 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 13:37:08 GMT (envelope-from iateaca@FreeBSD.org) Date: Sun, 7 Jun 2015 13:37:08 GMT Message-Id: <201506071337.t57Db8e6047169@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: r286781 - soc2015/iateaca/bhyve-ne2000-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.20 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, 07 Jun 2015 13:37:09 -0000 Author: iateaca Date: Sun Jun 7 13:37:08 2015 New Revision: 286781 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286781 Log: emulate the write on ED_CR_TXP reg and implement a mechanism for asserting interrupts Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Jun 7 13:18:13 2015 (r286780) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Jun 7 13:37:08 2015 (r286781) @@ -56,6 +56,7 @@ uint8_t reset; /* State Variables */ + uint8_t lintr; uint8_t page; uint8_t remote_read; uint8_t remote_write; @@ -147,6 +148,26 @@ ne2000_set_reg_by_offset(sc, page, offset, reg_value); } +static void +pci_ne2000_update_intr(struct pci_ne2000_softc *sc) +{ + uint8_t isr = 0; + + isr = ne2000_get_reg_by_offset(sc, NE2000_P0, ED_P0_ISR); + + if (isr) { + if (!sc->lintr) { + pci_lintr_assert(sc->asc_pi); + sc->lintr = 1; + } + } else { + if (sc->lintr) { + pci_lintr_deassert(sc->asc_pi); + sc->lintr = 0; + } + } +} + static int pci_ne2000_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { @@ -340,6 +361,12 @@ uint16_t rbcr = 0; uint16_t rsar = 0; + uint8_t tbcr0 = 0; + uint8_t tbcr1 = 0; + + uint16_t tbcr = 0; + uint8_t tpsr = 0; + switch (offset) { case ED_P0_CR: if (value & ED_CR_STP) { @@ -368,14 +395,34 @@ ED_P0_RSAR1); rsar = rsar0 | (rsar1 << 8); - DPRINTF("ED driver started a Remote DMA %s op from %d address of %d bytes", + DPRINTF("Remote DMA %s: from %d address of %d bytes", sc->remote_read ? "read" : "write", rsar, rbcr); } if (value & ED_CR_TXP) { + assert(!(sc->remote_read || sc->remote_write)); + assert(value & ED_CR_STA); + + tpsr = ne2000_get_reg_by_offset(sc, NE2000_P0, + ED_P0_TPSR); + tbcr0 = ne2000_get_reg_by_offset(sc, NE2000_P0, + ED_P0_TBCR0); + tbcr1 = ne2000_get_reg_by_offset(sc, NE2000_P0, + ED_P0_TBCR1); + tbcr = tbcr0 | (tbcr1 << 8); + + DPRINTF("Transmit Packet: from %d address of %d bytes", + tpsr * ED_PAGE_SIZE, tbcr); + + /* TODO send the packet on the tap interface */ + + ne2000_set_field_by_offset(sc, NE2000_P0, ED_P0_ISR, + ED_ISR_PTX, ED_ISR_PTX); + pci_ne2000_update_intr(sc); } break; case ED_P0_ISR: ne2000_set_field_by_offset(sc, NE2000_P0, ED_P0_ISR, value, 0); + pci_ne2000_update_intr(sc); break; } From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 14:26:27 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6125C2E4 for ; Sun, 7 Jun 2015 14:26:27 +0000 (UTC) (envelope-from pratiksinghal@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 4ECAD16C7 for ; Sun, 7 Jun 2015 14:26:27 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57EQR4r032625 for ; Sun, 7 Jun 2015 14:26:27 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57EQQKd032623 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 14:26:26 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Sun, 7 Jun 2015 14:26:26 GMT Message-Id: <201506071426.t57EQQKd032623@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286783 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 07 Jun 2015 14:26:27 -0000 Author: pratiksinghal Date: Sun Jun 7 14:26:26 2015 New Revision: 286783 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286783 Log: Removed the kernel panic and locking problem Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 13:59:02 2015 (r286782) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sun Jun 7 14:26:26 2015 (r286783) @@ -211,6 +211,8 @@ sc->a10_use_dma = 0 ; } } + //sc->a10_use_dma = 0 ; /* Remove this after testing */ + device_printf(sc->a10_dev, "Setting up dma finished %d\n", sc->a10_use_dma) ; return (0); fail: @@ -258,16 +260,21 @@ static int a10_mmc_prepare_dma(struct a10_mmc_softc* sc) { + device_printf(sc->a10_dev, "In the start of prepare dma\n") ; struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; struct mmc_command* cmd = sc->a10_req->cmd ; + device_printf(sc->a10_dev, "After the cmd part\n") ; int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; + device_printf(sc->a10_dev, "After the read part\n") ; bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; + device_printf(sc->a10_dev, "After the block before the for loop\n") ; bus_size_t off = 0 ; int desc, rem,seg ; uint32_t val ; desc = 0 ; + device_printf(sc->a10_dev, "Before the starting of for loop\n") ; /* Pick a segment and program all the descriptors in the segment. */ for(seg = 0; seg < sc->a10_dma_cb_arg.nsegs ; seg++) { @@ -303,11 +310,13 @@ } } + device_printf(sc->a10_dev, "After the for loop in a10_prepare_dma\n") ; if(desc == sc->a10_dma_ndesc) { device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer") ; return EIO ; } + device_printf(sc->a10_dev, "After the desc check\n") ; bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; @@ -331,7 +340,8 @@ A10_MMC_WRITE_4(sc, A10_MMC_IDIE,val) ; A10_MMC_WRITE_4(sc, A10_MMC_DLBA,desc_paddr) ; A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A20) ; - + + device_printf(sc->a10_dev, "Done preparing for DMA\n") ; return (0) ; } @@ -500,7 +510,7 @@ rint = A10_MMC_READ_4(sc, A10_MMC_RINTR); imask = A10_MMC_READ_4(sc, A10_MMC_IMASK); idst = A10_MMC_READ_4(sc, A10_MMC_IDST) ; - if (imask == 0 && rint == 0) { + if (imask == 0 && rint == 0 ) { A10_MMC_UNLOCK(sc); return; } @@ -539,6 +549,12 @@ else a10_mmc_req_ok(sc) ; } + else + a10_mmc_req_done(sc) ; + + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ; + A10_MMC_UNLOCK(sc) ; return ; } @@ -575,6 +591,7 @@ uint32_t cmdreg; sc = device_get_softc(bus); + device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; A10_MMC_LOCK(sc); if (sc->a10_req) { A10_MMC_UNLOCK(sc); @@ -609,13 +626,12 @@ blksz = min(cmd->data->len, MMC_SECTOR_SIZE); A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz); A10_MMC_WRITE_4(sc, A10_MMC_BCNTR, cmd->data->len); + if(sc->a10_use_dma == 1) + a10_mmc_prepare_dma(sc) ; } A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); - if(sc->a10_use_dma == 1) - a10_mmc_prepare_dma(sc) ; A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); - callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, a10_mmc_timeout, sc); A10_MMC_UNLOCK(sc); From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 16:23:16 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3EE5CD1C for ; Sun, 7 Jun 2015 16:23:16 +0000 (UTC) (envelope-from def@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 2CA31128D for ; Sun, 7 Jun 2015 16:23:16 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57GNGSC061415 for ; Sun, 7 Jun 2015 16:23:16 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57GNE4e061410 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 16:23:14 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 16:23:14 GMT Message-Id: <201506071623.t57GNE4e061410@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286795 - in soc2013/def/crashdump-head: sbin/cryptcore sys/kern sys/sys 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.20 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, 07 Jun 2015 16:23:16 -0000 Author: def Date: Sun Jun 7 16:23:14 2015 New Revision: 286795 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286795 Log: Let kernel dump key size be size_t. Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 15:54:57 2015 (r286794) +++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 16:23:14 2015 (r286795) @@ -146,8 +146,8 @@ * From this moment on keys have to be erased before exit. */ privkeysize = RSA_size(privkey); - if (privkeysize != kdk->kdk_encryptedkeylen) { - pjdlog_error("RSA modulus size mismatch: equals %db and should be %db.", + if (privkeysize != (int)kdk->kdk_encryptedkeylen) { + pjdlog_error("RSA modulus size mismatch: equals %db and should be %lub.", 8 * privkeysize, 8 * kdk->kdk_encryptedkeylen); goto failed; } Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 15:54:57 2015 (r286794) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 16:23:14 2015 (r286795) @@ -139,7 +139,6 @@ SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW, &show_busybufs, 0, ""); -#ifdef EKCD MALLOC_DEFINE(M_KDK, "kerneldumpkey", "Kernel dump key structure"); static struct kerneldumpcrypto { @@ -155,6 +154,7 @@ static struct kerneldumpkey *dumpkey; +#ifdef EKCD static int kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS); static int kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS); @@ -905,7 +905,7 @@ kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS) { struct kerneldumpkey *kdk; - size_t kdksize; + size_t encryptedkeylen, kdksize; int error; if (req->newptr == NULL) { @@ -916,8 +916,10 @@ dumpkey->kdk_encryptedkeylen, req)); } - kdksize = ((sizeof(*kdk) + req->newlen + KERNELDUMP_BLOCK_SIZE - 1) / - KERNELDUMP_BLOCK_SIZE) * KERNELDUMP_BLOCK_SIZE; + encryptedkeylen = req->newlen; + kdksize = ((sizeof(*kdk) + encryptedkeylen + + KERNELDUMP_BLOCK_SIZE - 1) / KERNELDUMP_BLOCK_SIZE) * + KERNELDUMP_BLOCK_SIZE; kdk = (struct kerneldumpkey *)malloc(kdksize, M_KDK, M_WAITOK); if (kdk == NULL) @@ -925,7 +927,7 @@ kdk->kdk_size = kdksize; bcopy(dumpcrypto.kdc_iv, kdk->kdk_iv, sizeof(kdk->kdk_iv)); - kdk->kdk_encryptedkeylen = req->newlen; + kdk->kdk_encryptedkeylen = encryptedkeylen; error = sysctl_handle_opaque(oidp, kdk->kdk_encryptedkey, kdk->kdk_encryptedkeylen, req); @@ -1064,6 +1066,7 @@ length)); } #endif + return (di->dumper(di->priv, virtual, physical, offset, length)); } Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 15:54:57 2015 (r286794) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sun Jun 7 16:23:14 2015 (r286795) @@ -93,9 +93,9 @@ }; struct kerneldumpkey { - uint32_t kdk_size; + size_t kdk_size; uint8_t kdk_iv[KERNELDUMP_IV_SIZE]; - int kdk_encryptedkeylen; + size_t kdk_encryptedkeylen; uint8_t kdk_encryptedkey[]; }; From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 17:12:21 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12DA6A55 for ; Sun, 7 Jun 2015 17:12:21 +0000 (UTC) (envelope-from def@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 00B081E23 for ; Sun, 7 Jun 2015 17:12:21 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57HCKE0039841 for ; Sun, 7 Jun 2015 17:12:20 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57HCKho039838 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 17:12:20 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 17:12:20 GMT Message-Id: <201506071712.t57HCKho039838@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286796 - soc2013/def/crashdump-head/sys/kern 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.20 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, 07 Jun 2015 17:12:21 -0000 Author: def Date: Sun Jun 7 17:12:19 2015 New Revision: 286796 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286796 Log: Add missing EKCD scope. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 16:23:14 2015 (r286795) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:12:19 2015 (r286796) @@ -139,6 +139,7 @@ SYSCTL_INT(_kern_shutdown, OID_AUTO, show_busybufs, CTLFLAG_RW, &show_busybufs, 0, ""); +#ifdef EKCD MALLOC_DEFINE(M_KDK, "kerneldumpkey", "Kernel dump key structure"); static struct kerneldumpcrypto { @@ -154,7 +155,6 @@ static struct kerneldumpkey *dumpkey; -#ifdef EKCD static int kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS); static int kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS); @@ -967,6 +967,8 @@ if (dumper.dumper != NULL) return (EBUSY); dumper = *di; + dumper.kdc = NULL; + dumper.kdk = NULL; #ifdef EKCD error = kerneldump_crypto_init(&dumper, &dumpcrypto, dumpkey); @@ -982,6 +984,7 @@ return (0); } +#ifdef EKCD /* Encrypt data and call dumper. */ static int dump_encrypted_write(struct dumperinfo *di, void *virtual, vm_offset_t physical, @@ -1032,6 +1035,7 @@ return (0); } +#endif static int dump_check_bounds(struct dumperinfo *di, off_t offset, size_t length) @@ -1084,8 +1088,10 @@ if (error != 0) return (error); +#ifdef EKCD if (di->kdc->kdc_enable == 1) di->kdc->kdc_offset = offset + sizeof(*kdh); +#endif return (0); } @@ -1105,8 +1111,10 @@ if (error != 0) return (error); +#ifdef EKCD if (di->kdc->kdc_enable == 1) di->kdc->kdc_offset = offset + kerneldumpkey_size(kdk); +#endif return (0); } From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 17:40:50 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 69CBDA8 for ; Sun, 7 Jun 2015 17:40:50 +0000 (UTC) (envelope-from def@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 3DBF913BA for ; Sun, 7 Jun 2015 17:40:50 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57Heo4K065495 for ; Sun, 7 Jun 2015 17:40:50 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57HenYM065492 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 17:40:49 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 17:40:49 GMT Message-Id: <201506071740.t57HenYM065492@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286797 - in soc2013/def/crashdump-head: sbin/cryptcore sys/kern 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.20 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, 07 Jun 2015 17:40:50 -0000 Author: def Date: Sun Jun 7 17:40:48 2015 New Revision: 286797 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286797 Log: Rename key material to key. Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c ============================================================================== --- soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 17:12:19 2015 (r286796) +++ soc2013/def/crashdump-head/sbin/cryptcore/cryptcore.c Sun Jun 7 17:40:48 2015 (r286797) @@ -65,9 +65,9 @@ /* * From this moment on keys have to be erased before exit. */ - if (sysctlbyname("security.ekcd.keymaterial", NULL, NULL, key, + if (sysctlbyname("security.ekcd.key", NULL, NULL, key, KERNELDUMP_KEY_SIZE) != 0) { - pjdlog_errno(LOG_ERR, "Unable to set key material"); + pjdlog_errno(LOG_ERR, "Unable to set key"); goto failed; } if (sysctlbyname("security.ekcd.encryptedkey", NULL, NULL, Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:12:19 2015 (r286796) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:40:48 2015 (r286797) @@ -155,7 +155,7 @@ static struct kerneldumpkey *dumpkey; -static int kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS); +static int kerneldump_sysctl_key(SYSCTL_HANDLER_ARGS); static int kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS); SYSCTL_NODE(_security, OID_AUTO, ekcd, CTLFLAG_RW, 0, @@ -164,11 +164,11 @@ SYSCTL_INT(_security_ekcd, OID_AUTO, enable, CTLFLAG_RW, &dumpcrypto.kdc_enable, 0, "Enable encrypted kernel crash dumps"); -SYSCTL_PROC(_security_ekcd, OID_AUTO, keymaterial, CTLTYPE_OPAQUE | CTLFLAG_WR, - NULL, 0, kerneldump_sysctl_keymaterial, "", "Key material"); +SYSCTL_PROC(_security_ekcd, OID_AUTO, key, CTLTYPE_OPAQUE | CTLFLAG_WR, NULL, 0, + kerneldump_sysctl_key, "", "Key"); SYSCTL_PROC(_security_ekcd, OID_AUTO, encryptedkey, CTLTYPE_OPAQUE | CTLFLAG_WR, - NULL, 0, kerneldump_sysctl_encryptedkey, "", "Encrypted key material"); + NULL, 0, kerneldump_sysctl_encryptedkey, "", "Encrypted key"); #endif /* EKCD */ /* @@ -887,7 +887,7 @@ } static int -kerneldump_sysctl_keymaterial(SYSCTL_HANDLER_ARGS) +kerneldump_sysctl_key(SYSCTL_HANDLER_ARGS) { int error; From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 17:50:29 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8F7C92B5 for ; Sun, 7 Jun 2015 17:50:29 +0000 (UTC) (envelope-from def@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 7D97D1666 for ; Sun, 7 Jun 2015 17:50:29 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57HoTfQ070715 for ; Sun, 7 Jun 2015 17:50:29 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57HoSZW070713 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 17:50:28 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 17:50:28 GMT Message-Id: <201506071750.t57HoSZW070713@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286798 - soc2013/def/crashdump-head/sys/kern 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.20 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, 07 Jun 2015 17:50:29 -0000 Author: def Date: Sun Jun 7 17:50:28 2015 New Revision: 286798 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286798 Log: Don't allow to read keys via sysctl(8). Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:40:48 2015 (r286797) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:50:28 2015 (r286798) @@ -891,9 +891,12 @@ { int error; + if (req->newptr == NULL) + return (EPERM); + error = sysctl_handle_opaque(oidp, dumpcrypto.kdc_key, sizeof(dumpcrypto.kdc_key), req); - if (req->newptr == NULL || error != 0) + if (error != 0) return (error); arc4rand(dumpcrypto.kdc_iv, sizeof(dumpcrypto.kdc_iv), 0); @@ -908,13 +911,8 @@ size_t encryptedkeylen, kdksize; int error; - if (req->newptr == NULL) { - if (dumpkey == NULL) - return (0); - - return (sysctl_handle_opaque(oidp, dumpkey->kdk_encryptedkey, - dumpkey->kdk_encryptedkeylen, req)); - } + if (req->newptr == NULL) + return (EPERM); encryptedkeylen = req->newlen; kdksize = ((sizeof(*kdk) + encryptedkeylen + From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 18:59:53 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 52BFE8DE for ; Sun, 7 Jun 2015 18:59:53 +0000 (UTC) (envelope-from def@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 4101D1623 for ; Sun, 7 Jun 2015 18:59:53 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57IxrJc015205 for ; Sun, 7 Jun 2015 18:59:53 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57IxqSv015191 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 18:59:52 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 18:59:52 GMT Message-Id: <201506071859.t57IxqSv015191@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286799 - soc2013/def/crashdump-head/sys/kern 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.20 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, 07 Jun 2015 18:59:53 -0000 Author: def Date: Sun Jun 7 18:59:52 2015 New Revision: 286799 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286799 Log: Create a custom handler for sysctl security.ekcd.enable. Don't dump a key when EKCD is disabled. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 17:50:28 2015 (r286798) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 18:59:52 2015 (r286799) @@ -153,16 +153,17 @@ size_t kdc_bufused; } dumpcrypto; -static struct kerneldumpkey *dumpkey; +static struct kerneldumpkey *dumpkey = NULL; +static int kerneldump_sysctl_enable(SYSCTL_HANDLER_ARGS); static int kerneldump_sysctl_key(SYSCTL_HANDLER_ARGS); static int kerneldump_sysctl_encryptedkey(SYSCTL_HANDLER_ARGS); SYSCTL_NODE(_security, OID_AUTO, ekcd, CTLFLAG_RW, 0, "Encrypted kernel crash dumps"); -SYSCTL_INT(_security_ekcd, OID_AUTO, enable, CTLFLAG_RW, &dumpcrypto.kdc_enable, - 0, "Enable encrypted kernel crash dumps"); +SYSCTL_PROC(_security_ekcd, OID_AUTO, enable, CTLTYPE_INT | CTLFLAG_RW, NULL, 0, + kerneldump_sysctl_enable, "I", "Enable encrypted kernel crash dumps"); SYSCTL_PROC(_security_ekcd, OID_AUTO, key, CTLTYPE_OPAQUE | CTLFLAG_WR, NULL, 0, kerneldump_sysctl_key, "", "Key"); @@ -887,6 +888,24 @@ } static int +kerneldump_sysctl_enable(SYSCTL_HANDLER_ARGS) +{ + int error; + + error = sysctl_handle_opaque(oidp, &dumpcrypto.kdc_enable, + sizeof(dumpcrypto.kdc_enable), req); + if (error != 0) + return (error); + + if (dumpcrypto.kdc_enable == 1) + dumper.kdk = dumpkey; + else + dumper.kdk = NULL; + + return (0); +} + +static int kerneldump_sysctl_key(SYSCTL_HANDLER_ARGS) { int error; From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 19:53:19 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8776A3B5 for ; Sun, 7 Jun 2015 19:53:19 +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 75980138A for ; Sun, 7 Jun 2015 19:53:19 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57JrJXX098985 for ; Sun, 7 Jun 2015 19:53:19 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57JrILa098981 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 19:53:18 GMT (envelope-from iateaca@FreeBSD.org) Date: Sun, 7 Jun 2015 19:53:18 GMT Message-Id: <201506071953.t57JrILa098981@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: r286801 - soc2015/iateaca/bhyve-ne2000-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.20 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, 07 Jun 2015 19:53:19 -0000 Author: iateaca Date: Sun Jun 7 19:53:18 2015 New Revision: 286801 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286801 Log: when update intr take in consideration the IMR register Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Jun 7 18:59:47 2015 (r286800) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sun Jun 7 19:53:18 2015 (r286801) @@ -152,10 +152,12 @@ pci_ne2000_update_intr(struct pci_ne2000_softc *sc) { uint8_t isr = 0; + uint8_t imr = 0; isr = ne2000_get_reg_by_offset(sc, NE2000_P0, ED_P0_ISR); + imr = ne2000_get_reg_by_offset(sc, NE2000_P0, ED_P0_IMR); - if (isr) { + if (imr & isr) { if (!sc->lintr) { pci_lintr_assert(sc->asc_pi); sc->lintr = 1; From owner-svn-soc-all@FreeBSD.ORG Sun Jun 7 23:00:10 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9F402983 for ; Sun, 7 Jun 2015 23:00:10 +0000 (UTC) (envelope-from def@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 8DE261E57 for ; Sun, 7 Jun 2015 23:00:10 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t57N0Am8042599 for ; Sun, 7 Jun 2015 23:00:10 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t57N0ACS042144 for svn-soc-all@FreeBSD.org; Sun, 7 Jun 2015 23:00:10 GMT (envelope-from def@FreeBSD.org) Date: Sun, 7 Jun 2015 23:00:10 GMT Message-Id: <201506072300.t57N0ACS042144@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to def@FreeBSD.org using -f From: def@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286815 - soc2013/def/crashdump-head/sys/kern 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.20 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, 07 Jun 2015 23:00:10 -0000 Author: def Date: Sun Jun 7 23:00:09 2015 New Revision: 286815 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286815 Log: ddb(4) writes textdumps backwards. Assume that data have to be aligned to block size. Assume that the last call to dump_write and the current one write data chunks next to each other. Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 21:59:43 2015 (r286814) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sun Jun 7 23:00:09 2015 (r286815) @@ -148,9 +148,9 @@ uint8_t kdc_iv[KERNELDUMP_IV_SIZE]; keyInstance kdc_ki; cipherInstance kdc_ci; - off_t kdc_offset; + off_t kdc_lastoffset; + size_t kdc_lastlength; uint8_t kdc_buf[KERNELDUMP_BUFFER_SIZE]; - size_t kdc_bufused; } dumpcrypto; static struct kerneldumpkey *dumpkey = NULL; @@ -878,8 +878,8 @@ if (error <= 0) return (EINVAL); - kdc->kdc_offset = 0; - kdc->kdc_bufused = 0; + kdc->kdc_lastoffset = 0; + kdc->kdc_lastlength = 0; di->kdc = kdc; di->kdk = kdk; @@ -1010,44 +1010,49 @@ struct kerneldumpcrypto *kdc; struct kerneldumpkey *kdk; int error; - size_t len; + size_t nbytes; kdc = di->kdc; kdk = di->kdk; + /* Data have to be aligned to block size. */ + if ((length % KERNELDUMP_BLOCK_SIZE) != 0) + return (EINVAL); + /* Data have to be written continuously. */ - if (kdc->kdc_offset != 0 && kdc->kdc_offset != offset && - kdc->kdc_offset + kdc->kdc_bufused != offset) { + if (kdc->kdc_lastoffset != 0 && + kdc->kdc_lastoffset + kdc->kdc_lastlength != offset && + offset + length != kdc->kdc_lastoffset) { return (EINVAL); } - while (kdc->kdc_bufused + length >= KERNELDUMP_BUFFER_SIZE) { - len = KERNELDUMP_BUFFER_SIZE - kdc->kdc_bufused; - memcpy(kdc->kdc_buf + kdc->kdc_bufused, virtual, len); - kdc->kdc_bufused += len; + kdc->kdc_lastoffset = offset; + kdc->kdc_lastlength = length; + + while (length > 0) { + if (length >= KERNELDUMP_BUFFER_SIZE) + nbytes = KERNELDUMP_BUFFER_SIZE; + else + nbytes = length; + memcpy(kdc->kdc_buf, virtual, nbytes); error = rijndael_blockEncrypt(&kdc->kdc_ci, &kdc->kdc_ki, - kdc->kdc_buf, 8 * KERNELDUMP_BUFFER_SIZE, kdc->kdc_buf); + kdc->kdc_buf, 8 * nbytes, kdc->kdc_buf); if (error <= 0) return (EIO); error = rijndael_cipherInit(&kdc->kdc_ci, MODE_CBC, - kdc->kdc_buf + KERNELDUMP_BUFFER_SIZE - KERNELDUMP_IV_SIZE); + kdc->kdc_buf + nbytes - KERNELDUMP_IV_SIZE); if (error <= 0) return (EIO); error = di->dumper(di->priv, kdc->kdc_buf, physical, - kdc->kdc_offset, KERNELDUMP_BUFFER_SIZE); + offset, nbytes); if (error != 0) return (error); - kdc->kdc_bufused = 0; - kdc->kdc_offset += KERNELDUMP_BUFFER_SIZE; - virtual = (void *)((char *)virtual + len); - length -= len; - } - if (length > 0) { - memcpy(kdc->kdc_buf + kdc->kdc_bufused, virtual, length); - kdc->kdc_bufused += length; + offset += nbytes; + virtual = (void *)((uint8_t *)virtual + nbytes); + length -= nbytes; } return (0); @@ -1106,8 +1111,10 @@ return (error); #ifdef EKCD - if (di->kdc->kdc_enable == 1) - di->kdc->kdc_offset = offset + sizeof(*kdh); + if (di->kdc->kdc_enable == 1) { + di->kdc->kdc_lastoffset = offset; + di->kdc->kdc_lastlength = sizeof(*kdh); + } #endif return (0); @@ -1129,8 +1136,10 @@ return (error); #ifdef EKCD - if (di->kdc->kdc_enable == 1) - di->kdc->kdc_offset = offset + kerneldumpkey_size(kdk); + if (di->kdc->kdc_enable == 1) { + di->kdc->kdc_lastoffset = offset; + di->kdc->kdc_lastlength = kerneldumpkey_size(kdk); + } #endif return (0); From owner-svn-soc-all@FreeBSD.ORG Mon Jun 8 09:57:03 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3B86F2F7 for ; Mon, 8 Jun 2015 09:57:03 +0000 (UTC) (envelope-from btw@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 29006194D for ; Mon, 8 Jun 2015 09:57:03 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t589v3dY099504 for ; Mon, 8 Jun 2015 09:57:03 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t589v1oa099470 for svn-soc-all@FreeBSD.org; Mon, 8 Jun 2015 09:57:01 GMT (envelope-from btw@FreeBSD.org) Date: Mon, 8 Jun 2015 09:57:01 GMT Message-Id: <201506080957.t589v1oa099470@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286826 - soc2015/btw/head/sys/net 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.20 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, 08 Jun 2015 09:57:03 -0000 Author: btw Date: Mon Jun 8 09:57:00 2015 New Revision: 286826 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286826 Log: Add a temporary sysctl to export the statistics of ifring to userspace. Modified: soc2015/btw/head/sys/net/if.c soc2015/btw/head/sys/net/if.h soc2015/btw/head/sys/net/if_mib.c soc2015/btw/head/sys/net/if_mib.h soc2015/btw/head/sys/net/if_var.h Modified: soc2015/btw/head/sys/net/if.c ============================================================================== --- soc2015/btw/head/sys/net/if.c Mon Jun 8 07:06:33 2015 (r286825) +++ soc2015/btw/head/sys/net/if.c Mon Jun 8 09:57:00 2015 (r286826) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -1769,6 +1770,39 @@ } /* + * Copy data from ifring to userland API structure if_ring_data. + */ +void +if_ring_data_copy(struct ifnet *ifp, struct if_ring_data *ifrd) +{ + struct ifrstat *ifrs; + struct xifrstat *xifrs; + int ri, cpu; + + ifrd->ifrd_epoch = ifp->if_epoch; + ifrd->ifrd_lastchange = ifp->if_lastchange; + + ifrd->ifrd_ncpus = mp_ncpus; + ifrd->ifrd_nrings = ifp->if_nrings; + + for (ri = 0; ri < ifp->if_nrings; ri++) { + for (cpu = 0; cpu < mp_ncpus; cpu++) { + + ifrs = &ifp->if_rings[ri]->ifr_stats[cpu]; + xifrs = &ifrd->ifrd_stats[ri * mp_ncpus + cpu]; + + xifrs->ifrs_ifinput = ifrs->ifrs_ifinput; + xifrs->ifrs_netisr = ifrs->ifrs_netisr; + xifrs->ifrs_ether = ifrs->ifrs_ether; + xifrs->ifrs_ip = ifrs->ifrs_ip; + xifrs->ifrs_ip6 = ifrs->ifrs_ip6; + xifrs->ifrs_udp = ifrs->ifrs_udp; + xifrs->ifrs_tcp = ifrs->ifrs_tcp; + } + } +} + +/* * Initialization, destruction and refcounting functions for ifaddrs. */ struct ifaddr * Modified: soc2015/btw/head/sys/net/if.h ============================================================================== --- soc2015/btw/head/sys/net/if.h Mon Jun 8 07:06:33 2015 (r286825) +++ soc2015/btw/head/sys/net/if.h Mon Jun 8 09:57:00 2015 (r286826) @@ -68,6 +68,35 @@ char *ifcr_buffer; /* buffer for cloner names */ }; +struct xifrstat { + uint64_t ifrs_ifinput; + uint64_t ifrs_netisr; + uint64_t ifrs_ether; + uint64_t ifrs_ip; + uint64_t ifrs_ip6; + uint64_t ifrs_udp; + uint64_t ifrs_tcp; +}; + +struct if_ring_data { + /* Unions are here to make sizes MI. */ + union { /* uptime at attach or stat reset */ + time_t ifrd_epoch; + uint64_t __ifrd_epoch_ph; + }; + union { /* time of last administrative change */ + struct timeval ifrd_lastchange; + struct { + uint64_t ph1; + uint64_t ph2; + } __ifrd_lastchange_ph; + }; + + int ifrd_ncpus; + int ifrd_nrings; + struct xifrstat ifrd_stats[0]; +}; + /* * Structure describing information about an interface * which may be of interest to management entities. Modified: soc2015/btw/head/sys/net/if_mib.c ============================================================================== --- soc2015/btw/head/sys/net/if_mib.c Mon Jun 8 07:06:33 2015 (r286825) +++ soc2015/btw/head/sys/net/if_mib.c Mon Jun 8 09:57:00 2015 (r286826) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,8 @@ * - a link-type-specific data * structure (as might be used * by an SNMP agent + * .ifdata..ringinfo + * - what's in `struct if_ring_data' * * Perhaps someday we will make addresses accessible via this interface * as well (then there will be four such...). The reason that the @@ -78,7 +81,7 @@ int error; u_int namelen = arg2; struct ifnet *ifp; - struct ifmibdata ifmd; + struct ifmibdata *ifmd = NULL; size_t dlen; char *dbuf; @@ -96,18 +99,23 @@ goto out; case IFDATA_GENERAL: - bzero(&ifmd, sizeof(ifmd)); - strlcpy(ifmd.ifmd_name, ifp->if_xname, sizeof(ifmd.ifmd_name)); + ifmd = malloc(sizeof(*ifmd), M_TEMP, M_NOWAIT | M_ZERO); + if (ifmd == NULL) { + error = ENOMEM; + goto out; + } + strlcpy(ifmd->ifmd_name, ifp->if_xname, + sizeof(ifmd->ifmd_name)); - ifmd.ifmd_pcount = ifp->if_pcount; - if_data_copy(ifp, &ifmd.ifmd_data); + ifmd->ifmd_pcount = ifp->if_pcount; + if_data_copy(ifp, &ifmd->ifmd_data); - ifmd.ifmd_flags = ifp->if_flags; - ifmd.ifmd_snd_len = 0; /* XXXGL */ - ifmd.ifmd_snd_maxlen = 0; /* XXXGL */ - ifmd.ifmd_snd_drops = if_get_counter(ifp, IFCOUNTER_OQDROPS); + ifmd->ifmd_flags = ifp->if_flags; + ifmd->ifmd_snd_len = 0; /* XXXGL */ + ifmd->ifmd_snd_maxlen = 0; /* XXXGL */ + ifmd->ifmd_snd_drops = if_get_counter(ifp, IFCOUNTER_OQDROPS); - error = SYSCTL_OUT(req, &ifmd, sizeof ifmd); + error = SYSCTL_OUT(req, ifmd, sizeof(*ifmd)); if (error) goto out; break; @@ -140,8 +148,28 @@ error = EPERM; free(dbuf, M_TEMP); goto out; + + case IFDATA_RINGINFO: + dlen = sizeof(*ifmd) + sizeof(struct xifrstat) * mp_ncpus * + ifp->if_nrings; + + ifmd = malloc(dlen, M_TEMP, M_NOWAIT | M_ZERO); + if (ifmd == NULL) { + error = ENOMEM; + goto out; + } + strlcpy(ifmd->ifmd_name, ifp->if_xname, + sizeof(ifmd->ifmd_name)); + if_ring_data_copy(ifp, &ifmd->ifmd_ring_data); + + error = SYSCTL_OUT(req, ifmd, dlen); + if (error) + goto out; + break; } out: + if (ifmd != NULL) + free(ifmd, M_TEMP); if_rele(ifp); return error; } Modified: soc2015/btw/head/sys/net/if_mib.h ============================================================================== --- soc2015/btw/head/sys/net/if_mib.h Mon Jun 8 07:06:33 2015 (r286825) +++ soc2015/btw/head/sys/net/if_mib.h Mon Jun 8 09:57:00 2015 (r286826) @@ -40,9 +40,16 @@ int ifmd_snd_maxlen; /* maximum length of send queue */ int ifmd_snd_drops; /* number of drops in send queue */ int ifmd_filler[4]; /* for future expansion */ - struct if_data ifmd_data; /* generic information and statistics */ + union { + struct if_data ifmd_data; /* generic information and statistics */ + struct if_ring_data ifmd_ring_data; + }; }; +#ifdef CTASSERT +CTASSERT(sizeof(struct if_data) >= sizeof(struct if_ring_data)); +#endif + /* * sysctl MIB tags at the net.link.generic level */ @@ -55,6 +62,7 @@ #define IFDATA_GENERAL 1 /* generic stats for all kinds of ifaces */ #define IFDATA_LINKSPECIFIC 2 /* specific to the type of interface */ #define IFDATA_DRIVERNAME 3 /* driver name and unit */ +#define IFDATA_RINGINFO 4 /* ring statistics */ /* * MIB tags at the net.link.generic.system level Modified: soc2015/btw/head/sys/net/if_var.h ============================================================================== --- soc2015/btw/head/sys/net/if_var.h Mon Jun 8 07:06:33 2015 (r286825) +++ soc2015/btw/head/sys/net/if_var.h Mon Jun 8 09:57:00 2015 (r286826) @@ -450,6 +450,7 @@ int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen); void if_data_copy(struct ifnet *, struct if_data *); +void if_ring_data_copy(struct ifnet *, struct if_ring_data *); int if_getmtu_family(if_t ifp, int family); int if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max); From owner-svn-soc-all@FreeBSD.ORG Tue Jun 9 20:04:50 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A1B5C394 for ; Tue, 9 Jun 2015 20:04:50 +0000 (UTC) (envelope-from clord@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 8C09C1352 for ; Tue, 9 Jun 2015 20:04:50 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t59K4oS5072158 for ; Tue, 9 Jun 2015 20:04:50 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t59K4heA072082 for svn-soc-all@FreeBSD.org; Tue, 9 Jun 2015 20:04:43 GMT (envelope-from clord@FreeBSD.org) Date: Tue, 9 Jun 2015 20:04:43 GMT Message-Id: <201506092004.t59K4heA072082@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286868 - in soc2015/clord/head: . bin/chmod bin/cp bin/ls cddl cddl/contrib/opensolaris cddl/contrib/opensolaris/lib/libdtrace/common contrib/dtc contrib/top etc lib/libc lib/libc/a... 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.20 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, 09 Jun 2015 20:04:50 -0000 Author: clord Date: Tue Jun 9 20:04:43 2015 New Revision: 286868 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286868 Log: merge with head Added: soc2015/clord/head/contrib/top/top.local.hs - copied unchanged from r286867, mirror/FreeBSD/head/contrib/top/top.local.hs soc2015/clord/head/contrib/top/top.xs - copied unchanged from r286867, mirror/FreeBSD/head/contrib/top/top.xs soc2015/clord/head/release/arm/GUMSTIX.conf - copied unchanged from r286867, mirror/FreeBSD/head/release/arm/GUMSTIX.conf soc2015/clord/head/sys/arm/ti/am335x/tps65217x.h - copied unchanged from r286867, mirror/FreeBSD/head/sys/arm/ti/am335x/tps65217x.h soc2015/clord/head/sys/dev/ixl/i40e_devids.h - copied unchanged from r286867, mirror/FreeBSD/head/sys/dev/ixl/i40e_devids.h soc2015/clord/head/sys/dev/proto/proto_busdma.c - copied unchanged from r286867, mirror/FreeBSD/head/sys/dev/proto/proto_busdma.c soc2015/clord/head/sys/dev/proto/proto_busdma.h - copied unchanged from r286867, mirror/FreeBSD/head/sys/dev/proto/proto_busdma.h soc2015/clord/head/sys/modules/geom/geom_map/ - copied from r286867, mirror/FreeBSD/head/sys/modules/geom/geom_map/ soc2015/clord/head/tools/bus_space/busdma.c - copied unchanged from r286867, mirror/FreeBSD/head/tools/bus_space/busdma.c soc2015/clord/head/tools/bus_space/busdma.h - copied unchanged from r286867, mirror/FreeBSD/head/tools/bus_space/busdma.h soc2015/clord/head/usr.sbin/pw/tests/pw-modified.conf - copied unchanged from r286867, mirror/FreeBSD/head/usr.sbin/pw/tests/pw-modified.conf soc2015/clord/head/usr.sbin/pw/tests/pw.conf - copied unchanged from r286867, mirror/FreeBSD/head/usr.sbin/pw/tests/pw.conf soc2015/clord/head/usr.sbin/pw/tests/pw_config.sh - copied unchanged from r286867, mirror/FreeBSD/head/usr.sbin/pw/tests/pw_config.sh Deleted: soc2015/clord/head/contrib/top/top.X soc2015/clord/head/contrib/top/top.local.H Modified: soc2015/clord/head/ (props changed) soc2015/clord/head/UPDATING soc2015/clord/head/bin/chmod/chmod.c soc2015/clord/head/bin/cp/cp.1 soc2015/clord/head/bin/cp/cp.c soc2015/clord/head/bin/cp/extern.h soc2015/clord/head/bin/cp/utils.c soc2015/clord/head/bin/ls/ls.c soc2015/clord/head/cddl/ (props changed) soc2015/clord/head/cddl/contrib/opensolaris/ (props changed) soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.h soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c soc2015/clord/head/contrib/dtc/ (props changed) soc2015/clord/head/contrib/dtc/checks.c soc2015/clord/head/contrib/top/ (props changed) soc2015/clord/head/etc/ (props changed) soc2015/clord/head/etc/Makefile soc2015/clord/head/lib/libc/ (props changed) soc2015/clord/head/lib/libc/aarch64/gen/setjmp.S soc2015/clord/head/lib/libc/string/strchr.3 soc2015/clord/head/lib/libdevstat/devstat.c soc2015/clord/head/lib/libdpv/dprompt.c soc2015/clord/head/lib/libedit/edit/readline/readline.h soc2015/clord/head/lib/libedit/readline.c soc2015/clord/head/lib/libugidfw/ugidfw.c soc2015/clord/head/lib/libutil/ (props changed) soc2015/clord/head/lib/libutil/Makefile soc2015/clord/head/lib/libutil/libutil.h soc2015/clord/head/lib/libutil/pw_util.3 soc2015/clord/head/lib/libutil/pw_util.c soc2015/clord/head/release/arm/BEAGLEBONE.conf soc2015/clord/head/release/arm/CUBOX-HUMMINGBOARD.conf soc2015/clord/head/release/arm/WANDBOARD.conf soc2015/clord/head/release/tools/arm.subr soc2015/clord/head/sbin/ (props changed) soc2015/clord/head/sbin/badsect/Makefile soc2015/clord/head/share/ (props changed) soc2015/clord/head/share/examples/bhyve/vmrun.sh soc2015/clord/head/share/man/man4/ (props changed) soc2015/clord/head/share/man/man4/geom.4 soc2015/clord/head/share/man/man4/geom_map.4 soc2015/clord/head/share/misc/committers-ports.dot soc2015/clord/head/share/mk/bsd.mkopt.mk soc2015/clord/head/sys/ (props changed) soc2015/clord/head/sys/amd64/amd64/initcpu.c soc2015/clord/head/sys/amd64/amd64/pmap.c soc2015/clord/head/sys/amd64/include/md_var.h soc2015/clord/head/sys/amd64/include/vmparam.h soc2015/clord/head/sys/amd64/linux/linux_support.s soc2015/clord/head/sys/amd64/vmm/ (props changed) soc2015/clord/head/sys/amd64/vmm/amd/svm.c soc2015/clord/head/sys/amd64/vmm/intel/vmx.c soc2015/clord/head/sys/amd64/vmm/intel/vmx.h soc2015/clord/head/sys/amd64/vmm/intel/vmx_msr.c soc2015/clord/head/sys/amd64/vmm/vmm_instruction_emul.c soc2015/clord/head/sys/arm/arm/exception.S soc2015/clord/head/sys/arm/arm/genassym.c soc2015/clord/head/sys/arm/arm/machdep.c soc2015/clord/head/sys/arm/arm/mp_machdep.c soc2015/clord/head/sys/arm/arm/pmap-v6-new.c soc2015/clord/head/sys/arm/arm/swtch.S soc2015/clord/head/sys/arm/arm/sys_machdep.c soc2015/clord/head/sys/arm/arm/vfp.c soc2015/clord/head/sys/arm/arm/vm_machdep.c soc2015/clord/head/sys/arm/freescale/imx/imx6_sdma.c soc2015/clord/head/sys/arm/include/pcpu.h soc2015/clord/head/sys/arm/include/vmparam.h soc2015/clord/head/sys/arm/ti/am335x/am335x_pmic.c soc2015/clord/head/sys/arm64/arm64/exception.S soc2015/clord/head/sys/arm64/include/vmparam.h soc2015/clord/head/sys/boot/ (props changed) soc2015/clord/head/sys/boot/zfs/zfsimpl.c soc2015/clord/head/sys/cam/ctl/ctl.c soc2015/clord/head/sys/cam/ctl/scsi_ctl.c soc2015/clord/head/sys/cddl/compat/opensolaris/sys/nvpair.h soc2015/clord/head/sys/compat/linux/linux_emul.c soc2015/clord/head/sys/compat/linux/linux_socket.c soc2015/clord/head/sys/conf/ (props changed) soc2015/clord/head/sys/conf/NOTES soc2015/clord/head/sys/conf/options soc2015/clord/head/sys/dev/aic7xxx/aic79xx_pci.c soc2015/clord/head/sys/dev/cxgbe/t4_netmap.c soc2015/clord/head/sys/dev/drm/drmP.h soc2015/clord/head/sys/dev/drm/drm_agpsupport.c soc2015/clord/head/sys/dev/drm/drm_bufs.c soc2015/clord/head/sys/dev/drm/drm_drv.c soc2015/clord/head/sys/dev/drm/drm_irq.c soc2015/clord/head/sys/dev/drm/i915_drv.c soc2015/clord/head/sys/dev/drm/mach64_drv.c soc2015/clord/head/sys/dev/drm/mga_drv.c soc2015/clord/head/sys/dev/drm/r128_drv.c soc2015/clord/head/sys/dev/drm/radeon_drv.c soc2015/clord/head/sys/dev/drm/savage_drv.c soc2015/clord/head/sys/dev/drm/sis_drv.c soc2015/clord/head/sys/dev/drm/tdfx_drv.c soc2015/clord/head/sys/dev/drm2/drm_bufs.c soc2015/clord/head/sys/dev/iwn/if_iwn.c soc2015/clord/head/sys/dev/ixl/i40e_adminq.c soc2015/clord/head/sys/dev/ixl/i40e_adminq.h soc2015/clord/head/sys/dev/ixl/i40e_adminq_cmd.h soc2015/clord/head/sys/dev/ixl/i40e_common.c soc2015/clord/head/sys/dev/ixl/i40e_hmc.c soc2015/clord/head/sys/dev/ixl/i40e_hmc.h soc2015/clord/head/sys/dev/ixl/i40e_lan_hmc.c soc2015/clord/head/sys/dev/ixl/i40e_nvm.c soc2015/clord/head/sys/dev/ixl/i40e_osdep.h soc2015/clord/head/sys/dev/ixl/i40e_prototype.h soc2015/clord/head/sys/dev/ixl/i40e_register.h soc2015/clord/head/sys/dev/ixl/i40e_type.h soc2015/clord/head/sys/dev/ixl/i40e_virtchnl.h soc2015/clord/head/sys/dev/ixl/if_ixl.c soc2015/clord/head/sys/dev/ixl/if_ixlv.c soc2015/clord/head/sys/dev/ixl/ixlv.h soc2015/clord/head/sys/dev/ixl/ixlvc.c soc2015/clord/head/sys/dev/mfi/mfi.c soc2015/clord/head/sys/dev/nand/nfc_rb.c soc2015/clord/head/sys/dev/pci/vga_pci.c soc2015/clord/head/sys/dev/proto/proto.h soc2015/clord/head/sys/dev/proto/proto_bus_pci.c soc2015/clord/head/sys/dev/proto/proto_core.c soc2015/clord/head/sys/dev/proto/proto_dev.h soc2015/clord/head/sys/dev/usb/quirk/usb_quirk.c soc2015/clord/head/sys/dev/usb/usb_dev.c soc2015/clord/head/sys/dev/usb/usbdevs soc2015/clord/head/sys/fs/devfs/devfs_vnops.c soc2015/clord/head/sys/fs/unionfs/union_vfsops.c soc2015/clord/head/sys/geom/part/g_part_gpt.c soc2015/clord/head/sys/i386/i386/initcpu.c soc2015/clord/head/sys/i386/i386/pmap.c soc2015/clord/head/sys/i386/i386/trap.c soc2015/clord/head/sys/i386/include/md_var.h soc2015/clord/head/sys/i386/include/vmparam.h soc2015/clord/head/sys/kern/imgact_elf.c soc2015/clord/head/sys/kern/kern_tc.c soc2015/clord/head/sys/kern/subr_uio.c soc2015/clord/head/sys/kern/subr_witness.c soc2015/clord/head/sys/kern/uipc_shm.c soc2015/clord/head/sys/kern/vfs_vnops.c soc2015/clord/head/sys/mips/conf/AR71XX_BASE soc2015/clord/head/sys/mips/conf/AR724X_BASE soc2015/clord/head/sys/mips/include/vmparam.h soc2015/clord/head/sys/modules/Makefile soc2015/clord/head/sys/modules/em/Makefile soc2015/clord/head/sys/modules/ixl/Makefile soc2015/clord/head/sys/modules/ixlv/Makefile soc2015/clord/head/sys/modules/proto/Makefile soc2015/clord/head/sys/net80211/ieee80211.c soc2015/clord/head/sys/net80211/ieee80211_freebsd.c soc2015/clord/head/sys/net80211/ieee80211_freebsd.h soc2015/clord/head/sys/net80211/ieee80211_output.c soc2015/clord/head/sys/net80211/ieee80211_scan.c soc2015/clord/head/sys/net80211/ieee80211_scan.h soc2015/clord/head/sys/net80211/ieee80211_scan_sw.c soc2015/clord/head/sys/net80211/ieee80211_scan_sw.h soc2015/clord/head/sys/net80211/ieee80211_var.h soc2015/clord/head/sys/netinet/sctp_sysctl.c soc2015/clord/head/sys/netinet/sctp_uio.h soc2015/clord/head/sys/powerpc/include/vmparam.h soc2015/clord/head/sys/sparc64/include/vmparam.h soc2015/clord/head/sys/sys/bus.h soc2015/clord/head/sys/sys/file.h soc2015/clord/head/sys/sys/mman.h soc2015/clord/head/sys/sys/param.h soc2015/clord/head/sys/vm/vm_extern.h soc2015/clord/head/sys/vm/vm_mmap.c soc2015/clord/head/sys/vm/vm_page.c soc2015/clord/head/sys/vm/vm_reserv.c soc2015/clord/head/sys/x86/acpica/madt.c soc2015/clord/head/sys/x86/x86/identcpu.c soc2015/clord/head/tests/sys/kern/ptrace_test.c soc2015/clord/head/tools/bus_space/C/Makefile soc2015/clord/head/tools/bus_space/C/lang.c soc2015/clord/head/tools/bus_space/C/libbus_space.h soc2015/clord/head/tools/bus_space/Makefile.inc soc2015/clord/head/tools/bus_space/Python/lang.c soc2015/clord/head/usr.bin/colcrt/colcrt.1 soc2015/clord/head/usr.bin/colrm/colrm.1 soc2015/clord/head/usr.bin/expand/expand.1 soc2015/clord/head/usr.bin/fold/fold.1 soc2015/clord/head/usr.bin/keylogin/Makefile soc2015/clord/head/usr.bin/last/last.1 soc2015/clord/head/usr.bin/mail/Makefile soc2015/clord/head/usr.bin/mail/main.c soc2015/clord/head/usr.bin/mkstr/mkstr.1 soc2015/clord/head/usr.bin/mkstr/mkstr.c soc2015/clord/head/usr.bin/rsh/Makefile soc2015/clord/head/usr.bin/rsh/rsh.c soc2015/clord/head/usr.bin/rup/Makefile soc2015/clord/head/usr.bin/systat/Makefile soc2015/clord/head/usr.bin/systat/main.c soc2015/clord/head/usr.bin/top/Makefile soc2015/clord/head/usr.bin/tset/tset.1 soc2015/clord/head/usr.bin/vgrind/regexp.c soc2015/clord/head/usr.bin/vgrind/vgrindefs.c soc2015/clord/head/usr.bin/vtfontcvt/Makefile soc2015/clord/head/usr.sbin/pw/grupd.c soc2015/clord/head/usr.sbin/pw/pw.c soc2015/clord/head/usr.sbin/pw/pw.h soc2015/clord/head/usr.sbin/pw/pw_group.c soc2015/clord/head/usr.sbin/pw/pw_user.c soc2015/clord/head/usr.sbin/pw/pwupd.c soc2015/clord/head/usr.sbin/pw/pwupd.h soc2015/clord/head/usr.sbin/pw/tests/Makefile soc2015/clord/head/usr.sbin/pw/tests/pw_groupmod.sh soc2015/clord/head/usr.sbin/pw/tests/pw_useradd.sh soc2015/clord/head/usr.sbin/pw/tests/pw_usermod.sh soc2015/clord/head/usr.sbin/pwd_mkdb/pwd_mkdb.8 soc2015/clord/head/usr.sbin/pwd_mkdb/pwd_mkdb.c Modified: soc2015/clord/head/UPDATING ============================================================================== --- soc2015/clord/head/UPDATING Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/UPDATING Tue Jun 9 20:04:43 2015 (r286868) @@ -31,6 +31,15 @@ disable the most expensive debugging functionality run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) +20150604: + Generation of legacy formatted entries have been disabled by default + in pwd_mkdb(8), as all base system consumers of the legacy formatted + entries were converted to use the new format by default when the new, + machine independent format have been added and supported since FreeBSD + 5.x. + + Please see the pwd_mkdb(8) manual page for further details. + 20150525: Clang and llvm have been upgraded to 3.6.1 release. Please see the 20141231 entry below for information about prerequisites and upgrading, Modified: soc2015/clord/head/bin/chmod/chmod.c ============================================================================== --- soc2015/clord/head/bin/chmod/chmod.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/chmod/chmod.c Tue Jun 9 20:04:43 2015 (r286868) @@ -162,14 +162,16 @@ atflag = AT_SYMLINK_NOFOLLOW; switch (p->fts_info) { - case FTS_D: /* Change it at FTS_DP. */ + case FTS_D: if (!Rflag) fts_set(ftsp, p, FTS_SKIP); - continue; + break; case FTS_DNR: /* Warn, chmod. */ warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); rval = 1; break; + case FTS_DP: /* Already changed at FTS_D. */ + continue; case FTS_ERR: /* Warn, continue. */ case FTS_NS: warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); Modified: soc2015/clord/head/bin/cp/cp.1 ============================================================================== --- soc2015/clord/head/bin/cp/cp.1 Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/cp/cp.1 Tue Jun 9 20:04:43 2015 (r286868) @@ -32,7 +32,7 @@ .\" @(#)cp.1 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd March 15, 2013 +.Dd June 6, 2015 .Dt CP 1 .Os .Sh NAME @@ -45,7 +45,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpvx +.Op Fl alpsvx .Ar source_file target_file .Nm .Oo @@ -53,7 +53,7 @@ .Op Fl H | Fl L | Fl P .Oc .Op Fl f | i | n -.Op Fl alpvx +.Op Fl alpsvx .Ar source_file ... target_directory .Sh DESCRIPTION In the first synopsis form, the @@ -179,6 +179,8 @@ and either the user ID or group ID cannot be preserved, neither the set-user-ID nor set-group-ID bits are preserved in the copy's permissions. +.It Fl s +Create symbolic links to regular files in a hierarchy instead of copying. .It Fl v Cause .Nm @@ -298,7 +300,10 @@ files while recreating a hierarchy. .Pp The -.Fl v +.Fl l, +.Fl s, +.Fl v, +.Fl x and .Fl n options are non-standard and their use in scripts is not recommended. Modified: soc2015/clord/head/bin/cp/cp.c ============================================================================== --- soc2015/clord/head/bin/cp/cp.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/cp/cp.c Tue Jun 9 20:04:43 2015 (r286868) @@ -75,15 +75,15 @@ #include "extern.h" #define STRIP_TRAILING_SLASH(p) { \ - while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/') \ - *--(p).p_end = 0; \ + while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/') \ + *--(p).p_end = 0; \ } static char emptystring[] = ""; PATH_T to = { to.p_path, emptystring, "" }; -int fflag, iflag, lflag, nflag, pflag, vflag; +int fflag, iflag, lflag, nflag, pflag, sflag, vflag; static int Rflag, rflag; volatile sig_atomic_t info; @@ -102,7 +102,7 @@ fts_options = FTS_NOCHDIR | FTS_PHYSICAL; Hflag = Lflag = 0; - while ((ch = getopt(argc, argv, "HLPRafilnprvx")) != -1) + while ((ch = getopt(argc, argv, "HLPRafilnprsvx")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -145,6 +145,9 @@ rflag = Lflag = 1; Hflag = 0; break; + case 's': + sflag = 1; + break; case 'v': vflag = 1; break; @@ -163,6 +166,8 @@ if (Rflag && rflag) errx(1, "the -R and -r options may not be specified together"); + if (lflag && sflag) + errx(1, "the -l and -s options may not be specified together"); if (rflag) Rflag = 1; if (Rflag) { @@ -183,7 +188,7 @@ if (strlcpy(to.p_path, target, sizeof(to.p_path)) >= sizeof(to.p_path)) errx(1, "%s: name too long", target); to.p_end = to.p_path + strlen(to.p_path); - if (to.p_path == to.p_end) { + if (to.p_path == to.p_end) { *to.p_end++ = '.'; *to.p_end = 0; } @@ -240,10 +245,10 @@ type = FILE_TO_FILE; if (have_trailing_slash && type == FILE_TO_FILE) { - if (r == -1) + if (r == -1) { errx(1, "directory %s does not exist", - to.p_path); - else + to.p_path); + } else errx(1, "%s is not a directory", to.p_path); } } else @@ -294,8 +299,8 @@ /* * If we are in case (2) or (3) above, we need to append the - * source name to the target name. - */ + * source name to the target name. + */ if (type != FILE_TO_FILE) { /* * Need to remember the roots of traversals to create @@ -374,7 +379,8 @@ mode = curr->fts_statp->st_mode; if ((mode & (S_ISUID | S_ISGID | S_ISTXT)) || ((mode | S_IRWXU) & mask) != (mode & mask)) - if (chmod(to.p_path, mode & mask) != 0){ + if (chmod(to.p_path, mode & mask) != + 0) { warn("chmod: %s", to.p_path); rval = 1; } @@ -382,7 +388,7 @@ continue; } - /* Not an error but need to remember it happened */ + /* Not an error but need to remember it happened. */ if (stat(to.p_path, &to_stat) == -1) dne = 1; else { @@ -408,7 +414,7 @@ switch (curr->fts_statp->st_mode & S_IFMT) { case S_IFLNK: - /* Catch special case of a non-dangling symlink */ + /* Catch special case of a non-dangling symlink. */ if ((fts_options & FTS_LOGICAL) || ((fts_options & FTS_COMFOLLOW) && curr->fts_level == 0)) { @@ -433,7 +439,7 @@ * modified by the umask. Trade-off between being * able to write the directory (if from directory is * 555) and not causing a permissions race. If the - * umask blocks owner writes, we fail.. + * umask blocks owner writes, we fail. */ if (dne) { if (mkdir(to.p_path, @@ -452,7 +458,7 @@ break; case S_IFBLK: case S_IFCHR: - if (Rflag) { + if (Rflag && !sflag) { if (copy_special(curr->fts_statp, !dne)) badcp = rval = 1; } else { @@ -462,10 +468,10 @@ break; case S_IFSOCK: warnx("%s is a socket (not copied).", - curr->fts_path); + curr->fts_path); break; case S_IFIFO: - if (Rflag) { + if (Rflag && !sflag) { if (copy_fifo(curr->fts_statp, !dne)) badcp = rval = 1; } else { Modified: soc2015/clord/head/bin/cp/extern.h ============================================================================== --- soc2015/clord/head/bin/cp/extern.h Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/cp/extern.h Tue Jun 9 20:04:43 2015 (r286868) @@ -37,7 +37,7 @@ } PATH_T; extern PATH_T to; -extern int fflag, iflag, lflag, nflag, pflag, vflag; +extern int fflag, iflag, lflag, nflag, pflag, sflag, vflag; extern volatile sig_atomic_t info; __BEGIN_DECLS Modified: soc2015/clord/head/bin/cp/utils.c ============================================================================== --- soc2015/clord/head/bin/cp/utils.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/cp/utils.c Tue Jun 9 20:04:43 2015 (r286868) @@ -57,15 +57,19 @@ #define cp_pct(x, y) ((y == 0) ? 0 : (int)(100.0 * (x) / (y))) -/* Memory strategy threshold, in pages: if physmem is larger then this, use a - * large buffer */ +/* + * Memory strategy threshold, in pages: if physmem is larger then this, use a + * large buffer. + */ #define PHYSPAGES_THRESHOLD (32*1024) -/* Maximum buffer size in bytes - do not allow it to grow larger than this */ +/* Maximum buffer size in bytes - do not allow it to grow larger than this. */ #define BUFSIZE_MAX (2*1024*1024) -/* Small (default) buffer size in bytes. It's inefficient for this to be - * smaller than MAXPHYS */ +/* + * Small (default) buffer size in bytes. It's inefficient for this to be + * smaller than MAXPHYS. + */ #define BUFSIZE_SMALL (MAXPHYS) int @@ -77,13 +81,15 @@ ssize_t wcount; size_t wresid; off_t wtotal; - int ch, checkch, from_fd = 0, rcount, rval, to_fd = 0; + int ch, checkch, from_fd, rcount, rval, to_fd; char *bufp; #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED char *p; #endif - if ((from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) { + from_fd = to_fd = -1; + if (!lflag && !sflag && + (from_fd = open(entp->fts_path, O_RDONLY, 0)) == -1) { warn("%s", entp->fts_path); return (1); } @@ -103,63 +109,65 @@ if (nflag) { if (vflag) printf("%s not overwritten\n", to.p_path); - (void)close(from_fd); - return (1); + rval = 1; + goto done; } else if (iflag) { (void)fprintf(stderr, "overwrite %s? %s", - to.p_path, YESNO); + to.p_path, YESNO); checkch = ch = getchar(); while (ch != '\n' && ch != EOF) ch = getchar(); if (checkch != 'y' && checkch != 'Y') { - (void)close(from_fd); (void)fprintf(stderr, "not overwritten\n"); - return (1); + rval = 1; + goto done; } } - + if (fflag) { - /* remove existing destination file name, - * create a new file */ - (void)unlink(to.p_path); - if (!lflag) - to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, - fs->st_mode & ~(S_ISUID | S_ISGID)); - } else { - if (!lflag) - /* overwrite existing destination file name */ - to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0); + /* + * Remove existing destination file name create a new + * file. + */ + (void)unlink(to.p_path); + if (!lflag && !sflag) { + to_fd = open(to.p_path, + O_WRONLY | O_TRUNC | O_CREAT, + fs->st_mode & ~(S_ISUID | S_ISGID)); + } + } else if (!lflag && !sflag) { + /* Overwrite existing destination file name. */ + to_fd = open(to.p_path, O_WRONLY | O_TRUNC, 0); } - } else { - if (!lflag) - to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, - fs->st_mode & ~(S_ISUID | S_ISGID)); + } else if (!lflag && !sflag) { + to_fd = open(to.p_path, O_WRONLY | O_TRUNC | O_CREAT, + fs->st_mode & ~(S_ISUID | S_ISGID)); } - - if (to_fd == -1) { + + if (!lflag && !sflag && to_fd == -1) { warn("%s", to.p_path); - (void)close(from_fd); - return (1); + rval = 1; + goto done; } rval = 0; - if (!lflag) { + if (!lflag && !sflag) { /* - * Mmap and write if less than 8M (the limit is so we don't totally - * trash memory on big files. This is really a minor hack, but it - * wins some CPU back. + * Mmap and write if less than 8M (the limit is so we don't + * totally trash memory on big files. This is really a minor + * hack, but it wins some CPU back. * Some filesystems, such as smbnetfs, don't support mmap, * so this is a best-effort attempt. */ #ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED if (S_ISREG(fs->st_mode) && fs->st_size > 0 && - fs->st_size <= 8 * 1024 * 1024 && + fs->st_size <= 8 * 1024 * 1024 && (p = mmap(NULL, (size_t)fs->st_size, PROT_READ, MAP_SHARED, from_fd, (off_t)0)) != MAP_FAILED) { wtotal = 0; for (bufp = p, wresid = fs->st_size; ; - bufp += wcount, wresid -= (size_t)wcount) { + bufp += wcount, wresid -= (size_t)wcount) { wcount = write(to_fd, bufp, wresid); if (wcount <= 0) break; @@ -204,7 +212,7 @@ wtotal = 0; while ((rcount = read(from_fd, buf, bufsize)) > 0) { for (bufp = buf, wresid = rcount; ; - bufp += wcount, wresid -= wcount) { + bufp += wcount, wresid -= wcount) { wcount = write(to_fd, bufp, wresid); if (wcount <= 0) break; @@ -230,13 +238,18 @@ rval = 1; } } - } else { + } else if (lflag) { if (link(entp->fts_path, to.p_path)) { warn("%s", to.p_path); rval = 1; } + } else if (sflag) { + if (symlink(entp->fts_path, to.p_path)) { + warn("%s", to.p_path); + rval = 1; + } } - + /* * Don't remove the target even after an error. The target might * not be a regular file, or its attributes might be important, @@ -244,7 +257,7 @@ * to remove it if we created it and its length is 0. */ - if (!lflag) { + if (!lflag && !sflag) { if (pflag && setfile(fs, to_fd)) rval = 1; if (pflag && preserve_fd_acls(from_fd, to_fd) != 0) @@ -255,8 +268,9 @@ } } - (void)close(from_fd); - +done: + if (from_fd != -1) + (void)close(from_fd); return (rval); } @@ -338,7 +352,7 @@ fdval = fd != -1; islink = !fdval && S_ISLNK(fs->st_mode); fs->st_mode &= S_ISUID | S_ISGID | S_ISVTX | - S_IRWXU | S_IRWXG | S_IRWXO; + S_IRWXU | S_IRWXG | S_IRWXO; tspec[0] = fs->st_atim; tspec[1] = fs->st_mtim; @@ -353,7 +367,7 @@ else { gotstat = 1; ts.st_mode &= S_ISUID | S_ISGID | S_ISVTX | - S_IRWXU | S_IRWXG | S_IRWXO; + S_IRWXU | S_IRWXG | S_IRWXO; } /* * Changing the ownership probably won't succeed, unless we're root @@ -477,7 +491,7 @@ return (0); /* - * If the file is a link we will not follow it + * If the file is a link we will not follow it. */ if (S_ISLNK(fs->st_mode)) { aclgetf = acl_get_link_np; @@ -536,8 +550,10 @@ { (void)fprintf(stderr, "%s\n%s\n", -"usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file target_file", -" cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpvx] source_file ... " -"target_directory"); + "usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpsvx] " + "source_file target_file", + " cp [-R [-H | -L | -P]] [-f | -i | -n] [-alpsvx] " + "source_file ... " + "target_directory"); exit(EX_USAGE); } Modified: soc2015/clord/head/bin/ls/ls.c ============================================================================== --- soc2015/clord/head/bin/ls/ls.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/bin/ls/ls.c Tue Jun 9 20:04:43 2015 (r286868) @@ -413,9 +413,14 @@ /* * If not -F, -P, -d or -l options, follow any symbolic links listed on - * the command line. + * the command line, unless in color mode in which case we need to + * distinguish file type for a symbolic link itself and its target. */ - if (!f_nofollow && !f_longform && !f_listdir && (!f_type || f_slash)) + if (!f_nofollow && !f_longform && !f_listdir && (!f_type || f_slash) +#ifdef COLORLS + && !f_color +#endif + ) fts_options |= FTS_COMFOLLOW; /* Modified: soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h ============================================================================== --- soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h Tue Jun 9 20:04:43 2015 (r286868) @@ -156,6 +156,21 @@ #define DT_DM_KERNEL 0x2 /* module is associated with a kernel object */ #define DT_DM_PRIMARY 0x4 /* module is a krtld primary kernel object */ +#ifdef __FreeBSD__ +/* + * A representation of a FreeBSD kernel module, used when checking module + * dependencies. This differs from dt_module_t, which refers to a KLD in the + * case of kernel probes. Since modules can be identified regardless of whether + * they've been compiled into the kernel, we use them to identify DTrace + * modules. + */ +typedef struct dt_kmodule { + struct dt_kmodule *dkm_next; /* hash table entry */ + char *dkm_name; /* string name of module */ + dt_module_t *dkm_module; /* corresponding KLD module */ +} dt_kmodule_t; +#endif + typedef struct dt_provmod { char *dp_name; /* name of provider module */ struct dt_provmod *dp_next; /* next module */ @@ -235,6 +250,9 @@ dt_idhash_t *dt_tls; /* hash table of thread-local identifiers */ dt_list_t dt_modlist; /* linked list of dt_module_t's */ dt_module_t **dt_mods; /* hash table of dt_module_t's */ +#ifdef __FreeBSD__ + dt_kmodule_t **dt_kmods; /* hash table of dt_kmodule_t's */ +#endif uint_t dt_modbuckets; /* number of module hash buckets */ uint_t dt_nmods; /* number of modules in hash and list */ dt_provmod_t *dt_provmod; /* linked list of provider modules */ Modified: soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c ============================================================================== --- soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c Tue Jun 9 20:04:43 2015 (r286868) @@ -37,6 +37,7 @@ #else #include #include +#include #include #endif @@ -542,6 +543,22 @@ return (ctfp ? ctf_getspecific(ctfp) : NULL); } +#ifdef __FreeBSD__ +dt_kmodule_t * +dt_kmodule_lookup(dtrace_hdl_t *dtp, const char *name) +{ + uint_t h = dt_strtab_hash(name, NULL) % dtp->dt_modbuckets; + dt_kmodule_t *dkmp; + + for (dkmp = dtp->dt_kmods[h]; dkmp != NULL; dkmp = dkmp->dkm_next) { + if (strcmp(dkmp->dkm_name, name) == 0) + return (dkmp); + } + + return (NULL); +} +#endif + static int dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp) { @@ -1124,6 +1141,12 @@ char fname[MAXPATHLEN]; struct stat64 st; int fd, err, bits; +#ifdef __FreeBSD__ + struct module_stat ms; + dt_kmodule_t *dkmp; + uint_t h; + int modid; +#endif dt_module_t *dmp; const char *s; @@ -1270,6 +1293,33 @@ if (dmp->dm_info.objfs_info_primary) dmp->dm_flags |= DT_DM_PRIMARY; +#ifdef __FreeBSD__ + ms.version = sizeof(ms); + for (modid = kldfirstmod(k_stat->id); modid > 0; + modid = modnext(modid)) { + if (modstat(modid, &ms) != 0) { + dt_dprintf("modstat failed for id %d in %s: %s\n", + modid, k_stat->name, strerror(errno)); + continue; + } + if (dt_kmodule_lookup(dtp, ms.name) != NULL) + continue; + + dkmp = malloc(sizeof (*dkmp)); + if (dkmp == NULL) { + dt_dprintf("failed to allocate memory\n"); + dt_module_destroy(dtp, dmp); + return; + } + + h = dt_strtab_hash(ms.name, NULL) % dtp->dt_modbuckets; + dkmp->dkm_next = dtp->dt_kmods[h]; + dkmp->dkm_name = strdup(ms.name); + dkmp->dkm_module = dmp; + dtp->dt_kmods[h] = dkmp; + } +#endif + dt_dprintf("opened %d-bit module %s (%s) [%d]\n", bits, dmp->dm_name, dmp->dm_file, dmp->dm_modid); } Modified: soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.h ============================================================================== --- soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.h Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.h Tue Jun 9 20:04:43 2015 (r286868) @@ -44,6 +44,10 @@ extern dt_module_t *dt_module_lookup_by_name(dtrace_hdl_t *, const char *); extern dt_module_t *dt_module_lookup_by_ctf(dtrace_hdl_t *, ctf_file_t *); +#ifdef __FreeBSD__ +extern dt_kmodule_t *dt_kmodule_lookup(dtrace_hdl_t *, const char *); +#endif + extern int dt_module_hasctf(dtrace_hdl_t *, dt_module_t *); extern ctf_file_t *dt_module_getctf(dtrace_hdl_t *, dt_module_t *); extern dt_ident_t *dt_module_extern(dtrace_hdl_t *, dt_module_t *, Modified: soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Tue Jun 9 20:04:43 2015 (r286868) @@ -1178,6 +1178,9 @@ #endif dtp->dt_modbuckets = _dtrace_strbuckets; dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *)); +#ifdef __FreeBSD__ + dtp->dt_kmods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *)); +#endif dtp->dt_provbuckets = _dtrace_strbuckets; dtp->dt_provs = calloc(dtp->dt_provbuckets, sizeof (dt_provider_t *)); dt_proc_hash_create(dtp); @@ -1199,6 +1202,7 @@ if (dtp->dt_mods == NULL || dtp->dt_provs == NULL || dtp->dt_procs == NULL || dtp->dt_ld_path == NULL || #ifdef __FreeBSD__ + dtp->dt_kmods == NULL || dtp->dt_objcopy_path == NULL || #endif dtp->dt_cpp_path == NULL || dtp->dt_cpp_argv == NULL) @@ -1621,6 +1625,10 @@ dtrace_prog_t *pgp; dt_xlator_t *dxp; dt_dirpath_t *dirp; +#ifdef __FreeBSD__ + dt_kmodule_t *dkm; + uint_t h; +#endif int i; if (dtp->dt_procs != NULL) @@ -1648,6 +1656,15 @@ if (dtp->dt_tls != NULL) dt_idhash_destroy(dtp->dt_tls); +#ifdef __FreeBSD__ + for (h = 0; h < dtp->dt_modbuckets; h++) + while ((dkm = dtp->dt_kmods[h]) != NULL) { + dtp->dt_kmods[h] = dkm->dkm_next; + free(dkm->dkm_name); + free(dkm); + } +#endif + while ((dmp = dt_list_next(&dtp->dt_modlist)) != NULL) dt_module_destroy(dtp, dmp); @@ -1697,6 +1714,9 @@ #endif free(dtp->dt_mods); +#ifdef __FreeBSD__ + free(dtp->dt_kmods); +#endif free(dtp->dt_provs); free(dtp); } Modified: soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c ============================================================================== --- soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c Tue Jun 9 20:04:43 2015 (r286868) @@ -278,6 +278,14 @@ } else if (strcmp(cnp->dn_string, "module") == 0) { dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string); found = mp != NULL && dt_module_getctf(dtp, mp) != NULL; +#ifdef __FreeBSD__ + if (!found) { + dt_kmodule_t *dkmp = dt_kmodule_lookup(dtp, + nnp->dn_string); + found = dkmp != NULL && + dt_module_getctf(dtp, dkmp->dkm_module) != NULL; + } +#endif } else if (strcmp(cnp->dn_string, "library") == 0) { if (yypcb->pcb_cflags & DTRACE_C_CTL) { assert(dtp->dt_filetag != NULL); Modified: soc2015/clord/head/contrib/dtc/checks.c ============================================================================== --- soc2015/clord/head/contrib/dtc/checks.c Tue Jun 9 19:41:16 2015 (r286867) +++ soc2015/clord/head/contrib/dtc/checks.c Tue Jun 9 20:04:43 2015 (r286868) @@ -624,11 +624,11 @@ if (!reg && !ranges) return; - if ((node->parent->addr_cells == -1)) + if (node->parent->addr_cells == -1) FAIL(c, "Relying on default #address-cells value for %s", node->fullpath); - if ((node->parent->size_cells == -1)) + if (node->parent->size_cells == -1) FAIL(c, "Relying on default #size-cells value for %s", node->fullpath); } Copied: soc2015/clord/head/contrib/top/top.local.hs (from r286867, mirror/FreeBSD/head/contrib/top/top.local.hs) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/clord/head/contrib/top/top.local.hs Tue Jun 9 20:04:43 2015 (r286868, copy of r286867, mirror/FreeBSD/head/contrib/top/top.local.hs) @@ -0,0 +1,68 @@ +/* + * Top - a top users display for Berkeley Unix + * + * Definitions for things that might vary between installations. + */ + +/* + * The space command forces an immediate update. Sometimes, on loaded + * systems, this update will take a significant period of time (because all + * the output is buffered). So, if the short-term load average is above + * "LoadMax", then top will put the cursor home immediately after the space + * is pressed before the next update is attempted. This serves as a visual + * acknowledgement of the command. On Suns, "LoadMax" will get multiplied by + * "FSCALE" before being compared to avenrun[0]. Therefore, "LoadMax" + * should always be specified as a floating point number. + */ +#ifndef LoadMax +#define LoadMax %LoadMax% +#endif + +/* + * "Table_size" defines the size of the hash tables used to map uid to + * username. The number of users in /etc/passwd CANNOT be greater than + * this number. If the error message "table overflow: too many users" + * is printed by top, then "Table_size" needs to be increased. Things will + * work best if the number is a prime number that is about twice the number + * of lines in /etc/passwd. + */ +#ifndef Table_size +#define Table_size %TableSize% +#endif + +/* + * "Nominal_TOPN" is used as the default TOPN when Default_TOPN is Infinity + * and the output is a dumb terminal. If we didn't do this, then + * installations who use a default TOPN of Infinity will get every + * process in the system when running top on a dumb terminal (or redirected + * to a file). Note that Nominal_TOPN is a default: it can still be + * overridden on the command line, even with the value "infinity". + */ +#ifndef Nominal_TOPN +#define Nominal_TOPN %NominalTopn% +#endif + +#ifndef Default_TOPN +#define Default_TOPN %topn% +#endif + +#ifndef Default_DELAY +#define Default_DELAY %delay% +#endif + +/* + * If the local system's getpwnam interface uses random access to retrieve + * a record (i.e.: 4.3 systems, Sun "yellow pages"), then defining + * RANDOM_PW will take advantage of that fact. If RANDOM_PW is defined, + * then getpwnam is used and the result is cached. If not, then getpwent + * is used to read and cache the password entries sequentially until the + * desired one is found. + * + * We initially set RANDOM_PW to something which is controllable by the + * Configure script. Then if its value is 0, we undef it. + */ + +#define RANDOM_PW %random% +#if RANDOM_PW == 0 +#undef RANDOM_PW +#endif Copied: soc2015/clord/head/contrib/top/top.xs (from r286867, mirror/FreeBSD/head/contrib/top/top.xs) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/clord/head/contrib/top/top.xs Tue Jun 9 20:04:43 2015 (r286868, copy of r286867, mirror/FreeBSD/head/contrib/top/top.xs) @@ -0,0 +1,448 @@ +.\" NOTE: changes to the manual page for "top" should be made in the +.\" file "top.X" and NOT in the file "top.1". +.\" $FreeBSD$ +.nr N %topn% +.nr D %delay% +.TH TOP 1 Local +.UC 4 +.SH NAME +top \- display and update information about the top cpu processes +.SH SYNOPSIS +.B top +[ +.B \-abCHIijnPqStuvz +] [ +.BI \-d count +] [ +.BI \-m io | cpu +] [ +.BI \-o field +] [ +.BI \-s time +] [ +.BI \-J jail +] [ +.BI \-U username +] [ +.I number +] +.SH DESCRIPTION +.\" This defines appropriate quote strings for nroff and troff +.ds lq \&" +.ds rq \&" +.if t .ds lq `` +.if t .ds rq '' +.\" Just in case these number registers aren't set yet... +.if \nN==0 .nr N 10 +.if \nD==0 .nr D 2 +.I Top +displays the top +.if !\nN==-1 \nN +processes on the system and periodically updates this information. +.if \nN==-1 \ +\{\ +If standard output is an intelligent terminal (see below) then +as many processes as will fit on the terminal screen are displayed +by default. Otherwise, a good number of them are shown (around 20). +.\} +Raw cpu percentage is used to rank the processes. If +.I number +is given, then the top +.I number +processes will be displayed instead of the default. +.PP +.I Top +makes a distinction between terminals that support advanced capabilities +and those that do not. This +distinction affects the choice of defaults for certain options. In the +remainder of this document, an \*(lqintelligent\*(rq terminal is one that +supports cursor addressing, clear screen, and clear to end of line. +Conversely, a \*(lqdumb\*(rq terminal is one that does not support such +features. If the output of +.I top +is redirected to a file, it acts as if it were being run on a dumb +terminal. +.SH OPTIONS +.TP +.B \-C +Toggle CPU display mode. +By default top displays the weighted CPU percentage in the WCPU column +(this is the same value that +.IR ps (1) +displays as CPU). +Each time +.B \-C +flag is passed it toggles between \*(lqraw cpu\*(rq mode +and \*(lqweighted cpu\*(rq mode, showing the \*(lqCPU\*(rq or +the \*(lqWCPU\*(rq column respectively. +.TP +.B \-S +Show system processes in the display. Normally, system processes such as +the pager and the swapper are not shown. This option makes them visible. +.TP +.B \-a +Display command names derived from the argv[] vector, rather than real +executable name. It's useful when you want to watch applications, that +puts their status information there. If the real name differs from argv[0], +it will be displayed in parenthesis. +.TP +.B \-b +Use \*(lqbatch\*(rq mode. In this mode, all input from the terminal is +ignored. Interrupt characters (such as ^C and ^\e) still have an effect. +This is the default on a dumb terminal, or when the output is not a terminal. +.TP +.B \-H +Display each thread for a multithreaded process individually. +By default a single summary line is displayed for each process. +.TP +.B \-i +Use \*(lqinteractive\*(rq mode. In this mode, any input is immediately +read for processing. See the section on \*(lqInteractive Mode\*(rq +for an explanation of +which keys perform what functions. After the command is processed, the +screen will immediately be updated, even if the command was not +understood. This mode is the default when standard output is an +intelligent terminal. +.TP +.B \-I +Do not display idle processes. +By default, top displays both active and idle processes. +.TP +.B \-j +Display the +.IR jail (8) +ID. +.TP +.B \-t +Do not display the +.I top +process. +.TP +.BI \-m display +Display either 'cpu' or 'io' statistics. Default is 'cpu'. +.TP +.B \-n +Use \*(lqnon-interactive\*(rq mode. This is identical to \*(lqbatch\*(rq +mode. +.TP +.B \-P +Display per-cpu CPU usage statistics. +.TP +.B \-q +Renice +.I top +to -20 so that it will run faster. This can be used when the system is +being very sluggish to improve the possibility of discovering the problem. +This option can only be used by root. +.TP +.B \-u +Do not take the time to map uid numbers to usernames. Normally, +.I top +will read as much of the file \*(lq/etc/passwd\*(rq as is necessary to map +all the user id numbers it encounters into login names. This option +disables all that, while possibly decreasing execution time. The uid +numbers are displayed instead of the names. +.TP +.B \-v +Write version number information to stderr then exit immediately. +No other processing takes place when this option is used. To see current +revision information while top is running, use the help command \*(lq?\*(rq. +.TP +.B \-z +Do not display the system idle process. +.TP +.BI \-d count +Show only +.I count +displays, then exit. A display is considered to be one update of the +screen. This option allows the user to select the number of displays he +wants to see before +.I top +automatically exits. For intelligent terminals, no upper limit +is set. The default is 1 for dumb terminals. +.TP +.BI \-s time +Set the delay between screen updates to +.I time +seconds. The default delay between updates is \nD seconds. +.TP +.BI \-o field +Sort the process display area on the specified field. The field name is +the name of the column as seen in the output, but in lower case. Likely +values are \*(lqcpu\*(rq, \*(lqsize\*(rq, \*(lqres\*(rq, and \*(lqtime\*(rq, +but may vary on different operating systems. Note that +not all operating systems support this option. +.TP +.BI \-J jail +Show only those processes owned by +.IR jail . +This may be either the +.B jid +or +.B name +of the jail. +Use +.B 0 +to limit to host processes. +Using this option implies the +.B \-j +flag. +.PP +.BI \-U username +Show only those processes owned by +.IR username . +This option currently only accepts usernames and will not understand +uid numbers. +.PP +Both +.I count +and +.I number +fields can be specified as \*(lqinfinite\*(rq, indicating that they can +stretch as far as possible. This is accomplished by using any proper +prefix of the keywords +\*(lqinfinity\*(rq, +\*(lqmaximum\*(rq, +or +\*(lqall\*(rq. +The default for +.I count +on an intelligent terminal is, in fact, +.BI infinity . +.PP +The environment variable +.B TOP +is examined for options before the command line is scanned. This enables *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Tue Jun 9 21:13:31 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 03478E05 for ; Tue, 9 Jun 2015 21:13:31 +0000 (UTC) (envelope-from clord@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 E4E14137C for ; Tue, 9 Jun 2015 21:13:30 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t59LDUV9091495 for ; Tue, 9 Jun 2015 21:13:30 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t59LDUQ8091180 for svn-soc-all@FreeBSD.org; Tue, 9 Jun 2015 21:13:30 GMT (envelope-from clord@FreeBSD.org) Date: Tue, 9 Jun 2015 21:13:30 GMT Message-Id: <201506092113.t59LDUQ8091180@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286869 - in soc2015/clord/head/sys/contrib/ficl: . doc softwords test 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.20 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, 09 Jun 2015 21:13:31 -0000 Author: clord Date: Tue Jun 9 21:13:30 2015 New Revision: 286869 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286869 Log: Merge ficl 3.0.3 from vendor tree Added: soc2015/clord/head/sys/contrib/ficl/ (props changed) - copied from r285382, mirror/FreeBSD/vendor/ficl/dist/ Deleted: soc2015/clord/head/sys/contrib/ficl/Makefile.linux soc2015/clord/head/sys/contrib/ficl/doc/ soc2015/clord/head/sys/contrib/ficl/ficl.dsp soc2015/clord/head/sys/contrib/ficl/ficl.dsw soc2015/clord/head/sys/contrib/ficl/softcore.c soc2015/clord/head/sys/contrib/ficl/softwords/makefile soc2015/clord/head/sys/contrib/ficl/softwords/oo.fr.bak soc2015/clord/head/sys/contrib/ficl/softwords/softcore.bat soc2015/clord/head/sys/contrib/ficl/softwords/softcore.pl soc2015/clord/head/sys/contrib/ficl/softwords/softcore.py soc2015/clord/head/sys/contrib/ficl/softwords/softcore.py.bat soc2015/clord/head/sys/contrib/ficl/softwords/win32.fr soc2015/clord/head/sys/contrib/ficl/sysdep.c soc2015/clord/head/sys/contrib/ficl/sysdep.h soc2015/clord/head/sys/contrib/ficl/test/ soc2015/clord/head/sys/contrib/ficl/win32.c From owner-svn-soc-all@FreeBSD.ORG Wed Jun 10 21:03:43 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB77FD2B for ; Wed, 10 Jun 2015 21:03:43 +0000 (UTC) (envelope-from roam@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 D9F5810D1 for ; Wed, 10 Jun 2015 21:03:43 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5AL3hWe004677 for ; Wed, 10 Jun 2015 21:03:43 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5AL3h6w004443 for svn-soc-all@FreeBSD.org; Wed, 10 Jun 2015 21:03:43 GMT (envelope-from roam@FreeBSD.org) Date: Wed, 10 Jun 2015 21:03:43 GMT Message-Id: <201506102103.t5AL3h6w004443@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286924 - soc2015/roam/ng_ayiya 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.20 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: Wed, 10 Jun 2015 21:03:44 -0000 Author: roam Date: Wed Jun 10 21:03:42 2015 New Revision: 286924 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286924 Log: Use the NG_* macros for member access. ObQuote: "Cause you can look but you can't touch" Modified: soc2015/roam/ng_ayiya/ng_ayiya.c Modified: soc2015/roam/ng_ayiya/ng_ayiya.c ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 20:43:07 2015 (r286923) +++ soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 21:03:42 2015 (r286924) @@ -109,13 +109,13 @@ "\t\"name\":\t\"%s\",\n" "\t\"has_secret\":\t%s,\n" "\t\"hooks\": {\n", - node->nd_ID, node->nd_name, + NG_NODE_ID(node), NG_NODE_NAME(node), priv->secrethash? "true": "false"); else sbuf_printf(sb, "Node [%x] %s\n" "Secret hash %sset\n", - node->nd_ID, node->nd_name, + NG_NODE_ID(node), NG_NODE_NAME(node), priv->secrethash? "": "not "); for (int idx = 0; idx < AYIYA_HOOK_LAST; idx++) { @@ -134,7 +134,7 @@ "\t\t\t\"type\":\t\"%s\"\n" "\t\t}%s\n", hname, NG_HOOK_NAME(hook), - peer->nd_ID, peer->nd_name, + NG_NODE_ID(peer), NG_NODE_NAME(peer), peer->nd_type->name, idx < AYIYA_HOOK_LAST - 1? ",": ""); else @@ -142,7 +142,7 @@ "Hook '%s' (%s) connected to node " "[%x] '%s' of type '%s'.\n", NG_HOOK_NAME(hook), hname, - peer->nd_ID, peer->nd_name, + NG_NODE_ID(peer), NG_NODE_NAME(peer), peer->nd_type->name); } else { if (json) From owner-svn-soc-all@FreeBSD.ORG Wed Jun 10 21:03:48 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 42E07D3D for ; Wed, 10 Jun 2015 21:03:48 +0000 (UTC) (envelope-from roam@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 24A3710D4 for ; Wed, 10 Jun 2015 21:03:48 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5AL3mPC005830 for ; Wed, 10 Jun 2015 21:03:48 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5AL3lNM005472 for svn-soc-all@FreeBSD.org; Wed, 10 Jun 2015 21:03:47 GMT (envelope-from roam@FreeBSD.org) Date: Wed, 10 Jun 2015 21:03:47 GMT Message-Id: <201506102103.t5AL3lNM005472@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286925 - soc2015/roam/ng_ayiya 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.20 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: Wed, 10 Jun 2015 21:03:48 -0000 Author: roam Date: Wed Jun 10 21:03:46 2015 New Revision: 286925 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286925 Log: Configure the ng_iface inet6 address. Use the tools from the brand-new Net-SixXS Perl distribution to parse the tunnel information obtained from TIC. Create a ng_iface node, connect to its "inet6" hook, and configure the local IPv6 address on it. That was the easy part :) ObQuote: "It's so easy when everybody tries to please me" Modified: soc2015/roam/ng_ayiya/Makefile soc2015/roam/ng_ayiya/scaffold.pl Modified: soc2015/roam/ng_ayiya/Makefile ============================================================================== --- soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:42 2015 (r286924) +++ soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:46 2015 (r286925) @@ -35,6 +35,8 @@ SCAFFOLD_V?= -v SCAFFOLD?= ${SUDO} ${PERL} ${SCAFFOLD_PL} ${SCAFFOLD_V} +TIC_TUNNEL?= T22928 + up: ${SCAFFOLD} setup @@ -43,3 +45,11 @@ down-all: ${SCAFFOLD} shutdown all + +tic-tunnels.txt: + @printf "\n\n======================\n\nPlease create the tic-tunnels.txt with the output of the sixxs-tic-tunnels tool\n\n======================\n\n" + false + +tic: tic-tunnels.txt + ${SCAFFOLD} inet6 ${TIC_TUNNEL} + ${SCAFFOLD} ayiya Modified: soc2015/roam/ng_ayiya/scaffold.pl ============================================================================== --- soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:42 2015 (r286924) +++ soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:46 2015 (r286925) @@ -30,6 +30,7 @@ use Getopt::Std; use JSON::PP; +use Net::SixXS::Data::Tunnel; use POSIX qw/:sys_wait_h/; my $debug = 0; @@ -44,17 +45,20 @@ sub ngctl($ @); sub run_command(@); sub check_wait_result($ $ $); +sub get_tic_tunnel($); sub cmd_help($ @); sub cmd_setup($ @); sub cmd_shutdown($ @); sub cmd_status($ @); sub cmd_version($ @); +sub cmd_inet6($ @); my %cmds = ( build => \&cmd_setup, erect => \&cmd_setup, help => \&cmd_help, + inet6 => \&cmd_inet6, setup => \&cmd_setup, shutdown => \&cmd_shutdown, teardown => \&cmd_shutdown, @@ -88,6 +92,7 @@ my ($err) = @_; my $s = < $nodes->{type}{ayiya}, + all => $nodes->{type}{ayiya} // [], + ours => undef, + others => [], }; - my $node; - my @ay = @{$res->{all} // []}; - debug "Got ".scalar(@ay)." AYIYA node(s), looking for ours..."; - for(my $i = 0; $i < @ay; $i++) { - if ($ay[$i]->{name} eq 'sc_ayiya') { - debug "- found it at position $i"; - ($node) = splice @ay, $i, 1; - last; - } - } - $res->{ours} = $node; - $res->{others} = \@ay; - - if (defined $node) { - my $js = ngctl 'config', "$node->{name}:"; + my $nm = 'sc_ayiya'; + debug "Got ".scalar(@{$res->{all}})." AYIYA node(s), looking for $nm"; + for my $node (@{$res->{all}}) { + my $name = "[$node->{id}] '$node->{name}'"; + my $js = ngctl 'config', "[$node->{id}]:"; $js =~ s/\A[^{]*//s; - debug "- got ".length($js)." characters of JSON"; - my $d = decode_json $js; - if (!defined($d) || ref $d ne 'HASH' || + debug "- got ".length($js)." characters of JSON for node $name"; + my $d; + eval { + $d = decode_json $js; + }; + my $err = $@; + if (length ($err // '') || !defined($d) || ref $d ne 'HASH' || grep !exists $d->{$_}, qw/id name has_secret hooks/) { - die "Node [$node->{id}] '$node->{name}' returned ". + warn "Node [$node->{id}] '$node->{name}' returned ". "an invalid JSON configuration\n"; + next; + } + $node->{config} = $d; + if ($node->{name} eq $nm) { + if (defined $res->{ours}) { + die "Inconsistent Netgraph configuration: ". + "duplicate name '$nm' for nodes ". + "[$res->{ours}->{id}] and [$node->{id}]\n"; + } + $res->{ours} = $node; + debug " - ours!"; + } else { + push @{$res->{others}}, $node; } - debug "- got keys: ".join(' ', sort keys %{$d}); } return $res; } @@ -356,3 +369,73 @@ } return $output; } + +sub cmd_inet6($ @) +{ + my ($cmd, @args) = @_; + + if (@args != 1) { + warn "The inet6 command expects a tunnel name parameter\n"; + usage 1; + } + my $tunnel = shift @args; + + my $t = get_tic_tunnel $tunnel; + my $ayiya = get_ayiya; + + if (!$ayiya->{ours}) { + die "Our ng_ayiya node is not configured\n"; + } + # Tear down the interface if it's configured + my $c = $ayiya->{ours}->{config}; + my $i6 = $c->{hooks}->{inet6}; + if (defined $i6) { + debug "Shutting down the current interface"; + ngctl 'shutdown', "[$i6->{id}]:"; + } + + # OK, let's create one + my $hkname = "inet6/$tunnel"; + ngctl 'mkpeer', "$c->{name}:", 'iface', $hkname, 'inet6'; + $ayiya = get_ayiya; + my $iface = $ayiya->{ours}->{config}->{hooks}->{inet6}->{name}; + if (!defined $iface) { + die "Could not query the newly-created ng_iface node\n"; + } + + run_command 'ifconfig', $iface, 'inet6', $t->ipv6_local; + # FIXME: Add a default route here, too. +} + +sub get_tic_tunnel($) +{ + my ($tunnel) = @_; + + my $fname = 'tic-tunnels.txt'; + open my $f, '<', $fname or + die "Could not open $fname: $!\n"; + my $in; + my %cfg; + while (<$f>) { + s/[\r\n]*$//; + if ($in) { + last unless /^\s+(\S[^:]+?)\s*:\s*(.*?)\s*$/; + my ($k, $v) = ($1, $2); + if (exists $cfg{$k}) { + die "Duplicate key $k for $tunnel in $fname\n"; + } + $cfg{$k} = $v; + } elsif ($_ eq $tunnel) { + $in = 1; + } + } + close $f or die "Could not close $fname: $!\n"; + if (!%cfg) { + if ($in) { + die "No key/value lines for $tunnel in $fname\n"; + } else { + die "No tunnel $tunnel defined in $fname\n"; + } + } + return Net::SixXS::Data::Tunnel->from_hash(\%cfg); +} From owner-svn-soc-all@FreeBSD.ORG Wed Jun 10 21:03:53 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 40617D50 for ; Wed, 10 Jun 2015 21:03:53 +0000 (UTC) (envelope-from roam@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 2EB8910D6 for ; Wed, 10 Jun 2015 21:03:53 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5AL3rgt006721 for ; Wed, 10 Jun 2015 21:03:53 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5AL3pho006621 for svn-soc-all@FreeBSD.org; Wed, 10 Jun 2015 21:03:51 GMT (envelope-from roam@FreeBSD.org) Date: Wed, 10 Jun 2015 21:03:51 GMT Message-Id: <201506102103.t5AL3pho006621@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286926 - soc2015/roam/ng_ayiya 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.20 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: Wed, 10 Jun 2015 21:03:53 -0000 Author: roam Date: Wed Jun 10 21:03:50 2015 New Revision: 286926 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286926 Log: Add the "secrethash" control message. ObQuote: "I've known a secret for a week or two" Modified: soc2015/roam/ng_ayiya/Makefile soc2015/roam/ng_ayiya/ng_ayiya.c soc2015/roam/ng_ayiya/ng_ayiya.h soc2015/roam/ng_ayiya/scaffold.pl Modified: soc2015/roam/ng_ayiya/Makefile ============================================================================== --- soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/Makefile Wed Jun 10 21:03:50 2015 (r286926) @@ -50,6 +50,6 @@ @printf "\n\n======================\n\nPlease create the tic-tunnels.txt with the output of the sixxs-tic-tunnels tool\n\n======================\n\n" false -tic: tic-tunnels.txt +tic: tic-tunnels.txt up ${SCAFFOLD} inet6 ${TIC_TUNNEL} ${SCAFFOLD} ayiya Modified: soc2015/roam/ng_ayiya/ng_ayiya.c ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/ng_ayiya.c Wed Jun 10 21:03:50 2015 (r286926) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include "ng_ayiya.h" @@ -48,6 +49,24 @@ static ng_disconnect_t ng_ayiya_disconnect; static ng_shutdown_t ng_ayiya_shutdown; +static ng_parse_array_getLength_t ng_ayiya_secrethash_getLength; + +static const struct ng_parse_type ng_ayiya_secrethash_type = { + &ng_parse_bytearray_type, + &ng_ayiya_secrethash_getLength, +}; + +static const struct ng_cmdlist ng_ayiya_cmds[] = { + { + NGM_AYIYA_COOKIE, + NGM_AYIYA_SECRETHASH, + "secrethash", + &ng_ayiya_secrethash_type, + NULL, + }, + { 0 } +}; + static struct ng_type typestruct = { .version = NG_ABI_VERSION, .name = NG_AYIYA_NODE_TYPE, @@ -57,6 +76,7 @@ .newhook = ng_ayiya_newhook, .disconnect = ng_ayiya_disconnect, .shutdown = ng_ayiya_shutdown, + .cmdlist = ng_ayiya_cmds, }; NETGRAPH_INIT(ayiya, &typestruct); @@ -80,7 +100,7 @@ struct ng_ayiya_private { node_p node; - char * secrethash; + u_char secrethash[16]; hook_p hooks[AYIYA_HOOK_LAST]; }; typedef struct ng_ayiya_private *priv_p; @@ -196,6 +216,26 @@ } break; + case NGM_AYIYA_COOKIE: + switch (msg->header.cmd) { + case NGM_AYIYA_SECRETHASH: + { + const priv_p priv = NG_NODE_PRIVATE(node); + if (msg->header.arglen != sizeof(priv->secrethash)) { + error = EINVAL; + break; + } + bcopy(msg->data, priv->secrethash, + sizeof(priv->secrethash)); + } + break; + + default: + error = EINVAL; + break; + } + break; + default: error = EINVAL; break; @@ -259,3 +299,10 @@ NG_NODE_UNREF(node); return (0); } + +static int +ng_ayiya_secrethash_getLength(const struct ng_parse_type * const type, + const u_char * const start, const u_char * const buf) +{ + return (sizeof(((const priv_p)NULL)->secrethash)); +} Modified: soc2015/roam/ng_ayiya/ng_ayiya.h ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.h Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/ng_ayiya.h Wed Jun 10 21:03:50 2015 (r286926) @@ -31,4 +31,8 @@ #define NG_AYIYA_NODE_TYPE "ayiya" #define NGM_AYIYA_COOKIE 1432823247 +enum { + NGM_AYIYA_SECRETHASH = 1, +}; + #endif Modified: soc2015/roam/ng_ayiya/scaffold.pl ============================================================================== --- soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:46 2015 (r286925) +++ soc2015/roam/ng_ayiya/scaffold.pl Wed Jun 10 21:03:50 2015 (r286926) @@ -179,6 +179,18 @@ # TODO: config, status, hooks, interfaces } +sub shutdown_node($) +{ + my ($node) = @_; + my $i6 = $node->{config}->{hooks}->{inet6}; + + if (defined $i6) { + ngctl 'shutdown', "[$i6->{id}]:"; + } + ngctl 'shutdown', "[$node->{id}]:"; + # TODO: the ksocket one, too +} + sub cmd_shutdown($ @) { my ($cmd, @args) = @_; @@ -194,7 +206,7 @@ my $ay = get_ayiya; if ($ay->{ours}) { debug "Shutting down our node $ay->{ours}->{id}"; - ngctl 'shutdown', "[$ay->{ours}->{id}]:"; + shutdown_node $ay->{ours}; } else { say "Our node not found"; } @@ -203,7 +215,7 @@ " other node(s)"; for (@{$ay->{others}}) { debug "- $_->{id}"; - ngctl 'shutdown', "[$_->{id}]:"; + shutdown_node $_; } } From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 00:24:32 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C3423A30 for ; Thu, 11 Jun 2015 00:24:32 +0000 (UTC) (envelope-from pratiksinghal@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 B0E4E124E for ; Thu, 11 Jun 2015 00:24:32 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5B0OWS7075895 for ; Thu, 11 Jun 2015 00:24:32 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5B0OWpj075879 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 00:24:32 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Thu, 11 Jun 2015 00:24:32 GMT Message-Id: <201506110024.t5B0OWpj075879@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286930 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 11 Jun 2015 00:24:32 -0000 Author: pratiksinghal Date: Thu Jun 11 00:24:31 2015 New Revision: 286930 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286930 Log: Corrected the handling of interrupts Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Wed Jun 10 22:39:10 2015 (r286929) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Thu Jun 11 00:24:31 2015 (r286930) @@ -228,6 +228,7 @@ static int a10_mmc_setup_dma(struct a10_mmc_softc* sc, device_t dev) { + sc->a10_dma_xfer_len = 0x2000 ; sc->a10_dma_ndesc = A10_MMC_NDESC ; sc->a10_dma_size = sizeof(struct a10_mmc_dma_desc)*(sc->a10_dma_ndesc) ; @@ -260,21 +261,16 @@ static int a10_mmc_prepare_dma(struct a10_mmc_softc* sc) { - device_printf(sc->a10_dev, "In the start of prepare dma\n") ; struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; struct mmc_command* cmd = sc->a10_req->cmd ; - device_printf(sc->a10_dev, "After the cmd part\n") ; int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; - device_printf(sc->a10_dev, "After the read part\n") ; bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; - device_printf(sc->a10_dev, "After the block before the for loop\n") ; bus_size_t off = 0 ; int desc, rem,seg ; - uint32_t val ; + uint32_t val; desc = 0 ; - device_printf(sc->a10_dev, "Before the starting of for loop\n") ; /* Pick a segment and program all the descriptors in the segment. */ for(seg = 0; seg < sc->a10_dma_cb_arg.nsegs ; seg++) { @@ -310,13 +306,11 @@ } } - device_printf(sc->a10_dev, "After the for loop in a10_prepare_dma\n") ; if(desc == sc->a10_dma_ndesc) { - device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer") ; + device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; return EIO ; } - device_printf(sc->a10_dev, "After the desc check\n") ; bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; @@ -341,7 +335,6 @@ A10_MMC_WRITE_4(sc, A10_MMC_DLBA,desc_paddr) ; A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A20) ; - device_printf(sc->a10_dev, "Done preparing for DMA\n") ; return (0) ; } @@ -526,38 +519,6 @@ return; } - if(sc->a10_use_dma == 1) { - if(idst) { - uint32_t comp = 0 ; - sc->a10_idst = idst ; - - if(idst & A10_MMC_IDMAC_ERROR) - sc->a10_req->cmd->error = EIO ; - if(!(idst & A10_MMC_IDMAC_COMPLETE)) - sc->a10_req->cmd->error = ETIMEDOUT ; - else - comp = 1 ; - - data = sc->a10_req->cmd->data ; - - if(data->flags&MMC_DATA_WRITE) - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; - else - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; - if(comp == 0) - a10_mmc_req_done(sc) ; - else - a10_mmc_req_ok(sc) ; - } - else - a10_mmc_req_done(sc) ; - - A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; - A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ; - A10_MMC_UNLOCK(sc) ; - return ; - } - if (rint & A10_MMC_INT_ERR_BIT) { device_printf(sc->a10_dev, "error rint: 0x%08X\n", rint); if (rint & A10_MMC_RESP_TIMEOUT) @@ -570,13 +531,50 @@ return; } + /* Do we have to return from here or continue afterwards ? */ + /* What is the DMA only, what is PIO only and what is common part ? */ + if(sc->a10_use_dma == 1) { + uint32_t comp = 0 ; + device_printf(sc->a10_dev, "IDST = %d\n", idst) ; + sc->a10_idst = idst ; + if(idst & A10_MMC_IDMAC_ERROR) { + device_printf(sc->a10_dev, "I/O error with DMA\n") ; + sc->a10_req->cmd->error = EIO ; + } + if(!(idst & A10_MMC_IDMAC_COMPLETE)) { + device_printf(sc->a10_dev, "Timeout error with DMA\n") ; + sc->a10_req->cmd->error = ETIMEDOUT ; + } + else + comp = 1 ; + + if(sc->a10_req->cmd->data != NULL) { + data = sc->a10_req->cmd->data ; + if(data->flags&MMC_DATA_WRITE) + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; + else + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; + } + + if(comp == 0) + a10_mmc_req_done(sc) ; + else { + device_printf(sc->a10_dev, "DMA transfer working!\n") ; + a10_mmc_req_ok(sc) ; + } + + } + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + sc->a10_intr |= rint; - data = sc->a10_req->cmd->data; - if (data != NULL && (rint & (A10_MMC_DATA_OVER | - A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) - a10_mmc_pio_transfer(sc, data); - if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) - a10_mmc_req_ok(sc); + if(sc->a10_use_dma == 0) { + data = sc->a10_req->cmd->data; + if (data != NULL && (rint & (A10_MMC_DATA_OVER | + A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) + a10_mmc_pio_transfer(sc, data); + if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) + a10_mmc_req_ok(sc); + } A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint); A10_MMC_UNLOCK(sc); @@ -591,13 +589,13 @@ uint32_t cmdreg; sc = device_get_softc(bus); - device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; A10_MMC_LOCK(sc); if (sc->a10_req) { A10_MMC_UNLOCK(sc); return (EBUSY); } sc->a10_req = req; + device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; cmd = req->cmd; cmdreg = A10_MMC_START; if (cmd->opcode == MMC_GO_IDLE_STATE) @@ -626,11 +624,16 @@ blksz = min(cmd->data->len, MMC_SECTOR_SIZE); A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz); A10_MMC_WRITE_4(sc, A10_MMC_BCNTR, cmd->data->len); - if(sc->a10_use_dma == 1) - a10_mmc_prepare_dma(sc) ; } A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); + + if(cmd->data != NULL ) { + if(sc->a10_use_dma == 1) { + a10_mmc_prepare_dma(sc) ; + } + } + A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, a10_mmc_timeout, sc); From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 01:28:03 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 211DA7D2 for ; Thu, 11 Jun 2015 01:28:03 +0000 (UTC) (envelope-from btw@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 0F66A11AC for ; Thu, 11 Jun 2015 01:28:03 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5B1S2qu080194 for ; Thu, 11 Jun 2015 01:28:02 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5B1S1Fp080169 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 01:28:01 GMT (envelope-from btw@FreeBSD.org) Date: Thu, 11 Jun 2015 01:28:01 GMT Message-Id: <201506110128.t5B1S1Fp080169@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286933 - soc2015/btw/head/usr.bin/netstat 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.20 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, 11 Jun 2015 01:28:03 -0000 Author: btw Date: Thu Jun 11 01:28:01 2015 New Revision: 286933 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286933 Log: Extend netstat(1) to report the statistics of ifring. Modified: soc2015/btw/head/usr.bin/netstat/if.c soc2015/btw/head/usr.bin/netstat/main.c soc2015/btw/head/usr.bin/netstat/netstat.h Modified: soc2015/btw/head/usr.bin/netstat/if.c ============================================================================== --- soc2015/btw/head/usr.bin/netstat/if.c Thu Jun 11 00:24:33 2015 (r286932) +++ soc2015/btw/head/usr.bin/netstat/if.c Thu Jun 11 01:28:01 2015 (r286933) @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -680,3 +681,87 @@ /* NOTREACHED */ } + +void +ring_stats(char *name) +{ + static int mib[] = { CTL_NET, + PF_LINK, + NETLINK_GENERIC, + IFMIB_IFDATA, + 0/* index */, + IFDATA_RINGINFO }; + size_t datalen = 0; + struct ifmibdata *data; + struct if_ring_data *ifrd; + struct xifrstat *ifrs; + int nrings, ncpus; + int ri, cpu, i; + + if ((mib[4] = if_nametoindex(name)) == 0) + xo_err(EX_DATAERR, "if_nametoindex(%s)", name); + + if (sysctl(mib, 6, NULL, &datalen, NULL, 0) < 0) + xo_err(EX_OSERR, "sysctl: net.link.generic.ifdata"); + + if ((data = malloc(datalen)) == NULL) + xo_err(EX_OSERR, "malloc %lu bytes", (u_long)datalen); + + if (sysctl(mib, 6, data, &datalen, NULL, 0) < 0) + xo_err(EX_OSERR, "sysctl: net.link.generic.ifdata"); + + ifrd = &data->ifmd_ring_data; + ifrs = ifrd->ifrd_stats; + + nrings = ifrd->ifrd_nrings; + ncpus = ifrd->ifrd_ncpus; + + xo_open_instance("interface"); + for (i = 27; i > 0; i--) + xo_emit("-"); + xo_emit(" {tk:name/%s} ", name); + for (i = 28 - (int)strlen(name); i > 0; i--) + xo_emit("-"); + xo_emit("\n"); + + xo_open_list("ring"); + for (ri = 0; ri < nrings; ri++) { + xo_open_instance("ring"); + xo_emit("\nring{tk:ring-id/%d}:\n", ri); + + xo_emit("{T:/%-8s} ", ""); + for (cpu = 0; cpu < ncpus; cpu++) { + char string[32]; + snprintf(string, sizeof(string), "cpu%d", cpu); + xo_emit("{T:/%12s}", string); + } + xo_emit("\n"); + +#define DUMP_LAYER(layer) \ +do { \ + xo_open_instance("layer"); \ + xo_emit("{tk:name/%-8s}:", #layer); \ + for (cpu = 0; cpu < ncpus; cpu++) { \ + char format[32]; \ + snprintf(format, sizeof(format), "{tk:cpu%d/%%12lu}", cpu);\ + xo_emit(format, ifrs[ri * ncpus + cpu].ifrs_##layer); \ + } \ + xo_emit("\n"); \ + xo_close_instance("layer"); \ +} while (0) + xo_open_list("layer"); + DUMP_LAYER(ifinput); + DUMP_LAYER(netisr); + DUMP_LAYER(ether); + DUMP_LAYER(ip); + DUMP_LAYER(ip6); + DUMP_LAYER(tcp); + DUMP_LAYER(udp); + xo_close_list("layer"); + xo_close_instance("ring"); + } + xo_close_list("ring"); + xo_close_instance("interface"); + + free(data); +} Modified: soc2015/btw/head/usr.bin/netstat/main.c ============================================================================== --- soc2015/btw/head/usr.bin/netstat/main.c Thu Jun 11 00:24:33 2015 (r286932) +++ soc2015/btw/head/usr.bin/netstat/main.c Thu Jun 11 01:28:01 2015 (r286933) @@ -545,7 +545,10 @@ #endif if (iflag && !sflag) { xo_open_container("statistics"); - intpr(interval, NULL, af); + if (Rflag) + intpr(interval, ring_stats, af); + else + intpr(interval, NULL, af); xo_close_container("statistics"); xo_finish(); exit(0); Modified: soc2015/btw/head/usr.bin/netstat/netstat.h ============================================================================== --- soc2015/btw/head/usr.bin/netstat/netstat.h Thu Jun 11 00:24:33 2015 (r286932) +++ soc2015/btw/head/usr.bin/netstat/netstat.h Thu Jun 11 01:28:01 2015 (r286933) @@ -157,3 +157,4 @@ void mroutepr(void); void mrt_stats(void); void bpf_stats(char *); +void ring_stats(char *); From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 02:41:46 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 478E2196 for ; Thu, 11 Jun 2015 02:41:46 +0000 (UTC) (envelope-from btw@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 3610915DE for ; Thu, 11 Jun 2015 02:41:46 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5B2fkBa002906 for ; Thu, 11 Jun 2015 02:41:46 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5B2fjEB002900 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 02:41:45 GMT (envelope-from btw@FreeBSD.org) Date: Thu, 11 Jun 2015 02:41:45 GMT Message-Id: <201506110241.t5B2fjEB002900@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286935 - soc2015/btw/head/sys/net 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.20 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, 11 Jun 2015 02:41:46 -0000 Author: btw Date: Thu Jun 11 02:41:45 2015 New Revision: 286935 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286935 Log: Convert lo(4) to use the per-ring counters. Modified: soc2015/btw/head/sys/net/if_loop.c Modified: soc2015/btw/head/sys/net/if_loop.c ============================================================================== --- soc2015/btw/head/sys/net/if_loop.c Thu Jun 11 01:22:27 2015 (r286934) +++ soc2015/btw/head/sys/net/if_loop.c Thu Jun 11 02:41:45 2015 (r286935) @@ -132,6 +132,7 @@ .ifat_drv = &lo_ifdrv, .ifat_dunit = unit, .ifat_mtu = LOMTU, + .ifat_nrings = 1, .ifat_flags = IFF_LOOPBACK | IFF_MULTICAST, .ifat_capabilities = IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6, .ifat_capenable = IFCAP_HWCSUM | IFCAP_HWCSUM_IPV6, @@ -206,12 +207,16 @@ { u_int32_t af; struct rtentry *rt = NULL; + ifring_t *ifrs; #ifdef MAC int error; #endif M_ASSERTPKTHDR(m); /* check if we have the packet header */ + ifrs = if_getsoftc(ifp, IF_RING); + m->m_pkthdr.ifring = ifrs[0]; + if (ro != NULL) rt = ro->ro_rt; #ifdef MAC From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 12:34:30 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8FFA6724 for ; Thu, 11 Jun 2015 12:34:30 +0000 (UTC) (envelope-from kczekirda@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 7E62D1D6C for ; Thu, 11 Jun 2015 12:34:30 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BCYUlU034650 for ; Thu, 11 Jun 2015 12:34:30 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BCYTSU033375 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 12:34:29 GMT (envelope-from kczekirda@FreeBSD.org) Date: Thu, 11 Jun 2015 12:34:29 GMT Message-Id: <201506111234.t5BCYTSU033375@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286941 - soc2015/kczekirda/ipxe 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.20 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, 11 Jun 2015 12:34:30 -0000 Author: kczekirda Date: Thu Jun 11 12:34:28 2015 New Revision: 286941 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286941 Log: I don't need bin/undionly.kkpxe Modified: soc2015/kczekirda/ipxe/Makefile soc2015/kczekirda/ipxe/pkg-plist Modified: soc2015/kczekirda/ipxe/Makefile ============================================================================== --- soc2015/kczekirda/ipxe/Makefile Thu Jun 11 04:41:54 2015 (r286940) +++ soc2015/kczekirda/ipxe/Makefile Thu Jun 11 12:34:28 2015 (r286941) @@ -182,7 +182,7 @@ MAKE_ARGS+= ARCH=i386 .endif -BINLIST= bin/undionly.kpxe bin/undionly.kkpxe bin/ipxe.iso bin/ipxe.usb +BINLIST= bin/undionly.kpxe bin/ipxe.iso bin/ipxe.usb ALL_TARGET?= ${BINLIST} Modified: soc2015/kczekirda/ipxe/pkg-plist ============================================================================== --- soc2015/kczekirda/ipxe/pkg-plist Thu Jun 11 04:41:54 2015 (r286940) +++ soc2015/kczekirda/ipxe/pkg-plist Thu Jun 11 12:34:28 2015 (r286941) @@ -1,6 +1,5 @@ %%DATADIR%%/VER %%DATADIR%%/ipxe.iso %%DATADIR%%/ipxe.usb -%%DATADIR%%/undionly.kkpxe %%DATADIR%%/undionly.kpxe From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 13:02:36 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A88CE1E5 for ; Thu, 11 Jun 2015 13:02:36 +0000 (UTC) (envelope-from btw@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 96EBC162A for ; Thu, 11 Jun 2015 13:02:36 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BD2a5W023312 for ; Thu, 11 Jun 2015 13:02:36 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BD2axW023307 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 13:02:36 GMT (envelope-from btw@FreeBSD.org) Date: Thu, 11 Jun 2015 13:02:36 GMT Message-Id: <201506111302.t5BD2axW023307@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286943 - soc2015/btw/head/sys/netinet6 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.20 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, 11 Jun 2015 13:02:36 -0000 Author: btw Date: Thu Jun 11 13:02:35 2015 New Revision: 286943 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286943 Log: Count the UDP packets over IPv6. Modified: soc2015/btw/head/sys/netinet6/udp6_usrreq.c Modified: soc2015/btw/head/sys/netinet6/udp6_usrreq.c ============================================================================== --- soc2015/btw/head/sys/netinet6/udp6_usrreq.c Thu Jun 11 12:47:13 2015 (r286942) +++ soc2015/btw/head/sys/netinet6/udp6_usrreq.c Thu Jun 11 13:02:35 2015 (r286943) @@ -219,6 +219,7 @@ #endif UDPSTAT_INC(udps_ipackets); + IFRSTAT_INC(m, ifrs_udp); /* * Destination port of 0 is illegal, based on RFC768. From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 13:18:12 2015 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 03EBEA00 for ; Thu, 11 Jun 2015 13:18:12 +0000 (UTC) (envelope-from btw@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 E60B6194E for ; Thu, 11 Jun 2015 13:18:11 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BDIBiT039878 for ; Thu, 11 Jun 2015 13:18:11 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BDIBqC039863 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 13:18:11 GMT (envelope-from btw@FreeBSD.org) Date: Thu, 11 Jun 2015 13:18:11 GMT Message-Id: <201506111318.t5BDIBqC039863@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286944 - soc2015/btw/head/tools/tools/mq-testing/vme 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.20 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, 11 Jun 2015 13:18:12 -0000 Author: btw Date: Thu Jun 11 13:18:10 2015 New Revision: 286944 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286944 Log: Set the checksum offload flags for each packet injected by user. Modified: soc2015/btw/head/tools/tools/mq-testing/vme/if_vme.c Modified: soc2015/btw/head/tools/tools/mq-testing/vme/if_vme.c ============================================================================== --- soc2015/btw/head/tools/tools/mq-testing/vme/if_vme.c Thu Jun 11 13:02:35 2015 (r286943) +++ soc2015/btw/head/tools/tools/mq-testing/vme/if_vme.c Thu Jun 11 13:18:10 2015 (r286944) @@ -93,6 +93,10 @@ #define PRIV_NET_VME PRIV_NET_TAP +#define VME_CSUM_SET (CSUM_IP_CHECKED | CSUM_IP_VALID | \ + CSUM_DATA_VALID | CSUM_DATA_VALID_IPV6 | \ + CSUM_PSEUDO_HDR) + /* module */ static int vmemodevent(module_t, int, void *); @@ -914,6 +918,8 @@ } m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.csum_data = 0xffff; + m->m_pkthdr.csum_flags = VME_CSUM_SET; /* * Only pass a unicast frame to ether_input(), if it would actually From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 20:00:52 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7B51966F for ; Thu, 11 Jun 2015 20:00:52 +0000 (UTC) (envelope-from kczekirda@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 69F8017E9 for ; Thu, 11 Jun 2015 20:00:52 +0000 (UTC) (envelope-from kczekirda@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BK0qnX015998 for ; Thu, 11 Jun 2015 20:00:52 GMT (envelope-from kczekirda@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BK0poQ015654 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 20:00:51 GMT (envelope-from kczekirda@FreeBSD.org) Date: Thu, 11 Jun 2015 20:00:51 GMT Message-Id: <201506112000.t5BK0poQ015654@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to kczekirda@FreeBSD.org using -f From: kczekirda@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286974 - soc2015/kczekirda/ipxe 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.20 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, 11 Jun 2015 20:00:52 -0000 Author: kczekirda Date: Thu Jun 11 20:00:51 2015 New Revision: 286974 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286974 Log: default options Modified: soc2015/kczekirda/ipxe/Makefile Modified: soc2015/kczekirda/ipxe/Makefile ============================================================================== --- soc2015/kczekirda/ipxe/Makefile Thu Jun 11 20:00:40 2015 (r286973) +++ soc2015/kczekirda/ipxe/Makefile Thu Jun 11 20:00:51 2015 (r286974) @@ -51,10 +51,6 @@ CON_SYSLOG CON_SYSLOGS CON_VMWARE CON_DEBUGCON CON_VESAFB \ CON_INT13 - -#OPTIONS_DEFAULT= VMXNET3 TIME_CMD IMGTRUST_CMD VLAN_CMD \ -# DOWNLOAD_PROTO_FTP IMAGE_COMBOOT - #DEBUG_DESC= with DEBUG=$$DEBUG e.g =dhcp,tcp #VIRTUALBOX_DESC= build VirtualBox PXE-ROM images #VMXNET3_DESC= build vmxnet3 ROM @@ -176,6 +172,22 @@ CON_VESAFB_DESC= VESA framebuffer console CON_INT13_DESC= INT13 disk log console +OPTIONS_DEFAULT= NET_PROTO_IPV4 \ + PXE_STACK PXE_MENU \ + DOWNLOAD_PROTO_TFTP DOWNLOAD_PROTO_HTTP \ + SANBOOT_PROTO_ISCSI SANBOOT_PROTO_AOE SANBOOT_PROTO_IB_SRP \ + SANBOOT_PROTO_FCP \ + CRYPTO_80211_WEP CRYPTO_80211_WPA CRYPTO_80211_WPA2 \ + DNS_RESOLVER \ + IMAGE_NBI IMAGE_ELF IMAGE_MULTIBOOT IMAGE_PXE \ + IMAGE_SCRIPT IMAGE_BZIMAGE IMAGE_COMBOOT IMAGE_EFI \ + IMAGE_SDI IMAGE_PNM IMAGE_PNG \ + CMD_AUTOBOOT CMD_NVO CMD_CONFIG CMD_IFMGMT CMD_IWMGMT \ + CMD_FCMGMT CMD_ROUTE CMD_IMAGE CMD_DHCP CMD_SANBOOT \ + CMD_MENU CMD_LOGIN CMD_SYNC \ + CONF_PCI_SETTINGS \ + USB_HCD_XHCI USB_HCD_EHCI USB_HCD_UHCI USB_KEYBOARD + .include .if ${ARCH} == "amd64" From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 22:14:13 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 81C81294 for ; Thu, 11 Jun 2015 22:14:13 +0000 (UTC) (envelope-from clord@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 6DD711B0F for ; Thu, 11 Jun 2015 22:14:13 +0000 (UTC) (envelope-from clord@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BMEDmq091506 for ; Thu, 11 Jun 2015 22:14:13 GMT (envelope-from clord@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BMEAuL091452 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 22:14:10 GMT (envelope-from clord@FreeBSD.org) Date: Thu, 11 Jun 2015 22:14:10 GMT Message-Id: <201506112214.t5BMEAuL091452@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to clord@FreeBSD.org using -f From: clord@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286978 - in soc2015/clord/head/sys/contrib/ficl: . aarch64 amd64 arm i386 mips mips64 powerpc softwords sparc64 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.20 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, 11 Jun 2015 22:14:13 -0000 Author: clord Date: Thu Jun 11 22:14:09 2015 New Revision: 286978 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286978 Log: Add FreeBSD ficl customizations back into vendor code Added: soc2015/clord/head/sys/contrib/ficl/aarch64/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/aarch64/ soc2015/clord/head/sys/contrib/ficl/amd64/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/amd64/ soc2015/clord/head/sys/contrib/ficl/arm/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/arm/ soc2015/clord/head/sys/contrib/ficl/i386/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/i386/ soc2015/clord/head/sys/contrib/ficl/loader.c - copied unchanged from r286905, soc2015/clord/head/sys/boot/ficl/loader.c soc2015/clord/head/sys/contrib/ficl/mips/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/mips/ soc2015/clord/head/sys/contrib/ficl/mips64/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/mips64/ soc2015/clord/head/sys/contrib/ficl/powerpc/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/powerpc/ soc2015/clord/head/sys/contrib/ficl/sparc64/ - copied from r286905, soc2015/clord/head/sys/boot/ficl/sparc64/ Modified: soc2015/clord/head/sys/contrib/ficl/dict.c soc2015/clord/head/sys/contrib/ficl/ficl.c soc2015/clord/head/sys/contrib/ficl/ficl.h soc2015/clord/head/sys/contrib/ficl/fileaccess.c soc2015/clord/head/sys/contrib/ficl/float.c soc2015/clord/head/sys/contrib/ficl/math64.c soc2015/clord/head/sys/contrib/ficl/math64.h soc2015/clord/head/sys/contrib/ficl/prefix.c soc2015/clord/head/sys/contrib/ficl/search.c soc2015/clord/head/sys/contrib/ficl/softwords/classes.fr soc2015/clord/head/sys/contrib/ficl/softwords/ficlclass.fr soc2015/clord/head/sys/contrib/ficl/softwords/ficllocal.fr soc2015/clord/head/sys/contrib/ficl/softwords/fileaccess.fr soc2015/clord/head/sys/contrib/ficl/softwords/forml.fr soc2015/clord/head/sys/contrib/ficl/softwords/ifbrack.fr soc2015/clord/head/sys/contrib/ficl/softwords/jhlocal.fr soc2015/clord/head/sys/contrib/ficl/softwords/marker.fr soc2015/clord/head/sys/contrib/ficl/softwords/oo.fr soc2015/clord/head/sys/contrib/ficl/softwords/prefix.fr soc2015/clord/head/sys/contrib/ficl/softwords/softcore.fr soc2015/clord/head/sys/contrib/ficl/softwords/string.fr soc2015/clord/head/sys/contrib/ficl/stack.c soc2015/clord/head/sys/contrib/ficl/testmain.c soc2015/clord/head/sys/contrib/ficl/tools.c soc2015/clord/head/sys/contrib/ficl/unix.c soc2015/clord/head/sys/contrib/ficl/vm.c soc2015/clord/head/sys/contrib/ficl/words.c Modified: soc2015/clord/head/sys/contrib/ficl/dict.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/dict.c Thu Jun 11 21:13:05 2015 (r286977) +++ soc2015/clord/head/sys/contrib/ficl/dict.c Thu Jun 11 22:14:09 2015 (r286978) @@ -3,7 +3,7 @@ ** Forth Inspired Command Language - dictionary methods ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 19 July 1997 -** $Id: dict.c,v 1.12 2001-10-28 10:59:22-08 jsadler Exp jsadler $ +** $Id: dict.c,v 1.14 2001/12/05 07:21:34 jsadler Exp $ *******************************************************************/ /* ** This file implements the dictionary -- FICL's model of @@ -51,12 +51,22 @@ ** SUCH DAMAGE. */ -#include -#include /* sprintf */ -#include +/* $FreeBSD$ */ + +#ifdef TESTMAIN +#include #include +#else +#include +#endif +#include #include "ficl.h" +/* Dictionary on-demand resizing control variables */ +CELL dictThreshold; +CELL dictIncrease; + + static char *dictCopyName(FICL_DICT *pDict, STRINGINFO si); /************************************************************************** @@ -378,11 +388,14 @@ FICL_DICT *pDict; size_t nAlloc; - nAlloc = sizeof (FICL_DICT) + nCells * sizeof (CELL) - + sizeof (FICL_HASH) + (nHash - 1) * sizeof (FICL_WORD *); + nAlloc = sizeof (FICL_HASH) + nCells * sizeof (CELL) + + (nHash - 1) * sizeof (FICL_WORD *); - pDict = ficlMalloc(nAlloc); + pDict = ficlMalloc(sizeof (FICL_DICT)); assert(pDict); + memset(pDict, 0, sizeof (FICL_DICT)); + pDict->dict = ficlMalloc(nAlloc); + assert(pDict->dict); pDict->size = nCells; dictEmpty(pDict, nHash); @@ -537,7 +550,6 @@ ); } - /************************************************************************** d i c t L o o k u p ** Find the FICL_WORD that matches the given name and length. @@ -833,4 +845,20 @@ return; } +/************************************************************************** + d i c t C h e c k T h r e s h o l d +** Verify if an increase in the dictionary size is warranted, and do it if +** so. +**************************************************************************/ + +void dictCheckThreshold(FICL_DICT* dp) +{ + if( dictCellsAvail(dp) < dictThreshold.u ) { + dp->dict = ficlMalloc( dictIncrease.u * sizeof (CELL) ); + assert(dp->dict); + dp->here = dp->dict; + dp->size = dictIncrease.u; + dictAlign(dp); + } +} Modified: soc2015/clord/head/sys/contrib/ficl/ficl.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/ficl.c Thu Jun 11 21:13:05 2015 (r286977) +++ soc2015/clord/head/sys/contrib/ficl/ficl.c Thu Jun 11 22:14:09 2015 (r286978) @@ -3,7 +3,7 @@ ** Forth Inspired Command Language - external interface ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 19 July 1997 -** $Id: ficl.c,v 1.17 2001-12-04 17:58:11-08 jsadler Exp jsadler $ +** $Id: ficl.c,v 1.16 2001/12/05 07:21:34 jsadler Exp $ *******************************************************************/ /* ** This is an ANS Forth interpreter written in C. @@ -55,7 +55,13 @@ ** SUCH DAMAGE. */ +/* $FreeBSD$ */ + +#ifdef TESTMAIN #include +#else +#include +#endif #include #include "ficl.h" @@ -407,8 +413,10 @@ case VM_OUTOFTEXT: vmPopIP(pVM); +#ifdef TESTMAIN if ((pVM->state != COMPILE) && (pVM->sourceID.i == 0)) ficlTextOut(pVM, FICL_PROMPT, 0); +#endif break; case VM_USEREXIT: @@ -681,10 +689,7 @@ **************************************************************************/ static void ficlSetVersionEnv(FICL_SYSTEM *pSys) { - int major = 0; - int minor = 0; - sscanf(FICL_VER, "%d.%d", &major, &minor); - ficlSetEnvD(pSys, "ficl-version", major, minor); + ficlSetEnvD(pSys, "ficl-version", FICL_VER_MAJOR, FICL_VER_MINOR); ficlSetEnv (pSys, "ficl-robust", FICL_ROBUST); return; } Modified: soc2015/clord/head/sys/contrib/ficl/ficl.h ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/ficl.h Thu Jun 11 21:13:05 2015 (r286977) +++ soc2015/clord/head/sys/contrib/ficl/ficl.h Thu Jun 11 22:14:09 2015 (r286978) @@ -4,7 +4,7 @@ ** Author: John Sadler (john_sadler@alum.mit.edu) ** Created: 19 July 1997 ** Dedicated to RHS, in loving memory -** $Id: ficl.h,v 1.19 2001-12-04 17:58:07-08 jsadler Exp jsadler $ +** $Id: ficl.h,v 1.18 2001/12/05 07:21:34 jsadler Exp $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) @@ -41,6 +41,8 @@ ** SUCH DAMAGE. */ +/* $FreeBSD$ */ + #if !defined (__FICL_H__) #define __FICL_H__ /* @@ -217,7 +219,6 @@ #include "sysdep.h" #include /* UCHAR_MAX */ -#include /* ** Forward declarations... read on. @@ -236,7 +237,9 @@ /* ** the Good Stuff starts here... */ -#define FICL_VER "3.03" +#define FICL_VER "3.03" +#define FICL_VER_MAJOR 3 +#define FICL_VER_MINOR 3 #if !defined (FICL_PROMPT) #define FICL_PROMPT "ok> " #endif @@ -732,7 +735,7 @@ FICL_HASH *pSearch[FICL_DEFAULT_VOCS]; int nLists; unsigned size; /* Number of cells in dict (total)*/ - CELL dict[1]; /* Base of dictionary memory */ + CELL *dict; /* Base of dictionary memory */ }; void *alignPtr(void *ptr); @@ -754,6 +757,7 @@ int dictCellsAvail (FICL_DICT *pDict); int dictCellsUsed (FICL_DICT *pDict); void dictCheck (FICL_DICT *pDict, FICL_VM *pVM, int n); +void dictCheckThreshold(FICL_DICT* dp); FICL_DICT *dictCreate(unsigned nCELLS); FICL_DICT *dictCreateHashed(unsigned nCells, unsigned nHash); FICL_HASH *dictCreateWordlist(FICL_DICT *dp, int nBuckets); @@ -969,6 +973,14 @@ int ficlExecXT(FICL_VM *pVM, FICL_WORD *pWord); /* +** ficlExecFD(FICL_VM *pVM, int fd); + * Evaluates text from file passed in via fd. + * Execution returns when all of file has been executed or an + * error occurs. + */ +int ficlExecFD(FICL_VM *pVM, int fd); + +/* ** Create a new VM from the heap, and link it into the system VM list. ** Initializes the VM and binds default sized stacks to it. Returns the ** address of the VM, or NULL if an error occurs. @@ -1091,7 +1103,33 @@ WORDKIND ficlWordClassify(FICL_WORD *pFW); +/* +** Dictionary on-demand resizing +*/ +extern CELL dictThreshold; +extern CELL dictIncrease; + +/* +** Various FreeBSD goodies +*/ + +#if defined(__i386__) && !defined(TESTMAIN) +extern void ficlOutb(FICL_VM *pVM); +extern void ficlInb(FICL_VM *pVM); +#endif +extern void ficlSetenv(FICL_VM *pVM); +extern void ficlSetenvq(FICL_VM *pVM); +extern void ficlGetenv(FICL_VM *pVM); +extern void ficlUnsetenv(FICL_VM *pVM); +extern void ficlCopyin(FICL_VM *pVM); +extern void ficlCopyout(FICL_VM *pVM); +extern void ficlFindfile(FICL_VM *pVM); +extern void ficlCcall(FICL_VM *pVM); +#if !defined(TESTMAIN) +extern void ficlPnpdevices(FICL_VM *pVM); +extern void ficlPnphandlers(FICL_VM *pVM); +#endif /* ** Used with File-Access wordset. @@ -1104,11 +1142,13 @@ #define FICL_FAM_OPEN_MODE(fam) ((fam) & (FICL_FAM_READ | FICL_FAM_WRITE | FICL_FAM_APPEND)) +#if (FICL_WANT_FILE) typedef struct ficlFILE { FILE *f; char filename[256]; } ficlFILE; +#endif #ifdef __cplusplus } Modified: soc2015/clord/head/sys/contrib/ficl/fileaccess.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/fileaccess.c Thu Jun 11 21:13:05 2015 (r286977) +++ soc2015/clord/head/sys/contrib/ficl/fileaccess.c Thu Jun 11 22:14:09 2015 (r286978) @@ -1,3 +1,5 @@ +/* $FreeBSD$ */ + #include #include #include @@ -418,6 +420,6 @@ ficlSetEnv(pSys, "file-ext", FICL_TRUE); #endif /* FICL_HAVE_FTRUNCATE */ #else - &pSys; + (void)pSys; #endif /* FICL_WANT_FILE */ } Modified: soc2015/clord/head/sys/contrib/ficl/float.c ============================================================================== --- soc2015/clord/head/sys/contrib/ficl/float.c Thu Jun 11 21:13:05 2015 (r286977) +++ soc2015/clord/head/sys/contrib/ficl/float.c Thu Jun 11 22:14:09 2015 (r286978) @@ -4,7 +4,7 @@ ** ANS Forth FLOAT word-set written in C ** Author: Guy Carver & John Sadler (john_sadler@alum.mit.edu) ** Created: Apr 2001 -** $Id: float.c,v 1.8 2001-12-04 17:58:16-08 jsadler Exp jsadler $ +** $Id: float.c,v 1.8 2001/12/05 07:21:34 jsadler Exp $ *******************************************************************/ /* ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) @@ -41,6 +41,8 @@ ** SUCH DAMAGE. */ +/* $FreeBSD$ */ + #include #include #include Copied: soc2015/clord/head/sys/contrib/ficl/loader.c (from r286905, soc2015/clord/head/sys/boot/ficl/loader.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2015/clord/head/sys/contrib/ficl/loader.c Thu Jun 11 22:14:09 2015 (r286978, copy of r286905, soc2015/clord/head/sys/boot/ficl/loader.c) @@ -0,0 +1,953 @@ +/*- + * Copyright (c) 2000 Daniel Capo Sobral + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +/******************************************************************* +** l o a d e r . c +** Additional FICL words designed for FreeBSD's loader +** +*******************************************************************/ + +#ifdef TESTMAIN +#include +#include +#include +#include +#include +#include +#include +#else +#include +#endif +#include "bootstrap.h" +#include +#include "ficl.h" + +/* FreeBSD's loader interaction words and extras + * + * setenv ( value n name n' -- ) + * setenv? ( value n name n' flag -- ) + * getenv ( addr n -- addr' n' | -1 ) + * unsetenv ( addr n -- ) + * copyin ( addr addr' len -- ) + * copyout ( addr addr' len -- ) + * findfile ( name len type len' -- addr ) + * pnpdevices ( -- addr ) + * pnphandlers ( -- addr ) + * ccall ( [[...[p10] p9] ... p1] n addr -- result ) + * .# ( value -- ) + */ + +void +ficlSetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name, *value; +#endif + char *namep, *valuep; + int names, values; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 4, 0); +#endif + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + values = stackPopINT(pVM->pStack); + valuep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (!name) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + value = (char*) ficlMalloc(values+1); + if (!value) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(value, valuep, values); + value[values] = '\0'; + + setenv(name, value, 1); + ficlFree(name); + ficlFree(value); +#endif + + return; +} + +void +ficlSetenvq(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name, *value; +#endif + char *namep, *valuep; + int names, values, overwrite; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 5, 0); +#endif + overwrite = stackPopINT(pVM->pStack); + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + values = stackPopINT(pVM->pStack); + valuep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (!name) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + value = (char*) ficlMalloc(values+1); + if (!value) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(value, valuep, values); + value[values] = '\0'; + + setenv(name, value, overwrite); + ficlFree(name); + ficlFree(value); +#endif + + return; +} + +void +ficlGetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name, *value; +#endif + char *namep; + int names; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 2, 2); +#endif + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (!name) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + + value = getenv(name); + ficlFree(name); + + if(value != NULL) { + stackPushPtr(pVM->pStack, value); + stackPushINT(pVM->pStack, strlen(value)); + } else +#endif + stackPushINT(pVM->pStack, -1); + + return; +} + +void +ficlUnsetenv(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name; +#endif + char *namep; + int names; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 2, 0); +#endif + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (!name) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + + unsetenv(name); + ficlFree(name); +#endif + + return; +} + +void +ficlCopyin(FICL_VM *pVM) +{ + void* src; + vm_offset_t dest; + size_t len; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 0); +#endif + + len = stackPopINT(pVM->pStack); + dest = stackPopINT(pVM->pStack); + src = stackPopPtr(pVM->pStack); + +#ifndef TESTMAIN + archsw.arch_copyin(src, dest, len); +#endif + + return; +} + +void +ficlCopyout(FICL_VM *pVM) +{ + void* dest; + vm_offset_t src; + size_t len; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 0); +#endif + + len = stackPopINT(pVM->pStack); + dest = stackPopPtr(pVM->pStack); + src = stackPopINT(pVM->pStack); + +#ifndef TESTMAIN + archsw.arch_copyout(src, dest, len); +#endif + + return; +} + +void +ficlFindfile(FICL_VM *pVM) +{ +#ifndef TESTMAIN + char *name, *type; +#endif + char *namep, *typep; + struct preloaded_file* fp; + int names, types; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 4, 1); +#endif + + types = stackPopINT(pVM->pStack); + typep = (char*) stackPopPtr(pVM->pStack); + names = stackPopINT(pVM->pStack); + namep = (char*) stackPopPtr(pVM->pStack); +#ifndef TESTMAIN + name = (char*) ficlMalloc(names+1); + if (!name) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(name, namep, names); + name[names] = '\0'; + type = (char*) ficlMalloc(types+1); + if (!type) + vmThrowErr(pVM, "Error: out of memory"); + strncpy(type, typep, types); + type[types] = '\0'; + + fp = file_findfile(name, type); +#else + fp = NULL; +#endif + stackPushPtr(pVM->pStack, fp); + + return; +} + +#ifndef TESTMAIN +#ifdef HAVE_PNP + +void +ficlPnpdevices(FICL_VM *pVM) +{ + static int pnp_devices_initted = 0; +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + if(!pnp_devices_initted) { + STAILQ_INIT(&pnp_devices); + pnp_devices_initted = 1; + } + + stackPushPtr(pVM->pStack, &pnp_devices); + + return; +} + +void +ficlPnphandlers(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + + stackPushPtr(pVM->pStack, pnphandlers); + + return; +} + +#endif + +#endif /* ndef TESTMAIN */ + +void +ficlCcall(FICL_VM *pVM) +{ + int (*func)(int, ...); + int result, p[10]; + int nparam, i; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 2, 0); +#endif + + func = stackPopPtr(pVM->pStack); + nparam = stackPopINT(pVM->pStack); + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, nparam, 1); +#endif + + for (i = 0; i < nparam; i++) + p[i] = stackPopINT(pVM->pStack); + + result = func(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], + p[9]); + + stackPushINT(pVM->pStack, result); + + return; +} + +/************************************************************************** + f i c l E x e c F D +** reads in text from file fd and passes it to ficlExec() + * returns VM_OUTOFTEXT on success or the ficlExec() error code on + * failure. + */ +#define nLINEBUF 256 +int ficlExecFD(FICL_VM *pVM, int fd) +{ + char cp[nLINEBUF]; + int nLine = 0, rval = VM_OUTOFTEXT; + char ch; + CELL id; + + id = pVM->sourceID; + pVM->sourceID.i = fd; + + /* feed each line to ficlExec */ + while (1) { + int status, i; + + i = 0; + while ((status = read(fd, &ch, 1)) > 0 && ch != '\n') + cp[i++] = ch; + nLine++; + if (!i) { + if (status < 1) + break; + continue; + } + rval = ficlExecC(pVM, cp, i); + if(rval != VM_QUIT && rval != VM_USEREXIT && rval != VM_OUTOFTEXT) + { + pVM->sourceID = id; + return rval; + } + } + /* + ** Pass an empty line with SOURCE-ID == -1 to flush + ** any pending REFILLs (as required by FILE wordset) + */ + pVM->sourceID.i = -1; + ficlExec(pVM, ""); + + pVM->sourceID = id; + return rval; +} + +static void displayCellNoPad(FICL_VM *pVM) +{ + CELL c; +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 1, 0); +#endif + c = stackPop(pVM->pStack); + ltoa((c).i, pVM->pad, pVM->base); + vmTextOut(pVM, pVM->pad, 0); + return; +} + +/* isdir? - Return whether an fd corresponds to a directory. + * + * isdir? ( fd -- bool ) + */ +static void isdirQuestion(FICL_VM *pVM) +{ + struct stat sb; + FICL_INT flag; + int fd; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 1, 1); +#endif + + fd = stackPopINT(pVM->pStack); + flag = FICL_FALSE; + do { + if (fd < 0) + break; + if (fstat(fd, &sb) < 0) + break; + if (!S_ISDIR(sb.st_mode)) + break; + flag = FICL_TRUE; + } while (0); + stackPushINT(pVM->pStack, flag); +} + +/* fopen - open a file and return new fd on stack. + * + * fopen ( ptr count mode -- fd ) + */ +static void pfopen(FICL_VM *pVM) +{ + int mode, fd, count; + char *ptr, *name; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); +#endif + + mode = stackPopINT(pVM->pStack); /* get mode */ + count = stackPopINT(pVM->pStack); /* get count */ + ptr = stackPopPtr(pVM->pStack); /* get ptr */ + + if ((count < 0) || (ptr == NULL)) { + stackPushINT(pVM->pStack, -1); + return; + } + + /* ensure that the string is null terminated */ + name = (char *)malloc(count+1); + bcopy(ptr,name,count); + name[count] = 0; + + /* open the file */ + fd = open(name, mode); + free(name); + stackPushINT(pVM->pStack, fd); + return; +} + +/* fclose - close a file who's fd is on stack. + * + * fclose ( fd -- ) + */ +static void pfclose(FICL_VM *pVM) +{ + int fd; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 1, 0); +#endif + fd = stackPopINT(pVM->pStack); /* get fd */ + if (fd != -1) + close(fd); + return; +} + +/* fread - read file contents + * + * fread ( fd buf nbytes -- nread ) + */ +static void pfread(FICL_VM *pVM) +{ + int fd, len; + char *buf; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); +#endif + len = stackPopINT(pVM->pStack); /* get number of bytes to read */ + buf = stackPopPtr(pVM->pStack); /* get buffer */ + fd = stackPopINT(pVM->pStack); /* get fd */ + if (len > 0 && buf && fd != -1) + stackPushINT(pVM->pStack, read(fd, buf, len)); + else + stackPushINT(pVM->pStack, -1); + return; +} + +/* freaddir - read directory contents + * + * freaddir ( fd -- ptr len TRUE | FALSE ) + */ +static void pfreaddir(FICL_VM *pVM) +{ +#ifdef TESTMAIN + static struct dirent dirent; + struct stat sb; + char *buf; + off_t off, ptr; + u_int blksz; + int bufsz; +#endif + struct dirent *d; + int fd; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 1, 3); +#endif + + fd = stackPopINT(pVM->pStack); +#if TESTMAIN + /* + * The readdirfd() function is specific to the loader environment. + * We do the best we can to make freaddir work, but it's not at + * all guaranteed. + */ + d = NULL; + buf = NULL; + do { + if (fd == -1) + break; + if (fstat(fd, &sb) == -1) + break; + blksz = (sb.st_blksize) ? sb.st_blksize : getpagesize(); + if ((blksz & (blksz - 1)) != 0) + break; + buf = malloc(blksz); + if (buf == NULL) + break; + off = lseek(fd, 0LL, SEEK_CUR); + if (off == -1) + break; + ptr = off; + if (lseek(fd, 0, SEEK_SET) == -1) + break; + bufsz = getdents(fd, buf, blksz); + while (bufsz > 0 && bufsz <= ptr) { + ptr -= bufsz; + bufsz = getdents(fd, buf, blksz); + } + if (bufsz <= 0) + break; + d = (void *)(buf + ptr); + dirent = *d; + off += d->d_reclen; + d = (lseek(fd, off, SEEK_SET) != off) ? NULL : &dirent; + } while (0); + if (buf != NULL) + free(buf); +#else + d = readdirfd(fd); +#endif + if (d != NULL) { + stackPushPtr(pVM->pStack, d->d_name); + stackPushINT(pVM->pStack, strlen(d->d_name)); + stackPushINT(pVM->pStack, FICL_TRUE); + } else { + stackPushINT(pVM->pStack, FICL_FALSE); + } +} + +/* fload - interpret file contents + * + * fload ( fd -- ) + */ +static void pfload(FICL_VM *pVM) +{ + int fd; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 1, 0); +#endif + fd = stackPopINT(pVM->pStack); /* get fd */ + if (fd != -1) + ficlExecFD(pVM, fd); + return; +} + +/* fwrite - write file contents + * + * fwrite ( fd buf nbytes -- nwritten ) + */ +static void pfwrite(FICL_VM *pVM) +{ + int fd, len; + char *buf; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); +#endif + len = stackPopINT(pVM->pStack); /* get number of bytes to read */ + buf = stackPopPtr(pVM->pStack); /* get buffer */ + fd = stackPopINT(pVM->pStack); /* get fd */ + if (len > 0 && buf && fd != -1) + stackPushINT(pVM->pStack, write(fd, buf, len)); + else + stackPushINT(pVM->pStack, -1); + return; +} + +/* fseek - seek to a new position in a file + * + * fseek ( fd ofs whence -- pos ) + */ +static void pfseek(FICL_VM *pVM) +{ + int fd, pos, whence; + +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 3, 1); +#endif + whence = stackPopINT(pVM->pStack); + pos = stackPopINT(pVM->pStack); + fd = stackPopINT(pVM->pStack); + stackPushINT(pVM->pStack, lseek(fd, pos, whence)); + return; +} + +/* key - get a character from stdin + * + * key ( -- char ) + */ +static void key(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif + stackPushINT(pVM->pStack, getchar()); + return; +} + +/* key? - check for a character from stdin (FACILITY) + * + * key? ( -- flag ) + */ +static void keyQuestion(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM, 0, 1); +#endif +#ifdef TESTMAIN + /* XXX Since we don't fiddle with termios, let it always succeed... */ + stackPushINT(pVM->pStack, FICL_TRUE); +#else + /* But here do the right thing. */ + stackPushINT(pVM->pStack, ischar()? FICL_TRUE : FICL_FALSE); +#endif + return; +} + +/* seconds - gives number of seconds since beginning of time + * + * beginning of time is defined as: + * + * BTX - number of seconds since midnight + * FreeBSD - number of seconds since Jan 1 1970 + * + * seconds ( -- u ) + */ +static void pseconds(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM,0,1); +#endif + stackPushUNS(pVM->pStack, (FICL_UNS) time(NULL)); + return; +} + +/* ms - wait at least that many milliseconds (FACILITY) + * + * ms ( u -- ) + * + */ +static void ms(FICL_VM *pVM) +{ +#if FICL_ROBUST > 1 + vmCheckStack(pVM,1,0); +#endif +#ifdef TESTMAIN + usleep(stackPopUNS(pVM->pStack)*1000); +#else + delay(stackPopUNS(pVM->pStack)*1000); +#endif + return; +} *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 22:34:06 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9B712625 for ; Thu, 11 Jun 2015 22:34:06 +0000 (UTC) (envelope-from roam@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 893F71F76 for ; Thu, 11 Jun 2015 22:34:06 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BMY60N012148 for ; Thu, 11 Jun 2015 22:34:06 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BMY4at012125 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 22:34:04 GMT (envelope-from roam@FreeBSD.org) Date: Thu, 11 Jun 2015 22:34:04 GMT Message-Id: <201506112234.t5BMY4at012125@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286979 - soc2015/roam/ng_ayiya 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.20 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, 11 Jun 2015 22:34:06 -0000 Author: roam Date: Thu Jun 11 22:34:04 2015 New Revision: 286979 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286979 Log: A first, not completely working, attempt at AYIYA. Add the "configure" control message to query the ng_iface node for its IPv6 address (we shall use it as our identity). Add the rcvdata method and use the new ayiya_build() function to wrap and send inet6->ayiya packets and the new ayiya_verify() function to unwrap and send ayiya->inet6 packets. ObQuote: "Why won't you talk to me? You never talk to me" Modified: soc2015/roam/ng_ayiya/Makefile soc2015/roam/ng_ayiya/ng_ayiya.c soc2015/roam/ng_ayiya/ng_ayiya.h soc2015/roam/ng_ayiya/scaffold.pl Modified: soc2015/roam/ng_ayiya/Makefile ============================================================================== --- soc2015/roam/ng_ayiya/Makefile Thu Jun 11 22:14:09 2015 (r286978) +++ soc2015/roam/ng_ayiya/Makefile Thu Jun 11 22:34:04 2015 (r286979) @@ -52,4 +52,4 @@ tic: tic-tunnels.txt up ${SCAFFOLD} inet6 ${TIC_TUNNEL} - ${SCAFFOLD} ayiya + ${SCAFFOLD} ayiya ${TIC_TUNNEL} Modified: soc2015/roam/ng_ayiya/ng_ayiya.c ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.c Thu Jun 11 22:14:09 2015 (r286978) +++ soc2015/roam/ng_ayiya/ng_ayiya.c Thu Jun 11 22:34:04 2015 (r286979) @@ -31,9 +31,15 @@ #include #include #include +#include +#include +#include +#include #include +#include #include #include +#include #include "ng_ayiya.h" @@ -48,6 +54,7 @@ static ng_newhook_t ng_ayiya_newhook; static ng_disconnect_t ng_ayiya_disconnect; static ng_shutdown_t ng_ayiya_shutdown; +static ng_rcvdata_t ng_ayiya_rcvdata; static ng_parse_array_getLength_t ng_ayiya_secrethash_getLength; @@ -64,6 +71,13 @@ &ng_ayiya_secrethash_type, NULL, }, + { + NGM_AYIYA_COOKIE, + NGM_AYIYA_CONFIGURE, + "configure", + NULL, + &ng_parse_uint32_type, + }, { 0 } }; @@ -77,6 +91,7 @@ .disconnect = ng_ayiya_disconnect, .shutdown = ng_ayiya_shutdown, .cmdlist = ng_ayiya_cmds, + .rcvdata = ng_ayiya_rcvdata, }; NETGRAPH_INIT(ayiya, &typestruct); @@ -99,9 +114,12 @@ }; struct ng_ayiya_private { - node_p node; - u_char secrethash[16]; + u_char identity[16]; + u_char secrethash[20]; hook_p hooks[AYIYA_HOOK_LAST]; + node_p node; + item_p configuring; + bool configured; }; typedef struct ng_ayiya_private *priv_p; @@ -127,16 +145,16 @@ "{\n" "\t\"id\":\t\"%x\",\n" "\t\"name\":\t\"%s\",\n" - "\t\"has_secret\":\t%s,\n" + "\t\"configured\":\t%s,\n" "\t\"hooks\": {\n", NG_NODE_ID(node), NG_NODE_NAME(node), - priv->secrethash? "true": "false"); + priv->configured? "true": "false"); else sbuf_printf(sb, "Node [%x] %s\n" - "Secret hash %sset\n", + "Configured: %s\n", NG_NODE_ID(node), NG_NODE_NAME(node), - priv->secrethash? "": "not "); + priv->configured? "yes": "no"); for (int idx = 0; idx < AYIYA_HOOK_LAST; idx++) { const char * const hname = hookdefs[idx].name; @@ -180,6 +198,28 @@ sbuf_printf(sb, "\t}\n}"); } +static void +configuring_respond(const node_p node, const uint32_t error) +{ + const priv_p priv = NG_NODE_PRIVATE(node); + item_p item = priv->configuring; + struct ng_mesg *msg; + struct ng_mesg *resp; + + if (item == NULL) + return; + + NGI_GET_MSG(item, msg); + NG_MKRESPONSE(resp, msg, sizeof(error), M_NOWAIT); + *(uint32_t *)(resp->data) = error; + int err; + NG_RESPOND_MSG(err, node, item, resp); + NG_FREE_MSG(msg); + + priv->configuring = NULL; + priv->configured = (error == 0); +} + static int ng_ayiya_rcvmsg(const node_p node, item_p item, const hook_p lasthook) { @@ -188,8 +228,11 @@ struct ng_mesg *msg; NGI_GET_MSG(item, msg); + const bool is_resp = msg->header.flags & NGF_RESP; switch (msg->header.typecookie) { case NGM_GENERIC_COOKIE: + if (is_resp) + ERROUT(EINVAL); switch (msg->header.cmd) { case NGM_TEXT_CONFIG: case NGM_TEXT_STATUS: @@ -217,6 +260,8 @@ break; case NGM_AYIYA_COOKIE: + if (is_resp) + ERROUT(EINVAL); switch (msg->header.cmd) { case NGM_AYIYA_SECRETHASH: { @@ -230,12 +275,72 @@ } break; + case NGM_AYIYA_CONFIGURE: + { + const priv_p priv = NG_NODE_PRIVATE(node); + if (msg->header.arglen != 0 || priv->configured || + !priv->hooks[AYIYA_HOOK_INET6]) + ERROUT(EINVAL); + if (priv->configuring) + ERROUT(EINPROGRESS); + + /* Configuration is mostly querying the IPv6 address */ + struct ng_mesg *q; + NG_MKMESSAGE(q, NGM_IFACE_COOKIE, + NGM_IFACE_GET_IFINDEX, 0, M_NOWAIT); + if (q == NULL) + ERROUT(ENOMEM); + NG_SEND_MSG_HOOK(error, node, q, + priv->hooks[AYIYA_HOOK_INET6], NG_NODE_ID(node)); + /* Put that message back where it was! */ + NGI_MSG(item) = msg; + priv->configuring = item; + /** + * Do not pass "Go", do not respond to the message, + * do not free the item. + */ + return (0); + } + default: error = EINVAL; break; } break; + case NGM_IFACE_COOKIE: + { + if (!is_resp || msg->header.cmd != NGM_IFACE_GET_IFINDEX || + msg->header.arglen != 4) + ERROUT(EINVAL); + + const uint32_t ifidx = *(const uint32_t * const)msg->data; + struct ifnet * const ifp = ifnet_byindex_ref(ifidx); + if (ifp == NULL) + ERROUT(EINVAL); + + bool found = false; + const struct ifaddr *ifa; + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + if (ifa->ifa_addr == NULL || + ifa->ifa_addr->sa_family != AF_INET6) + continue; + const struct sockaddr_in6 * const a = + (const struct sockaddr_in6 *)ifa->ifa_addr; + if (a->sin6_addr.s6_addr16[0] == IPV6_ADDR_INT16_ULL) + continue; + + const priv_p priv = NG_NODE_PRIVATE(node); + bcopy(a->sin6_addr.s6_addr, priv->identity, sizeof(priv->identity)); + found = 1; + break; + } + if_rele(ifp); + + configuring_respond(node, found? 0: ENOENT); + break; + } + default: error = EINVAL; break; @@ -269,7 +374,8 @@ if (priv->hooks[idx] != NULL) return (EISCONN); - /* TODO: some more checks here */ + if (idx == AYIYA_HOOK_INET6) + priv->configured = false; priv->hooks[idx] = hook; return (0); @@ -278,7 +384,8 @@ static int ng_ayiya_disconnect(const hook_p hook) { - priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + const node_p node = NG_HOOK_NODE(hook); + const priv_p priv = NG_NODE_PRIVATE(node); int idx; for (idx = 0; idx < AYIYA_HOOK_LAST; idx++) if (priv->hooks[idx] == hook) @@ -286,6 +393,8 @@ if (idx == AYIYA_HOOK_LAST) panic("%s", __func__); priv->hooks[idx] = NULL; + if (priv->configuring && idx == AYIYA_HOOK_INET6) + configuring_respond(node, ECONNABORTED); return (0); } @@ -294,6 +403,8 @@ { const priv_p priv = NG_NODE_PRIVATE(node); + if (priv->configuring) + configuring_respond(0, ECONNABORTED); free(priv, M_NETGRAPH_AYIYA); NG_NODE_SET_PRIVATE(node, NULL); NG_NODE_UNREF(node); @@ -306,3 +417,222 @@ { return (sizeof(((const priv_p)NULL)->secrethash)); } + +static unsigned +which_hook(const hook_p hook, const priv_p priv) +{ + for (unsigned i = 0; i < AYIYA_HOOK_LAST; i++) + if (hook == priv->hooks[i]) + return (i); + return (AYIYA_HOOK_LAST); +} + +static int +ayiya_build(struct mbuf **mb, const u_char opcode, const u_char nextheader, + const priv_p priv) +{ + struct mbuf *m = *mb; + + M_PREPEND(m, sizeof(struct ng_ayiya_packet), M_NOWAIT); + if (m->m_next) + m = m_defrag(m, M_NOWAIT); + if (m == NULL) + return (ENOMEM); + struct ng_ayiya_header * const hdr = + (struct ng_ayiya_header *)m->m_data; + struct ng_ayiya_packet * const pkt = + (struct ng_ayiya_packet *)m->m_data; + + hdr->idlen = 4; + hdr->idtype = 1; // Integer + hdr->siglen = sizeof(pkt->signature) / 4; + hdr->hshmeth = 2; // SHA1 + hdr->autmeth = 1; // shared secret + hdr->opcode = opcode; + hdr->nextheader = nextheader; + hdr->epochtime = htonl(time_second); + + bcopy(priv->identity, pkt->identity, sizeof(pkt->identity)); + + /* Start with the secret hash... */ + bcopy(priv->secrethash, pkt->signature, sizeof(pkt->signature)); + + /* ...now hash it */ + SHA1_CTX c; + u_char hash[20]; + + SHA1Init(&c); + SHA1Update(&c, m->m_data, m->m_len); + SHA1Final(hash, &c); + bcopy(hash, pkt->signature, sizeof(pkt->signature)); + + /* And I think we're done. */ + *mb = m; + return (0); +} + +static int +ayiya_verify(struct mbuf **mb, u_char * const opcode, u_char * const nextheader, + const priv_p priv) +{ + struct mbuf *m = *mb; + + if (m->m_next) { + m = m_defrag(m, M_NOWAIT); + *mb = m; + } + if (m == NULL) + return (ENOMEM); + const int32_t len = m->m_len; + struct ng_ayiya_header * const hdr = + (struct ng_ayiya_header *)m->m_data; + const int32_t ofs_id = sizeof(*hdr); + if (len < ofs_id) + return (EINVAL); + if (hdr->idlen > 4) + return (EINVAL); + const int32_t ofs_sig = ofs_id + (2 << hdr->idlen); + if (len < ofs_sig) + return (EINVAL); + const unsigned siglen = 4 * hdr->siglen; + u_char * const sig = ((u_char *)hdr) + ofs_sig; + const int32_t ofs_data = ofs_sig + siglen; + if (len < ofs_data) + return (EINVAL); + + /* Okay, it seems that we have enough of a packet to process. */ + switch (hdr->autmeth) { + case 0: + /* Hmm... */ + break; + + case 1: + switch (hdr->hshmeth) { + case 0: + return (EINVAL); + + case 1: + { + /* + u_char csum[16]; + if (sizeof(csum) != siglen) + return (EINVAL); + bcopy(sig, csum, siglen); + bcopy(priv->secrethash, sig, siglen); + MD5_CTX c; + MD5Init(&c); + MD5Update(&c, m->m_data, m->m_len); + u_char hash[16]; + MD5Final(hash, &c); + if (bcmp(csum, hash, siglen) != 0) + return (EINVAL); + */ + m_freem(m); + *mb = NULL; + return (0); + } + + case 2: + { + u_char csum[20]; + if (sizeof(csum) != siglen) + return (EINVAL); + bcopy(sig, csum, siglen); + bcopy(priv->secrethash, sig, siglen); + SHA1_CTX c; + SHA1Init(&c); + SHA1Update(&c, m->m_data, m->m_len); + u_char hash[20]; + SHA1Final(hash, &c); + if (bcmp(csum, hash, siglen) != 0) + return (EINVAL); + break; + } + + default: + return (EOPNOTSUPP); + } + break; + + case 2: + return (EOPNOTSUPP); + + default: + return (EOPNOTSUPP); + } + + m_adj(m, ofs_data); + *mb = m; + *opcode = hdr->opcode; + *nextheader = hdr->nextheader; + return (0); +} + +static int +ng_ayiya_rcvdata(const hook_p hook, const item_p item) +{ + const priv_p priv = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); + struct mbuf *m; + + NGI_GET_M(item, m); + NG_FREE_ITEM(item); + + unsigned hidx = which_hook(hook, priv); + switch (hidx) { + case AYIYA_HOOK_INET6: + { + if (!priv->configured || priv->hooks[AYIYA_HOOK_AYIYA] == NULL) + { + /* FIXME: enqueue the packet? */ + m_freem(m); + return (0); + } + + /* Prepare a packet for forwarding */ + int error = ayiya_build(&m, 1, IPPROTO_IPV6, priv); + if (error != 0) + return (error); + + NG_SEND_DATA_ONLY(error, priv->hooks[AYIYA_HOOK_INET6], m); + return (error); + } + + case AYIYA_HOOK_AYIYA: + { + u_char opcode; + u_char nextheader; + int error = ayiya_verify(&m, &opcode, &nextheader, priv); + if (error != 0) + { + m_freem(m); + return (0); + } + + switch (opcode) + { + case 1: + /* Forward */ + if (nextheader != IPPROTO_IPV6) + { + m_freem(m); + return (0); + } + int error; + NG_SEND_DATA_ONLY(error, priv->hooks[AYIYA_HOOK_INET6], m); + /* Ignore the error, nothing to do, really. */ + break; + + default: + break; + } + + m_freem(m); + return (0); + } + + default: + m_freem(m); + return (EINVAL); + } + /* NOTREACHED */ +} Modified: soc2015/roam/ng_ayiya/ng_ayiya.h ============================================================================== --- soc2015/roam/ng_ayiya/ng_ayiya.h Thu Jun 11 22:14:09 2015 (r286978) +++ soc2015/roam/ng_ayiya/ng_ayiya.h Thu Jun 11 22:34:04 2015 (r286979) @@ -33,6 +33,36 @@ enum { NGM_AYIYA_SECRETHASH = 1, + NGM_AYIYA_CONFIGURE, }; +struct ng_ayiya_header { +#if _BYTE_ORDER == _BIG_ENDIAN + unsigned idlen:4, + idtype:4, + siglen:4, + hshmeth:4, + autmeth:4, + opcode:4, + nextheader:8; +#endif +#if _BYTE_ORDER == _LITTLE_ENDIAN + unsigned idtype:4, + idlen:4, + hshmeth:4, + siglen:4, + opcode:4, + autmeth:4, + nextheader:8; +#endif + uint32_t epochtime; +} __packed; + +/* A packet that we will send: IPv6 address as identity, SHA1 signature */ +struct ng_ayiya_packet { + struct ng_ayiya_header hdr; + u_char identity[16]; + u_char signature[20]; +} __packed; + #endif Modified: soc2015/roam/ng_ayiya/scaffold.pl ============================================================================== --- soc2015/roam/ng_ayiya/scaffold.pl Thu Jun 11 22:14:09 2015 (r286978) +++ soc2015/roam/ng_ayiya/scaffold.pl Thu Jun 11 22:34:04 2015 (r286979) @@ -28,6 +28,7 @@ use strict; use warnings; +use Digest::SHA1 qw/sha1_hex/; use Getopt::Std; use JSON::PP; use Net::SixXS::Data::Tunnel; @@ -55,6 +56,7 @@ sub cmd_inet6($ @); my %cmds = ( + ayiya => \&cmd_ayiya, build => \&cmd_setup, erect => \&cmd_setup, help => \&cmd_help, @@ -91,7 +93,8 @@ { my ($err) = @_; my $s = <{$_}, qw/id name has_secret hooks/) { + grep !exists $d->{$_}, qw/id name configured hooks/) { warn "Node [$node->{id}] '$node->{name}' returned ". "an invalid JSON configuration\n"; next; @@ -417,6 +420,9 @@ run_command 'ifconfig', $iface, 'inet6', $t->ipv6_local; # FIXME: Add a default route here, too. + + debug "Trying to get the node to configure itself"; + ngctl 'msg', "$c->{name}:", 'configure'; } sub get_tic_tunnel($) @@ -451,3 +457,47 @@ } return Net::SixXS::Data::Tunnel->from_hash(\%cfg); } + +sub cmd_ayiya($ @) +{ + my ($cmd, @args) = @_; + + if (@args != 1) { + warn "The ayiya command expects a tunnel name parameter\n"; + usage 1; + } + my $tunnel = shift @args; + + my $t = get_tic_tunnel $tunnel; + my $ayiya = get_ayiya; + + if (!$ayiya->{ours}) { + die "Our ng_ayiya node is not configured\n"; + } + # Tear down the socket if it's configured + my $c = $ayiya->{ours}->{config}; + my $sa = $c->{hooks}->{ayiya}; + if (defined $sa) { + debug "Shutting down the current socket"; + ngctl 'shutdown', "[$sa->{id}]:"; + } + + # Initialize the shared secret + my $p = sha1_hex($t->password); + $p =~ s/(..)/0x$1, /g; + $p = "[ $p ]"; + ngctl 'msg', "$c->{name}:", 'secrethash', $p; + # OK, let's create one + my $hkname = "ayiya/$tunnel"; + my $hkpeer = 'inet/dgram/udp'; + my $pname = 'sc_conn'; + ngctl 'mkpeer', "$c->{name}:", 'ksocket', $hkname, $hkpeer; + ngctl 'name', "$c->{name}:$hkname", $pname; + $ayiya = get_ayiya; + $c = $ayiya->{ours}->{config}; + if (!defined $c || $c->{hooks}->{ayiya}->{name} ne $pname) { + die "Could not query the newly-created ng_ksocket node\n"; + } + ngctl 'msg', "$pname:", 'connect', 'inet/'.$t->ipv4_pop.':5072'; + ...; +} From owner-svn-soc-all@FreeBSD.ORG Thu Jun 11 22:56:13 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CE2EFA48 for ; Thu, 11 Jun 2015 22:56:13 +0000 (UTC) (envelope-from roam@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 BCAB71580 for ; Thu, 11 Jun 2015 22:56:13 +0000 (UTC) (envelope-from roam@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5BMuDPv033438 for ; Thu, 11 Jun 2015 22:56:13 GMT (envelope-from roam@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5BMuDKt033434 for svn-soc-all@FreeBSD.org; Thu, 11 Jun 2015 22:56:13 GMT (envelope-from roam@FreeBSD.org) Date: Thu, 11 Jun 2015 22:56:13 GMT Message-Id: <201506112256.t5BMuDKt033434@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to roam@FreeBSD.org using -f From: roam@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286980 - soc2015/roam/ng_ayiya 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.20 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, 11 Jun 2015 22:56:13 -0000 Author: roam Date: Thu Jun 11 22:56:12 2015 New Revision: 286980 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286980 Log: Point to GitLab for Net-SixXS, not on CPAN yet. ObQuote: "But if you try sometime you will find you get what you need" Modified: soc2015/roam/ng_ayiya/Makefile Modified: soc2015/roam/ng_ayiya/Makefile ============================================================================== --- soc2015/roam/ng_ayiya/Makefile Thu Jun 11 22:34:04 2015 (r286979) +++ soc2015/roam/ng_ayiya/Makefile Thu Jun 11 22:56:12 2015 (r286980) @@ -47,7 +47,7 @@ ${SCAFFOLD} shutdown all tic-tunnels.txt: - @printf "\n\n======================\n\nPlease create the tic-tunnels.txt with the output of the sixxs-tic-tunnels tool\n\n======================\n\n" + @printf "\n\n======================\n\nPlease create the tic-tunnels.txt with the output of\nthe sixxs-tic-tunnels tool from the Net-SixXS distribution:\nhttps://gitlab.com/ppentchev/Net-SixXS\n\n======================\n\n" false tic: tic-tunnels.txt up From owner-svn-soc-all@FreeBSD.ORG Fri Jun 12 09:24:05 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 209EE6BF for ; Fri, 12 Jun 2015 09:24:05 +0000 (UTC) (envelope-from pratiksinghal@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 0D47F1449 for ; Fri, 12 Jun 2015 09:24:05 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5C9O4vO045342 for ; Fri, 12 Jun 2015 09:24:04 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5C9O4iK045337 for svn-soc-all@FreeBSD.org; Fri, 12 Jun 2015 09:24:04 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Fri, 12 Jun 2015 09:24:04 GMT Message-Id: <201506120924.t5C9O4iK045337@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286988 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 12 Jun 2015 09:24:05 -0000 Author: pratiksinghal Date: Fri Jun 12 09:24:03 2015 New Revision: 286988 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286988 Log: Removed trailing whitespace Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Fri Jun 12 07:50:34 2015 (r286987) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Fri Jun 12 09:24:03 2015 (r286988) @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include @@ -56,7 +56,7 @@ #define A10_MMC_MEMRES 0 #define A10_MMC_IRQRES 1 #define A10_MMC_RESSZ 2 -#define A10_MMC_NDESC 16 +#define A10_MMC_NDESC 16 #define A10_MMC_DMA_FTRGLEVEL_A20 0x20070008 struct a10_mmc_softc { @@ -73,22 +73,22 @@ struct mtx a10_mtx; struct resource * a10_res[A10_MMC_RESSZ]; uint32_t a10_intr; - uint32_t a10_idst ; + uint32_t a10_idst ; uint32_t a10_intr_wait; void * a10_intrhand; - int a10_use_dma ; + int a10_use_dma ; + + /* Fields required for DMA access */ + uint32_t a10_dma_xfer_len ; + bus_dma_segment_t* a10_dma_segs ; + int a10_dma_nsegs ; + bus_size_t a10_dma_size ; + struct a10_mmc_cb a10_dma_cb_arg ; + bus_dmamap_t a10_dma_map ; + bus_dma_tag_t a10_dma_tag ; + int a10_dma_ndesc; + void* a10_dma_desc ; - /* Fields required for DMA access */ - uint32_t a10_dma_xfer_len ; - bus_dma_segment_t* a10_dma_segs ; - int a10_dma_nsegs ; - bus_size_t a10_dma_size ; - struct a10_mmc_cb a10_dma_cb_arg ; - bus_dmamap_t a10_dma_map ; - bus_dma_tag_t a10_dma_tag ; - int a10_dma_ndesc; - void* a10_dma_desc ; - }; static struct resource_spec a10_mmc_res_spec[] = { @@ -99,14 +99,14 @@ static int a10_mmc_probe(device_t); static int a10_mmc_attach(device_t); -static int a10_mmc_setup_dma(struct a10_mmc_softc*, device_t) ; -static int a10_mmc_prepare_dma(struct a10_mmc_softc*) ; +static int a10_mmc_setup_dma(struct a10_mmc_softc*, device_t) ; +static int a10_mmc_prepare_dma(struct a10_mmc_softc*) ; static int a10_mmc_detach(device_t); static int a10_mmc_reset(struct a10_mmc_softc *); static void a10_mmc_intr(void *); static int a10_mmc_update_clock(struct a10_mmc_softc *); -static void a10_dma_cb(void*, bus_dma_segment_t*, int, int) ; +static void a10_dma_cb(void*, bus_dma_segment_t*, int, int) ; static int a10_mmc_update_ios(device_t, device_t); static int a10_mmc_request(device_t, device_t, struct mmc_request *); static int a10_mmc_get_ro(device_t, device_t); @@ -142,7 +142,7 @@ struct sysctl_oid_list *tree; sc = device_get_softc(dev); - sc->a10_use_dma = 1 ; + sc->a10_use_dma = 1 ; sc->a10_dev = dev; sc->a10_req = NULL; sc->a10_id = device_get_unit(dev); @@ -207,12 +207,12 @@ if(sc->a10_use_dma == 1) { if(a10_mmc_setup_dma(sc,dev) != 0) { - device_printf(sc->a10_dev, "Couldn't setup DMA!\n") ; - sc->a10_use_dma = 0 ; + device_printf(sc->a10_dev, "Couldn't setup DMA!\n") ; + sc->a10_use_dma = 0 ; } } - //sc->a10_use_dma = 0 ; /* Remove this after testing */ - device_printf(sc->a10_dev, "Setting up dma finished %d\n", sc->a10_use_dma) ; + //sc->a10_use_dma = 0 ; /* Remove this after testing */ + device_printf(sc->a10_dev, "Setting up dma finished %d\n", sc->a10_use_dma) ; return (0); fail: @@ -224,132 +224,132 @@ return (ENXIO); } -/*TODO :- Add the dismantling DMA part also with goto statements */ -static int +/*TODO :- Add the dismantling DMA part also with goto statements */ +static int a10_mmc_setup_dma(struct a10_mmc_softc* sc, device_t dev) { - sc->a10_dma_xfer_len = 0x2000 ; - sc->a10_dma_ndesc = A10_MMC_NDESC ; - sc->a10_dma_size = sizeof(struct a10_mmc_dma_desc)*(sc->a10_dma_ndesc) ; + sc->a10_dma_xfer_len = 0x2000 ; + sc->a10_dma_ndesc = A10_MMC_NDESC ; + sc->a10_dma_size = sizeof(struct a10_mmc_dma_desc)*(sc->a10_dma_ndesc) ; - uint32_t error ; - /* First create the tag */ + uint32_t error ; + /* First create the tag */ error = bus_dma_tag_create(bus_get_dma_tag(dev),1, sc->a10_dma_size,BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL,NULL,sc->a10_dma_size, 1,sc->a10_dma_size,0, - NULL,NULL,&sc->a10_dma_tag) ; + NULL,NULL,&sc->a10_dma_tag) ; if(error) - return (error) ; + return (error) ; - /* Allocate the memory and map at kva sc->a10_dma_desc*/ + /* Allocate the memory and map at kva sc->a10_dma_desc*/ - error = bus_dmamem_alloc(sc->a10_dma_tag,&sc->a10_dma_desc,BUS_DMA_WAITOK,&sc->a10_dma_map) ; + error = bus_dmamem_alloc(sc->a10_dma_tag,&sc->a10_dma_desc,BUS_DMA_WAITOK,&sc->a10_dma_map) ; if(error) - return (error) ; + return (error) ; - /* Load the map */ - error = bus_dmamap_load(sc->a10_dma_tag, sc->a10_dma_map,sc->a10_dma_desc,sc->a10_dma_size,a10_dma_cb, &sc->a10_dma_cb_arg,0) ; + /* Load the map */ + error = bus_dmamap_load(sc->a10_dma_tag, sc->a10_dma_map,sc->a10_dma_desc,sc->a10_dma_size,a10_dma_cb, &sc->a10_dma_cb_arg,0) ; if((error != 0)&&(error != EINPROGRESS)) - return (error) ; - - return(0) ; + return (error) ; + + return(0) ; } static int a10_mmc_prepare_dma(struct a10_mmc_softc* sc) { - struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; - struct mmc_command* cmd = sc->a10_req->cmd ; - int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; - bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; - bus_size_t off = 0 ; - int desc, rem,seg ; - uint32_t val; + struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; + struct mmc_command* cmd = sc->a10_req->cmd ; + int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; + bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; + bus_size_t off = 0 ; + int desc, rem,seg ; + uint32_t val; - desc = 0 ; + desc = 0 ; - /* Pick a segment and program all the descriptors in the segment. */ + /* Pick a segment and program all the descriptors in the segment. */ for(seg = 0; seg < sc->a10_dma_cb_arg.nsegs ; seg++) { - bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[seg].ds_addr; - bus_size_t len = (sc->a10_dma_cb_arg).segs[seg].ds_len ; - rem = min(len,cmd->data->len) ; + bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[seg].ds_addr; + bus_size_t len = (sc->a10_dma_cb_arg).segs[seg].ds_len ; + rem = min(len,cmd->data->len) ; while(rem > 0) { if(desc == sc->a10_dma_ndesc) - break ; - len = min(sc->a10_dma_xfer_len, rem) ; - dma[desc].buff_size = htole32(len) ; - dma[desc].buff_addr = htole32(paddr + off) ; - dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; - - cmd->data->len -= len ; - rem -= len ; - off += len ; + break ; + len = min(sc->a10_dma_xfer_len, rem) ; + dma[desc].buff_size = htole32(len) ; + dma[desc].buff_addr = htole32(paddr + off) ; + dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; + + cmd->data->len -= len ; + rem -= len ; + off += len ; if(desc == 0) { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_FD) ; + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_FD) ; } if(cmd->data->len == 0) { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_LD) ; - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_ER) ; - dma[desc].next = 0 ; + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_LD) ; + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_ER) ; + dma[desc].next = 0 ; } - else { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_DIC) ; - dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) ; + else { + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_DIC) ; + dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) ; } - desc++ ; + desc++ ; } } if(desc == sc->a10_dma_ndesc) { - device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; + device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; return EIO ; } - - bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; - val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; - val |= A10_MMC_DMA_ENABLE ; - val |= A10_MMC_INT_ENABLE ; - A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; - val |= A10_MMC_DMA_RESET ; - A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; - A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_SOFT_RST) ; - A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_IDMA_ON | A10_MMC_IDMAC_FIX_BURST) ; - val = A10_MMC_READ_4(sc,A10_MMC_IDIE) ; + bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; + + val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; + val |= A10_MMC_DMA_ENABLE ; + val |= A10_MMC_INT_ENABLE ; + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; + val |= A10_MMC_DMA_RESET ; + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; + A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_SOFT_RST) ; + A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_IDMA_ON | A10_MMC_IDMAC_FIX_BURST) ; + val = A10_MMC_READ_4(sc,A10_MMC_IDIE) ; val &= ~(A10_MMC_IDMAC_RECEIVE_INT | A10_MMC_IDMAC_TRANSMIT_INT) ; if(read == 1) { - val |= A10_MMC_IDMAC_RECEIVE_INT ; - } - else { - val |= A10_MMC_IDMAC_TRANSMIT_INT ; - } - - A10_MMC_WRITE_4(sc, A10_MMC_IDIE,val) ; - A10_MMC_WRITE_4(sc, A10_MMC_DLBA,desc_paddr) ; - A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A20) ; - - return (0) ; -} + val |= A10_MMC_IDMAC_RECEIVE_INT ; + } + else { + val |= A10_MMC_IDMAC_TRANSMIT_INT ; + } + + A10_MMC_WRITE_4(sc, A10_MMC_IDIE,val) ; + A10_MMC_WRITE_4(sc, A10_MMC_DLBA,desc_paddr) ; + A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A20) ; + + return (0) ; +} static void -a10_dma_cb(void* arg, bus_dma_segment_t* segs, int nsegs, int error) +a10_dma_cb(void* arg, bus_dma_segment_t* segs, int nsegs, int error) { - if(error) { - printf("a10_mmc: Error in a10_dma_callback function, code = %d\n",error) ; - return ; - } - - (*(struct a10_mmc_cb*)arg).nsegs = nsegs ; - (*(struct a10_mmc_cb*)arg).addr = segs[0].ds_addr ; - (*(struct a10_mmc_cb*)arg).segs = segs; + if(error) { + printf("a10_mmc: Error in a10_dma_callback function, code = %d\n",error) ; + return ; + } + + (*(struct a10_mmc_cb*)arg).nsegs = nsegs ; + (*(struct a10_mmc_cb*)arg).addr = segs[0].ds_addr ; + (*(struct a10_mmc_cb*)arg).segs = segs; } static int @@ -414,7 +414,7 @@ sc->a10_req = NULL; sc->a10_intr = 0; sc->a10_resid = 0; - sc->a10_idst = 0 ; + sc->a10_idst = 0 ; sc->a10_intr_wait = 0; req->done(req); } @@ -454,7 +454,7 @@ a10_mmc_req_done(sc); } -static void +static void a10_mmc_timeout(void *arg) { struct a10_mmc_softc *sc; @@ -502,7 +502,7 @@ A10_MMC_LOCK(sc); rint = A10_MMC_READ_4(sc, A10_MMC_RINTR); imask = A10_MMC_READ_4(sc, A10_MMC_IMASK); - idst = A10_MMC_READ_4(sc, A10_MMC_IDST) ; + idst = A10_MMC_READ_4(sc, A10_MMC_IDST) ; if (imask == 0 && rint == 0 ) { A10_MMC_UNLOCK(sc); return; @@ -531,40 +531,40 @@ return; } - /* Do we have to return from here or continue afterwards ? */ - /* What is the DMA only, what is PIO only and what is common part ? */ + /* Do we have to return from here or continue afterwards ? */ + /* What is the DMA only, what is PIO only and what is common part ? */ if(sc->a10_use_dma == 1) { - uint32_t comp = 0 ; - device_printf(sc->a10_dev, "IDST = %d\n", idst) ; - sc->a10_idst = idst ; - if(idst & A10_MMC_IDMAC_ERROR) { - device_printf(sc->a10_dev, "I/O error with DMA\n") ; - sc->a10_req->cmd->error = EIO ; + uint32_t comp = 0 ; + device_printf(sc->a10_dev, "IDST = %d\n", idst) ; + sc->a10_idst = idst ; + if(idst & A10_MMC_IDMAC_ERROR) { + device_printf(sc->a10_dev, "I/O error with DMA\n") ; + sc->a10_req->cmd->error = EIO ; } - if(!(idst & A10_MMC_IDMAC_COMPLETE)) { - device_printf(sc->a10_dev, "Timeout error with DMA\n") ; + if(!(idst & A10_MMC_IDMAC_COMPLETE)) { + device_printf(sc->a10_dev, "Timeout error with DMA\n") ; sc->a10_req->cmd->error = ETIMEDOUT ; } else - comp = 1 ; + comp = 1 ; - if(sc->a10_req->cmd->data != NULL) { - data = sc->a10_req->cmd->data ; + if(sc->a10_req->cmd->data != NULL) { + data = sc->a10_req->cmd->data ; if(data->flags&MMC_DATA_WRITE) - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; else - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; + bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; } if(comp == 0) - a10_mmc_req_done(sc) ; + a10_mmc_req_done(sc) ; else { - device_printf(sc->a10_dev, "DMA transfer working!\n") ; - a10_mmc_req_ok(sc) ; + device_printf(sc->a10_dev, "DMA transfer working!\n") ; + a10_mmc_req_ok(sc) ; } } - A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; sc->a10_intr |= rint; if(sc->a10_use_dma == 0) { @@ -595,7 +595,7 @@ return (EBUSY); } sc->a10_req = req; - device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; + device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; cmd = req->cmd; cmdreg = A10_MMC_START; if (cmd->opcode == MMC_GO_IDLE_STATE) @@ -609,7 +609,7 @@ sc->a10_intr = 0; sc->a10_resid = 0; - sc->a10_idst = 0 ; + sc->a10_idst = 0 ; sc->a10_intr_wait = A10_MMC_CMD_DONE; cmd->error = MMC_ERR_NONE; if (cmd->data != NULL) { @@ -628,7 +628,7 @@ A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); - if(cmd->data != NULL ) { + if(cmd->data != NULL ) { if(sc->a10_use_dma == 1) { a10_mmc_prepare_dma(sc) ; } @@ -643,7 +643,7 @@ } static int -a10_mmc_read_ivar(device_t bus, device_t child, int which, +a10_mmc_read_ivar(device_t bus, device_t child, int which, uintptr_t *result) { struct a10_mmc_softc *sc; From owner-svn-soc-all@FreeBSD.ORG Fri Jun 12 09:51:34 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32F299C6 for ; Fri, 12 Jun 2015 09:51:34 +0000 (UTC) (envelope-from pratiksinghal@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 14DBB1AC5 for ; Fri, 12 Jun 2015 09:51:34 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5C9pXEa073983 for ; Fri, 12 Jun 2015 09:51:33 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5C9pXVW073493 for svn-soc-all@FreeBSD.org; Fri, 12 Jun 2015 09:51:33 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Fri, 12 Jun 2015 09:51:33 GMT Message-Id: <201506120951.t5C9pXVW073493@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r286989 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 12 Jun 2015 09:51:34 -0000 Author: pratiksinghal Date: Fri Jun 12 09:51:32 2015 New Revision: 286989 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=286989 Log: Cleaned up interrupt handling code. Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Fri Jun 12 09:24:03 2015 (r286988) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Fri Jun 12 09:51:32 2015 (r286989) @@ -58,6 +58,7 @@ #define A10_MMC_RESSZ 2 #define A10_MMC_NDESC 16 #define A10_MMC_DMA_FTRGLEVEL_A20 0x20070008 +#define A10_MMC_DMA_FTRGLEVEL_A10 0x00070208 struct a10_mmc_softc { bus_space_handle_t a10_bsh; @@ -87,7 +88,8 @@ bus_dmamap_t a10_dma_map ; bus_dma_tag_t a10_dma_tag ; int a10_dma_ndesc; - void* a10_dma_desc ; + void* a10_dma_desc ; /* Contains the kva of the descriptor which we will pass to DLBA */ + int a10_dma_ops ; /* Which type of operation DMA is performing ? 0:read, 1:write, 2:other */ }; @@ -119,6 +121,12 @@ bus_space_read_4((_sc)->a10_bst, (_sc)->a10_bsh, _reg) #define A10_MMC_WRITE_4(_sc, _reg, _value) \ bus_space_write_4((_sc)->a10_bst, (_sc)->a10_bsh, _reg, _value) +#define A10_MMC_READ_2(_sc, _reg) \ + bus_space_read_2((_sc)->a10_bst, (_sc)->a10_bsh, _reg) +#define A10_MMC_WRITE_2(_sc, _reg, _value) \ + bus_space_write_2((_sc)->a10_bst, (_sc)->a10_bsh, _reg, _value) + + static int a10_mmc_probe(device_t dev) @@ -143,6 +151,7 @@ sc = device_get_softc(dev); sc->a10_use_dma = 1 ; + sc->a10_dma_ops = 2 ; sc->a10_dev = dev; sc->a10_req = NULL; sc->a10_id = device_get_unit(dev); @@ -244,7 +253,7 @@ /* Allocate the memory and map at kva sc->a10_dma_desc*/ - error = bus_dmamem_alloc(sc->a10_dma_tag,&sc->a10_dma_desc,BUS_DMA_WAITOK,&sc->a10_dma_map) ; + error = bus_dmamem_alloc(sc->a10_dma_tag,&sc->a10_dma_desc,BUS_DMA_WAITOK|BUS_DMA_ZERO,&sc->a10_dma_map) ; if(error) return (error) ; @@ -261,49 +270,47 @@ static int a10_mmc_prepare_dma(struct a10_mmc_softc* sc) { + device_printf(sc->a10_dev, "Call to prepare dma\n") ; struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; struct mmc_command* cmd = sc->a10_req->cmd ; int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; bus_size_t off = 0 ; - int desc, rem,seg ; + int desc, rem ; uint32_t val; desc = 0 ; /* Pick a segment and program all the descriptors in the segment. */ - for(seg = 0; seg < sc->a10_dma_cb_arg.nsegs ; seg++) + bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[0].ds_addr; + bus_size_t len = (sc->a10_dma_cb_arg).segs[0].ds_len ; + rem = min(len,cmd->data->len) ; + while(rem > 0) { - bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[seg].ds_addr; - bus_size_t len = (sc->a10_dma_cb_arg).segs[seg].ds_len ; - rem = min(len,cmd->data->len) ; - while(rem > 0) - { - if(desc == sc->a10_dma_ndesc) - break ; - len = min(sc->a10_dma_xfer_len, rem) ; - dma[desc].buff_size = htole32(len) ; - dma[desc].buff_addr = htole32(paddr + off) ; - dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; - - cmd->data->len -= len ; - rem -= len ; - off += len ; - if(desc == 0) { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_FD) ; - } - - if(cmd->data->len == 0) { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_LD) ; - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_ER) ; - dma[desc].next = 0 ; - } - else { - dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_DIC) ; - dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) ; - } - desc++ ; + if(desc == sc->a10_dma_ndesc) + break ; + len = min(sc->a10_dma_xfer_len, rem) ; + dma[desc].buff_size = htole32(len) ; + dma[desc].buff_addr = htole32(paddr + off) ; + dma[desc].config = htole32(A10_MMC_DMA_CONFIG_CH|A10_MMC_DMA_CONFIG_OWN) ; + + cmd->data->len -= len ; + rem -= len ; + off += len ; + if(desc == 0) { + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_FD) ; + } + + if(cmd->data->len == 0) { + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_LD) ; + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_ER) ; + dma[desc].next = 0 ; + } + else { + dma[desc].config |= htole32(A10_MMC_DMA_CONFIG_DIC) ; + dma[desc].next = htole32(desc_paddr + ((desc+1)*sizeof(struct a10_mmc_dma_desc))) ; } + desc++ ; } if(desc == sc->a10_dma_ndesc) { @@ -313,27 +320,42 @@ bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; + /* Enable DMA and interrupts*/ val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; val |= A10_MMC_DMA_ENABLE ; val |= A10_MMC_INT_ENABLE ; A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; + + /* Reset DMA */ val |= A10_MMC_DMA_RESET ; A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; + + /* IDMA Soft reset */ A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_SOFT_RST) ; + + /* Enable IDMA with Fix burst */ A10_MMC_WRITE_4(sc, A10_MMC_DMAC,A10_MMC_IDMAC_IDMA_ON | A10_MMC_IDMAC_FIX_BURST) ; + + /* Disable interrupts */ val = A10_MMC_READ_4(sc,A10_MMC_IDIE) ; val &= ~(A10_MMC_IDMAC_RECEIVE_INT | A10_MMC_IDMAC_TRANSMIT_INT) ; + A10_MMC_WRITE_4(sc,A10_MMC_IDIE, val) ; - if(read == 1) { + /* Enable required interrupts */ + if(read == 1) val |= A10_MMC_IDMAC_RECEIVE_INT ; - } - else { + else val |= A10_MMC_IDMAC_TRANSMIT_INT ; - } - A10_MMC_WRITE_4(sc, A10_MMC_IDIE,val) ; + + /* Give the starting segment physical address */ A10_MMC_WRITE_4(sc, A10_MMC_DLBA,desc_paddr) ; - A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A20) ; + + /* Configure the watermark level. */ + A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A10) ; + + /* Disable debounce*/ + A10_MMC_WRITE_4(sc, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE), A10_MMC_GCTRL); return (0) ; } @@ -503,7 +525,8 @@ rint = A10_MMC_READ_4(sc, A10_MMC_RINTR); imask = A10_MMC_READ_4(sc, A10_MMC_IMASK); idst = A10_MMC_READ_4(sc, A10_MMC_IDST) ; - if (imask == 0 && rint == 0 ) { + + if (imask == 0 && rint == 0 && idst == 0 ) { A10_MMC_UNLOCK(sc); return; } @@ -521,8 +544,10 @@ if (rint & A10_MMC_INT_ERR_BIT) { device_printf(sc->a10_dev, "error rint: 0x%08X\n", rint); - if (rint & A10_MMC_RESP_TIMEOUT) + if (rint & A10_MMC_RESP_TIMEOUT) { + device_printf(sc->a10_dev,"Setting timeout in intr\n") ; sc->a10_req->cmd->error = MMC_ERR_TIMEOUT; + } else sc->a10_req->cmd->error = MMC_ERR_FAILED; A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint); @@ -531,52 +556,48 @@ return; } - /* Do we have to return from here or continue afterwards ? */ - /* What is the DMA only, what is PIO only and what is common part ? */ - if(sc->a10_use_dma == 1) { - uint32_t comp = 0 ; - device_printf(sc->a10_dev, "IDST = %d\n", idst) ; - sc->a10_idst = idst ; - if(idst & A10_MMC_IDMAC_ERROR) { - device_printf(sc->a10_dev, "I/O error with DMA\n") ; - sc->a10_req->cmd->error = EIO ; - } - if(!(idst & A10_MMC_IDMAC_COMPLETE)) { - device_printf(sc->a10_dev, "Timeout error with DMA\n") ; - sc->a10_req->cmd->error = ETIMEDOUT ; - } - else - comp = 1 ; - - if(sc->a10_req->cmd->data != NULL) { - data = sc->a10_req->cmd->data ; - if(data->flags&MMC_DATA_WRITE) - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map,BUS_DMASYNC_POSTWRITE) ; - else - bus_dmamap_sync(sc->a10_dma_tag,sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; - } + if(idst & A10_MMC_IDMAC_ERROR) { + device_printf(sc->a10_dev, "error rint: 0x%08x\n", idst) ; + sc->a10_req->cmd->error = MMC_ERR_FAILED ; + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + a10_mmc_req_done(sc) ; + A10_MMC_UNLOCK(sc) ; + return ; + } - if(comp == 0) - a10_mmc_req_done(sc) ; - else { - device_printf(sc->a10_dev, "DMA transfer working!\n") ; - a10_mmc_req_ok(sc) ; - } + if(idst & A10_MMC_IDMAC_COMPLETE) { + device_printf(sc->a10_dev, "DMA transfer complete!\n", idst) ; + if(sc->a10_dma_ops == 0) + bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; + else if(sc->a10_dma_ops == 1) + bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTWRITE) ; + else + device_printf(sc->a10_dev, "Invalid operations request!\n") ; + a10_mmc_req_ok(sc) ; + A10_MMC_UNLOCK(sc) ; + return ; + } + if((idst)&&(!(idst & A10_MMC_IDMAC_COMPLETE))) { + device_printf(sc->a10_dev, "DMA timeout error!\n", idst) ; + sc->a10_req_cmd->error = MMC_ERR_TIMEOUT ; + a10_mmc_req_done(sc) ; + A10_MMC_UNLOCK(sc) ; } - A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; sc->a10_intr |= rint; - if(sc->a10_use_dma == 0) { - data = sc->a10_req->cmd->data; - if (data != NULL && (rint & (A10_MMC_DATA_OVER | - A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) - a10_mmc_pio_transfer(sc, data); - if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) - a10_mmc_req_ok(sc); + data = sc->a10_req->cmd->data; + + if (data != NULL && (rint & (A10_MMC_DATA_OVER | + A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) + a10_mmc_pio_transfer(sc, data); } + if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) + a10_mmc_req_ok(sc); + A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint); + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; A10_MMC_UNLOCK(sc); } @@ -586,7 +607,9 @@ int blksz; struct a10_mmc_softc *sc; struct mmc_command *cmd; - uint32_t cmdreg; + uint32_t cmdreg,imask; + + imask = A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT | A10_MMC_WAIT_PREOVER | A10_MMC_DATA_OVER ; sc = device_get_softc(bus); A10_MMC_LOCK(sc); @@ -612,6 +635,7 @@ sc->a10_idst = 0 ; sc->a10_intr_wait = A10_MMC_CMD_DONE; cmd->error = MMC_ERR_NONE; + /* Will data be NULL when reading data ? */ if (cmd->data != NULL) { sc->a10_intr_wait |= A10_MMC_DATA_OVER; cmdreg |= A10_MMC_DATA_EXP | A10_MMC_WAIT_PREOVER; @@ -619,21 +643,29 @@ cmdreg |= A10_MMC_SEND_AUTOSTOP; sc->a10_intr_wait |= A10_MMC_AUTOCMD_DONE; } - if (cmd->data->flags & MMC_DATA_WRITE) + if (cmd->data->flags & MMC_DATA_WRITE) { cmdreg |= A10_MMC_WRITE; + if(sc->a10_use_dma == 1) + imask |= A10_MMC_TX_DATA_REQ ; + } + else { + if(sc->a10_use_dma == 1) + imask |= A10_MMC_RX_DATA_REQ ; + } blksz = min(cmd->data->len, MMC_SECTOR_SIZE); A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz); A10_MMC_WRITE_4(sc, A10_MMC_BCNTR, cmd->data->len); - } - - A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); - - if(cmd->data != NULL ) { - if(sc->a10_use_dma == 1) { + if(sc->a10_use_dma == 1) a10_mmc_prepare_dma(sc) ; - } } + uint32_t newmask = A10_MMC_READ_4(sc, A10_MMC_IMASK) ; + if(!(imask & A10_MMC_SDIO_INT)) + A10_MMC_WRITE_2(sc, A10_MMC_IMASK, newmask) ; + else + A10_MMC_WRITE_4(sc, A10_MMC_IMASK, newmask) ; + + A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg); A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode); callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz, a10_mmc_timeout, sc); From owner-svn-soc-all@FreeBSD.ORG Sat Jun 13 01:46:52 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2FA7ADE8 for ; Sat, 13 Jun 2015 01:46:52 +0000 (UTC) (envelope-from pratiksinghal@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 1D1BCDB0 for ; Sat, 13 Jun 2015 01:46:52 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5D1kpbu022775 for ; Sat, 13 Jun 2015 01:46:51 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5D1kpba022758 for svn-soc-all@FreeBSD.org; Sat, 13 Jun 2015 01:46:51 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Sat, 13 Jun 2015 01:46:51 GMT Message-Id: <201506130146.t5D1kpba022758@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287028 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 13 Jun 2015 01:46:52 -0000 Author: pratiksinghal Date: Sat Jun 13 01:46:51 2015 New Revision: 287028 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287028 Log: 1) Added the code for setting up data buffer 2) Cleaned up the code in a10_mmc_request. Changes in a10_mmc_prepare_dma still to be done though. Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Fri Jun 12 22:05:04 2015 (r287027) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 13 01:46:51 2015 (r287028) @@ -57,6 +57,8 @@ #define A10_MMC_IRQRES 1 #define A10_MMC_RESSZ 2 #define A10_MMC_NDESC 16 +#define A10_DMA_NSEGS 16 +#define A10_DMA_BUFF_SIZE 512 #define A10_MMC_DMA_FTRGLEVEL_A20 0x20070008 #define A10_MMC_DMA_FTRGLEVEL_A10 0x00070208 @@ -103,6 +105,7 @@ static int a10_mmc_attach(device_t); static int a10_mmc_setup_dma(struct a10_mmc_softc*, device_t) ; static int a10_mmc_prepare_dma(struct a10_mmc_softc*) ; +static int a10_mmc_can_do_dma(struct mmc_request*) ; static int a10_mmc_detach(device_t); static int a10_mmc_reset(struct a10_mmc_softc *); static void a10_mmc_intr(void *); @@ -220,8 +223,9 @@ sc->a10_use_dma = 0 ; } } - //sc->a10_use_dma = 0 ; /* Remove this after testing */ - device_printf(sc->a10_dev, "Setting up dma finished %d\n", sc->a10_use_dma) ; +#ifdef DEBUG + device_printf(sc->a10_dev, "DMA status %d\n", sc->a10_use_dma) ; +#endif return (0); fail: @@ -262,6 +266,19 @@ if((error != 0)&&(error != EINPROGRESS)) return (error) ; + + /* Now allocate tag and map for the buffer to be used with transfer. */ + error = bus_dma_tag_create(bus_get_dma_tag(dev),1, + 0,BUS_SPACE_MAXADDR_32BIT,BUS_SPACE_MAXADDR, + NULL,NULL,A10_DMA_BUFF_SIZE, + A10_DMA_NSEGS,A10_DMA_BUFF_SIZE,0, + NULL,NULL,&sc->a10_dma_buf_tag) ; + if(error) + return (error) ; + + error = bus_dma_map_create(sc->a10_dma_buf_tag,0,&sc->a10_dma_buf_map) ; + if(error) + return (error) ; return(0) ; @@ -270,9 +287,11 @@ static int a10_mmc_prepare_dma(struct a10_mmc_softc* sc) { + device_printf(sc->a10_dev, "Call to prepare dma\n") ; struct a10_mmc_dma_desc* dma = sc->a10_dma_desc ; struct mmc_command* cmd = sc->a10_req->cmd ; + device_printf(sc->a10_dev,"sc->a10_req = %p, sc->a10_req->cmd = %p, sc->a10_req->cmd->data = %p, dma = %p\n", sc->a10_req,sc->a10_req->cmd,sc->a10_req->cmd->data,dma) ; int read = (sc->a10_req->cmd->data->flags & MMC_DATA_WRITE) ? 0 : 1 ; bus_addr_t desc_paddr = (sc->a10_dma_cb_arg).addr ; bus_size_t off = 0 ; @@ -280,11 +299,12 @@ uint32_t val; desc = 0 ; - + device_printf(sc->a10_dev,"Before loop\n") ; /* Pick a segment and program all the descriptors in the segment. */ bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[0].ds_addr; bus_size_t len = (sc->a10_dma_cb_arg).segs[0].ds_len ; rem = min(len,cmd->data->len) ; + device_printf(sc->a10_dev, "Before rem\n") ; while(rem > 0) { if(desc == sc->a10_dma_ndesc) @@ -313,12 +333,15 @@ desc++ ; } + device_printf(sc->a10_dev, "After the completion of loop\n") ; if(desc == sc->a10_dma_ndesc) { device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; return EIO ; } + device_printf(sc->a10_dev, "Before syncing\n") ; bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; + device_printf(sc->a10_dev, "After syncing\n") ; /* Enable DMA and interrupts*/ val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; @@ -356,11 +379,17 @@ /* Disable debounce*/ A10_MMC_WRITE_4(sc, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE), A10_MMC_GCTRL); - + device_printf(sc->a10_dev, "Completed the prepare function\n") ; return (0) ; } +/* Not implemented yet. */ +static int +a10_mmc_can_do_dma(struct mmc_request* req) +{ + return (1) ; +} static void a10_dma_cb(void* arg, bus_dma_segment_t* segs, int nsegs, int error) { @@ -369,7 +398,6 @@ return ; } - (*(struct a10_mmc_cb*)arg).nsegs = nsegs ; (*(struct a10_mmc_cb*)arg).addr = segs[0].ds_addr ; (*(struct a10_mmc_cb*)arg).segs = segs; } @@ -566,7 +594,7 @@ } if(idst & A10_MMC_IDMAC_COMPLETE) { - device_printf(sc->a10_dev, "DMA transfer complete!\n", idst) ; + device_printf(sc->a10_dev, "DMA transfer complete!\n") ; if(sc->a10_dma_ops == 0) bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTREAD) ; else if(sc->a10_dma_ops == 1) @@ -579,8 +607,8 @@ } if((idst)&&(!(idst & A10_MMC_IDMAC_COMPLETE))) { - device_printf(sc->a10_dev, "DMA timeout error!\n", idst) ; - sc->a10_req_cmd->error = MMC_ERR_TIMEOUT ; + device_printf(sc->a10_dev, "DMA timeout error!\n") ; + sc->a10_req->cmd->error = MMC_ERR_TIMEOUT ; a10_mmc_req_done(sc) ; A10_MMC_UNLOCK(sc) ; } @@ -591,8 +619,6 @@ if (data != NULL && (rint & (A10_MMC_DATA_OVER | A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0) a10_mmc_pio_transfer(sc, data); - } - if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait) a10_mmc_req_ok(sc); @@ -601,6 +627,7 @@ A10_MMC_UNLOCK(sc); } +/* Interrupt masking in linux kernel apart from RX/TX is still dubious. */ static int a10_mmc_request(device_t bus, device_t child, struct mmc_request *req) { @@ -609,16 +636,15 @@ struct mmc_command *cmd; uint32_t cmdreg,imask; - imask = A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT | A10_MMC_WAIT_PREOVER | A10_MMC_DATA_OVER ; - sc = device_get_softc(bus); A10_MMC_LOCK(sc); if (sc->a10_req) { A10_MMC_UNLOCK(sc); return (EBUSY); } + sc->a10_req = req; - device_printf(sc->a10_dev, "a10_req = %p\n", sc->a10_req) ; + imask = 0 ; cmd = req->cmd; cmdreg = A10_MMC_START; if (cmd->opcode == MMC_GO_IDLE_STATE) @@ -635,7 +661,7 @@ sc->a10_idst = 0 ; sc->a10_intr_wait = A10_MMC_CMD_DONE; cmd->error = MMC_ERR_NONE; - /* Will data be NULL when reading data ? */ + if (cmd->data != NULL) { sc->a10_intr_wait |= A10_MMC_DATA_OVER; cmdreg |= A10_MMC_DATA_EXP | A10_MMC_WAIT_PREOVER; @@ -643,20 +669,20 @@ cmdreg |= A10_MMC_SEND_AUTOSTOP; sc->a10_intr_wait |= A10_MMC_AUTOCMD_DONE; } - if (cmd->data->flags & MMC_DATA_WRITE) { + if (cmd->data->flags & MMC_DATA_WRITE) cmdreg |= A10_MMC_WRITE; - if(sc->a10_use_dma == 1) - imask |= A10_MMC_TX_DATA_REQ ; - } - else { - if(sc->a10_use_dma == 1) - imask |= A10_MMC_RX_DATA_REQ ; - } + blksz = min(cmd->data->len, MMC_SECTOR_SIZE); A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz); A10_MMC_WRITE_4(sc, A10_MMC_BCNTR, cmd->data->len); - if(sc->a10_use_dma == 1) - a10_mmc_prepare_dma(sc) ; + + if((sc->a10_use_dma == 1)&&(a10_mmc_can_do_dma(req))) { + uint32_t error = a10_mmc_prepare_dma(sc) ; + if(error == 0) + imask |= (A10_MMC_TX_DATA_REQ|A10_MMC_RX_DATA_REQ) ; + else + device_printf(sc->a10_dev, "Couldn't prepare DMA, using pio instead\n") ; + } } uint32_t newmask = A10_MMC_READ_4(sc, A10_MMC_IMASK) ; From owner-svn-soc-all@FreeBSD.ORG Sat Jun 13 05:54:32 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 13BA35F7 for ; Sat, 13 Jun 2015 05:54:32 +0000 (UTC) (envelope-from pratiksinghal@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 E9421F03 for ; Sat, 13 Jun 2015 05:54:31 +0000 (UTC) (envelope-from pratiksinghal@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5D5sVsu031689 for ; Sat, 13 Jun 2015 05:54:31 GMT (envelope-from pratiksinghal@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5D5sVJY031683 for svn-soc-all@FreeBSD.org; Sat, 13 Jun 2015 05:54:31 GMT (envelope-from pratiksinghal@FreeBSD.org) Date: Sat, 13 Jun 2015 05:54:31 GMT Message-Id: <201506130554.t5D5sVJY031683@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to pratiksinghal@FreeBSD.org using -f From: pratiksinghal@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287030 - soc2015/pratiksinghal/cubie-head/sys/arm/allwinner 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.20 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, 13 Jun 2015 05:54:32 -0000 Author: pratiksinghal Date: Sat Jun 13 05:54:30 2015 New Revision: 287030 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287030 Log: 1) DMA partially working 2) Interrupt storm error still to be removed. (Interrupt handling is not correct now) Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Modified: soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c ============================================================================== --- soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 13 01:28:19 2015 (r287029) +++ soc2015/pratiksinghal/cubie-head/sys/arm/allwinner/a10_mmc.c Sat Jun 13 05:54:30 2015 (r287030) @@ -92,6 +92,8 @@ int a10_dma_ndesc; void* a10_dma_desc ; /* Contains the kva of the descriptor which we will pass to DLBA */ int a10_dma_ops ; /* Which type of operation DMA is performing ? 0:read, 1:write, 2:other */ + bus_dma_tag_t a10_dma_buff_tag ; + bus_dmamap_t a10_dma_buff_map ; }; @@ -272,11 +274,11 @@ 0,BUS_SPACE_MAXADDR_32BIT,BUS_SPACE_MAXADDR, NULL,NULL,A10_DMA_BUFF_SIZE, A10_DMA_NSEGS,A10_DMA_BUFF_SIZE,0, - NULL,NULL,&sc->a10_dma_buf_tag) ; + NULL,NULL,&sc->a10_dma_buff_tag) ; if(error) return (error) ; - error = bus_dma_map_create(sc->a10_dma_buf_tag,0,&sc->a10_dma_buf_map) ; + error = bus_dmamap_create(sc->a10_dma_buff_tag,0,&sc->a10_dma_buff_map) ; if(error) return (error) ; @@ -299,12 +301,12 @@ uint32_t val; desc = 0 ; - device_printf(sc->a10_dev,"Before loop\n") ; + /* Pick a segment and program all the descriptors in the segment. */ bus_addr_t paddr = (sc->a10_dma_cb_arg).segs[0].ds_addr; bus_size_t len = (sc->a10_dma_cb_arg).segs[0].ds_len ; rem = min(len,cmd->data->len) ; - device_printf(sc->a10_dev, "Before rem\n") ; + while(rem > 0) { if(desc == sc->a10_dma_ndesc) @@ -333,22 +335,19 @@ desc++ ; } - device_printf(sc->a10_dev, "After the completion of loop\n") ; if(desc == sc->a10_dma_ndesc) { device_printf(sc->a10_dev, "Couldn't find enough descriptors for DMA transfer! desc = %d,sc->a10_dma_ndesc = %d\n",desc, sc->a10_dma_ndesc) ; return EIO ; } - device_printf(sc->a10_dev, "Before syncing\n") ; bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_PREWRITE) ; - device_printf(sc->a10_dev, "After syncing\n") ; /* Enable DMA and interrupts*/ val = A10_MMC_READ_4(sc, A10_MMC_GCTRL) ; val |= A10_MMC_DMA_ENABLE ; val |= A10_MMC_INT_ENABLE ; A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; - + /* Reset DMA */ val |= A10_MMC_DMA_RESET ; A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,val) ; @@ -376,9 +375,9 @@ /* Configure the watermark level. */ A10_MMC_WRITE_4(sc, A10_MMC_FTRGL,A10_MMC_DMA_FTRGLEVEL_A10) ; - /* Disable debounce*/ - A10_MMC_WRITE_4(sc, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE), A10_MMC_GCTRL); + A10_MMC_WRITE_4(sc, A10_MMC_GCTRL, A10_MMC_READ_4(sc, A10_MMC_GCTRL) & (~A10_MMC_DEBOUNCE_ENABLE)); + device_printf(sc->a10_dev, "Completed the prepare function\n") ; return (0) ; } @@ -566,6 +565,7 @@ "Spurious interrupt - no active request, rint: 0x%08X\n", rint); A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint); + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; A10_MMC_UNLOCK(sc); return; } @@ -579,6 +579,7 @@ else sc->a10_req->cmd->error = MMC_ERR_FAILED; A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint); + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; a10_mmc_req_done(sc); A10_MMC_UNLOCK(sc); return; @@ -588,6 +589,7 @@ device_printf(sc->a10_dev, "error rint: 0x%08x\n", idst) ; sc->a10_req->cmd->error = MMC_ERR_FAILED ; A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ; a10_mmc_req_done(sc) ; A10_MMC_UNLOCK(sc) ; return ; @@ -601,6 +603,8 @@ bus_dmamap_sync(sc->a10_dma_tag, sc->a10_dma_map, BUS_DMASYNC_POSTWRITE) ; else device_printf(sc->a10_dev, "Invalid operations request!\n") ; + A10_MMC_WRITE_4(sc, A10_MMC_IDST, idst) ; + A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint) ; a10_mmc_req_ok(sc) ; A10_MMC_UNLOCK(sc) ; return ; @@ -664,13 +668,16 @@ if (cmd->data != NULL) { sc->a10_intr_wait |= A10_MMC_DATA_OVER; + sc->a10_dma_ops = 0 ; cmdreg |= A10_MMC_DATA_EXP | A10_MMC_WAIT_PREOVER; if (cmd->data->flags & MMC_DATA_MULTI) { cmdreg |= A10_MMC_SEND_AUTOSTOP; sc->a10_intr_wait |= A10_MMC_AUTOCMD_DONE; } - if (cmd->data->flags & MMC_DATA_WRITE) + if (cmd->data->flags & MMC_DATA_WRITE) { cmdreg |= A10_MMC_WRITE; + sc->a10_dma_ops = 1 ; + } blksz = min(cmd->data->len, MMC_SECTOR_SIZE); A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz); From owner-svn-soc-all@FreeBSD.ORG Sat Jun 13 06:36:56 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8284FBB6 for ; Sat, 13 Jun 2015 06:36:56 +0000 (UTC) (envelope-from btw@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 6FF599D5 for ; Sat, 13 Jun 2015 06:36:56 +0000 (UTC) (envelope-from btw@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5D6auZp056572 for ; Sat, 13 Jun 2015 06:36:56 GMT (envelope-from btw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5D6atfL056527 for svn-soc-all@FreeBSD.org; Sat, 13 Jun 2015 06:36:55 GMT (envelope-from btw@FreeBSD.org) Date: Sat, 13 Jun 2015 06:36:55 GMT Message-Id: <201506130636.t5D6atfL056527@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to btw@FreeBSD.org using -f From: btw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r287032 - soc2015/btw/head/tools/tools/mq-testing/udp 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.20 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, 13 Jun 2015 06:36:56 -0000 Author: btw Date: Sat Jun 13 06:36:54 2015 New Revision: 287032 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287032 Log: Extend mq-testing/udp to support IPv6. Modified: soc2015/btw/head/tools/tools/mq-testing/udp/pktgen.c soc2015/btw/head/tools/tools/mq-testing/udp/server.c Modified: soc2015/btw/head/tools/tools/mq-testing/udp/pktgen.c ============================================================================== --- soc2015/btw/head/tools/tools/mq-testing/udp/pktgen.c Sat Jun 13 05:55:26 2015 (r287031) +++ soc2015/btw/head/tools/tools/mq-testing/udp/pktgen.c Sat Jun 13 06:36:54 2015 (r287032) @@ -45,29 +45,32 @@ #include #include #include +#include #include #include #include "common.h" -/* - * TODO: - * #1. Add supports for IPv6; - */ #define IFCONFIG_BIN "/sbin/ifconfig " -#define IFCONFIG_ARGS "%s inet %s" +#define IFCONFIG_ARGS "%s %s %s up" static char vmedev[MAXPATHLEN]; static uint8_t vmeif_ether[ETHER_ADDR_LEN]; -static in_addr_t vmeif_ip; +static char vmeif_ipstr[INET6_ADDRSTRLEN] = ""; +static struct in6_addr vmeif_ip6; +static struct in_addr vmeif_ip; static char vmeif_name[IFNAMSIZ] = "vme0"; -static char vmeif_ipstr[256] = "192.168.10.1"; +static char vmeif_ipstr_v4[] = "192.168.10.1"; +static char vmeif_ipstr_v6[] = "fec0::1"; static char *payload = "hello, world!"; static int pktsize = 100; static int quiet = 0; static int cpu = -1; static uint64_t total_sent = 0; +static int ipversion = 4; + +static void (*build_udp_packet)(uint8_t *, int); /* The checksum function is taken from tools/tools/netmap/pkt-gen.c */ static uint16_t @@ -109,7 +112,7 @@ } static void -build_udp_packet(uint8_t *buf, int pkt_size) +build_udp_packet_v4(uint8_t *buf, int pkt_size) { struct ether_header *eh = (struct ether_header *)buf; struct ip *ip = (struct ip *)(eh + 1); @@ -135,7 +138,7 @@ ip->ip_ttl = IPDEFTTL; ip->ip_p = IPPROTO_UDP; ip->ip_src.s_addr = htonl(0x0a000001 + (rand() % 0xfffffe)); - ip->ip_dst.s_addr = vmeif_ip; + ip->ip_dst = vmeif_ip; ip->ip_sum = 0; ip->ip_sum = wrapsum(checksum(ip, sizeof(*ip), 0)); @@ -149,6 +152,42 @@ pkt_size - (sizeof(*eh) + sizeof(*ip) + sizeof(*udp)))); } +static void +build_udp_packet_v6(uint8_t *buf, int pkt_size) +{ + struct ether_header *eh = (struct ether_header *)buf; + struct ip6_hdr *ip6 = (struct ip6_hdr *)(eh + 1); + struct udphdr *udp = (struct udphdr *)(ip6 + 1); + char *data = (char *)(udp + 1); + + /* Just fake an address */ + eh->ether_shost[0] = 0x01; + eh->ether_shost[1] = 0xbd; + eh->ether_shost[2] = 0xbc; + eh->ether_shost[3] = 0x4d; + eh->ether_shost[4] = 0xfb; + eh->ether_shost[5] = 0xfb; + memcpy(eh->ether_dhost, vmeif_ether, ETHER_ADDR_LEN); + eh->ether_type = htons(ETHERTYPE_IPV6); + + ip6->ip6_flow = 0; + ip6->ip6_plen = htons(pkt_size - sizeof(*eh) - sizeof(*ip6)); + ip6->ip6_nxt = IPPROTO_UDP; + ip6->ip6_hlim = 0xff; + ip6->ip6_vfc |= IPV6_VERSION; + ip6->ip6_dst = vmeif_ip6; + for (int i = 0; i < 16; i++) + ip6->ip6_src.s6_addr[i] = rand(); + + udp->uh_sport = htons(1 + rand() % 65535); + udp->uh_dport = htons(SERVER_PORT); + udp->uh_ulen = htons(pkt_size - sizeof(*eh) - sizeof(*ip6)); + udp->uh_sum = 1; + + memcpy(data, payload, min(strlen(payload) + 1, + pkt_size - (sizeof(*eh) + sizeof(*ip6) + sizeof(*udp)))); +} + static int get_ifaddr(const char *ifname, uint8_t *ether_addr) { @@ -213,7 +252,7 @@ uint8_t *buf; int ch; - while ((ch = getopt(argc, argv, "a:b:i:l:p:q")) != -1) { + while ((ch = getopt(argc, argv, "a:b:i:l:p:q46")) != -1) { switch (ch) { case 'a': strlcpy(vmeif_ipstr, optarg, sizeof(vmeif_ipstr)); @@ -233,15 +272,31 @@ case 'q': quiet = 1; break; + case '4': + ipversion = 4; + break; + case '6': + ipversion = 6; + break; default: usage(argv[0]); break; } } + if (vmeif_ipstr[0] == '\0') { + if (ipversion == 4) + strlcpy(vmeif_ipstr, vmeif_ipstr_v4, + sizeof(vmeif_ipstr)); + else + strlcpy(vmeif_ipstr, vmeif_ipstr_v6, + sizeof(vmeif_ipstr)); + } + if (!quiet) { printf("vme name: %s\n", vmeif_name); - printf("vme ip: %s\n", vmeif_ipstr); + printf("IP version: %d\n", ipversion); + printf("vme IP: %s\n", vmeif_ipstr); printf("packet size: %d\n", pktsize); printf("payload: %s\n", payload); if (cpu != -1) @@ -262,16 +317,34 @@ exit(EXIT_FAILURE); } - snprintf(cmd, sizeof(cmd), IFCONFIG_BIN IFCONFIG_ARGS, vmeif_name, - vmeif_ipstr); - if (system(cmd) != 0) { - fprintf(stderr, "Failed to setup %s\n", vmeif_name); + switch (ipversion) { + case 4: + if (inet_pton(AF_INET, vmeif_ipstr, &vmeif_ip) != 1) { + fprintf(stderr, "Malformed address %s specified\n", + vmeif_ipstr); + exit(EXIT_FAILURE); + } + snprintf(cmd, sizeof(cmd), IFCONFIG_BIN IFCONFIG_ARGS, + vmeif_name, "inet", vmeif_ipstr); + build_udp_packet = build_udp_packet_v4; + break; + case 6: + if (inet_pton(AF_INET6, vmeif_ipstr, &vmeif_ip6) != 1) { + fprintf(stderr, "Malformed address %s specified\n", + vmeif_ipstr); + exit(EXIT_FAILURE); + } + snprintf(cmd, sizeof(cmd), IFCONFIG_BIN IFCONFIG_ARGS, + vmeif_name, "inet6", vmeif_ipstr); + build_udp_packet = build_udp_packet_v6; + break; + default: + fprintf(stderr, "Only support ipv4 and ipv6.\n"); exit(EXIT_FAILURE); } - if ((vmeif_ip = inet_addr(vmeif_ipstr)) == INADDR_NONE) { - fprintf(stderr, "Malformed address %s specified\n", - vmeif_ipstr); + if (system(cmd) != 0) { + fprintf(stderr, "Failed to setup %s\n", vmeif_name); exit(EXIT_FAILURE); } Modified: soc2015/btw/head/tools/tools/mq-testing/udp/server.c ============================================================================== --- soc2015/btw/head/tools/tools/mq-testing/udp/server.c Sat Jun 13 05:55:26 2015 (r287031) +++ soc2015/btw/head/tools/tools/mq-testing/udp/server.c Sat Jun 13 06:36:54 2015 (r287032) @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -38,6 +39,7 @@ #include "common.h" +static int ipversion = 4; static int verbose = 0; static void @@ -47,17 +49,49 @@ exit(EXIT_FAILURE); } +static char * +addr2str(int af, struct sockaddr *addr) +{ + static char msg[1024]; + char addrstr[INET6_ADDRSTRLEN]; + + switch (af) { + case AF_INET: + snprintf(msg, sizeof(msg), "%s:%d", + inet_ntoa(((struct sockaddr_in *)addr)->sin_addr), + ntohs(((struct sockaddr_in *)addr)->sin_port)); + break; + case AF_INET6: + snprintf(msg, sizeof(msg), "%s:%d", + inet_ntop(AF_INET6, + &((struct sockaddr_in6 *)addr)->sin6_addr, + addrstr, sizeof(addrstr)), + ntohs(((struct sockaddr_in6 *)addr)->sin6_port)); + break; + } + + return (msg); +} + int main(int argc, char **argv) { - int sd; - struct sockaddr_in lsin, from; - socklen_t length; + int sd, af; + struct sockaddr *lsin, *from; + struct sockaddr_in lsin4, from4; + struct sockaddr_in6 lsin6, from6; + socklen_t addrlen, length; char msg[BUFSIZ]; int n, ch, i; - while ((ch = getopt(argc, argv, "v")) != -1) { + while ((ch = getopt(argc, argv, "46v")) != -1) { switch (ch) { + case '4': + ipversion = 4; + break; + case '6': + ipversion = 6; + break; case 'v': verbose = 1; break; @@ -67,33 +101,43 @@ } } - sd = socket(AF_INET, SOCK_DGRAM, 0); - if (sd < 0) { - perror("socket"); - exit(EXIT_FAILURE); + if (ipversion == 4) { + af = AF_INET; + lsin = (struct sockaddr *)&lsin4; + from = (struct sockaddr *)&from4; + addrlen = sizeof(struct sockaddr_in); + + memset(&lsin4, 0, sizeof(lsin4)); + lsin4.sin_family = AF_INET; + lsin4.sin_addr.s_addr = INADDR_ANY; + lsin4.sin_port = htons(SERVER_PORT); + } else { + af = AF_INET6; + lsin = (struct sockaddr *)&lsin6; + from = (struct sockaddr *)&from6; + addrlen = sizeof(struct sockaddr_in6); + + memset(&lsin6, 0, sizeof(lsin6)); + lsin6.sin6_family = AF_INET6; + lsin6.sin6_addr = in6addr_any; + lsin6.sin6_port = htons(SERVER_PORT); } - memset(&lsin, 0, sizeof(lsin)); - lsin.sin_family = AF_INET; - lsin.sin_addr.s_addr = INADDR_ANY; - lsin.sin_port = htons(SERVER_PORT); - if (bind(sd, (struct sockaddr *)&lsin, sizeof(lsin)) < 0) { - perror("bind"); - exit(EXIT_FAILURE); - } + sd = socket(af, SOCK_DGRAM, 0); + if (sd < 0) + err(EXIT_FAILURE, "socket"); + + if (bind(sd, lsin, addrlen) < 0) + err(EXIT_FAILURE, "bind"); while (1) { - length = sizeof(from); - n = recvfrom(sd, msg, sizeof(msg), 0, - (struct sockaddr *)&from, &length); - if (n < 0) { - perror("recvfrom"); - exit(EXIT_FAILURE); - } + length = addrlen; + n = recvfrom(sd, msg, sizeof(msg), 0, from, &length); + if (n < 0) + err(EXIT_FAILURE, "recvfrom"); if (verbose) { - printf("from=%s:%d len=%d ", inet_ntoa(from.sin_addr), - ntohs(from.sin_port), n); + printf("from=%s len=%d ", addr2str(af, from), n); for (i = 0; i < n && msg[i]; i++) { if (isprint(msg[i])) printf("%c", msg[i]); From owner-svn-soc-all@FreeBSD.ORG Sat Jun 13 15:47:48 2015 Return-Path: Delivered-To: svn-soc-all@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F48D54E for ; Sat, 13 Jun 2015 15:47:48 +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 F11288ED for ; Sat, 13 Jun 2015 15:47:47 +0000 (UTC) (envelope-from iateaca@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5DFll8f052998 for ; Sat, 13 Jun 2015 15:47:47 GMT (envelope-from iateaca@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.9/8.14.9/Submit) id t5DFllwF052996 for svn-soc-all@FreeBSD.org; Sat, 13 Jun 2015 15:47:47 GMT (envelope-from iateaca@FreeBSD.org) Date: Sat, 13 Jun 2015 15:47:47 GMT Message-Id: <201506131547.t5DFllwF052996@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: r287036 - soc2015/iateaca/bhyve-ne2000-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.20 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, 13 Jun 2015 15:47:48 -0000 Author: iateaca Date: Sat Jun 13 15:47:46 2015 New Revision: 287036 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=287036 Log: implement a mechanism to transmit and receive packets using a tap interface Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Modified: soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c ============================================================================== --- soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Jun 13 14:24:31 2015 (r287035) +++ soc2015/iateaca/bhyve-ne2000-head/usr.sbin/bhyve/pci_ne2000.c Sat Jun 13 15:47:46 2015 (r287036) @@ -1,8 +1,14 @@ + +#include + #include #include +#include +#include #include "pci_emul.h" +#include "mevent.h" #include "if_edreg.h" /* @@ -56,6 +62,7 @@ uint8_t reset; /* State Variables */ + int tapfd; uint8_t lintr; uint8_t page; uint8_t remote_read; @@ -110,6 +117,14 @@ static int ne2000_reset_board(void); static int ne2000_software_reset(struct pci_ne2000_softc *sc); +static int +ne2000_tap_init(struct pci_ne2000_softc *sc, char *tap_name); +static int +ne2000_tap_tx(struct pci_ne2000_softc *sc, uint8_t tpsr, uint16_t tbcr); +static int +ne2000_tap_rx(struct pci_ne2000_softc *sc); +static void +ne2000_tap_callback(int fd, enum ev_type type, void *param); /* * NE2000 module function definitions @@ -171,9 +186,77 @@ } static int +ne2000_tap_init(struct pci_ne2000_softc *sc, char *tap_name) +{ + int err; + int opt = 1; + struct mevent *evf_read = NULL; + + assert(tap_name != NULL); + + sc->tapfd = open(tap_name, O_RDWR); + assert(sc->tapfd != -1); + + err = ioctl(sc->tapfd, FIONBIO, &opt); + assert(err >= 0); + + evf_read = mevent_add(sc->tapfd, EVF_READ, ne2000_tap_callback, sc); + assert(evf_read != NULL); + + DPRINTF("Tap interface: fd: %d, opt: %d", sc->tapfd, opt); + + return 0; +} + +static int +ne2000_tap_tx(struct pci_ne2000_softc *sc, uint8_t tpsr, uint16_t tbcr) +{ + ssize_t write_len; + + write_len = write(sc->tapfd, sc->ram + tpsr * ED_PAGE_SIZE, tbcr); + assert(write_len > 0 && write_len == tbcr); + + DPRINTF("Transmit Packet: from %d address of %d bytes", + tpsr * ED_PAGE_SIZE, tbcr); + + ne2000_set_field_by_offset(sc, NE2000_P0, ED_P0_ISR, + ED_ISR_PTX, ED_ISR_PTX); + pci_ne2000_update_intr(sc); + + return 0; +} + +static int +ne2000_tap_rx(struct pci_ne2000_softc *sc) +{ + uint8_t dummybuf[2048]; + ssize_t read_len; + + read_len = read(sc->tapfd, dummybuf, sizeof(dummybuf)); + + DPRINTF("Receive Packet: from tap interface of %zd bytes", read_len); + + return 0; +} + +static void +ne2000_tap_callback(int fd, enum ev_type type, void *param) +{ + int err; + struct pci_ne2000_softc *sc = (struct pci_ne2000_softc *)param; + assert(sc != NULL); + + err = ne2000_tap_rx(sc); + assert(err == 0); + + return; +} + +static int pci_ne2000_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { struct pci_ne2000_softc *sc = NULL; + int err; #if DEBUG_NE2000 == 1 dbg = fopen("/tmp/bhyve_ne2000.log", "w+"); @@ -187,6 +270,11 @@ pi->pi_arg = sc; sc->asc_pi = pi; + /* TODO - implement a better parsing of the input opts and get the name + * of the tap interface */ + err = ne2000_tap_init(sc, "/dev/tap0"); + assert(err == 0); + /* probe a RTL8029 PCI card as a generic NE2000 device */ pci_set_cfgdata16(pi, PCIR_DEVICE, 0x8029); pci_set_cfgdata16(pi, PCIR_VENDOR, 0x10ec); @@ -412,14 +500,8 @@ ED_P0_TBCR1); tbcr = tbcr0 | (tbcr1 << 8); - DPRINTF("Transmit Packet: from %d address of %d bytes", - tpsr * ED_PAGE_SIZE, tbcr); - - /* TODO send the packet on the tap interface */ - - ne2000_set_field_by_offset(sc, NE2000_P0, ED_P0_ISR, - ED_ISR_PTX, ED_ISR_PTX); - pci_ne2000_update_intr(sc); + err = ne2000_tap_tx(sc, tpsr, tbcr); + assert(err == 0); } break; case ED_P0_ISR: