From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 03:47:07 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id EA1A0E53 for ; Sun, 15 Sep 2013 03:47:07 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C8F262BB9 for ; Sun, 15 Sep 2013 03:47:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F3l70T059497 for ; Sun, 15 Sep 2013 03:47:07 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F3l7Wa059492 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 03:47:07 GMT (envelope-from ccqin@FreeBSD.org) Date: Sun, 15 Sep 2013 03:47:07 GMT Message-Id: <201309150347.r8F3l7Wa059492@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257356 - in soc2013/ccqin/head/sys: dev/ath net80211 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.14 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, 15 Sep 2013 03:47:08 -0000 Author: ccqin Date: Sun Sep 15 03:47:06 2013 New Revision: 257356 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257356 Log: Add ieee80211_ratectl_rc_info_get() to get the ieee80211_rc_info. If can be located in an mbuf, then use it; otherwise alloc a new one, zero it and attach it. * modify ath to use it. Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c soc2013/ccqin/head/sys/net80211/ieee80211_node.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Modified: soc2013/ccqin/head/sys/dev/ath/if_ath.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath.c Sun Sep 15 01:44:07 2013 (r257355) +++ soc2013/ccqin/head/sys/dev/ath/if_ath.c Sun Sep 15 03:47:06 2013 (r257356) @@ -4057,7 +4057,6 @@ struct ieee80211_node *ni = bf->bf_node; struct ath_node *an = NULL; struct ieee80211_rc_info *rc_info = NULL; - struct m_tag *mtag; ATH_TX_UNLOCK_ASSERT(sc); ATH_TXQ_UNLOCK_ASSERT(txq); @@ -4091,20 +4090,7 @@ (ts->ts_status == 0 ? 0 : 1)); #endif /* net80211 ratectl */ - mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: no ratectl mbuf tag found.\n", __func__); - struct ieee80211_rc_info tmp_rc_info; - rc_info = &tmp_rc_info; - bzero(rc_info, sizeof(rc_info)); - } else { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: found ratectl mbuf tag.\n", __func__); - rc_info = (struct ieee80211_rc_info*)(mtag + 1); - } - + rc_info = ieee80211_ratectl_rc_info_get(ni, bf->bf_m); ieee80211_ratectl_rc_info_set(rc_info, 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, Modified: soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c ============================================================================== --- soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sun Sep 15 01:44:07 2013 (r257355) +++ soc2013/ccqin/head/sys/dev/ath/if_ath_tx.c Sun Sep 15 03:47:06 2013 (r257356) @@ -1392,7 +1392,6 @@ struct ieee80211_node *ni = bf->bf_node; struct ieee80211_rc_info *rc_info = NULL; struct ieee80211_rc_series *rc = NULL; - struct m_tag *mtag; uint8_t rate, rix; int try0; @@ -1418,37 +1417,18 @@ #endif /* net80211 ratectl */ - mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); -again: - if (NULL == mtag) { - mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_RATECTL, - sizeof(struct ieee80211_rc_info), M_NOWAIT); - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: can't alloc mbuf tag for ratectl.\n", __func__); - goto again; - } - } else - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: nani? find mbuf tag for ratectl directly.\n", __func__); - - rc_info = (struct ieee80211_rc_info*)(mtag + 1); + rc_info = ieee80211_ratectl_rc_info_get(ni, bf->bf_m); rc = rc_info->iri_rc; - bzero(rc_info, sizeof(rc_info)); - + rc_info->iri_flags = 0; if (bf->bf_state.bfs_shpream) rc_info->iri_flags |= IEEE80211_RATECTL_INFO_SP; if (bf->bf_state.bfs_aggr) rc_info->iri_flags |= IEEE80211_RATECTL_INFO_AGGR; - rc_info->iri_framelen = bf->bf_state.bfs_pktlen; ieee80211_ratectl_rates(ni, rc_info); - m_tag_prepend(bf->bf_m, mtag); - rix = rc[0].rix; try0 = rc[0].tries; rate = ni->ni_txrate; @@ -4103,7 +4083,6 @@ struct ath_tid *atid = &an->an_tid[tid]; struct ath_tx_status *ts = &bf->bf_status.ds_txstat; struct ieee80211_rc_info *rc_info = NULL; - struct m_tag *mtag; /* The TID state is protected behind the TXQ lock */ ATH_TX_LOCK(sc); @@ -4162,25 +4141,13 @@ #endif /* net80211 ratectl */ - mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: no ratectl mbuf tag found.\n", __func__); - struct ieee80211_rc_info tmp_rc_info; - rc_info = &tmp_rc_info; - bzero(rc_info, sizeof(rc_info)); - } else { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: found ratectl mbuf tag.\n", __func__); - rc_info = (struct ieee80211_rc_info*)(mtag + 1); - } - rc_info->iri_flags &= ~IEEE80211_RATECTL_INFO_AGGR; + rc_info = ieee80211_ratectl_rc_info_get(ni, bf->bf_m); ieee80211_ratectl_rc_info_set(rc_info, 1, (ts->ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, ts->ts_shortretry, ts->ts_longretry, ts->ts_finaltsi, ts->ts_rate); + rc_info->iri_flags &= ~IEEE80211_RATECTL_INFO_AGGR; ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } @@ -4549,7 +4516,6 @@ ath_bufhead bf_cq; struct ath_tx_status ts = bf_first->bf_status.ds_txstat; struct ieee80211_rc_info *rc_info = NULL; - struct m_tag *mtag; TAILQ_INIT(&bf_q); TAILQ_INIT(&bf_cq); @@ -4566,21 +4532,9 @@ bf_first->bf_state.bfs_pktlen, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes); #endif + /* net80211 ratectl */ - mtag = m_tag_locate(bf_first->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: no ratectl mbuf tag found.\n", __func__); - struct ieee80211_rc_info tmp_rc_info; - rc_info = &tmp_rc_info; - bzero(rc_info, sizeof(rc_info)); - } else { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: found ratectl mbuf tag.\n", __func__); - rc_info = (struct ieee80211_rc_info*)(mtag + 1); - } - + rc_info = ieee80211_ratectl_rc_info_get(ni, bf_first->bf_m); ieee80211_ratectl_rc_info_set(rc_info, bf_first->bf_state.bfs_nframes, bf_first->bf_state.bfs_nframes, @@ -4731,8 +4685,7 @@ #endif int txseq; struct ieee80211_rc_info *rc_info = NULL; - struct m_tag *mtag; - + struct mbuf *m; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: called; hwq_depth=%d\n", __func__, atid->hwq_depth); @@ -4862,11 +4815,9 @@ memcpy(rc, bf_first->bf_state.bfs_rc, sizeof(rc)); #endif /* - * Get the net80211 ratectl mtag here, as bf_first will - * be set to NULL later. + * Get the mbuf here, as bf_first will be set to NULL later. */ - mtag = m_tag_locate(bf_first->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); + m = bf_first->bf_m; DPRINTF(sc, ATH_DEBUG_SW_TX_AGGR, "%s: txa_start=%d, tx_ok=%d, status=%.8x, flags=%.8x, " @@ -4990,23 +4941,12 @@ nbad); #endif /* net80211 ratectl */ - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: no ratectl mbuf tag found.\n", __func__); - struct ieee80211_rc_info tmp_rc_info; - rc_info = &tmp_rc_info; - bzero(rc_info, sizeof(rc_info)); - } else { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: found ratectl mbuf tag.\n", __func__); - rc_info = (struct ieee80211_rc_info*)(mtag + 1); - } - - rc_info->iri_flags |= IEEE80211_RATECTL_INFO_AGGR; + rc_info = ieee80211_ratectl_rc_info_get(ni, m); ieee80211_ratectl_rc_info_set(rc_info, nframes, nbad, pktlen, ts.ts_shortretry, ts.ts_longretry, ts.ts_finaltsi, ts.ts_rate); + rc_info->iri_flags |= IEEE80211_RATECTL_INFO_AGGR; ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } @@ -5083,7 +5023,6 @@ struct ath_tx_status ts; int drops = 0; struct ieee80211_rc_info *rc_info = NULL; - struct m_tag *mtag; /* * Take a copy of this; filtering/cloning the frame may free the @@ -5105,27 +5044,13 @@ bf->bf_state.bfs_pktlen, 1, (ts.ts_status == 0) ? 0 : 1); #endif - mtag = m_tag_locate(bf->bf_m, MTAG_ABI_NET80211, - NET80211_TAG_RATECTL, NULL); - - if (NULL == mtag) { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: no ratectl mbuf tag found.\n", __func__); - struct ieee80211_rc_info tmp_rc_info; - rc_info = &tmp_rc_info; - bzero(rc_info, sizeof(rc_info)); - } else { - IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, - "%s: found ratectl mbuf tag.\n", __func__); - rc_info = (struct ieee80211_rc_info*)(mtag + 1); - } - - rc_info->iri_flags &= ~IEEE80211_RATECTL_INFO_AGGR; + rc_info = ieee80211_ratectl_rc_info_get(ni, bf->bf_m); ieee80211_ratectl_rc_info_set(rc_info, 1, (ts.ts_status == 0 ? 0 : 1), bf->bf_state.bfs_pktlen, ts.ts_shortretry, ts.ts_longretry, ts.ts_finaltsi, ts.ts_rate); + rc_info->iri_flags &= ~IEEE80211_RATECTL_INFO_AGGR; ieee80211_ratectl_tx_complete(ni->ni_vap, ni, rc_info); } /* Modified: soc2013/ccqin/head/sys/net80211/ieee80211_node.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_node.c Sun Sep 15 01:44:07 2013 (r257355) +++ soc2013/ccqin/head/sys/net80211/ieee80211_node.c Sun Sep 15 03:47:06 2013 (r257356) @@ -1074,8 +1074,6 @@ ieee80211_ies_cleanup(&ni->ni_ies); ieee80211_psq_cleanup(&ni->ni_psq); free(ni, M_80211_NODE); - IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_RATECTL, - "%s: after free(ni, M_80211_NODE).\n", __func__); } static void @@ -1735,7 +1733,7 @@ * to use ni_ic below to reclaim resources. */ #if 0 - IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE, + IEEE80211_DPRINTF(vap, IEEE80211_MSG_NODE, "%s %p<%s> in %s table\n", __func__, ni, ether_sprintf(ni->ni_macaddr), nt != NULL ? nt->nt_name : ""); Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Sun Sep 15 01:44:07 2013 (r257355) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl.h Sun Sep 15 03:47:06 2013 (r257356) @@ -329,4 +329,31 @@ rc_info->iri_txrate = txrate; } +__inline static struct ieee80211_rc_info * +ieee80211_ratectl_rc_info_get(struct ieee80211_node *ni, + struct mbuf *m) +{ + struct m_tag *mtag; + + mtag = m_tag_locate(m, MTAG_ABI_NET80211, + NET80211_TAG_RATECTL, NULL); + + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: %sratectl mbuf tag found.\n", __func__, + (NULL == mtag? "no ":"")); +again: + if (NULL == mtag) { + mtag = m_tag_alloc(MTAG_ABI_NET80211, NET80211_TAG_RATECTL, + sizeof(struct ieee80211_rc_info), M_NOWAIT); + if (NULL == mtag) { + IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_RATECTL, ni, + "%s: can't alloc mbuf tag for ratectl.\n", __func__); + goto again; + } + bzero(mtag + 1, mtag->m_tag_len); + m_tag_prepend(m, mtag); + } + return (struct ieee80211_rc_info*)(mtag + 1); +} + #endif From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:48:15 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8471A185 for ; Sun, 15 Sep 2013 09:48:15 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 637972856 for ; Sun, 15 Sep 2013 09:48:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9mFNO004760 for ; Sun, 15 Sep 2013 09:48:15 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9mFBo004754 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:48:15 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:48:15 GMT Message-Id: <201309150948.r8F9mFBo004754@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257358 - soc2013/zcore/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.14 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, 15 Sep 2013 09:48:15 -0000 Author: zcore Date: Sun Sep 15 09:48:15 2013 New Revision: 257358 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257358 Log: adopt endian functions from Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 07:48:42 2013 (r257357) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:48:15 2013 (r257358) @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -163,30 +164,6 @@ }; #define ahci_ctx(sc) ((sc)->asc_pi->pi_vmctx) -static inline uint32_t cpu_to_be32(uint32_t val) -{ - return ((val & 0xff) << 24) | - ((val & 0xff00) << 8) | - ((val & 0xff0000) >> 8) | - ((val & 0xff000000) >> 24); -} - -static inline uint32_t cpu_to_be16(uint16_t val) -{ - return ((val & 0xff) << 8) | - ((val & 0xff00) >> 8); -} - -static inline uint16_t be16_to_cpu(uint8_t *val) -{ - return (val[0] << 8) | val[1]; -} - -static inline uint16_t be32_to_cpu(uint8_t *val) -{ - return (val[0] << 24) | (val[1] << 16) | (val[2] << 8) | val[3]; -} - static inline void lba_to_msf(uint8_t *buf, int lba) { lba += 150; @@ -639,12 +616,11 @@ { uint8_t buf[8]; uint64_t sectors; - uint32_t *ptr = (uint32_t *)buf; sectors = blockif_size(p->bctx) / blockif_sectsz(p->bctx); sectors >>= 2; - ptr[0] = cpu_to_be32(sectors - 1); - ptr[1] = cpu_to_be32(2048); + be32enc(buf, sectors - 1); + be32enc(buf + 4, 2048); cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; write_prdt(p, slot, cfis, buf, sizeof(buf)); ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); @@ -656,7 +632,7 @@ int len; uint8_t format, *acmd = cfis + 0x40; - len = be16_to_cpu(acmd + 7); + len = be16dec(acmd + 7); format = acmd[9] >> 6; switch (format) { case 0: @@ -706,11 +682,11 @@ lba_to_msf(bp, sectors); bp += 3; } else { - *(uint32_t *)bp = cpu_to_be32(sectors); + be32enc(bp, sectors); bp += 4; } size = bp - buf; - *(uint16_t*)buf = cpu_to_be16(size - 2); + be16enc(buf, size - 2); if (len > size) len = size; write_prdt(p, slot, cfis, buf, len); @@ -783,7 +759,7 @@ lba_to_msf(bp, sectors); bp += 3; } else { - *(uint32_t *)bp = cpu_to_be32(sectors); + be32enc(bp, sectors); bp += 4; } @@ -806,7 +782,7 @@ } size = bp - buf; - *(uint16_t*)buf = cpu_to_be16(size - 2); + be16enc(buf, size - 2); if (len > size) len = size; write_prdt(p, slot, cfis, buf, len); @@ -844,8 +820,8 @@ p->unhandled_read |= (1 << slot); return; } - lba = be32_to_cpu(acmd + 2); - len = be16_to_cpu(acmd + 7); + lba = be32dec(acmd + 2); + len = be16dec(acmd + 7); if (len == 0) { cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:48:50 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9DB2A1A1 for ; Sun, 15 Sep 2013 09:48:50 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 89BAD285F for ; Sun, 15 Sep 2013 09:48:50 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9mo43011437 for ; Sun, 15 Sep 2013 09:48:50 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9moDd011432 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:48:50 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:48:50 GMT Message-Id: <201309150948.r8F9moDd011432@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257359 - soc2013/zcore/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.14 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, 15 Sep 2013 09:48:50 -0000 Author: zcore Date: Sun Sep 15 09:48:50 2013 New Revision: 257359 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257359 Log: support ATAPI_REQUEST_SENSE Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:48:15 2013 (r257358) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:48:50 2013 (r257359) @@ -857,6 +857,26 @@ } static void +atapi_request_sense(struct ahci_port *p, int slot, uint8_t *cfis) +{ + int len; + uint8_t buf[64]; + uint8_t *acmd = cfis + 0x40; + + len = acmd[4]; + if (len > sizeof(buf)) + len = sizeof(buf); + memset(buf, 0, len); + buf[0] = 0x70 | (1 << 7); + buf[2] = p->sense_key; + buf[7] = 10; + buf[12] = p->asc; + write_prdt(p, slot, cfis, buf, len); + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); +} + +static void handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { uint8_t *acmd = cfis + 0x40; @@ -890,6 +910,9 @@ case ATAPI_READ_BIG: atapi_read(p, slot, cfis); break; + case ATAPI_REQUEST_SENSE: + atapi_request_sense(p, slot, cfis); + break; default: break; } From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:49:12 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E6F611B1 for ; Sun, 15 Sep 2013 09:49:12 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D4A8F2861 for ; Sun, 15 Sep 2013 09:49:12 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9nC3U015262 for ; Sun, 15 Sep 2013 09:49:12 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9nClW015257 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:49:12 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:49:12 GMT Message-Id: <201309150949.r8F9nClW015257@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257360 - soc2013/zcore/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.14 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, 15 Sep 2013 09:49:13 -0000 Author: zcore Date: Sun Sep 15 09:49:12 2013 New Revision: 257360 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257360 Log: fix used uninitialized Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:48:50 2013 (r257359) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:12 2013 (r257360) @@ -219,7 +219,7 @@ break; default: WPRINTF(("unsupported fis type %d\n", ft)); - break; + return; } memcpy(p->rfis + offset, fis, len); if (irq) { @@ -1573,8 +1573,10 @@ value = pci_ahci_host_read(sc, offset); else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) value = pci_ahci_port_read(sc, offset); - else + else { + value = 0; DPRINTF(("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset)); + } pthread_mutex_unlock(&sc->mtx); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:49:33 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B41261C2 for ; Sun, 15 Sep 2013 09:49:33 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A08432863 for ; Sun, 15 Sep 2013 09:49:33 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9nXq8019334 for ; Sun, 15 Sep 2013 09:49:33 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9nXuK019329 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:49:33 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:49:33 GMT Message-Id: <201309150949.r8F9nXuK019329@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257361 - soc2013/zcore/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.14 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, 15 Sep 2013 09:49:33 -0000 Author: zcore Date: Sun Sep 15 09:49:33 2013 New Revision: 257361 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257361 Log: consolidate debug printf Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:12 2013 (r257360) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:33 2013 (r257361) @@ -74,10 +74,13 @@ /* * Debug printf */ +#ifdef AHCI_DEBUG static FILE *dbg; #define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) -#define DPRINTF(params) dprintf params -#define WPRINTF(params) dprintf params +#else +#define dprintf(format, arg...) +#endif +#define wprintf printf struct ahci_ioreq { struct blockif_req io_req; @@ -188,7 +191,7 @@ sc->is |= (1 << i); } - DPRINTF(("%s %x\n", __func__, sc->is)); + dprintf("%s %x\n", __func__, sc->is); if (sc->is && (sc->ghc & AHCI_GHC_IE)) pci_generate_msi(sc->asc_pi, 0); } @@ -218,7 +221,7 @@ irq = 0; break; default: - WPRINTF(("unsupported fis type %d\n", ft)); + wprintf("unsupported fis type %d\n", ft); return; } memcpy(p->rfis + offset, fis, len); @@ -883,11 +886,12 @@ { int i; - dprintf("ACMD:\n"); + dprintf("ACMD:"); for (i = 0; i < 16; i++) dprintf("%02x ", acmd[i]); dprintf("\n"); } + switch (acmd[0]) { case ATAPI_TEST_UNIT_READY: cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; @@ -1004,7 +1008,7 @@ handle_packet_cmd(p, slot, cfis); break; default: - WPRINTF(("Unsupported cmd:%02x\n", cfis[2])); + wprintf("Unsupported cmd:%02x\n", cfis[2]); p->tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; p->is |= AHCI_P_IX_TFE; p->ci &= ~(1 << slot); @@ -1025,12 +1029,11 @@ sc = p->pr_sc; hdr = p->cmd_lst + slot * AHCI_CL_SIZE; cfl = (hdr->flags & 0x1f) * 4; - dprintf("cfis length:%d prdt entries: %d\n", cfl, hdr->prdtl); cfis = paddr_guest2host(ahci_ctx(sc), hdr->ctba, 0x80 + hdr->prdtl * sizeof(struct ahci_prdt_entry)); prdt = (struct ahci_prdt_entry *)(cfis + 0x80); - /* dump cfis, will be removed latter */ + dprintf("\ncfis:"); for (i = 0; i < cfl; i++) { if (i % 10 == 0) dprintf("\n"); @@ -1038,22 +1041,19 @@ } dprintf("\n"); - /* dump prdt, will be removed latter */ for (i = 0; i < hdr->prdtl; i++) { - dprintf("%d@%08"PRIx64", %d\n", prdt->dbc & 0x3fffff, prdt->dba, (prdt->dbc >> 31) & 0x1); + dprintf("%d@%08"PRIx64"\n", prdt->dbc & 0x3fffff, prdt->dba); prdt++; } if (cfis[0] != FIS_TYPE_REGH2D) { - WPRINTF(("Not a H2D FIS:%02x\n", cfis[0])); + wprintf("Not a H2D FIS:%02x\n", cfis[0]); return; } if (cfis[1] & 0x80) { - dprintf("command cfis\n"); handle_cmd(p, slot, cfis); } else { - dprintf("control cfis\n"); if (cfis[15] & (1 << 2)) p->reset = 1; else if (p->reset) { @@ -1092,7 +1092,7 @@ struct ahci_cmd_hdr *hdr; int ncq = 0; - DPRINTF(("%s %d\n", __func__, err)); + dprintf("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; @@ -1151,7 +1151,7 @@ } pthread_mutex_unlock(&sc->mtx); - DPRINTF(("%s exit\n", __func__)); + dprintf("%s exit\n", __func__); } static void @@ -1164,7 +1164,7 @@ struct ahci_ioreq *aior; struct ahci_cmd_hdr *hdr; - DPRINTF(("%s %d\n", __func__, err)); + dprintf("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; @@ -1212,7 +1212,7 @@ } pthread_mutex_unlock(&sc->mtx); - DPRINTF(("%s exit\n", __func__)); + dprintf("%s exit\n", __func__); } @@ -1255,9 +1255,9 @@ } str = cpy = strdup(opts); +#ifdef AHCI_DEBUG dbg = fopen("/tmp/log", "w+"); - DPRINTF(("pci_ahci initializing\n")); - +#endif sc = malloc(sizeof(struct pci_ahci_softc)); memset(sc, 0, sizeof(struct pci_ahci_softc)); pi->pi_arg = sc; @@ -1346,8 +1346,8 @@ offset = (offset - AHCI_OFFSET) % AHCI_STEP; struct ahci_port *p = &sc->port[port]; - DPRINTF(("pci_ahci_port %d: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", - port, offset, value)); + dprintf("pci_ahci_port %d: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", + port, offset, value); switch (offset) { case AHCI_P_CLB: p->clb = value; @@ -1408,7 +1408,7 @@ case AHCI_P_TFD: case AHCI_P_SIG: case AHCI_P_SSTS: - WPRINTF(("pci_ahci_port: read only registers 0x%"PRIx64"\n", offset)); + wprintf("pci_ahci_port: read only registers 0x%"PRIx64"\n", offset); break; case AHCI_P_SCTL: if (!(p->cmd & AHCI_P_CMD_ST)) { @@ -1437,15 +1437,15 @@ static void pci_ahci_host_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value) { - DPRINTF(("pci_ahci_host: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", - offset, value)); + dprintf("pci_ahci_host: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", + offset, value); switch (offset) { case AHCI_CAP: case AHCI_PI: case AHCI_VS: case AHCI_CAP2: - WPRINTF(("pci_ahci_host: read only registers 0x%"PRIx64"\n", offset)); + wprintf("pci_ahci_host: read only registers 0x%"PRIx64"\n", offset); break; case AHCI_GHC: if (value & AHCI_GHC_HR) @@ -1480,7 +1480,7 @@ else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) pci_ahci_port_write(sc, offset, value); else - DPRINTF(("pci_ahci: unknown i/o write offset 0x%"PRIx64"\n", offset)); + wprintf("pci_ahci: unknown i/o write offset 0x%"PRIx64"\n", offset); pthread_mutex_unlock(&sc->mtx); } @@ -1511,8 +1511,8 @@ value = 0; break; } - DPRINTF(("pci_ahci_host: read offset 0x%"PRIx64" value 0x%x\n", - offset, value)); + dprintf("pci_ahci_host: read offset 0x%"PRIx64" value 0x%x\n", + offset, value); return (value); } @@ -1551,8 +1551,8 @@ value = 0; break; } - DPRINTF(("pci_ahci_port %d: read offset 0x%"PRIx64" value 0x%x\n", - port, offset, value)); + dprintf("pci_ahci_port %d: read offset 0x%"PRIx64" value 0x%x\n", + port, offset, value); return value; } @@ -1575,7 +1575,7 @@ value = pci_ahci_port_read(sc, offset); else { value = 0; - DPRINTF(("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset)); + wprintf("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset); } pthread_mutex_unlock(&sc->mtx); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:49:56 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D1C321D3 for ; Sun, 15 Sep 2013 09:49:56 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BE58A2866 for ; Sun, 15 Sep 2013 09:49:56 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9nul5023943 for ; Sun, 15 Sep 2013 09:49:56 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9nutm023938 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:49:56 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:49:56 GMT Message-Id: <201309150949.r8F9nutm023938@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257362 - soc2013/zcore/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.14 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, 15 Sep 2013 09:49:56 -0000 Author: zcore Date: Sun Sep 15 09:49:56 2013 New Revision: 257362 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257362 Log: fix extra unnecessary interrupts Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:33 2013 (r257361) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:56 2013 (r257362) @@ -1363,7 +1363,6 @@ break; case AHCI_P_IS: p->is &= ~value; - ahci_generate_intr(sc); break; case AHCI_P_IE: p->ie = value & 0xFDC000FF; From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:50:16 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 021781E3 for ; Sun, 15 Sep 2013 09:50:16 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E3C5E2869 for ; Sun, 15 Sep 2013 09:50:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9oFjB033621 for ; Sun, 15 Sep 2013 09:50:15 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9oFod033607 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:50:15 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:50:15 GMT Message-Id: <201309150950.r8F9oFod033607@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257363 - soc2013/zcore/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.14 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, 15 Sep 2013 09:50:16 -0000 Author: zcore Date: Sun Sep 15 09:50:15 2013 New Revision: 257363 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257363 Log: claim we support Asynchronous Notification for ATAPI device Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:49:56 2013 (r257362) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:50:15 2013 (r257363) @@ -572,6 +572,7 @@ buf[67] = 100; buf[68] = 100; buf[76] = (1 << 2 | 1 << 1); + buf[78] = (1 << 5); buf[80] = (0x1f << 4); buf[82] = (1 << 4); buf[83] = (1 << 14); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:50:43 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 00ECA1F2 for ; Sun, 15 Sep 2013 09:50:42 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E1936286B for ; Sun, 15 Sep 2013 09:50:42 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9ogQh055475 for ; Sun, 15 Sep 2013 09:50:42 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9ogdM055458 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:50:42 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:50:42 GMT Message-Id: <201309150950.r8F9ogdM055458@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257364 - soc2013/zcore/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.14 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, 15 Sep 2013 09:50:43 -0000 Author: zcore Date: Sun Sep 15 09:50:42 2013 New Revision: 257364 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257364 Log: use self-defined OPCODES Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:50:15 2013 (r257363) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:50:42 2013 (r257364) @@ -72,6 +72,22 @@ }; /* + * SCSI opcodes + */ +#define TEST_UNIT_READY 0x00 +#define REQUEST_SENSE 0x03 +#define INQUIRY 0x12 +#define START_STOP_UNIT 0x1B +#define PREVENT_ALLOW 0x1E +#define READ_CAPACITY 0x25 +#define READ_10 0x28 +#define POSITION_TO_ELEMENT 0x2B +#define READ_TOC 0x43 +#define MODE_SENSE_10 0x5A +#define READ_12 0xA8 +#define READ_CD 0xBE + +/* * Debug printf */ #ifdef AHCI_DEBUG @@ -894,28 +910,28 @@ } switch (acmd[0]) { - case ATAPI_TEST_UNIT_READY: + case TEST_UNIT_READY: cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); break; - case ATAPI_INQUIRY: + case INQUIRY: atapi_inquiry(p, slot, cfis); break; - case ATAPI_READ_CAPACITY: + case READ_CAPACITY: atapi_read_capacity(p, slot, cfis); break; - case ATAPI_PREVENT_ALLOW: + case PREVENT_ALLOW: /* TODO */ cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); break; - case ATAPI_READ_TOC: + case READ_TOC: atapi_read_toc(p, slot, cfis); break; - case ATAPI_READ_BIG: + case READ_10: atapi_read(p, slot, cfis); break; - case ATAPI_REQUEST_SENSE: + case REQUEST_SENSE: atapi_request_sense(p, slot, cfis); break; default: From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:51:04 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D6112209 for ; Sun, 15 Sep 2013 09:51:04 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C34AA2893 for ; Sun, 15 Sep 2013 09:51:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9p4te073979 for ; Sun, 15 Sep 2013 09:51:04 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9p40D073974 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:51:04 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:51:04 GMT Message-Id: <201309150951.r8F9p40D073974@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257365 - soc2013/zcore/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.14 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, 15 Sep 2013 09:51:04 -0000 Author: zcore Date: Sun Sep 15 09:51:04 2013 New Revision: 257365 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257365 Log: support READ_12 Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:50:42 2013 (r257364) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:51:04 2013 (r257365) @@ -841,7 +841,10 @@ return; } lba = be32dec(acmd + 2); - len = be16dec(acmd + 7); + if (acmd[0] == READ_10) + len = be16dec(acmd + 7); + else + len = be32dec(acmd + 6); if (len == 0) { cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); @@ -929,6 +932,7 @@ atapi_read_toc(p, slot, cfis); break; case READ_10: + case READ_12: atapi_read(p, slot, cfis); break; case REQUEST_SENSE: From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 09:51:32 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4E5CA223 for ; Sun, 15 Sep 2013 09:51:32 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3A0BB2898 for ; Sun, 15 Sep 2013 09:51:32 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8F9pWRE079496 for ; Sun, 15 Sep 2013 09:51:32 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8F9pWuk079490 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 09:51:32 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 09:51:32 GMT Message-Id: <201309150951.r8F9pWuk079490@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257366 - soc2013/zcore/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.14 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, 15 Sep 2013 09:51:32 -0000 Author: zcore Date: Sun Sep 15 09:51:31 2013 New Revision: 257366 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257366 Log: support START_STOP_UNIT Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:51:04 2013 (r257365) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 09:51:31 2013 (r257366) @@ -258,7 +258,7 @@ fis[0] = error; fis[2] = tfd & 0x77; *(uint32_t *)(fis + 4) = (1 << slot); - if (error & ATA_S_ERROR) + if (fis[2] & ATA_S_ERROR) p->is |= AHCI_P_IX_TFE; p->tfd = tfd; p->ci &= ~(1 << slot); @@ -287,7 +287,7 @@ fis[11] = cfis[11]; fis[12] = cfis[12]; fis[13] = cfis[13]; - if (error & ATA_S_ERROR) + if (fis[2] & ATA_S_ERROR) p->is |= AHCI_P_IX_TFE; p->tfd = tfd; p->ci &= ~(1 << slot); @@ -900,6 +900,30 @@ } static void +atapi_start_stop_unit(struct ahci_port *p, int slot, uint8_t *cfis) +{ + uint32_t tfd; + uint8_t *acmd = cfis + 0x40; + + switch (acmd[4] & 3) { + case 0: + case 1: + case 3: + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + tfd = ATA_S_READY | ATA_S_DSC; + break; + case 2: + /* TODO eject media */ + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + p->sense_key = ATA_SENSE_ILLEGAL_REQUEST; + p->asc = 0x53; + tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR; + break; + } + ahci_write_fis_d2h(p, slot, cfis, tfd); +} + +static void handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { uint8_t *acmd = cfis + 0x40; @@ -938,6 +962,9 @@ case REQUEST_SENSE: atapi_request_sense(p, slot, cfis); break; + case START_STOP_UNIT: + atapi_start_stop_unit(p, slot, cfis); + break; default: break; } From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 14:07:17 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6D5836FE for ; Sun, 15 Sep 2013 14:07:17 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 40BD72365 for ; Sun, 15 Sep 2013 14:07:17 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FE7HbP019714 for ; Sun, 15 Sep 2013 14:07:17 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FE7HIK019709 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 14:07:17 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 15 Sep 2013 14:07:17 GMT Message-Id: <201309151407.r8FE7HIK019709@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257375 - soc2013/mattbw/backend/query 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.14 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, 15 Sep 2013 14:07:17 -0000 Author: mattbw Date: Sun Sep 15 14:07:16 2013 New Revision: 257375 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257375 Log: Split query check into two functions. Modified: soc2013/mattbw/backend/query/check.c Modified: soc2013/mattbw/backend/query/check.c ============================================================================== --- soc2013/mattbw/backend/query/check.c Sun Sep 15 13:50:56 2013 (r257374) +++ soc2013/mattbw/backend/query/check.c Sun Sep 15 14:07:16 2013 (r257375) @@ -35,6 +35,7 @@ /* Attempts to match a set of QueryIDs into packages. */ static bool string_match(const char *left, const char *right); +static bool check_metadata(const char *name, const char *namever, const char *repo, const char *arch, struct query_id *query_id); /* Returns true if the given package matches the given query ID. */ bool @@ -58,33 +59,42 @@ if (namever == NULL || arch == NULL || repo == NULL) { matches = false; } else { - bool namever_matches; - bool namever_matches_name; - bool namever_matches_namever; - bool arch_matches; - bool repo_matches; - - /* - * Allow raw names to match the Query ID namever, as well as - * the full package namevers. This allows Resolve to work - * properly. - */ - namever_matches_name = string_match(query_id->namever, name); - namever_matches_namever = string_match(query_id->namever, - namever); - namever_matches = (namever_matches_name || - namever_matches_namever); + matches = check_metadata(name, namever, repo, arch, query_id); + } - arch_matches = string_match(query_id->arch, arch); - repo_matches = string_match(query_id->repo, repo); + free(namever); + return matches; +} +static bool +check_metadata(const char *name, const char *namever, const char *repo, + const char *arch, struct query_id *query_id) +{ + bool namever_matches; + bool namever_matches_name; + bool namever_matches_namever; + bool arch_matches; + bool repo_matches; + + assert(name != NULL); + assert(namever != NULL); + assert(arch != NULL); + assert(repo != NULL); + assert(query_id != NULL); + assert(query_id->namever != NULL); - matches = (namever_matches && arch_matches && repo_matches); - } + /* + * Allow raw names to match the Query ID namever, as well as the full + * package namevers. This allows Resolve to work properly. + */ + namever_matches_name = string_match(query_id->namever, name); + namever_matches_namever = string_match(query_id->namever, namever); + namever_matches = (namever_matches_name || namever_matches_namever); - free(namever); + arch_matches = string_match(query_id->arch, arch); + repo_matches = string_match(query_id->repo, repo); - return matches; + return (namever_matches && arch_matches && repo_matches); } /* From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 14:30:24 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5A652C96 for ; Sun, 15 Sep 2013 14:30:24 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 46D9F2499 for ; Sun, 15 Sep 2013 14:30:24 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FEUOfO001465 for ; Sun, 15 Sep 2013 14:30:24 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FEUOi3001436 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 14:30:24 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 14:30:24 GMT Message-Id: <201309151430.r8FEUOi3001436@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257376 - soc2013/zcore/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.14 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, 15 Sep 2013 14:30:24 -0000 Author: zcore Date: Sun Sep 15 14:30:23 2013 New Revision: 257376 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257376 Log: simplify queue handling The max tag number is 32 and the blockif queue size is also 32, so the queue won't be full. Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c soc2013/zcore/head/usr.sbin/bhyve/block_if.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Sep 15 14:07:16 2013 (r257375) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Sep 15 14:30:23 2013 (r257376) @@ -54,6 +54,7 @@ enum blockop { BOP_READ, BOP_WRITE, + BOP_FLUSH, BOP_CANCEL }; @@ -132,6 +133,10 @@ br->br_offset) < 0) err = errno; break; + case BOP_FLUSH: + if (fsync(bc->bc_fd) < 0) + err = errno; + break; case BOP_CANCEL: err = EINTR; break; @@ -299,6 +304,14 @@ } int +blockif_flush(struct blockif_ctxt *bc) +{ + + assert(bc->bc_magic == BLOCKIF_SIG); + return (blockif_request(bc, NULL, BOP_FLUSH)); +} + +int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq) { @@ -335,14 +348,6 @@ return (0); } -int -blockif_fsync(struct blockif_ctxt *bc) -{ - - assert(bc->bc_magic == BLOCKIF_SIG); - return fsync(bc->bc_fd); -} - /* * Accessors */ Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sun Sep 15 14:07:16 2013 (r257375) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sun Sep 15 14:30:23 2013 (r257376) @@ -52,8 +52,8 @@ int blockif_is_ro(struct blockif_ctxt *bc); int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq); +int blockif_flush(struct blockif_ctxt *bc); int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_close(struct blockif_ctxt *bc); -int blockif_fsync(struct blockif_ctxt *bc); #endif /* _BLOCK_IF_H_ */ Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 14:07:16 2013 (r257375) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 14:30:23 2013 (r257376) @@ -115,10 +115,6 @@ int atapi; int reset; int mult_sectors; - int flush_pending; - uint32_t unhandled_read; - uint32_t unhandled_write; - pthread_cond_t flush_cond; uint8_t xfermode; uint8_t sense_key; uint8_t asc; @@ -146,7 +142,6 @@ */ struct ahci_ioreq *ioreq; int ioqsz; - int iofree; STAILQ_HEAD(ahci_fhead, ahci_ioreq) iofhd; }; @@ -392,14 +387,6 @@ cfis[2] == ATA_WRITE_FPDMA_QUEUED) readop = 0; - if (!p->iofree) { - if (readop) - p->unhandled_read |= (1 << slot); - else - p->unhandled_write |= (1 << slot); - return; - } - if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || cfis[2] == ATA_READ_FPDMA_QUEUED) { lba = ((uint64_t)cfis[10] << 40) | @@ -437,7 +424,6 @@ aior = STAILQ_FIRST(&p->iofhd); assert(aior != NULL); STAILQ_REMOVE_HEAD(&p->iofhd, io_list); - p->iofree--; aior->cfis = cfis; aior->slot = slot; aior->len = len; @@ -464,15 +450,21 @@ static void handle_flush(struct ahci_port *p, int slot, uint8_t *cfis) { - struct pci_ahci_softc *sc = p->pr_sc; + int err; + struct ahci_ioreq *aior; - if (p->unhandled_write) { - p->flush_pending = 1; - pthread_cond_wait(&p->flush_cond, &sc->mtx); - p->flush_pending = 0; - } - blockif_fsync(p->bctx); - ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC); + /* + * Pull request off free list + */ + aior = STAILQ_FIRST(&p->iofhd); + assert(aior != NULL); + STAILQ_REMOVE_HEAD(&p->iofhd, io_list); + aior->cfis = cfis; + aior->slot = slot; + aior->len = 0; + + err = blockif_flush(p->bctx); + assert(err == 0); } static inline void @@ -836,10 +828,6 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; - if (!p->iofree) { - p->unhandled_read |= (1 << slot); - return; - } lba = be32dec(acmd + 2); if (acmd[0] == READ_10) len = be16dec(acmd + 7); @@ -858,7 +846,6 @@ aior = STAILQ_FIRST(&p->iofhd); assert(aior != NULL); STAILQ_REMOVE_HEAD(&p->iofhd, io_list); - p->iofree--; aior->cfis = cfis; aior->slot = slot; aior->len = len; @@ -1175,28 +1162,6 @@ * Move the blockif request back to the free list */ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); - p->iofree++; - - /* - * If the number of oustanding commands has dropped below the - * threshold, see if more can be queued up - */ - if (p->ioqsz - p->iofree <= 2 && (p->cmd & AHCI_P_CMD_ST)) { - int i; - uint32_t unhandled = p->unhandled_read | p->unhandled_write; - for (i = 0; (i < 32) && unhandled; i++) { - if (!p->iofree) - break; - if (unhandled & (1 << i)) { - handle_slot(p, i); - unhandled &= ~(1 << i); - } - } - p->unhandled_read &= unhandled; - p->unhandled_write &= unhandled; - if (!p->unhandled_write && p->flush_pending) - pthread_cond_signal(&p->flush_cond); - } pthread_mutex_unlock(&sc->mtx); dprintf("%s exit\n", __func__); @@ -1239,25 +1204,6 @@ * Move the blockif request back to the free list */ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); - p->iofree++; - - /* - * If the number of oustanding commands has dropped below the - * threshold, see if more can be queued up - */ - if (p->ioqsz - p->iofree <= 2 && (p->cmd & AHCI_P_CMD_ST)) { - int i; - uint32_t unhandled = p->unhandled_read; - for (i = 0; (i < 32) && unhandled; i++) { - if (!p->iofree) - break; - if (unhandled & (1 << i)) { - handle_slot(p, i); - unhandled &= ~(1 << i); - } - } - p->unhandled_read &= unhandled; - } pthread_mutex_unlock(&sc->mtx); dprintf("%s exit\n", __func__); @@ -1286,7 +1232,6 @@ vr->io_req.br_callback = atapi_ioreq_cb; vr->io_req.br_param = vr; STAILQ_INSERT_TAIL(&pr->iofhd, vr, io_list); - pr->iofree++; } } @@ -1345,7 +1290,6 @@ sc->port[i].bctx = bctxt; sc->port[i].pr_sc = sc; - pthread_cond_init(&sc->port[i].flush_cond, NULL); /* * Allocate blockif request structures and add them * to the free list From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 14:58:07 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8718E155 for ; Sun, 15 Sep 2013 14:58:07 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5A2212585 for ; Sun, 15 Sep 2013 14:58:07 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FEw7R7040751 for ; Sun, 15 Sep 2013 14:58:07 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FEw7Sv040740 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 14:58:07 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 14:58:07 GMT Message-Id: <201309151458.r8FEw7Sv040740@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257377 - soc2013/zcore/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.14 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, 15 Sep 2013 14:58:07 -0000 Author: zcore Date: Sun Sep 15 14:58:07 2013 New Revision: 257377 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257377 Log: fix bug in last commit Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c soc2013/zcore/head/usr.sbin/bhyve/block_if.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Sep 15 14:30:23 2013 (r257376) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.c Sun Sep 15 14:58:07 2013 (r257377) @@ -304,11 +304,11 @@ } int -blockif_flush(struct blockif_ctxt *bc) +blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq) { assert(bc->bc_magic == BLOCKIF_SIG); - return (blockif_request(bc, NULL, BOP_FLUSH)); + return (blockif_request(bc, breq, BOP_FLUSH)); } int Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sun Sep 15 14:30:23 2013 (r257376) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Sun Sep 15 14:58:07 2013 (r257377) @@ -52,7 +52,7 @@ int blockif_is_ro(struct blockif_ctxt *bc); int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq); -int blockif_flush(struct blockif_ctxt *bc); +int blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq); int blockif_close(struct blockif_ctxt *bc); Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 14:30:23 2013 (r257376) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 14:58:07 2013 (r257377) @@ -452,6 +452,7 @@ { int err; struct ahci_ioreq *aior; + struct blockif_req *breq; /* * Pull request off free list @@ -462,8 +463,9 @@ aior->cfis = cfis; aior->slot = slot; aior->len = 0; + breq = &aior->io_req; - err = blockif_flush(p->bctx); + err = blockif_flush(p->bctx, breq); assert(err == 0); } From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 15:28:49 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CE5DD9AD for ; Sun, 15 Sep 2013 15:28:49 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A07912723 for ; Sun, 15 Sep 2013 15:28:49 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FFSn6G092752 for ; Sun, 15 Sep 2013 15:28:49 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FFSnYZ092742 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 15:28:49 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 15 Sep 2013 15:28:49 GMT Message-Id: <201309151528.r8FFSnYZ092742@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257380 - in soc2013/mattbw/backend: . query 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.14 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, 15 Sep 2013 15:28:49 -0000 Author: mattbw Date: Sun Sep 15 15:28:49 2013 New Revision: 257380 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257380 Log: Add basic error handling back into the query code. This should make the cases of `repo-list`ing non-installed packages and passing incorrect package IDs work properly. Added: soc2013/mattbw/backend/query/error.c soc2013/mattbw/backend/query/error.h Modified: soc2013/mattbw/backend/Makefile soc2013/mattbw/backend/query/depends.c soc2013/mattbw/backend/query/do.c soc2013/mattbw/backend/query/find.c soc2013/mattbw/backend/query/find.h soc2013/mattbw/backend/query/match.c soc2013/mattbw/backend/query/match.h Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/Makefile Sun Sep 15 15:28:49 2013 (r257380) @@ -56,6 +56,7 @@ query/check.c \ query/depends.c \ query/do.c \ + query/error.c \ query/find.c \ query/id.c \ query/match.c \ Modified: soc2013/mattbw/backend/query/depends.c ============================================================================== --- soc2013/mattbw/backend/query/depends.c Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/depends.c Sun Sep 15 15:28:49 2013 (r257380) @@ -27,6 +27,7 @@ #include "../pkgutils.h" /* pkgutils_... */ #include "../utils.h" /* ERR */ #include "depends.h" /* query_depends_... */ +#include "error.h" /* query_error_... */ #include "id.h" /* query_id, query_id_... */ #include "match.h" /* query_match_... */ @@ -110,12 +111,14 @@ static struct pkg * id_to_package(gchar *package_id, struct pkgdb *db, unsigned int load_flags) { + enum query_error error; struct pkg *package; struct query_id query_id; assert(package_id != NULL); assert(db != NULL); + error = QUERY_ERROR_OK; package = NULL; if (package_id != NULL) { @@ -123,7 +126,10 @@ success = query_id_from_package_id(package_id, &query_id); if (success) { - package = query_match_id(&query_id, db, load_flags); + package = query_match_id(&query_id, db, load_flags, + &error); + assert(error == QUERY_ERROR_OK || package != NULL); + assert(error != QUERY_ERROR_OK || package == NULL); } } return package; Modified: soc2013/mattbw/backend/query/do.c ============================================================================== --- soc2013/mattbw/backend/query/do.c Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/do.c Sun Sep 15 15:28:49 2013 (r257380) @@ -110,7 +110,6 @@ assert(db != NULL); assert(emitter != NULL); - success = false; packages = NULL; package_ids = get_strv_and_length(backend, "package_ids", &count); @@ -118,7 +117,14 @@ query_ids = to_query_ids(package_ids, count); if (query_ids != NULL) { - packages = query_match_ids(query_ids, count, db, load_flags); + enum query_error error; + + error = QUERY_ERROR_OK; + packages = query_match_ids(query_ids, count, db, load_flags, + &error); + success = query_error_handle(backend, error); + } else { + success = query_error_handle(backend, QUERY_ERROR_INVALID_IDS); } if (packages != NULL) { success = emit_packages(backend, db, emitter, packages, count); Added: soc2013/mattbw/backend/query/error.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query/error.c Sun Sep 15 15:28:49 2013 (r257380) @@ -0,0 +1,55 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include "../pk-backend.h" + +#include "../utils.h" /* ERR */ +#include "error.h" /* query_error */ + +/* Reports query errors on the backend. */ + +static const char *ERROR_STRINGS[QUERY_ERROR_COUNT] = { + "QUERY_ERROR_OK reported as error, this is an internal bug.", + "Cannot perform this action on a package from a remote repository.", + "No results were found.", + "The given PackageID(s) could not be interpreted." +}; + +static PkErrorEnum ERROR_ENUMS[QUERY_ERROR_COUNT] = { + PK_ERROR_ENUM_INTERNAL_ERROR, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, + PK_ERROR_ENUM_PACKAGE_NOT_FOUND, + PK_ERROR_ENUM_PACKAGE_ID_INVALID +}; + +bool +query_error_handle(PkBackend *backend, enum query_error error) +{ + + assert(backend != NULL); + assert(error < QUERY_ERROR_COUNT); + + if (error != QUERY_ERROR_OK) { + ERR(backend, ERROR_ENUMS[error], ERROR_STRINGS[error]); + } + return (error == QUERY_ERROR_OK); +} Added: soc2013/mattbw/backend/query/error.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/query/error.h Sun Sep 15 15:28:49 2013 (r257380) @@ -0,0 +1,37 @@ +/*- + * Copyright (C) 2013 Matt Windsor + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PKGNG_BACKEND_QUERY_ERROR_H_ +#define _PKGNG_BACKEND_QUERY_ERROR_H_ + +#include +#include "../pk-backend.h" + +enum query_error { + QUERY_ERROR_OK, + QUERY_ERROR_REMOTE_NOT_ALLOWED, + QUERY_ERROR_NO_RESULTS, + QUERY_ERROR_INVALID_IDS, + QUERY_ERROR_COUNT +}; + +bool query_error_handle(PkBackend *backend, enum query_error error); + +#endif /* !_PKGNG_BACKEND_QUERY_ERROR_H_ */ Modified: soc2013/mattbw/backend/query/find.c ============================================================================== --- soc2013/mattbw/backend/query/find.c Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/find.c Sun Sep 15 15:28:49 2013 (r257380) @@ -26,39 +26,45 @@ #include "../utils.h" /* INTENTIONALLY_IGNORE */ #include "find.h" /* query_find_... */ -#include "id.h" /* struct query_id */ +#include "id.h" /* struct spec->query_id */ static bool can_remote_iterate(struct query_id *query_id, unsigned int load_flags); struct pkgdb_it * -query_find_local(struct query_id *query_id, struct pkgdb *db, - unsigned int load_flags) +query_find_local(struct query_find_spec *spec) { - assert(query_id != NULL); - assert(db != NULL); - INTENTIONALLY_IGNORE(load_flags); - return pkgdb_query(db, query_id->namever, MATCH_EXACT); + assert(spec != NULL); + assert(spec->query_id != NULL); + assert(spec->db != NULL); + return pkgdb_query(spec->db, spec->query_id->namever, MATCH_EXACT); } struct pkgdb_it * -query_find_remote(struct query_id *query_id, struct pkgdb *db, - unsigned int load_flags) +query_find_remote(struct query_find_spec *spec) { struct pkgdb_it *iterator; - assert(query_id != NULL); - assert(db != NULL); - iterator = pkgdb_rquery(db, query_id->namever, MATCH_EXACT, - query_id->repo); + assert(spec != NULL); + assert(spec->query_id != NULL); + assert(spec->db != NULL); + assert(spec->error_p != NULL); + iterator = pkgdb_rquery(spec->db, spec->query_id->namever, MATCH_EXACT, + spec->query_id->repo); /* * Make sure we can use this iterator. (We only check now so that * the case of there being no remote matches is properly handled.) */ - if (!(iterator == NULL || can_remote_iterate(query_id, load_flags))) { - pkgdb_it_free(iterator); - iterator = NULL; + if (iterator != NULL) { + if (!can_remote_iterate(spec->query_id, spec->load_flags)) { + pkgdb_it_free(iterator); + iterator = NULL; + + *(spec->error_p) = QUERY_ERROR_REMOTE_NOT_ALLOWED; + } + } else { + *(spec->error_p) = QUERY_ERROR_NO_RESULTS; } return iterator; } Modified: soc2013/mattbw/backend/query/find.h ============================================================================== --- soc2013/mattbw/backend/query/find.h Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/find.h Sun Sep 15 15:28:49 2013 (r257380) @@ -23,8 +23,19 @@ #include "pkg.h" /* struct pkgdb */ #include "id.h" /* struct query_id */ +#include "error.h" /* enum query_error */ -struct pkgdb_it *query_find_local(struct query_id *query_id, struct pkgdb *db, unsigned int load_flags); -struct pkgdb_it *query_find_remote(struct query_id *query_id, struct pkgdb *db, unsigned int load_flags); +struct query_find_spec { + unsigned int load_flags; + + enum query_error *error_p; + struct pkgdb *db; + struct query_id *query_id; +}; + +typedef struct pkgdb_it *(*query_find_function) (struct query_find_spec *spec); + +struct pkgdb_it *query_find_local(struct query_find_spec *spec); +struct pkgdb_it *query_find_remote(struct query_find_spec *spec); #endif /* !_PKGNG_BACKEND_QUERY_FIND_H_ */ Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/match.c Sun Sep 15 15:28:49 2013 (r257380) @@ -33,14 +33,12 @@ /* Attempts to match a set of QueryIDs into packages. */ -typedef struct pkgdb_it *(*query_func_ptr) (struct query_id *id, struct pkgdb *db, unsigned int load_flags); - -static struct pkg *query_match_from(query_func_ptr function, struct pkgdb *db, struct query_id *query_id, unsigned int load_flags); -static struct pkg *match_iterator(struct pkgdb_it *it, struct query_id *query_id, unsigned int load_flags); +static struct pkg *query_match_from(query_find_function function, struct query_find_spec *spec); +static struct pkg *match_iterator(struct pkgdb_it *it, struct query_find_spec *spec); struct pkg ** query_match_ids(struct query_id *query_ids, unsigned int count, - struct pkgdb *db, unsigned int load_flags) + struct pkgdb *db, unsigned int load_flags, enum query_error *error_p) { bool success; unsigned int i; @@ -48,6 +46,7 @@ assert(query_ids != NULL); assert(db != NULL); + assert(error_p != NULL); packages = query_packages_array_alloc(count); success = (packages != NULL); @@ -60,7 +59,8 @@ */ break; } - packages[i] = query_match_id(query_ids + i, db, load_flags); + packages[i] = query_match_id(query_ids + i, db, load_flags, + error_p); success = (packages[i] != NULL); } @@ -74,52 +74,58 @@ * Takes a QueryID and attempts to retrieve its corresponding package. */ struct pkg * -query_match_id(struct query_id *query_id, struct pkgdb *db, unsigned int load_flags) +query_match_id(struct query_id *query_id, struct pkgdb *db, + unsigned int load_flags, enum query_error *error_p) { bool try_local; bool try_remote; enum repo_type type; struct pkg *package; + struct query_find_spec spec; assert(query_id != NULL); assert(db != NULL); + assert(error_p != NULL); + + spec.query_id = query_id; + spec.db = db; + spec.error_p = error_p; + spec.load_flags = load_flags; /* * If we're not given a specific repository in the PackageID, we want * to try searching locally first and then remotely; otherwise which * database we query depends on the repository we have been given. */ - type = repo_type(query_id->repo); + type = repo_type(spec.query_id->repo); try_local = (type != REPO_REMOTE); try_remote = (type != REPO_LOCAL); package = NULL; if (try_local) { - package = query_match_from(query_find_local, db, query_id, load_flags); + package = query_match_from(query_find_local, &spec); } if (package == NULL && try_remote) { - package = query_match_from(query_find_remote, db, query_id, load_flags); + package = query_match_from(query_find_remote, &spec); } return package; } /* Takes a querying function and attempts to find a QueryID using it. */ static struct pkg * -query_match_from(query_func_ptr function, struct pkgdb *db, - struct query_id *query_id, unsigned int load_flags) +query_match_from(query_find_function function, struct query_find_spec *spec) { struct pkg *result; struct pkgdb_it *iterator; assert(function != NULL); - assert(db != NULL); - assert(query_id != NULL); + assert(spec != NULL); result = NULL; - iterator = function(query_id, db, load_flags); + iterator = function(spec); if (iterator != NULL) { - result = match_iterator(iterator, query_id, load_flags); + result = match_iterator(iterator, spec); pkgdb_it_free(iterator); } return result; @@ -130,19 +136,20 @@ * package if one matches, or NULL if none do. */ static struct pkg * -match_iterator(struct pkgdb_it *it, struct query_id *query_id, - unsigned int load_flags) +match_iterator(struct pkgdb_it *it, struct query_find_spec *spec) { bool success; struct pkg *pkg; assert(it != NULL); + assert(spec != NULL); + assert(spec->query_id != NULL); success = false; pkg = NULL; - while (pkgdb_it_next(it, &pkg, load_flags) == EPKG_OK) { - success = query_check_package(pkg, query_id); + while (pkgdb_it_next(it, &pkg, spec->load_flags) == EPKG_OK) { + success = query_check_package(pkg, spec->query_id); /* Did it match? */ if (success) { break; Modified: soc2013/mattbw/backend/query/match.h ============================================================================== --- soc2013/mattbw/backend/query/match.h Sun Sep 15 14:51:23 2013 (r257379) +++ soc2013/mattbw/backend/query/match.h Sun Sep 15 15:28:49 2013 (r257380) @@ -24,9 +24,10 @@ #include #include "pkg.h" +#include "error.h" /* enum query_error */ #include "id.h" /* struct query_id */ -struct pkg *query_match_id(struct query_id *query_id, struct pkgdb *db, unsigned int load_flags); -struct pkg **query_match_ids(struct query_id *query_ids, unsigned int count, struct pkgdb *db, unsigned int load_flags); +struct pkg *query_match_id(struct query_id *query_id, struct pkgdb *db, unsigned int load_flags, enum query_error *error_p); +struct pkg **query_match_ids(struct query_id *query_ids, unsigned int count, struct pkgdb *db, unsigned int load_flags, enum query_error *error_p); #endif /* !_PKGNG_BACKEND_QUERY_MATCH_H_ */ From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 15:32:32 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0A2669EF for ; Sun, 15 Sep 2013 15:32:32 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EB19A2760 for ; Sun, 15 Sep 2013 15:32:31 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FFWVWg031098 for ; Sun, 15 Sep 2013 15:32:31 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FFWVOs031095 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 15:32:31 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 15 Sep 2013 15:32:31 GMT Message-Id: <201309151532.r8FFWVOs031095@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257381 - in soc2013/mattbw/backend: jobs query 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.14 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, 15 Sep 2013 15:32:32 -0000 Author: mattbw Date: Sun Sep 15 15:32:31 2013 New Revision: 257381 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257381 Log: Add "no results found" query error reporting too. Modified: soc2013/mattbw/backend/jobs/core.c soc2013/mattbw/backend/query/match.c Modified: soc2013/mattbw/backend/jobs/core.c ============================================================================== --- soc2013/mattbw/backend/jobs/core.c Sun Sep 15 15:28:49 2013 (r257380) +++ soc2013/mattbw/backend/jobs/core.c Sun Sep 15 15:32:31 2013 (r257381) @@ -147,7 +147,7 @@ const char *detail; #ifndef __clang__ - detail = "Detail message not set." + detail = "Detail message not set."; #endif switch (status) { Modified: soc2013/mattbw/backend/query/match.c ============================================================================== --- soc2013/mattbw/backend/query/match.c Sun Sep 15 15:28:49 2013 (r257380) +++ soc2013/mattbw/backend/query/match.c Sun Sep 15 15:32:31 2013 (r257381) @@ -108,6 +108,9 @@ if (package == NULL && try_remote) { package = query_match_from(query_find_remote, &spec); } + if (package == NULL) { + *error_p = QUERY_ERROR_NO_RESULTS; + } return package; } From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 15:33:44 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8E73BA02 for ; Sun, 15 Sep 2013 15:33:44 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6D1172765 for ; Sun, 15 Sep 2013 15:33:44 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FFXieB039328 for ; Sun, 15 Sep 2013 15:33:44 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FFXieE039323 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 15:33:44 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 15:33:44 GMT Message-Id: <201309151533.r8FFXieE039323@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257382 - soc2013/zcore/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.14 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, 15 Sep 2013 15:33:44 -0000 Author: zcore Date: Sun Sep 15 15:33:44 2013 New Revision: 257382 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257382 Log: s/dprintf/DPRINTF and s/wprintf/WPRINTF also make WPRINTF bugless Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 15:32:31 2013 (r257381) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 15:33:44 2013 (r257382) @@ -92,11 +92,11 @@ */ #ifdef AHCI_DEBUG static FILE *dbg; -#define dprintf(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) +#define DPRINTF(format, arg...) do{fprintf(dbg, format, ##arg);fflush(dbg);}while(0) #else -#define dprintf(format, arg...) +#define DPRINTF(format, arg...) #endif -#define wprintf printf +#define WPRINTF(format, arg...) printf(format, ##arg) struct ahci_ioreq { struct blockif_req io_req; @@ -202,7 +202,7 @@ sc->is |= (1 << i); } - dprintf("%s %x\n", __func__, sc->is); + DPRINTF("%s %x\n", __func__, sc->is); if (sc->is && (sc->ghc & AHCI_GHC_IE)) pci_generate_msi(sc->asc_pi, 0); } @@ -232,7 +232,7 @@ irq = 0; break; default: - wprintf("unsupported fis type %d\n", ft); + WPRINTF("unsupported fis type %d\n", ft); return; } memcpy(p->rfis + offset, fis, len); @@ -919,10 +919,10 @@ { int i; - dprintf("ACMD:"); + DPRINTF("ACMD:"); for (i = 0; i < 16; i++) - dprintf("%02x ", acmd[i]); - dprintf("\n"); + DPRINTF("%02x ", acmd[i]); + DPRINTF("\n"); } switch (acmd[0]) { @@ -1045,7 +1045,7 @@ handle_packet_cmd(p, slot, cfis); break; default: - wprintf("Unsupported cmd:%02x\n", cfis[2]); + WPRINTF("Unsupported cmd:%02x\n", cfis[2]); p->tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; p->is |= AHCI_P_IX_TFE; p->ci &= ~(1 << slot); @@ -1070,21 +1070,21 @@ 0x80 + hdr->prdtl * sizeof(struct ahci_prdt_entry)); prdt = (struct ahci_prdt_entry *)(cfis + 0x80); - dprintf("\ncfis:"); + DPRINTF("\ncfis:"); for (i = 0; i < cfl; i++) { if (i % 10 == 0) - dprintf("\n"); - dprintf("%02x ", cfis[i]); + DPRINTF("\n"); + DPRINTF("%02x ", cfis[i]); } - dprintf("\n"); + DPRINTF("\n"); for (i = 0; i < hdr->prdtl; i++) { - dprintf("%d@%08"PRIx64"\n", prdt->dbc & 0x3fffff, prdt->dba); + DPRINTF("%d@%08"PRIx64"\n", prdt->dbc & 0x3fffff, prdt->dba); prdt++; } if (cfis[0] != FIS_TYPE_REGH2D) { - wprintf("Not a H2D FIS:%02x\n", cfis[0]); + WPRINTF("Not a H2D FIS:%02x\n", cfis[0]); return; } @@ -1129,7 +1129,7 @@ struct ahci_cmd_hdr *hdr; int ncq = 0; - dprintf("%s %d\n", __func__, err); + DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; @@ -1166,7 +1166,7 @@ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); pthread_mutex_unlock(&sc->mtx); - dprintf("%s exit\n", __func__); + DPRINTF("%s exit\n", __func__); } static void @@ -1179,7 +1179,7 @@ struct ahci_ioreq *aior; struct ahci_cmd_hdr *hdr; - dprintf("%s %d\n", __func__, err); + DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; @@ -1208,7 +1208,7 @@ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); pthread_mutex_unlock(&sc->mtx); - dprintf("%s exit\n", __func__); + DPRINTF("%s exit\n", __func__); } @@ -1340,7 +1340,7 @@ offset = (offset - AHCI_OFFSET) % AHCI_STEP; struct ahci_port *p = &sc->port[port]; - dprintf("pci_ahci_port %d: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", + DPRINTF("pci_ahci_port %d: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", port, offset, value); switch (offset) { case AHCI_P_CLB: @@ -1401,7 +1401,7 @@ case AHCI_P_TFD: case AHCI_P_SIG: case AHCI_P_SSTS: - wprintf("pci_ahci_port: read only registers 0x%"PRIx64"\n", offset); + WPRINTF("pci_ahci_port: read only registers 0x%"PRIx64"\n", offset); break; case AHCI_P_SCTL: if (!(p->cmd & AHCI_P_CMD_ST)) { @@ -1430,7 +1430,7 @@ static void pci_ahci_host_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value) { - dprintf("pci_ahci_host: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", + DPRINTF("pci_ahci_host: write offset 0x%"PRIx64" value 0x%"PRIx64"\n", offset, value); switch (offset) { @@ -1438,7 +1438,7 @@ case AHCI_PI: case AHCI_VS: case AHCI_CAP2: - wprintf("pci_ahci_host: read only registers 0x%"PRIx64"\n", offset); + WPRINTF("pci_ahci_host: read only registers 0x%"PRIx64"\n", offset); break; case AHCI_GHC: if (value & AHCI_GHC_HR) @@ -1473,7 +1473,7 @@ else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP) pci_ahci_port_write(sc, offset, value); else - wprintf("pci_ahci: unknown i/o write offset 0x%"PRIx64"\n", offset); + WPRINTF("pci_ahci: unknown i/o write offset 0x%"PRIx64"\n", offset); pthread_mutex_unlock(&sc->mtx); } @@ -1504,7 +1504,7 @@ value = 0; break; } - dprintf("pci_ahci_host: read offset 0x%"PRIx64" value 0x%x\n", + DPRINTF("pci_ahci_host: read offset 0x%"PRIx64" value 0x%x\n", offset, value); return (value); @@ -1544,7 +1544,7 @@ value = 0; break; } - dprintf("pci_ahci_port %d: read offset 0x%"PRIx64" value 0x%x\n", + DPRINTF("pci_ahci_port %d: read offset 0x%"PRIx64" value 0x%x\n", port, offset, value); return value; @@ -1568,7 +1568,7 @@ value = pci_ahci_port_read(sc, offset); else { value = 0; - wprintf("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset); + WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset); } pthread_mutex_unlock(&sc->mtx); From owner-svn-soc-all@FreeBSD.ORG Sun Sep 15 15:54:34 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9DCB5FC5 for ; Sun, 15 Sep 2013 15:54:34 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 89F7E2854 for ; Sun, 15 Sep 2013 15:54:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8FFsYe9013827 for ; Sun, 15 Sep 2013 15:54:34 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8FFsYkV013815 for svn-soc-all@FreeBSD.org; Sun, 15 Sep 2013 15:54:34 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 15 Sep 2013 15:54:34 GMT Message-Id: <201309151554.r8FFsYkV013815@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257383 - soc2013/zcore/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.14 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, 15 Sep 2013 15:54:34 -0000 Author: zcore Date: Sun Sep 15 15:54:34 2013 New Revision: 257383 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257383 Log: make slots equeal the blockif queue size Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 15:33:44 2013 (r257382) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Sun Sep 15 15:54:34 2013 (r257383) @@ -1240,7 +1240,7 @@ static int pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts) { - int i, ret = 0; + int i, slots, ret = 0; struct pci_ahci_softc *sc; char *str, *cpy, *fstr; @@ -1302,11 +1302,12 @@ pthread_mutex_init(&sc->mtx, NULL); /* Intel Cougar Point AHCI */ + slots = sc->port[0].ioqsz - 1; sc->cap = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| AHCI_CAP_PMD | AHCI_CAP_SSC | AHCI_CAP_PSC | - (0x1f << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_SXS | (sc->ports - 1); + (slots << AHCI_CAP_NCS_SHIFT) | AHCI_CAP_SXS | (sc->ports - 1); sc->pi = (1 << sc->ports) - 1; sc->vs = 0x10300; sc->cap2 = AHCI_CAP2_APST; From owner-svn-soc-all@FreeBSD.ORG Mon Sep 16 01:05:35 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 7D1F1CF8 for ; Mon, 16 Sep 2013 01:05:35 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6860020AE for ; Mon, 16 Sep 2013 01:05:35 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8G15Ze7019306 for ; Mon, 16 Sep 2013 01:05:35 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8G15Z8u019296 for svn-soc-all@FreeBSD.org; Mon, 16 Sep 2013 01:05:35 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 16 Sep 2013 01:05:35 GMT Message-Id: <201309160105.r8G15Z8u019296@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257392 - soc2013/bguan/head/sys/dev/xen/usbfront 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.14 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, 16 Sep 2013 01:05:35 -0000 Author: bguan Date: Mon Sep 16 01:05:35 2013 New Revision: 257392 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257392 Log: debug method xenhci_roothub_exec() for xen usb host controller Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Sep 16 00:06:54 2013 (r257391) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Sep 16 01:05:35 2013 (r257392) @@ -93,92 +93,1424 @@ #define XENHCI_INTR_ENDPT 1 extern struct usb_bus_methods xenhci_bus_methods; +extern struct usb_pipe_methods xenhci_device_generic_methods; +static void xenhci_timeout(void *); +static void xenhci_device_done(struct usb_xfer *, usb_error_t); + /* static void -xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) +xenhci_iterate_hw_softc(struct usb_bus *bus, usb_bus_mem_sub_cb_t *cb) +{ + //TODO need this method()? +}*/ + +usb_error_t +xenhci_start_controller(struct xenhci_softc *sc) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_start_controller()\n"); + #endif + //TODO + /* catch any lost interrupts */ + xenhci_do_poll(&sc->sc_bus); + + return (0); +} + +usb_error_t +xenhci_halt_controller(struct xenhci_softc *sc) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_halt_controller()\n"); + #endif + //TODO + return (0); +} + +usb_error_t +xenhci_init(struct xenhci_softc *sc, device_t dev) +{ + /* initialise some bus fields */ + sc->sc_bus.parent = dev; + + /* set up the bus struct */ + sc->sc_bus.methods = &xenhci_bus_methods; + + /* setup devices array */ + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = XENHCI_MAX_DEVICES; + + /* get all DMA memory */ + //if (usb_bus_mem_alloc_all(&sc->sc_bus, + // USB_GET_DMA_TAG(dev), &xenhci_iterate_hw_softc)) { + if (usb_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(dev), NULL)) { + return (ENOMEM); + } + + return (0); +} + +void +xenhci_uninit(struct xenhci_softc *sc) +{ + /* TODO? + * NOTE: At this point the control transfer process is gone + * and "xenhci_configure_msg" is no longer called. Consequently + * waiting for the configuration messages to complete is not + * needed. + */ + usb_bus_mem_free_all(&sc->sc_bus, NULL); +} + +static void +xenhci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_set_hw_power_sleep()\n"); + #endif + //TODO + struct xenhci_softc *sc = XENHCI_BUS2SC(bus); + + switch (state) { + case USB_HW_POWER_SUSPEND: + DPRINTF("Stopping the XENHCI\n"); + xenhci_halt_controller(sc); + break; + case USB_HW_POWER_SHUTDOWN: + DPRINTF("Stopping the XENHCI\n"); + xenhci_halt_controller(sc); + break; + case USB_HW_POWER_RESUME: + DPRINTF("Starting the XENHCI\n"); + xenhci_start_controller(sc); + break; + default: + break; + } +} + +static usb_error_t +xenhci_generic_done_sub(struct usb_xfer *xfer) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_generic_done_sub()\n"); + #endif + + struct xenhci_td *td; + struct xenhci_td *td_alt_next; + uint32_t len; + uint8_t status; + + td = xfer->td_transfer_cache; + td_alt_next = td->alt_next; + + if (xfer->aframes != xfer->nframes) + usbd_xfer_set_frame_len(xfer, xfer->aframes, 0); + + while (1) { + + usb_pc_cpu_invalidate(td->page_cache); + + status = td->status; + len = td->remainder; + + DPRINTFN(4, "xfer=%p[%u/%u] rem=%u/%u status=%u\n", + xfer, (unsigned int)xfer->aframes, + (unsigned int)xfer->nframes, + (unsigned int)len, (unsigned int)td->len, + (unsigned int)status); + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xfer=%p[%u/%u] rem=%u/%u status=%u\n", + xfer, (unsigned int)xfer->aframes, + (unsigned int)xfer->nframes, + (unsigned int)len, (unsigned int)td->len, + (unsigned int)status); + #endif + + /* + * Verify the status length and + * add the length to "frlengths[]": + */ + if (len > td->len) { + /* should not happen */ + DPRINTF("Invalid status length, " + "0x%04x/0x%04x bytes\n", len, td->len); + + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]Invalid status length, " + "0x%04x/0x%04x bytes\n", len, td->len); + #endif + + status = XENHCI_TRB_ERROR_LENGTH; + } else if (xfer->aframes != xfer->nframes) { + xfer->frlengths[xfer->aframes] += td->len - len; + } + /* Check for last transfer */ + if (((void *)td) == xfer->td_transfer_last) { + td = NULL; + break; + } + /* Check for transfer error */ + if (status != XENHCI_TRB_ERROR_SHORT_PKT && + status != XENHCI_TRB_ERROR_SUCCESS) { + /* the transfer is finished */ + td = NULL; + break; + } + /* Check for short transfer */ + if (len > 0) { + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr || + xfer->flags_int.control_xfr) { + /* follow alt next */ + td = td->alt_next; + } else { + /* the transfer is finished */ + td = NULL; + } + break; + } + td = td->obj_next; + + if (td->alt_next != td_alt_next) { + /* this USB frame is complete */ + break; + } + } + + /* update transfer cache */ + + xfer->td_transfer_cache = td; + + return ((status == XENHCI_TRB_ERROR_STALL) ? USB_ERR_STALLED : + (status != XENHCI_TRB_ERROR_SHORT_PKT && + status != XENHCI_TRB_ERROR_SUCCESS) ? USB_ERR_IOERROR : + USB_ERR_NORMAL_COMPLETION); +} + +static void +xenhci_generic_done(struct usb_xfer *xfer) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_generic_done()\n"); + #endif + + usb_error_t err = 0; + + DPRINTFN(13, "xfer=%p endpoint=%p transfer done\n", + xfer, xfer->endpoint); + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xfer=%p endpoint=%p transfer done\n", + xfer, xfer->endpoint); + #endif + + /* reset scanner */ + xfer->td_transfer_cache = xfer->td_transfer_first; + + if (xfer->flags_int.control_xfr) { + if (xfer->flags_int.control_hdr) + err = xenhci_generic_done_sub(xfer); + + xfer->aframes = 1; + + if (xfer->td_transfer_cache == NULL) + goto done; + } + + while (xfer->aframes != xfer->nframes) { + + err = xenhci_generic_done_sub(xfer); + xfer->aframes++; + + if (xfer->td_transfer_cache == NULL) + goto done; + } + + if (xfer->flags_int.control_xfr && + !xfer->flags_int.control_act) + err = xenhci_generic_done_sub(xfer); +done: + /* transfer is complete */ + //xhci_device_done(xfer, err); +} + +static void +xenhci_activate_transfer(struct usb_xfer *xfer) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_activate_transfer()\n"); + #endif + + struct xenhci_td *td; + + td = xfer->td_transfer_cache; + + usb_pc_cpu_invalidate(td->page_cache); + + if (!(td->td_trb[0].dwTrb3 & htole32(XENHCI_TRB_3_CYCLE_BIT))) { + + /* activate the transfer */ + td->td_trb[0].dwTrb3 |= htole32(XENHCI_TRB_3_CYCLE_BIT); + usb_pc_cpu_flush(td->page_cache); + + //xhci_endpoint_doorbell(xfer);//? + } +} + +static void +xenhci_skip_transfer(struct usb_xfer *xfer) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_skip_transfer()\n"); + #endif + + struct xenhci_td *td; + struct xenhci_td *td_last; + + td = xfer->td_transfer_cache; + td_last = xfer->td_transfer_last; + + td = td->alt_next; + + usb_pc_cpu_invalidate(td->page_cache); + + if (!(td->td_trb[0].dwTrb3 & htole32(XENHCI_TRB_3_CYCLE_BIT))) { + + usb_pc_cpu_invalidate(td_last->page_cache); + + /* copy LINK TRB to current waiting location */ + td->td_trb[0].qwTrb0 = td_last->td_trb[td_last->ntrb].qwTrb0; + td->td_trb[0].dwTrb2 = td_last->td_trb[td_last->ntrb].dwTrb2; + usb_pc_cpu_flush(td->page_cache); + + td->td_trb[0].dwTrb3 = td_last->td_trb[td_last->ntrb].dwTrb3; + usb_pc_cpu_flush(td->page_cache); + + //xhci_endpoint_doorbell(xfer);//? + } +} + +/*------------------------------------------------------------------------* + * xenhci_check_transfer + *------------------------------------------------------------------------*/ +static void +xenhci_check_transfer(struct xenhci_softc *sc, struct xenhci_trb *trb) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_check_transfer()\n"); + #endif + + struct xenhci_endpoint_ext *pepext; + int64_t offset; + uint64_t td_event; + uint32_t temp; + uint32_t remainder; + uint16_t stream_id; + uint16_t i; + uint8_t status; + uint8_t halted; + uint8_t epno; + uint8_t index; + + /* decode TRB */ + td_event = le64toh(trb->qwTrb0); + temp = le32toh(trb->dwTrb2); + + remainder = XENHCI_TRB_2_REM_GET(temp); + + status = XENHCI_TRB_2_ERROR_GET(temp); + stream_id = XENHCI_TRB_2_STREAM_GET(temp); + + temp = le32toh(trb->dwTrb3); + epno = XENHCI_TRB_3_EP_GET(temp); + index = XENHCI_TRB_3_SLOT_GET(temp); + + /* check if error means halted */ + halted = (status != XENHCI_TRB_ERROR_SHORT_PKT && + status != XENHCI_TRB_ERROR_SUCCESS); + + DPRINTF("slot=%u epno=%u stream=%u remainder=%u status=%u\n", + index, epno, stream_id, remainder, status); + #ifdef XENUSB_BEBUG + printf("[gbtest]slot=%u epno=%u stream=%u remainder=%u status=%u\n", + index, epno, stream_id, remainder, status); + #endif + + if (index > sc->sc_noslot) { + DPRINTF("Invalid slot.\n"); + return; + } + + if ((epno == 0) || (epno >= XENHCI_MAX_ENDPOINTS)) { + DPRINTF("Invalid endpoint.\n"); + return; + } + + pepext = &sc->sc_hw.devs[index].endp[epno]; + + if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS) { + stream_id = 0; + DPRINTF("stream_id=0\n"); + } else if (stream_id >= XENHCI_MAX_STREAMS) { + DPRINTF("Invalid stream ID.\n"); + return; + } + + /* try to find the USB transfer that generated the event */ + for (i = 0; i != (XENHCI_MAX_TRANSFERS - 1); i++) { + struct usb_xfer *xfer; + struct xenhci_td *td; + + xfer = pepext->xfer[i + (XENHCI_MAX_TRANSFERS * stream_id)]; + if (xfer == NULL) + continue; + + td = xfer->td_transfer_cache; + + DPRINTFN(5, "Checking if 0x%016llx == (0x%016llx .. 0x%016llx)\n", + (long long)td_event, + (long long)td->td_self, + (long long)td->td_self + sizeof(td->td_trb)); + #ifdef XENUSB_BEBUG + printf("[gbtest]Checking if 0x%016llx == (0x%016llx .. 0x%016llx)\n", + (long long)td_event, + (long long)td->td_self, + (long long)td->td_self + sizeof(td->td_trb)); + #endif + + /* + * NOTE: Some XENHCI implementations might not trigger + * an event on the last LINK TRB so we need to + * consider both the last and second last event + * address as conditions for a successful transfer. + * + * NOTE: We assume that the XENHCI will only trigger one + * event per chain of TRBs. + */ + + offset = td_event - td->td_self; + + if (offset >= 0 && + offset < (int64_t)sizeof(td->td_trb)) { + + usb_pc_cpu_invalidate(td->page_cache); + + /* compute rest of remainder, if any */ + for (i = (offset / 16) + 1; i < td->ntrb; i++) { + temp = le32toh(td->td_trb[i].dwTrb2); + remainder += XENHCI_TRB_2_BYTES_GET(temp); + } + + DPRINTFN(5, "New remainder: %u\n", remainder); + + /* clear isochronous transfer errors */ + if (xfer->flags_int.isochronous_xfr) { + if (halted) { + halted = 0; + status = XENHCI_TRB_ERROR_SUCCESS; + remainder = td->len; + } + } + + /* "td->remainder" is verified later */ + td->remainder = remainder; + td->status = status; + + usb_pc_cpu_flush(td->page_cache); + + /* + * 1) Last transfer descriptor makes the + * transfer done + */ + if (((void *)td) == xfer->td_transfer_last) { + DPRINTF("TD is last\n"); + xenhci_generic_done(xfer); + break; + } + + /* + * 2) Any kind of error makes the transfer + * done + */ + if (halted) { + DPRINTF("TD has I/O error\n"); + xenhci_generic_done(xfer); + break; + } + + /* + * 3) If there is no alternate next transfer, + * a short packet also makes the transfer done + */ + if (td->remainder > 0) { + if (td->alt_next == NULL) { + DPRINTF( + "short TD has no alternate next\n"); + xenhci_generic_done(xfer); + break; + } + DPRINTF("TD has short pkt\n"); + if (xfer->flags_int.short_frames_ok || + xfer->flags_int.isochronous_xfr || + xfer->flags_int.control_xfr) { + /* follow the alt next */ + xfer->td_transfer_cache = td->alt_next; + xenhci_activate_transfer(xfer); + break; + } + xenhci_skip_transfer(xfer); + xenhci_generic_done(xfer); + break; + } + + /* + * 4) Transfer complete - go to next TD + */ + DPRINTF("Following next TD\n"); + xfer->td_transfer_cache = td->obj_next; + xenhci_activate_transfer(xfer); + break; /* there should only be one match */ + } + } +} + +static void +xenhci_check_command(struct xenhci_softc *sc, struct xenhci_trb *trb) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_check_command()\n"); + #endif + + if (sc->sc_cmd_addr == trb->qwTrb0) { + DPRINTF("Received command event\n"); + sc->sc_cmd_result[0] = trb->dwTrb2; + sc->sc_cmd_result[1] = trb->dwTrb3; + cv_signal(&sc->sc_cmd_cv); + } +} + +static void +xenhci_interrupt_poll(struct xenhci_softc *sc) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_interrupt_poll()\n"); + #endif + + struct usb_page_search buf_res; + struct xenhci_hw_root *phwr; + //uint64_t addr; + uint32_t temp; + uint16_t i; + uint8_t event; + uint8_t j; + uint8_t k; + uint8_t t; + + usbd_get_page(&sc->sc_hw.root_pc, 0, &buf_res); + + phwr = buf_res.buffer; + + /* Receive any events */ + + usb_pc_cpu_invalidate(&sc->sc_hw.root_pc); + + i = sc->sc_event_idx; + j = sc->sc_event_ccs; + t = 2; + + while (1) { + + temp = le32toh(phwr->hwr_events[i].dwTrb3); + + k = (temp & XENHCI_TRB_3_CYCLE_BIT) ? 1 : 0; + + if (j != k) + break; + + event = XENHCI_TRB_3_TYPE_GET(temp); + + DPRINTFN(10, "event[%u] = %u (0x%016llx 0x%08lx 0x%08lx)\n", + i, event, (long long)le64toh(phwr->hwr_events[i].qwTrb0), + (long)le32toh(phwr->hwr_events[i].dwTrb2), + (long)le32toh(phwr->hwr_events[i].dwTrb3)); + #ifdef XENUSB_BEBUG + printf("[gbtest]event[%u] = %u (0x%016llx 0x%08lx 0x%08lx)\n", + i, event, (long long)le64toh(phwr->hwr_events[i].qwTrb0), + (long)le32toh(phwr->hwr_events[i].dwTrb2), + (long)le32toh(phwr->hwr_events[i].dwTrb3)); + #endif + + switch (event) { + case XENHCI_TRB_EVENT_TRANSFER: + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: XENHCI_TRB_EVENT_TRANSFER\n"); + #endif + xenhci_check_transfer(sc, &phwr->hwr_events[i]); + break; + case XENHCI_TRB_EVENT_CMD_COMPLETE: + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: XENHCI_TRB_EVENT_CMD_COMPLETE\n"); + #endif + xenhci_check_command(sc, &phwr->hwr_events[i]); + break; + default: + DPRINTF("Unhandled event = %u\n", event); + break; + } + + i++; + + if (i == XENHCI_MAX_EVENTS) { + i = 0; + j ^= 1; + + /* check for timeout */ + if (!--t) + break; + } + } + + sc->sc_event_idx = i; + sc->sc_event_ccs = j; + + /* + * NOTE: The Event Ring Dequeue Pointer Register is 64-bit + * latched. That means to activate the register we need to + * write both the low and high double word of the 64-bit + * register. + */ + + //addr = (uint32_t)buf_res.physaddr; + //addr += (uintptr_t)&((struct xhci_hw_root *)0)->hwr_events[i]; + + /* try to clear busy bit */ + //addr |= XHCI_ERDP_LO_BUSY; + + //XWRITE4(sc, runt, XHCI_ERDP_LO(0), (uint32_t)addr); + //XWRITE4(sc, runt, XHCI_ERDP_HI(0), (uint32_t)(addr >> 32)); +} + + +/*------------------------------------------------------------------------* + * xenhci_timeout - XENHCI timeout handler + *------------------------------------------------------------------------*/ +static void +xenhci_timeout(void *arg) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_timeout()\n"); + #endif + + struct usb_xfer *xfer = arg; + + DPRINTF("xfer=%p\n", xfer); + + USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED); + + /* transfer is transferred */ + xenhci_device_done(xfer, USB_ERR_TIMEOUT); +} + +static void +xenhci_do_poll(struct usb_bus *bus) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_do_poll()\n"); + #endif + + struct xenhci_softc *sc = XENHCI_BUS2SC(bus); + + USB_BUS_LOCK(&sc->sc_bus); + xenhci_interrupt_poll(sc); + USB_BUS_UNLOCK(&sc->sc_bus); +} + +static usb_error_t +xenhci_set_address(struct usb_device *udev, struct mtx *mtx, uint16_t address) +{ + #ifdef XENUSB_BEBUG + printf("[xenusb_debug]xenhci.c: xenhci_set_address()\n"); + #endif + //TODO + return (0); +} + + + + + +/*------------------------------------------------------------------------* + * + */ +static void +xenhci_setup_generic_chain_sub(struct xenhci_std_temp *temp) +{ + struct usb_page_search buf_res; + struct xenhci_td *td; + struct xenhci_td *td_next; + struct xenhci_td *td_alt_next; + struct xenhci_td *td_first; + uint32_t buf_offset; + uint32_t average; + uint32_t len_old; + uint32_t npkt_off; + uint32_t dword; + uint8_t shortpkt_old; + uint8_t precompute; + uint8_t x; + + td_alt_next = NULL; + buf_offset = 0; + shortpkt_old = temp->shortpkt; + len_old = temp->len; + npkt_off = 0; + precompute = 1; + +restart: + + td = temp->td; + td_next = td_first = temp->td_next; + + while (1) { + + if (temp->len == 0) { + + if (temp->shortpkt) + break; + + /* send a Zero Length Packet, ZLP, last */ + + temp->shortpkt = 1; + average = 0; + + } else { + + average = temp->average; + + if (temp->len < average) { + if (temp->len % temp->max_packet_size) { + temp->shortpkt = 1; + } + average = temp->len; + } + } + + if (td_next == NULL) + panic("%s: out of XHCI transfer descriptors!", __FUNCTION__); + + /* get next TD */ + + td = td_next; + td_next = td->obj_next; + + /* check if we are pre-computing */ + + if (precompute) { + + /* update remaining length */ + + temp->len -= average; + + continue; + } + /* fill out current TD */ + + td->len = average; + td->remainder = 0; + td->status = 0; + + /* update remaining length */ + + temp->len -= average; + + /* reset TRB index */ + + x = 0; + + if (temp->trb_type == XENHCI_TRB_TYPE_SETUP_STAGE) { + /* immediate data */ + + if (average > 8) + average = 8; + + td->td_trb[0].qwTrb0 = 0; + + usbd_copy_out(temp->pc, temp->offset + buf_offset, + (uint8_t *)(uintptr_t)&td->td_trb[0].qwTrb0, + average); + + dword = XENHCI_TRB_2_BYTES_SET(8) | + XENHCI_TRB_2_TDSZ_SET(0) | + XENHCI_TRB_2_IRQ_SET(0); + + td->td_trb[0].dwTrb2 = htole32(dword); + + dword = XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_SETUP_STAGE) | + XENHCI_TRB_3_IDT_BIT | XENHCI_TRB_3_CYCLE_BIT; + + /* check wLength */ + if (td->td_trb[0].qwTrb0 & + htole64(XENHCI_TRB_0_WLENGTH_MASK)) { + if (td->td_trb[0].qwTrb0 & htole64(1)) + dword |= XENHCI_TRB_3_TRT_IN; + else + dword |= XENHCI_TRB_3_TRT_OUT; + } + + td->td_trb[0].dwTrb3 = htole32(dword); +#ifdef USB_DEBUG + xhci_dump_trb(&td->td_trb[x]); +#endif + x++; + + } else do { + + uint32_t npkt; + + /* fill out buffer pointers */ + + if (average == 0) { + npkt = 0; + memset(&buf_res, 0, sizeof(buf_res)); + } else { + usbd_get_page(temp->pc, temp->offset + + buf_offset, &buf_res); + + /* get length to end of page */ + if (buf_res.length > average) + buf_res.length = average; + + /* check for maximum length */ + if (buf_res.length > XENHCI_TD_PAGE_SIZE) + buf_res.length = XENHCI_TD_PAGE_SIZE; + + npkt_off += buf_res.length; + + /* setup npkt */ + npkt = (len_old - npkt_off + temp->max_packet_size - 1) / + temp->max_packet_size; + + if (npkt > 31) + npkt = 31; + } + + /* fill out TRB's */ + td->td_trb[x].qwTrb0 = + htole64((uint64_t)buf_res.physaddr); + + dword = + XENHCI_TRB_2_BYTES_SET(buf_res.length) | + XENHCI_TRB_2_TDSZ_SET(npkt) | + XENHCI_TRB_2_IRQ_SET(0); + + td->td_trb[x].dwTrb2 = htole32(dword); + + switch (temp->trb_type) { + case XENHCI_TRB_TYPE_ISOCH: + /* BEI: Interrupts are inhibited until EOT */ + dword = XENHCI_TRB_3_CHAIN_BIT | XENHCI_TRB_3_CYCLE_BIT | + XENHCI_TRB_3_BEI_BIT | + XENHCI_TRB_3_TBC_SET(temp->tbc) | + XENHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (td != td_first) { + dword |= XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_NORMAL); + } else if (temp->do_isoc_sync != 0) { + temp->do_isoc_sync = 0; + /* wait until "isoc_frame" */ + dword |= XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_ISOCH) | + XENHCI_TRB_3_FRID_SET(temp->isoc_frame / 8); + } else { + /* start data transfer at next interval */ + dword |= XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_ISOCH) | + XENHCI_TRB_3_ISO_SIA_BIT; + } + if (temp->direction == UE_DIR_IN) + dword |= XENHCI_TRB_3_DIR_IN | XENHCI_TRB_3_ISP_BIT; + break; + case XENHCI_TRB_TYPE_DATA_STAGE: + dword = XENHCI_TRB_3_CHAIN_BIT | XENHCI_TRB_3_CYCLE_BIT | + XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_DATA_STAGE) | + XENHCI_TRB_3_TBC_SET(temp->tbc) | + XENHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XENHCI_TRB_3_DIR_IN | XENHCI_TRB_3_ISP_BIT; + break; + case XENHCI_TRB_TYPE_STATUS_STAGE: + dword = XENHCI_TRB_3_CHAIN_BIT | XENHCI_TRB_3_CYCLE_BIT | + XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_STATUS_STAGE) | + XENHCI_TRB_3_TBC_SET(temp->tbc) | + XENHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XHCI_TRB_3_DIR_IN; + break; + default: /* XENHCI_TRB_TYPE_NORMAL */ + /* BEI: Interrupts are inhibited until EOT */ + dword = XENHCI_TRB_3_CHAIN_BIT | XENHCI_TRB_3_CYCLE_BIT | + XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_NORMAL) | + XENHCI_TRB_3_BEI_BIT | + XENHCI_TRB_3_TBC_SET(temp->tbc) | + XENHCI_TRB_3_TLBPC_SET(temp->tlbpc); + if (temp->direction == UE_DIR_IN) + dword |= XENHCI_TRB_3_DIR_IN | XENHCI_TRB_3_ISP_BIT; + break; + } + td->td_trb[x].dwTrb3 = htole32(dword); + + average -= buf_res.length; + buf_offset += buf_res.length; +#ifdef USB_DEBUG + xhci_dump_trb(&td->td_trb[x]); +#endif + x++; + + } while (average != 0); + + td->td_trb[x-1].dwTrb3 |= htole32(XENHCI_TRB_3_IOC_BIT); + + /* store number of data TRB's */ + + td->ntrb = x; + + DPRINTF("NTRB=%u\n", x); + + /* fill out link TRB */ + + if (td_next != NULL) { + /* link the current TD with the next one */ + td->td_trb[x].qwTrb0 = htole64((uint64_t)td_next->td_self); + DPRINTF("LINK=0x%08llx\n", (long long)td_next->td_self); + } else { + /* this field will get updated later */ + DPRINTF("NOLINK\n"); + } + + dword = XENHCI_TRB_2_IRQ_SET(0); + + td->td_trb[x].dwTrb2 = htole32(dword); + + dword = XENHCI_TRB_3_TYPE_SET(XENHCI_TRB_TYPE_LINK) | + XENHCI_TRB_3_CYCLE_BIT | XENHCI_TRB_3_IOC_BIT; + + td->td_trb[x].dwTrb3 = htole32(dword); + + td->alt_next = td_alt_next; +#ifdef USB_DEBUG + xhci_dump_trb(&td->td_trb[x]); +#endif + usb_pc_cpu_flush(td->page_cache); + } + + if (precompute) { + precompute = 0; + + /* setup alt next pointer, if any */ + if (temp->last_frame) { + td_alt_next = NULL; + } else { + /* we use this field internally */ + td_alt_next = td_next; + } + + /* restore */ + temp->shortpkt = shortpkt_old; + temp->len = len_old; + goto restart; + } + + /* + * Remove cycle bit from the first TRB if we are + * stepping them: + */ + if (temp->step_td != 0) { + td_first->td_trb[0].dwTrb3 &= ~htole32(XENHCI_TRB_3_CYCLE_BIT); + usb_pc_cpu_flush(td_first->page_cache); + } + + /* remove chain bit because this is the last TRB in the chain */ + td->td_trb[td->ntrb - 1].dwTrb2 &= ~htole32(XENHCI_TRB_2_TDSZ_SET(15)); + td->td_trb[td->ntrb - 1].dwTrb3 &= ~htole32(XENHCI_TRB_3_CHAIN_BIT); + + usb_pc_cpu_flush(td->page_cache); + + temp->td = td; + temp->td_next = td_next; +} + +static void +xenhci_setup_generic_chain(struct usb_xfer *xfer) { - //TODO need this method()? -}*/ + //struct xhci_std_temp temp; + struct xenhci_td *td; + uint32_t x; + uint32_t y; + uint8_t mult; + + temp.do_isoc_sync = 0; + temp.step_td = 0; + temp.tbc = 0; + temp.tlbpc = 0; + temp.average = xfer->max_hc_frame_size; + temp.max_packet_size = xfer->max_packet_size; + temp.sc = XHCI_BUS2SC(xfer->xroot->bus); + temp.pc = NULL; + temp.last_frame = 0; + temp.offset = 0; + temp.multishort = xfer->flags_int.isochronous_xfr || + xfer->flags_int.control_xfr || + xfer->flags_int.short_frames_ok; + + /* toggle the DMA set we are using */ + xfer->flags_int.curr_dma_set ^= 1; + + /* get next DMA set */ + td = xfer->td_start[xfer->flags_int.curr_dma_set]; + + temp.td = NULL; + temp.td_next = td; + + xfer->td_transfer_first = td; + xfer->td_transfer_cache = td; + + if (xfer->flags_int.isochronous_xfr) { + uint8_t shift; + + /* compute multiplier for ISOCHRONOUS transfers */ + mult = xfer->endpoint->ecomp ? + UE_GET_SS_ISO_MULT(xfer->endpoint->ecomp->bmAttributes) + : 0; + /* check for USB 2.0 multiplier */ + if (mult == 0) { + mult = (xfer->endpoint->edesc-> *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Mon Sep 16 01:16:02 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D48F7EA2 for ; Mon, 16 Sep 2013 01:16:02 +0000 (UTC) (envelope-from bguan@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C01B12119 for ; Mon, 16 Sep 2013 01:16:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8G1G2kD049634 for ; Mon, 16 Sep 2013 01:16:02 GMT (envelope-from bguan@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8G1G2xR049632 for svn-soc-all@FreeBSD.org; Mon, 16 Sep 2013 01:16:02 GMT (envelope-from bguan@FreeBSD.org) Date: Mon, 16 Sep 2013 01:16:02 GMT Message-Id: <201309160116.r8G1G2xR049632@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to bguan@FreeBSD.org using -f From: bguan@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257393 - soc2013/bguan/head/sys/dev/xen/usbfront 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.14 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, 16 Sep 2013 01:16:02 -0000 Author: bguan Date: Mon Sep 16 01:16:02 2013 New Revision: 257393 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257393 Log: do the USB transfer for xen usb host controller Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Modified: soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c ============================================================================== --- soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Sep 16 01:05:35 2013 (r257392) +++ soc2013/bguan/head/sys/dev/xen/usbfront/xenhci.c Mon Sep 16 01:16:02 2013 (r257393) @@ -2337,7 +2337,7 @@ .device_resume = xenhci_device_resume, //TODO .device_suspend = xenhci_device_suspend, //TODO .set_hw_power = xenhci_set_hw_power, //TODO - .roothub_exec = xenhci_roothub_exec, //ok + .roothub_exec = xenhci_roothub_exec, //ok .xfer_poll = xenhci_do_poll, //TODO .start_dma_delay = xenhci_start_dma_delay, .set_address = xenhci_set_address, //not primary From owner-svn-soc-all@FreeBSD.ORG Mon Sep 16 06:39:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E2195D68 for ; Mon, 16 Sep 2013 06:39:34 +0000 (UTC) (envelope-from syuu@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CD61520AD for ; Mon, 16 Sep 2013 06:39:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8G6dYNw041772 for ; Mon, 16 Sep 2013 06:39:34 GMT (envelope-from syuu@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8G6dYPI041742 for svn-soc-all@FreeBSD.org; Mon, 16 Sep 2013 06:39:34 GMT (envelope-from syuu@FreeBSD.org) Date: Mon, 16 Sep 2013 06:39:34 GMT Message-Id: <201309160639.r8G6dYPI041742@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to syuu@FreeBSD.org using -f From: syuu@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257395 - in soc2013/syuu/bhyve_usb/usr.sbin/bhyve: . usb usb/gpl usb/include usb/include/hw 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.14 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, 16 Sep 2013 06:39:35 -0000 Author: syuu Date: Mon Sep 16 06:39:34 2013 New Revision: 257395 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257395 Log: import iov.[ch], import trace_* functions, enable usb_device_* calls, testing bootup GuestOS with uhci & usb-serial Added: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/hexdump.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/iov.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/iov.h soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/trace.h Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/dev-hub.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/bus.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/desc.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/dev-serial.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/hcd-uhci.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/host-libusb.c soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/include/hw/usb.h Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/Makefile Mon Sep 16 06:39:34 2013 (r257395) @@ -19,7 +19,7 @@ CFLAGS+=-I${.CURDIR}/usb/include -I${.CURDIR} SRCS+= core.c hcd-uhci.c host-libusb.c dev-hub.c .PATH: ${.CURDIR}/usb/gpl -SRCS+= desc.c dev-serial.c bus.c +SRCS+= desc.c dev-serial.c bus.c iov.c hexdump.c NO_MAN= Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/core.c Mon Sep 16 06:39:34 2013 (r257395) @@ -27,31 +27,29 @@ #include #include #include "hw/usb.h" - -#define trace_usb_packet_state_fault(busnr, path, nr, p, state, expected) \ - fprintf(stderr, "%s:%d trace_usb_packet_state_fault busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \ - __func__, __LINE__, busnr, path, nr, p, state, expected) -#define trace_usb_packet_state_change(busnr, path, nr, p, state, expected) \ - fprintf(stderr, "%s:%d trace_usb_packet_state_change busnr=%d path=%s nr=%d p=%p state=%s expected=%s\n", \ - __func__, __LINE__, busnr, path, nr, p, state, expected) - +#include "usb/gpl/iov.h" +#include "trace.h" void usb_attach(USBPort *port) { USBDevice *dev = port->dev; +// fprintf(usblog, "%s:%d dev=%p port=%p\n", +// __func__, __LINE__, dev, port); assert(dev != NULL); assert(dev->attached); assert(dev->state == USB_STATE_NOTATTACHED); port->ops->attach(port); dev->state = USB_STATE_ATTACHED; -// usb_device_handle_attach(dev); + usb_device_handle_attach(dev); } void usb_detach(USBPort *port) { USBDevice *dev = port->dev; +// fprintf(usblog, "%s:%d dev=%p port=%p\n", +// __func__, __LINE__, dev, port); assert(dev != NULL); assert(dev->state != USB_STATE_NOTATTACHED); port->ops->detach(port); @@ -62,6 +60,8 @@ { USBDevice *dev = port->dev; +// fprintf(usblog, "%s:%d dev=%p port=%p\n", +// __func__, __LINE__, dev, port); assert(dev != NULL); usb_detach(port); usb_attach(port); @@ -73,10 +73,12 @@ if (dev == NULL || !dev->attached) { return; } +// fprintf(usblog, "%s:%d dev=%p\n", +// __func__, __LINE__, dev); dev->remote_wakeup = 0; dev->addr = 0; dev->state = USB_STATE_DEFAULT; -// usb_device_handle_reset(dev); + usb_device_handle_reset(dev); } void usb_wakeup(USBEndpoint *ep, unsigned int stream) @@ -84,6 +86,8 @@ USBDevice *dev = ep->dev; USBBus *bus = usb_bus_from_device(dev); +// fprintf(usblog, "%s:%d dev=%p bus=%p ep=%p stream=%x\n", +// __func__, __LINE__, dev, bus, ep, stream); if (dev->remote_wakeup && dev->port && dev->port->ops->wakeup) { dev->port->ops->wakeup(dev->port); } @@ -109,6 +113,8 @@ { int request, value, index; + fprintf(usblog, "%s:%d s=%p p=%p\n", + __func__, __LINE__, s, p); if (p->iov.size != 8) { p->status = USB_RET_STALL; return; @@ -124,8 +130,8 @@ index = (s->setup_buf[5] << 8) | s->setup_buf[4]; if (s->setup_buf[0] & USB_DIR_IN) { -// usb_device_handle_control(s, p, request, value, index, -// s->setup_len, s->data_buf); + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); if (p->status == USB_RET_ASYNC) { s->setup_state = SETUP_STATE_SETUP; } @@ -158,6 +164,8 @@ { int request, value, index; + fprintf(usblog, "%s:%d s=%p p=%p\n", + __func__, __LINE__, s, p); assert(p->ep->nr == 0); request = (s->setup_buf[0] << 8) | s->setup_buf[1]; @@ -166,9 +174,11 @@ switch(s->setup_state) { case SETUP_STATE_ACK: + fprintf(usblog, "%s:%d setup_state=SETUP_STATE_ACK\n", + __func__, __LINE__); if (!(s->setup_buf[0] & USB_DIR_IN)) { -// usb_device_handle_control(s, p, request, value, index, -// s->setup_len, s->data_buf); + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); if (p->status == USB_RET_ASYNC) { return; } @@ -178,6 +188,8 @@ break; case SETUP_STATE_DATA: + fprintf(usblog, "%s:%d setup_state=SETUP_STATE_DATA\n", + __func__, __LINE__); if (s->setup_buf[0] & USB_DIR_IN) { int len = s->setup_len - s->setup_index; if (len > p->iov.size) { @@ -195,6 +207,8 @@ break; default: + fprintf(usblog, "%s:%d setup_state=default\n", + __func__, __LINE__); p->status = USB_RET_STALL; } } @@ -203,8 +217,12 @@ { assert(p->ep->nr == 0); + fprintf(usblog, "%s:%d s=%p p=%p\n", + __func__, __LINE__, s, p); switch(s->setup_state) { case SETUP_STATE_ACK: + fprintf(usblog, "%s:%d setup_state=SETUP_STATE_ACK\n", + __func__, __LINE__); if (s->setup_buf[0] & USB_DIR_IN) { s->setup_state = SETUP_STATE_IDLE; /* transfer OK */ @@ -214,6 +232,8 @@ break; case SETUP_STATE_DATA: + fprintf(usblog, "%s:%d setup_state=SETUP_STATE_DATA\n", + __func__, __LINE__); if (!(s->setup_buf[0] & USB_DIR_IN)) { int len = s->setup_len - s->setup_index; if (len > p->iov.size) { @@ -231,6 +251,8 @@ break; default: + fprintf(usblog, "%s:%d setup_state=default\n", + __func__, __LINE__); p->status = USB_RET_STALL; } } @@ -239,6 +261,8 @@ { int i, request, value, index; +// fprintf(usblog, "%s:%d s=%p p=%p\n", +// __func__, __LINE__, s, p); for (i = 0; i < 8; i++) { s->setup_buf[i] = p->parameter >> (i*8); } @@ -263,8 +287,8 @@ usb_packet_copy(p, s->data_buf, s->setup_len); } -// usb_device_handle_control(s, p, request, value, index, -// s->setup_len, s->data_buf); + usb_device_handle_control(s, p, request, value, index, + s->setup_len, s->data_buf); if (p->status == USB_RET_ASYNC) { return; } @@ -288,6 +312,8 @@ s->setup_state = SETUP_STATE_IDLE; } +// fprintf(usblog, "%s:%d s=%p p=%p\n", +// __func__, __LINE__, s, p); switch (s->setup_state) { case SETUP_STATE_SETUP: if (p->actual_length < s->setup_len) { @@ -340,20 +366,23 @@ { USBDevice *dev = port->dev; +// fprintf(usblog, "%s:%d port=%p addr=%x\n", +// __func__, __LINE__, port, addr); if (dev == NULL || !dev->attached || dev->state != USB_STATE_DEFAULT) { return NULL; } if (dev->addr == addr) { return dev; } -// return usb_device_find_device(dev, addr); - return 0; + return usb_device_find_device(dev, addr); } static void usb_process_one(USBPacket *p) { USBDevice *dev = p->ep->dev; + fprintf(usblog, "%s:%d p=%p dev=%p\n", + __func__, __LINE__, p, dev); /* * Handlers expect status to be initialized to USB_RET_SUCCESS, but it * can be USB_RET_NAK here from a previous usb_process_one() call, @@ -369,25 +398,37 @@ } switch (p->pid) { case USB_TOKEN_SETUP: + fprintf(usblog, "%s:%d pid=USB_TOKEN_SETUP\n", + __func__, __LINE__); do_token_setup(dev, p); break; case USB_TOKEN_IN: + fprintf(usblog, "%s:%d pid=USB_TOKEN_IN\n", + __func__, __LINE__); do_token_in(dev, p); break; case USB_TOKEN_OUT: + fprintf(usblog, "%s:%d pid=USB_TOKEN_OUT\n", + __func__, __LINE__); do_token_out(dev, p); break; default: + fprintf(usblog, "%s:%d pid=default\n", + __func__, __LINE__); p->status = USB_RET_STALL; } } else { + fprintf(usblog, "%s:%d nr != 0\n", + __func__, __LINE__); /* data pipe */ -// usb_device_handle_data(dev, p); + usb_device_handle_data(dev, p); } } static void usb_queue_one(USBPacket *p) { +// fprintf(usblog, "%s:%d p=%p\n", +// __func__, __LINE__, p); usb_packet_set_state(p, USB_PACKET_QUEUED); QTAILQ_INSERT_TAIL(&p->ep->queue, p, queue); p->status = USB_RET_ASYNC; @@ -398,6 +439,8 @@ driver will call usb_packet_complete() when done processing it. */ void usb_handle_packet(USBDevice *dev, USBPacket *p) { + fprintf(usblog, "%s:%d dev=%p p=%p\n", + __func__, __LINE__, dev, p); if (dev == NULL) { p->status = USB_RET_NODEV; return; @@ -444,6 +487,8 @@ { USBEndpoint *ep = p->ep; +// fprintf(usblog, "%s:%d dev=%p p=%p ep=%p\n", +// __func__, __LINE__, dev, p, ep); assert(QTAILQ_FIRST(&ep->queue) == p); assert(p->status != USB_RET_ASYNC && p->status != USB_RET_NAK); @@ -463,6 +508,8 @@ { USBEndpoint *ep = p->ep; +// fprintf(usblog, "%s:%d dev=%p p=%p ep=%p\n", +// __func__, __LINE__, dev, p, ep); usb_packet_check_state(p, USB_PACKET_ASYNC); usb_packet_complete_one(dev, p); @@ -493,20 +540,20 @@ void usb_cancel_packet(USBPacket * p) { bool callback = (p->state == USB_PACKET_ASYNC); +// fprintf(usblog, "%s:%d p=%p callback=%d\n", +// __func__, __LINE__, p, callback); assert(usb_packet_is_inflight(p)); usb_packet_set_state(p, USB_PACKET_CANCELED); QTAILQ_REMOVE(&p->ep->queue, p, queue); if (callback) { -// usb_device_cancel_packet(p->ep->dev, p); + usb_device_cancel_packet(p->ep->dev, p); } } void usb_packet_init(USBPacket *p) { - p->iov.iov = (struct iovec *)calloc(sizeof(struct iovec), 1); - p->iov.niov = p->iov.size = 0; - p->iov.nalloc = 1; + qemu_iovec_init(&p->iov, 1); } static const char *usb_packet_state_name(USBPacketState state) @@ -543,6 +590,8 @@ void usb_packet_set_state(USBPacket *p, USBPacketState state) { +// fprintf(usblog, "%s:%d p=%p state=%d\n", +// __func__, __LINE__, p, state); if (p->ep) { USBDevice *dev = p->ep->dev; USBBus *bus = usb_bus_from_device(dev); @@ -561,6 +610,8 @@ USBEndpoint *ep, unsigned int stream, uint64_t id, bool short_not_ok, bool int_req) { +// fprintf(usblog, "%s:%d p=%p pid=%d ep=%p stream=%x id=%lx short_not_ok=%d int_req=%d\n", +// __func__, __LINE__, p, pid, ep, stream, id, short_not_ok, int_req); assert(!usb_packet_is_inflight(p)); assert(p->iov.iov != NULL); p->id = id; @@ -573,39 +624,37 @@ p->short_not_ok = short_not_ok; p->int_req = int_req; p->combined = NULL; - assert(p->iov.nalloc != -1); - p->iov.niov = 0; - p->iov.size = 0; + qemu_iovec_reset(&p->iov); usb_packet_set_state(p, USB_PACKET_SETUP); } void usb_packet_addbuf(USBPacket *p, void *ptr, size_t len) { - assert(p->iov.nalloc != -1); - - if (p->iov.niov == p->iov.nalloc) { - p->iov.nalloc = 2 * p->iov.nalloc + 1; - p->iov.iov = (struct iovec *)realloc(p->iov.iov, sizeof(struct iovec) * p->iov.nalloc); - } - p->iov.iov[p->iov.niov].iov_base = ptr; - p->iov.iov[p->iov.niov].iov_len = len; - p->iov.size += len; - ++p->iov.niov; +// fprintf(usblog, "%s:%d p=%p ptr=%p len=%zu\n", +// __func__, __LINE__, p, ptr, len); + qemu_iovec_add(&p->iov, ptr, len); } void usb_packet_copy(USBPacket *p, void *ptr, size_t bytes) { IOVector *iov = p->combined ? &p->combined->iov : &p->iov; +// fprintf(usblog, "%s:%d p=%p ptr=%p bytes=%zu\n", +// __func__, __LINE__, p, ptr, bytes); assert(p->actual_length >= 0); assert(p->actual_length + bytes <= iov->size); switch (p->pid) { case USB_TOKEN_SETUP: case USB_TOKEN_OUT: -// iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); +// fprintf(usblog, "%s:%d pid:%s\n", +// __func__, __LINE__, +// p->pid == USB_TOKEN_SETUP ? "USB_TOKEN_SETUP" : "USB_TOKEN_OUT"); + iov_to_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; case USB_TOKEN_IN: -// iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); +// fprintf(usblog, "%s:%d pid:USB_TOKEN_IN\n", +// __func__, __LINE__); + iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes); break; default: fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid); @@ -617,34 +666,37 @@ void usb_packet_skip(USBPacket *p, size_t bytes) { IOVector *iov = p->combined ? &p->combined->iov : &p->iov; +// fprintf(usblog, "%s:%d p=%p bytes=%zu\n", +// __func__, __LINE__, p, bytes); assert(p->actual_length >= 0); assert(p->actual_length + bytes <= iov->size); if (p->pid == USB_TOKEN_IN) { -// iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes); + iov_memset(iov->iov, iov->niov, p->actual_length, 0, bytes); } p->actual_length += bytes; } size_t usb_packet_size(USBPacket *p) { +// fprintf(usblog, "%s:%d p=%p\n", +// __func__, __LINE__, p); return p->combined ? p->combined->iov.size : p->iov.size; } void usb_packet_cleanup(USBPacket *p) { - assert(!usb_packet_is_inflight(p)); - assert(p->iov.nalloc != -1); - - free(p->iov.iov); - p->iov.size = p->iov.niov = p->iov.nalloc = 0; - p->iov.iov = NULL; +// fprintf(usblog, "%s:%d p=%p\n", +// __func__, __LINE__, p); + qemu_iovec_destroy(&p->iov); } void usb_ep_reset(USBDevice *dev) { int ep; +// fprintf(usblog, "%s:%d dev=%p\n", +// __func__, __LINE__, dev); dev->ep_ctl.nr = 0; dev->ep_ctl.type = USB_ENDPOINT_XFER_CONTROL; dev->ep_ctl.ifnum = 0; @@ -670,6 +722,8 @@ { int ep; +// fprintf(usblog, "%s:%d dev=%p\n", +// __func__, __LINE__, dev); usb_ep_reset(dev); QTAILQ_INIT(&dev->ep_ctl.queue); for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++) { @@ -724,6 +778,8 @@ { struct USBEndpoint *eps; +// fprintf(usblog, "%s:%d dev=%p pid=%d ep=%d\n", +// __func__, __LINE__, dev, pid, ep); if (dev == NULL) { return NULL; } Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/dev-hub.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/dev-hub.c Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/dev-hub.c Mon Sep 16 06:39:34 2013 (r257395) @@ -22,19 +22,13 @@ * THE SOFTWARE. */ //#include "qemu-common.h" -//#include "trace.h" +#include "trace.h" #include "hw/usb.h" #include "usb/gpl/desc.h" //#include "qemu/error-report.h" #include -#define trace_usb_hub_attach(a,b) -#define trace_usb_hub_detach(a,b) -#define trace_usb_hub_reset(a) -#define trace_usb_hub_control(a,b,c,d,e) -#define trace_usb_hub_get_port_status(a,b,c,d) -#define trace_usb_hub_set_port_feature(a,b,c) -#define trace_usb_hub_clear_port_feature(a,b,c) +extern FILE *usblog; #if 0 #define NUM_PORTS 8 @@ -222,6 +216,8 @@ static void usb_hub_complete(USBPort *port, USBPacket *packet) { USBHubState *s = port->opaque; +// fprintf(usblog, "%s:%d port=%p packet=%p\n", +// __func__, __LINE__, port, packet); /* * Just pass it along upstream for now. @@ -243,6 +239,8 @@ USBDevice *downstream; int i; +// fprintf(usblog, "%s:%d dev=%p addr=%x\n", +// __func__, __LINE__, dev, addr); for (i = 0; i < NUM_PORTS; i++) { port = &s->ports[i]; if (!(port->wPortStatus & PORT_STAT_ENABLE)) { Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/bus.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/bus.c Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/bus.c Mon Sep 16 06:39:34 2013 (r257395) @@ -6,12 +6,7 @@ //#include "hw/qdev.h" //#include "sysemu/sysemu.h" //#include "monitor/monitor.h" -//#include "trace.h" - -#define trace_usb_port_claim(a, b) -#define trace_usb_port_attach(a,b,c,d) -#define trace_usb_port_detach(a,b) -#define trace_usb_port_release(a,b) +#include "trace.h" void pstrcpy(char *buf, int buf_size, const char *str) { @@ -128,35 +123,40 @@ static int usb_device_init(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); if (klass->init) { return klass->init(dev); } return 0; } -#if 0 USBDevice *usb_device_find_device(USBDevice *dev, uint8_t addr) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p addr=%x klass=%p\n", +// __func__, __LINE__, dev, addr, klass); if (klass->find_device) { return klass->find_device(dev, addr); } return NULL; } -#endif static void usb_device_handle_destroy(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); if (klass->handle_destroy) { klass->handle_destroy(dev); } } -#if 0 void usb_device_cancel_packet(USBDevice *dev, USBPacket *p) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p p=%p klass=%p\n", +// __func__, __LINE__, dev, p, klass); if (klass->cancel_packet) { klass->cancel_packet(dev, p); } @@ -165,6 +165,8 @@ void usb_device_handle_attach(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); if (klass->handle_attach) { klass->handle_attach(dev); } @@ -173,6 +175,8 @@ void usb_device_handle_reset(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); if (klass->handle_reset) { klass->handle_reset(dev); } @@ -182,6 +186,8 @@ int value, int index, int length, uint8_t *data) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p p=%p request=%d value=%d index=%d length=%d data=%p klass=%p\n", +// __func__, __LINE__, dev, p, request, value, index, length, data, klass); if (klass->handle_control) { klass->handle_control(dev, p, request, value, index, length, data); } @@ -190,21 +196,26 @@ void usb_device_handle_data(USBDevice *dev, USBPacket *p) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p p=%p klass=%p\n", +// __func__, __LINE__, dev, p, klass); if (klass->handle_data) { klass->handle_data(dev, p); } } -#endif const char *usb_device_get_product_desc(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); return klass->product_desc; } const USBDesc *usb_device_get_usb_desc(USBDevice *dev) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p klass=%p\n", +// __func__, __LINE__, dev, klass); if (dev->usb_desc) { return dev->usb_desc; } @@ -225,6 +236,8 @@ void usb_device_flush_ep_queue(USBDevice *dev, USBEndpoint *ep) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p ep=%p klass=%p\n", +// __func__, __LINE__, dev, ep, klass); if (klass->flush_ep_queue) { klass->flush_ep_queue(dev, ep); } @@ -233,6 +246,8 @@ void usb_device_ep_stopped(USBDevice *dev, USBEndpoint *ep) { USBDeviceClass *klass = USB_DEVICE_GET_CLASS(dev); +// fprintf(usblog, "%s:%d dev=%p ep=%p klass=%p\n", +// __func__, __LINE__, dev, ep, klass); if (klass->ep_stopped) { klass->ep_stopped(dev, ep); } @@ -348,6 +363,8 @@ USBBus *bus; int i; +// fprintf(usblog, "%s:%d masterbus:%s ports:%p portcount:%d firstport:%d opaqueue:%p ops:%p speedmask:%x\n", +// __func__, __LINE__, masterbus, ports, portcount, firstport, opaque, ops, speedmask); QTAILQ_FOREACH(bus, &busses, next) { if (strcmp(bus->name, masterbus) == 0) { break; @@ -374,6 +391,8 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr) { +// fprintf(usblog, "%s:%d downstream:%p upstream:%p portnr:%d\n", +// __func__, __LINE__, downstream, upstream, portnr); if (upstream) { snprintf(downstream->path, sizeof(downstream->path), "%s.%d", upstream->path, portnr); @@ -505,7 +524,7 @@ int usb_device_detach(USBDevice *dev) { -// USBBus *bus = usb_bus_from_device(dev); + USBBus *bus = usb_bus_from_device(dev); USBPort *port = dev->port; assert(port != NULL); Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/desc.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/desc.c Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/desc.c Mon Sep 16 06:39:34 2013 (r257395) @@ -5,18 +5,7 @@ #include "hw/usb.h" #include "desc.h" - -#define trace_usb_desc_device(a,b,c) -#define trace_usb_desc_config(a,b,c,d) -#define trace_usb_desc_string(a,b,c,d) -#define trace_usb_desc_device_qualifier(a,b,c) -#define trace_usb_desc_other_speed_config(a,b,c,d) -#define trace_usb_set_addr(a) -#define trace_usb_set_config(a,b,c) -#define trace_usb_clear_device_feature(a,b,c) -#define trace_usb_set_device_feature(a,b,c) -#define trace_usb_set_interface(a,b,c,d) -#define trace_usb_desc_bos(a,b,c) +#include "trace.h" void usb_device_set_interface(USBDevice *dev, int interface, int alt_old, int alt_new) Modified: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/dev-serial.c ============================================================================== --- soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/dev-serial.c Mon Sep 16 02:01:36 2013 (r257394) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/dev-serial.c Mon Sep 16 06:39:34 2013 (r257395) @@ -39,11 +39,12 @@ } -//#define DEBUG_Serial +#define DEBUG_Serial #ifdef DEBUG_Serial +extern FILE *usblog; #define DPRINTF(fmt, ...) \ -do { printf("usb-serial: " fmt , ## __VA_ARGS__); } while (0) +do { fprintf(usblog, "usb-serial: " fmt , ## __VA_ARGS__); } while (0) #else #define DPRINTF(fmt, ...) do {} while(0) #endif Added: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/hexdump.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/hexdump.c Mon Sep 16 06:39:34 2013 (r257395) @@ -0,0 +1,37 @@ +/* + * Helper to hexdump a buffer + * + * Copyright (c) 2013 Red Hat, Inc. + * Copyright (c) 2013 Gerd Hoffmann + * Copyright (c) 2013 Peter Crosthwaite + * Copyright (c) 2013 Xilinx, Inc + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include + +void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size) +{ + unsigned int b; + + for (b = 0; b < size; b++) { + if ((b % 16) == 0) { + fprintf(fp, "%s: %04x:", prefix, b); + } + if ((b % 4) == 0) { + fprintf(fp, " "); + } + fprintf(fp, " %02x", (unsigned char)buf[b]); + if ((b % 16) == 15) { + fprintf(fp, "\n"); + } + } + if ((b % 16) != 0) { + fprintf(fp, "\n"); + } +} Added: soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/iov.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/syuu/bhyve_usb/usr.sbin/bhyve/usb/gpl/iov.c Mon Sep 16 06:39:34 2013 (r257395) @@ -0,0 +1,439 @@ +/* + * Helpers for getting linearized buffers from iov / filling buffers into iovs + * + * Copyright IBM, Corp. 2007, 2008 + * Copyright (C) 2010 Red Hat, Inc. + * + * Author(s): + * Anthony Liguori + * Amit Shah + * Michael Tokarev + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + * Contributions after 2012-01-13 are licensed under the terms of the + * GNU GPL, version 2 or (at your option) any later version. + */ + +#include "usb/gpl/iov.h" +#include "hw/usb.h" + +#ifdef _WIN32 +# include +# include +#else +# include +# include +#endif +#include +#include +#include +#include +#include +#include + +size_t iov_from_buf(const struct iovec *iov, unsigned int iov_cnt, + size_t offset, const void *buf, size_t bytes) +{ + size_t done; + unsigned int i; + for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { + if (offset < iov[i].iov_len) { + size_t len = MIN(iov[i].iov_len - offset, bytes - done); + memcpy(iov[i].iov_base + offset, buf + done, len); + done += len; + offset = 0; + } else { + offset -= iov[i].iov_len; + } + } + assert(offset == 0); + return done; +} + +size_t iov_to_buf(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, void *buf, size_t bytes) +{ + size_t done; + unsigned int i; + for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { + if (offset < iov[i].iov_len) { + size_t len = MIN(iov[i].iov_len - offset, bytes - done); + memcpy(buf + done, iov[i].iov_base + offset, len); + done += len; + offset = 0; + } else { + offset -= iov[i].iov_len; + } + } + assert(offset == 0); + return done; +} + +size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, + size_t offset, int fillc, size_t bytes) +{ + size_t done; + unsigned int i; + for (i = 0, done = 0; (offset || done < bytes) && i < iov_cnt; i++) { + if (offset < iov[i].iov_len) { + size_t len = MIN(iov[i].iov_len - offset, bytes - done); + memset(iov[i].iov_base + offset, fillc, len); + done += len; + offset = 0; + } else { + offset -= iov[i].iov_len; + } + } + assert(offset == 0); + return done; +} + +size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt) +{ + size_t len; + unsigned int i; + + len = 0; + for (i = 0; i < iov_cnt; i++) { + len += iov[i].iov_len; + } + return len; +} + +/* helper function for iov_send_recv() */ +static ssize_t +do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send) +{ +#ifdef CONFIG_POSIX + ssize_t ret; + struct msghdr msg; + memset(&msg, 0, sizeof(msg)); + msg.msg_iov = iov; + msg.msg_iovlen = iov_cnt; + do { + ret = do_send + ? sendmsg(sockfd, &msg, 0) + : recvmsg(sockfd, &msg, 0); + } while (ret < 0 && errno == EINTR); + return ret; +#else + /* else send piece-by-piece */ + /*XXX Note: windows has WSASend() and WSARecv() */ + unsigned i = 0; + ssize_t ret = 0; + while (i < iov_cnt) { + ssize_t r = do_send + ? send(sockfd, iov[i].iov_base, iov[i].iov_len, 0) + : recv(sockfd, iov[i].iov_base, iov[i].iov_len, 0); + if (r > 0) { + ret += r; + } else if (!r) { + break; + } else if (errno == EINTR) { + continue; + } else { + /* else it is some "other" error, + * only return if there was no data processed. */ + if (ret == 0) { + ret = -1; + } + break; + } + i++; + } + return ret; +#endif +} + +ssize_t iov_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, + size_t offset, size_t bytes, + bool do_send) +{ + ssize_t total = 0; + ssize_t ret; + size_t orig_len, tail; + unsigned niov; + + while (bytes > 0) { + /* Find the start position, skipping `offset' bytes: + * first, skip all full-sized vector elements, */ + for (niov = 0; niov < iov_cnt && offset >= iov[niov].iov_len; ++niov) { + offset -= iov[niov].iov_len; + } + + /* niov == iov_cnt would only be valid if bytes == 0, which + * we already ruled out in the loop condition. */ + assert(niov < iov_cnt); + iov += niov; + iov_cnt -= niov; + + if (offset) { + /* second, skip `offset' bytes from the (now) first element, + * undo it on exit */ + iov[0].iov_base += offset; + iov[0].iov_len -= offset; + } + /* Find the end position skipping `bytes' bytes: */ + /* first, skip all full-sized elements */ + tail = bytes; + for (niov = 0; niov < iov_cnt && iov[niov].iov_len <= tail; ++niov) { + tail -= iov[niov].iov_len; + } + if (tail) { + /* second, fixup the last element, and remember the original + * length */ + assert(niov < iov_cnt); + assert(iov[niov].iov_len > tail); + orig_len = iov[niov].iov_len; + iov[niov++].iov_len = tail; + } + + ret = do_send_recv(sockfd, iov, niov, do_send); + + /* Undo the changes above before checking for errors */ + if (tail) { + iov[niov-1].iov_len = orig_len; + } + if (offset) { + iov[0].iov_base -= offset; + iov[0].iov_len += offset; + } + + if (ret < 0) { + assert(errno != EINTR); + if (errno == EAGAIN && total > 0) { + return total; + } + return -1; + } + + if (ret == 0 && !do_send) { + /* recv returns 0 when the peer has performed an orderly + * shutdown. */ + break; + } + + /* Prepare for the next iteration */ + offset += ret; + total += ret; + bytes -= ret; + } + + return total; +} + + +void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt, + FILE *fp, const char *prefix, size_t limit) +{ + int v; + size_t size = 0; + char *buf; + + for (v = 0; v < iov_cnt; v++) { + size += iov[v].iov_len; + } + size = size > limit ? limit : size; + buf = malloc(size); + iov_to_buf(iov, iov_cnt, 0, buf, size); + qemu_hexdump(buf, fp, prefix, size); + free(buf); +} + +unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, + const struct iovec *iov, unsigned int iov_cnt, + size_t offset, size_t bytes) +{ + size_t len; + unsigned int i, j; + for (i = 0, j = 0; i < iov_cnt && j < dst_iov_cnt && bytes; i++) { + if (offset >= iov[i].iov_len) { + offset -= iov[i].iov_len; + continue; + } + len = MIN(bytes, iov[i].iov_len - offset); + + dst_iov[j].iov_base = iov[i].iov_base + offset; + dst_iov[j].iov_len = len; + j++; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-soc-all@FreeBSD.ORG Mon Sep 16 08:08:52 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CD38FECF for ; Mon, 16 Sep 2013 08:08:52 +0000 (UTC) (envelope-from ccqin@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B8B3F2573 for ; Mon, 16 Sep 2013 08:08:52 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8G88q4q091449 for ; Mon, 16 Sep 2013 08:08:52 GMT (envelope-from ccqin@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8G88qb6091423 for svn-soc-all@FreeBSD.org; Mon, 16 Sep 2013 08:08:52 GMT (envelope-from ccqin@FreeBSD.org) Date: Mon, 16 Sep 2013 08:08:52 GMT Message-Id: <201309160808.r8G88qb6091423@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to ccqin@FreeBSD.org using -f From: ccqin@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257398 - in soc2013/ccqin/head/sys: conf net80211 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.14 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, 16 Sep 2013 08:08:52 -0000 Author: ccqin Date: Mon Sep 16 08:08:52 2013 New Revision: 257398 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257398 Log: Update ieee80211_sample and complete ieee80211_ratectl_none templete. * rename ieee80211_rc_sample* to ieee80211_sample*. this seems more harmonious. * modify ieee80211_sample to let it use the latest net80211-ratectl features. * fix some errors in ieee80211_sample. * complete the ieee80211_ratectl_none templete with new added net80211-ratectl functions. Added: soc2013/ccqin/head/sys/net80211/ieee80211_sample.c - copied, changed from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c soc2013/ccqin/head/sys/net80211/ieee80211_sample.h - copied, changed from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h - copied unchanged from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h Deleted: soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h Modified: soc2013/ccqin/head/sys/conf/files soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Modified: soc2013/ccqin/head/sys/conf/files ============================================================================== --- soc2013/ccqin/head/sys/conf/files Mon Sep 16 06:25:54 2013 (r257397) +++ soc2013/ccqin/head/sys/conf/files Mon Sep 16 08:08:52 2013 (r257398) @@ -3100,6 +3100,7 @@ net80211/ieee80211_ratectl_none.c optional wlan net80211/ieee80211_regdomain.c optional wlan net80211/ieee80211_rssadapt.c optional wlan wlan_rssadapt +net80211/ieee80211_sample.c optional wlan | wlan_sample net80211/ieee80211_scan.c optional wlan net80211/ieee80211_scan_sta.c optional wlan net80211/ieee80211_sta.c optional wlan Modified: soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 16 06:25:54 2013 (r257397) +++ soc2013/ccqin/head/sys/net80211/ieee80211_amrr.c Mon Sep 16 08:08:52 2013 (r257398) @@ -57,13 +57,10 @@ #define is_enough(amn) \ ((amn)->amn_txcnt > 10) -static void amrr_setinterval(const struct ieee80211vap *, int); static void amrr_init(struct ieee80211vap *, uint32_t); static void amrr_deinit(struct ieee80211vap *); static void amrr_node_init(struct ieee80211_node *); static void amrr_node_deinit(struct ieee80211_node *); -static int amrr_update(struct ieee80211_amrr *, - struct ieee80211_amrr_node *, struct ieee80211_node *); static int amrr_rate(struct ieee80211_node *, void *, uint32_t); static void amrr_rates(struct ieee80211_node *, struct ieee80211_rc_info *); static void amrr_tx_complete(const struct ieee80211vap *, @@ -71,6 +68,7 @@ static void amrr_tx_update(const struct ieee80211vap *, const struct ieee80211_node *, void *, void *, void *); static void amrr_stats(const struct ieee80211vap *); +static void amrr_setinterval(const struct ieee80211vap *, int); static void amrr_sysctlattach(struct ieee80211vap *, struct sysctl_ctx_list *, struct sysctl_oid *); Modified: soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Mon Sep 16 06:25:54 2013 (r257397) +++ soc2013/ccqin/head/sys/net80211/ieee80211_ratectl_none.c Mon Sep 16 08:08:52 2013 (r257398) @@ -112,6 +112,11 @@ } static void +none_rates(struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) +{ +} + +static void none_tx_complete(const struct ieee80211vap *vap, const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { @@ -128,6 +133,16 @@ { } +static void +none_stats(const struct ieee80211vap *vap) +{ + struct ieee80211_rc_stat * irs = IEEE80211_RATECTL_STAT(vap); + printf("tx count: %d (ok count: %d, fail count: %d)\n" + "retry count: %d (short retry: %d, long retry: %d)\n", + irs->irs_txcnt, irs->irs_txcnt - irs->irs_failcnt, irs->irs_failcnt, + irs->irs_retrycnt, irs->irs_shortretry, irs->irs_longretry); + /* ... */ +} /* number of references from net80211 layer */ static int nrefs = 0; @@ -140,9 +155,11 @@ .ir_node_init = none_node_init, .ir_node_deinit = none_node_deinit, .ir_rate = none_rate, + .ir_rates = none_rates, .ir_tx_complete = none_tx_complete, .ir_tx_update = none_tx_update, .ir_setinterval = none_setinterval, + .ir_stats = none_stats, }; IEEE80211_RATECTL_MODULE(ratectl_none, 1); IEEE80211_RATECTL_ALG(none, IEEE80211_RATECTL_NONE, none); Copied and modified: soc2013/ccqin/head/sys/net80211/ieee80211_sample.c (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c) ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.c Mon Sep 2 08:00:12 2013 (r256825, copy source) +++ soc2013/ccqin/head/sys/net80211/ieee80211_sample.c Mon Sep 16 08:08:52 2013 (r257398) @@ -38,6 +38,7 @@ #include #include +#include #ifdef INET #include @@ -47,21 +48,26 @@ #include #include #include -#include -#include +#include +#include static void sample_init(struct ieee80211vap *, uint32_t); static void sample_deinit(struct ieee80211vap *); static void sample_node_init(struct ieee80211_node *); static void sample_node_deinit(struct ieee80211_node *); static int sample_rate(struct ieee80211_node *, void *, uint32_t); +static void sample_rates(struct ieee80211_node *, struct ieee80211_rc_info *); static void sample_tx_complete(const struct ieee80211vap *, - const struct ieee80211_node *, int, - void *, void *); + const struct ieee80211_node *, struct ieee80211_rc_info *); static void sample_tx_update(const struct ieee80211vap *vap, const struct ieee80211_node *, void *, void *, void *); +static void sample_stats(const struct ieee80211vap *); static void sample_setinterval(const struct ieee80211vap *, int); +static void sample_sysctlattach(struct ieee80211vap *, + struct sysctl_ctx_list *, struct sysctl_oid *); +static void sample_update_static_rix(struct ieee80211_node *); + /* number of references from net80211 layer */ static int nrefs = 0; @@ -78,6 +84,7 @@ .ir_tx_complete = sample_tx_complete, .ir_tx_update = sample_tx_update, .ir_setinterval = sample_setinterval, + .ir_stats = sample_stats, }; IEEE80211_RATECTL_MODULE(sample, 1); IEEE80211_RATECTL_ALG(sample, IEEE80211_RATECTL_SAMPLE, sample); @@ -136,10 +143,12 @@ #define RATE(_ix) (ni->ni_rates.rs_rates[(_ix)] & IEEE80211_RATE_VAL) #define DOT11RATE(_ix) (rt->info[(_ix)].dot11Rate & IEEE80211_RATE_VAL) #define MCS(_ix) (ni->ni_htrates.rs_rates[_ix] | IEEE80211_RATE_MCS) + struct ieee80211vap *vap = ni->ni_vap; struct ieee80211_sample *sample = vap->iv_rs; struct ieee80211_sample_node *san = NULL; - const struct ieee80211_rate_table *rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan); + + const struct ieee80211_rate_table *rt = NULL; enum ieee80211_phymode curmode = ieee80211_chan2mode(vap->iv_ic->ic_curchan); int x, y, rix; @@ -156,6 +165,7 @@ san->san_sample = sample; + rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan); KASSERT(rt != NULL, ("no rate table, mode %u", curmode)); san->sched = mrr_schedules[curmode]; @@ -177,9 +187,6 @@ rix = rt->rateCodeToIndex[MCS(x)]; if (rix == 0xff) continue; - /* skip rates marked broken by hal */ - if (!rt->info[rix].valid) - continue; KASSERT(rix < SAMPLE_MAXRATES, ("mcs %u has rix %d", MCS(x), rix)); san->ratemask |= (uint64_t) 1<rateCodeToIndex[RATE(x)]; if (rix == 0xff) continue; - /* skip rates marked broken by hal */ - if (!rt->info[rix].valid) - continue; KASSERT(rix < SAMPLE_MAXRATES, ("rate %u has rix %d", RATE(x), rix)); san->ratemask |= (uint64_t) 1<info[ix].dot11Rate & IEEE80211_RATE_VAL) #define MCS(ix) (rt->info[ix].dot11Rate | IEEE80211_RATE_MCS) @@ -624,7 +628,7 @@ sample->sample_rate/100)) { rix = pick_sample_rate(ni, rt, size_bin); IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, - &ni, "att %d sample_tt %d size %u sample rate %d %s current rate %d %s", + ni, "att %d sample_tt %d size %u sample rate %d %s current rate %d %s", average_tx_time, san->sample_tt[size_bin], bin_to_size(size_bin), @@ -650,13 +654,13 @@ } else if (san->packets_sent[size_bin] < 20) { /* let the bit-rate switch quickly during the first few packets */ IEEE80211_NOTE(vap, - IEEE80211_MSG_RATECTL, &ni, + IEEE80211_MSG_RATECTL, ni, "%s: switching quickly..", __func__); change_rates = 1; } else if (ticks - sample->sample_min_switch > san->ticks_since_switch[size_bin]) { /* min_switch seconds have gone by */ IEEE80211_NOTE(vap, - IEEE80211_MSG_RATECTL, &ni, + IEEE80211_MSG_RATECTL, ni, "%s: min_switch %d > ticks_since_switch %d..", __func__, ticks - sample->sample_min_switch, san->ticks_since_switch[size_bin]); change_rates = 1; @@ -664,7 +668,7 @@ (2*average_tx_time < san->stats[size_bin][san->current_rix[size_bin]].average_tx_time)) { /* the current bit-rate is twice as slow as the best one */ IEEE80211_NOTE(vap, - IEEE80211_MSG_RATECTL, &ni, + IEEE80211_MSG_RATECTL, ni, "%s: 2x att (= %d) < cur_rix att %d", __func__, 2 * average_tx_time, san->stats[size_bin][san->current_rix[size_bin]].average_tx_time); @@ -686,7 +690,7 @@ if ((MCS(best_rix) > MCS(cur_rix)) && (average_tx_time * 8) <= (cur_att * 10)) { IEEE80211_NOTE(vap, - IEEE80211_MSG_RATECTL, &ni, + IEEE80211_MSG_RATECTL, ni, "%s: HT: best_rix 0x%d > cur_rix 0x%x, average_tx_time %d, cur_att %d", __func__, MCS(best_rix), MCS(cur_rix), average_tx_time, cur_att); @@ -700,7 +704,7 @@ if (best_rix != san->current_rix[size_bin]) { IEEE80211_NOTE(vap, IEEE80211_MSG_RATECTL, - &ni, + ni, "%s: size %d switch rate %d (%d/%d) -> %d (%d/%d) after %d packets mrr %d", __func__, bin_to_size(size_bin), @@ -794,7 +798,7 @@ const int size_bin = size_to_bin(frame_size); const int size = bin_to_size(size_bin); - int is_ht40 = ieee80211_ratectl_hascap_cw40(vap, ni); + int is_ht40 = ieee80211_ratectl_hascap_cw40(ni); int tt, tries_so_far; int pct; @@ -827,7 +831,7 @@ MIN(tries3 + tries_so_far, tries) - tries_so_far - 1, is_ht40); } - if (san->stats[size_bin][rix0].total_packets < sample->sanple_smoothing_minpackets) { + if (san->stats[size_bin][rix0].total_packets < sample->sample_smoothing_minpackets) { /* just average the first few packets */ int avg_tx = san->stats[size_bin][rix0].average_tx_time; int packets = san->stats[size_bin][rix0].total_packets; @@ -835,8 +839,8 @@ } else { /* use a ewma */ san->stats[size_bin][rix0].average_tx_time = - ((san->stats[size_bin][rix0].average_tx_time * sample->sanple_smoothing_rate) + - (tt * (100 - sample->sanple_smoothing_rate))) / 100; + ((san->stats[size_bin][rix0].average_tx_time * sample->sample_smoothing_rate) + + (tt * (100 - sample->sample_smoothing_rate))) / 100; } /* @@ -863,7 +867,7 @@ pct = ((nframes - nbad) * 1000) / nframes; if (san->stats[size_bin][rix0].total_packets < - sample->sanple_smoothing_minpackets) { + sample->sample_smoothing_minpackets) { /* just average the first few packets */ int a_pct = (san->stats[size_bin][rix0].packets_acked * 1000) / (san->stats[size_bin][rix0].total_packets); @@ -871,8 +875,8 @@ } else { /* use a ewma */ san->stats[size_bin][rix0].ewma_pct = - ((san->stats[size_bin][rix0].ewma_pct * sample->sanple_smoothing_rate) + - (pct * (100 - sample->sanple_smoothing_rate))) / 100; + ((san->stats[size_bin][rix0].ewma_pct * sample->sample_smoothing_rate) + + (pct * (100 - sample->sample_smoothing_rate))) / 100; } if (rix0 == san->current_sample_rix[size_bin]) { @@ -883,25 +887,22 @@ static void sample_tx_complete(const struct ieee80211vap *vap, - const struct ieee80211_node *ni, int ok, - void *arg1, void *arg2) + const struct ieee80211_node *ni, struct ieee80211_rc_info *rc_info) { struct ieee80211_sample_node *san = ni->ni_rctls; - const struct ieee80211_rate_table *rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan); - - /* XXX need to change arg2 to pointer of ieee80211_rc_info */ - struct ieee80211_rc_info *rc_info = (struct ieee80211_rc_info*)arg2; - + const struct ieee80211_rate_table *rt = NULL; + struct ieee80211_rc_series *rc = NULL; int final_rix, short_tries, long_tries; int nframes, nbad; int frame_size, mrr; + rt = ieee80211_get_ratetable(vap->iv_ic->ic_curchan); + rc = rc_info->iri_rc; /* update per vap statistics */ ieee80211_ratectl_update_stat(vap, rc_info); final_rix = rt->rateCodeToIndex[rc_info->iri_txrate]; short_tries = rc_info->iri_shortretry; - /* XXX why plus 1 here? */ long_tries = rc_info->iri_longretry + 1; nframes = rc_info->iri_txcnt; @@ -911,6 +912,7 @@ mrr = 0; if (nframes == 0) { + /* XXX need some msg out */ return; } @@ -944,7 +946,6 @@ } else { int finalTSIdx = rc_info->iri_finaltsi; - int i; /* * NB: series > 0 are not penalized for failure @@ -1008,18 +1009,11 @@ static void sample_setinterval(const struct ieee80211vap *vap, int msecs) { - struct ieee80211_sample *sample = vap->iv_rs; - int t; - - if (msecs < 100) - msecs = 100; - t = msecs_to_ticks(msecs); /* ieee80211_sample doesn't have the sample_interval field by now */ - // sample->sample_interval = (t < 1) ? 1 : t; } static void -sample_stats(void *arg, struct ieee80211_node *ni) +sample_stats_node(void *arg, struct ieee80211_node *ni) { struct ieee80211vap *vap = ni->ni_vap; struct ieee80211_sample_node *san = ni->ni_rctls; @@ -1071,20 +1065,16 @@ } } } - -static int -sample_sysctl_stats(SYSCTL_HANDLER_ARGS) +static void +sample_stats(const struct ieee80211vap *vap) { - struct ieee80211vap *vap = arg1; struct ieee80211com *ic = vap->iv_ifp->if_l2com; - int error, v; - - v = 0; - error = sysctl_handle_int(oidp, &v, 0, req); - if (error || !req->newptr) - return error; - ieee80211_iterate_nodes(&ic->ic_sta, sample_stats, NULL); - return 0; + struct ieee80211_rc_stat * irs = IEEE80211_RATECTL_STAT(vap); + printf("tx count: %d (ok count: %d, fail count: %d)\n" + "retry count: %d (short retry: %d, long retry: %d)\n", + irs->irs_txcnt, irs->irs_txcnt - irs->irs_failcnt, irs->irs_failcnt, + irs->irs_retrycnt, irs->irs_shortretry, irs->irs_longretry); + ieee80211_iterate_nodes(&ic->ic_sta, sample_stats_node, NULL); } static int @@ -1134,8 +1124,4 @@ "sample_rate", CTLTYPE_INT | CTLFLAG_RW, vap, 0, sample_sysctl_sample_rate, "I", "sample: percent air time devoted to sampling new rates (%%)"); - /* XXX max_successive_failures, stale_failure_timeout, min_switch */ - SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO, - "sample_stats", CTLTYPE_INT | CTLFLAG_RW, vap, 0, - sample_sysctl_stats, "I", "sample: print statistics"); } Copied and modified: soc2013/ccqin/head/sys/net80211/ieee80211_sample.h (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h) ============================================================================== --- soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample.h Mon Sep 2 08:00:12 2013 (r256825, copy source) +++ soc2013/ccqin/head/sys/net80211/ieee80211_sample.h Mon Sep 16 08:08:52 2013 (r257398) @@ -143,25 +143,28 @@ return NUM_PACKET_SIZE_BINS-1; } -static uint32_t sample_pkt_txtime(const struct ieee80211_rate_table *rt, +static uint32_t sample_pkt_tx_time(const struct ieee80211_rate_table *rt, uint32_t frameLen, uint16_t rateix, int isht40, int isShortPreamble) { - uint8_t rc; - int numStreams; + uint8_t rate = rt->info[rateix].dot11Rate; + uint32_t tx_time = 0; - rc = rt->info[rateix].rateCode; - - /* Legacy rate? Return the old way */ - if (! IS_HT_RATE(rc)) - return ieee80211_compute_duration(rt, frameLen, rateix, isShortPreamble); - - /* 11n frame - extract out the number of spatial streams */ - numStreams = HT_RC_2_STREAMS(rc); - KASSERT(numStreams > 0 && numStreams <= 4, - ("number of spatial streams needs to be 1..3: MCS rate 0x%x!", - rateix)); + if (rt->info[rateix].phy == IEEE80211_T_HT) { + int numStreams; + /* 11n frame - extract out the number of spatial streams */ + rate |= IEEE80211_RATE_MCS; + numStreams = HT_RC_2_STREAMS(rate); + KASSERT(numStreams > 0 && numStreams <= 4, + ("number of spatial streams needs to be 1..3: MCS rate 0x%x!", + rateix)); + tx_time = ieee80211_compute_duration_ht(frameLen, rate, numStreams, isht40, isShortPreamble); + } else { + /* Legacy rate? Return the old way */ + rate &= IEEE80211_RATE_VAL; + tx_time = ieee80211_compute_duration(rt, frameLen, rate, isShortPreamble); + } - return ieee80211_compute_duration_ht(frameLen, rc, numStreams, isht40, isShortPreamble); + return tx_time; } #define WIFI_CW_MIN 31 @@ -183,9 +186,9 @@ int rts, cts; int tt, x, cw, cix; - int tt = 0; - int x = 0; - int cw = WIFI_CW_MIN; + tt = 0; + x = 0; + cw = WIFI_CW_MIN; KASSERT(rt != NULL, ("no rate table, mode %u", curmode)); @@ -194,7 +197,7 @@ rix, rt->rateCount, curmode); return 0; } - cix = rt->info[rix].controlRate; + cix = rt->info[rix].ctlRateIndex; /* * XXX getting mac/phy level timings should be fixed for turbo * rates, and there is probably a way to get this from the @@ -242,7 +245,7 @@ if (0xff == protrix) protrix = 0; - cix = rt->info[protrix].controlRate; + cix = rt->info[protrix].ctlRateIndex; } if (0 /*length > ic->ic_rtsthreshold */) { @@ -250,7 +253,6 @@ } if (rts || cts) { - int ctsrate; int ctsduration = 0; /* NB: this is intentionally not a runtime check */ @@ -258,12 +260,11 @@ ("bogus cix %d, max %u, mode %u\n", cix, rt->rateCount, curmode)); - ctsrate = rt->info[cix].rateCode | rt->info[cix].shortPreamble; if (rts) /* SIFS + CTS */ ctsduration += rt->info[cix].spAckDuration; /* XXX assumes short preamble */ - ctsduration += sample_pkt_txtime(rt, length, rix, is_ht40, 0); + ctsduration += sample_pkt_tx_time(rt, length, rix, is_ht40, 0); if (cts) /* SIFS + ACK */ ctsduration += rt->info[cix].spAckDuration; @@ -273,7 +274,7 @@ tt += t_difs; /* XXX assumes short preamble */ - tt += (long_retries+1)*sample_pkt_txtime(rt, length, rix, is_ht40, 0); + tt += (long_retries+1)*sample_pkt_tx_time(rt, length, rix, is_ht40, 0); tt += (long_retries+1)*(t_sifs + rt->info[rix].spAckDuration); Copied: soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h (from r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/ccqin/head/sys/net80211/ieee80211_sample_txsched.h Mon Sep 16 08:08:52 2013 (r257398, copy of r256825, soc2013/ccqin/head/sys/net80211/ieee80211_rc_sample_txsched.h) @@ -0,0 +1,241 @@ +/* $FreeBSD: head/sys/dev/ath/ath_rate/sample/tx_schedules.h 240384 2012-08-15 07:50:42Z adrian $*/ + +/*- + * Copyright (c) 2005 John Bicket + * Copyright (c) 2013 Chenchong Qin + * 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, + * without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + * redistribution must be conditioned upon including a substantially + * similar Disclaimer requirement for further binary redistribution. + * 3. Neither the names of the above-listed copyright holders nor the names + * of any contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. + * + */ +#ifndef _NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_ +#define _NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_ + +#include + +#define A(_r) \ + (((_r) == 6) ? 0 : (((_r) == 9) ? 1 : (((_r) == 12) ? 2 : \ + (((_r) == 18) ? 3 : (((_r) == 24) ? 4 : (((_r) == 36) ? 5 : \ + (((_r) == 48) ? 6 : (((_r) == 54) ? 7 : 0)))))))) +static const struct txschedule series_11a[] = { + { 3,A( 6), 3,A( 6), 0,A( 6), 0,A( 6) }, /* 6Mb/s */ + { 4,A( 9), 3,A( 6), 4,A( 6), 0,A( 6) }, /* 9Mb/s */ + { 4,A(12), 3,A( 6), 4,A( 6), 0,A( 6) }, /* 12Mb/s */ + { 4,A(18), 3,A( 12), 4,A( 6), 2,A( 6) }, /* 18Mb/s */ + { 4,A(24), 3,A( 18), 4,A( 12), 2,A( 6) }, /* 24Mb/s */ + { 4,A(36), 3,A( 24), 4,A( 18), 2,A( 6) }, /* 36Mb/s */ + { 4,A(48), 3,A( 36), 4,A( 24), 2,A(12) }, /* 48Mb/s */ + { 4,A(54), 3,A( 48), 4,A( 36), 2,A(24) } /* 54Mb/s */ +}; + +#define NA1(_r) \ + (((_r) == 6.5) ? 8 : (((_r) == 13) ? 9 : (((_r) == 19.5)? 10 : \ + (((_r) == 26) ? 11 : (((_r) == 39) ? 12 : (((_r) == 52) ? 13 : \ + (((_r) == 58.5)? 14 : (((_r) == 65) ? 15 : 0)))))))) +#define NA2(_r) \ + (((_r) == 13) ? 16 : (((_r) == 26) ? 17 : (((_r) == 39) ? 18 : \ + (((_r) == 52) ? 19 : (((_r) == 78) ? 20 : (((_r) == 104)? 21 : \ + (((_r) == 117)? 22 : (((_r) == 130)? 23 : 0)))))))) +#define NA3(_r) \ + (((_r) == 19.5) ? 24 : (((_r) == 39) ? 25 : (((_r) == 58.5) ? 26 : \ + (((_r) == 78) ? 27 : (((_r) == 117) ? 28 : (((_r) == 156) ? 29 : \ + (((_r) == 175.5) ? 30 : (((_r) == 195)? 31 : 0)))))))) +static const struct txschedule series_11na[] = { + { 3,A( 6), 3,A( 6), 0,A( 6), 0,A( 6) }, /* 6Mb/s */ + { 4,A( 9), 3,A( 6), 4,A( 6), 0,A( 6) }, /* 9Mb/s */ + { 4,A(12), 3,A( 6), 4,A( 6), 0,A( 6) }, /* 12Mb/s */ + { 4,A(18), 3,A( 12), 4,A( 6), 2,A( 6) }, /* 18Mb/s */ + { 4,A(24), 3,A( 18), 4,A( 12), 2,A( 6) }, /* 24Mb/s */ + { 4,A(36), 3,A( 24), 4,A( 18), 2,A( 6) }, /* 36Mb/s */ + { 4,A(48), 3,A( 36), 4,A( 24), 2,A(12) }, /* 48Mb/s */ + { 4,A(54), 3,A( 48), 4,A( 36), 2,A(24) }, /* 54Mb/s */ + + /* 1 stream rates */ + + { 3,NA1( 6.5), 3,NA1( 6.5), 0,NA1( 6.5), 0,NA1(6.5) }, /* 6.5Mb/s */ + { 4,NA1( 13), 3,NA1( 6.5), 4,NA1( 6.5), 0,NA1(6.5) }, /* 13Mb/s */ + { 4,NA1(19.5), 3,NA1( 6.5), 4,NA1( 6.5), 0,NA1(6.5) }, /*19.5Mb/s */ + { 4,NA1( 26), 3,NA1(19.5), 4,NA1( 6.5), 2,NA1(6.5) }, /* 26Mb/s */ + { 4,NA1( 39), 3,NA1( 26), 4,NA1(19.5), 2,NA1(6.5) }, /* 39Mb/s */ + { 4,NA1( 52), 3,NA1( 39), 4,NA1( 26), 2,NA1(6.5) }, /* 52Mb/s */ + { 4,NA1(58.5), 3,NA1( 52), 4,NA1( 39), 2,NA1( 13) }, /*58.5Mb/s */ + { 4,NA1( 65), 3,NA1(58.5), 4,NA1( 52), 2,NA1( 13) }, /* 65Mb/s */ + + /* 2 stream rates */ + + { 3,NA2( 13), 3,NA2( 13), 0,NA2( 13), 0,NA2( 13) }, /* 13Mb/s */ + { 4,NA2( 26), 3,NA2( 13), 4,NA2( 13), 0,NA2( 13) }, /* 26Mb/s */ + { 4,NA2( 39), 3,NA2( 26), 4,NA2( 13), 2,NA2( 13) }, /* 39Mb/s */ + { 4,NA2( 52), 3,NA2( 39), 4,NA2( 26), 2,NA2( 13) }, /* 52Mb/s */ + { 4,NA2( 78), 3,NA2( 52), 4,NA2( 39), 2,NA2( 13) }, /* 78Mb/s */ + { 4,NA2( 104), 3,NA2( 78), 4,NA2( 52), 2,NA2( 13) }, /* 104Mb/s */ + { 4,NA2( 117), 3,NA2( 104), 4,NA2( 78), 2,NA2( 26) }, /* 117Mb/s */ + { 4,NA2( 130), 3,NA2( 117), 4,NA2( 104), 2,NA2( 26) }, /* 130Mb/s */ + + /* 3 stream rates */ + + { 3,NA3(19.5), 3,NA3(19.5), 0,NA3(19.5), 0,NA3(19.5) }, /* 19Mb/s */ + { 3,NA3( 39), 3,NA3(19.5), 0,NA3(19.5), 0,NA3(19.5) }, /* 39Mb/s */ + { 3,NA3(58.5), 3,NA3( 39), 0,NA3(19.5), 0,NA3(19.5) }, /* 58Mb/s */ + { 3,NA3( 78), 3,NA3(58.5), 0,NA3( 39), 0,NA3(19.5) }, /* 78Mb/s */ + { 3,NA3( 117), 3,NA3( 78), 0,NA3(58.5), 0,NA3(19.5) }, /* 117Mb/s */ + { 3,NA3( 156), 3,NA3( 117), 0,NA3( 78), 0,NA3(19.5) }, /* 156Mb/s */ + { 3,NA3(175.5), 3,NA3( 156), 0,NA3( 117), 0,NA3( 39) }, /* 175Mb/s */ + { 3,NA3( 195), 3,NA3( 195), 0,NA3( 156), 0,NA3(58.5) }, /* 195Mb/s */ +}; +#undef A +#undef NA3 +#undef NA2 +#undef NA1 + +#define G(_r) \ + (((_r) == 1) ? 0 : (((_r) == 2) ? 1 : (((_r) == 5.5) ? 2 : \ + (((_r) == 11) ? 3 : (((_r) == 6) ? 4 : (((_r) == 9) ? 5 : \ + (((_r) == 12) ? 6 : (((_r) == 18) ? 7 : (((_r) == 24) ? 8 : \ + (((_r) == 36) ? 9 : (((_r) == 48) ? 10 : (((_r) == 54) ? 11 : 0)))))))))))) +static const struct txschedule series_11g[] = { + { 3,G( 1), 3,G( 1), 0,G( 1), 0,G( 1) }, /* 1Mb/s */ + { 4,G( 2), 3,G( 1), 4,G( 1), 0,G( 1) }, /* 2Mb/s */ + { 4,G(5.5),3,G( 2), 4,G( 1), 2,G( 1) }, /* 5.5Mb/s */ + { 4,G(11), 3,G(5.5), 4,G( 2), 2,G( 1) }, /* 11Mb/s */ + { 4,G( 6), 3,G(5.5), 4,G( 2), 2,G( 1) }, /* 6Mb/s */ + { 4,G( 9), 3,G( 6), 4,G(5.5), 2,G( 1) }, /* 9Mb/s */ + { 4,G(12), 3,G( 11), 4,G(5.5), 2,G( 1) }, /* 12Mb/s */ + { 4,G(18), 3,G( 12), 4,G( 11), 2,G( 1) }, /* 18Mb/s */ + { 4,G(24), 3,G( 18), 4,G( 12), 2,G( 1) }, /* 24Mb/s */ + { 4,G(36), 3,G( 24), 4,G( 18), 2,G( 1) }, /* 36Mb/s */ + { 4,G(48), 3,G( 36), 4,G( 24), 2,G( 1) }, /* 48Mb/s */ + { 4,G(54), 3,G( 48), 4,G( 36), 2,G( 1) } /* 54Mb/s */ +}; + +#define NG1(_r) \ + (((_r) == 6.5) ? 12 : (((_r) == 13) ? 13 : (((_r) == 19.5)? 14 : \ + (((_r) == 26) ? 15 : (((_r) == 39) ? 16 : (((_r) == 52) ? 17 : \ + (((_r) == 58.5)? 18 : (((_r) == 65) ? 19 : 0)))))))) +#define NG2(_r) \ + (((_r) == 13) ? 20 : (((_r) == 26) ? 21 : (((_r) == 39) ? 22 : \ + (((_r) == 52) ? 23 : (((_r) == 78) ? 24 : (((_r) == 104) ? 25 : \ + (((_r) == 117) ? 26 : (((_r) == 130)? 27 : 0)))))))) +#define NG3(_r) \ + (((_r) == 19.5) ? 28 : (((_r) == 39) ? 29 : (((_r) == 58.5) ? 30 : \ + (((_r) == 78) ? 31 : (((_r) == 117) ? 32 : (((_r) == 156) ? 33 : \ + (((_r) == 175.5) ? 34 : (((_r) == 195)? 35 : 0)))))))) + +static const struct txschedule series_11ng[] = { + { 3,G( 1), 3,G( 1), 0,G( 1), 0,G( 1) }, /* 1Mb/s */ + { 4,G( 2), 3,G( 1), 4,G( 1), 0,G( 1) }, /* 2Mb/s */ + { 4,G(5.5),3,G( 2), 4,G( 1), 2,G( 1) }, /* 5.5Mb/s */ + { 4,G(11), 3,G(5.5), 4,G( 2), 2,G( 1) }, /* 11Mb/s */ + { 4,G( 6), 3,G(5.5), 4,G( 2), 2,G( 1) }, /* 6Mb/s */ + { 4,G( 9), 3,G( 6), 4,G(5.5), 2,G( 1) }, /* 9Mb/s */ + { 4,G(12), 3,G( 11), 4,G(5.5), 2,G( 1) }, /* 12Mb/s */ + { 4,G(18), 3,G( 12), 4,G( 11), 2,G( 1) }, /* 18Mb/s */ + { 4,G(24), 3,G( 18), 4,G( 12), 2,G( 1) }, /* 24Mb/s */ + { 4,G(36), 3,G( 24), 4,G( 18), 2,G( 1) }, /* 36Mb/s */ + { 4,G(48), 3,G( 36), 4,G( 24), 2,G( 1) }, /* 48Mb/s */ + { 4,G(54), 3,G( 48), 4,G( 36), 2,G( 1) }, /* 54Mb/s */ + + /* 1 stream rates */ + + { 3,NG1( 6.5), 3,NG1( 6.5), 0,NG1( 6.5), 0,NG1(6.5) }, /* 6.5Mb/s */ + { 4,NG1( 13), 3,NG1( 6.5), 4,NG1( 6.5), 0,NG1(6.5) }, /* 13Mb/s */ + { 4,NG1(19.5), 3,NG1( 6.5), 4,NG1( 6.5), 0,NG1(6.5) }, /*19.5Mb/s */ + { 4,NG1( 26), 3,NG1(19.5), 4,NG1( 6.5), 2,NG1(6.5) }, /* 26Mb/s */ + { 4,NG1( 39), 3,NG1( 26), 4,NG1(19.5), 2,NG1(6.5) }, /* 39Mb/s */ + { 4,NG1( 52), 3,NG1( 39), 4,NG1( 26), 2,NG1(6.5) }, /* 52Mb/s */ + { 4,NG1(58.5), 3,NG1( 52), 4,NG1( 39), 2,NG1( 13) }, /*58.5Mb/s */ + { 4,NG1( 65), 3,NG1(58.5), 4,NG1( 52), 2,NG1( 13) }, /* 65Mb/s */ + + /* 2 stream rates */ + + { 3,NG2( 13), 3,NG2( 13), 0,NG2( 13), 0,NG2( 13) }, /* 13Mb/s */ + { 4,NG2( 26), 3,NG2( 13), 4,NG2( 13), 0,NG2( 13) }, /* 26Mb/s */ + { 4,NG2( 39), 3,NG2( 26), 4,NG2( 13), 2,NG2( 13) }, /* 39Mb/s */ + { 4,NG2( 52), 3,NG2( 39), 4,NG2( 26), 2,NG2( 13) }, /* 52Mb/s */ + { 4,NG2( 78), 3,NG2( 52), 4,NG2( 39), 2,NG2( 13) }, /* 78Mb/s */ + { 4,NG2( 104), 3,NG2( 78), 4,NG2( 52), 2,NG2( 13) }, /* 104Mb/s */ + { 4,NG2( 117), 3,NG2( 104), 4,NG2( 78), 2,NG2( 26) }, /* 117Mb/s */ + { 4,NG2( 130), 3,NG2( 117), 4,NG2( 104), 2,NG2( 26) }, /* 130Mb/s */ + + /* 3 stream rates */ + + { 3,NG3(19.5), 3,NG3(19.5), 0,NG3(19.5), 0,NG3(19.5) }, /* 19Mb/s */ + { 3,NG3( 39), 3,NG3(19.5), 0,NG3(19.5), 0,NG3(19.5) }, /* 39Mb/s */ + { 3,NG3(58.5), 3,NG3( 39), 0,NG3(19.5), 0,NG3(19.5) }, /* 58Mb/s */ + { 3,NG3( 78), 3,NG3(58.5), 0,NG3( 39), 0,NG3(19.5) }, /* 78Mb/s */ + { 3,NG3( 117), 3,NG3( 78), 0,NG3(58.5), 0,NG3(19.5) }, /* 117Mb/s */ + { 3,NG3( 156), 3,NG3( 117), 0,NG3( 78), 0,NG3(19.5) }, /* 156Mb/s */ + { 3,NG3(175.5), 3,NG3( 156), 0,NG3( 117), 0,NG3( 39) }, /* 175Mb/s */ + { 3,NG3( 195), 3,NG3( 195), 0,NG3( 156), 0,NG3(58.5) }, /* 195Mb/s */ + +}; +#undef G +#undef NG3 +#undef NG2 +#undef NG1 + +#define H(_r) \ + (((_r) == 3) ? 0 : (((_r) == 4.5) ? 1 : (((_r) == 6) ? 2 : \ + (((_r) == 9) ? 3 : (((_r) == 12) ? 4 : (((_r) == 18) ? 5 : \ + (((_r) == 24) ? 6 : (((_r) == 27) ? 7 : 0)))))))) +static const struct txschedule series_half[] = { + { 3,H( 3), 3,H( 3), 0,H( 3), 0,H( 3) }, /* 3Mb/s */ + { 4,H(4.5),3,H( 3), 4,H( 3), 0,H( 3) }, /* 4.5Mb/s */ + { 4,H( 6), 3,H( 3), 4,H( 3), 0,H( 3) }, /* 6Mb/s */ + { 4,H( 9), 3,H( 6), 4,H( 3), 2,H( 3) }, /* 9Mb/s */ + { 4,H(12), 3,H( 9), 4,H( 6), 2,H( 3) }, /* 12Mb/s */ + { 4,H(18), 3,H( 12), 4,H( 9), 2,H( 3) }, /* 18Mb/s */ + { 4,H(24), 3,H( 18), 4,H( 12), 2,H( 6) }, /* 24Mb/s */ + { 4,H(27), 3,H( 24), 4,H( 18), 2,H(12) } /* 27Mb/s */ +}; +#undef H + +#ifdef Q +#undef Q +#endif +#define Q(_r) \ + (((_r) == 1.5) ? 0 : (((_r) ==2.25) ? 1 : (((_r) == 3) ? 2 : \ + (((_r) == 4.5) ? 3 : (((_r) == 6) ? 4 : (((_r) == 9) ? 5 : \ + (((_r) == 12) ? 6 : (((_r) == 13.5)? 7 : 0)))))))) +static const struct txschedule series_quarter[] = { + { 3,Q( 1.5),3,Q(1.5), 0,Q(1.5), 0,Q(1.5) }, /* 1.5Mb/s */ + { 4,Q(2.25),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) }, /*2.25Mb/s */ + { 4,Q( 3),3,Q(1.5), 4,Q(1.5), 0,Q(1.5) }, /* 3Mb/s */ + { 4,Q( 4.5),3,Q( 3), 4,Q(1.5), 2,Q(1.5) }, /* 4.5Mb/s */ + { 4,Q( 6),3,Q(4.5), 4,Q( 3), 2,Q(1.5) }, /* 6Mb/s */ + { 4,Q( 9),3,Q( 6), 4,Q(4.5), 2,Q(1.5) }, /* 9Mb/s */ + { 4,Q( 12),3,Q( 9), 4,Q( 6), 2,Q( 3) }, /* 12Mb/s */ + { 4,Q(13.5),3,Q( 12), 4,Q( 9), 2,Q( 6) } /*13.5Mb/s */ +}; +#undef Q + +#endif /* _NET80211_IEEE80211_RATECTL_SAMPLE_TXSCHEDULES_H_ */ From owner-svn-soc-all@FreeBSD.ORG Tue Sep 17 15:41:15 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 7E2EE243 for ; Tue, 17 Sep 2013 15:41:15 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 69C732D48 for ; Tue, 17 Sep 2013 15:41:15 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8HFfFTE074754 for ; Tue, 17 Sep 2013 15:41:15 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8HFfFaY074745 for svn-soc-all@FreeBSD.org; Tue, 17 Sep 2013 15:41:15 GMT (envelope-from zcore@FreeBSD.org) Date: Tue, 17 Sep 2013 15:41:15 GMT Message-Id: <201309171541.r8HFfFaY074745@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257427 - soc2013/zcore/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.14 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, 17 Sep 2013 15:41:15 -0000 Author: zcore Date: Tue Sep 17 15:41:15 2013 New Revision: 257427 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257427 Log: fix CI clear for NCQ Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Tue Sep 17 14:23:15 2013 (r257426) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Tue Sep 17 15:41:15 2013 (r257427) @@ -256,7 +256,6 @@ if (fis[2] & ATA_S_ERROR) p->is |= AHCI_P_IX_TFE; p->tfd = tfd; - p->ci &= ~(1 << slot); ahci_write_fis(p, FIS_TYPE_SETDEVBITS, fis); } @@ -374,7 +373,7 @@ static void handle_dma(struct ahci_port *p, int slot, uint8_t *cfis) { - int i, err, readop = 1; + int i, err, ncq = 0, readop = 1; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -398,6 +397,7 @@ len = cfis[11] << 8 | cfis[3]; if (!len) len = 65536; + ncq = 1; } else if (cfis[2] == ATA_READ_DMA48 || cfis[2] == ATA_WRITE_DMA48) { lba = ((uint64_t)cfis[10] << 40) | ((uint64_t)cfis[9] << 32) | @@ -445,6 +445,9 @@ else err = blockif_write(p->bctx, breq); assert(err == 0); + + if (ncq) + p->ci &= ~(1 << slot); } static void From owner-svn-soc-all@FreeBSD.ORG Wed Sep 18 15:00:02 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 7CDFF2B2 for ; Wed, 18 Sep 2013 15:00:02 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6A57A2FAD for ; Wed, 18 Sep 2013 15:00:02 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8IF02o4010483 for ; Wed, 18 Sep 2013 15:00:02 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8IF02SV010474 for svn-soc-all@FreeBSD.org; Wed, 18 Sep 2013 15:00:02 GMT (envelope-from zcore@FreeBSD.org) Date: Wed, 18 Sep 2013 15:00:02 GMT Message-Id: <201309181500.r8IF02SV010474@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257458 - soc2013/zcore/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.14 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, 18 Sep 2013 15:00:02 -0000 Author: zcore Date: Wed Sep 18 15:00:02 2013 New Revision: 257458 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257458 Log: fix SLOTs setting if blockif queue size is larger than 32 Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Wed Sep 18 11:07:32 2013 (r257457) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Wed Sep 18 15:00:02 2013 (r257458) @@ -1305,7 +1305,10 @@ pthread_mutex_init(&sc->mtx, NULL); /* Intel Cougar Point AHCI */ - slots = sc->port[0].ioqsz - 1; + slots = sc->port[0].ioqsz; + if (slots > 32) + slots = 32; + --slots; sc->cap = AHCI_CAP_64BIT | AHCI_CAP_SNCQ | AHCI_CAP_SSNTF | AHCI_CAP_SMPS | AHCI_CAP_SSS | AHCI_CAP_SALP | AHCI_CAP_SAL | AHCI_CAP_SCLO | (0x3 << AHCI_CAP_ISS_SHIFT)| From owner-svn-soc-all@FreeBSD.ORG Wed Sep 18 22:03:21 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2B8A3E5A for ; Wed, 18 Sep 2013 22:03:21 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0AF692924 for ; Wed, 18 Sep 2013 22:03:21 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8IM3Kdb090021 for ; Wed, 18 Sep 2013 22:03:20 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8IM3KQu090008 for svn-soc-all@FreeBSD.org; Wed, 18 Sep 2013 22:03:20 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 18 Sep 2013 22:03:20 GMT Message-Id: <201309182203.r8IM3KQu090008@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257471 - in soc2013/dpl/head/usr.bin/bsdiff: bsdiff bspatch 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.14 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, 18 Sep 2013 22:03:21 -0000 Author: dpl Date: Wed Sep 18 22:03:20 2013 New Revision: 257471 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257471 Log: Ported bsdiff and bspatch to Capsicum. Hope that it is useful. Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Wed Sep 18 21:15:21 2013 (r257470) +++ soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Wed Sep 18 22:03:20 2013 (r257471) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include @@ -41,7 +42,7 @@ #define O_BINARY 0 #endif -#define MIN(x,y) (((x)<(y)) ? (x) : (y)) +#define DMIN(x,y) (((x)<(y)) ? (x) : (y)) static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h) { @@ -171,7 +172,7 @@ }; x=st+(en-st)/2; - if(memcmp(old+I[x],new,MIN(oldsize-I[x],newsize))<0) { + if(memcmp(old+I[x],new,DMIN(oldsize-I[x],newsize))<0) { return search(I,old,oldsize,new,newsize,x,en,pos); } else { return search(I,old,oldsize,new,newsize,st,x,pos); @@ -198,7 +199,7 @@ int main(int argc,char *argv[]) { - int fd; + int first, second; u_char *old,*new; off_t oldsize,newsize; off_t *I,*V; @@ -215,17 +216,39 @@ FILE * pf; BZFILE * pfbz2; int bz2err; + cap_rights_t filerights, pathrights; if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); + /* Capsicum */ + if ((first = open(argv[1],O_RDONLY|O_BINARY,0)) < 0) + err(1,"%s",argv[1]); + if ((second = open(argv[2], O_RDONLY|O_BINARY, 0)) < 0) + err(1,"%s",argv[1]); + /* Create the patch file */ + if ((pf = fopen(argv[3], "wb")) == NULL) + err(1, "%s", argv[3]); + + cap_rights_init(&filerights, CAP_READ, CAP_SEEK); + cap_rights_init(&pathrights, CAP_WRITE, CAP_SEEK); + + if (cap_rights_limit(first, &filerights) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(second, &filerights) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(fileno(pf), &pathrights) < 0) + err(1, "Couldn't limit fd"); + + if (cap_enter() < 0) + err(1, "Couldn't enter capability mode"); + /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure that we never try to malloc(0) and get a NULL pointer */ - if(((fd=open(argv[1],O_RDONLY|O_BINARY,0))<0) || - ((oldsize=lseek(fd,0,SEEK_END))==-1) || + if(((oldsize=lseek(first,0,SEEK_END))==-1) || ((old=malloc(oldsize+1))==NULL) || - (lseek(fd,0,SEEK_SET)!=0) || - (read(fd,old,oldsize)!=oldsize) || - (close(fd)==-1)) err(1,"%s",argv[1]); + (lseek(first,0,SEEK_SET)!=0) || + (read(first,old,oldsize)!=oldsize) || + (close(first)==-1)) err(1,"%s",argv[1]); if(((I=malloc((oldsize+1)*sizeof(off_t)))==NULL) || ((V=malloc((oldsize+1)*sizeof(off_t)))==NULL)) err(1,NULL); @@ -236,22 +259,17 @@ /* Allocate newsize+1 bytes instead of newsize bytes to ensure that we never try to malloc(0) and get a NULL pointer */ - if(((fd=open(argv[2],O_RDONLY|O_BINARY,0))<0) || - ((newsize=lseek(fd,0,SEEK_END))==-1) || + if(((newsize=lseek(second,0,SEEK_END))==-1) || ((new=malloc(newsize+1))==NULL) || - (lseek(fd,0,SEEK_SET)!=0) || - (read(fd,new,newsize)!=newsize) || - (close(fd)==-1)) err(1,"%s",argv[2]); + (lseek(second,0,SEEK_SET)!=0) || + (read(second,new,newsize)!=newsize) || + (close(second)==-1)) err(1,"%s",argv[2]); if(((db=malloc(newsize+1))==NULL) || ((eb=malloc(newsize+1))==NULL)) err(1,NULL); dblen=0; eblen=0; - /* Create the patch file */ - if ((pf = fopen(argv[3], "wb")) == NULL) - err(1, "%s", argv[3]); - /* Header is 0 8 "BSDIFF40" 8 8 length of bzip2ed ctrl block Modified: soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Wed Sep 18 21:15:21 2013 (r257470) +++ soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Wed Sep 18 22:03:20 2013 (r257471) @@ -24,6 +24,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include __FBSDID("$FreeBSD$"); @@ -62,7 +63,6 @@ FILE * f, * cpf, * dpf, * epf; BZFILE * cpfbz2, * dpfbz2, * epfbz2; int cbz2err, dbz2err, ebz2err; - int fd; ssize_t oldsize,newsize; ssize_t bzctrllen,bzdatalen; u_char header[32],buf[8]; @@ -71,12 +71,46 @@ off_t ctrl[3]; off_t lenread; off_t i; + int first, second; + cap_rights_t firstr, secondr, patchr, bzfiler; if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); + /* Capsicum */ + if ((first = open(argv[1],O_RDONLY|O_BINARY,0)) < 0) + err(1,"%s",argv[1]); + if ((second = open(argv[2],O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666)) < 0) + err(1,"%s",argv[1]); /* Open patch file */ if ((f = fopen(argv[3], "rb")) == NULL) err(1, "fopen(%s)", argv[3]); + if ((cpf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + if ((dpf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + if ((epf = fopen(argv[3], "rb")) == NULL) + err(1, "fopen(%s)", argv[3]); + + cap_rights_init(&firstr, CAP_READ, CAP_SEEK); + cap_rights_init(&secondr, CAP_WRITE); + cap_rights_init(&patchr, CAP_READ, CAP_SEEK); + cap_rights_init(&bzfiler, CAP_READ, CAP_SEEK); + + if (cap_rights_limit(first, &firstr) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(second, &secondr) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(fileno(f), &patchr) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(fileno(cpf), &bzfiler) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(fileno(dpf), &bzfiler) < 0) + err(1, "Couldn't limit fd"); + if (cap_rights_limit(fileno(epf), &bzfiler) < 0) + err(1, "Couldn't limit fd"); + + if (cap_enter() < 0) + err(1, "Couldn't enter capability mode"); /* File format: @@ -113,34 +147,27 @@ /* Close patch file and re-open it via libbzip2 at the right places */ if (fclose(f)) err(1, "fclose(%s)", argv[3]); - if ((cpf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); if (fseeko(cpf, 32, SEEK_SET)) err(1, "fseeko(%s, %lld)", argv[3], (long long)32); if ((cpfbz2 = BZ2_bzReadOpen(&cbz2err, cpf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", cbz2err); - if ((dpf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); if (fseeko(dpf, 32 + bzctrllen, SEEK_SET)) err(1, "fseeko(%s, %lld)", argv[3], (long long)(32 + bzctrllen)); if ((dpfbz2 = BZ2_bzReadOpen(&dbz2err, dpf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", dbz2err); - if ((epf = fopen(argv[3], "rb")) == NULL) - err(1, "fopen(%s)", argv[3]); if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET)) err(1, "fseeko(%s, %lld)", argv[3], (long long)(32 + bzctrllen + bzdatalen)); if ((epfbz2 = BZ2_bzReadOpen(&ebz2err, epf, 0, 0, NULL, 0)) == NULL) errx(1, "BZ2_bzReadOpen, bz2err = %d", ebz2err); - if(((fd=open(argv[1],O_RDONLY|O_BINARY,0))<0) || - ((oldsize=lseek(fd,0,SEEK_END))==-1) || + if(((oldsize=lseek(first,0,SEEK_END))==-1) || ((old=malloc(oldsize+1))==NULL) || - (lseek(fd,0,SEEK_SET)!=0) || - (read(fd,old,oldsize)!=oldsize) || - (close(fd)==-1)) err(1,"%s",argv[1]); + (lseek(first,0,SEEK_SET)!=0) || + (read(first,old,oldsize)!=oldsize) || + (close(first)==-1)) err(1,"%s",argv[1]); if((new=malloc(newsize+1))==NULL) err(1,NULL); oldpos=0;newpos=0; @@ -196,8 +223,7 @@ err(1, "fclose(%s)", argv[3]); /* Write the new file */ - if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666))<0) || - (write(fd,new,newsize)!=newsize) || (close(fd)==-1)) + if((write(second,new,newsize)!=newsize) || (close(second)==-1)) err(1,"%s",argv[2]); free(new); From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 12:37:54 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D27F468E for ; Thu, 19 Sep 2013 12:37:54 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BECC32AAF for ; Thu, 19 Sep 2013 12:37:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JCbs3V018807 for ; Thu, 19 Sep 2013 12:37:54 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JCbssT018799 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 12:37:54 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 19 Sep 2013 12:37:54 GMT Message-Id: <201309191237.r8JCbssT018799@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257494 - soc2013/mattbw/backend 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.14 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, 19 Sep 2013 12:37:54 -0000 Author: mattbw Date: Thu Sep 19 12:37:54 2013 New Revision: 257494 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257494 Log: We don't need to pull in gio, just glib. Modified: soc2013/mattbw/backend/Makefile Modified: soc2013/mattbw/backend/Makefile ============================================================================== --- soc2013/mattbw/backend/Makefile Thu Sep 19 11:06:58 2013 (r257493) +++ soc2013/mattbw/backend/Makefile Thu Sep 19 12:37:54 2013 (r257494) @@ -69,7 +69,7 @@ LIBDIR= /usr/local/lib/packagekit-backend -PKGS= pkg gio-2.0 gio-unix-2.0 +PKGS= pkg glib-2.0 # ATF test flags TESTPROGS= \ From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 12:51:39 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CAA507E3 for ; Thu, 19 Sep 2013 12:51:39 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B776B2B61 for ; Thu, 19 Sep 2013 12:51:39 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JCpdMh008321 for ; Thu, 19 Sep 2013 12:51:39 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JCpdPj008308 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 12:51:39 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 19 Sep 2013 12:51:39 GMT Message-Id: <201309191251.r8JCpdPj008308@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257495 - soc2013/mattbw 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.14 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, 19 Sep 2013 12:51:39 -0000 Author: mattbw Date: Thu Sep 19 12:51:39 2013 New Revision: 257495 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257495 Log: Update README. Modified: soc2013/mattbw/README Modified: soc2013/mattbw/README ============================================================================== --- soc2013/mattbw/README Thu Sep 19 12:37:54 2013 (r257494) +++ soc2013/mattbw/README Thu Sep 19 12:51:39 2013 (r257495) @@ -2,8 +2,7 @@ http://wiki.freebsd.org/SummerOfCode2013/pkgPackagekit -------------------------------------------------------------------------------- -This is a Google Summer of Code project to create a PackageKit backend for the -FreeBSD pkgng package manager. +This is a PackageKit backend for the FreeBSD pkgng package manager. It is licenced under the GNU General Public License version 2+ (this is because it links to PackageKit itself, which is under this licence). @@ -16,9 +15,10 @@ versions 0.7.x but WILL NOT YET work with 0.8.x due to API incompatibilities) - pkgng (currently building against version 1.1.3; higher versions might work) - FreeBSD (tested with 9.1; should work with higher versions) +- For the tests, atf (devel/atf) is needed to compile and run the unit tests. -Tested primarily with clang in C11 mode; C89 mode likely will not work and C99 -likely would need GNU/clang extensions. +Tested primarily with clang in C11 mode and GCC in GNU99 mode. +C89 and normal C99 mode will not work. -------------------------------------------------------------------------------- From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 16:27:34 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6B347EAB for ; Thu, 19 Sep 2013 16:27:34 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 57ED1296F for ; Thu, 19 Sep 2013 16:27:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JGRYXA066260 for ; Thu, 19 Sep 2013 16:27:34 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JGRYL8066251 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 16:27:34 GMT (envelope-from zcore@FreeBSD.org) Date: Thu, 19 Sep 2013 16:27:34 GMT Message-Id: <201309191627.r8JGRYL8066251@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257501 - soc2013/zcore/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.14 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, 19 Sep 2013 16:27:34 -0000 Author: zcore Date: Thu Sep 19 16:27:34 2013 New Revision: 257501 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257501 Log: remove max iovcnt limitation Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.h Thu Sep 19 14:41:10 2013 (r257500) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Thu Sep 19 16:27:34 2013 (r257501) @@ -32,9 +32,7 @@ #include #include -#include "ahci.h" - -#define BLOCKIF_IOV_MAX AHCI_SG_ENTRIES /* XXX */ +#define BLOCKIF_IOV_MAX 32 /* XXX */ struct blockif_req { struct iovec br_iov[BLOCKIF_IOV_MAX]; Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 14:41:10 2013 (r257500) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:27:34 2013 (r257501) @@ -105,6 +105,7 @@ uint8_t *cfis; uint32_t len; int slot; + int prdtl; }; struct ahci_port { @@ -371,9 +372,9 @@ } static void -handle_dma(struct ahci_port *p, int slot, uint8_t *cfis) +handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, int seek) { - int i, err, ncq = 0, readop = 1; + int i, err, iovcnt, ncq = 0, readop = 1; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -382,6 +383,7 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + prdt += seek; if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48 || cfis[2] == ATA_WRITE_FPDMA_QUEUED) readop = 0; @@ -429,12 +431,18 @@ aior->len = len; breq = &aior->io_req; breq->br_offset = lba; - breq->br_iovcnt = hdr->prdtl; + iovcnt = hdr->prdtl - seek; + if (iovcnt > BLOCKIF_IOV_MAX) { + aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; + iovcnt = BLOCKIF_IOV_MAX; + } else + aior->prdtl = 0; + breq->br_iovcnt = iovcnt; /* * Build up the iovec based on the prdt */ - for (i = 0; i < hdr->prdtl; i++) { + for (i = 0; i < iovcnt; i++) { breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc), prdt->dba, prdt->dbc + 1); breq->br_iov[i].iov_len = prdt->dbc + 1; @@ -446,7 +454,7 @@ err = blockif_write(p->bctx, breq); assert(err == 0); - if (ncq) + if (!aior->prdtl && ncq) p->ci &= ~(1 << slot); } @@ -821,9 +829,9 @@ } static void -atapi_read(struct ahci_port *p, int slot, uint8_t *cfis) +atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, int seek) { - int i, err; + int i, err, iovcnt; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -833,6 +841,7 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + prdt += seek; lba = be32dec(acmd + 2); if (acmd[0] == READ_10) len = be16dec(acmd + 7); @@ -856,7 +865,13 @@ aior->len = len; breq = &aior->io_req; breq->br_offset = lba; - breq->br_iovcnt = hdr->prdtl; + iovcnt = hdr->prdtl - seek; + if (iovcnt > BLOCKIF_IOV_MAX) { + aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; + iovcnt = BLOCKIF_IOV_MAX; + } else + aior->prdtl = 0; + breq->br_iovcnt = iovcnt; /* * Build up the iovec based on the prdt @@ -949,7 +964,7 @@ break; case READ_10: case READ_12: - atapi_read(p, slot, cfis); + atapi_read(p, slot, cfis, 0); break; case REQUEST_SENSE: atapi_request_sense(p, slot, cfis); @@ -1021,7 +1036,7 @@ case ATA_WRITE_DMA48: case ATA_READ_FPDMA_QUEUED: case ATA_WRITE_FPDMA_QUEUED: - handle_dma(p, slot, cfis); + handle_dma(p, slot, cfis, 0); break; case ATA_FLUSHCACHE: case ATA_FLUSHCACHE48: @@ -1130,20 +1145,34 @@ struct ahci_ioreq *aior; uint32_t tfd; struct ahci_cmd_hdr *hdr; - int ncq = 0; + int pending, slot, ncq = 0; + uint8_t *cfis; DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; + cfis = aior->cfis; + slot = aior->slot; + pending = aior->prdtl; sc = p->pr_sc; - hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; - if (aior->cfis[2] == ATA_WRITE_FPDMA_QUEUED || - aior->cfis[2] == ATA_READ_FPDMA_QUEUED) + hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || + cfis[2] == ATA_READ_FPDMA_QUEUED) ncq = 1; pthread_mutex_lock(&sc->mtx); + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + + if (pending && !err) { + handle_dma(p, slot, cfis, hdr->prdtl - pending); + goto out; + } + if (!err) { tfd = ATA_S_READY | ATA_S_DSC; if (ncq) @@ -1154,20 +1183,15 @@ tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; hdr->prdbc = 0; if (ncq) - p->serr |= (1 << aior->slot); + p->serr |= (1 << slot); } if (ncq) { - p->sact &= ~(1 << aior->slot); - ahci_write_fis_sdb(p, aior->slot, tfd); + p->sact &= ~(1 << slot); + ahci_write_fis_sdb(p, slot, tfd); } else - ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); - - /* - * Move the blockif request back to the free list - */ - STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); - + ahci_write_fis_d2h(p, slot, cfis, tfd); +out: pthread_mutex_unlock(&sc->mtx); DPRINTF("%s exit\n", __func__); } @@ -1181,16 +1205,30 @@ struct pci_ahci_softc *sc; struct ahci_ioreq *aior; struct ahci_cmd_hdr *hdr; + int pending, slot; DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; + cfis = aior->cfis; + slot = aior->slot; + pending = aior->prdtl; sc = p->pr_sc; hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; pthread_mutex_lock(&sc->mtx); + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + + if (pending && !err) { + atapi_read(p, slot, cfis, hdr->prdtl - pending); + goto out; + } + if (!err) { tfd = ATA_S_READY | ATA_S_DSC; hdr->prdbc = aior->len; @@ -1201,18 +1239,12 @@ hdr->prdbc = 0; } - cfis = aior->cfis; cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; - ahci_write_fis_d2h(p, aior->slot, cfis, tfd); - - /* - * Move the blockif request back to the free list - */ - STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + ahci_write_fis_d2h(p, slot, cfis, tfd); +out: pthread_mutex_unlock(&sc->mtx); DPRINTF("%s exit\n", __func__); - } static void From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 16:28:03 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 44A22EC4 for ; Thu, 19 Sep 2013 16:28:03 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1750D2975 for ; Thu, 19 Sep 2013 16:28:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JGS2fN071856 for ; Thu, 19 Sep 2013 16:28:02 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JGS2Zp071850 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 16:28:02 GMT (envelope-from zcore@FreeBSD.org) Date: Thu, 19 Sep 2013 16:28:02 GMT Message-Id: <201309191628.r8JGS2Zp071850@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257502 - soc2013/zcore/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.14 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, 19 Sep 2013 16:28:03 -0000 Author: zcore Date: Thu Sep 19 16:28:02 2013 New Revision: 257502 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257502 Log: support MODE_SENSE_10 Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:27:34 2013 (r257501) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:28:02 2013 (r257502) @@ -88,6 +88,12 @@ #define READ_CD 0xBE /* + * SCSI mode page codes + */ +#define MODEPAGE_RW_ERROR_RECOVERY 0x01 +#define MODEPAGE_CD_CAPABILITIES 0x2A + +/* * Debug printf */ #ifdef AHCI_DEBUG @@ -931,6 +937,78 @@ } static void +atapi_mode_sense(struct ahci_port *p, int slot, uint8_t *cfis) +{ + int len; + uint32_t tfd; + uint8_t pc, code, *acmd = cfis + 0x40; + + len = be16dec(acmd + 7); + pc = acmd[2] >> 6; + code = acmd[2] & 0x3f; + switch (pc) { + case 0: + switch (code) { + case MODEPAGE_RW_ERROR_RECOVERY: + { + uint8_t buf[16]; + + if (len > sizeof(buf)) + len = sizeof(buf); + + memset(buf, 0, sizeof(buf)); + be16enc(buf, 16 - 2); + buf[2] = 0x70; + buf[8] = 0x01; + buf[9] = 16 - 10; + buf[11] = 0x05; + write_prdt(p, slot, cfis, buf, len); + tfd = ATA_S_READY | ATA_S_DSC; + break; + } + case MODEPAGE_CD_CAPABILITIES: + { + uint8_t buf[30]; + + if (len > sizeof(buf)) + len = sizeof(buf); + + memset(buf, 0, sizeof(buf)); + be16enc(buf, 30 - 2); + buf[2] = 0x70; + buf[8] = 0x2A; + buf[9] = 30 - 10; + buf[10] = 0x08; + buf[12] = 0x71; + be16enc(&buf[18], 2); + be16enc(&buf[20], 512); + write_prdt(p, slot, cfis, buf, len); + tfd = ATA_S_READY | ATA_S_DSC; + break; + } + default: + goto error; + break; + } + break; + case 3: + p->sense_key = ATA_SENSE_ILLEGAL_REQUEST; + p->asc = 0x39; + tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR; + break; +error: + case 1: + case 2: + p->sense_key = ATA_SENSE_ILLEGAL_REQUEST; + p->asc = 0x24; + tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR; + break; + } + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + ahci_write_fis_d2h(p, slot, cfis, tfd); +} + +static void handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { uint8_t *acmd = cfis + 0x40; @@ -972,6 +1050,9 @@ case START_STOP_UNIT: atapi_start_stop_unit(p, slot, cfis); break; + case MODE_SENSE_10: + atapi_mode_sense(p, slot, cfis); + break; default: break; } From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 16:28:37 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 575CEED3 for ; Thu, 19 Sep 2013 16:28:37 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 43D452977 for ; Thu, 19 Sep 2013 16:28:37 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JGSbRV078443 for ; Thu, 19 Sep 2013 16:28:37 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JGSb10078437 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 16:28:37 GMT (envelope-from zcore@FreeBSD.org) Date: Thu, 19 Sep 2013 16:28:37 GMT Message-Id: <201309191628.r8JGSb10078437@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257503 - soc2013/zcore/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.14 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, 19 Sep 2013 16:28:37 -0000 Author: zcore Date: Thu Sep 19 16:28:37 2013 New Revision: 257503 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257503 Log: support GET_EVENT_STATUS_NOTIFICATION Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:28:02 2013 (r257502) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:28:37 2013 (r257503) @@ -83,6 +83,7 @@ #define READ_10 0x28 #define POSITION_TO_ELEMENT 0x2B #define READ_TOC 0x43 +#define GET_EVENT_STATUS_NOTIFICATION 0x4A #define MODE_SENSE_10 0x5A #define READ_12 0xA8 #define READ_CD 0xBE @@ -1009,6 +1010,38 @@ } static void +atapi_get_event_status_notification(struct ahci_port *p, int slot, + uint8_t *cfis) +{ + uint32_t tfd; + uint8_t *acmd = cfis + 0x40; + + /* we don't support asynchronous operation */ + if (!(acmd[1] & 1)) { + p->sense_key = ATA_SENSE_ILLEGAL_REQUEST; + p->asc = 0x24; + tfd = (p->sense_key << 12) | ATA_S_READY | ATA_S_ERROR; + } else { + int len; + uint8_t buf[8]; + + len = be16dec(acmd + 7); + if (len > sizeof(buf)) + len = sizeof(buf); + + memset(buf, 0, sizeof(buf)); + be16enc(buf, 8 - 2); + buf[2] = 0x04; + buf[3] = 0x10; + buf[5] = 0x02; + write_prdt(p, slot, cfis, buf, len); + tfd = ATA_S_READY | ATA_S_DSC; + } + cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; + ahci_write_fis_d2h(p, slot, cfis, tfd); +} + +static void handle_packet_cmd(struct ahci_port *p, int slot, uint8_t *cfis) { uint8_t *acmd = cfis + 0x40; @@ -1053,6 +1086,9 @@ case MODE_SENSE_10: atapi_mode_sense(p, slot, cfis); break; + case GET_EVENT_STATUS_NOTIFICATION: + atapi_get_event_status_notification(p, slot, cfis); + break; default: break; } From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 17:13:38 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 41499C2F for ; Thu, 19 Sep 2013 17:13:38 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 2D8052BD3 for ; Thu, 19 Sep 2013 17:13:38 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JHDbTW082437 for ; Thu, 19 Sep 2013 17:13:37 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JHDbMT082430 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 17:13:37 GMT (envelope-from dpl@FreeBSD.org) Date: Thu, 19 Sep 2013 17:13:37 GMT Message-Id: <201309191713.r8JHDbMT082430@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257505 - in soc2013/dpl/head/usr.bin/bsdiff: bsdiff bspatch 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.14 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, 19 Sep 2013 17:13:38 -0000 Author: dpl Date: Thu Sep 19 17:13:37 2013 New Revision: 257505 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257505 Log: Updated bsdiff and bspatch. Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Thu Sep 19 16:22:05 2013 (r257504) +++ soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Thu Sep 19 17:13:37 2013 (r257505) @@ -27,8 +27,8 @@ #include __FBSDID("$FreeBSD$"); -#include #include +#include #include #include @@ -42,8 +42,6 @@ #define O_BINARY 0 #endif -#define DMIN(x,y) (((x)<(y)) ? (x) : (y)) - static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h) { off_t i,j,k,x,tmp,jj,kk; @@ -172,7 +170,7 @@ }; x=st+(en-st)/2; - if(memcmp(old+I[x],new,DMIN(oldsize-I[x],newsize))<0) { + if(memcmp(old+I[x],new,MIN(oldsize-I[x],newsize))<0) { return search(I,old,oldsize,new,newsize,x,en,pos); } else { return search(I,old,oldsize,new,newsize,st,x,pos); @@ -232,14 +230,14 @@ cap_rights_init(&filerights, CAP_READ, CAP_SEEK); cap_rights_init(&pathrights, CAP_WRITE, CAP_SEEK); - if (cap_rights_limit(first, &filerights) < 0) + if (cap_rights_limit(first, &filerights) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(second, &filerights) < 0) + if (cap_rights_limit(second, &filerights) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(fileno(pf), &pathrights) < 0) + if (cap_rights_limit(fileno(pf), &pathrights) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_enter() < 0) + if (cap_enter() < 0 && errno != ENOSYS) err(1, "Couldn't enter capability mode"); /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure Modified: soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Thu Sep 19 16:22:05 2013 (r257504) +++ soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Thu Sep 19 17:13:37 2013 (r257505) @@ -23,10 +23,9 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - -#include -#include __FBSDID("$FreeBSD$"); +#include +#include #include #include @@ -96,20 +95,20 @@ cap_rights_init(&patchr, CAP_READ, CAP_SEEK); cap_rights_init(&bzfiler, CAP_READ, CAP_SEEK); - if (cap_rights_limit(first, &firstr) < 0) + if (cap_rights_limit(first, &firstr) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(second, &secondr) < 0) + if (cap_rights_limit(second, &secondr) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(fileno(f), &patchr) < 0) + if (cap_rights_limit(fileno(f), &patchr) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(fileno(cpf), &bzfiler) < 0) + if (cap_rights_limit(fileno(cpf), &bzfiler) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(fileno(dpf), &bzfiler) < 0) + if (cap_rights_limit(fileno(dpf), &bzfiler) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_rights_limit(fileno(epf), &bzfiler) < 0) + if (cap_rights_limit(fileno(epf), &bzfiler) < 0 && errno != ENOSYS) err(1, "Couldn't limit fd"); - if (cap_enter() < 0) + if (cap_enter() < 0 && errno != ENOSYS) err(1, "Couldn't enter capability mode"); /* From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 20:32:37 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0CFA6AB2 for ; Thu, 19 Sep 2013 20:32:37 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id ED85A282D for ; Thu, 19 Sep 2013 20:32:36 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JKWaXd016353 for ; Thu, 19 Sep 2013 20:32:36 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JKWaXI016351 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 20:32:36 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 19 Sep 2013 20:32:36 GMT Message-Id: <201309192032.r8JKWaXI016351@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257512 - soc2013/mattbw/backend/query 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.14 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, 19 Sep 2013 20:32:37 -0000 Author: mattbw Date: Thu Sep 19 20:32:36 2013 New Revision: 257512 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257512 Log: Do some indent()ing. Modified: soc2013/mattbw/backend/query/find.h Modified: soc2013/mattbw/backend/query/find.h ============================================================================== --- soc2013/mattbw/backend/query/find.h Thu Sep 19 19:49:31 2013 (r257511) +++ soc2013/mattbw/backend/query/find.h Thu Sep 19 20:32:36 2013 (r257512) @@ -26,10 +26,10 @@ #include "error.h" /* enum query_error */ struct query_find_spec { - unsigned int load_flags; + unsigned int load_flags; enum query_error *error_p; - struct pkgdb *db; + struct pkgdb *db; struct query_id *query_id; }; From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 20:32:57 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 393CBAC0 for ; Thu, 19 Sep 2013 20:32:57 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 17112282E for ; Thu, 19 Sep 2013 20:32:57 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JKWuMt016446 for ; Thu, 19 Sep 2013 20:32:56 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JKWupu016435 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 20:32:56 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 19 Sep 2013 20:32:56 GMT Message-Id: <201309192032.r8JKWupu016435@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257513 - in soc2013/mattbw/backend: actions jobs 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.14 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, 19 Sep 2013 20:32:57 -0000 Author: mattbw Date: Thu Sep 19 20:32:56 2013 New Revision: 257513 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257513 Log: Do some indent()ing; I accidentally committed from the wrong directory last time. Added: soc2013/mattbw/backend/jobs/.indent.pro Modified: soc2013/mattbw/backend/actions/get_details.c soc2013/mattbw/backend/actions/get_files.c soc2013/mattbw/backend/actions/get_update_detail.c soc2013/mattbw/backend/actions/install_files.c soc2013/mattbw/backend/actions/remove_packages.c soc2013/mattbw/backend/actions/search_files.c soc2013/mattbw/backend/actions/search_groups.c soc2013/mattbw/backend/actions/search_names.c soc2013/mattbw/backend/actions/update_system.c Modified: soc2013/mattbw/backend/actions/get_details.c ============================================================================== --- soc2013/mattbw/backend/actions/get_details.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/get_details.c Thu Sep 19 20:32:56 2013 (r257513) @@ -60,7 +60,7 @@ bool success; const char *description; const char *www; - gchar *id; + gchar *id; int64_t flatsize; guint flatsize_u; @@ -76,7 +76,7 @@ PKG_FLATSIZE, &flatsize, PKG_WWW, &www); - flatsize_u = (guint)CLAMP(flatsize, 0, G_MAXUINT); + flatsize_u = (guint) CLAMP(flatsize, 0, G_MAXUINT); id = pkgutils_pkg_to_id(pkg); Modified: soc2013/mattbw/backend/actions/get_files.c ============================================================================== --- soc2013/mattbw/backend/actions/get_files.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/get_files.c Thu Sep 19 20:32:56 2013 (r257513) @@ -84,7 +84,7 @@ "couldn't construct filename string"); else { char *filenames; - gchar *id; + gchar *id; filenames = sbuf_data(sb); /* Skip over any initial ; */ Modified: soc2013/mattbw/backend/actions/get_update_detail.c ============================================================================== --- soc2013/mattbw/backend/actions/get_update_detail.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/get_update_detail.c Thu Sep 19 20:32:56 2013 (r257513) @@ -61,8 +61,8 @@ pkgutils_add_old_version(db, pkg, &old); if (old != NULL && pkg_version_change(pkg) == PKG_UPGRADE) { const char *update_text; - gchar *new_id; - gchar *old_id; + gchar *new_id; + gchar *old_id; new_id = pkgutils_pkg_to_id(pkg); old_id = pkgutils_pkg_to_id(old); @@ -80,7 +80,6 @@ success = true; } - pkg_free(old); return success; Modified: soc2013/mattbw/backend/actions/install_files.c ============================================================================== --- soc2013/mattbw/backend/actions/install_files.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/install_files.c Thu Sep 19 20:32:56 2013 (r257513) @@ -63,7 +63,7 @@ gboolean success; struct pkg *pkg; struct pkg_manifest_key *keys; - struct pkgdb *db; + struct pkgdb *db; success = FALSE; pkg = NULL; @@ -99,7 +99,6 @@ "could not install file"); goto cleanup; } - success = TRUE; } @@ -132,7 +131,7 @@ PK_ERROR_ENUM_INTERNAL_ERROR, "path vector is empty"); else { - gchar **p; + gchar **p; for (p = paths, success = TRUE; (*p != NULL) && success == TRUE; Modified: soc2013/mattbw/backend/actions/remove_packages.c ============================================================================== --- soc2013/mattbw/backend/actions/remove_packages.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/remove_packages.c Thu Sep 19 20:32:56 2013 (r257513) @@ -31,8 +31,8 @@ static gboolean remove_packages(PkBackend *backend, bool simulate); /* - * The thread that performs an removePackages operation. Should be invoked - * by the pk_backend_remove_packages hook. + * The thread that performs an removePackages operation. Should be invoked by + * the pk_backend_remove_packages hook. */ gboolean remove_packages_thread(PkBackend *backend) Modified: soc2013/mattbw/backend/actions/search_files.c ============================================================================== --- soc2013/mattbw/backend/actions/search_files.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/search_files.c Thu Sep 19 20:32:56 2013 (r257513) @@ -42,7 +42,7 @@ struct pkg *pkg; struct pkgdb *db; struct pkgdb_it *it; - gchar **filev; + gchar **filev; assert(backend != NULL); db = NULL; @@ -67,7 +67,6 @@ ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no files given"); goto cleanup; } - for (i = 0; i < filec; i++) { at_least_one = false; @@ -75,14 +74,13 @@ if (it != NULL) { while (pkgdb_it_next(it, &pkg, PKG_LOAD_BASIC) == EPKG_OK) { - assert(pkg != NULL); + assert(pkg != NULL); emit_package(pkg, backend, - pkgutils_pkg_current_state(pkg)); + pkgutils_pkg_current_state(pkg)); at_least_one = true; } } - /* TODO: specifically name file? */ if (at_least_one == false) ERR(backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, Modified: soc2013/mattbw/backend/actions/search_groups.c ============================================================================== --- soc2013/mattbw/backend/actions/search_groups.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/search_groups.c Thu Sep 19 20:32:56 2013 (r257513) @@ -63,19 +63,16 @@ ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "search was NULL"); goto cleanup; } - groupc = g_strv_length(values); if (groupc == 0) { ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no values"); goto cleanup; } - groupv = calloc(groupc, sizeof(PkGroupEnum)); if (groupv == NULL) { ERR(backend, PK_ERROR_ENUM_OOM, "couldn't alloc groupv"); goto cleanup; } - for (i = 0; i < groupc; i++) { groupv[i] = pk_group_enum_from_string(values[i]); if (groupv[i] == PK_GROUP_ENUM_UNKNOWN) @@ -87,7 +84,6 @@ ERR(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "no search.term"); goto cleanup; } - search.type = MATCH_REGEX; search.in = FIELD_ORIGIN; search.sort_by = FIELD_ORIGIN; Modified: soc2013/mattbw/backend/actions/search_names.c ============================================================================== --- soc2013/mattbw/backend/actions/search_names.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/search_names.c Thu Sep 19 20:32:56 2013 (r257513) @@ -69,7 +69,6 @@ ((i + 1) * 100) / len); } } - pkgdb_close(search.db); (void)pk_backend_set_percentage(backend, 100); (void)pk_backend_finished(backend); Modified: soc2013/mattbw/backend/actions/update_system.c ============================================================================== --- soc2013/mattbw/backend/actions/update_system.c Thu Sep 19 20:32:36 2013 (r257512) +++ soc2013/mattbw/backend/actions/update_system.c Thu Sep 19 20:32:56 2013 (r257513) @@ -29,8 +29,8 @@ #include "../pkgutils.h" /* pkgutils_... */ /* - * The thread that performs an UpdateSystem operation. Should be invoked - * by the pk_backend_update_system hook. + * The thread that performs an UpdateSystem operation. Should be invoked by + * the pk_backend_update_system hook. */ gboolean update_system_thread(PkBackend *backend) Added: soc2013/mattbw/backend/jobs/.indent.pro ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/jobs/.indent.pro Thu Sep 19 20:32:56 2013 (r257513) @@ -0,0 +1,7 @@ +-TPkBackend +-Tgchar +-Tgboolean +-Tbool +-sob +-nlp +-ci4 From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 02:25:05 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 265584D1 for ; Fri, 20 Sep 2013 02:25:05 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1415226C5 for ; Fri, 20 Sep 2013 02:25:05 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8K2P4sU048966 for ; Fri, 20 Sep 2013 02:25:04 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8K2P4RJ048943 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 02:25:04 GMT (envelope-from zcore@FreeBSD.org) Date: Fri, 20 Sep 2013 02:25:04 GMT Message-Id: <201309200225.r8K2P4RJ048943@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257525 - soc2013/zcore/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.14 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, 20 Sep 2013 02:25:05 -0000 Author: zcore Date: Fri Sep 20 02:25:04 2013 New Revision: 257525 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257525 Log: set br_offset accordingly Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Sep 20 01:55:37 2013 (r257524) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Fri Sep 20 02:25:04 2013 (r257525) @@ -111,6 +111,7 @@ STAILQ_ENTRY(ahci_ioreq) io_list; uint8_t *cfis; uint32_t len; + uint32_t done; int slot; int prdtl; }; @@ -379,7 +380,8 @@ } static void -handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, int seek) +handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, + uint32_t done, int seek) { int i, err, iovcnt, ncq = 0, readop = 1; uint64_t lba; @@ -436,8 +438,9 @@ aior->cfis = cfis; aior->slot = slot; aior->len = len; + aior->done = done; breq = &aior->io_req; - breq->br_offset = lba; + breq->br_offset = lba + done; iovcnt = hdr->prdtl - seek; if (iovcnt > BLOCKIF_IOV_MAX) { aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; @@ -453,6 +456,7 @@ breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc), prdt->dba, prdt->dbc + 1); breq->br_iov[i].iov_len = prdt->dbc + 1; + aior->done += (prdt->dbc + 1); prdt++; } if (readop) @@ -836,7 +840,8 @@ } static void -atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, int seek) +atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, + uint32_t done, int seek) { int i, err, iovcnt; uint64_t lba; @@ -870,8 +875,9 @@ aior->cfis = cfis; aior->slot = slot; aior->len = len; + aior->done = done; breq = &aior->io_req; - breq->br_offset = lba; + breq->br_offset = lba + done; iovcnt = hdr->prdtl - seek; if (iovcnt > BLOCKIF_IOV_MAX) { aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; @@ -887,6 +893,7 @@ breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc), prdt->dba, prdt->dbc + 1); breq->br_iov[i].iov_len = prdt->dbc + 1; + aior->done += (prdt->dbc + 1); prdt++; } err = blockif_read(p->bctx, breq); @@ -1075,7 +1082,7 @@ break; case READ_10: case READ_12: - atapi_read(p, slot, cfis, 0); + atapi_read(p, slot, cfis, 0, 0); break; case REQUEST_SENSE: atapi_request_sense(p, slot, cfis); @@ -1153,7 +1160,7 @@ case ATA_WRITE_DMA48: case ATA_READ_FPDMA_QUEUED: case ATA_WRITE_FPDMA_QUEUED: - handle_dma(p, slot, cfis, 0); + handle_dma(p, slot, cfis, 0, 0); break; case ATA_FLUSHCACHE: case ATA_FLUSHCACHE48: @@ -1286,11 +1293,11 @@ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); if (pending && !err) { - handle_dma(p, slot, cfis, hdr->prdtl - pending); + handle_dma(p, slot, cfis, aior->done, hdr->prdtl - pending); goto out; } - if (!err) { + if (!err && aior->done == aior->len) { tfd = ATA_S_READY | ATA_S_DSC; if (ncq) hdr->prdbc = 0; @@ -1342,11 +1349,11 @@ STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); if (pending && !err) { - atapi_read(p, slot, cfis, hdr->prdtl - pending); + atapi_read(p, slot, cfis, aior->done, hdr->prdtl - pending); goto out; } - if (!err) { + if (!err && aior->done == aior->len) { tfd = ATA_S_READY | ATA_S_DSC; hdr->prdbc = aior->len; } else { From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 12:06:28 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CFE20FDB for ; Fri, 20 Sep 2013 12:06:28 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BB98E228B for ; Fri, 20 Sep 2013 12:06:28 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KC6SOV007820 for ; Fri, 20 Sep 2013 12:06:28 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KC6SHl007807 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 12:06:28 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 20 Sep 2013 12:06:28 GMT Message-Id: <201309201206.r8KC6SHl007807@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257532 - soc2013/mattbw/port 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.14 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, 20 Sep 2013 12:06:28 -0000 Author: mattbw Date: Fri Sep 20 12:06:28 2013 New Revision: 257532 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257532 Log: Add in eadler's port file recommendations. Modified: soc2013/mattbw/port/Makefile soc2013/mattbw/port/pkg-message Modified: soc2013/mattbw/port/Makefile ============================================================================== --- soc2013/mattbw/port/Makefile Fri Sep 20 07:45:37 2013 (r257531) +++ soc2013/mattbw/port/Makefile Fri Sep 20 12:06:28 2013 (r257532) @@ -1,4 +1,4 @@ -# %FREEBSD$ +# $FreeBSD$ PORTNAME= pkgpackagekit PORTVERSION= 0.1 @@ -14,6 +14,6 @@ WRKSRC= ${WRKDIR}/backend post-install: - cat pkg-message + ${CAT} pkg-message | ${SED} 's,%%PREFIX%%,${PREFIX},g' .include Modified: soc2013/mattbw/port/pkg-message ============================================================================== --- soc2013/mattbw/port/pkg-message Fri Sep 20 07:45:37 2013 (r257531) +++ soc2013/mattbw/port/pkg-message Fri Sep 20 12:06:28 2013 (r257532) @@ -1,5 +1,5 @@ In order to enable this backend by default, you will need to change the file -/usr/local/etc/PackageKit/PackageKit.conf, replacing the line: +%%PREFIX%%/etc/PackageKit/PackageKit.conf, replacing the line: < DefaultBackend=ports From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 12:07:27 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 79436FF9 for ; Fri, 20 Sep 2013 12:07:27 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6678522A7 for ; Fri, 20 Sep 2013 12:07:27 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KC7RMr035712 for ; Fri, 20 Sep 2013 12:07:27 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KC7RvG035707 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 12:07:27 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 20 Sep 2013 12:07:27 GMT Message-Id: <201309201207.r8KC7RvG035707@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257533 - soc2013/mattbw/port 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.14 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, 20 Sep 2013 12:07:27 -0000 Author: mattbw Date: Fri Sep 20 12:07:27 2013 New Revision: 257533 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257533 Log: Add space in #include. Modified: soc2013/mattbw/port/Makefile Modified: soc2013/mattbw/port/Makefile ============================================================================== --- soc2013/mattbw/port/Makefile Fri Sep 20 12:06:28 2013 (r257532) +++ soc2013/mattbw/port/Makefile Fri Sep 20 12:07:27 2013 (r257533) @@ -16,4 +16,4 @@ post-install: ${CAT} pkg-message | ${SED} 's,%%PREFIX%%,${PREFIX},g' -.include +.include From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 12:26:03 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A5E218AA for ; Fri, 20 Sep 2013 12:26:03 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9168123E0 for ; Fri, 20 Sep 2013 12:26:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KCQ3W7064646 for ; Fri, 20 Sep 2013 12:26:03 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KCQ37W064638 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 12:26:03 GMT (envelope-from mattbw@FreeBSD.org) Date: Fri, 20 Sep 2013 12:26:03 GMT Message-Id: <201309201226.r8KCQ37W064638@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257534 - soc2013/mattbw/port 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.14 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, 20 Sep 2013 12:26:03 -0000 Author: mattbw Date: Fri Sep 20 12:26:03 2013 New Revision: 257534 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257534 Log: Update port to latest code. Modified: soc2013/mattbw/port/Makefile soc2013/mattbw/port/distinfo Modified: soc2013/mattbw/port/Makefile ============================================================================== --- soc2013/mattbw/port/Makefile Fri Sep 20 12:07:27 2013 (r257533) +++ soc2013/mattbw/port/Makefile Fri Sep 20 12:26:03 2013 (r257534) @@ -1,7 +1,7 @@ # $FreeBSD$ PORTNAME= pkgpackagekit -PORTVERSION= 0.1 +PORTVERSION= 0.1.1 CATEGORIES= ports-mgmt MASTER_SITES= http://www-student.cs.york.ac.uk/~mbw500/ Modified: soc2013/mattbw/port/distinfo ============================================================================== --- soc2013/mattbw/port/distinfo Fri Sep 20 12:07:27 2013 (r257533) +++ soc2013/mattbw/port/distinfo Fri Sep 20 12:26:03 2013 (r257534) @@ -1,2 +1,2 @@ -SHA256 (pkgpackagekit-0.1.tar.gz) = 85562b2fbd783579a97eddd3616fdf1f511618a85dcf89743f7483d8b06823e1 -SIZE (pkgpackagekit-0.1.tar.gz) = 40960 +SHA256 (pkgpackagekit-0.1.1.tar.gz) = 855e70060e623dbaba043753b658f23fef33a88b98c6b0113bd13439188ce354 +SIZE (pkgpackagekit-0.1.1.tar.gz) = 40960 From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 19:40:04 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 288B269 for ; Fri, 20 Sep 2013 19:40:04 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 163D32D02 for ; Fri, 20 Sep 2013 19:40:04 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KJe37Y095531 for ; Fri, 20 Sep 2013 19:40:03 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KJe3P2095516 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 19:40:03 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 20 Sep 2013 19:40:03 GMT Message-Id: <201309201940.r8KJe3P2095516@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257539 - soc2013/dpl/head/lib/libzcap/zlibworker 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.14 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, 20 Sep 2013 19:40:04 -0000 Author: dpl Date: Fri Sep 20 19:40:03 2013 New Revision: 257539 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257539 Log: Added debug info to zlibworker, and the file necessary to make it work. Added: soc2013/dpl/head/lib/libzcap/zlibworker/debug.h Added: soc2013/dpl/head/lib/libzcap/zlibworker/debug.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/dpl/head/lib/libzcap/zlibworker/debug.h Fri Sep 20 19:40:03 2013 (r257539) @@ -0,0 +1 @@ +int DEBUG_ZCAP = 1; From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 19:41:10 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 5654E8F for ; Fri, 20 Sep 2013 19:41:10 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3546C2D2C for ; Fri, 20 Sep 2013 19:41:10 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KJfAdM044567 for ; Fri, 20 Sep 2013 19:41:10 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KJf9N1044559 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 19:41:09 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 20 Sep 2013 19:41:09 GMT Message-Id: <201309201941.r8KJf9N1044559@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257540 - soc2013/dpl/head/lib/libzcap 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.14 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, 20 Sep 2013 19:41:10 -0000 Author: dpl Date: Fri Sep 20 19:41:09 2013 New Revision: 257540 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257540 Log: Added debugging code. Modified: soc2013/dpl/head/lib/libzcap/capsicum.c soc2013/dpl/head/lib/libzcap/debug.h Modified: soc2013/dpl/head/lib/libzcap/capsicum.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/capsicum.c Fri Sep 20 19:40:03 2013 (r257539) +++ soc2013/dpl/head/lib/libzcap/capsicum.c Fri Sep 20 19:41:09 2013 (r257540) @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,17 @@ /* At "debug.h" */ extern int DEBUG_ZCAP; +static void +debug(const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + if (DEBUG_ZCAP == 1) + vfprintf(stderr, msg, ap); + va_end(ap); +} + /* * This function should be called only by: * gzopen(), deflateInit(), inflateInit(), @@ -75,8 +87,7 @@ struct sandbox *box; box = findSandbox(ptr); - if (DEBUG_ZCAP) - printf("DEBUG: Stopping sandbox:%d\n",box->pd ); + debug("DEBUG: Stopping sandbox:%d\n",box->pd); pdkill(box->pd, SIGKILL); SLIST_REMOVE(&sandboxes, box, sandbox, next); @@ -111,8 +122,7 @@ { struct sandbox *sandbox; - if (DEBUG_ZCAP) - printf("DEBUG: findSandbox(%p)\n", ptr); + debug("DEBUG: findSandbox(%p)\n", ptr); if (ptr == NULL) return (SLIST_FIRST(&sandboxes)); @@ -176,10 +186,8 @@ newsandbox->dataptr = data; newsandbox->pd = procd; newsandbox->socket = sv[1]; - if (DEBUG_ZCAP) { - printf("DEBUG: We have started a new sandbox.\n"); - printf("\tdata: %p pd: %d, socket: %d\n", data, newsandbox->pd, newsandbox->socket); - } + debug("DEBUG: We have started a new sandbox.\n"); + debug("\tdata: %p pd: %d, socket: %d\n", data, newsandbox->pd, newsandbox->socket); } return (newsandbox); } @@ -204,14 +212,13 @@ box = findSandbox(ptr); - if (DEBUG_ZCAP) - printf("DEBUG: zcaplib: Entered sendCommand(%p, %p): box: %p\n", nvl, ptr, box); - if (DEBUG_ZCAP) - printf("DEBUG: zcaplib: About to send command\n"); + debug("DEBUG: zcaplib: Entered sendCommand(%p, %p): box: %p\n", nvl, ptr, box); + debug("DEBUG: zcaplib: About to send command\n"); + if( nvlist_send(box->socket, nvl) != 0 ) err(1, "zcaplib: nvlist_send Error"); - if (DEBUG_ZCAP) - printf("DEBUG: zcaplib: Awaiting answer\n"); + debug("DEBUG: zcaplib: Awaiting answer\n"); + if ((new = nvlist_recv(box->socket)) == NULL) err(1, "nvlist_recv(): nvlist_t is NULL"); return (new); Modified: soc2013/dpl/head/lib/libzcap/debug.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/debug.h Fri Sep 20 19:40:03 2013 (r257539) +++ soc2013/dpl/head/lib/libzcap/debug.h Fri Sep 20 19:41:09 2013 (r257540) @@ -1 +1 @@ -int DEBUG_ZCAP = 0; +int DEBUG_ZCAP = 1; From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 19:42:47 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E551FC3 for ; Fri, 20 Sep 2013 19:42:47 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D2F502D37 for ; Fri, 20 Sep 2013 19:42:47 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KJgl6K063697 for ; Fri, 20 Sep 2013 19:42:47 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KJglZP063693 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 19:42:47 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 20 Sep 2013 19:42:47 GMT Message-Id: <201309201942.r8KJglZP063693@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257541 - soc2013/dpl/head/lib/libzcap/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.14 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, 20 Sep 2013 19:42:48 -0000 Author: dpl Date: Fri Sep 20 19:42:47 2013 New Revision: 257541 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257541 Log: No changes. Modified: soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Modified: soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Fri Sep 20 19:41:09 2013 (r257540) +++ soc2013/dpl/head/lib/libzcap/test/zcaplibtest.c Fri Sep 20 19:42:47 2013 (r257541) @@ -214,7 +214,6 @@ if ((d = calloc(50, 1)) == NULL) err(1, "zcaplibtest: calloc()"); - /* Writing functions */ if (gzwrite(file, (void *)buf, buflen) == 0) printf("gzwrite(): Error\n"); From owner-svn-soc-all@FreeBSD.ORG Fri Sep 20 19:44:22 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B7C60E7 for ; Fri, 20 Sep 2013 19:44:22 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A4A542D43 for ; Fri, 20 Sep 2013 19:44:22 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8KJiM4p076708 for ; Fri, 20 Sep 2013 19:44:22 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8KJiMIP076703 for svn-soc-all@FreeBSD.org; Fri, 20 Sep 2013 19:44:22 GMT (envelope-from dpl@FreeBSD.org) Date: Fri, 20 Sep 2013 19:44:22 GMT Message-Id: <201309201944.r8KJiMIP076703@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257542 - in soc2013/dpl/head/lib/libzcap: . zlibworker 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.14 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, 20 Sep 2013 19:44:22 -0000 Author: dpl Date: Fri Sep 20 19:44:22 2013 New Revision: 257542 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257542 Log: Update to zlibworker to handle better gzfileparams(). Modified: soc2013/dpl/head/lib/libzcap/commands.c soc2013/dpl/head/lib/libzcap/zlibworker/commands.c soc2013/dpl/head/lib/libzcap/zlibworker/commands.h soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Modified: soc2013/dpl/head/lib/libzcap/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/commands.c Fri Sep 20 19:42:47 2013 (r257541) +++ soc2013/dpl/head/lib/libzcap/commands.c Fri Sep 20 19:44:22 2013 (r257542) @@ -92,7 +92,7 @@ extern bool slist_initiated; nvlist_t *nvl, *args, *result; -size_t gzsize = sizeof(gzFile); +size_t gzsize = sizeof(struct gzFile_s *); size_t gzheadersize = sizeof(gz_state); size_t zstreamsize = sizeof(z_stream); @@ -799,6 +799,7 @@ result = sendCommand(nvl, file); ptr = nvlist_get_binary(result, "result", &gzsize); memcpy(file, ptr, gzsize); + fprintf(stderr, "ZCAPLIB: gzopen(): %p\n", ptr); destroy(); return(file); } @@ -806,7 +807,6 @@ int zcapcmd_gzbuffer(gzFile file, unsigned size) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZBUFFER); @@ -824,7 +824,6 @@ int zcapcmd_gzsetparams(gzFile file, int level, int strategy) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZSETPARAMS); @@ -899,7 +898,6 @@ int zcapcmd_gzputs(gzFile file, const char *s) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZPUTS); @@ -917,7 +915,6 @@ char * zcapcmd_gzgets(gzFile file, char *buf, int len) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZGETS); @@ -939,7 +936,6 @@ int zcapcmd_gzputc(gzFile file, int c) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZPUTC); @@ -957,7 +953,6 @@ int zcapcmd_gzungetc(int c, gzFile file) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZUNGETC); @@ -975,7 +970,6 @@ int zcapcmd_gzflush(gzFile file, int flush) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZFLUSH); @@ -993,7 +987,6 @@ z_off_t zcapcmd_gzseek(gzFile file, z_off_t offset, int whence) { - initNvl(); nvlist_add_number(nvl, "command", ZCAPCMD_GZSEEK); Modified: soc2013/dpl/head/lib/libzcap/zlibworker/commands.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Fri Sep 20 19:42:47 2013 (r257541) +++ soc2013/dpl/head/lib/libzcap/zlibworker/commands.c Fri Sep 20 19:44:22 2013 (r257542) @@ -11,7 +11,7 @@ extern int zero; extern void *data; -size_t gzsize = sizeof(gz_state); +size_t gzsize = sizeof(struct gzFile_s *); size_t zstreamsize = sizeof(z_stream); /* @@ -254,6 +254,8 @@ mode = nvlist_get_string(args, "mode"); ret = gzdopen(fd, mode); + + fprintf(stderr, "ZLIBWORKER: gzopen(): %p\n", ret); nvlist_add_binary(result, "result", ret, gzsize); } @@ -275,12 +277,20 @@ zcapcmd_gzsetparams(nvlist_t *args, nvlist_t *result) { int ret = -1; + gzFile file; + int level, strat; - ret = gzsetparams( - (gzFile)nvlist_get_binary(args, "file", &gzsize), - nvlist_get_number(args, "level"), - nvlist_get_number(args, "strategy") - ); + fprintf(stderr, "We get about to get zcapcmd_gzsetparams() args\n"); + file = (gzFile)nvlist_get_binary(args, "file", &gzsize); + fprintf(stderr, "We got file\n"); + level = nvlist_get_number(args, "level"); + fprintf(stderr, "We got level\n"); + strat = nvlist_get_number(args, "strategy"); + fprintf(stderr, "We got strat\n"); + + fprintf(stderr, "We get to gzsetparams(%p, %d, %d)\n", file, level, strat); + ret = gzsetparams(file, level, strat); + fprintf(stderr, "We finished with zcapcmd_gzsetparams()\n"); nvlist_add_number(result, "result", ret); } Modified: soc2013/dpl/head/lib/libzcap/zlibworker/commands.h ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/commands.h Fri Sep 20 19:42:47 2013 (r257541) +++ soc2013/dpl/head/lib/libzcap/zlibworker/commands.h Fri Sep 20 19:44:22 2013 (r257542) @@ -4,13 +4,9 @@ This list is taken from zlib.h, in this same directory. All this defines represent the commands passed to the real - zlib listening through a program, and it will recognize them. + zlib listening through zlibworker, and it will recognize them. Also, the defines have been checked for not being duplicates. - Since the only things that we can Capsicumize are: deflate() - and inflate(), we only have to care about sending those to - commands (related to the basic functions, and utility functions. - */ #define SOCKETFILENO 3 Modified: soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c ============================================================================== --- soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Fri Sep 20 19:42:47 2013 (r257541) +++ soc2013/dpl/head/lib/libzcap/zlibworker/zlibworker.c Fri Sep 20 19:44:22 2013 (r257542) @@ -1,13 +1,17 @@ #include +#include #include #include #include +#include #include #include +#include #include "commands.h" #include "data.h" +#include "debug.h" int main(int argc, char *argv[]); static void destroy(nvlist_t *nvl, nvlist_t *args, nvlist_t *results); @@ -75,6 +79,20 @@ /* Zero is set when we need to zero out data */ int zero = 0; +/* At "debug.h" */ +extern int DEBUG_ZCAP; + +static void +debug(const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + if (DEBUG_ZCAP == 1) + vfprintf(stderr, msg, ap); + va_end(ap); +} + /* Deletes nvlists */ static void destroy(nvlist_t *nvl, nvlist_t *args, nvlist_t *results) @@ -106,6 +124,8 @@ /* Sandbox the process */ if (cap_enter() < 0) err(1, "Couldn't enter capability mode"); + + debug("DEBUG: zlibworker(%d) entered capability mode\n", getpid()); if ((data = calloc(5*1024, 1)) == NULL) err(1, "malloc\n"); @@ -114,6 +134,7 @@ if ((result = nvlist_create(0)) == NULL) err(1, "Can't create result.\n"); + debug("DEBUG: zlibworker(%d) Awaiting command\n", getpid()); if ((nvl = nvlist_recv(SOCKETFILENO)) == NULL) err(1, "Received nvlist is NULL\n"); @@ -294,6 +315,7 @@ break; } + debug("DEBUG: zlibworker(%d) About to send result\n", getpid()); if (nvlist_send(SOCKETFILENO, result) != 0) err(1, "Couldn't send response\n"); From owner-svn-soc-all@FreeBSD.ORG Sat Sep 21 20:45:54 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 141BEC48 for ; Sat, 21 Sep 2013 20:45:54 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 00B0427E7 for ; Sat, 21 Sep 2013 20:45:54 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8LKjruV080277 for ; Sat, 21 Sep 2013 20:45:53 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8LKjrKN080274 for svn-soc-all@FreeBSD.org; Sat, 21 Sep 2013 20:45:53 GMT (envelope-from def@FreeBSD.org) Date: Sat, 21 Sep 2013 20:45:53 GMT Message-Id: <201309212045.r8LKjrKN080274@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: r257574 - soc2013/def/crashdump-head/sbin/dumpkey 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.14 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, 21 Sep 2013 20:45:54 -0000 Author: def Date: Sat Sep 21 20:45:53 2013 New Revision: 257574 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257574 Log: dumpkey program which generates an AES key, encrypts it with RSA and transfers it to kernel via sysctl. Added: soc2013/def/crashdump-head/sbin/dumpkey/ soc2013/def/crashdump-head/sbin/dumpkey/Makefile soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c Added: soc2013/def/crashdump-head/sbin/dumpkey/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sbin/dumpkey/Makefile Sat Sep 21 20:45:53 2013 (r257574) @@ -0,0 +1,15 @@ +SYS= ${.CURDIR}/../../sys +.PATH: ${SYS}/crypto ${SYS}/crypto/rijndael +.PATH: ${SYS}/crypto/hmac ${SYS}/crypto/sha2 + +PROG= dumpkey +SRCS= ${PROG}.c +SRCS+= rijndael-api.c rijndael-api-fst.c rijndael-alg-fst.c +SRCS+= hmac.c xts.c sha2.c +CFLAGS+=-I${SYS} +DPADD+= ${LIBCRYPTO} +LDADD+= -lcrypto +WARNS?= 2 +NO_MAN= + +.include Added: soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/sbin/dumpkey/dumpkey.c Sat Sep 21 20:45:53 2013 (r257574) @@ -0,0 +1,227 @@ +#include +#include +#include +#include +#include +#include +#include + +#define OPENSSL_NO_SHA +#include +#include +#include +#include + +#define PATH_DEVRANDOM "/dev/random" + +static void +hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, + int idx, const uint8_t *magic, size_t magicsize) +{ + uint8_t byte_idx = idx; + + hmac_init(&ctx->o.pctx_hmac, CRYPTO_SHA2_512_HMAC, + masterkey, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); + hmac_update(&ctx->o.pctx_hmac, magic, magicsize); + hmac_update(&ctx->o.pctx_hmac, &byte_idx, sizeof(byte_idx)); + hmac_final(&ctx->o.pctx_hmac, key, KERNELDUMP_KEY_SIZE); +} + +static void +usage(void) +{ + printf("usage: dumpkey -p public_key\n"); +} + +static int +read_data(char *buf, size_t size, const char *file) +{ + FILE *fp; + + fp = fopen(file, "r"); + + if (fp == NULL) + return (-1); + + if (fread(buf, size, 1, fp) != 1) { + fclose(fp); + + return (-1); + } + + fclose(fp); + + return (0); +} + +static int +random_data(char *buf, size_t size) +{ + if(read_data(buf, size, PATH_DEVRANDOM)) + return (-1); + + return (0); +} + +static int +encrypt_key(char *key, size_t keysize, char *encrypted_key, RSA *public_key, char *public_key_file) +{ + FILE *fp; + + fp = fopen(public_key_file, "r"); + + if (fp == NULL) + return (-1); + + public_key = PEM_read_RSA_PUBKEY(fp, &public_key, NULL, NULL); + fclose(fp); + + if (public_key == NULL) + return (-1); + + if (RSA_public_encrypt(keysize, key, encrypted_key, public_key, RSA_PKCS1_PADDING) == -1) + return (-1); + + return (0); +} + +static int +expand_key(char *key, size_t keysize, char *data_key, char *tweak_key) +{ + struct xts_ctx ctx; + + bzero(&ctx, sizeof(ctx)); + bzero(data_key, keysize); + bzero(tweak_key, keysize); + + hkdf_expand(&ctx, key, data_key, 1, kerneldump_magic, sizeof(kerneldump_magic)); + memcpy(tweak_key, data_key, keysize); + hkdf_expand(&ctx, key, tweak_key, 2, kerneldump_magic, sizeof(kerneldump_magic)); + + bzero(&ctx, sizeof(ctx)); + + return (0); +} + +static int +set_data_key(char *key, size_t keysize) +{ + return (sysctlbyname("kern.dump.key.data", NULL, 0, key, keysize)); +} + +static int +set_tweak_key(char *key, size_t keysize) +{ + return (sysctlbyname("kern.dump.key.tweak", NULL, 0, key, keysize)); +} + +static int +set_encrypted_key(char *key, size_t keysize) +{ + return (sysctlbyname("kern.dump.key.encrypted", NULL, 0, key, keysize)); +} + +static int +set_tweak(char *tweak, size_t tweaksize) +{ + return (sysctlbyname("kern.dump.tweak", NULL, 0, tweak, tweaksize)); +} + +int +main(int argc, char **argv) +{ + char *public_key_file; + char key[KERNELDUMP_KEY_SIZE], encrypted_key[KERNELDUMP_ENCRYPTED_KEY_SIZE]; + char data_key[KERNELDUMP_KEY_SIZE], tweak_key[KERNELDUMP_KEY_SIZE]; + char tweak[KERNELDUMP_TWEAK_SIZE]; + int ch, error; + RSA *public_key; + + ERR_load_crypto_strings(); + OpenSSL_add_all_algorithms(); + OPENSSL_config(NULL); + + error = 0; + public_key_file = NULL; + public_key = RSA_new(); + + while ((ch = getopt(argc, argv, "p:")) != -1) + switch (ch) { + case 'p': + public_key_file = optarg; + break; + default: + usage(); + error = 1; + goto out; + } + + if (public_key_file == NULL) { + usage(); + error = 1; + goto out; + } + + if (random_data(key, KERNELDUMP_KEY_SIZE)) { + printf("Error: cannot generate a symmetric key.\n"); + error = 1; + goto out; + } + + if (encrypt_key(key, KERNELDUMP_KEY_SIZE, encrypted_key, public_key, public_key_file)) { + printf("Error: cannot encrypt a symmetric key.\n"); + error = 1; + goto out; + } + + if (set_encrypted_key(encrypted_key, KERNELDUMP_ENCRYPTED_KEY_SIZE)) { + printf("Error: cannot set an encrypted symmetric key.\n"); + error = 1; + goto out; + } + + if (expand_key(key, KERNELDUMP_KEY_SIZE, data_key, tweak_key)) { + printf("Error: cannot expand a symmetric key."); + error = 1; + goto out; + } + + if (set_data_key(data_key, KERNELDUMP_KEY_SIZE)) { + printf("Error: cannot set a symmetric data key.\n"); + error = 1; + goto out; + } + + if (set_tweak_key(tweak_key, KERNELDUMP_KEY_SIZE)) { + printf("Error: cannot set a symmetric tweak key."); + error = 1; + goto out; + } + + if (random_data(tweak, KERNELDUMP_TWEAK_SIZE)) { + printf("Error: cannot generate a tweak.\n"); + error = 1; + goto out; + } + + if (set_tweak(tweak, KERNELDUMP_TWEAK_SIZE)) { + printf("Error: cannot set a tweak.\n"); + error = 1; + goto out; + } + +out: + bzero(key, KERNELDUMP_KEY_SIZE); + bzero(encrypted_key, KERNELDUMP_ENCRYPTED_KEY_SIZE); + bzero(data_key, KERNELDUMP_KEY_SIZE); + bzero(tweak_key, KERNELDUMP_KEY_SIZE); + bzero(tweak, KERNELDUMP_TWEAK_SIZE); + RSA_free(public_key); + + ERR_free_strings(); + EVP_cleanup(); + + return (0); +} + From owner-svn-soc-all@FreeBSD.ORG Sat Sep 21 21:14:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 43410430 for ; Sat, 21 Sep 2013 21:14:06 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 172B1290C for ; Sat, 21 Sep 2013 21:14:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8LLE5cW083091 for ; Sat, 21 Sep 2013 21:14:05 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8LLE5K2083085 for svn-soc-all@FreeBSD.org; Sat, 21 Sep 2013 21:14:05 GMT (envelope-from def@FreeBSD.org) Date: Sat, 21 Sep 2013 21:14:05 GMT Message-Id: <201309212114.r8LLE5K2083085@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: r257575 - in soc2013/def/crashdump-head/etc: defaults rc.d 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.14 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, 21 Sep 2013 21:14:06 -0000 Author: def Date: Sat Sep 21 21:14:05 2013 New Revision: 257575 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257575 Log: rc.d script to generate RSA keys if they don't exist and run dumpkey. Added: soc2013/def/crashdump-head/etc/rc.d/dumpkey (contents, props changed) Modified: soc2013/def/crashdump-head/etc/defaults/rc.conf Modified: soc2013/def/crashdump-head/etc/defaults/rc.conf ============================================================================== --- soc2013/def/crashdump-head/etc/defaults/rc.conf Sat Sep 21 20:45:53 2013 (r257574) +++ soc2013/def/crashdump-head/etc/defaults/rc.conf Sat Sep 21 21:14:05 2013 (r257575) @@ -606,6 +606,10 @@ chkprintcap_flags="-d" # Create missing directories by default. dumpdev="AUTO" # Device to crashdump to (device name, AUTO, or NO). dumpdir="/var/crash" # Directory where crash dumps are to be stored +dumpkey_enable="YES" +dumpkey_pub="/var/crash/.public.key" +dumpkey_priv="/var/crash/.private.key" +dumpkey_bits="2048" savecore_flags="-m 10" # Used if dumpdev is enabled above, and present. # By default, only the 10 most recent kernel dumps # are saved. Added: soc2013/def/crashdump-head/etc/rc.d/dumpkey ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/def/crashdump-head/etc/rc.d/dumpkey Sat Sep 21 21:14:05 2013 (r257575) @@ -0,0 +1,33 @@ +#!/bin/sh + +# PROVIDE: dumpkey +# REQUIRE: dumpon + +. /etc/rc.subr + +name="dumpkey" +rcvar="dumpkey_enable" +start_cmd="dumpkey_start" +start_precmd="dumpkey_prestart" +stop_cmd=":" + +dumpkey_prestart() +{ + if [ ! -r "${dumpkey_pub}" ] || [ ! -r "${dumpkey_priv}" ]; then + warn "At least one of keys doesn't exist. Generating new keys..." + + dumpkey_pub=${dumpdir}/.public.key + dumpkey_priv=${dumpdir}/.private.key + + /usr/bin/openssl genrsa -out ${dumpkey_priv} ${dumpkey_bits} + /usr/bin/openssl rsa -in ${dumpkey_priv} -out ${dumpkey_pub} -outform PEM -pubout + fi +} + +dumpkey_start() +{ + /sbin/dumpkey -p ${dumpkey_pub} +} + +load_rc_config $name +run_rc_command "$1" From owner-svn-soc-all@FreeBSD.ORG Sat Sep 21 21:57:29 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 89C48D72 for ; Sat, 21 Sep 2013 21:57: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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6733F2AA9 for ; Sat, 21 Sep 2013 21:57:29 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8LLvTlF032660 for ; Sat, 21 Sep 2013 21:57:29 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8LLvTRi032657 for svn-soc-all@FreeBSD.org; Sat, 21 Sep 2013 21:57:29 GMT (envelope-from def@FreeBSD.org) Date: Sat, 21 Sep 2013 21:57:29 GMT Message-Id: <201309212157.r8LLvTRi032657@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: r257576 - soc2013/def/crashdump-head/sys/crypto 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.14 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, 21 Sep 2013 21:57:29 -0000 Author: def Date: Sat Sep 21 21:57:29 2013 New Revision: 257576 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257576 Log: Provide a sequential number of 128-bits block inside a data unit for xts_block_encrypt and xts_block_decrypt. Multiply tweak by alpha^j. Modified: soc2013/def/crashdump-head/sys/crypto/xts.c soc2013/def/crashdump-head/sys/crypto/xts.h Modified: soc2013/def/crashdump-head/sys/crypto/xts.c ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.c Sat Sep 21 21:14:05 2013 (r257575) +++ soc2013/def/crashdump-head/sys/crypto/xts.c Sat Sep 21 21:57:29 2013 (r257576) @@ -126,24 +126,30 @@ static __inline void xts_start(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, - uint64_t *tweak, uint64_t sector, const uint8_t *xtweak) + uint64_t *tweak, uint64_t sector, const uint8_t *xtweak, int j) { + int i; + tweak[0] = htole64(sector); tweak[1] = *((const uint64_t *)xtweak); /* encrypt the tweak */ alg->pa_encrypt(tweak_ctx, (uint8_t *)tweak, (uint8_t *)tweak); + + /* multiply by alpha^j */ + for (i = 0 ; i < j ; i++) + gf_mul128(tweak, tweak); } void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + xts_start(alg, tweak_ctx, tweak, sector, xtweak, j); while (len >= XTS_BLK_BYTES) { xts_fullblock(alg->pa_encrypt, data_ctx, tweak, src, dst); @@ -159,13 +165,13 @@ void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst) { uint64_t tweak[XTS_BLK_BYTES / 8]; uint64_t prevtweak[XTS_BLK_BYTES / 8]; - xts_start(alg, tweak_ctx, tweak, sector, xtweak); + xts_start(alg, tweak_ctx, tweak, sector, xtweak, j); if ((len & XTS_BLK_MASK) != 0) len -= XTS_BLK_BYTES; Modified: soc2013/def/crashdump-head/sys/crypto/xts.h ============================================================================== --- soc2013/def/crashdump-head/sys/crypto/xts.h Sat Sep 21 21:14:05 2013 (r257575) +++ soc2013/def/crashdump-head/sys/crypto/xts.h Sat Sep 21 21:57:29 2013 (r257576) @@ -60,12 +60,12 @@ void xts_block_encrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst); void xts_block_decrypt(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, const struct xts_ctx *data_ctx, - uint64_t sector, const uint8_t *xtweak, int len, + uint64_t sector, const uint8_t *xtweak, int j, int len, const uint8_t *src, uint8_t *dst); algop_crypt_t xts_aes_encrypt; From owner-svn-soc-all@FreeBSD.ORG Sat Sep 21 23:07:04 2013 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 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E92A096A for ; Sat, 21 Sep 2013 23:07:03 +0000 (UTC) (envelope-from def@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id C77972DC8 for ; Sat, 21 Sep 2013 23:07:03 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8LN73Bp024713 for ; Sat, 21 Sep 2013 23:07:03 GMT (envelope-from def@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8LN73Ud024701 for svn-soc-all@FreeBSD.org; Sat, 21 Sep 2013 23:07:03 GMT (envelope-from def@FreeBSD.org) Date: Sat, 21 Sep 2013 23:07:03 GMT Message-Id: <201309212307.r8LN73Ud024701@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: r257589 - in soc2013/def/crashdump-head: sbin/savecore 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.14 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, 21 Sep 2013 23:07:04 -0000 Author: def Date: Sat Sep 21 23:07:03 2013 New Revision: 257589 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257589 Log: Change crash dump routines and savecore to use the current version of XTS implementation. Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c soc2013/def/crashdump-head/sys/kern/kern_shutdown.c soc2013/def/crashdump-head/sys/sys/kerneldump.h Modified: soc2013/def/crashdump-head/sbin/savecore/decryptfile.c ============================================================================== --- soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Sat Sep 21 22:43:50 2013 (r257588) +++ soc2013/def/crashdump-head/sbin/savecore/decryptfile.c Sat Sep 21 23:07:03 2013 (r257589) @@ -19,9 +19,9 @@ memcpy(fd->buf + fd->buf_used, data, resid); fd->buf_used += resid; - xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, (struct xts_ctx *)&fd->data_ctx, - fd->offset, fd->tweak, NULL, PEFS_SECTOR_SIZE, - fd->buf, fd->buf); + xts_block_decrypt(&xts_alg_aes, (struct xts_ctx *)&fd->tweak_ctx, + (struct xts_ctx *)&fd->data_ctx, fd->offset, fd->tweak, 0, + PEFS_SECTOR_SIZE, fd->buf, fd->buf); if (fwrite(fd->buf, 1, PEFS_SECTOR_SIZE, fd->fp) != PEFS_SECTOR_SIZE) return (0); Modified: soc2013/def/crashdump-head/sys/kern/kern_shutdown.c ============================================================================== --- soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Sep 21 22:43:50 2013 (r257588) +++ soc2013/def/crashdump-head/sys/kern/kern_shutdown.c Sat Sep 21 23:07:03 2013 (r257589) @@ -876,7 +876,6 @@ struct kerneldumpbuffer *kdb; int error, sector_index, devblk_index; off_t sector_offset; - uint64_t tweak[XTS_BLK_BYTES / 8]; kdk = di->kdk; kdb = di->kdb; @@ -890,26 +889,14 @@ sector_index = (offset - kdb->kdhoffset)/KERNELDUMP_SECTOR_SIZE; sector_offset = kdb->kdhoffset + sector_index*KERNELDUMP_SECTOR_SIZE; - devblk_index = (offset - kdb->kdhoffset - sector_index*KERNELDUMP_SECTOR_SIZE)/KERNELDUMP_DEVBLK_SIZE; - - if (sector_index == kdb->sector_index) { - kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, kdb->devblk_index, devblk_index, - sector_offset, kdk->tweak); - memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak)); - } + devblk_index = (offset - sector_offset)/KERNELDUMP_DEVBLK_SIZE; while (length > 0) { memcpy(kdb->buf, virtual, KERNELDUMP_DEVBLK_SIZE); - if (sector_index != kdb->sector_index) { - kerneldump_calc_tweak(&xts_alg_aes, &kdk->tweak_ctx, kdb->alpha_j, 0, devblk_index, - sector_offset, kdk->tweak); - kdb->sector_index = sector_index; - memcpy(tweak, kdb->alpha_j[devblk_index], sizeof(tweak)); - } - - xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, offset, kdk->tweak, - tweak, KERNELDUMP_DEVBLK_SIZE, kdb->buf, kdb->buf); + xts_block_encrypt(&xts_alg_aes, &kdk->tweak_ctx, &kdk->data_ctx, + sector_offset, kdk->tweak, devblk_index*KERNELDUMP_DEVBLK_BLKS, + KERNELDUMP_DEVBLK_SIZE, kdb->buf, kdb->buf); error = (di->dumper(di->priv, kdb->buf, physical, offset, KERNELDUMP_DEVBLK_SIZE)); @@ -921,13 +908,8 @@ offset += KERNELDUMP_DEVBLK_SIZE; devblk_index = (devblk_index+1)%KERNELDUMP_SECTOR_BLKS; - if (devblk_index == 0) { - sector_index++; + if (devblk_index == 0) sector_offset = offset; - } else { - memcpy(kdb->alpha_j[devblk_index], tweak, sizeof(tweak)); - kdb->devblk_index = devblk_index; - } } return (0); @@ -955,24 +937,6 @@ #endif } -void -kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, - uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j, - uint64_t sector, const uint8_t *xtweak) -{ - int k; - - if (i == 0) - xts_start(alg, tweak_ctx, alpha_j[0], sector, xtweak); - - for (++i ; i <= j ; i++) { - memcpy(alpha_j[i], alpha_j[i-1], XTS_BLK_BYTES); - - for (k = 0 ; k < KERNELDUMP_DEVBLK_SIZE/XTS_BLK_BYTES ; k++) - gf_mul128(alpha_j[i], alpha_j[i]); - } -} - static void kerneldump_hkdf_expand(struct xts_ctx *ctx, const uint8_t *masterkey, uint8_t *key, int idx, const uint8_t *magic, size_t magicsize) @@ -1037,8 +1001,6 @@ return (NULL); } - kdb->sector_index = -1; - kdb->devblk_index = -1; kdb->kdhoffset = 0; return (kdb); Modified: soc2013/def/crashdump-head/sys/sys/kerneldump.h ============================================================================== --- soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Sep 21 22:43:50 2013 (r257588) +++ soc2013/def/crashdump-head/sys/sys/kerneldump.h Sat Sep 21 23:07:03 2013 (r257589) @@ -133,20 +133,15 @@ struct kerneldumpbuffer { #define KERNELDUMP_DEVBLK_SIZE 512 #define KERNELDUMP_SECTOR_SIZE 4096 +#define KERNELDUMP_DEVBLK_BLKS (KERNELDUMP_DEVBLK_SIZE/XTS_BLK_BYTES) #define KERNELDUMP_SECTOR_BLKS (KERNELDUMP_SECTOR_SIZE/KERNELDUMP_DEVBLK_SIZE) uint8_t buf[KERNELDUMP_DEVBLK_SIZE]; /* Raw data buffer. */ - uint64_t alpha_j[KERNELDUMP_SECTOR_BLKS][XTS_BLK_BYTES / 8]; - off_t sector_index; - off_t devblk_index; off_t kdhoffset; /* Offset value of the first kdh. */ }; void kerneldump_crypto_init(struct dumperinfo *di); struct kerneldumpkey *kerneldump_set_key(struct kerneldumpkey *kdk, int keysize, char *key, char *tweak); struct kerneldumpbuffer *kerneldump_set_buffer(struct kerneldumpbuffer *kdb); -void kerneldump_calc_tweak(const struct xts_alg *alg, const struct xts_ctx *tweak_ctx, - uint64_t (*alpha_j)[XTS_BLK_BYTES / 8], int i, int j, - uint64_t sector, const uint8_t *xtweak); void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, uint64_t dumplen, uint32_t blksz); #endif