From luigi at FreeBSD.org Sun Feb 1 08:00:51 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Sun Feb 1 08:01:02 2009 Subject: svn commit: r187983 - head/sbin/ipfw Message-ID: <200902011600.n11G0osL060567@svn.freebsd.org> Author: luigi Date: Sun Feb 1 16:00:49 2009 New Revision: 187983 URL: http://svn.freebsd.org/changeset/base/187983 Log: put the altq-related functions into a separate file. Minor cleanup of the includes used by the various source files, including annotations of why certain headers are used. Added: head/sbin/ipfw/altq.c (contents, props changed) Modified: head/sbin/ipfw/Makefile head/sbin/ipfw/dummynet.c head/sbin/ipfw/ipfw2.c head/sbin/ipfw/ipfw2.h head/sbin/ipfw/nat.c Modified: head/sbin/ipfw/Makefile ============================================================================== --- head/sbin/ipfw/Makefile Sun Feb 1 10:13:18 2009 (r187982) +++ head/sbin/ipfw/Makefile Sun Feb 1 16:00:49 2009 (r187983) @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= ipfw -SRCS= ipfw2.c dummynet.c ipv6.c main.c nat.c +SRCS= ipfw2.c dummynet.c ipv6.c main.c nat.c altq.c WARNS?= 2 MAN= ipfw.8 Added: head/sbin/ipfw/altq.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/ipfw/altq.c Sun Feb 1 16:00:49 2009 (r187983) @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2002-2003 Luigi Rizzo + * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp + * Copyright (c) 1994 Ugen J.S.Antsilevich + * + * Idea and grammar partially left from: + * Copyright (c) 1993 Daniel Boulet + * + * Redistribution and use in source forms, with and without modification, + * are permitted provided that this entire comment appears intact. + * + * Redistribution in binary form may occur without any restrictions. + * Obviously, it would be nice if you gave credit where credit is due + * but requiring it would be too onerous. + * + * This software is provided ``AS IS'' without any warranties of any kind. + * + * NEW command line interface for IP firewall facility + * + * $FreeBSD$ + * + * altq interface + */ + +#include +#include +#include + +#include "ipfw2.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include /* IFNAMSIZ */ +#include +#include + +/* + * Map between current altq queue id numbers and names. + */ +static TAILQ_HEAD(, pf_altq) altq_entries = + TAILQ_HEAD_INITIALIZER(altq_entries); + +void +altq_set_enabled(int enabled) +{ + int pffd; + + pffd = open("/dev/pf", O_RDWR); + if (pffd == -1) + err(EX_UNAVAILABLE, + "altq support opening pf(4) control device"); + if (enabled) { + if (ioctl(pffd, DIOCSTARTALTQ) != 0 && errno != EEXIST) + err(EX_UNAVAILABLE, "enabling altq"); + } else { + if (ioctl(pffd, DIOCSTOPALTQ) != 0 && errno != ENOENT) + err(EX_UNAVAILABLE, "disabling altq"); + } + close(pffd); +} + +static void +altq_fetch(void) +{ + struct pfioc_altq pfioc; + struct pf_altq *altq; + int pffd; + unsigned int mnr; + static int altq_fetched = 0; + + if (altq_fetched) + return; + altq_fetched = 1; + pffd = open("/dev/pf", O_RDONLY); + if (pffd == -1) { + warn("altq support opening pf(4) control device"); + return; + } + bzero(&pfioc, sizeof(pfioc)); + if (ioctl(pffd, DIOCGETALTQS, &pfioc) != 0) { + warn("altq support getting queue list"); + close(pffd); + return; + } + mnr = pfioc.nr; + for (pfioc.nr = 0; pfioc.nr < mnr; pfioc.nr++) { + if (ioctl(pffd, DIOCGETALTQ, &pfioc) != 0) { + if (errno == EBUSY) + break; + warn("altq support getting queue list"); + close(pffd); + return; + } + if (pfioc.altq.qid == 0) + continue; + altq = safe_calloc(1, sizeof(*altq)); + *altq = pfioc.altq; + TAILQ_INSERT_TAIL(&altq_entries, altq, entries); + } + close(pffd); +} + +u_int32_t +altq_name_to_qid(const char *name) +{ + struct pf_altq *altq; + + altq_fetch(); + TAILQ_FOREACH(altq, &altq_entries, entries) + if (strcmp(name, altq->qname) == 0) + break; + if (altq == NULL) + errx(EX_DATAERR, "altq has no queue named `%s'", name); + return altq->qid; +} + +const char * +altq_qid_to_name(u_int32_t qid) +{ + struct pf_altq *altq; + + altq_fetch(); + TAILQ_FOREACH(altq, &altq_entries, entries) + if (qid == altq->qid) + break; + if (altq == NULL) + return NULL; + return altq->qname; +} + +void +print_altq_cmd(ipfw_insn_altq *altqptr) +{ + if (altqptr) { + const char *qname; + + qname = altq_qid_to_name(altqptr->qid); + if (qname == NULL) + printf(" altq ?<%u>", altqptr->qid); + else + printf(" altq %s", qname); + } +} Modified: head/sbin/ipfw/dummynet.c ============================================================================== --- head/sbin/ipfw/dummynet.c Sun Feb 1 10:13:18 2009 (r187982) +++ head/sbin/ipfw/dummynet.c Sun Feb 1 16:00:49 2009 (r187983) @@ -24,7 +24,8 @@ #include #include -#include +#include +/* XXX there are several sysctl leftover here */ #include #include "ipfw2.h" @@ -38,12 +39,11 @@ #include #include +#include #include -#include -#include #include #include -#include +#include /* inet_ntoa */ static struct _s_x dummynet_params[] = { { "plr", TOK_PLR }, Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Sun Feb 1 10:13:18 2009 (r187982) +++ head/sbin/ipfw/ipfw2.c Sun Feb 1 16:00:49 2009 (r187983) @@ -37,19 +37,15 @@ #include #include #include +#include /* ctime */ #include /* _long_to_time */ #include #include -#define IPFW_INTERNAL /* Access to protected structures in ip_fw.h. */ - #include -#include -#include -#include -#include /* def. of struct route */ +#include /* only IFNAMSIZ */ #include -#include +#include /* only n_short, n_long */ #include #include #include @@ -586,106 +582,6 @@ strtoport(char *s, char **end, int base, } /* - * Map between current altq queue id numbers and names. - */ -static int altq_fetched = 0; -static TAILQ_HEAD(, pf_altq) altq_entries = - TAILQ_HEAD_INITIALIZER(altq_entries); - -static void -altq_set_enabled(int enabled) -{ - int pffd; - - pffd = open("/dev/pf", O_RDWR); - if (pffd == -1) - err(EX_UNAVAILABLE, - "altq support opening pf(4) control device"); - if (enabled) { - if (ioctl(pffd, DIOCSTARTALTQ) != 0 && errno != EEXIST) - err(EX_UNAVAILABLE, "enabling altq"); - } else { - if (ioctl(pffd, DIOCSTOPALTQ) != 0 && errno != ENOENT) - err(EX_UNAVAILABLE, "disabling altq"); - } - close(pffd); -} - -static void -altq_fetch(void) -{ - struct pfioc_altq pfioc; - struct pf_altq *altq; - int pffd; - unsigned int mnr; - - if (altq_fetched) - return; - altq_fetched = 1; - pffd = open("/dev/pf", O_RDONLY); - if (pffd == -1) { - warn("altq support opening pf(4) control device"); - return; - } - bzero(&pfioc, sizeof(pfioc)); - if (ioctl(pffd, DIOCGETALTQS, &pfioc) != 0) { - warn("altq support getting queue list"); - close(pffd); - return; - } - mnr = pfioc.nr; - for (pfioc.nr = 0; pfioc.nr < mnr; pfioc.nr++) { - if (ioctl(pffd, DIOCGETALTQ, &pfioc) != 0) { - if (errno == EBUSY) - break; - warn("altq support getting queue list"); - close(pffd); - return; - } - if (pfioc.altq.qid == 0) - continue; - altq = safe_calloc(1, sizeof(*altq)); - *altq = pfioc.altq; - TAILQ_INSERT_TAIL(&altq_entries, altq, entries); - } - close(pffd); -} - -static u_int32_t -altq_name_to_qid(const char *name) -{ - struct pf_altq *altq; - - altq_fetch(); - TAILQ_FOREACH(altq, &altq_entries, entries) - if (strcmp(name, altq->qname) == 0) - break; - if (altq == NULL) - errx(EX_DATAERR, "altq has no queue named `%s'", name); - return altq->qid; -} - -static const char * -altq_qid_to_name(u_int32_t qid) -{ - struct pf_altq *altq; - - altq_fetch(); - TAILQ_FOREACH(altq, &altq_entries, entries) - if (qid == altq->qid) - break; - if (altq == NULL) - return NULL; - return altq->qname; -} - -static void -fill_altq_qid(u_int32_t *qid, const char *av) -{ - *qid = altq_name_to_qid(av); -} - -/* * Fill the body of the command with the list of port ranges. */ static int @@ -1206,13 +1102,7 @@ show_ipfw(struct ip_fw *rule, int pcwidt printf(" log"); } if (altqptr) { - const char *qname; - - qname = altq_qid_to_name(altqptr->qid); - if (qname == NULL) - printf(" altq ?<%u>", altqptr->qid); - else - printf(" altq %s", qname); + print_altq_cmd(altqptr); } if (tagptr) { if (tagptr->len & F_NOT) @@ -2945,7 +2835,7 @@ chkarg: have_altq = (ipfw_insn *)a; cmd->len = F_INSN_SIZE(ipfw_insn_altq); cmd->opcode = O_ALTQ; - fill_altq_qid(&a->qid, *av); + a->qid = altq_name_to_qid(*av); ac--; av++; } break; Modified: head/sbin/ipfw/ipfw2.h ============================================================================== --- head/sbin/ipfw/ipfw2.h Sun Feb 1 10:13:18 2009 (r187982) +++ head/sbin/ipfw/ipfw2.h Sun Feb 1 16:00:49 2009 (r187983) @@ -219,6 +219,7 @@ int contigmask(uint8_t *p, int len); * functions involved, so we do not lose error checking. */ struct _ipfw_insn; +struct _ipfw_insn_altq; struct _ipfw_insn_u32; struct _ipfw_insn_ip6; struct _ipfw_insn_icmp6; @@ -243,6 +244,12 @@ void ipfw_flush(int force); void ipfw_zero(int ac, char *av[], int optname); void ipfw_list(int ac, char *av[], int show_counters); +/* altq.c */ +void altq_set_enabled(int enabled); +u_int32_t altq_name_to_qid(const char *name); + +void print_altq_cmd(struct _ipfw_insn_altq *altqptr); + /* dummynet.c */ void ipfw_list_pipes(void *data, uint nbytes, int ac, char *av[]); int ipfw_delete_pipe(int pipe_or_queue, int n); Modified: head/sbin/ipfw/nat.c ============================================================================== --- head/sbin/ipfw/nat.c Sun Feb 1 10:13:18 2009 (r187982) +++ head/sbin/ipfw/nat.c Sun Feb 1 16:00:49 2009 (r187983) @@ -24,7 +24,6 @@ #include #include -#include #include #include "ipfw2.h" @@ -43,7 +42,6 @@ #include #include /* def. of struct route */ #include -#include #include #include #include From bz at FreeBSD.org Sun Feb 1 13:11:11 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Sun Feb 1 13:11:18 2009 Subject: svn commit: r187989 - in head: . sys/netinet6 usr.bin/netstat Message-ID: <200902012111.n11LB9er066518@svn.freebsd.org> Author: bz Date: Sun Feb 1 21:11:08 2009 New Revision: 187989 URL: http://svn.freebsd.org/changeset/base/187989 Log: Remove the single global unlocked route cache ip6_forward_rt from the inet6 stack along with statistics and make sure we properly free the rt in all cases. While the current situation is not better performance wise it prevents panics seen more often these days. After more inet6 and ipsec cleanup we should be able to improve the situation again passing the rt to ip6_forward directly. Leave the ip6_forward_rt entry in struct vinet6 but mark it for removal. PR: kern/128247, kern/131038 MFC after: 25 days Committed from: Bugathon #6 Tested by: Denis Ahrens (different initial version) Modified: head/UPDATING head/sys/netinet6/frag6.c head/sys/netinet6/ip6_forward.c head/sys/netinet6/ip6_input.c head/sys/netinet6/ip6_var.h head/sys/netinet6/vinet6.h head/usr.bin/netstat/inet6.c Modified: head/UPDATING ============================================================================== --- head/UPDATING Sun Feb 1 20:18:27 2009 (r187988) +++ head/UPDATING Sun Feb 1 21:11:08 2009 (r187989) @@ -22,6 +22,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20090201: + INET6 statistics (struct ip6stat) was updated. + netstat(1) needs to be recompiled. + 20090119: NTFS has been removed from GENERIC kernel on amd64 to match GENERIC on i386. Should not cause any issues since mount_ntfs(8) Modified: head/sys/netinet6/frag6.c ============================================================================== --- head/sys/netinet6/frag6.c Sun Feb 1 20:18:27 2009 (r187988) +++ head/sys/netinet6/frag6.c Sun Feb 1 21:11:08 2009 (r187989) @@ -751,18 +751,6 @@ frag6_slowtimo(void) } VNET_LIST_RUNLOCK(); IP6Q_UNLOCK(); - -#if 0 - /* - * Routing changes might produce a better route than we last used; - * make sure we notice eventually, even if forwarding only for one - * destination and the cache is never replaced. - */ - if (V_ip6_forward_rt.ro_rt) { - RTFREE(V_ip6_forward_rt.ro_rt); - V_ip6_forward_rt.ro_rt = 0; - } -#endif } /* Modified: head/sys/netinet6/ip6_forward.c ============================================================================== --- head/sys/netinet6/ip6_forward.c Sun Feb 1 20:18:27 2009 (r187988) +++ head/sys/netinet6/ip6_forward.c Sun Feb 1 21:11:08 2009 (r187989) @@ -77,10 +77,6 @@ __FBSDID("$FreeBSD$"); #include -#ifdef VIMAGE_GLOBALS -struct route_in6 ip6_forward_rt; -#endif - /* * Forward a packet. If some error occurs return the sender * an icmp packet. Note we can't always generate a meaningful @@ -100,6 +96,7 @@ ip6_forward(struct mbuf *m, int srcrt) struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); struct sockaddr_in6 *dst = NULL; struct rtentry *rt = NULL; + struct route_in6 rin6; int error, type = 0, code = 0; struct mbuf *mcopy = NULL; struct ifnet *origifp; /* maybe unnecessary */ @@ -112,8 +109,6 @@ ip6_forward(struct mbuf *m, int srcrt) #endif char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN]; - /* GIANT_REQUIRED; */ /* XXX bz: ip6_forward_rt */ - #ifdef IPSEC /* * Check AH/ESP integrity. @@ -355,56 +350,27 @@ ip6_forward(struct mbuf *m, int srcrt) skip_ipsec: #endif - dst = (struct sockaddr_in6 *)&V_ip6_forward_rt.ro_dst; - if (!srcrt) { - /* ip6_forward_rt.ro_dst.sin6_addr is equal to ip6->ip6_dst */ - if (V_ip6_forward_rt.ro_rt == 0 || - (V_ip6_forward_rt.ro_rt->rt_flags & RTF_UP) == 0) { - if (V_ip6_forward_rt.ro_rt) { - RTFREE(V_ip6_forward_rt.ro_rt); - V_ip6_forward_rt.ro_rt = 0; - } - - /* this probably fails but give it a try again */ - rtalloc((struct route *)&V_ip6_forward_rt); - } - - if (V_ip6_forward_rt.ro_rt == 0) { - V_ip6stat.ip6s_noroute++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute); - if (mcopy) { - icmp6_error(mcopy, ICMP6_DST_UNREACH, - ICMP6_DST_UNREACH_NOROUTE, 0); - } - m_freem(m); - return; - } - } else if ((rt = V_ip6_forward_rt.ro_rt) == 0 || - !IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, &dst->sin6_addr)) { - if (V_ip6_forward_rt.ro_rt) { - RTFREE(V_ip6_forward_rt.ro_rt); - V_ip6_forward_rt.ro_rt = 0; - } - bzero(dst, sizeof(*dst)); - dst->sin6_len = sizeof(struct sockaddr_in6); - dst->sin6_family = AF_INET6; - dst->sin6_addr = ip6->ip6_dst; - - rtalloc((struct route *)&V_ip6_forward_rt); - if (V_ip6_forward_rt.ro_rt == 0) { - V_ip6stat.ip6s_noroute++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute); - if (mcopy) { - icmp6_error(mcopy, ICMP6_DST_UNREACH, - ICMP6_DST_UNREACH_NOROUTE, 0); - } - m_freem(m); - return; + bzero(&rin6, sizeof(struct route_in6)); + dst = (struct sockaddr_in6 *)&rin6.ro_dst; + dst->sin6_len = sizeof(struct sockaddr_in6); + dst->sin6_family = AF_INET6; + dst->sin6_addr = ip6->ip6_dst; + + rin6.ro_rt = rtalloc1((struct sockaddr *)dst, 0, 0); + if (rin6.ro_rt != NULL) + RT_UNLOCK(rin6.ro_rt); + else { + V_ip6stat.ip6s_noroute++; + in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_noroute); + if (mcopy) { + icmp6_error(mcopy, ICMP6_DST_UNREACH, + ICMP6_DST_UNREACH_NOROUTE, 0); } + goto bad; } - rt = V_ip6_forward_rt.ro_rt; + rt = rin6.ro_rt; #ifdef IPSEC - skip_routing:; +skip_routing: #endif /* @@ -421,14 +387,12 @@ skip_ipsec: /* XXX: this should not happen */ V_ip6stat.ip6s_cantforward++; V_ip6stat.ip6s_badscope++; - m_freem(m); - return; + goto bad; } if (in6_setscope(&src_in6, m->m_pkthdr.rcvif, &inzone)) { V_ip6stat.ip6s_cantforward++; V_ip6stat.ip6s_badscope++; - m_freem(m); - return; + goto bad; } if (inzone != outzone #ifdef IPSEC @@ -452,8 +416,7 @@ skip_ipsec: if (mcopy) icmp6_error(mcopy, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_BEYONDSCOPE, 0); - m_freem(m); - return; + goto bad; } /* @@ -469,8 +432,7 @@ skip_ipsec: inzone != outzone) { V_ip6stat.ip6s_cantforward++; V_ip6stat.ip6s_badscope++; - m_freem(m); - return; + goto bad; } if (m->m_pkthdr.len > IN6_LINKMTU(rt->rt_ifp)) { @@ -510,8 +472,7 @@ skip_ipsec: #endif /* IPSEC */ icmp6_error(mcopy, ICMP6_PACKET_TOO_BIG, 0, mtu); } - m_freem(m); - return; + goto bad; } if (rt->rt_flags & RTF_GATEWAY) @@ -544,8 +505,7 @@ skip_ipsec: */ icmp6_error(mcopy, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0); - m_freem(m); - return; + goto bad; } type = ND_REDIRECT; } @@ -624,12 +584,12 @@ pass: senderr: if (mcopy == NULL) - return; + goto out; switch (error) { case 0: if (type == ND_REDIRECT) { icmp6_redirect_output(mcopy, rt); - return; + goto out; } goto freecopy; @@ -651,9 +611,18 @@ senderr: break; } icmp6_error(mcopy, type, code, 0); - return; + goto out; freecopy: m_freem(mcopy); - return; + goto out; +bad: + m_freem(m); +out: + if (rt != NULL +#ifdef IPSEC + && !ipsecrt +#endif + ) + RTFREE(rt); } Modified: head/sys/netinet6/ip6_input.c ============================================================================== --- head/sys/netinet6/ip6_input.c Sun Feb 1 20:18:27 2009 (r187988) +++ head/sys/netinet6/ip6_input.c Sun Feb 1 21:11:08 2009 (r187989) @@ -143,8 +143,6 @@ extern int icmp6errppslim; extern int icmp6_nodeinfo; extern int udp6_sendspace; extern int udp6_recvspace; - -extern struct route_in6 ip6_forward_rt; #endif struct pfil_head inet6_pfil_hook; @@ -309,10 +307,12 @@ ip6_input(struct mbuf *m) int nxt, ours = 0; struct ifnet *deliverifp = NULL, *ifp = NULL; struct in6_addr odst; + struct route_in6 rin6; int srcrt = 0; struct llentry *lle = NULL; - struct sockaddr_in6 dst6; + struct sockaddr_in6 dst6, *dst; + bzero(&rin6, sizeof(struct route_in6)); #ifdef IPSEC /* * should the inner packet be considered authentic? @@ -565,29 +565,13 @@ passin: if (lle != NULL) LLE_RUNLOCK(lle); - if (V_ip6_forward_rt.ro_rt != NULL && - (V_ip6_forward_rt.ro_rt->rt_flags & RTF_UP) != 0 && - IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, - &((struct sockaddr_in6 *)(&V_ip6_forward_rt.ro_dst))->sin6_addr)) - V_ip6stat.ip6s_forward_cachehit++; - else { - struct sockaddr_in6 *dst6; - - if (V_ip6_forward_rt.ro_rt) { - /* route is down or destination is different */ - V_ip6stat.ip6s_forward_cachemiss++; - RTFREE(V_ip6_forward_rt.ro_rt); - V_ip6_forward_rt.ro_rt = 0; - } - - bzero(&V_ip6_forward_rt.ro_dst, sizeof(struct sockaddr_in6)); - dst6 = (struct sockaddr_in6 *)&V_ip6_forward_rt.ro_dst; - dst6->sin6_len = sizeof(struct sockaddr_in6); - dst6->sin6_family = AF_INET6; - dst6->sin6_addr = ip6->ip6_dst; - - rtalloc((struct route *)&V_ip6_forward_rt); - } + dst = &rin6.ro_dst; + dst->sin6_len = sizeof(struct sockaddr_in6); + dst->sin6_family = AF_INET6; + dst->sin6_addr = ip6->ip6_dst; + rin6.ro_rt = rtalloc1((struct sockaddr *)dst, 0, 0); + if (rin6.ro_rt) + RT_UNLOCK(rin6.ro_rt); #define rt6_key(r) ((struct sockaddr_in6 *)((r)->rt_nodes->rn_key)) @@ -611,14 +595,14 @@ passin: * while it would be less efficient. Or, should we rather install a * reject route for such a case? */ - if (V_ip6_forward_rt.ro_rt && - (V_ip6_forward_rt.ro_rt->rt_flags & + if (rin6.ro_rt && + (rin6.ro_rt->rt_flags & (RTF_HOST|RTF_GATEWAY)) == RTF_HOST && #ifdef RTF_WASCLONED - !(V_ip6_forward_rt.ro_rt->rt_flags & RTF_WASCLONED) && + !(rin6.ro_rt->rt_flags & RTF_WASCLONED) && #endif #ifdef RTF_CLONED - !(V_ip6_forward_rt.ro_rt->rt_flags & RTF_CLONED) && + !(rin6.ro_rt->rt_flags & RTF_CLONED) && #endif #if 0 /* @@ -627,11 +611,11 @@ passin: * already done through looking up the routing table. */ IN6_ARE_ADDR_EQUAL(&ip6->ip6_dst, - &rt6_key(V_ip6_forward_rt.ro_rt)->sin6_addr) + &rt6_key(rin6.ro_rt)->sin6_addr) #endif - V_ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_LOOP) { + rin6.ro_rt->rt_ifp->if_type == IFT_LOOP) { struct in6_ifaddr *ia6 = - (struct in6_ifaddr *)V_ip6_forward_rt.ro_rt->rt_ifa; + (struct in6_ifaddr *)rin6.ro_rt->rt_ifa; /* * record address information into m_tag. @@ -667,11 +651,11 @@ passin: * FAITH (Firewall Aided Internet Translator) */ if (V_ip6_keepfaith) { - if (V_ip6_forward_rt.ro_rt && V_ip6_forward_rt.ro_rt->rt_ifp - && V_ip6_forward_rt.ro_rt->rt_ifp->if_type == IFT_FAITH) { + if (rin6.ro_rt && rin6.ro_rt->rt_ifp && + rin6.ro_rt->rt_ifp->if_type == IFT_FAITH) { /* XXX do we need more sanity checks? */ ours = 1; - deliverifp = V_ip6_forward_rt.ro_rt->rt_ifp; /* faith */ + deliverifp = rin6.ro_rt->rt_ifp; /* faith */ goto hbhcheck; } } @@ -721,7 +705,7 @@ passin: #if 0 /*touches NULL pointer*/ in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard); #endif - return; /* m have already been freed */ + goto out; /* m have already been freed */ } /* adjust pointer */ @@ -744,7 +728,7 @@ passin: icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER, (caddr_t)&ip6->ip6_plen - (caddr_t)ip6); - return; + goto out; } #ifndef PULLDOWN_TEST /* ip6_hopopts_input() ensures that mbuf is contiguous */ @@ -754,7 +738,7 @@ passin: sizeof(struct ip6_hbh)); if (hbh == NULL) { V_ip6stat.ip6s_tooshort++; - return; + goto out; } #endif nxt = hbh->ip6h_nxt; @@ -816,16 +800,13 @@ passin: if (ip6_mrouter && ip6_mforward && ip6_mforward(ip6, m->m_pkthdr.rcvif, m)) { V_ip6stat.ip6s_cantforward++; - m_freem(m); - return; - } - if (!ours) { - m_freem(m); - return; + goto bad; } + if (!ours) + goto bad; } else if (!ours) { ip6_forward(m, srcrt); - return; + goto out; } ip6 = mtod(m, struct ip6_hdr *); @@ -880,9 +861,12 @@ passin: #endif /* IPSEC */ nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &off, nxt); } - return; - bad: + goto out; +bad: m_freem(m); +out: + if (rin6.ro_rt) + RTFREE(rin6.ro_rt); } /* Modified: head/sys/netinet6/ip6_var.h ============================================================================== --- head/sys/netinet6/ip6_var.h Sun Feb 1 20:18:27 2009 (r187988) +++ head/sys/netinet6/ip6_var.h Sun Feb 1 21:11:08 2009 (r187989) @@ -229,9 +229,6 @@ struct ip6stat { /* number of times that a deprecated address is chosen */ u_quad_t ip6s_sources_deprecated[16]; - u_quad_t ip6s_forward_cachehit; - u_quad_t ip6s_forward_cachemiss; - /* number of times that each rule of source selection is applied. */ u_quad_t ip6s_sources_rule[16]; }; Modified: head/sys/netinet6/vinet6.h ============================================================================== --- head/sys/netinet6/vinet6.h Sun Feb 1 20:18:27 2009 (r187988) +++ head/sys/netinet6/vinet6.h Sun Feb 1 21:11:08 2009 (r187989) @@ -54,7 +54,7 @@ struct vnet_inet6 { u_int _frag6_nfrags; struct ip6q _ip6q; - struct route_in6 _ip6_forward_rt; + struct route_in6 _ip6_forward_rt; /* XXX remove */ struct in6_addrpolicy _defaultaddrpolicy; TAILQ_HEAD(, addrsel_policyent) _addrsel_policytab; @@ -194,7 +194,6 @@ extern struct vnet_inet6 vnet_inet6_0; #define V_ip6_defhlim VNET_INET6(ip6_defhlim) #define V_ip6_defmcasthlim VNET_INET6(ip6_defmcasthlim) #define V_ip6_desync_factor VNET_INET6(ip6_desync_factor) -#define V_ip6_forward_rt VNET_INET6(ip6_forward_rt) #define V_ip6_forwarding VNET_INET6(ip6_forwarding) #define V_ip6_hdrnestlimit VNET_INET6(ip6_hdrnestlimit) #define V_ip6_keepfaith VNET_INET6(ip6_keepfaith) Modified: head/usr.bin/netstat/inet6.c ============================================================================== --- head/usr.bin/netstat/inet6.c Sun Feb 1 20:18:27 2009 (r187988) +++ head/usr.bin/netstat/inet6.c Sun Feb 1 21:11:08 2009 (r187989) @@ -512,8 +512,6 @@ ip6_stats(u_long off, const char *name, } } - p1a(ip6s_forward_cachehit, "\t%ju forward cache hit\n"); - p1a(ip6s_forward_cachemiss, "\t%ju forward cache miss\n"); printf("\tSource addresses selection rule applied:\n"); for (i = 0; i < 16; i++) { if (ip6stat.ip6s_sources_rule[i]) From sam at FreeBSD.org Sun Feb 1 14:24:09 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Sun Feb 1 14:24:14 2009 Subject: svn commit: r187991 - head/sys/net80211 Message-ID: <200902012224.n11MO85p067988@svn.freebsd.org> Author: sam Date: Sun Feb 1 22:24:08 2009 New Revision: 187991 URL: http://svn.freebsd.org/changeset/base/187991 Log: when promoting an 11b channel to 11g do not accept a ``pure G'' (OFDM only) channel, only accept a real 11g channel; this fixes a problem where we were wrongly promoting 11b to a Dynamic Turbo G channel which broke scanning on channel 6 Modified: head/sys/net80211/ieee80211_scan_sta.c Modified: head/sys/net80211/ieee80211_scan_sta.c ============================================================================== --- head/sys/net80211/ieee80211_scan_sta.c Sun Feb 1 21:50:07 2009 (r187990) +++ head/sys/net80211/ieee80211_scan_sta.c Sun Feb 1 22:24:08 2009 (r187991) @@ -395,12 +395,12 @@ find11gchannel(struct ieee80211com *ic, */ for (j = i+1; j < ic->ic_nchans; j++) { c = &ic->ic_channels[j]; - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c)) + if (c->ic_freq == freq && IEEE80211_IS_CHAN_G(c)) return c; } for (j = 0; j < i; j++) { c = &ic->ic_channels[j]; - if (c->ic_freq == freq && IEEE80211_IS_CHAN_ANYG(c)) + if (c->ic_freq == freq && IEEE80211_IS_CHAN_G(c)) return c; } return NULL; From sbruno at FreeBSD.org Sun Feb 1 15:28:53 2009 From: sbruno at FreeBSD.org (Sean Bruno) Date: Sun Feb 1 15:29:05 2009 Subject: svn commit: r187993 - head/sys/dev/firewire Message-ID: <200902012328.n11NSqYG069209@svn.freebsd.org> Author: sbruno Date: Sun Feb 1 23:28:52 2009 New Revision: 187993 URL: http://svn.freebsd.org/changeset/base/187993 Log: Some updates and bug squashing in the firewire stack. Move the interupt handler to a driver_intr_t type function as it was trying to do way to much for a lightweight filter interrupt function. Introduce much more locking around fc->mtx. Tested this for lock reversals and other such lockups. Locking seems to be working better, but there is much more to do with regard to locking. The most significant lock is in the BUS RESET handler. It was possible, before this checkin, to set a bus reset via "fwcontrol -r" and have the BUS RESET handler fire before the code responsible for asserting BUS RESET was complete. This locking fixes that issue. Move some of the memory allocations in the fc struct to the attach function in firewire.c Rework the businfo.generation indicator to be merely a on/off bit now. It's purpose according to spec is to notify the bus that the config ROM has changed. That's it. Catch and squash a possible panic in SBP where in the SBP_LOCK was held during a possible error case. The error handling code would definitely panic as it would try to acquire the SBP_LOCK on entrance. Catch and squash a camcontrol/device lockup when firewire drives go away. When a firewire device was powered off or disconnected from the firewire bus, a "camcontrol rescan all" would hang trying to poll removed devices as they were not properly detached. Don't do that. Approved by: scottl MFC after: 2 weeks Modified: head/sys/dev/firewire/firewire.c head/sys/dev/firewire/fwohci.c head/sys/dev/firewire/fwohci_pci.c head/sys/dev/firewire/fwohcivar.h head/sys/dev/firewire/sbp.c Modified: head/sys/dev/firewire/firewire.c ============================================================================== --- head/sys/dev/firewire/firewire.c Sun Feb 1 23:27:21 2009 (r187992) +++ head/sys/dev/firewire/firewire.c Sun Feb 1 23:28:52 2009 (r187993) @@ -430,6 +430,31 @@ firewire_attach(device_t dev) fwdev_makedev(sc); + fc->crom_src_buf = (struct crom_src_buf *)malloc( + sizeof(struct crom_src_buf), + M_FW, M_NOWAIT | M_ZERO); + if (fc->crom_src_buf == NULL) { + device_printf(fc->dev, "%s: Malloc Failure crom src buff\n", __func__); + return ENOMEM; + } + fc->topology_map = (struct fw_topology_map *)malloc( + sizeof(struct fw_topology_map), + M_FW, M_NOWAIT | M_ZERO); + if (fc->topology_map == NULL) { + device_printf(fc->dev, "%s: Malloc Failure topology map\n", __func__); + free(fc->crom_src_buf, M_FW); + return ENOMEM; + } + fc->speed_map = (struct fw_speed_map *)malloc( + sizeof(struct fw_speed_map), + M_FW, M_NOWAIT | M_ZERO); + if (fc->speed_map == NULL) { + device_printf(fc->dev, "%s: Malloc Failure speed map\n", __func__); + free(fc->crom_src_buf, M_FW); + free(fc->topology_map, M_FW); + return ENOMEM; + } + mtx_init(&fc->wait_lock, "fwwait", NULL, MTX_DEF); mtx_init(&fc->tlabel_lock, "fwtlabel", NULL, MTX_DEF); CALLOUT_INIT(&fc->timeout_callout); @@ -451,7 +476,9 @@ firewire_attach(device_t dev) bus_generic_attach(dev); /* bus_reset */ + FW_GLOCK(fc); fw_busreset(fc, FWBUSNOTREADY); + FW_GUNLOCK(fc); fc->ibr(fc); return 0; @@ -642,11 +669,6 @@ fw_init_crom(struct firewire_comm *fc) { struct crom_src *src; - fc->crom_src_buf = (struct crom_src_buf *) - malloc(sizeof(struct crom_src_buf), M_FW, M_WAITOK | M_ZERO); - if (fc->crom_src_buf == NULL) - return; - src = &fc->crom_src_buf->src; bzero(src, sizeof(struct crom_src)); @@ -663,7 +685,7 @@ fw_init_crom(struct firewire_comm *fc) src->businfo.cyc_clk_acc = 100; src->businfo.max_rec = fc->maxrec; src->businfo.max_rom = MAXROM_4; - src->businfo.generation = 1; + src->businfo.generation = 0; src->businfo.link_spd = fc->speed; src->businfo.eui64.hi = fc->eui.hi; @@ -682,9 +704,6 @@ fw_reset_crom(struct firewire_comm *fc) struct crom_src *src; struct crom_chunk *root; - if (fc->crom_src_buf == NULL) - fw_init_crom(fc); - buf = fc->crom_src_buf; src = fc->crom_src; root = fc->crom_root; @@ -715,18 +734,18 @@ fw_busreset(struct firewire_comm *fc, ui struct firewire_dev_comm *fdc; struct crom_src *src; device_t *devlistp; - void *newrom; int i, devcnt; - switch(fc->status){ - case FWBUSMGRELECT: + FW_GLOCK_ASSERT(fc); + if (fc->status == FWBUSMGRELECT) callout_stop(&fc->bmr_callout); - break; - default: - break; - } + fc->status = new_status; fw_reset_csr(fc); + + if (fc->status == FWBUSNOTREADY) + fw_init_crom(fc); + fw_reset_crom(fc); if (device_get_children(fc->bdev, &devlistp, &devcnt) == 0) { @@ -739,19 +758,19 @@ fw_busreset(struct firewire_comm *fc, ui free(devlistp, M_TEMP); } - newrom = malloc(CROMSIZE, M_FW, M_NOWAIT | M_ZERO); src = &fc->crom_src_buf->src; - crom_load(src, (uint32_t *)newrom, CROMSIZE); - if (bcmp(newrom, fc->config_rom, CROMSIZE) != 0) { - /* bump generation and reload */ - src->businfo.generation ++; - /* generation must be between 0x2 and 0xF */ - if (src->businfo.generation < 2) - src->businfo.generation ++; - crom_load(src, (uint32_t *)newrom, CROMSIZE); - bcopy(newrom, (void *)fc->config_rom, CROMSIZE); - } - free(newrom, M_FW); + /* + * If the old config rom needs to be overwritten, + * bump the businfo.generation indicator to + * indicate that we need to be reprobed + */ + if (bcmp(src, fc->config_rom, CROMSIZE) != 0) { + /* generation is a 2 bit field */ + /* valid values are only from 0 - 3 */ + src->businfo.generation = 1; + bcopy(src, (void *)fc->config_rom, CROMSIZE); + } else + src->businfo.generation = 0; } /* Call once after reboot */ @@ -807,13 +826,7 @@ void fw_init(struct firewire_comm *fc) fc->ir[i]->maxq = FWMAXQUEUE; fc->it[i]->maxq = FWMAXQUEUE; } -/* Initialize csr registers */ - fc->topology_map = (struct fw_topology_map *)malloc( - sizeof(struct fw_topology_map), - M_FW, M_NOWAIT | M_ZERO); - fc->speed_map = (struct fw_speed_map *)malloc( - sizeof(struct fw_speed_map), - M_FW, M_NOWAIT | M_ZERO); + CSRARC(fc, TOPO_MAP) = 0x3f1 << 16; CSRARC(fc, TOPO_MAP + 4) = 1; CSRARC(fc, SPED_MAP) = 0x3f1 << 16; @@ -1559,7 +1572,7 @@ fw_explore_node(struct fw_device *dfwdev /* unchanged ? */ if (bcmp(&csr[0], &fwdev->csrrom[0], sizeof(uint32_t) * 5) == 0) { if (firewire_debug) - printf("node%d: crom unchanged\n", node); + device_printf(fc->dev, "node%d: crom unchanged\n", node); return (0); } Modified: head/sys/dev/firewire/fwohci.c ============================================================================== --- head/sys/dev/firewire/fwohci.c Sun Feb 1 23:27:21 2009 (r187992) +++ head/sys/dev/firewire/fwohci.c Sun Feb 1 23:28:52 2009 (r187993) @@ -1003,7 +1003,7 @@ again: if (maxdesc < db_tr->dbcnt) { maxdesc = db_tr->dbcnt; if (firewire_debug) - device_printf(sc->fc.dev, "maxdesc: %d\n", maxdesc); + device_printf(sc->fc.dev, "%s: maxdesc %d\n", __func__, maxdesc); } /* last db */ LAST_DB(db_tr, db); @@ -1842,6 +1842,7 @@ fwohci_intr_core(struct fwohci_softc *sc struct firewire_comm *fc = (struct firewire_comm *)sc; uint32_t node_id, plen; + FW_GLOCK_ASSERT(fc); if ((stat & OHCI_INT_PHY_BUS_R) && (fc->status != FWBUSRESET)) { fc->status = FWBUSRESET; /* Disable bus reset interrupt until sid recv. */ @@ -1884,8 +1885,8 @@ fwohci_intr_core(struct fwohci_softc *sc plen = OREAD(sc, OHCI_SID_CNT); fc->nodeid = node_id & 0x3f; - device_printf(fc->dev, "node_id=0x%08x, gen=%d, ", - node_id, (plen >> 16) & 0xff); + device_printf(fc->dev, "node_id=0x%08x, SelfID Count=%d, ", + fc->nodeid, (plen >> 16) & 0xff); if (!(node_id & OHCI_NODE_VALID)) { printf("Bus reset failure\n"); goto sidout; @@ -1996,9 +1997,11 @@ fwohci_task_busreset(void *arg, int pend { struct fwohci_softc *sc = (struct fwohci_softc *)arg; + FW_GLOCK(&sc->fc); fw_busreset(&sc->fc, FWBUSRESET); OWRITE(sc, OHCI_CROMHDR, ntohl(sc->fc.config_rom[0])); OWRITE(sc, OHCI_BUS_OPT, ntohl(sc->fc.config_rom[2])); + FW_GUNLOCK(&sc->fc); } static void @@ -2010,6 +2013,10 @@ fwohci_task_sid(void *arg, int pending) int i, plen; + /* + * We really should have locking + * here. Not sure why it's not + */ plen = OREAD(sc, OHCI_SID_CNT); if (plen & OHCI_SID_ERR) { @@ -2029,14 +2036,13 @@ fwohci_task_sid(void *arg, int pending) } for (i = 0; i < plen / 4; i ++) buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i+1]); -#if 1 /* XXX needed?? */ + /* pending all pre-bus_reset packets */ fwohci_txd(sc, &sc->atrq); fwohci_txd(sc, &sc->atrs); fwohci_arcv(sc, &sc->arrs, -1); fwohci_arcv(sc, &sc->arrq, -1); fw_drain_txq(fc); -#endif fw_sidrcv(fc, buf, plen); free(buf, M_FW); } @@ -2061,6 +2067,7 @@ fwohci_check_stat(struct fwohci_softc *s { uint32_t stat, irstat, itstat; + FW_GLOCK_ASSERT(&sc->fc); stat = OREAD(sc, FWOHCI_INTSTAT); if (stat == 0xffffffff) { device_printf(sc->fc.dev, @@ -2090,29 +2097,24 @@ fwohci_check_stat(struct fwohci_softc *s return (FILTER_HANDLED); } -int -fwohci_filt(void *arg) -{ - struct fwohci_softc *sc = (struct fwohci_softc *)arg; - - if (!(sc->intmask & OHCI_INT_EN)) { - /* polling mode */ - return (FILTER_STRAY); - } - return (fwohci_check_stat(sc)); -} - void fwohci_intr(void *arg) { - fwohci_filt(arg); + struct fwohci_softc *sc = (struct fwohci_softc *)arg; + + FW_GLOCK(&sc->fc); + fwohci_check_stat(sc); + FW_GUNLOCK(&sc->fc); } void fwohci_poll(struct firewire_comm *fc, int quick, int count) { struct fwohci_softc *sc = (struct fwohci_softc *)fc; + + FW_GLOCK(fc); fwohci_check_stat(sc); + FW_GUNLOCK(fc); } static void @@ -2466,6 +2468,7 @@ fwohci_ibr(struct firewire_comm *fc) device_printf(fc->dev, "Initiate bus reset\n"); sc = (struct fwohci_softc *)fc; + FW_GLOCK(fc); /* * Make sure our cached values from the config rom are * initialised. @@ -2486,6 +2489,7 @@ fwohci_ibr(struct firewire_comm *fc) fun |= FW_PHY_ISBR | FW_PHY_RHB; fun = fwphy_wrdata(sc, FW_PHY_ISBR_REG, fun); #endif + FW_GUNLOCK(fc); } void Modified: head/sys/dev/firewire/fwohci_pci.c ============================================================================== --- head/sys/dev/firewire/fwohci_pci.c Sun Feb 1 23:27:21 2009 (r187992) +++ head/sys/dev/firewire/fwohci_pci.c Sun Feb 1 23:28:52 2009 (r187993) @@ -334,14 +334,11 @@ fwohci_pci_attach(device_t self) return ENXIO; } - err = bus_setup_intr(self, sc->irq_res, - INTR_TYPE_NET | INTR_MPSAFE, -#if FWOHCI_INTFILT - fwohci_filt, NULL, sc, &sc->ih); -#else - NULL, (driver_intr_t *) fwohci_intr, sc, &sc->ih); -#endif + INTR_TYPE_NET | INTR_MPSAFE, + NULL, (driver_intr_t *) fwohci_intr, + sc, &sc->ih); + #if defined(__DragonFly__) || __FreeBSD_version < 500000 /* XXX splcam() should mask this irq for sbp.c*/ err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_CAM, Modified: head/sys/dev/firewire/fwohcivar.h ============================================================================== --- head/sys/dev/firewire/fwohcivar.h Sun Feb 1 23:27:21 2009 (r187992) +++ head/sys/dev/firewire/fwohcivar.h Sun Feb 1 23:28:52 2009 (r187993) @@ -37,12 +37,6 @@ #include -#if defined(__DragonFly__) || __FreeBSD_version < 700043 -#define FWOHCI_INTFILT 0 -#else -#define FWOHCI_INTFILT 1 -#endif - typedef struct fwohci_softc { struct firewire_comm fc; bus_space_tag_t bst; @@ -84,7 +78,7 @@ typedef struct fwohci_softc { } fwohci_softc_t; void fwohci_intr (void *arg); -int fwohci_filt (void *arg); +void fwohci_filt (void *arg); int fwohci_init (struct fwohci_softc *, device_t); void fwohci_poll (struct firewire_comm *, int, int); void fwohci_reset (struct fwohci_softc *, device_t); Modified: head/sys/dev/firewire/sbp.c ============================================================================== --- head/sys/dev/firewire/sbp.c Sun Feb 1 23:27:21 2009 (r187992) +++ head/sys/dev/firewire/sbp.c Sun Feb 1 23:28:52 2009 (r187993) @@ -493,6 +493,7 @@ END_DEBUG /* lost device */ sbp_cam_detach_sdev(sdev); sbp_free_sdev(sdev); + target->luns[lun] = NULL; } } @@ -781,7 +782,9 @@ END_DEBUG SBP_UNLOCK(sbp); } sdev->status = SBP_DEV_RETRY; - sbp_abort_all_ocbs(sdev, CAM_SCSI_BUS_RESET); + sbp_cam_detach_sdev(sdev); + sbp_free_sdev(sdev); + target->luns[i] = NULL; break; case SBP_DEV_PROBE: case SBP_DEV_TOATTACH: @@ -1255,11 +1258,18 @@ END_DEBUG htonl(((sdev->target->sbp->fd.fc->nodeid | FWLOCALBUS )<< 16)); xfer->send.payload[1] = htonl((uint32_t)ocb->bus_addr); + /* + * sbp_xfer_free() will attempt to acquire + * the SBP lock on entrance. Also, this removes + * a LOR between the firewire layer and sbp + */ + SBP_UNLOCK(sdev->target->sbp); if(fw_asyreq(xfer->fc, -1, xfer) != 0){ sbp_xfer_free(xfer); ocb->ccb->ccb_h.status = CAM_REQ_INVALID; xpt_done(ocb->ccb); } + SBP_LOCK(sdev->target->sbp); } static void @@ -2123,6 +2133,7 @@ sbp_free_sdev(struct sbp_dev *sdev) sdev->ocb[i].dmamap); fwdma_free(sdev->target->sbp->fd.fc, &sdev->dma); free(sdev, M_SBP); + sdev = NULL; } static void From alfred at FreeBSD.org Sun Feb 1 16:49:40 2009 From: alfred at FreeBSD.org (Alfred Perlstein) Date: Sun Feb 1 16:49:53 2009 Subject: svn commit: r187994 - in head: lib/libusbhid sys/dev/usb2/bluetooth sys/dev/usb2/core sys/dev/usb2/include sys/dev/usb2/input sys/dev/usb2/serial usr.bin/usbhidaction usr.bin/usbhidctl Message-ID: <200902020049.n120ndkc070738@svn.freebsd.org> Author: alfred Date: Mon Feb 2 00:49:39 2009 New Revision: 187994 URL: http://svn.freebsd.org/changeset/base/187994 Log: src/usr.bin/usbhidaction/usbhidaction.c src/usr.bin/usbhidctl/usbhid.c src/sys/dev/usb2/include/usb2_hid.h src/sys/dev/usb2/input/uhid2.c src/lib/libusbhid/Makefile src/lib/libusbhid/descr.c src/lib/libusbhid/descr_compat.c src/lib/libusbhid/usbhid.3 src/lib/libusbhid/usbhid.h src/lib/libusbhid/usbvar.h Patches to make libusbhid and HID userland utilities compatible with the new USB stack. All HID ioctls should go through the libusbhid library to ensure compatibility. I have found at least one piece of software in /usr/ports which needs to get updated before USB HID devices will work. This is the X joystick input driver. Reported and tested by: Daichi GOTO and Masanori OZAWA. src/sys/dev/usb2/core/usb2_process.c Correct USB process names. Reported by: Andre Guibert de Bruet src/sys/dev/usb2/serial/uftdi2.c Integrate changes from old USB stack. Submitted by: hps Added: head/lib/libusbhid/descr_compat.c (contents, props changed) Modified: head/lib/libusbhid/Makefile head/lib/libusbhid/descr.c head/lib/libusbhid/usbhid.3 head/lib/libusbhid/usbhid.h head/lib/libusbhid/usbvar.h head/sys/dev/usb2/bluetooth/ubtbcmfw2.c head/sys/dev/usb2/core/usb2_process.c head/sys/dev/usb2/include/usb2_hid.h head/sys/dev/usb2/input/uhid2.c head/sys/dev/usb2/serial/uftdi2.c head/usr.bin/usbhidaction/usbhidaction.c head/usr.bin/usbhidctl/usbhid.c Modified: head/lib/libusbhid/Makefile ============================================================================== --- head/lib/libusbhid/Makefile Sun Feb 1 23:28:52 2009 (r187993) +++ head/lib/libusbhid/Makefile Mon Feb 2 00:49:39 2009 (r187994) @@ -15,7 +15,7 @@ MLINKS= usbhid.3 libusbhid.3 usbhid.3 hi usbhid.3 hid_init.3 \ usbhid.3 hid_get_data.3 usbhid.3 hid_set_data.3 -SRCS= descr.c parse.c usage.c data.c +SRCS= descr.c descr_compat.c parse.c usage.c data.c INCS= usbhid.h Modified: head/lib/libusbhid/descr.c ============================================================================== --- head/lib/libusbhid/descr.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/lib/libusbhid/descr.c Mon Feb 2 00:49:39 2009 (r187994) @@ -39,21 +39,83 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "usbhid.h" #include "usbvar.h" +int +hid_set_immed(int fd, int enable) +{ + int ret; + ret = ioctl(fd, USB_SET_IMMED, &enable); + if (ret < 0) + ret = hid_set_immed_compat7(fd, enable); + return (ret); +} + +int +hid_get_report_id(int fd) +{ + int temp = -1; + int ret; + + ret = ioctl(fd, USB_GET_REPORT_ID, &temp); + if (ret < 0) + ret = hid_get_report_id_compat7(fd); + else + ret = temp; + + return (ret); +} + report_desc_t hid_get_report_desc(int fd) { - struct usb_ctl_report_desc rep; + struct usb2_gen_descriptor ugd; + report_desc_t rep; + void *data; + + memset(&ugd, 0, sizeof(ugd)); + + /* get actual length first */ + ugd.ugd_data = NULL; + ugd.ugd_maxlen = 65535; + if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { + /* could not read descriptor */ + /* try FreeBSD 7 compat code */ + return (hid_get_report_desc_compat7(fd)); + } - rep.ucrd_size = 0; - if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) + /* + * NOTE: The kernel will return a failure if + * "ugd_actlen" is zero. + */ + data = malloc(ugd.ugd_actlen); + if (data == NULL) return (NULL); - return hid_use_report_desc(rep.ucrd_data, (unsigned int)rep.ucrd_size); + /* fetch actual descriptor */ + ugd.ugd_data = data; + ugd.ugd_maxlen = ugd.ugd_actlen; + if (ioctl(fd, USB_GET_REPORT_DESC, &ugd) < 0) { + /* could not read descriptor */ + free(data); + return (NULL); + } + + /* check END_COLLECTION */ + if (((unsigned char *)ugd.ugd_data)[ugd.ugd_actlen -1] != 0xC0) { + /* invalid end byte */ + free(data); + return (NULL); + } + + rep = hid_use_report_desc(data, ugd.ugd_actlen); + + free(data); + + return (rep); } report_desc_t Added: head/lib/libusbhid/descr_compat.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libusbhid/descr_compat.c Mon Feb 2 00:49:39 2009 (r187994) @@ -0,0 +1,77 @@ +/* + * Copyright (c) 1999 Lennart Augustsson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * This file contains fallback-compatibility code for the old FreeBSD + * USB stack. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "usbhid.h" +#include "usbvar.h" + +int +hid_set_immed_compat7(int fd, int enable) +{ + return (ioctl(fd, USB_SET_IMMED, &enable)); +} + +int +hid_get_report_id_compat7(int fd) +{ + int temp = -1; + + if (ioctl(fd, USB_GET_REPORT_ID, &temp) < 0) + return (-1); + + return (temp); +} + +report_desc_t +hid_get_report_desc_compat7(int fd) +{ + struct usb_ctl_report_desc rep; + + rep.ucrd_size = 0; + if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0) + return (NULL); + + return (hid_use_report_desc(rep.ucrd_data, (unsigned int)rep.ucrd_size)); +} Modified: head/lib/libusbhid/usbhid.3 ============================================================================== --- head/lib/libusbhid/usbhid.3 Sun Feb 1 23:28:52 2009 (r187993) +++ head/lib/libusbhid/usbhid.3 Mon Feb 2 00:49:39 2009 (r187994) @@ -26,12 +26,13 @@ .\" .\" $FreeBSD$ .\" -.Dd December 29, 2001 +.Dd January 27, 2009 .Dt USBHID 3 .Os .Sh NAME .Nm usbhid , .Nm hid_get_report_desc , +.Nm hid_get_report_id , .Nm hid_use_report_desc , .Nm hid_dispose_report_desc , .Nm hid_start_parse , @@ -51,6 +52,10 @@ .In usbhid.h .Ft report_desc_t .Fn hid_get_report_desc "int file" +.Ft int +.Fn hid_get_report_id "int file" +.Ft int +.Fn hid_set_immed "int fd" "int enable" .Ft report_desc_t .Fn hid_use_report_desc "unsigned char *data" "unsigned int size" .Ft void @@ -94,7 +99,15 @@ which contains the data layout informati The routines can be divided into four parts: extraction of the descriptor, parsing of the descriptor, translating to/from symbolic names, and data manipulation. +.Ss Synchronous HID operation +Synchronous HID operation can be enabled or disabled by a call to +.Fn hid_set_immed . +If the second argument is zero synchronous HID operation is disabled. +Else synchronous HID operation is enabled. +The function returns a negative value on failure. .Ss Descriptor Functions +The report descriptor ID can be obtained by calling +.Fn hid_get_report_id . A report descriptor can be obtained by calling .Fn hid_get_report_desc with a file descriptor obtained by opening a Modified: head/lib/libusbhid/usbhid.h ============================================================================== --- head/lib/libusbhid/usbhid.h Sun Feb 1 23:28:52 2009 (r187993) +++ head/lib/libusbhid/usbhid.h Mon Feb 2 00:49:39 2009 (r187994) @@ -87,6 +87,8 @@ __BEGIN_DECLS report_desc_t hid_get_report_desc(int file); report_desc_t hid_use_report_desc(unsigned char *data, unsigned int size); void hid_dispose_report_desc(report_desc_t); +int hid_get_report_id(int file); +int hid_set_immed(int fd, int enable); /* Parsing of a HID report descriptor, parse.c: */ hid_data_t hid_start_parse(report_desc_t d, int kindset, int id); Modified: head/lib/libusbhid/usbvar.h ============================================================================== --- head/lib/libusbhid/usbvar.h Sun Feb 1 23:28:52 2009 (r187993) +++ head/lib/libusbhid/usbvar.h Mon Feb 2 00:49:39 2009 (r187994) @@ -34,3 +34,8 @@ struct report_desc { unsigned char data[1]; }; +/* internal backwards compatibility functions */ + +int hid_set_immed_compat7(int fd, int enable); +int hid_get_report_id_compat7(int fd); +report_desc_t hid_get_report_desc_compat7(int fd); Modified: head/sys/dev/usb2/bluetooth/ubtbcmfw2.c ============================================================================== --- head/sys/dev/usb2/bluetooth/ubtbcmfw2.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/sys/dev/usb2/bluetooth/ubtbcmfw2.c Mon Feb 2 00:49:39 2009 (r187994) @@ -385,8 +385,8 @@ ubtbcmfw_open(struct usb2_fifo *fifo, in else if (fflags & FWRITE) xfer = sc->sc_xfer[UBTBCMFW_BULK_DT_WR]; else - return (EINVAL); /* XXX can happen? */ - + return (EINVAL); /* should not happen */ + if (usb2_fifo_alloc_buffer(fifo, xfer->max_data_length, UBTBCMFW_IFQ_MAXLEN) != 0) return (ENOMEM); Modified: head/sys/dev/usb2/core/usb2_process.c ============================================================================== --- head/sys/dev/usb2/core/usb2_process.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/sys/dev/usb2/core/usb2_process.c Mon Feb 2 00:49:39 2009 (r187994) @@ -184,11 +184,11 @@ usb2_proc_setup(struct usb2_process *up, TAILQ_INIT(&up->up_qhead); - usb2_cv_init(&up->up_cv, "WMSG"); - usb2_cv_init(&up->up_drain, "DMSG"); + usb2_cv_init(&up->up_cv, "wmsg"); + usb2_cv_init(&up->up_drain, "dmsg"); if (USB_THREAD_CREATE(&usb2_process, up, - &up->up_ptr, "USBPROC")) { + &up->up_ptr, "usbproc")) { DPRINTFN(0, "Unable to create USB process."); up->up_ptr = NULL; goto error; Modified: head/sys/dev/usb2/include/usb2_hid.h ============================================================================== --- head/sys/dev/usb2/include/usb2_hid.h Sun Feb 1 23:28:52 2009 (r187993) +++ head/sys/dev/usb2/include/usb2_hid.h Mon Feb 2 00:49:39 2009 (r187994) @@ -29,6 +29,8 @@ #ifndef _USB2_HID_H_ #define _USB2_HID_H_ +#include + #define UR_GET_HID_DESCRIPTOR 0x06 #define UDESC_HID 0x21 #define UDESC_REPORT 0x22 Modified: head/sys/dev/usb2/input/uhid2.c ============================================================================== --- head/sys/dev/usb2/input/uhid2.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/sys/dev/usb2/input/uhid2.c Mon Feb 2 00:49:39 2009 (r187994) @@ -87,10 +87,9 @@ SYSCTL_INT(_hw_usb2_uhid, OID_AUTO, debu enum { UHID_INTR_DT_RD, - UHID_INTR_CS_RD, UHID_CTRL_DT_WR, UHID_CTRL_DT_RD, - UHID_N_TRANSFER = 4, + UHID_N_TRANSFER, }; struct uhid_softc { @@ -114,7 +113,6 @@ struct uhid_softc { uint8_t sc_fid; uint8_t sc_flags; #define UHID_FLAG_IMMED 0x01 /* set if read should be immediate */ -#define UHID_FLAG_INTR_STALL 0x02 /* set if interrupt transfer stalled */ #define UHID_FLAG_STATIC_DESC 0x04 /* set if report descriptors are * static */ }; @@ -130,7 +128,6 @@ static device_attach_t uhid_attach; static device_detach_t uhid_detach; static usb2_callback_t uhid_intr_callback; -static usb2_callback_t uhid_intr_clear_stall_callback; static usb2_callback_t uhid_write_callback; static usb2_callback_t uhid_read_callback; @@ -174,41 +171,25 @@ uhid_intr_callback(struct usb2_xfer *xfe } case USB_ST_SETUP: - if (sc->sc_flags & UHID_FLAG_INTR_STALL) { - usb2_transfer_start(sc->sc_xfer[UHID_INTR_CS_RD]); - } else { - if (usb2_fifo_put_bytes_max( - sc->sc_fifo.fp[USB_FIFO_RX]) != 0) { - xfer->frlengths[0] = xfer->max_data_length; - usb2_start_hardware(xfer); - } +re_submit: + if (usb2_fifo_put_bytes_max( + sc->sc_fifo.fp[USB_FIFO_RX]) != 0) { + xfer->frlengths[0] = sc->sc_isize; + usb2_start_hardware(xfer); } return; default: /* Error */ if (xfer->error != USB_ERR_CANCELLED) { /* try to clear stall first */ - sc->sc_flags |= UHID_FLAG_INTR_STALL; - usb2_transfer_start(sc->sc_xfer[UHID_INTR_CS_RD]); + xfer->flags.stall_pipe = 1; + goto re_submit; } return; } } static void -uhid_intr_clear_stall_callback(struct usb2_xfer *xfer) -{ - struct uhid_softc *sc = xfer->priv_sc; - struct usb2_xfer *xfer_other = sc->sc_xfer[UHID_INTR_DT_RD]; - - if (usb2_clear_stall_callback(xfer, xfer_other)) { - DPRINTF("stall cleared\n"); - sc->sc_flags &= ~UHID_FLAG_INTR_STALL; - usb2_transfer_start(xfer_other); - } -} - -static void uhid_fill_set_report(struct usb2_device_request *req, uint8_t iface_no, uint8_t type, uint8_t id, uint16_t size) { @@ -337,20 +318,10 @@ static const struct usb2_config uhid_con .endpoint = UE_ADDR_ANY, .direction = UE_DIR_IN, .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, - .mh.bufsize = 0, /* use wMaxPacketSize */ + .mh.bufsize = UHID_BSIZE, .mh.callback = &uhid_intr_callback, }, - [UHID_INTR_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.callback = &uhid_intr_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - [UHID_CTRL_DT_WR] = { .type = UE_CONTROL, .endpoint = 0x00, /* Control pipe */ @@ -530,6 +501,8 @@ uhid_ioctl(struct usb2_fifo *fifo, u_lon size = sc->sc_repdesc_size; } ugd->ugd_actlen = size; + if (ugd->ugd_data == NULL) + break; /* descriptor length only */ error = copyout(sc->sc_repdesc_ptr, ugd->ugd_data, size); break; Modified: head/sys/dev/usb2/serial/uftdi2.c ============================================================================== --- head/sys/dev/usb2/serial/uftdi2.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/sys/dev/usb2/serial/uftdi2.c Mon Feb 2 00:49:39 2009 (r187994) @@ -233,6 +233,7 @@ MODULE_DEPEND(uftdi, usb2_serial, 1, 1, MODULE_DEPEND(uftdi, usb2_core, 1, 1, 1); static struct usb2_device_id uftdi_devs[] = { + {USB_VPI(USB_VENDOR_DRESDENELEKTRONIK, USB_PRODUCT_DRESDENELEKTRONIK_SENSORTERMINALBOARD, UFTDI_TYPE_8U232AM)}, {USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_SERIAL_8U100AX, UFTDI_TYPE_SIO)}, {USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_SERIAL_2232C, UFTDI_TYPE_8U232AM)}, {USB_VPI(USB_VENDOR_FTDI, USB_PRODUCT_FTDI_SERIAL_8U232AM, UFTDI_TYPE_8U232AM)}, Modified: head/usr.bin/usbhidaction/usbhidaction.c ============================================================================== --- head/usr.bin/usbhidaction/usbhidaction.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/usr.bin/usbhidaction/usbhidaction.c Mon Feb 2 00:49:39 2009 (r187994) @@ -46,9 +46,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include @@ -155,8 +153,7 @@ main(int argc, char **argv) fd = open(dev, O_RDWR); if (fd < 0) err(1, "%s", dev); - if (ioctl(fd, USB_GET_REPORT_ID, &reportid) < 0) - reportid = -1; + reportid = hid_get_report_id(fd); repd = hid_get_report_desc(fd); if (repd == NULL) err(1, "hid_get_report_desc() failed"); Modified: head/usr.bin/usbhidctl/usbhid.c ============================================================================== --- head/usr.bin/usbhidctl/usbhid.c Sun Feb 1 23:28:52 2009 (r187993) +++ head/usr.bin/usbhidctl/usbhid.c Mon Feb 2 00:49:39 2009 (r187994) @@ -42,14 +42,12 @@ #include #include #include -#include #include #include #include #include #include -#include -#include +#include int verbose = 0; int all = 0; @@ -207,7 +205,6 @@ dumpdata(int f, report_desc_t rd, int lo struct hid_item h, *hids, *n; int r, dlen; u_char *dbuf; - static int one = 1; u_int32_t colls[100]; int sp = 0; char namebuf[10000], *namep; @@ -231,7 +228,7 @@ dumpdata(int f, report_desc_t rd, int lo dlen = hid_report_size(rd, hid_input, 0); dbuf = malloc(dlen); if (!loop) - if (ioctl(f, USB_SET_IMMED, &one) < 0) { + if (hid_set_immed(f, 1) < 0) { if (errno == EOPNOTSUPP) warnx("device does not support immediate mode, only changes reported."); else From imp at FreeBSD.org Sun Feb 1 18:05:59 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sun Feb 1 18:06:06 2009 Subject: svn commit: r187995 - head/usr.bin/make Message-ID: <200902020205.n1225w8V077982@svn.freebsd.org> Author: imp Date: Mon Feb 2 02:05:58 2009 New Revision: 187995 URL: http://svn.freebsd.org/changeset/base/187995 Log: Sort the options, per style(9). Reviewed by: obrien@ Modified: head/usr.bin/make/main.c Modified: head/usr.bin/make/main.c ============================================================================== --- head/usr.bin/make/main.c Mon Feb 2 00:49:39 2009 (r187994) +++ head/usr.bin/make/main.c Mon Feb 2 02:05:58 2009 (r187995) @@ -372,6 +372,7 @@ rearg: optind = 1; /* since we're called more than once */ optreset = 1; #define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nQpqrstvx:" +#define OPTFLAGS "ABC:D:d:E:ef:I:ij:km:nPpQqrSstV:vXx:" for (;;) { if ((optind < argc) && strcmp(argv[optind], "--") == 0) { found_dd = TRUE; @@ -385,6 +386,11 @@ rearg: arch_fatal = FALSE; MFLAGS_append("-A", NULL); break; + case 'B': + compatMake = TRUE; + MFLAGS_append("-B", NULL); + unsetenv("MAKE_JOBS_FIFO"); + break; case 'C': if (chdir(optarg) == -1) err(1, "chdir %s", optarg); @@ -393,30 +399,6 @@ rearg: Var_SetGlobal(optarg, "1"); MFLAGS_append("-D", optarg); break; - case 'I': - Parse_AddIncludeDir(optarg); - MFLAGS_append("-I", optarg); - break; - case 'V': - Lst_AtEnd(&variables, estrdup(optarg)); - MFLAGS_append("-V", optarg); - break; - case 'X': - expandVars = FALSE; - break; - case 'B': - compatMake = TRUE; - MFLAGS_append("-B", NULL); - unsetenv("MAKE_JOBS_FIFO"); - break; - case 'P': - usePipes = FALSE; - MFLAGS_append("-P", NULL); - break; - case 'S': - keepgoing = FALSE; - MFLAGS_append("-S", NULL); - break; case 'd': { char *modules = optarg; @@ -484,6 +466,10 @@ rearg: case 'f': Lst_AtEnd(&makefiles, estrdup(optarg)); break; + case 'I': + Parse_AddIncludeDir(optarg); + MFLAGS_append("-I", optarg); + break; case 'i': ignoreErrors = TRUE; MFLAGS_append("-i", NULL); @@ -513,6 +499,10 @@ rearg: noExecute = TRUE; MFLAGS_append("-n", NULL); break; + case 'P': + usePipes = FALSE; + MFLAGS_append("-P", NULL); + break; case 'p': printGraphOnly = TRUE; debug |= DEBUG_GRAPH1; @@ -531,6 +521,10 @@ rearg: noBuiltins = TRUE; MFLAGS_append("-r", NULL); break; + case 'S': + keepgoing = FALSE; + MFLAGS_append("-S", NULL); + break; case 's': beSilent = TRUE; MFLAGS_append("-s", NULL); @@ -539,11 +533,18 @@ rearg: touchFlag = TRUE; MFLAGS_append("-t", NULL); break; + case 'V': + Lst_AtEnd(&variables, estrdup(optarg)); + MFLAGS_append("-V", optarg); + break; case 'v': beVerbose = TRUE; beQuiet = FALSE; MFLAGS_append("-v", NULL); break; + case 'X': + expandVars = FALSE; + break; case 'x': if (Main_ParseWarn(optarg, 1) != -1) MFLAGS_append("-x", optarg); From sepotvin at FreeBSD.org Sun Feb 1 19:34:41 2009 From: sepotvin at FreeBSD.org (Stephane E. Potvin) Date: Sun Feb 1 19:34:47 2009 Subject: svn commit: r187996 - head/sys/kern Message-ID: <200902020334.n123YeMW079868@svn.freebsd.org> Author: sepotvin Date: Mon Feb 2 03:34:40 2009 New Revision: 187996 URL: http://svn.freebsd.org/changeset/base/187996 Log: Fix select on platforms where sizeof(long) != sizeof(int). This used to work by accident before the cleanup done in revision 187693. Approved by: kan (mentor) Modified: head/sys/kern/sys_generic.c Modified: head/sys/kern/sys_generic.c ============================================================================== --- head/sys/kern/sys_generic.c Mon Feb 2 02:05:58 2009 (r187995) +++ head/sys/kern/sys_generic.c Mon Feb 2 03:34:40 2009 (r187996) @@ -903,7 +903,7 @@ static int select_flags[3] = { * bit position in the fd_mask array. */ static __inline int -selflags(fd_mask **ibits, int idx, int bit) +selflags(fd_mask **ibits, int idx, fd_mask bit) { int flags; int msk; @@ -912,7 +912,7 @@ selflags(fd_mask **ibits, int idx, int b for (msk = 0; msk < 3; msk++) { if (ibits[msk] == NULL) continue; - if ((ibits[msk][idx] & (fd_mask)bit) == 0) + if ((ibits[msk][idx] & bit) == 0) continue; flags |= select_flags[msk]; } From fjoe at FreeBSD.org Sun Feb 1 22:25:58 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Sun Feb 1 22:26:05 2009 Subject: svn commit: r188001 - head/usr.bin/make Message-ID: <200902020625.n126Pvt6083157@svn.freebsd.org> Author: fjoe Date: Mon Feb 2 06:25:57 2009 New Revision: 188001 URL: http://svn.freebsd.org/changeset/base/188001 Log: Remove duplicate OPTFLAGS definition. Modified: head/usr.bin/make/main.c Modified: head/usr.bin/make/main.c ============================================================================== --- head/usr.bin/make/main.c Mon Feb 2 04:59:00 2009 (r188000) +++ head/usr.bin/make/main.c Mon Feb 2 06:25:57 2009 (r188001) @@ -371,7 +371,6 @@ MainParseArgs(int argc, char **argv) rearg: optind = 1; /* since we're called more than once */ optreset = 1; -#define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nQpqrstvx:" #define OPTFLAGS "ABC:D:d:E:ef:I:ij:km:nPpQqrSstV:vXx:" for (;;) { if ((optind < argc) && strcmp(argv[optind], "--") == 0) { From imp at bsdimp.com Mon Feb 2 00:38:57 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Mon Feb 2 00:39:02 2009 Subject: svn commit: r188001 - head/usr.bin/make In-Reply-To: <200902020625.n126Pvt6083157@svn.freebsd.org> References: <200902020625.n126Pvt6083157@svn.freebsd.org> Message-ID: <20090202.013713.2007156486.imp@bsdimp.com> In message: <200902020625.n126Pvt6083157@svn.freebsd.org> Max Khon writes: : Author: fjoe : Date: Mon Feb 2 06:25:57 2009 : New Revision: 188001 : URL: http://svn.freebsd.org/changeset/base/188001 : : Log: : Remove duplicate OPTFLAGS definition. Pointy hat to: imp@ Thanks Max. Warner : Modified: : head/usr.bin/make/main.c : : Modified: head/usr.bin/make/main.c : ============================================================================== : --- head/usr.bin/make/main.c Mon Feb 2 04:59:00 2009 (r188000) : +++ head/usr.bin/make/main.c Mon Feb 2 06:25:57 2009 (r188001) : @@ -371,7 +371,6 @@ MainParseArgs(int argc, char **argv) : rearg: : optind = 1; /* since we're called more than once */ : optreset = 1; : -#define OPTFLAGS "ABC:D:E:I:PSV:Xd:ef:ij:km:nQpqrstvx:" : #define OPTFLAGS "ABC:D:d:E:ef:I:ij:km:nPpQqrSstV:vXx:" : for (;;) { : if ((optind < argc) && strcmp(argv[optind], "--") == 0) { : From luigi at FreeBSD.org Mon Feb 2 02:58:06 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Mon Feb 2 02:58:18 2009 Subject: svn commit: r188004 - head/sbin/ipfw Message-ID: <200902021058.n12Aw5i0095288@svn.freebsd.org> Author: luigi Date: Mon Feb 2 10:58:05 2009 New Revision: 188004 URL: http://svn.freebsd.org/changeset/base/188004 Log: remove duplicate #include Modified: head/sbin/ipfw/dummynet.c Modified: head/sbin/ipfw/dummynet.c ============================================================================== --- head/sbin/ipfw/dummynet.c Mon Feb 2 08:31:16 2009 (r188003) +++ head/sbin/ipfw/dummynet.c Mon Feb 2 10:58:05 2009 (r188004) @@ -39,7 +39,6 @@ #include #include -#include #include #include #include From luigi at FreeBSD.org Mon Feb 2 03:02:20 2009 From: luigi at FreeBSD.org (Luigi Rizzo) Date: Mon Feb 2 03:02:32 2009 Subject: svn commit: r188005 - head/sbin/ipfw Message-ID: <200902021102.n12B2KVd095425@svn.freebsd.org> Author: luigi Date: Mon Feb 2 11:02:19 2009 New Revision: 188005 URL: http://svn.freebsd.org/changeset/base/188005 Log: Explain that we assume AF_INET and only use the addr and port field from a struct sockaddr_in, so there is no need to initialize sin_len Modified: head/sbin/ipfw/ipfw2.c Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Mon Feb 2 10:58:05 2009 (r188004) +++ head/sbin/ipfw/ipfw2.c Mon Feb 2 11:02:19 2009 (r188005) @@ -2733,7 +2733,10 @@ chkarg: action->opcode = O_FORWARD_IP; action->len = F_INSN_SIZE(ipfw_insn_sa); - p->sa.sin_len = sizeof(struct sockaddr_in); + /* + * In the kernel we assume AF_INET and use only + * sin_port and sin_addr. + */ p->sa.sin_family = AF_INET; p->sa.sin_port = 0; /* From rwatson at FreeBSD.org Mon Feb 2 03:20:15 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Feb 2 03:20:22 2009 Subject: svn commit: r188006 - in head/usr.bin: basename dirname Message-ID: <200902021119.n12BJva6095787@svn.freebsd.org> Author: rwatson Date: Mon Feb 2 11:19:56 2009 New Revision: 188006 URL: http://svn.freebsd.org/changeset/base/188006 Log: Alow dirname(1) to accept multiple arguments in the same way that basename(1) does. (Two different PRs contained identical patches, both cited below) PR: 121520, 86148 Submitted by: Ighighi Submitted by: Leif Neland MFC after: 3 days Modified: head/usr.bin/basename/basename.1 head/usr.bin/dirname/dirname.c Modified: head/usr.bin/basename/basename.1 ============================================================================== --- head/usr.bin/basename/basename.1 Mon Feb 2 11:02:19 2009 (r188005) +++ head/usr.bin/basename/basename.1 Mon Feb 2 11:19:56 2009 (r188006) @@ -52,6 +52,7 @@ .Op Ar ... .Nm dirname .Ar string +.Op Ar ... .Sh DESCRIPTION The .Nm Modified: head/usr.bin/dirname/dirname.c ============================================================================== --- head/usr.bin/dirname/dirname.c Mon Feb 2 11:02:19 2009 (r188005) +++ head/usr.bin/dirname/dirname.c Mon Feb 2 11:19:56 2009 (r188006) @@ -66,12 +66,15 @@ main(int argc, char **argv) argc -= optind; argv += optind; - if (argc != 1) + if (argc < 1) usage(); - if ((p = dirname(*argv)) == NULL) - err(1, "%s", *argv); - (void)printf("%s\n", p); + while (argc--) { + if ((p = dirname(*argv)) == NULL) + err(1, "%s", *argv); + argv++; + (void)printf("%s\n", p); + } exit(0); } @@ -79,6 +82,6 @@ void usage(void) { - (void)fprintf(stderr, "usage: dirname string\n"); + (void)fprintf(stderr, "usage: dirname string [...]\n"); exit(1); } From ed at 80386.nl Mon Feb 2 03:31:44 2009 From: ed at 80386.nl (Ed Schouten) Date: Mon Feb 2 03:31:51 2009 Subject: svn commit: r188006 - in head/usr.bin: basename dirname In-Reply-To: <200902021119.n12BJva6095787@svn.freebsd.org> References: <200902021119.n12BJva6095787@svn.freebsd.org> Message-ID: <20090202113141.GH1230@hoeg.nl> Hi Robert, * Robert Watson wrote: > - (void)fprintf(stderr, "usage: dirname string\n"); > + (void)fprintf(stderr, "usage: dirname string [...]\n"); Maybe we shouldn't use brackets here, like rm(1): usage: rm [-f | -i] [-dIPRrvW] file ... -- Ed Schouten WWW: http://80386.nl/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090202/7227a859/attachment.pgp From christoph.mallon at gmx.de Mon Feb 2 03:43:00 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Mon Feb 2 03:43:07 2009 Subject: svn commit: r188006 - in head/usr.bin: basename dirname In-Reply-To: <20090202113141.GH1230@hoeg.nl> References: <200902021119.n12BJva6095787@svn.freebsd.org> <20090202113141.GH1230@hoeg.nl> Message-ID: <4986DC3D.5020708@gmx.de> Ed Schouten schrieb: > Hi Robert, > > * Robert Watson wrote: >> - (void)fprintf(stderr, "usage: dirname string\n"); >> + (void)fprintf(stderr, "usage: dirname string [...]\n"); > > Maybe we shouldn't use brackets here, like rm(1): > > usage: rm [-f | -i] [-dIPRrvW] file ... Also there are no [] around the ... in the manpages of rm, chmod, cp, chown, ... From gabor at FreeBSD.org Mon Feb 2 03:57:56 2009 From: gabor at FreeBSD.org (=?ISO-8859-1?Q?G=E1bor_K=F6vesd=E1n?=) Date: Mon Feb 2 03:58:32 2009 Subject: svn commit: r188006 - in head/usr.bin: basename dirname In-Reply-To: <20090202113141.GH1230@hoeg.nl> References: <200902021119.n12BJva6095787@svn.freebsd.org> <20090202113141.GH1230@hoeg.nl> Message-ID: <4986DBCA.5000501@FreeBSD.org> Ed Schouten escribi?: > Hi Robert, > > * Robert Watson wrote: > >> - (void)fprintf(stderr, "usage: dirname string\n"); >> + (void)fprintf(stderr, "usage: dirname string [...]\n"); >> > > Maybe we shouldn't use brackets here, like rm(1): > > usage: rm [-f | -i] [-dIPRrvW] file ... > I'd prefer if we used brackets with rm(1), as well. Even if these syntax descriptions aren't BNFs, the brackets are usually used to denote optionality. -- Gabor Kovesdan EMAIL: gabor@FreeBSD.org WWW: http://www.kovesdan.org From phk at FreeBSD.org Mon Feb 2 06:29:18 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon Feb 2 06:29:31 2009 Subject: svn commit: r188007 - head/usr.sbin/fifolog/lib Message-ID: <200902021429.n12ETFQk099110@svn.freebsd.org> Author: phk Date: Mon Feb 2 14:29:15 2009 New Revision: 188007 URL: http://svn.freebsd.org/changeset/base/188007 Log: Don't overwrite it, if only one sector is written yet. Discovered by: "Dewayne Geraghty" Modified: head/usr.sbin/fifolog/lib/fifolog_write_poll.c Modified: head/usr.sbin/fifolog/lib/fifolog_write_poll.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_write_poll.c Mon Feb 2 11:19:56 2009 (r188006) +++ head/usr.sbin/fifolog/lib/fifolog_write_poll.c Mon Feb 2 14:29:15 2009 (r188007) @@ -152,15 +152,16 @@ fifolog_write_open(struct fifolog_writer es = fifolog_int_findend(f->ff, &o); if (es != NULL) return (es); - if (o == 0) { - f->seq = 0; - f->recno = 0; + i = fifolog_int_read(f->ff, o); + if (i) + return ("Read error, looking for seq"); + f->seq = be32dec(f->ff->recbuf); + if (f->seq == 0) { + /* Empty fifolog */ + f->seq = random(); } else { - i = fifolog_int_read(f->ff, o); - if (i) - return ("Read error, looking for seq"); - f->seq = be32dec(f->ff->recbuf) + 1; f->recno = o + 1; + f->seq++; } f->ibufsize = 32768; From phk at FreeBSD.org Mon Feb 2 06:30:08 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon Feb 2 06:30:14 2009 Subject: svn commit: r188008 - head/usr.sbin/fifolog/lib Message-ID: <200902021430.n12EU7Dp099164@svn.freebsd.org> Author: phk Date: Mon Feb 2 14:30:07 2009 New Revision: 188008 URL: http://svn.freebsd.org/changeset/base/188008 Log: The last sector in the first segment might just be a sync, increment before checking validity of segment two. Modified: head/usr.sbin/fifolog/lib/fifolog_reader.c Modified: head/usr.sbin/fifolog/lib/fifolog_reader.c ============================================================================== --- head/usr.sbin/fifolog/lib/fifolog_reader.c Mon Feb 2 14:29:15 2009 (r188007) +++ head/usr.sbin/fifolog/lib/fifolog_reader.c Mon Feb 2 14:30:07 2009 (r188008) @@ -155,6 +155,7 @@ fifolog_reader_seek(const struct fifolog retval = fifolog_int_findend(fr->ff, &s); if (retval != NULL) err(1, "%s", retval); + s++; e = fifolog_reader_findsync(fr->ff, &s); if (e == 0) return (0); /* empty fifolog */ From mtm at FreeBSD.org Mon Feb 2 07:33:22 2009 From: mtm at FreeBSD.org (Mike Makonnen) Date: Mon Feb 2 07:33:33 2009 Subject: svn commit: r188009 - head/etc/rc.d Message-ID: <200902021533.n12FXMHC000481@svn.freebsd.org> Author: mtm Date: Mon Feb 2 15:33:22 2009 New Revision: 188009 URL: http://svn.freebsd.org/changeset/base/188009 Log: The 30 second wait for network interfaces to show up effectively makes the time to boot an unplugged system 30 sec. longer for no good reason. Therefore, add a check to make sure that any DHCP interfaces are plugged in before waiting. Modified: head/etc/rc.d/defaultroute Modified: head/etc/rc.d/defaultroute ============================================================================== --- head/etc/rc.d/defaultroute Mon Feb 2 14:30:07 2009 (r188008) +++ head/etc/rc.d/defaultroute Mon Feb 2 15:33:22 2009 (r188009) @@ -18,10 +18,21 @@ stop_cmd=":" defaultroute_start() { - # Return without waiting if we don't have dhcp interfaces. - # Once we can test that the link is actually up, we should - # remove this test and always wait. - [ -z "`list_net_interfaces dhcp`" ] && return + local output carrier nocarrier + + # Return without waiting if we don't have dhcp interfaces or + # if none of the dhcp interfaces is plugged in. + dhcp_interfaces=`list_net_interfaces dhcp` + [ -z "${dhcp_interfaces}" ] && return + carrier=false + for _if in ${dhcp_interfaces}; do + output=`/sbin/ifconfig ${_if}` + nocarrier=`expr "${output}" : '.*[[:blank:]]status: \(no carrier\)'` + [ -z "${nocarrier}" ] && carrier=true + done + if ! ${carrier}; then + return + fi # Wait for a default route delay=${if_up_delay} From mtm at FreeBSD.org Mon Feb 2 07:38:26 2009 From: mtm at FreeBSD.org (Mike Makonnen) Date: Mon Feb 2 07:38:37 2009 Subject: svn commit: r188010 - head/etc/defaults Message-ID: <200902021538.n12FcOgW000612@svn.freebsd.org> Author: mtm Date: Mon Feb 2 15:38:24 2009 New Revision: 188010 URL: http://svn.freebsd.org/changeset/base/188010 Log: Since, rc.d/defaultroute has the ability to wait for a default route to show up we can turn this knob back on without screwing subsequent daemons that expect to be able to talk to the outside world. Modified: head/etc/defaults/rc.conf Modified: head/etc/defaults/rc.conf ============================================================================== --- head/etc/defaults/rc.conf Mon Feb 2 15:33:22 2009 (r188009) +++ head/etc/defaults/rc.conf Mon Feb 2 15:38:24 2009 (r188010) @@ -101,7 +101,7 @@ nisdomainname="NO" # Set to NIS domain dhclient_program="/sbin/dhclient" # Path to dhcp client program. dhclient_flags="" # Extra flags to pass to dhcp client. #dhclient_flags_fxp0="" # Extra dhclient flags for fxp0 only -background_dhclient="NO" # Start dhcp client in the background. +background_dhclient="YES" # Start dhcp client in the background. #background_dhclient_fxp0="YES" # Start dhcp client on fxp0 in the background. synchronous_dhclient="NO" # Start dhclient directly on configured # interfaces during startup. From sam at FreeBSD.org Mon Feb 2 08:55:57 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Mon Feb 2 08:56:03 2009 Subject: svn commit: r188011 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902021655.n12Gtvir002253@svn.freebsd.org> Author: sam Date: Mon Feb 2 16:55:57 2009 New Revision: 188011 URL: http://svn.freebsd.org/changeset/base/188011 Log: restore variable initialization removed in r187831; this broke the horrible SAVE/RESTORE_CCK macros used by swan/nala cards to implement 11b using 11g Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Mon Feb 2 15:38:24 2009 (r188010) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Mon Feb 2 16:55:57 2009 (r188011) @@ -954,7 +954,7 @@ ar5212PerCalibrationN(struct ath_hal *ah int32_t qCoff, qCoffDenom; int32_t iqCorrMeas, iCoff, iCoffDenom; uint32_t powerMeasQ, powerMeasI; - HAL_BOOL isBmode; + HAL_BOOL isBmode = AH_FALSE; OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq); *isCalDone = AH_FALSE; From sam at FreeBSD.org Mon Feb 2 08:56:59 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Mon Feb 2 08:57:10 2009 Subject: svn commit: r188012 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902021656.n12Guw1i002309@svn.freebsd.org> Author: sam Date: Mon Feb 2 16:56:58 2009 New Revision: 188012 URL: http://svn.freebsd.org/changeset/base/188012 Log: o make SAVE_CCK slightly less error prone by always writing the _flag value used later by RESTORE_CCK o swap arg order in RESTORE_CCK to slightly reduce cost Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212.h Mon Feb 2 16:55:57 2009 (r188011) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h Mon Feb 2 16:56:58 2009 (r188012) @@ -399,10 +399,11 @@ struct ath_hal_5212 { (_chan)->ic_flags &= ~IEEE80211_CHAN_CCK; \ (_chan)->ic_flags |= IEEE80211_CHAN_DYN; \ (_flag) = AH_TRUE; \ - } \ + } else \ + (_flag) = AH_FALSE; \ } while (0) #define RESTORE_CCK(_ah, _chan, _flag) do { \ - if ((IS_2425(_ah) || IS_2417(_ah)) && (_flag)) { \ + if ((_flag) && (IS_2425(_ah) || IS_2417(_ah))) { \ (_chan)->ic_flags &= ~IEEE80211_CHAN_DYN; \ (_chan)->ic_flags |= IEEE80211_CHAN_CCK; \ } \ From emax at FreeBSD.org Mon Feb 2 10:08:24 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Mon Feb 2 10:08:36 2009 Subject: svn commit: r188013 - head/usr.sbin/bluetooth/btpand Message-ID: <200902021808.n12I8MiY003634@svn.freebsd.org> Author: emax Date: Mon Feb 2 18:08:22 2009 New Revision: 188013 URL: http://svn.freebsd.org/changeset/base/188013 Log: Fix client mode. Pick up service availability changes. Obtained from: NetBSD MFC after: 1 month Modified: head/usr.sbin/bluetooth/btpand/btpand.c head/usr.sbin/bluetooth/btpand/btpand.h head/usr.sbin/bluetooth/btpand/server.c Modified: head/usr.sbin/bluetooth/btpand/btpand.c ============================================================================== --- head/usr.sbin/bluetooth/btpand/btpand.c Mon Feb 2 16:56:58 2009 (r188012) +++ head/usr.sbin/bluetooth/btpand/btpand.c Mon Feb 2 18:08:22 2009 (r188013) @@ -54,8 +54,8 @@ uint16_t service_class; bdaddr_t local_bdaddr; /* -d */ bdaddr_t remote_bdaddr; /* -a */ -uint16_t l2cap_psm = 15; /* -p */ -int l2cap_mode = 0; /* -m */ +uint16_t l2cap_psm; /* -p */ +int l2cap_mode; /* -m */ int server_limit; /* -n */ @@ -177,6 +177,9 @@ main(int argc, char *argv[]) if (interface_name == NULL) interface_name = "/dev/tap"; + if (l2cap_psm == 0) + l2cap_psm = L2CAP_PSM_BNEP; + if (bdaddr_any(&remote_bdaddr) && server_limit == 0) { if (service_class == SDP_SERVICE_CLASS_PANU) server_limit = 1; Modified: head/usr.sbin/bluetooth/btpand/btpand.h ============================================================================== --- head/usr.sbin/bluetooth/btpand/btpand.h Mon Feb 2 16:56:58 2009 (r188012) +++ head/usr.sbin/bluetooth/btpand/btpand.h Mon Feb 2 18:08:22 2009 (r188013) @@ -51,6 +51,10 @@ #define L2CAP_PSM_INVALID(psm) (((psm) & 0x0101) != 0x0001) #endif +#ifndef L2CAP_PSM_BNEP +#define L2CAP_PSM_BNEP 15 +#endif + typedef struct channel channel_t; typedef struct pfilter pfilter_t; typedef struct mfilter mfilter_t; Modified: head/usr.sbin/bluetooth/btpand/server.c ============================================================================== --- head/usr.sbin/bluetooth/btpand/server.c Mon Feb 2 16:56:58 2009 (r188012) +++ head/usr.sbin/bluetooth/btpand/server.c Mon Feb 2 18:08:22 2009 (r188013) @@ -1,4 +1,4 @@ -/* $NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $ */ +/* $NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -28,11 +28,12 @@ /* $FreeBSD$ */ #include -__RCSID("$NetBSD: server.c,v 1.1 2008/08/17 13:20:57 plunky Exp $"); +__RCSID("$NetBSD: server.c,v 1.2 2009/01/24 17:29:28 plunky Exp $"); #include #include +#include #include #include #include @@ -42,7 +43,7 @@ __RCSID("$NetBSD: server.c,v 1.1 2008/08 static struct event server_ev; static int server_fd; -static int server_load; +static int server_avail; static void * server_ss; static uint32_t server_handle; @@ -73,13 +74,13 @@ server_update(int count) log_debug("count %d", count); - server_load = (count - 1) * 100 / server_limit; - log_info("server_load: %d%%", server_load); + server_avail = UINT8_MAX - (count - 1) * UINT8_MAX / server_limit; + log_info("Service Availability: %d/%d", server_avail, UINT8_MAX); - if (server_load > 99 && server_fd != -1) + if (server_avail == 0 && server_fd != -1) server_close(); - if (server_load < 100 && server_fd == -1) + if (server_avail > 0 && server_fd == -1) server_open(); if (service_name) @@ -257,19 +258,9 @@ server_register(void) } memset(&p, 0, sizeof(p)); - p.psm = l2cap_psm; - - if (server_load < 1) p.load_factor = 0; - else if (server_load <= 17) p.load_factor = 1; - else if (server_load <= 33) p.load_factor = 2; - else if (server_load <= 50) p.load_factor = 3; - else if (server_load <= 67) p.load_factor = 4; - else if (server_load <= 83) p.load_factor = 5; - else if (server_load <= 99) p.load_factor = 6; - else p.load_factor = 7; - - if (l2cap_mode != 0) p.security_description = 0x0001; + p.load_factor = server_avail; + p.security_description = (l2cap_mode == 0 ? 0x0000 : 0x0001); if (server_handle) rv = sdp_change_service(server_ss, server_handle, From emax at FreeBSD.org Mon Feb 2 10:10:53 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Mon Feb 2 10:10:59 2009 Subject: svn commit: r188014 - head/usr.sbin/bluetooth Message-ID: <200902021810.n12IAqJk003723@svn.freebsd.org> Author: emax Date: Mon Feb 2 18:10:51 2009 New Revision: 188014 URL: http://svn.freebsd.org/changeset/base/188014 Log: Hook up btpand(8) to the build MFC after: 1 month Modified: head/usr.sbin/bluetooth/Makefile Modified: head/usr.sbin/bluetooth/Makefile ============================================================================== --- head/usr.sbin/bluetooth/Makefile Mon Feb 2 18:08:22 2009 (r188013) +++ head/usr.sbin/bluetooth/Makefile Mon Feb 2 18:10:51 2009 (r188014) @@ -6,6 +6,7 @@ SUBDIR= \ bt3cfw \ bthidcontrol \ bthidd \ + btpand \ hccontrol \ hcsecd \ hcseriald \ From lulf at FreeBSD.org Mon Feb 2 11:22:55 2009 From: lulf at FreeBSD.org (Ulf Lilleengen) Date: Mon Feb 2 11:23:02 2009 Subject: svn commit: r188017 - head/sbin/geom/core Message-ID: <200902021922.n12JMrM8005192@svn.freebsd.org> Author: lulf Date: Mon Feb 2 19:22:53 2009 New Revision: 188017 URL: http://svn.freebsd.org/changeset/base/188017 Log: - Use a separate pointer to the allocated memory for freeing, as strsep may modify the pointer argument passed to it. This triggered an assert in malloc when a geom command being run under the livefs environment. PR: bin/130632 Submitted by: Dimitry Andric Pointy hat to: me MFC after: 2 days Modified: head/sbin/geom/core/geom.c Modified: head/sbin/geom/core/geom.c ============================================================================== --- head/sbin/geom/core/geom.c Mon Feb 2 18:32:41 2009 (r188016) +++ head/sbin/geom/core/geom.c Mon Feb 2 19:22:53 2009 (r188017) @@ -487,13 +487,13 @@ library_path(void) static void load_library(void) { - char *curpath, path[MAXPATHLEN], *totalpath; + char *curpath, path[MAXPATHLEN], *tofree, *totalpath; uint32_t *lib_version; void *dlh; int ret; ret = 0; - totalpath = strdup(library_path()); + tofree = totalpath = strdup(library_path()); if (totalpath == NULL) err(EXIT_FAILURE, "Not enough memory for library path"); @@ -519,7 +519,7 @@ load_library(void) } break; } - free(totalpath); + free(tofree); /* No library was found, but standard commands can still be used */ if (ret == -1) return; From jhb at FreeBSD.org Mon Feb 2 11:54:17 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Feb 2 11:54:24 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf Message-ID: <200902021954.n12JsGT2005768@svn.freebsd.org> Author: jhb Date: Mon Feb 2 19:54:16 2009 New Revision: 188018 URL: http://svn.freebsd.org/changeset/base/188018 Log: - Add a new ioctl to /dev/pci to fetch details on an individual BAR of a device. The details include the current value of the BAR (including all the flag bits and the current base address), its length, and whether or not it is enabled. Since this operation is not invasive, non-root users are allowed to use it (unlike manual config register access which requires root). The intention is that userland apps (such as Xorg) will use this interface rather than dangerously frobbing the BARs from userland to obtain this information. - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used with -l will now list all the active BARs for each device. MFC after: 1 month Modified: head/sys/dev/pci/pci_user.c head/sys/dev/pci/pcireg.h head/usr.sbin/pciconf/pciconf.8 head/usr.sbin/pciconf/pciconf.c Modified: head/sys/dev/pci/pci_user.c ============================================================================== --- head/sys/dev/pci/pci_user.c Mon Feb 2 19:22:53 2009 (r188017) +++ head/sys/dev/pci/pci_user.c Mon Feb 2 19:54:16 2009 (r188018) @@ -307,7 +307,10 @@ pci_ioctl(struct cdev *dev, u_long cmd, struct pci_conf_io *cio; struct pci_devinfo *dinfo; struct pci_io *io; + struct pci_bar_io *bio; struct pci_match_conf *pattern_buf; + struct resource_list_entry *rle; + uint32_t value; size_t confsz, iolen, pbufsz; int error, ionum, i, num_patterns; #ifdef PRE7_COMPAT @@ -319,11 +322,11 @@ pci_ioctl(struct cdev *dev, u_long cmd, io_old = NULL; pattern_buf_old = NULL; - if (!(flag & FWRITE) && - (cmd != PCIOCGETCONF && cmd != PCIOCGETCONF_OLD)) + if (!(flag & FWRITE) && cmd != PCIOCGETBAR && + cmd != PCIOCGETCONF && cmd != PCIOCGETCONF_OLD) return EPERM; #else - if (!(flag & FWRITE) && cmd != PCIOCGETCONF) + if (!(flag & FWRITE) && cmd != PCIOCGETBAR && cmd != PCIOCGETCONF) return EPERM; #endif @@ -669,6 +672,70 @@ getconfexit: } break; + case PCIOCGETBAR: + bio = (struct pci_bar_io *)data; + + /* + * Assume that the user-level bus number is + * in fact the physical PCI bus number. + */ + pcidev = pci_find_dbsf(bio->pbi_sel.pc_domain, + bio->pbi_sel.pc_bus, bio->pbi_sel.pc_dev, + bio->pbi_sel.pc_func); + if (pcidev == NULL) { + error = ENODEV; + break; + } + dinfo = device_get_ivars(pcidev); + + /* + * Look for a resource list entry matching the requested BAR. + * + * XXX: This will not find BARs that are not initialized, but + * maybe that is ok? + */ + rle = resource_list_find(&dinfo->resources, SYS_RES_MEMORY, + bio->pbi_reg); + if (rle == NULL) + rle = resource_list_find(&dinfo->resources, + SYS_RES_IOPORT, bio->pbi_reg); + if (rle == NULL || rle->res == NULL) { + error = EINVAL; + break; + } + + /* + * Ok, we have a resource for this BAR. Read the lower + * 32 bits to get any flags. + */ + value = pci_read_config(pcidev, bio->pbi_reg, 4); + if (PCI_BAR_MEM(value)) { + if (rle->type != SYS_RES_MEMORY) { + error = EINVAL; + break; + } + value &= ~PCIM_BAR_MEM_BASE; + } else { + if (rle->type != SYS_RES_IOPORT) { + error = EINVAL; + break; + } + value &= ~PCIM_BAR_IO_BASE; + } + bio->pbi_base = rman_get_start(rle->res) | value; + bio->pbi_length = rman_get_size(rle->res); + + /* + * Check the command register to determine if this BAR + * is enabled. + */ + value = pci_read_config(pcidev, PCIR_COMMAND, 2); + if (rle->type == SYS_RES_MEMORY) + bio->pbi_enabled = (value & PCIM_CMD_MEMEN) != 0; + else + bio->pbi_enabled = (value & PCIM_CMD_PORTEN) != 0; + error = 0; + break; default: error = ENOTTY; break; Modified: head/sys/dev/pci/pcireg.h ============================================================================== --- head/sys/dev/pci/pcireg.h Mon Feb 2 19:22:53 2009 (r188017) +++ head/sys/dev/pci/pcireg.h Mon Feb 2 19:54:16 2009 (r188018) @@ -117,7 +117,7 @@ #define PCIR_BARS 0x10 #define PCIR_BAR(x) (PCIR_BARS + (x) * 4) -#define PCI_MAX_BAR_0 5 /* Number of standard bars */ +#define PCIR_MAX_BAR_0 5 #define PCI_RID2BAR(rid) (((rid) - PCIR_BARS) / 4) #define PCI_BAR_IO(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_IO_SPACE) #define PCI_BAR_MEM(x) (((x) & PCIM_BAR_SPACE) == PCIM_BAR_MEM_SPACE) @@ -158,6 +158,7 @@ /* config registers for header type 1 (PCI-to-PCI bridge) devices */ +#define PCIR_MAX_BAR_1 1 #define PCIR_SECSTAT_1 0x1e #define PCIR_PRIBUS_1 0x18 @@ -188,6 +189,7 @@ /* config registers for header type 2 (CardBus) devices */ +#define PCIR_MAX_BAR_2 0 #define PCIR_CAP_PTR_2 0x14 #define PCIR_SECSTAT_2 0x16 Modified: head/usr.sbin/pciconf/pciconf.8 ============================================================================== --- head/usr.sbin/pciconf/pciconf.8 Mon Feb 2 19:22:53 2009 (r188017) +++ head/usr.sbin/pciconf/pciconf.8 Mon Feb 2 19:54:16 2009 (r188018) @@ -33,7 +33,7 @@ .Nd diagnostic utility for the PCI bus .Sh SYNOPSIS .Nm -.Fl l Op Fl cv +.Fl l Op Fl bcv .Nm .Fl a Ar selector .Nm @@ -112,6 +112,32 @@ device, which contains several (similar one chip. .Pp If the +.Fl b +option is supplied, +.Nm +will list any base address registers +.Pq BARs +that are assigned resources for each device. +Each BAR will be enumerated via a line in the following format: +.Bd -literal + bar [10] = type Memory, range 32, base 0xda060000, size 131072, enabled +.Ed +.Pp +The first value after the +.Dq Li bar +prefix in the square brackets is the offset of the BAR in config space in +hexadecimal. +The type of a BAR is one of +.Dq Memory , +.Dq Prefetchable Memory , +or +.Dq I/O Port . +The range indicates the maximum address the BAR decodes. +The base and size indicate the start and length of the BAR's address window, +respectively. +Finally, the last flag indicates if the BAR is enabled or disabled. +.Pp +If the .Fl c option is supplied, .Nm Modified: head/usr.sbin/pciconf/pciconf.c ============================================================================== --- head/usr.sbin/pciconf/pciconf.c Mon Feb 2 19:22:53 2009 (r188017) +++ head/usr.sbin/pciconf/pciconf.c Mon Feb 2 19:54:16 2009 (r188018) @@ -37,6 +37,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -66,7 +67,8 @@ struct pci_vendor_info TAILQ_HEAD(,pci_vendor_info) pci_vendors; -static void list_devs(int verbose, int caps); +static void list_bars(int fd, struct pci_conf *p); +static void list_devs(int verbose, int bars, int caps); static void list_verbose(struct pci_conf *p); static const char *guess_class(struct pci_conf *p); static const char *guess_subclass(struct pci_conf *p); @@ -81,7 +83,7 @@ static void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n", - "usage: pciconf -l [-cv]", + "usage: pciconf -l [-bcv]", " pciconf -a selector", " pciconf -r [-b | -h] selector addr[:addr2]", " pciconf -w [-b | -h] selector addr value"); @@ -92,10 +94,10 @@ int main(int argc, char **argv) { int c; - int listmode, readmode, writemode, attachedmode, caps, verbose; + int listmode, readmode, writemode, attachedmode, bars, caps, verbose; int byte, isshort; - listmode = readmode = writemode = attachedmode = caps = verbose = byte = isshort = 0; + listmode = readmode = writemode = attachedmode = bars = caps = verbose = byte = isshort = 0; while ((c = getopt(argc, argv, "abchlrwv")) != -1) { switch(c) { @@ -104,6 +106,7 @@ main(int argc, char **argv) break; case 'b': + bars = 1; byte = 1; break; @@ -143,7 +146,7 @@ main(int argc, char **argv) usage(); if (listmode) { - list_devs(verbose, caps); + list_devs(verbose, bars, caps); } else if (attachedmode) { chkattached(argv[optind], byte ? 1 : isshort ? 2 : 4); @@ -161,7 +164,7 @@ main(int argc, char **argv) } static void -list_devs(int verbose, int caps) +list_devs(int verbose, int bars, int caps) { int fd; struct pci_conf_io pc; @@ -217,6 +220,8 @@ list_devs(int verbose, int caps) p->pc_revid, p->pc_hdr); if (verbose) list_verbose(p); + if (bars) + list_bars(fd, p); if (caps) list_caps(fd, p); } @@ -226,6 +231,64 @@ list_devs(int verbose, int caps) } static void +list_bars(int fd, struct pci_conf *p) +{ + struct pci_bar_io bar; + uint64_t base; + const char *type; + int i, range, max; + + switch (p->pc_hdr & PCIM_HDRTYPE) { + case PCIM_HDRTYPE_NORMAL: + max = PCIR_MAX_BAR_0; + break; + case PCIM_HDRTYPE_BRIDGE: + max = PCIR_MAX_BAR_1; + break; + case PCIM_HDRTYPE_CARDBUS: + max = PCIR_MAX_BAR_2; + break; + default: + return; + } + + for (i = 0; i <= max; i++) { + bar.pbi_sel = p->pc_sel; + bar.pbi_reg = PCIR_BAR(i); + if (ioctl(fd, PCIOCGETBAR, &bar) < 0) + continue; + if (PCI_BAR_IO(bar.pbi_base)) { + type = "I/O Port"; + range = 32; + base = bar.pbi_base & PCIM_BAR_IO_BASE; + } else { + if (bar.pbi_base & PCIM_BAR_MEM_PREFETCH) + type = "Prefetchable Memory"; + else + type = "Memory"; + switch (bar.pbi_base & PCIM_BAR_MEM_TYPE) { + case PCIM_BAR_MEM_32: + range = 32; + break; + case PCIM_BAR_MEM_1MB: + range = 20; + break; + case PCIM_BAR_MEM_64: + range = 64; + break; + default: + range = -1; + } + base = bar.pbi_base & ~((uint64_t)0xf); + } + printf(" bar [%02x] = type %s, range %2d, base %#jx, ", + PCIR_BAR(i), type, range, (uintmax_t)base); + printf("size %2d, %s\n", (int)bar.pbi_length, + bar.pbi_enabled ? "enabled" : "disabled"); + } +} + +static void list_verbose(struct pci_conf *p) { struct pci_vendor_info *vi; From cognet at FreeBSD.org Mon Feb 2 12:09:15 2009 From: cognet at FreeBSD.org (Olivier Houchard) Date: Mon Feb 2 12:09:27 2009 Subject: svn commit: r188019 - in head/sys/arm: arm sa11x0 Message-ID: <200902022009.n12K9Ei5006072@svn.freebsd.org> Author: cognet Date: Mon Feb 2 20:09:14 2009 New Revision: 188019 URL: http://svn.freebsd.org/changeset/base/188019 Log: Remove unused variables. Spotted out by: Christoph Mallon Modified: head/sys/arm/arm/dump_machdep.c head/sys/arm/arm/elf_trampoline.c head/sys/arm/arm/pmap.c head/sys/arm/arm/vm_machdep.c head/sys/arm/sa11x0/assabet_machdep.c Modified: head/sys/arm/arm/dump_machdep.c ============================================================================== --- head/sys/arm/arm/dump_machdep.c Mon Feb 2 19:54:16 2009 (r188018) +++ head/sys/arm/arm/dump_machdep.c Mon Feb 2 20:09:14 2009 (r188019) @@ -158,14 +158,12 @@ cb_dumpdata(struct md_pa *mdp, int seqnr { struct dumperinfo *di = (struct dumperinfo*)arg; vm_paddr_t pa; - vm_offset_t va; uint32_t pgs; size_t counter, sz, chunk; int c, error; error = 0; /* catch case in which chunk size is 0 */ counter = 0; - va = 0; pgs = mdp->md_size / PAGE_SIZE; pa = mdp->md_start; Modified: head/sys/arm/arm/elf_trampoline.c ============================================================================== --- head/sys/arm/arm/elf_trampoline.c Mon Feb 2 19:54:16 2009 (r188018) +++ head/sys/arm/arm/elf_trampoline.c Mon Feb 2 20:09:14 2009 (r188019) @@ -404,11 +404,11 @@ load_kernel(unsigned int kstart, unsigne int symtabindex = -1; int symstrindex = -1; vm_offset_t lastaddr = 0; - Elf_Addr ssym = 0, esym = 0; + Elf_Addr ssym = 0; Elf_Dyn *dp; eh = (Elf32_Ehdr *)kstart; - ssym = esym = 0; + ssym = 0; entry_point = (void*)eh->e_entry; memcpy(phdr, (void *)(kstart + eh->e_phoff ), eh->e_phnum * sizeof(phdr[0])); Modified: head/sys/arm/arm/pmap.c ============================================================================== --- head/sys/arm/arm/pmap.c Mon Feb 2 19:54:16 2009 (r188018) +++ head/sys/arm/arm/pmap.c Mon Feb 2 20:09:14 2009 (r188019) @@ -3102,7 +3102,7 @@ void pmap_remove_all(vm_page_t m) { pv_entry_t pv; - pt_entry_t *ptep, pte; + pt_entry_t *ptep; struct l2_bucket *l2b; boolean_t flush = FALSE; pmap_t curpm; @@ -3130,7 +3130,6 @@ pmap_remove_all(vm_page_t m) l2b = pmap_get_l2_bucket(pv->pv_pmap, pv->pv_va); KASSERT(l2b != NULL, ("No l2 bucket")); ptep = &l2b->l2b_kva[l2pte_index(pv->pv_va)]; - pte = *ptep; *ptep = 0; PTE_SYNC_CURRENT(pv->pv_pmap, ptep); pmap_free_l2_bucket(pv->pv_pmap, l2b, 1); Modified: head/sys/arm/arm/vm_machdep.c ============================================================================== --- head/sys/arm/arm/vm_machdep.c Mon Feb 2 19:54:16 2009 (r188018) +++ head/sys/arm/arm/vm_machdep.c Mon Feb 2 20:09:14 2009 (r188019) @@ -108,14 +108,13 @@ void cpu_fork(register struct thread *td1, register struct proc *p2, struct thread *td2, int flags) { - struct pcb *pcb1, *pcb2; + struct pcb *pcb2; struct trapframe *tf; struct switchframe *sf; struct mdproc *mdp2; if ((flags & RFPROC) == 0) return; - pcb1 = td1->td_pcb; pcb2 = (struct pcb *)(td2->td_kstack + td2->td_kstack_pages * PAGE_SIZE) - 1; #ifdef __XSCALE__ #ifndef CPU_XSCALE_CORE3 Modified: head/sys/arm/sa11x0/assabet_machdep.c ============================================================================== --- head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 19:54:16 2009 (r188018) +++ head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 20:09:14 2009 (r188019) @@ -210,12 +210,10 @@ initarm(void *arg, void *arg2) struct pv_addr md_addr; struct pv_addr md_bla; int loop; - u_int kerneldatasize, symbolsize; u_int l1pagetable; vm_offset_t freemempos; vm_offset_t lastalloced; vm_offset_t lastaddr; - vm_size_t pt_size; uint32_t memsize = 32 * 1024 * 1024; sa1110_uart_vaddr = SACOM1_VBASE; @@ -232,8 +230,6 @@ initarm(void *arg, void *arg2) physical_end = lastaddr; physical_freestart = (((vm_offset_t)physical_end) + PAGE_MASK) & ~PAGE_MASK; md_addr.pv_va = md_addr.pv_pa = MDROOT_ADDR; - kerneldatasize = (u_int32_t)&end - (u_int32_t)KERNVIRTADDR; - symbolsize = 0; freemempos = (vm_offset_t)round_page(physical_freestart); memset((void *)freemempos, 0, 256*1024); /* Define a macro to simplify memory allocation */ @@ -272,7 +268,6 @@ initarm(void *arg, void *arg2) * This page will just contain the system vectors and can be * shared by all processes. */ - pt_size = round_page(freemempos) - physical_freestart; /* Allocate stacks for all modes */ valloc_pages(irqstack, IRQ_STACK_SIZE); From christoph.mallon at gmx.de Mon Feb 2 12:14:33 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Mon Feb 2 12:14:39 2009 Subject: svn commit: r188019 - in head/sys/arm: arm sa11x0 In-Reply-To: <200902022009.n12K9Ei5006072@svn.freebsd.org> References: <200902022009.n12K9Ei5006072@svn.freebsd.org> Message-ID: <49875422.8070402@gmx.de> Olivier Houchard schrieb: > Modified: head/sys/arm/sa11x0/assabet_machdep.c > ============================================================================== > --- head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 19:54:16 2009 (r188018) > +++ head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 20:09:14 2009 (r188019) > @@ -272,7 +268,6 @@ initarm(void *arg, void *arg2) > * This page will just contain the system vectors and can be > * shared by all processes. > */ > - pt_size = round_page(freemempos) - physical_freestart; > > /* Allocate stacks for all modes */ > valloc_pages(irqstack, IRQ_STACK_SIZE); What about the comment above? It seems to relate to the removed line. From cognet at ci0.org Mon Feb 2 12:23:40 2009 From: cognet at ci0.org (Olivier Houchard) Date: Mon Feb 2 12:23:46 2009 Subject: svn commit: r188019 - in head/sys/arm: arm sa11x0 In-Reply-To: <49875422.8070402@gmx.de> References: <200902022009.n12K9Ei5006072@svn.freebsd.org> <49875422.8070402@gmx.de> Message-ID: <20090202230054.GA58364@ci0.org> On Mon, Feb 02, 2009 at 09:14:26PM +0100, Christoph Mallon wrote: > Olivier Houchard schrieb: > >Modified: head/sys/arm/sa11x0/assabet_machdep.c > >============================================================================== > >--- head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 19:54:16 2009 > >(r188018) > >+++ head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 20:09:14 2009 > >(r188019) > >@@ -272,7 +268,6 @@ initarm(void *arg, void *arg2) > > * This page will just contain the system vectors and can be > > * shared by all processes. > > */ > >- pt_size = round_page(freemempos) - physical_freestart; > > > > /* Allocate stacks for all modes */ > > valloc_pages(irqstack, IRQ_STACK_SIZE); > > What about the comment above? It seems to relate to the removed line. Actually, it refers to the line just before :) I'm going to move it up so it's more clear. Thanks, Olivier From cognet at FreeBSD.org Mon Feb 2 12:24:32 2009 From: cognet at FreeBSD.org (Olivier Houchard) Date: Mon Feb 2 12:24:43 2009 Subject: svn commit: r188020 - head/sys/arm/sa11x0 Message-ID: <200902022024.n12KOT1M006431@svn.freebsd.org> Author: cognet Date: Mon Feb 2 20:24:29 2009 New Revision: 188020 URL: http://svn.freebsd.org/changeset/base/188020 Log: Move a comment to where it belongs. Spotted out by: Christoph Mallon Modified: head/sys/arm/sa11x0/assabet_machdep.c Modified: head/sys/arm/sa11x0/assabet_machdep.c ============================================================================== --- head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 20:09:14 2009 (r188019) +++ head/sys/arm/sa11x0/assabet_machdep.c Mon Feb 2 20:24:29 2009 (r188020) @@ -261,13 +261,12 @@ initarm(void *arg, void *arg2) } } - valloc_pages(systempage, 1); - /* * Allocate a page for the system page mapped to V0x00000000 * This page will just contain the system vectors and can be * shared by all processes. */ + valloc_pages(systempage, 1); /* Allocate stacks for all modes */ valloc_pages(irqstack, IRQ_STACK_SIZE); From jhb at freebsd.org Mon Feb 2 12:55:34 2009 From: jhb at freebsd.org (John Baldwin) Date: Mon Feb 2 12:55:48 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf In-Reply-To: <200902021954.n12JsGT2005768@svn.freebsd.org> References: <200902021954.n12JsGT2005768@svn.freebsd.org> Message-ID: <200902021554.55644.jhb@freebsd.org> On Monday 02 February 2009 2:54:16 pm John Baldwin wrote: > Author: jhb > Date: Mon Feb 2 19:54:16 2009 > New Revision: 188018 > URL: http://svn.freebsd.org/changeset/base/188018 > > Log: > - Add a new ioctl to /dev/pci to fetch details on an individual BAR of a > device. The details include the current value of the BAR (including all > the flag bits and the current base address), its length, and whether or not > it is enabled. Since this operation is not invasive, non-root users are > allowed to use it (unlike manual config register access which requires > root). The intention is that userland apps (such as Xorg) will use this > interface rather than dangerously frobbing the BARs from userland to > obtain this information. > - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used > with -l will now list all the active BARs for each device. > > MFC after: 1 month As with the capability messages, I attempted to make the bar messages match the output of a verbose dmesg. An example: igb0@pci0:8:0:0: class=0x020000 card=0x10a715d9 chip=0x10a78086 rev=0x02 hdr=0x00 vendor = 'Intel Corporation' class = network subclass = ethernet bar [10] = type Memory, range 32, base 0xda020000, size 131072, enabled bar [14] = type Memory, range 32, base 0xda000000, size 131072, enabled bar [18] = type I/O Port, range 32, base 0x3000, size 32, enabled bar [1c] = type Memory, range 32, base 0xda080000, size 16384, enabled cap 01[40] = powerspec 2 supports D0 D3 current D0 cap 05[50] = MSI supports 1 message, 64 bit cap 11[60] = MSI-X supports 10 messages in map 0x1c enabled cap 10[a0] = PCI-Express 2 endpoint There are a few caveats: 1) the ioctl will not report any status for a BAR that doesn't have allocated resources. We could fix this is if we stored details about the BARs we enumerate during pci_add_child() in the dinfo. 2) The ioctl will report status for BARs we add via quirks, but the pciconf doesn't know how to get to them. It may make sense for the IOCTL to work differently than it does now. Perhaps as an iterator where you request register 0 the first time, and then pass in the previous register on each update. It would then walk all the resources and signal end by setting the register to -1. The current mode does handle what Xorg expects I think, whereas the iterator approach would require more hacking on X. -- John Baldwin From sbruno at FreeBSD.org Mon Feb 2 13:05:14 2009 From: sbruno at FreeBSD.org (Sean Bruno) Date: Mon Feb 2 13:05:21 2009 Subject: svn commit: r188029 - head/usr.sbin/fwcontrol Message-ID: <200902022105.n12L5C3o007520@svn.freebsd.org> Author: sbruno Date: Mon Feb 2 21:05:12 2009 New Revision: 188029 URL: http://svn.freebsd.org/changeset/base/188029 Log: Begin basic improvements to fwcontrol in the area of handling video streams from cameras. This patch changes the displayed timer to a time stamp and corrects one or two mishandled errors. Submitted by: imp Modified: head/usr.sbin/fwcontrol/fwdv.c head/usr.sbin/fwcontrol/fwmpegts.c Modified: head/usr.sbin/fwcontrol/fwdv.c ============================================================================== --- head/usr.sbin/fwcontrol/fwdv.c Mon Feb 2 21:02:23 2009 (r188028) +++ head/usr.sbin/fwcontrol/fwdv.c Mon Feb 2 21:05:12 2009 (r188029) @@ -202,15 +202,20 @@ again: (dv->payload[0] & DV_DSF_12) == 0) dv->payload[0] |= DV_DSF_12; nb = nblocks[system]; - fprintf(stderr, "%d", k%10); + fprintf(stderr, "%d:%02d:%02d %d\r", + k / (3600 * frame_rate[system]), + (k / (60 * frame_rate[system])) % 60, + (k / frame_rate[system]) % 60, + k % frame_rate[system]); + #if FIX_FRAME if (m > 0 && m != nb) { /* padding bad frame */ npad = ((nb - m) % nb); if (npad < 0) npad += nb; - fprintf(stderr, "(%d blocks padded)", - npad); + fprintf(stderr, "\n%d blocks padded\n", + npad); npad *= DSIZE; wbuf[vec].iov_base = pad; wbuf[vec++].iov_len = npad; @@ -221,10 +226,6 @@ again: } #endif k++; - if (k % frame_rate[system] == 0) { - /* every second */ - fprintf(stderr, "\n"); - } fflush(stderr); m = 0; } @@ -245,9 +246,8 @@ next: if (vec > 0) writev(fd, wbuf, vec); } - if(fd != STDOUT_FILENO) { + if (fd != STDOUT_FILENO) close(fd); - } fprintf(stderr, "\n"); } Modified: head/usr.sbin/fwcontrol/fwmpegts.c ============================================================================== --- head/usr.sbin/fwcontrol/fwmpegts.c Mon Feb 2 21:02:23 2009 (r188028) +++ head/usr.sbin/fwcontrol/fwmpegts.c Mon Feb 2 21:05:12 2009 (r188029) @@ -195,10 +195,9 @@ mpegtsrecv(int d, const char *filename, if (len < 0) { if (errno == EAGAIN) { fprintf(stderr, "(EAGAIN) - push 'Play'?\n"); - if (len <= 0) - continue; - } else - err(1, "read failed"); + continue; + } + err(1, "read failed"); } ptr = (uint32_t *) buf; From emax at FreeBSD.org Mon Feb 2 13:34:04 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Mon Feb 2 13:34:16 2009 Subject: svn commit: r188030 - head/sys/dev/kbdmux Message-ID: <200902022134.n12LY4H0008110@svn.freebsd.org> Author: emax Date: Mon Feb 2 21:34:04 2009 New Revision: 188030 URL: http://svn.freebsd.org/changeset/base/188030 Log: Properly retun error core from kbdmux_modevent() Reported by: Christoph Mallon < christoph -dot- mallon -at- gmx -dot- de > MFC after: 1 week Modified: head/sys/dev/kbdmux/kbdmux.c Modified: head/sys/dev/kbdmux/kbdmux.c ============================================================================== --- head/sys/dev/kbdmux/kbdmux.c Mon Feb 2 21:05:12 2009 (r188029) +++ head/sys/dev/kbdmux/kbdmux.c Mon Feb 2 21:34:04 2009 (r188030) @@ -1363,7 +1363,7 @@ kbdmux_modevent(module_t mod, int type, break; } - return (0); + return (error); } DEV_MODULE(kbdmux, kbdmux_modevent, NULL); From rnoland at FreeBSD.org Mon Feb 2 13:41:52 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Feb 2 13:42:03 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf In-Reply-To: <200902021554.55644.jhb@freebsd.org> References: <200902021954.n12JsGT2005768@svn.freebsd.org> <200902021554.55644.jhb@freebsd.org> Message-ID: <1233608975.1492.45.camel@ferret.2hip.net> On Mon, 2009-02-02 at 15:54 -0500, John Baldwin wrote: > On Monday 02 February 2009 2:54:16 pm John Baldwin wrote: > > Author: jhb > > Date: Mon Feb 2 19:54:16 2009 > > New Revision: 188018 > > URL: http://svn.freebsd.org/changeset/base/188018 > > > > Log: > > - Add a new ioctl to /dev/pci to fetch details on an individual BAR of a > > device. The details include the current value of the BAR (including all > > the flag bits and the current base address), its length, and whether or not > > it is enabled. Since this operation is not invasive, non-root users are > > allowed to use it (unlike manual config register access which requires > > root). The intention is that userland apps (such as Xorg) will use this > > interface rather than dangerously frobbing the BARs from userland to > > obtain this information. > > - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used > > with -l will now list all the active BARs for each device. > > > > MFC after: 1 month > > As with the capability messages, I attempted to make the bar messages match > the output of a verbose dmesg. An example: > > igb0@pci0:8:0:0: class=0x020000 card=0x10a715d9 chip=0x10a78086 rev=0x02 hdr=0x00 > vendor = 'Intel Corporation' > class = network > subclass = ethernet > bar [10] = type Memory, range 32, base 0xda020000, size 131072, enabled > bar [14] = type Memory, range 32, base 0xda000000, size 131072, enabled > bar [18] = type I/O Port, range 32, base 0x3000, size 32, enabled > bar [1c] = type Memory, range 32, base 0xda080000, size 16384, enabled > cap 01[40] = powerspec 2 supports D0 D3 current D0 > cap 05[50] = MSI supports 1 message, 64 bit > cap 11[60] = MSI-X supports 10 messages in map 0x1c enabled > cap 10[a0] = PCI-Express 2 endpoint I haven't looked this over thoroughly yet, but will it support BIOS mappings as well? Or should I take a crack at adding that? robert. > There are a few caveats: > > 1) the ioctl will not report any status for a BAR that doesn't have allocated > resources. We could fix this is if we stored details about the BARs we > enumerate during pci_add_child() in the dinfo. > 2) The ioctl will report status for BARs we add via quirks, but the pciconf > doesn't know how to get to them. It may make sense for the IOCTL to work > differently than it does now. Perhaps as an iterator where you request > register 0 the first time, and then pass in the previous register on each > update. It would then walk all the resources and signal end by setting > the register to -1. The current mode does handle what Xorg expects I > think, whereas the iterator approach would require more hacking on X. -- Robert Noland FreeBSD -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: This is a digitally signed message part Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090202/6b3cca2e/attachment.pgp From rdivacky at FreeBSD.org Mon Feb 2 13:51:53 2009 From: rdivacky at FreeBSD.org (Roman Divacky) Date: Mon Feb 2 13:52:00 2009 Subject: svn commit: r188031 - head/lib/libc/sparc64/sys Message-ID: <200902022151.n12LpqeC008470@svn.freebsd.org> Author: rdivacky Date: Mon Feb 2 21:51:52 2009 New Revision: 188031 URL: http://svn.freebsd.org/changeset/base/188031 Log: Provide a type for the argument. Approved by: kib (mentor) Modified: head/lib/libc/sparc64/sys/__sparc_utrap.c Modified: head/lib/libc/sparc64/sys/__sparc_utrap.c ============================================================================== --- head/lib/libc/sparc64/sys/__sparc_utrap.c Mon Feb 2 21:34:04 2009 (r188030) +++ head/lib/libc/sparc64/sys/__sparc_utrap.c Mon Feb 2 21:51:52 2009 (r188031) @@ -122,7 +122,7 @@ __utrap_write(const char *str) } void -__utrap_kill_self(sig) +__utrap_kill_self(int sig) { int berrno; From jhb at FreeBSD.org Mon Feb 2 14:04:41 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Feb 2 14:04:53 2009 Subject: svn commit: r188032 - head/sys/sys Message-ID: <200902022204.n12M4e0C008777@svn.freebsd.org> Author: jhb Date: Mon Feb 2 22:04:40 2009 New Revision: 188032 URL: http://svn.freebsd.org/changeset/base/188032 Log: - Add a new ioctl to /dev/pci to fetch details on an individual BAR of a device. The details include the current value of the BAR (including all the flag bits and the current base address), its length, and whether or not it is enabled. Since this operation is not invasive, non-root users are allowed to use it (unlike manual config register access which requires root). The intention is that userland apps (such as Xorg) will use this interface rather than dangerously frobbing the BARs from userland to obtain this information. - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used with -l will now list all the active BARs for each device. (Missed in previous commit) MFC after: 1 week Modified: head/sys/sys/pciio.h Modified: head/sys/sys/pciio.h ============================================================================== --- head/sys/sys/pciio.h Mon Feb 2 21:51:52 2009 (r188031) +++ head/sys/sys/pciio.h Mon Feb 2 22:04:40 2009 (r188032) @@ -108,9 +108,18 @@ struct pci_io { u_int32_t pi_data; /* data to write or result of read */ }; +struct pci_bar_io { + struct pcisel pbi_sel; /* device to operate on */ + int pbi_reg; /* starting address of BAR */ + int pbi_enabled; /* decoding enabled */ + uint64_t pbi_base; /* current value of BAR */ + uint64_t pbi_length; /* length of BAR */ +}; + #define PCIOCGETCONF _IOWR('p', 5, struct pci_conf_io) #define PCIOCREAD _IOWR('p', 2, struct pci_io) #define PCIOCWRITE _IOWR('p', 3, struct pci_io) #define PCIOCATTACHED _IOWR('p', 4, struct pci_io) +#define PCIOCGETBAR _IOWR('p', 6, struct pci_bar_io) #endif /* !_SYS_PCIIO_H_ */ From jhb at FreeBSD.org Mon Feb 2 14:06:21 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Feb 2 14:06:33 2009 Subject: svn commit: r188033 - head/sys/dev/cardbus Message-ID: <200902022206.n12M6KPD008847@svn.freebsd.org> Author: jhb Date: Mon Feb 2 22:06:20 2009 New Revision: 188033 URL: http://svn.freebsd.org/changeset/base/188033 Log: Goof, catch up to constant rename (I renamed it to match the overall PCI style of having register offsets start with PCIR_* rather than PCI_*). Submitted by: rss Modified: head/sys/dev/cardbus/cardbus.c Modified: head/sys/dev/cardbus/cardbus.c ============================================================================== --- head/sys/dev/cardbus/cardbus.c Mon Feb 2 22:04:40 2009 (r188032) +++ head/sys/dev/cardbus/cardbus.c Mon Feb 2 22:06:20 2009 (r188033) @@ -143,7 +143,7 @@ cardbus_device_setup_regs(pcicfgregs *cf * Some cards power up with garbage in their BARs. This * code clears all that junk out. */ - for (i = 0; i < PCI_MAX_BAR_0; i++) + for (i = 0; i < PCIR_MAX_BAR_0; i++) pci_write_config(dev, PCIR_BAR(i), 0, 4); cfg->intline = From kmacy at FreeBSD.org Mon Feb 2 15:04:21 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Mon Feb 2 15:04:32 2009 Subject: svn commit: r188036 - head/sys/dev/xen/netfront Message-ID: <200902022304.n12N4KGJ010210@svn.freebsd.org> Author: kmacy Date: Mon Feb 2 23:04:20 2009 New Revision: 188036 URL: http://svn.freebsd.org/changeset/base/188036 Log: break out of loop if we run out of mbufs Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Mon Feb 2 22:18:48 2009 (r188035) +++ head/sys/dev/xen/netfront/netfront.c Mon Feb 2 23:04:20 2009 (r188036) @@ -1234,11 +1234,12 @@ xennet_get_responses(struct netfront_inf gnttab_release_grant_reference(&np->gref_rx_head, ref); next: - if (m != NULL) { - m->m_len = rx->status; - m->m_data += rx->offset; - m0->m_pkthdr.len += rx->status; - } + if (m == NULL) + break; + + m->m_len = rx->status; + m->m_data += rx->offset; + m0->m_pkthdr.len += rx->status; if (!(rx->flags & NETRXF_more_data)) break; From jhb at freebsd.org Mon Feb 2 15:09:54 2009 From: jhb at freebsd.org (John Baldwin) Date: Mon Feb 2 15:10:01 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf In-Reply-To: <1233608975.1492.45.camel@ferret.2hip.net> References: <200902021954.n12JsGT2005768@svn.freebsd.org> <200902021554.55644.jhb@freebsd.org> <1233608975.1492.45.camel@ferret.2hip.net> Message-ID: <200902021659.54847.jhb@freebsd.org> On Monday 02 February 2009 4:09:35 pm Robert Noland wrote: > On Mon, 2009-02-02 at 15:54 -0500, John Baldwin wrote: > > On Monday 02 February 2009 2:54:16 pm John Baldwin wrote: > > > Author: jhb > > > Date: Mon Feb 2 19:54:16 2009 > > > New Revision: 188018 > > > URL: http://svn.freebsd.org/changeset/base/188018 > > > > > > Log: > > > - Add a new ioctl to /dev/pci to fetch details on an individual BAR of a > > > device. The details include the current value of the BAR (including all > > > the flag bits and the current base address), its length, and whether or not > > > it is enabled. Since this operation is not invasive, non-root users are > > > allowed to use it (unlike manual config register access which requires > > > root). The intention is that userland apps (such as Xorg) will use this > > > interface rather than dangerously frobbing the BARs from userland to > > > obtain this information. > > > - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when used > > > with -l will now list all the active BARs for each device. > > > > > > MFC after: 1 month > > > > As with the capability messages, I attempted to make the bar messages match > > the output of a verbose dmesg. An example: > > > > igb0@pci0:8:0:0: class=0x020000 card=0x10a715d9 chip=0x10a78086 rev=0x02 hdr=0x00 > > vendor = 'Intel Corporation' > > class = network > > subclass = ethernet > > bar [10] = type Memory, range 32, base 0xda020000, size 131072, enabled > > bar [14] = type Memory, range 32, base 0xda000000, size 131072, enabled > > bar [18] = type I/O Port, range 32, base 0x3000, size 32, enabled > > bar [1c] = type Memory, range 32, base 0xda080000, size 16384, enabled > > cap 01[40] = powerspec 2 supports D0 D3 current D0 > > cap 05[50] = MSI supports 1 message, 64 bit > > cap 11[60] = MSI-X supports 10 messages in map 0x1c enabled > > cap 10[a0] = PCI-Express 2 endpoint > > I haven't looked this over thoroughly yet, but will it support BIOS > mappings as well? Or should I take a crack at adding that? It does not handle the BIOS BAR. If we need to we can either extend this or add a new ioctl for that. However, if X is just reading the current setting then what it is doing now may be fine. I will try to look at the current code for that in a bit. -- John Baldwin From rnoland at FreeBSD.org Mon Feb 2 15:21:30 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Feb 2 15:21:36 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf In-Reply-To: <200902021659.54847.jhb@freebsd.org> References: <200902021954.n12JsGT2005768@svn.freebsd.org> <200902021554.55644.jhb@freebsd.org> <1233608975.1492.45.camel@ferret.2hip.net> <200902021659.54847.jhb@freebsd.org> Message-ID: <1233616882.1492.68.camel@ferret.2hip.net> On Mon, 2009-02-02 at 16:59 -0500, John Baldwin wrote: > On Monday 02 February 2009 4:09:35 pm Robert Noland wrote: > > On Mon, 2009-02-02 at 15:54 -0500, John Baldwin wrote: > > > On Monday 02 February 2009 2:54:16 pm John Baldwin wrote: > > > > Author: jhb > > > > Date: Mon Feb 2 19:54:16 2009 > > > > New Revision: 188018 > > > > URL: http://svn.freebsd.org/changeset/base/188018 > > > > > > > > Log: > > > > - Add a new ioctl to /dev/pci to fetch details on an individual BAR of > a > > > > device. The details include the current value of the BAR (including > all > > > > the flag bits and the current base address), its length, and whether > or not > > > > it is enabled. Since this operation is not invasive, non-root users > are > > > > allowed to use it (unlike manual config register access which > requires > > > > root). The intention is that userland apps (such as Xorg) will use > this > > > > interface rather than dangerously frobbing the BARs from userland to > > > > obtain this information. > > > > - Add a new sub-mode to the 'list' mode of pciconf. The -b flag when > used > > > > with -l will now list all the active BARs for each device. > > > > > > > > MFC after: 1 month > > > > > > As with the capability messages, I attempted to make the bar messages > match > > > the output of a verbose dmesg. An example: > > > > > > igb0@pci0:8:0:0: class=0x020000 card=0x10a715d9 chip=0x10a78086 > rev=0x02 hdr=0x00 > > > vendor = 'Intel Corporation' > > > class = network > > > subclass = ethernet > > > bar [10] = type Memory, range 32, base 0xda020000, size 131072, > enabled > > > bar [14] = type Memory, range 32, base 0xda000000, size 131072, > enabled > > > bar [18] = type I/O Port, range 32, base 0x3000, size 32, enabled > > > bar [1c] = type Memory, range 32, base 0xda080000, size 16384, > enabled > > > cap 01[40] = powerspec 2 supports D0 D3 current D0 > > > cap 05[50] = MSI supports 1 message, 64 bit > > > cap 11[60] = MSI-X supports 10 messages in map 0x1c enabled > > > cap 10[a0] = PCI-Express 2 endpoint > > > > I haven't looked this over thoroughly yet, but will it support BIOS > > mappings as well? Or should I take a crack at adding that? > > It does not handle the BIOS BAR. If we need to we can either extend this or > add a new ioctl for that. However, if X is just reading the current setting > then what it is doing now may be fine. I will try to look at the current > code for that in a bit. Right now, X wants to know if a pci bios BAR exists, what size it is and what the base address is. In libpciaccess it then mmaps that region and copies the bios into a buffer which is handed to X. If a pci bios does not exist, it mmaps 0xc0000 x 0x10000 (the standard VGA bios setting). We may not be able to do this as efficiently as I would like unless we implement a way to actually extract the bios contents, as userland would still possibly need a way to set/restore the rom rom enabled bit for copying. robert. -- Robert Noland FreeBSD -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: This is a digitally signed message part Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20090202/48358fad/attachment.pgp From imp at FreeBSD.org Mon Feb 2 16:10:22 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 16:10:29 2009 Subject: svn commit: r188037 - head/sys/kern Message-ID: <200902030010.n130ALGm011551@svn.freebsd.org> Author: imp Date: Tue Feb 3 00:10:21 2009 New Revision: 188037 URL: http://svn.freebsd.org/changeset/base/188037 Log: Declare bus_data_devices to be static: it isn't used elsewhere. Use NULL in a couple of places rather than 0 in the context of pointers to be consistent with the rest of the file. Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Mon Feb 2 23:04:20 2009 (r188036) +++ head/sys/kern/subr_bus.c Tue Feb 3 00:10:21 2009 (r188037) @@ -741,10 +741,10 @@ sysctl_devctl_disable(SYSCTL_HANDLER_ARG /* End of /dev/devctl code */ -TAILQ_HEAD(,device) bus_data_devices; +static TAILQ_HEAD(,device) bus_data_devices; static int bus_data_generation = 1; -kobj_method_t null_methods[] = { +static kobj_method_t null_methods[] = { { 0, 0 } }; @@ -1735,7 +1735,7 @@ device_probe_child(device_t dev, device_ driverlink_t best = NULL; driverlink_t dl; int result, pri = 0; - int hasclass = (child->devclass != 0); + int hasclass = (child->devclass != NULL); GIANT_REQUIRED; @@ -2014,7 +2014,7 @@ device_print_prettyname(device_t dev) { const char *name = device_get_name(dev); - if (name == 0) + if (name == NULL) return (printf("unknown: ")); return (printf("%s%d: ", name, device_get_unit(dev))); } @@ -3842,7 +3842,7 @@ root_bus_module_handler(module_t mod, in static moduledata_t root_bus_mod = { "rootbus", root_bus_module_handler, - 0 + NULL }; DECLARE_MODULE(rootbus, root_bus_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); From delphij at FreeBSD.org Mon Feb 2 16:15:20 2009 From: delphij at FreeBSD.org (Xin LI) Date: Mon Feb 2 16:15:35 2009 Subject: svn commit: r188038 - head/sbin/ifconfig Message-ID: <200902030015.n130FJHh011687@svn.freebsd.org> Author: delphij Date: Tue Feb 3 00:15:19 2009 New Revision: 188038 URL: http://svn.freebsd.org/changeset/base/188038 Log: Use %u instead of %zu when we intend to print integer constant. Modified: head/sbin/ifconfig/ifieee80211.c Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Tue Feb 3 00:10:21 2009 (r188037) +++ head/sbin/ifconfig/ifieee80211.c Tue Feb 3 00:15:19 2009 (r188038) @@ -1023,16 +1023,16 @@ set80211chanlist(const char *val, int d, switch (sscanf(cp, "%u-%u", &first, &last)) { case 1: if (first > IEEE80211_CHAN_MAX) - errx(-1, "channel %u out of range, max %zu", + errx(-1, "channel %u out of range, max %u", first, IEEE80211_CHAN_MAX); setbit(chanlist.ic_channels, first); break; case 2: if (first > IEEE80211_CHAN_MAX) - errx(-1, "channel %u out of range, max %zu", + errx(-1, "channel %u out of range, max %u", first, IEEE80211_CHAN_MAX); if (last > IEEE80211_CHAN_MAX) - errx(-1, "channel %u out of range, max %zu", + errx(-1, "channel %u out of range, max %u", last, IEEE80211_CHAN_MAX); if (first > last) errx(-1, "void channel range, %u > %u", From xcllnt at mac.com Mon Feb 2 17:00:41 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Mon Feb 2 17:00:52 2009 Subject: svn commit: r188017 - head/sbin/geom/core In-Reply-To: <200902021922.n12JMrM8005192@svn.freebsd.org> References: <200902021922.n12JMrM8005192@svn.freebsd.org> Message-ID: <685DBD3A-CE6E-4D0B-80C5-31DA98521200@mac.com> On Feb 2, 2009, at 11:22 AM, Ulf Lilleengen wrote: > - Use a separate pointer to the allocated memory for freeing, as > strsep may > modify the pointer argument passed to it. This triggered an > assert in malloc > when a geom command being run under the livefs environment. Thanks Ulf! -- Marcel Moolenaar xcllnt@mac.com From imp at FreeBSD.org Mon Feb 2 17:17:17 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 17:17:25 2009 Subject: svn commit: r188039 - head/sys/sys Message-ID: <200902030117.n131HHas012859@svn.freebsd.org> Author: imp Date: Tue Feb 3 01:17:17 2009 New Revision: 188039 URL: http://svn.freebsd.org/changeset/base/188039 Log: Use NULL in preference to '0' for pointers. Modified: head/sys/sys/sysctl.h Modified: head/sys/sys/sysctl.h ============================================================================== --- head/sys/sys/sysctl.h Tue Feb 3 00:15:19 2009 (r188038) +++ head/sys/sys/sysctl.h Tue Feb 3 01:17:17 2009 (r188039) @@ -222,7 +222,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e /* This constructs a "raw" MIB oid. */ #define SYSCTL_OID(parent, nbr, name, kind, a1, a2, handler, fmt, descr) \ static struct sysctl_oid sysctl__##parent##_##name = { \ - &sysctl_##parent##_children, { 0 }, nbr, kind, \ + &sysctl_##parent##_children, { NULL }, nbr, kind, \ a1, a2, #name, handler, fmt, 0, __DESCR(descr) }; \ DATA_SET(sysctl_set, sysctl__##parent##_##name) @@ -258,7 +258,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_e #define SYSCTL_ADD_NODE(ctx, parent, nbr, name, access, handler, descr) \ sysctl_add_oid(ctx, parent, nbr, name, CTLTYPE_NODE|(access), \ - 0, 0, handler, "N", __DESCR(descr)) + NULL, 0, handler, "N", __DESCR(descr)) /* Oid for a string. len can be 0 to indicate '\0' termination. */ #define SYSCTL_STRING(parent, nbr, name, access, arg, len, descr) \ From imp at FreeBSD.org Mon Feb 2 17:17:36 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 17:17:47 2009 Subject: svn commit: r188040 - head/sys/sys Message-ID: <200902030117.n131HZDr012899@svn.freebsd.org> Author: imp Date: Tue Feb 3 01:17:34 2009 New Revision: 188040 URL: http://svn.freebsd.org/changeset/base/188040 Log: Use NULL in preference to 0 for pointers. Modified: head/sys/sys/kobj.h Modified: head/sys/sys/kobj.h ============================================================================== --- head/sys/sys/kobj.h Tue Feb 3 01:17:17 2009 (r188039) +++ head/sys/sys/kobj.h Tue Feb 3 01:17:34 2009 (r188040) @@ -114,7 +114,7 @@ DEFINE_CLASS_0(name, name ## _class, met #define DEFINE_CLASS_0(name, classvar, methods, size) \ \ struct kobj_class classvar = { \ - #name, methods, size, 0 \ + #name, methods, size, NULL \ } /* @@ -127,7 +127,7 @@ struct kobj_class classvar = { \ base1) \ \ static kobj_class_t name ## _baseclasses[] = \ - { &base1, 0 }; \ + { &base1, NULL }; \ struct kobj_class classvar = { \ #name, methods, size, name ## _baseclasses \ } @@ -143,7 +143,7 @@ struct kobj_class classvar = { \ \ static kobj_class_t name ## _baseclasses[] = \ { &base1, \ - &base2, 0 }; \ + &base2, NULL }; \ struct kobj_class name ## _class = { \ #name, methods, size, name ## _baseclasses \ } @@ -160,7 +160,7 @@ struct kobj_class name ## _class = { \ static kobj_class_t name ## _baseclasses[] = \ { &base1, \ &base2, \ - &base3, 0 }; \ + &base3, NULL }; \ struct kobj_class name ## _class = { \ #name, methods, size, name ## _baseclasses \ } From kmacy at FreeBSD.org Mon Feb 2 19:43:01 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Mon Feb 2 19:43:07 2009 Subject: svn commit: r188042 - head/sys/i386/xen Message-ID: <200902030343.n133h0LH016110@svn.freebsd.org> Author: kmacy Date: Tue Feb 3 03:43:00 2009 New Revision: 188042 URL: http://svn.freebsd.org/changeset/base/188042 Log: make sure that interrupts are disabled when handling page faults et al Modified: head/sys/i386/xen/xen_machdep.c Modified: head/sys/i386/xen/xen_machdep.c ============================================================================== --- head/sys/i386/xen/xen_machdep.c Tue Feb 3 02:51:57 2009 (r188041) +++ head/sys/i386/xen/xen_machdep.c Tue Feb 3 03:43:00 2009 (r188042) @@ -1130,13 +1130,13 @@ initvalues(start_info_t *startinfo) trap_info_t trap_table[] = { { 0, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(div)}, - { 1, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dbg)}, - { 3, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(bpt)}, + { 1, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dbg)}, + { 3, 3|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(bpt)}, { 4, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(ofl)}, /* This is UPL on Linux and KPL on BSD */ { 5, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(bnd)}, { 6, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(ill)}, - { 7, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dna)}, + { 7, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dna)}, /* * { 8, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(XXX)}, * no handler for double fault @@ -1146,7 +1146,7 @@ trap_info_t trap_table[] = { {11, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(missing)}, {12, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(stk)}, {13, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(prot)}, - {14, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(page)}, + {14, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(page)}, {15, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(rsvd)}, {16, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(fpu)}, {17, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(align)}, From imp at FreeBSD.org Mon Feb 2 20:28:47 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 20:28:59 2009 Subject: svn commit: r188044 - head/sys/dev/mmc Message-ID: <200902030428.n134Skg8017030@svn.freebsd.org> Author: imp Date: Tue Feb 3 04:28:45 2009 New Revision: 188044 URL: http://svn.freebsd.org/changeset/base/188044 Log: o Define some symbols for a few items that are bare constants in the code. o Use NULL in preference to 0 for a few pointers. o default to bus timing normal, like we default to bus_width_1. Modified: head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcreg.h Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Tue Feb 3 03:46:26 2009 (r188043) +++ head/sys/dev/mmc/mmc.c Tue Feb 3 04:28:45 2009 (r188044) @@ -105,9 +105,9 @@ struct mmc_ivars { #define CMD_RETRIES 3 -SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, 0, "mmc driver"); +SYSCTL_NODE(_hw, OID_AUTO, mmc, CTLFLAG_RD, NULL, "mmc driver"); -int mmc_debug; +static int mmc_debug; SYSCTL_INT(_hw_mmc, OID_AUTO, debug, CTLFLAG_RW, &mmc_debug, 0, "Debug level"); /* bus entry points */ @@ -570,7 +570,8 @@ mmc_switch(struct mmc_softc *sc, uint8_t } static int -mmc_sd_switch(struct mmc_softc *sc, uint8_t mode, uint8_t grp, uint8_t value, uint8_t *res) +mmc_sd_switch(struct mmc_softc *sc, uint8_t mode, uint8_t grp, uint8_t value, + uint8_t *res) { int err; struct mmc_command cmd; @@ -578,11 +579,11 @@ mmc_sd_switch(struct mmc_softc *sc, uint memset(&cmd, 0, sizeof(struct mmc_command)); memset(&data, 0, sizeof(struct mmc_data)); - memset(res, 0, 64); + cmd.opcode = SD_SWITCH_FUNC; cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; - cmd.arg = mode << 31; + cmd.arg = mode << 31; /* 0 - check, 1 - set */ cmd.arg |= 0x00FFFFFF; cmd.arg &= ~(0xF << (grp * 4)); cmd.arg |= value << (grp * 4); @@ -656,7 +657,8 @@ mmc_set_timing(struct mmc_softc *sc, int return (MMC_ERR_INVALID); } if (mmcbr_get_mode(sc->dev) == mode_sd) - err = mmc_sd_switch(sc, 1, 0, value, switch_res); + err = mmc_sd_switch(sc, SD_SWITCH_MODE_SET, SD_SWITCH_GROUP1, + value, switch_res); else err = mmc_switch(sc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, value); @@ -1144,6 +1146,7 @@ mmc_discover_cards(struct mmc_softc *sc) if (mmcbr_get_ro(sc->dev)) ivar->read_only = 1; ivar->bus_width = bus_width_1; + ivar->timing = bus_timing_normal; ivar->mode = mmcbr_get_mode(sc->dev); if (ivar->mode == mode_sd) { mmc_decode_cid_sd(ivar->raw_cid, &ivar->cid); @@ -1162,14 +1165,15 @@ mmc_discover_cards(struct mmc_softc *sc) mmc_select_card(sc, ivar->rca); mmc_app_send_scr(sc, ivar->rca, ivar->raw_scr); mmc_app_decode_scr(ivar->raw_scr, &ivar->scr); - /* Get card switch capabilities. */ - ivar->timing = bus_timing_normal; + /* Get card switch capabilities (command class 10). */ if ((ivar->scr.sda_vsn >= 1) && (ivar->csd.ccc & (1<<10))) { - mmc_sd_switch(sc, 0, 0, 0xF, switch_res); + mmc_sd_switch(sc, SD_SWITCH_MODE_CHECK, + SD_SWITCH_GROUP1, SD_SWITCH_NOCHANGE, + switch_res); if (switch_res[13] & 2) { ivar->timing = bus_timing_hs; - ivar->hs_tran_speed = 50000000; + ivar->hs_tran_speed = SD_MAX_HS; } } mmc_app_sd_status(sc, ivar->rca, ivar->raw_sd_status); @@ -1221,10 +1225,10 @@ mmc_discover_cards(struct mmc_softc *sc) ivar->timing = bus_timing_hs; if (ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_52) - ivar->hs_tran_speed = 52000000; + ivar->hs_tran_speed = MMC_TYPE_52_MAX_HS; else if (ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_26) - ivar->hs_tran_speed = 26000000; + ivar->hs_tran_speed = MMC_TYPE_26_MAX_HS; else ivar->hs_tran_speed = ivar->tran_speed; /* Find max supported bus width. */ @@ -1524,5 +1528,5 @@ static driver_t mmc_driver = { static devclass_t mmc_devclass; -DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, 0, 0); -DRIVER_MODULE(mmc, sdhci, mmc_driver, mmc_devclass, 0, 0); +DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, NULL, NULL); +DRIVER_MODULE(mmc, sdhci, mmc_driver, mmc_devclass, NULL, NULL); Modified: head/sys/dev/mmc/mmcreg.h ============================================================================== --- head/sys/dev/mmc/mmcreg.h Tue Feb 3 03:46:26 2009 (r188043) +++ head/sys/dev/mmc/mmcreg.h Tue Feb 3 04:28:45 2009 (r188044) @@ -97,6 +97,7 @@ struct mmc_command { #define MMC_ERR_FAILED 4 #define MMC_ERR_INVALID 5 #define MMC_ERR_NO_MEMORY 6 +#define MMC_ERR_MAX 6 struct mmc_data *data; /* Data segment with cmd */ struct mmc_request *mrq; /* backpointer to request */ }; @@ -287,7 +288,6 @@ struct mmc_request { /* * EXT_CSD fields */ - #define EXT_CSD_ERASE_GRP_DEF 175 /* R/W */ #define EXT_CSD_BUS_WIDTH 183 /* R/W */ #define EXT_CSD_HS_TIMING 185 /* R/W */ @@ -300,7 +300,6 @@ struct mmc_request { /* * EXT_CSD field definitions */ - #define EXT_CSD_CMD_SET_NORMAL 1 #define EXT_CSD_CMD_SET_SECURE 2 #define EXT_CSD_CMD_SET_CPSECURE 4 @@ -312,12 +311,27 @@ struct mmc_request { #define EXT_CSD_BUS_WIDTH_4 1 #define EXT_CSD_BUS_WIDTH_8 2 +#define MMC_TYPE_26_MAX_HS 26000000 +#define MMC_TYPE_52_MAX_HS 52000000 + /* * SD bus widths */ #define SD_BUS_WIDTH_1 0 #define SD_BUS_WIDTH_4 2 +/* + * SD Switch + */ +#define SD_SWITCH_MODE_CHECK 0 +#define SD_SWITCH_MODE_SET 1 +#define SD_SWITCH_GROUP1 0 +#define SD_SWITCH_NORMAL_MODE 0 +#define SD_SWITCH_HS_MODE 1 +#define SD_SWITCH_NOCHANGE 0xF + +#define SD_MAX_HS 50000000 + /* OCR bits */ /* From thompsa at FreeBSD.org Mon Feb 2 21:50:37 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Mon Feb 2 21:50:49 2009 Subject: svn commit: r188048 - in head/sys/dev/usb2: core include quirk Message-ID: <200902030550.n135oapF018660@svn.freebsd.org> Author: thompsa Date: Tue Feb 3 05:50:36 2009 New Revision: 188048 URL: http://svn.freebsd.org/changeset/base/188048 Log: Move away from autogenerated enums, these values never change and its helpful to be able to look them up. Modified: head/sys/dev/usb2/core/usb2_error.c head/sys/dev/usb2/include/usb2_error.h head/sys/dev/usb2/include/usb2_mfunc.h head/sys/dev/usb2/include/usb2_revision.h head/sys/dev/usb2/quirk/usb2_quirk.h Modified: head/sys/dev/usb2/core/usb2_error.c ============================================================================== --- head/sys/dev/usb2/core/usb2_error.c Tue Feb 3 04:37:45 2009 (r188047) +++ head/sys/dev/usb2/core/usb2_error.c Tue Feb 3 05:50:36 2009 (r188048) @@ -29,8 +29,37 @@ #include -USB_MAKE_DEBUG_TABLE(USB_ERR); - +static const char* usb_errstr_table[USB_ERR_MAX] = { + [USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION", + [USB_ERR_BAD_ADDRESS] = "USB_ERR_BAD_ADDRESS", + [USB_ERR_BAD_BUFSIZE] = "USB_ERR_BAD_BUFSIZE", + [USB_ERR_BAD_CONTEXT] = "USB_ERR_BAD_CONTEXT", + [USB_ERR_BAD_FLAG] = "USB_ERR_BAD_FLAG", + [USB_ERR_CANCELLED] = "USB_ERR_CANCELLED", + [USB_ERR_DMA_LOAD_FAILED] = "USB_ERR_DMA_LOAD_FAILED", + [USB_ERR_INTERRUPTED] = "USB_ERR_INTERRUPTED", + [USB_ERR_INVAL] = "USB_ERR_INVAL", + [USB_ERR_IN_USE] = "USB_ERR_IN_USE", + [USB_ERR_IOERROR] = "USB_ERR_IOERROR", + [USB_ERR_NOMEM] = "USB_ERR_NOMEM", + [USB_ERR_NOT_CONFIGURED] = "USB_ERR_NOT_CONFIGURED", + [USB_ERR_NOT_LOCKED] = "USB_ERR_NOT_LOCKED", + [USB_ERR_NOT_STARTED] = "USB_ERR_NOT_STARTED", + [USB_ERR_NO_ADDR] = "USB_ERR_NO_ADDR", + [USB_ERR_NO_CALLBACK] = "USB_ERR_NO_CALLBACK", + [USB_ERR_NO_INTR_THREAD] = "USB_ERR_NO_INTR_THREAD", + [USB_ERR_NO_PIPE] = "USB_ERR_NO_PIPE", + [USB_ERR_NO_POWER] = "USB_ERR_NO_POWER", + [USB_ERR_NO_ROOT_HUB] = "USB_ERR_NO_ROOT_HUB", + [USB_ERR_PENDING_REQUESTS] = "USB_ERR_PENDING_REQUESTS", + [USB_ERR_SET_ADDR_FAILED] = "USB_ERR_SET_ADDR_FAILED", + [USB_ERR_SHORT_XFER] = "USB_ERR_SHORT_XFER", + [USB_ERR_STALLED] = "USB_ERR_STALLED", + [USB_ERR_TIMEOUT] = "USB_ERR_TIMEOUT", + [USB_ERR_TOO_DEEP] = "USB_ERR_TOO_DEEP", + [USB_ERR_ZERO_MAXP] = "USB_ERR_ZERO_MAXP", + [USB_ERR_ZERO_NFRAMES] = "USB_ERR_ZERO_NFRAMES", +}; /*------------------------------------------------------------------------* * usb2_errstr * @@ -39,5 +68,5 @@ USB_MAKE_DEBUG_TABLE(USB_ERR); const char * usb2_errstr(usb2_error_t err) { - return ((err < USB_ERR_MAX) ? USB_ERR[err] : "USB_ERR_UNKNOWN"); + return (err < USB_ERR_MAX ? usb_errstr_table[err] : "USB_ERR_UNKNOWN"); } Modified: head/sys/dev/usb2/include/usb2_error.h ============================================================================== --- head/sys/dev/usb2/include/usb2_error.h Tue Feb 3 04:37:45 2009 (r188047) +++ head/sys/dev/usb2/include/usb2_error.h Tue Feb 3 05:50:36 2009 (r188048) @@ -27,42 +27,37 @@ #ifndef _USB2_ERROR_H_ #define _USB2_ERROR_H_ -/* - * The "USB_STATUS" macro defines all the USB error codes. - * NOTE: "USB_ERR_NORMAL_COMPLETION" is not an error code. - * NOTE: "USB_ERR_STARTING" is not an error code. - */ -#define USB_ERR(m,n)\ -m(n, USB_ERR_NORMAL_COMPLETION)\ -m(n, USB_ERR_PENDING_REQUESTS)\ -m(n, USB_ERR_NOT_STARTED)\ -m(n, USB_ERR_INVAL)\ -m(n, USB_ERR_NOMEM)\ -m(n, USB_ERR_CANCELLED)\ -m(n, USB_ERR_BAD_ADDRESS)\ -m(n, USB_ERR_BAD_BUFSIZE)\ -m(n, USB_ERR_BAD_FLAG)\ -m(n, USB_ERR_NO_CALLBACK)\ -m(n, USB_ERR_IN_USE)\ -m(n, USB_ERR_NO_ADDR)\ -m(n, USB_ERR_NO_PIPE)\ -m(n, USB_ERR_ZERO_NFRAMES)\ -m(n, USB_ERR_ZERO_MAXP)\ -m(n, USB_ERR_SET_ADDR_FAILED)\ -m(n, USB_ERR_NO_POWER)\ -m(n, USB_ERR_TOO_DEEP)\ -m(n, USB_ERR_IOERROR)\ -m(n, USB_ERR_NOT_CONFIGURED)\ -m(n, USB_ERR_TIMEOUT)\ -m(n, USB_ERR_SHORT_XFER)\ -m(n, USB_ERR_STALLED)\ -m(n, USB_ERR_INTERRUPTED)\ -m(n, USB_ERR_DMA_LOAD_FAILED)\ -m(n, USB_ERR_BAD_CONTEXT)\ -m(n, USB_ERR_NO_ROOT_HUB)\ -m(n, USB_ERR_NO_INTR_THREAD)\ -m(n, USB_ERR_NOT_LOCKED)\ - -USB_MAKE_ENUM(USB_ERR); +enum { /* keep in sync with usb_errstr_table */ + USB_ERR_NORMAL_COMPLETION = 0, + USB_ERR_PENDING_REQUESTS, /* 1 */ + USB_ERR_NOT_STARTED, /* 2 */ + USB_ERR_INVAL, /* 3 */ + USB_ERR_NOMEM, /* 4 */ + USB_ERR_CANCELLED, /* 5 */ + USB_ERR_BAD_ADDRESS, /* 6 */ + USB_ERR_BAD_BUFSIZE, /* 7 */ + USB_ERR_BAD_FLAG, /* 8 */ + USB_ERR_NO_CALLBACK, /* 9 */ + USB_ERR_IN_USE, /* 10 */ + USB_ERR_NO_ADDR, /* 11 */ + USB_ERR_NO_PIPE, /* 12 */ + USB_ERR_ZERO_NFRAMES, /* 13 */ + USB_ERR_ZERO_MAXP, /* 14 */ + USB_ERR_SET_ADDR_FAILED, /* 15 */ + USB_ERR_NO_POWER, /* 16 */ + USB_ERR_TOO_DEEP, /* 17 */ + USB_ERR_IOERROR, /* 18 */ + USB_ERR_NOT_CONFIGURED, /* 19 */ + USB_ERR_TIMEOUT, /* 20 */ + USB_ERR_SHORT_XFER, /* 21 */ + USB_ERR_STALLED, /* 22 */ + USB_ERR_INTERRUPTED, /* 23 */ + USB_ERR_DMA_LOAD_FAILED, /* 24 */ + USB_ERR_BAD_CONTEXT, /* 25 */ + USB_ERR_NO_ROOT_HUB, /* 26 */ + USB_ERR_NO_INTR_THREAD, /* 27 */ + USB_ERR_NOT_LOCKED, /* 28 */ + USB_ERR_MAX +}; #endif /* _USB2_ERROR_H_ */ Modified: head/sys/dev/usb2/include/usb2_mfunc.h ============================================================================== --- head/sys/dev/usb2/include/usb2_mfunc.h Tue Feb 3 04:37:45 2009 (r188047) +++ head/sys/dev/usb2/include/usb2_mfunc.h Tue Feb 3 05:50:36 2009 (r188048) @@ -29,14 +29,6 @@ #ifndef _USB2_MFUNC_H_ #define _USB2_MFUNC_H_ -#define USB_MAKE_001(n,ENUM) ENUM, -#define USB_MAKE_ENUM(m) \ -enum { m(USB_MAKE_001,) m##_MAX } - -#define USB_MAKE_002(n,ENUM) #ENUM, -#define USB_MAKE_DEBUG_TABLE(m) \ -static const char * m[m##_MAX] = { m(USB_MAKE_002,) } - #define USB_LOG2(n) ( \ ((x) <= (1<<0x00)) ? 0x00 : \ ((x) <= (1<<0x01)) ? 0x01 : \ Modified: head/sys/dev/usb2/include/usb2_revision.h ============================================================================== --- head/sys/dev/usb2/include/usb2_revision.h Tue Feb 3 04:37:45 2009 (r188047) +++ head/sys/dev/usb2/include/usb2_revision.h Tue Feb 3 05:50:36 2009 (r188048) @@ -27,41 +27,39 @@ #ifndef _USB2_REVISION_H_ #define _USB2_REVISION_H_ -#include - /* * The "USB_SPEED" macro defines all the supported USB speeds. */ -#define USB_SPEED(m,n)\ -m(n, USB_SPEED_VARIABLE)\ -m(n, USB_SPEED_LOW)\ -m(n, USB_SPEED_FULL)\ -m(n, USB_SPEED_HIGH)\ -m(n, USB_SPEED_SUPER)\ - -USB_MAKE_ENUM(USB_SPEED); +enum { + USB_SPEED_VARIABLE, + USB_SPEED_LOW, + USB_SPEED_FULL, + USB_SPEED_HIGH, + USB_SPEED_SUPER, + USB_SPEED_MAX +}; /* * The "USB_REV" macro defines all the supported USB revisions. */ -#define USB_REV(m,n)\ -m(n, USB_REV_UNKNOWN)\ -m(n, USB_REV_PRE_1_0)\ -m(n, USB_REV_1_0)\ -m(n, USB_REV_1_1)\ -m(n, USB_REV_2_0)\ -m(n, USB_REV_2_5)\ -m(n, USB_REV_3_0)\ - -USB_MAKE_ENUM(USB_REV); +enum { + USB_REV_UNKNOWN, + USB_REV_PRE_1_0, + USB_REV_1_0, + USB_REV_1_1, + USB_REV_2_0, + USB_REV_2_5, + USB_REV_3_0, + USB_REV_MAX +}; /* * The "USB_MODE" macro defines all the supported USB modes. */ -#define USB_MODE(m,n)\ -m(n, USB_MODE_HOST)\ -m(n, USB_MODE_DEVICE)\ - -USB_MAKE_ENUM(USB_MODE); +enum { + USB_MODE_HOST, + USB_MODE_DEVICE, + USB_MODE_MAX +}; #endif /* _USB2_REVISION_H_ */ Modified: head/sys/dev/usb2/quirk/usb2_quirk.h ============================================================================== --- head/sys/dev/usb2/quirk/usb2_quirk.h Tue Feb 3 04:37:45 2009 (r188047) +++ head/sys/dev/usb2/quirk/usb2_quirk.h Tue Feb 3 05:50:36 2009 (r188048) @@ -28,56 +28,32 @@ #define _USB2_QUIRK_H_ /* NOTE: UQ_NONE is not a valid quirk */ - -#define USB_QUIRK(m,n) \ - m(n, UQ_NONE) \ - /* left and right sound channels are swapped */ \ - m(n, UQ_AUDIO_SWAP_LR) \ - /* input is async despite claim of adaptive */ \ - m(n, UQ_AU_INP_ASYNC) \ - /* don't adjust for fractional samples */ \ - m(n, UQ_AU_NO_FRAC) \ - /* audio device has broken extension unit */ \ - m(n, UQ_AU_NO_XU) \ - /* bad audio spec version number */ \ - m(n, UQ_BAD_ADC) \ - /* device claims audio class, but isn't */ \ - m(n, UQ_BAD_AUDIO) \ - /* printer has broken bidir mode */ \ - m(n, UQ_BROKEN_BIDIR) \ - /* device is bus powered, despite claim */ \ - m(n, UQ_BUS_POWERED) \ - /* device should be ignored by hid class */ \ - m(n, UQ_HID_IGNORE) \ - /* device should be ignored by kbd class */ \ - m(n, UQ_KBD_IGNORE) \ - /* doesn't identify properly */ \ - m(n, UQ_MS_BAD_CLASS) \ - /* mouse sends an unknown leading byte */ \ - m(n, UQ_MS_LEADING_BYTE) \ - /* mouse has Z-axis reversed */ \ - m(n, UQ_MS_REVZ) \ - /* string descriptors are broken */ \ - m(n, UQ_NO_STRINGS) \ - /* device needs clear endpoint stall */ \ - m(n, UQ_OPEN_CLEARSTALL) \ - /* hub lies about power status */ \ - m(n, UQ_POWER_CLAIM) \ - /* spurious mouse button up events */ \ - m(n, UQ_SPUR_BUT_UP) \ - /* has some Unicode strings swapped */ \ - m(n, UQ_SWAP_UNICODE) \ - /* select configuration index 1 by default */ \ - m(n, UQ_CFG_INDEX_1) \ - /* select configuration index 2 by default */ \ - m(n, UQ_CFG_INDEX_2) \ - /* select configuration index 3 by default */ \ - m(n, UQ_CFG_INDEX_3) \ - /* select configuration index 4 by default */ \ - m(n, UQ_CFG_INDEX_4) \ - /* select configuration index 0 by default */ \ - m(n, UQ_CFG_INDEX_0) - -USB_MAKE_ENUM(USB_QUIRK); +enum { + UQ_NONE, + UQ_AUDIO_SWAP_LR, /* left and right sound channels are swapped */ + UQ_AU_INP_ASYNC, /* input is async despite claim of adaptive */ + UQ_AU_NO_FRAC, /* don't adjust for fractional samples */ + UQ_AU_NO_XU, /* audio device has broken extension unit */ + UQ_BAD_ADC, /* bad audio spec version number */ + UQ_BAD_AUDIO, /* device claims audio class, but isn't */ + UQ_BROKEN_BIDIR, /* printer has broken bidir mode */ + UQ_BUS_POWERED, /* device is bus powered, despite claim */ + UQ_HID_IGNORE, /* device should be ignored by hid class */ + UQ_KBD_IGNORE, /* device should be ignored by kbd class */ + UQ_MS_BAD_CLASS, /* doesn't identify properly */ + UQ_MS_LEADING_BYTE, /* mouse sends an unknown leading byte */ + UQ_MS_REVZ, /* mouse has Z-axis reversed */ + UQ_NO_STRINGS, /* string descriptors are broken */ + UQ_OPEN_CLEARSTALL, /* device needs clear endpoint stall */ + UQ_POWER_CLAIM, /* hub lies about power status */ + UQ_SPUR_BUT_UP, /* spurious mouse button up events */ + UQ_SWAP_UNICODE, /* has some Unicode strings swapped */ + UQ_CFG_INDEX_1, /* select configuration index 1 by default */ + UQ_CFG_INDEX_2, /* select configuration index 2 by default */ + UQ_CFG_INDEX_3, /* select configuration index 3 by default */ + UQ_CFG_INDEX_4, /* select configuration index 4 by default */ + UQ_CFG_INDEX_0, /* select configuration index 0 by default */ + USB_QUIRK_MAX +}; #endif /* _USB2_QUIRK_H_ */ From jkoshy at FreeBSD.org Mon Feb 2 22:12:14 2009 From: jkoshy at FreeBSD.org (Joseph Koshy) Date: Mon Feb 2 22:12:25 2009 Subject: svn commit: r188050 - head/sys/sys Message-ID: <200902030612.n136CDef019150@svn.freebsd.org> Author: jkoshy Date: Tue Feb 3 06:12:13 2009 New Revision: 188050 URL: http://svn.freebsd.org/changeset/base/188050 Log: Introduce a C type representing the header for GNU-style hash table sections. These ELF sections are generated by newer versions of GNU binutils. Reviewed by: kaiw, Ali Bahrami Modified: head/sys/sys/elf_common.h Modified: head/sys/sys/elf_common.h ============================================================================== --- head/sys/sys/elf_common.h Tue Feb 3 06:08:58 2009 (r188049) +++ head/sys/sys/elf_common.h Tue Feb 3 06:12:13 2009 (r188050) @@ -48,6 +48,17 @@ typedef struct { u_int32_t n_type; /* Type of this note. */ } Elf_Note; +/* + * The header for GNU-style hash sections. + */ + +typedef struct { + u_int32_t gh_nbuckets; /* Number of hash buckets. */ + u_int32_t gh_symndx; /* First visible symbol in .dynsym. */ + u_int32_t gh_maskwords; /* #maskwords used in bloom filter. */ + u_int32_t gh_shift2; /* Bloom filter shift count. */ +} Elf_GNU_Hash_Header; + /* Indexes into the e_ident array. Keep synced with http://www.sco.com/developers/gabi/latest/ch4.eheader.html */ #define EI_MAG0 0 /* Magic number, byte 0. */ From marcel at FreeBSD.org Mon Feb 2 23:07:14 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Mon Feb 2 23:07:21 2009 Subject: svn commit: r188054 - head/sys/geom Message-ID: <200902030707.n1377E6Z020377@svn.freebsd.org> Author: marcel Date: Tue Feb 3 07:07:13 2009 New Revision: 188054 URL: http://svn.freebsd.org/changeset/base/188054 Log: In g_handleattr(), set bp->bio_completed also for the case where len is 0. Otherwise g_getattr() will never succeed when it is handled by g_handleattr_str(). Modified: head/sys/geom/geom_subr.c Modified: head/sys/geom/geom_subr.c ============================================================================== --- head/sys/geom/geom_subr.c Tue Feb 3 07:04:10 2009 (r188053) +++ head/sys/geom/geom_subr.c Tue Feb 3 07:07:13 2009 (r188054) @@ -882,12 +882,13 @@ g_handleattr(struct bio *bp, const char } } else if (bp->bio_length == len) { bcopy(val, bp->bio_data, len); - bp->bio_completed = len; } else { printf("%s: %s bio_length %jd len %d -> EFAULT\n", __func__, bp->bio_to->name, (intmax_t)bp->bio_length, len); error = EFAULT; } + if (error == 0) + bp->bio_completed = bp->bio_length; g_io_deliver(bp, error); return (1); } From imp at bsdimp.com Mon Feb 2 23:42:15 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Mon Feb 2 23:42:21 2009 Subject: svn commit: r188018 - in head: sys/dev/pci usr.sbin/pciconf In-Reply-To: <200902021659.54847.jhb@freebsd.org> References: <200902021554.55644.jhb@freebsd.org> <1233608975.1492.45.camel@ferret.2hip.net> <200902021659.54847.jhb@freebsd.org> Message-ID: <20090203.003939.-579111975.imp@bsdimp.com> In message: <200902021659.54847.jhb@freebsd.org> John Baldwin writes: On Mon, 2009-02-02 at 15:54 -0500, John Baldwin wrote: jhb> I haven't looked this over thoroughly yet, but will it support BIOS jhb> mappings as well? Or should I take a crack at adding that? On Monday 02 February 2009 4:09:35 pm Robert Noland wrote: rnoland> It does not handle the BIOS BAR. If we need to we can either rnoland> extend this or add a new ioctl for that. However, if X is rnoland> just reading the current setting then what it is doing now rnoland> may be fine. I will try to look at the current code for that rnoland> in a bit. The BIOS BAR is special. Very special in a number of ways... Be careful probing it. I run into trouble whenever I touch the cardbus CIS parsing code. Warner From imp at FreeBSD.org Mon Feb 2 23:50:07 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:50:13 2009 Subject: svn commit: r188055 - head/sys/kern Message-ID: <200902030750.n137o104021165@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:50:01 2009 New Revision: 188055 URL: http://svn.freebsd.org/changeset/base/188055 Log: int foo(void) is the proper ANSI function definition when there's no parameters. Use it for resettodr(). Modified: head/sys/kern/subr_rtc.c Modified: head/sys/kern/subr_rtc.c ============================================================================== --- head/sys/kern/subr_rtc.c Tue Feb 3 07:07:13 2009 (r188054) +++ head/sys/kern/subr_rtc.c Tue Feb 3 07:50:01 2009 (r188055) @@ -154,7 +154,7 @@ inittodr(time_t base) * Write system time back to RTC */ void -resettodr() +resettodr(void) { struct timespec ts; int error; From imp at FreeBSD.org Mon Feb 2 23:50:42 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:50:54 2009 Subject: svn commit: r188056 - head/sys/kern Message-ID: <200902030750.n137ofUH021214@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:50:41 2009 New Revision: 188056 URL: http://svn.freebsd.org/changeset/base/188056 Log: o Use unsigned for bit fields. o Use NULL for pointers in preference to 0. Modified: head/sys/kern/subr_witness.c Modified: head/sys/kern/subr_witness.c ============================================================================== --- head/sys/kern/subr_witness.c Tue Feb 3 07:50:01 2009 (r188055) +++ head/sys/kern/subr_witness.c Tue Feb 3 07:50:41 2009 (r188056) @@ -235,8 +235,8 @@ struct witness { uint16_t w_num_descendants; /* direct/indirect * descendant count */ int16_t w_ddb_level; - int w_displayed:1; - int w_reversed:1; + unsigned w_displayed:1; + unsigned w_reversed:1; }; STAILQ_HEAD(witness_list, witness); @@ -376,7 +376,7 @@ static void witness_setflag(struct lock_ #define witness_debugger(c) #endif -SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, 0, "Witness Locking"); +SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, NULL, "Witness Locking"); /* * If set to 0, lock order checking is disabled. If set to -1, From imp at FreeBSD.org Mon Feb 2 23:51:12 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:51:23 2009 Subject: svn commit: r188057 - head/sys/kern Message-ID: <200902030751.n137pBEu021261@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:51:11 2009 New Revision: 188057 URL: http://svn.freebsd.org/changeset/base/188057 Log: Use NULL in preference to 0 for pointers. Modified: head/sys/kern/subr_firmware.c head/sys/kern/subr_prf.c Modified: head/sys/kern/subr_firmware.c ============================================================================== --- head/sys/kern/subr_firmware.c Tue Feb 3 07:50:41 2009 (r188056) +++ head/sys/kern/subr_firmware.c Tue Feb 3 07:51:11 2009 (r188057) @@ -525,7 +525,7 @@ firmware_modevent(module_t mod, int type static moduledata_t firmware_mod = { "firmware", firmware_modevent, - 0 + NULL }; DECLARE_MODULE(firmware, firmware_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST); MODULE_VERSION(firmware, 1); Modified: head/sys/kern/subr_prf.c ============================================================================== --- head/sys/kern/subr_prf.c Tue Feb 3 07:50:41 2009 (r188056) +++ head/sys/kern/subr_prf.c Tue Feb 3 07:51:11 2009 (r188057) @@ -959,7 +959,7 @@ sysctl_kern_msgbuf(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_kern, OID_AUTO, msgbuf, CTLTYPE_STRING | CTLFLAG_RD, - 0, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer"); + NULL, 0, sysctl_kern_msgbuf, "A", "Contents of kernel message buffer"); static int msgbuf_clearflag; From imp at FreeBSD.org Mon Feb 2 23:51:43 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:51:54 2009 Subject: svn commit: r188058 - head/sys/kern Message-ID: <200902030751.n137pgMY021308@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:51:41 2009 New Revision: 188058 URL: http://svn.freebsd.org/changeset/base/188058 Log: Use NULL in preference to 0 for pointers. Modified: head/sys/kern/subr_clist.c head/sys/kern/subr_taskqueue.c Modified: head/sys/kern/subr_clist.c ============================================================================== --- head/sys/kern/subr_clist.c Tue Feb 3 07:51:11 2009 (r188057) +++ head/sys/kern/subr_clist.c Tue Feb 3 07:51:41 2009 (r188058) @@ -43,7 +43,7 @@ SYSINIT(clist, SI_SUB_CLIST, SI_ORDER_FI static MALLOC_DEFINE(M_CLIST, "clist", "clist queue blocks"); -static struct cblock *cfreelist = 0; +static struct cblock *cfreelist = NULL; int cfreecount = 0; static int cslushcount; static int ctotcount; @@ -478,7 +478,7 @@ b_to_q(char *src, int amount, struct cli int unputc(struct clist *clistp) { - struct cblock *cblockp = 0, *cbp = 0; + struct cblock *cblockp = NULL, *cbp = NULL; int s; int chr = -1; Modified: head/sys/kern/subr_taskqueue.c ============================================================================== --- head/sys/kern/subr_taskqueue.c Tue Feb 3 07:51:11 2009 (r188057) +++ head/sys/kern/subr_taskqueue.c Tue Feb 3 07:51:41 2009 (r188058) @@ -114,7 +114,7 @@ _taskqueue_create(const char *name, int queue = malloc(sizeof(struct taskqueue), M_TASKQUEUE, mflags | M_ZERO); if (!queue) - return 0; + return NULL; STAILQ_INIT(&queue->tq_queue); queue->tq_name = name; @@ -213,7 +213,7 @@ taskqueue_enqueue(struct taskqueue *queu if (!prev || prev->ta_priority >= task->ta_priority) { STAILQ_INSERT_TAIL(&queue->tq_queue, task, ta_link); } else { - prev = 0; + prev = NULL; for (ins = STAILQ_FIRST(&queue->tq_queue); ins; prev = ins, ins = STAILQ_NEXT(ins, ta_link)) if (ins->ta_priority < task->ta_priority) @@ -423,11 +423,11 @@ taskqueue_thread_enqueue(void *context) wakeup_one(tq); } -TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, 0, +TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL, swi_add(NULL, "task queue", taskqueue_swi_run, NULL, SWI_TQ, INTR_MPSAFE, &taskqueue_ih)); -TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, 0, +TASKQUEUE_DEFINE(swi_giant, taskqueue_swi_giant_enqueue, NULL, swi_add(NULL, "Giant taskq", taskqueue_swi_giant_run, NULL, SWI_TQ_GIANT, 0, &taskqueue_giant_ih)); @@ -462,6 +462,6 @@ taskqueue_fast_run(void *dummy) taskqueue_run(taskqueue_fast); } -TASKQUEUE_FAST_DEFINE(fast, taskqueue_fast_enqueue, 0, +TASKQUEUE_FAST_DEFINE(fast, taskqueue_fast_enqueue, NULL, swi_add(NULL, "Fast task queue", taskqueue_fast_run, NULL, SWI_TQ_FAST, INTR_MPSAFE, &taskqueue_fast_ih)); From imp at FreeBSD.org Mon Feb 2 23:52:08 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:52:20 2009 Subject: svn commit: r188059 - head/sys/kern Message-ID: <200902030752.n137q7SN021354@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:52:07 2009 New Revision: 188059 URL: http://svn.freebsd.org/changeset/base/188059 Log: Prefer ANSI function definitions to K&R ones. Modified: head/sys/kern/subr_autoconf.c Modified: head/sys/kern/subr_autoconf.c ============================================================================== --- head/sys/kern/subr_autoconf.c Tue Feb 3 07:51:41 2009 (r188058) +++ head/sys/kern/subr_autoconf.c Tue Feb 3 07:52:07 2009 (r188059) @@ -91,8 +91,7 @@ run_interrupt_driven_config_hooks_warnin } static void -run_interrupt_driven_config_hooks(dummy) - void *dummy; +run_interrupt_driven_config_hooks(void *dummy) { struct intr_config_hook *hook_entry, *next_entry; int warned; @@ -127,8 +126,7 @@ SYSINIT(intr_config_hooks, SI_SUB_INT_CO * be used to complete initialization. */ int -config_intrhook_establish(hook) - struct intr_config_hook *hook; +config_intrhook_establish(struct intr_config_hook *hook) { struct intr_config_hook *hook_entry; @@ -151,8 +149,7 @@ config_intrhook_establish(hook) } void -config_intrhook_disestablish(hook) - struct intr_config_hook *hook; +config_intrhook_disestablish(struct intr_config_hook *hook) { struct intr_config_hook *hook_entry; From imp at FreeBSD.org Mon Feb 2 23:52:38 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:52:43 2009 Subject: svn commit: r188060 - head/sys/kern Message-ID: <200902030752.n137qalg021400@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:52:36 2009 New Revision: 188060 URL: http://svn.freebsd.org/changeset/base/188060 Log: Use ANSI function definition for profil. Modified: head/sys/kern/subr_prof.c Modified: head/sys/kern/subr_prof.c ============================================================================== --- head/sys/kern/subr_prof.c Tue Feb 3 07:52:07 2009 (r188059) +++ head/sys/kern/subr_prof.c Tue Feb 3 07:52:36 2009 (r188060) @@ -404,9 +404,7 @@ struct profil_args { #endif /* ARGSUSED */ int -profil(td, uap) - struct thread *td; - register struct profil_args *uap; +profil(struct thread *td, struct profil_args *uap) { struct uprof *upp; struct proc *p; From imp at FreeBSD.org Mon Feb 2 23:53:09 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:53:15 2009 Subject: svn commit: r188061 - head/sys/kern Message-ID: <200902030753.n137r8jI021448@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:53:08 2009 New Revision: 188061 URL: http://svn.freebsd.org/changeset/base/188061 Log: rman_debug should be static, so make it static. Modified: head/sys/kern/subr_rman.c Modified: head/sys/kern/subr_rman.c ============================================================================== --- head/sys/kern/subr_rman.c Tue Feb 3 07:52:36 2009 (r188060) +++ head/sys/kern/subr_rman.c Tue Feb 3 07:53:08 2009 (r188061) @@ -99,7 +99,7 @@ struct resource_i { int r_rid; /* optional rid for this resource. */ }; -int rman_debug = 0; +static int rman_debug = 0; TUNABLE_INT("debug.rman_debug", &rman_debug); SYSCTL_INT(_debug, OID_AUTO, rman_debug, CTLFLAG_RW, &rman_debug, 0, "rman debug"); From imp at FreeBSD.org Mon Feb 2 23:53:52 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:54:03 2009 Subject: svn commit: r188062 - head/sys/kern Message-ID: <200902030753.n137rp0A021504@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:53:51 2009 New Revision: 188062 URL: http://svn.freebsd.org/changeset/base/188062 Log: Make bioq_disksort have a ANSI-C definition rather than a K&R definition. Modified: head/sys/kern/subr_disk.c Modified: head/sys/kern/subr_disk.c ============================================================================== --- head/sys/kern/subr_disk.c Tue Feb 3 07:53:08 2009 (r188061) +++ head/sys/kern/subr_disk.c Tue Feb 3 07:53:51 2009 (r188062) @@ -144,9 +144,7 @@ bioq_takefirst(struct bio_queue_head *he * This implements the one-way scan which optimizes disk seek times. */ void -bioq_disksort(bioq, bp) - struct bio_queue_head *bioq; - struct bio *bp; +bioq_disksort(struct bio_queue_head *bioq, struct bio *bp) { struct bio *bq; struct bio *bn; From imp at FreeBSD.org Mon Feb 2 23:54:43 2009 From: imp at FreeBSD.org (Warner Losh) Date: Mon Feb 2 23:54:49 2009 Subject: svn commit: r188063 - head/sys/kern Message-ID: <200902030754.n137sg9g021561@svn.freebsd.org> Author: imp Date: Tue Feb 3 07:54:42 2009 New Revision: 188063 URL: http://svn.freebsd.org/changeset/base/188063 Log: Use NULL in preference to 0 in pointer contexts. Modified: head/sys/kern/subr_devstat.c head/sys/kern/subr_kobj.c Modified: head/sys/kern/subr_devstat.c ============================================================================== --- head/sys/kern/subr_devstat.c Tue Feb 3 07:53:51 2009 (r188062) +++ head/sys/kern/subr_devstat.c Tue Feb 3 07:54:42 2009 (r188063) @@ -407,10 +407,10 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS) * Sysctl entries for devstat. The first one is a node that all the rest * hang off of. */ -SYSCTL_NODE(_kern, OID_AUTO, devstat, CTLFLAG_RD, 0, "Device Statistics"); +SYSCTL_NODE(_kern, OID_AUTO, devstat, CTLFLAG_RD, NULL, "Device Statistics"); SYSCTL_PROC(_kern_devstat, OID_AUTO, all, CTLFLAG_RD|CTLTYPE_OPAQUE, - 0, 0, sysctl_devstat, "S,devstat", "All devices in the devstat list"); + NULL, 0, sysctl_devstat, "S,devstat", "All devices in the devstat list"); /* * Export the number of devices in the system so that userland utilities * can determine how much memory to allocate to hold all the devices. @@ -534,4 +534,4 @@ devstat_free(struct devstat *dsp) } SYSCTL_INT(_debug_sizeof, OID_AUTO, devstat, CTLFLAG_RD, - 0, sizeof(struct devstat), "sizeof(struct devstat)"); + NULL, sizeof(struct devstat), "sizeof(struct devstat)"); Modified: head/sys/kern/subr_kobj.c ============================================================================== --- head/sys/kern/subr_kobj.c Tue Feb 3 07:53:51 2009 (r188062) +++ head/sys/kern/subr_kobj.c Tue Feb 3 07:54:42 2009 (r188063) @@ -207,7 +207,7 @@ kobj_lookup_method_class(kobj_class_t cl } } - return 0; + return NULL; } static kobj_method_t* @@ -230,7 +230,7 @@ kobj_lookup_method_mi(kobj_class_t cls, } } - return 0; + return NULL; } kobj_method_t* @@ -261,7 +261,7 @@ kobj_class_free(kobj_class_t cls) { int i; kobj_method_t *m; - void* ops = 0; + void* ops = NULL; KOBJ_ASSERT(MA_NOTOWNED); KOBJ_LOCK(); @@ -281,7 +281,7 @@ kobj_class_free(kobj_class_t cls) * Free memory and clean up. */ ops = cls->ops; - cls->ops = 0; + cls->ops = NULL; } KOBJ_UNLOCK(); @@ -302,7 +302,7 @@ kobj_create(kobj_class_t cls, */ obj = malloc(cls->size, mtype, mflags | M_ZERO); if (!obj) - return 0; + return NULL; kobj_init(obj, cls); return obj; @@ -355,7 +355,7 @@ kobj_delete(kobj_t obj, struct malloc_ty if (!refs) kobj_class_free(cls); - obj->ops = 0; + obj->ops = NULL; if (mtype) free(obj, mtype); } From jkoshy at FreeBSD.org Tue Feb 3 01:01:46 2009 From: jkoshy at FreeBSD.org (Joseph Koshy) Date: Tue Feb 3 01:01:53 2009 Subject: svn commit: r188065 - in head/sys/amd64: amd64 include Message-ID: <200902030901.n1391jl6023007@svn.freebsd.org> Author: jkoshy Date: Tue Feb 3 09:01:45 2009 New Revision: 188065 URL: http://svn.freebsd.org/changeset/base/188065 Log: Improve robustness of NMI handling, for NMIs recognized in kernel mode. - Make the NMI handler run on its own stack (TSS_IST2). - Store the GSBASE value for each CPU just before the start of each NMI stack, permitting efficient retrieval using %rsp-relative addressing. - For NMIs taken from kernel mode, program MSR_GSBASE explicitly since one or both of MSR_GSBASE and MSR_KGSBASE can be potentially invalid. The current contents of MSR_GSBASE are saved and restored at exit. - For NMIs handled from user mode, continue to use 'swapgs' to load the per-CPU GSBASE. Reviewed by: jeff Debugging help: jeff Tested by: gnn, Artem Belevich Modified: head/sys/amd64/amd64/exception.S head/sys/amd64/amd64/machdep.c head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/intr_machdep.h Modified: head/sys/amd64/amd64/exception.S ============================================================================== --- head/sys/amd64/amd64/exception.S Tue Feb 3 08:25:24 2009 (r188064) +++ head/sys/amd64/amd64/exception.S Tue Feb 3 09:01:45 2009 (r188065) @@ -383,22 +383,24 @@ IDTVEC(fast_syscall32) * NMI handling is special. * * First, NMIs do not respect the state of the processor's RFLAGS.IF - * bit and the NMI handler may be invoked at any time, including when - * the processor is in a critical section with RFLAGS.IF == 0. In - * particular, this means that the processor's GS.base values could be - * inconsistent on entry to the handler, and so we need to read - * MSR_GSBASE to determine if a 'swapgs' is needed. We use '%ebx', a - * C-preserved register, to remember whether to swap GS back on the - * exit path. + * bit. The NMI handler may be entered at any time, including when + * the processor is in a critical section with RFLAGS.IF == 0. + * The processor's GS.base value could be invalid on entry to the + * handler. * * Second, the processor treats NMIs specially, blocking further NMIs - * until an 'iretq' instruction is executed. We therefore need to - * execute the NMI handler with interrupts disabled to prevent a - * nested interrupt from executing an 'iretq' instruction and - * inadvertently taking the processor out of NMI mode. + * until an 'iretq' instruction is executed. We thus need to execute + * the NMI handler with interrupts disabled, to prevent a nested interrupt + * from executing an 'iretq' instruction and inadvertently taking the + * processor out of NMI mode. * - * Third, the NMI handler runs on its own stack (tss_ist1), shared - * with the double fault handler. + * Third, the NMI handler runs on its own stack (tss_ist2). The canonical + * GS.base value for the processor is stored just above the bottom of its + * NMI stack. For NMIs taken from kernel mode, the current value in + * the processor's GS.base is saved at entry to C-preserved register %r12, + * the canonical value for GS.base is then loaded into the processor, and + * the saved value is restored at exit time. For NMIs taken from user mode, + * the cheaper 'SWAPGS' instructions are used for swapping GS.base. */ IDTVEC(nmi) @@ -423,12 +425,22 @@ IDTVEC(nmi) movq %r15,TF_R15(%rsp) xorl %ebx,%ebx testb $SEL_RPL_MASK,TF_CS(%rsp) - jnz nmi_needswapgs /* we came from userland */ + jnz nmi_fromuserspace + /* + * We've interrupted the kernel. Preserve GS.base in %r12. + */ movl $MSR_GSBASE,%ecx rdmsr - cmpl $VM_MAXUSER_ADDRESS >> 32,%edx - jae nmi_calltrap /* GS.base holds a kernel VA */ -nmi_needswapgs: + movq %rax,%r12 + shlq $32,%rdx + orq %rdx,%r12 + /* Retrieve and load the canonical value for GS.base. */ + movq TF_SIZE(%rsp),%rdx + movl %edx,%eax + shrq $32,%rdx + wrmsr + jmp nmi_calltrap +nmi_fromuserspace: incl %ebx swapgs /* Note: this label is also used by ddb and gdb: */ @@ -439,14 +451,19 @@ nmi_calltrap: MEXITCOUNT #ifdef HWPMC_HOOKS /* - * Check if the current trap was from user mode and if so - * whether the current thread needs a user call chain to be - * captured. We are still in NMI mode at this point. + * Capture a userspace callchain if needed. + * + * - Check if the current trap was from user mode. + * - Check if the current thread is valid. + * - Check if the thread requires a user call chain to be + * captured. + * + * We are still in NMI mode at this point. */ - testb $SEL_RPL_MASK,TF_CS(%rsp) - jz nocallchain - movq PCPU(CURTHREAD),%rax /* curthread present? */ - orq %rax,%rax + testl %ebx,%ebx + jz nocallchain /* not from userspace */ + movq PCPU(CURTHREAD),%rax + orq %rax,%rax /* curthread present? */ jz nocallchain testl $TDP_CALLCHAIN,TD_PFLAGS(%rax) /* flagged for capture? */ jz nocallchain @@ -498,8 +515,18 @@ outofnmi: nocallchain: #endif testl %ebx,%ebx - jz nmi_restoreregs + jz nmi_kernelexit swapgs + jmp nmi_restoreregs +nmi_kernelexit: + /* + * Put back the preserved MSR_GSBASE value. + */ + movl $MSR_GSBASE,%ecx + movq %r12,%rdx + movl %edx,%eax + shrq $32,%rdx + wrmsr nmi_restoreregs: movq TF_RDI(%rsp),%rdi movq TF_RSI(%rsp),%rsi Modified: head/sys/amd64/amd64/machdep.c ============================================================================== --- head/sys/amd64/amd64/machdep.c Tue Feb 3 08:25:24 2009 (r188064) +++ head/sys/amd64/amd64/machdep.c Tue Feb 3 09:01:45 2009 (r188065) @@ -809,6 +809,9 @@ struct gate_descriptor *idt = &idt0[0]; static char dblfault_stack[PAGE_SIZE] __aligned(16); +static char nmi0_stack[PAGE_SIZE] __aligned(16); +CTASSERT(sizeof(struct nmi_pcpu) == 16); + struct amd64tss common_tss[MAXCPU]; /* software prototypes -- in more palatable form */ @@ -1291,6 +1294,7 @@ hammer_time(u_int64_t modulep, u_int64_t caddr_t kmdp; int gsel_tss, x; struct pcpu *pc; + struct nmi_pcpu *np; u_int64_t msr; char *env; @@ -1365,7 +1369,7 @@ hammer_time(u_int64_t modulep, u_int64_t setidt(x, &IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_DE, &IDTVEC(div), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_DB, &IDTVEC(dbg), SDT_SYSIGT, SEL_KPL, 0); - setidt(IDT_NMI, &IDTVEC(nmi), SDT_SYSIGT, SEL_KPL, 1); + setidt(IDT_NMI, &IDTVEC(nmi), SDT_SYSIGT, SEL_KPL, 2); setidt(IDT_BP, &IDTVEC(bpt), SDT_SYSIGT, SEL_UPL, 0); setidt(IDT_OF, &IDTVEC(ofl), SDT_SYSIGT, SEL_KPL, 0); setidt(IDT_BR, &IDTVEC(bnd), SDT_SYSIGT, SEL_KPL, 0); @@ -1438,6 +1442,14 @@ hammer_time(u_int64_t modulep, u_int64_t /* doublefault stack space, runs on ist1 */ common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; + /* + * NMI stack, runs on ist2. The pcpu pointer is stored just + * above the start of the ist2 stack. + */ + np = ((struct nmi_pcpu *) &nmi0_stack[sizeof(nmi0_stack)]) - 1; + np->np_pcpu = (register_t) pc; + common_tss[0].tss_ist2 = (long) np; + /* Set the IO permission bitmap (empty due to tss seg limit) */ common_tss[0].tss_iobase = sizeof(struct amd64tss); Modified: head/sys/amd64/amd64/mp_machdep.c ============================================================================== --- head/sys/amd64/amd64/mp_machdep.c Tue Feb 3 08:25:24 2009 (r188064) +++ head/sys/amd64/amd64/mp_machdep.c Tue Feb 3 09:01:45 2009 (r188065) @@ -92,6 +92,7 @@ void *bootstacks[MAXCPU]; /* Temporary holder for double fault stack */ char *doublefault_stack; +char *nmi_stack; /* Hotwire a 0->4MB V==P mapping */ extern pt_entry_t *KPTphys; @@ -437,6 +438,7 @@ void init_secondary(void) { struct pcpu *pc; + struct nmi_pcpu *np; u_int64_t msr, cr0; int cpu, gsel_tss, x; struct region_descriptor ap_gdt; @@ -450,6 +452,10 @@ init_secondary(void) common_tss[cpu].tss_iobase = sizeof(struct amd64tss); common_tss[cpu].tss_ist1 = (long)&doublefault_stack[PAGE_SIZE]; + /* The NMI stack runs on IST2. */ + np = ((struct nmi_pcpu *) &nmi_stack[PAGE_SIZE]) - 1; + common_tss[cpu].tss_ist2 = (long) np; + /* Prepare private GDT */ gdt_segs[GPROC0_SEL].ssd_base = (long) &common_tss[cpu]; ssdtosyssd(&gdt_segs[GPROC0_SEL], @@ -474,6 +480,9 @@ init_secondary(void) pc->pc_rsp0 = 0; pc->pc_gs32p = &gdt[NGDT * cpu + GUGS32_SEL]; + /* Save the per-cpu pointer for use by the NMI handler. */ + np->np_pcpu = (register_t) pc; + wrmsr(MSR_FSBASE, 0); /* User value */ wrmsr(MSR_GSBASE, (u_int64_t)pc); wrmsr(MSR_KGSBASE, (u_int64_t)pc); /* XXX User value while we're in the kernel */ @@ -725,6 +734,7 @@ start_all_aps(void) /* allocate and set up an idle stack data page */ bootstacks[cpu] = (void *)kmem_alloc(kernel_map, KSTACK_PAGES * PAGE_SIZE); doublefault_stack = (char *)kmem_alloc(kernel_map, PAGE_SIZE); + nmi_stack = (char *)kmem_alloc(kernel_map, PAGE_SIZE); bootSTK = (char *)bootstacks[cpu] + KSTACK_PAGES * PAGE_SIZE - 8; bootAP = cpu; Modified: head/sys/amd64/include/intr_machdep.h ============================================================================== --- head/sys/amd64/include/intr_machdep.h Tue Feb 3 08:25:24 2009 (r188064) +++ head/sys/amd64/include/intr_machdep.h Tue Feb 3 09:01:45 2009 (r188065) @@ -120,6 +120,15 @@ struct intsrc { struct trapframe; +/* + * The following data structure holds per-cpu data, and is placed just + * above the top of the space used for the NMI stack. + */ +struct nmi_pcpu { + register_t np_pcpu; + register_t __padding; /* pad to 16 bytes */ +}; + extern struct mtx icu_lock; extern int elcr_found; From rrs at FreeBSD.org Tue Feb 3 03:00:44 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Tue Feb 3 03:00:50 2009 Subject: svn commit: r188066 - in head/sys: dev/xen/netback net netinet Message-ID: <200902031100.n13B0hvp028517@svn.freebsd.org> Author: rrs Date: Tue Feb 3 11:00:43 2009 New Revision: 188066 URL: http://svn.freebsd.org/changeset/base/188066 Log: Adds support for SCTP checksum offload. This means we, like TCP and UDP, move the checksum calculation into the IP routines when there is no hardware support we call into the normal SCTP checksum routine. The next round of SCTP updates will use this functionality. Of course the IGB driver needs a few updates to support the new intel controller set that actually does SCTP csum offload too. Reviewed by: gnn, rwatson, kmacy Modified: head/sys/dev/xen/netback/netback.c head/sys/net/if_ethersubr.c head/sys/netinet/ip_divert.c head/sys/netinet/ip_ipsec.c head/sys/netinet/ip_output.c Modified: head/sys/dev/xen/netback/netback.c ============================================================================== --- head/sys/dev/xen/netback/netback.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/dev/xen/netback/netback.c Tue Feb 3 11:00:43 2009 (r188066) @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_sctp.h" #include #include @@ -57,6 +58,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#include +#endif #include #include @@ -295,6 +300,11 @@ fixup_checksum(struct mbuf *m) htons(IPPROTO_TCP + (iplen - iphlen))); th->th_sum = in_cksum_skip(m, iplen + sizeof(*eh), sizeof(*eh) + iphlen); m->m_pkthdr.csum_flags &= ~CSUM_TCP; +#ifdef SCTP + } else if (sw_csum & CSUM_SCTP) { + sctp_delayed_cksum(m); + sw_csum &= ~CSUM_SCTP; +#endif } else { u_short csum; struct udphdr *uh = (struct udphdr *)((caddr_t)ip + iphlen); @@ -908,7 +918,8 @@ netif_rx(netif_t *netif) #ifdef XEN_NETBACK_FIXUP_CSUM /* Check if we need to compute a checksum. This happens */ /* when bridging from one domain to another. */ - if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA)) + if ((m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) || + (m->m_pkthdr.csum_flags & CSUM_SCTP)) fixup_checksum(m); #endif Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/net/if_ethersubr.c Tue Feb 3 11:00:43 2009 (r188066) @@ -299,6 +299,8 @@ ether_output(struct ifnet *ifp, struct m csum_flags |= (CSUM_IP_CHECKED|CSUM_IP_VALID); if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) csum_flags |= (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + csum_flags |= CSUM_SCTP_VALID; m->m_pkthdr.csum_flags |= csum_flags; m->m_pkthdr.csum_data = 0xffff; return (if_simloop(ifp, m, dst->sa_family, 0)); @@ -339,6 +341,8 @@ ether_output(struct ifnet *ifp, struct m csum_flags |= (CSUM_IP_CHECKED|CSUM_IP_VALID); if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA) csum_flags |= (CSUM_DATA_VALID|CSUM_PSEUDO_HDR); + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + csum_flags |= CSUM_SCTP_VALID; if (m->m_flags & M_BCAST) { struct mbuf *n; Modified: head/sys/netinet/ip_divert.c ============================================================================== --- head/sys/netinet/ip_divert.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_divert.c Tue Feb 3 11:00:43 2009 (r188066) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_ipfw.h" #include "opt_mac.h" +#include "opt_sctp.h" #ifndef INET #error "IPDIVERT requires INET." #endif @@ -76,6 +77,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#endif #include @@ -222,7 +226,14 @@ divert_packet(struct mbuf *m, int incomi m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; ip->ip_len = htons(ip->ip_len); } - +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) { + ip->ip_len = ntohs(ip->ip_len); + sctp_delayed_cksum(m); + m->m_pkthdr.csum_flags &= ~CSUM_SCTP; + ip->ip_len = htons(ip->ip_len); + } +#endif /* * Record receive interface address, if any. * But only for incoming packets. Modified: head/sys/netinet/ip_ipsec.c ============================================================================== --- head/sys/netinet/ip_ipsec.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_ipsec.c Tue Feb 3 11:00:43 2009 (r188066) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ipsec.h" +#include "opt_sctp.h" #include #include @@ -56,6 +57,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#endif #include @@ -328,7 +332,12 @@ ip_ipsec_output(struct mbuf **m, struct in_delayed_cksum(*m); (*m)->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - +#ifdef SCTP + if ((*m)->m_pkthdr.csum_flags & CSUM_SCTP) { + sctp_delayed_cksum(*m); + (*m)->m_pkthdr.csum_flags &= ~CSUM_SCTP; + } +#endif ip->ip_len = htons(ip->ip_len); ip->ip_off = htons(ip->ip_off); Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Tue Feb 3 09:01:45 2009 (r188065) +++ head/sys/netinet/ip_output.c Tue Feb 3 11:00:43 2009 (r188066) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "opt_mac.h" #include "opt_mbuf_stress_test.h" #include "opt_mpath.h" +#include "opt_sctp.h" #include #include @@ -70,6 +71,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef SCTP +#include +#include +#endif #ifdef IPSEC #include @@ -485,7 +490,10 @@ sendit: } m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; - +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; +#endif error = netisr_queue(NETISR_IP, m); goto done; } else @@ -502,6 +510,10 @@ sendit: CSUM_DATA_VALID | CSUM_PSEUDO_HDR; m->m_pkthdr.csum_data = 0xffff; } +#ifdef SCTP + if (m->m_pkthdr.csum_flags & CSUM_SCTP) + m->m_pkthdr.csum_flags |= CSUM_SCTP_VALID; +#endif m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; @@ -536,6 +548,12 @@ passout: in_delayed_cksum(m); sw_csum &= ~CSUM_DELAY_DATA; } +#ifdef SCTP + if (sw_csum & CSUM_SCTP) { + sctp_delayed_cksum(m); + sw_csum &= ~CSUM_SCTP; + } +#endif m->m_pkthdr.csum_flags &= ifp->if_hwassist; /* @@ -670,7 +688,13 @@ ip_fragment(struct ip *ip, struct mbuf * in_delayed_cksum(m0); m0->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - +#ifdef SCTP + if (m0->m_pkthdr.csum_flags & CSUM_SCTP && + (if_hwassist_flags & CSUM_IP_FRAGS) == 0) { + sctp_delayed_cksum(m0); + m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; + } +#endif if (len > PAGE_SIZE) { /* * Fragment large datagrams such that each segment From rrs at FreeBSD.org Tue Feb 3 03:04:04 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Tue Feb 3 03:04:12 2009 Subject: svn commit: r188067 - in head/sys: netinet netinet6 Message-ID: <200902031104.n13B43DG028622@svn.freebsd.org> Author: rrs Date: Tue Feb 3 11:04:03 2009 New Revision: 188067 URL: http://svn.freebsd.org/changeset/base/188067 Log: - Cleanup checksum code. - Prepare for CRC offloading, add MIB counters (RS/MT). - Bugfix: Disable CRC computation for IPv6 addresses with local scope (MT). - Bugfix: Handle close() with SO_LINGER correctly when notifications are generated during the close() call(MT). - Bugfix: Generate DRY event when sender is dry during subscription. Only for 1-to-1 style sockets (RS/MT) - Bugfix: Put vtags for the correct amount of time into time-wait (MT). - Bugfix: Clear vtag entries correctly on expiration (MT). - Bugfix: shutdown() indicates ENOTCONN when called for unconnected 1-to-1 style sockets (MT). - Bugfix: In sctp Auth code (PL). - Add support for devices that support SCTP csum offload (igb). - Add missing sctp_associd to mib sysctl xsctp_tcb structure (RS) Obtained from: With help from Peter Lei and Michael Tuexen Modified: head/sys/netinet/sctp_auth.c head/sys/netinet/sctp_constants.h head/sys/netinet/sctp_crc32.c head/sys/netinet/sctp_crc32.h head/sys/netinet/sctp_input.c head/sys/netinet/sctp_os_bsd.h head/sys/netinet/sctp_output.c head/sys/netinet/sctp_pcb.c head/sys/netinet/sctp_pcb.h head/sys/netinet/sctp_sysctl.c head/sys/netinet/sctp_uio.h head/sys/netinet/sctp_usrreq.c head/sys/netinet/sctputil.c head/sys/netinet/sctputil.h head/sys/netinet6/sctp6_usrreq.c Modified: head/sys/netinet/sctp_auth.c ============================================================================== --- head/sys/netinet/sctp_auth.c Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_auth.c Tue Feb 3 11:04:03 2009 (r188067) @@ -1645,8 +1645,10 @@ sctp_auth_get_cookie_params(struct sctp_ bcopy(p_random->random_data, new_key->key, random_len); } #else - keylen = sizeof(*p_random) + random_len + sizeof(*chunks) + num_chunks + - sizeof(*hmacs) + hmacs_len; + keylen = sizeof(*p_random) + random_len + sizeof(*hmacs) + hmacs_len; + if (chunks != NULL) { + keylen += sizeof(*chunks) + num_chunks; + } new_key = sctp_alloc_key(keylen); if (new_key != NULL) { /* copy in the RANDOM */ Modified: head/sys/netinet/sctp_constants.h ============================================================================== --- head/sys/netinet/sctp_constants.h Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_constants.h Tue Feb 3 11:04:03 2009 (r188067) @@ -37,8 +37,15 @@ __FBSDID("$FreeBSD$"); #define __sctp_constants_h__ /* IANA assigned port number for SCTP over UDP encapsulation */ -#define SCTP_OVER_UDP_TUNNELING_PORT 9899 - +/* For freebsd we cannot bind the port at + * startup. Otherwise what will happen is + * we really won't be bound. The user must + * put it into the sysctl... or we need + * to build a special timer for this to allow + * us to wait 1 second or so after the system + * comes up. + */ +#define SCTP_OVER_UDP_TUNNELING_PORT 0 /* Number of packets to get before sack sent by default */ #define SCTP_DEFAULT_SACK_FREQ 2 @@ -310,10 +317,6 @@ __FBSDID("$FreeBSD$"); #define SCTP_PARTIAL_DELIVERY_SHIFT 1 -/* Minimum number of bytes read by user before we - * condsider doing a rwnd update - */ - /* * default HMAC for cookies, etc... use one of the AUTH HMAC id's * SCTP_HMAC is the HMAC_ID to use @@ -323,21 +326,6 @@ __FBSDID("$FreeBSD$"); #define SCTP_SIGNATURE_SIZE SCTP_AUTH_DIGEST_LEN_SHA1 #define SCTP_SIGNATURE_ALOC_SIZE SCTP_SIGNATURE_SIZE -/* DEFINE HERE WHAT CRC YOU WANT TO USE */ -#define SCTP_USECRC_RFC2960 1 -/* #define SCTP_USECRC_FLETCHER 1 */ -/* #define SCTP_USECRC_SSHCRC32 1 */ -/* #define SCTP_USECRC_FASTCRC32 1 */ -/* #define SCTP_USECRC_CRC32 1 */ -/* #define SCTP_USECRC_TCP32 1 */ -/* #define SCTP_USECRC_CRC16SMAL 1 */ -/* #define SCTP_USECRC_CRC16 1 */ -/* #define SCTP_USECRC_MODADLER 1 */ - -#ifndef SCTP_ADLER32_BASE -#define SCTP_ADLER32_BASE 65521 -#endif - /* * the SCTP protocol signature this includes the version number encoded in * the last 4 bits of the signature. @@ -619,43 +607,16 @@ __FBSDID("$FreeBSD$"); -/* - * Number of ticks before the soxwakeup() event that is delayed is sent AFTER - * the accept() call - */ - -/* - * Of course we really don't collect stale cookies, being folks of decerning - * taste. However we do count them, if we get too many before the association - * comes up.. we give up. Below is the constant that dictates when we give it - * up...this is a implemenation dependent treatment. In ours we do not ask - * for a extension of time, but just retry this many times... - */ - /* max number of TSN's dup'd that I will hold */ #define SCTP_MAX_DUP_TSNS 20 /* * Here we define the types used when setting the retry amounts. */ -/* constants for type of set */ - -/* Maximum TSN's we will summarize in a drop report */ - /* How many drop re-attempts we make on INIT/COOKIE-ECHO */ #define SCTP_RETRY_DROPPED_THRESH 4 /* - * And the max we will keep a history of in the tcb which MUST be lower than - * 256. - */ - -/* - * Here we define the default timers and the default number of attemts we - * make for each respective side (send/init). - */ - -/* * Maxmium number of chunks a single association can have on it. Note that * this is a squishy number since the count can run over this if the user * sends a large message down .. the fragmented chunks don't count until @@ -763,7 +724,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_DEBUG_INDATA1 0x01000000 #define SCTP_DEBUG_INDATA2 0x02000000 /* unused */ #define SCTP_DEBUG_INDATA3 0x04000000 /* unused */ -#define SCTP_DEBUG_INDATA4 0x08000000 /* unused */ +#define SCTP_DEBUG_CRCOFFLOAD 0x08000000 /* unused */ #define SCTP_DEBUG_USRREQ1 0x10000000 /* unused */ #define SCTP_DEBUG_USRREQ2 0x20000000 /* unused */ #define SCTP_DEBUG_PEEL1 0x40000000 @@ -783,7 +744,7 @@ __FBSDID("$FreeBSD$"); #define SCTP_INITIAL_CWND 4380 -#define SCTP_DEFAULT_MTU 1500 /* emegency default MTU */ +#define SCTP_DEFAULT_MTU 1500 /* emergency default MTU */ /* amount peer is obligated to have in rwnd or I will abort */ #define SCTP_MIN_RWND 1500 @@ -996,13 +957,6 @@ __FBSDID("$FreeBSD$"); */ #define SCTP_STACK_VTAG_HASH_SIZE 32 - -/* - * If we use the per-endpoint model than we do not have a hash table of - * entries but instead have a single head pointer and we must crawl through - * the entire list. - */ - /* * Number of seconds of time wait for a vtag. */ Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_crc32.c Tue Feb 3 11:04:03 2009 (r188067) @@ -34,12 +34,16 @@ #include __FBSDID("$FreeBSD$"); +#include +#include +#include +#include +#include #include #include +#include -#ifndef SCTP_USE_ADLER32 - - +#if !defined(SCTP_WITH_NO_CSUM) /** * * Routine Description: @@ -80,12 +84,14 @@ __FBSDID("$FreeBSD$"); * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o32[256] = @@ -134,12 +140,14 @@ uint32_t sctp_crc_tableil8_o32[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o40[256] = @@ -188,12 +196,14 @@ uint32_t sctp_crc_tableil8_o40[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o48[256] = @@ -242,12 +252,14 @@ uint32_t sctp_crc_tableil8_o48[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o56[256] = @@ -296,12 +308,14 @@ uint32_t sctp_crc_tableil8_o56[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o64[256] = @@ -350,12 +364,14 @@ uint32_t sctp_crc_tableil8_o64[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o72[256] = @@ -404,12 +420,14 @@ uint32_t sctp_crc_tableil8_o72[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o80[256] = @@ -458,12 +476,14 @@ uint32_t sctp_crc_tableil8_o80[256] = * The following CRC lookup table was generated automagically using the * following model parameters: * - * Generator Polynomial = ................. 0x1EDC6F41 Generator Polynomial - * Length = .......... 32 bits Reflected Bits = ....................... TRUE - * Table Generation Offset = .............. 32 bits Number of Slices = - * ..................... 8 slices Slice Lengths = ........................ 8 - * 8 8 8 8 8 8 8 Directory Name = ....................... .\ File Name = - * ............................ 8x256_tables.c + * Generator Polynomial = ................. 0x1EDC6F41 + * Generator Polynomial Length = .......... 32 bits + * Reflected Bits = ....................... TRUE + * Table Generation Offset = .............. 32 bits + * Number of Slices = ..................... 8 slices + * Slice Lengths = ........................ 8 8 8 8 8 8 8 8 + * Directory Name = ....................... .\ + * File Name = ............................ 8x256_tables.c */ uint32_t sctp_crc_tableil8_o88[256] = @@ -506,6 +526,7 @@ uint32_t sctp_crc_tableil8_o88[256] = * end of the CRC lookup table crc_tableil8_o88 */ + static uint32_t sctp_crc32c_sb8_64_bit(uint32_t crc, unsigned char *p_buf, @@ -578,7 +599,7 @@ sctp_crc32c_sb8_64_bit(uint32_t crc, * * none */ -uint32_t +static uint32_t update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) @@ -662,7 +683,7 @@ uint32_t sctp_crc_c[256] = { #define SCTP_CRC32C(c,d) (c=(c>>8)^sctp_crc_c[(c^(d))&0xFF]) -uint32_t +static uint32_t old_update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) @@ -676,8 +697,8 @@ old_update_crc32(uint32_t crc32c, } -uint32_t -sctp_csum_finalize(uint32_t crc32c) +static uint32_t +sctp_finalize_crc32(uint32_t crc32c) { uint32_t result; @@ -709,4 +730,88 @@ sctp_csum_finalize(uint32_t crc32c) return (crc32c); } +#endif /* !defined(SCTP_WITH_NO_CSUM) */ + +#if defined(SCTP_WITH_NO_CSUM) +uint32_t +sctp_calculate_cksum(struct mbuf *m, uint32_t offset) +{ + return (0); +} + +#else +uint32_t +sctp_calculate_cksum(struct mbuf *m, uint32_t offset) +{ + /* + * given a mbuf chain with a packetheader offset by 'offset' + * pointing at a sctphdr (with csum set to 0) go through the chain + * of SCTP_BUF_NEXT()'s and calculate the SCTP checksum. This also + * has a side bonus as it will calculate the total length of the + * mbuf chain. Note: if offset is greater than the total mbuf + * length, checksum=1, pktlen=0 is returned (ie. no real error code) + */ + uint32_t base = 0xffffffff; + struct mbuf *at; + + at = m; + /* find the correct mbuf and offset into mbuf */ + while ((at != NULL) && (offset > (uint32_t) SCTP_BUF_LEN(at))) { + offset -= SCTP_BUF_LEN(at); /* update remaining offset + * left */ + at = SCTP_BUF_NEXT(at); + } + while (at != NULL) { + if ((SCTP_BUF_LEN(at) - offset) > 0) { + if ((SCTP_BUF_LEN(at) - offset) < 4) { + /* Use old method if less than 4 bytes */ + base = old_update_crc32(base, + (unsigned char *)(SCTP_BUF_AT(at, offset)), + (unsigned int)(SCTP_BUF_LEN(at) - offset)); + } else { + base = update_crc32(base, + (unsigned char *)(SCTP_BUF_AT(at, offset)), + (unsigned int)(SCTP_BUF_LEN(at) - offset)); + } + /* we only offset once into the first mbuf */ + } + if (offset) { + if (offset < (uint32_t) SCTP_BUF_LEN(at)) + offset = 0; + else + offset -= SCTP_BUF_LEN(at); + } + at = SCTP_BUF_NEXT(at); + } + base = sctp_finalize_crc32(base); + return (base); +} + #endif + +void +sctp_delayed_cksum(struct mbuf *m) +{ + struct ip *ip; + uint32_t checksum; + uint32_t offset; + + ip = mtod(m, struct ip *); + offset = ip->ip_hl << 2; + checksum = sctp_calculate_cksum(m, offset); + SCTP_STAT_DECR(sctps_sendhwcrc); + SCTP_STAT_INCR(sctps_sendswcrc); + offset += offsetof(struct sctphdr, checksum); + + if (offset + sizeof(uint32_t) > (uint32_t) (m->m_len)) { + printf("delayed m_pullup, m->len: %d off: %d p: %d\n", + (uint32_t) m->m_len, offset, ip->ip_p); + /* + * XXX this shouldn't happen, but if it does, the correct + * behavior may be to insert the checksum in the appropriate + * next mbuf in the chain. + */ + return; + } + *(uint32_t *) (m->m_data + offset) = checksum; +} Modified: head/sys/netinet/sctp_crc32.h ============================================================================== --- head/sys/netinet/sctp_crc32.h Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_crc32.h Tue Feb 3 11:04:03 2009 (r188067) @@ -36,16 +36,10 @@ __FBSDID("$FreeBSD$"); #ifndef __crc32c_h__ #define __crc32c_h__ -#ifndef SCTP_USE_ADLER32 - #if defined(_KERNEL) || defined(__Userspace__) -uint32_t update_crc32(uint32_t, unsigned char *, unsigned int); - -uint32_t old_update_crc32(uint32_t, unsigned char *, unsigned int); - -uint32_t sctp_csum_finalize(uint32_t); - +uint32_t sctp_calculate_cksum(struct mbuf *, uint32_t); +void sctp_delayed_cksum(struct mbuf *); #endif /* _KERNEL */ -#endif /* !SCTP_USE_ADLER32 */ + #endif /* __crc32c_h__ */ Modified: head/sys/netinet/sctp_input.c ============================================================================== --- head/sys/netinet/sctp_input.c Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_input.c Tue Feb 3 11:04:03 2009 (r188067) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -1384,14 +1385,6 @@ sctp_process_cookie_existing(struct mbuf /* FOOBAR */ return (NULL); } - /* pre-reserve some space */ -#ifdef INET6 - SCTP_BUF_RESV_UF(op_err, sizeof(struct ip6_hdr)); -#else - SCTP_BUF_RESV_UF(op_err, sizeof(struct ip)); -#endif - SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr)); - SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr)); /* Set the len */ SCTP_BUF_LEN(op_err) = sizeof(struct sctp_paramhdr); ph = mtod(op_err, struct sctp_paramhdr *); @@ -2504,15 +2497,6 @@ sctp_handle_cookie_echo(struct mbuf *m, /* FOOBAR */ return (NULL); } - /* pre-reserve some space */ -#ifdef INET6 - SCTP_BUF_RESV_UF(op_err, sizeof(struct ip6_hdr)); -#else - SCTP_BUF_RESV_UF(op_err, sizeof(struct ip)); -#endif - SCTP_BUF_RESV_UF(op_err, sizeof(struct sctphdr)); - SCTP_BUF_RESV_UF(op_err, sizeof(struct sctp_chunkhdr)); - /* Set the len */ SCTP_BUF_LEN(op_err) = sizeof(struct sctp_stale_cookie_msg); scm = mtod(op_err, struct sctp_stale_cookie_msg *); @@ -2598,9 +2582,9 @@ sctp_handle_cookie_echo(struct mbuf *m, } } } - if (to == NULL) + if (to == NULL) { return (NULL); - + } cookie_len -= SCTP_SIGNATURE_SIZE; if (*stcb == NULL) { /* this is the "normal" case... get a new TCB */ @@ -5594,7 +5578,6 @@ sctp_input_with_port(i_pak, off, port) int refcount_up = 0; int length, mlen, offset; - if (SCTP_GET_PKT_VRFID(i_pak, vrf_id)) { SCTP_RELEASE_PKT(i_pak); return; @@ -5642,6 +5625,11 @@ sctp_input_with_port(i_pak, off, port) } ip = mtod(m, struct ip *); } + /* validate mbuf chain length with IP payload length */ + if (mlen < (SCTP_GET_IPV4_LENGTH(ip) - iphlen)) { + SCTP_STAT_INCR(sctps_hdrops); + goto bad; + } sh = (struct sctphdr *)((caddr_t)ip + iphlen); ch = (struct sctp_chunkhdr *)((caddr_t)sh + sizeof(*sh)); SCTPDBG(SCTP_DEBUG_INPUT1, @@ -5659,15 +5647,26 @@ sctp_input_with_port(i_pak, off, port) goto bad; } /* validate SCTP checksum */ + SCTPDBG(SCTP_DEBUG_CRCOFFLOAD, + "sctp_input(): Packet of length %d received on %s with csum_flags 0x%x.\n", + m->m_pkthdr.len, + if_name(m->m_pkthdr.rcvif), + m->m_pkthdr.csum_flags); + if (m->m_pkthdr.csum_flags & CSUM_SCTP_VALID) { + SCTP_STAT_INCR(sctps_recvhwcrc); + goto sctp_skip_csum_4; + } check = sh->checksum; /* save incoming checksum */ if ((check == 0) && (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback)) && ((ip->ip_src.s_addr == ip->ip_dst.s_addr) || (SCTP_IS_IT_LOOPBACK(m))) ) { + SCTP_STAT_INCR(sctps_recvnocrc); goto sctp_skip_csum_4; } sh->checksum = 0; /* prepare for calc */ - calc_check = sctp_calculate_sum(m, &mlen, iphlen); + calc_check = sctp_calculate_cksum(m, iphlen); + SCTP_STAT_INCR(sctps_recvswcrc); if (calc_check != check) { SCTPDBG(SCTP_DEBUG_INPUT1, "Bad CSUM on SCTP packet calc_check:%x check:%x m:%p mlen:%d iphlen:%d\n", calc_check, check, m, mlen, iphlen); @@ -5699,11 +5698,6 @@ sctp_skip_csum_4: SCTP_STAT_INCR(sctps_hdrops); goto bad; } - /* validate mbuf chain length with IP payload length */ - if (mlen < (SCTP_GET_IPV4_LENGTH(ip) - iphlen)) { - SCTP_STAT_INCR(sctps_hdrops); - goto bad; - } /* * Locate pcb and tcb for datagram sctp_findassociation_addr() wants * IP/SCTP/first chunk header... Modified: head/sys/netinet/sctp_os_bsd.h ============================================================================== --- head/sys/netinet/sctp_os_bsd.h Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_os_bsd.h Tue Feb 3 11:04:03 2009 (r188067) @@ -154,11 +154,8 @@ MALLOC_DECLARE(SCTP_M_SOCKOPT); #define MOD_IPSEC ipsec /* then define the macro(s) that hook into the vimage macros */ -#if defined(__FreeBSD__) && __FreeBSD_version >= 800056 #define MODULE_GLOBAL(__MODULE, __SYMBOL) V_ ## __SYMBOL -#else -#define MODULE_GLOBAL(__MODULE, __SYMBOL) (__SYMBOL) -#endif + /* * */ Modified: head/sys/netinet/sctp_output.c ============================================================================== --- head/sys/netinet/sctp_output.c Tue Feb 3 11:00:43 2009 (r188066) +++ head/sys/netinet/sctp_output.c Tue Feb 3 11:04:03 2009 (r188067) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -5213,6 +5214,9 @@ sctp_lowlevel_chunk_output(struct sctp_i int ecn_ok, struct sctp_tmit_chunk *chk, int out_of_asoc_ok, + uint16_t src_port, + uint16_t dest_port, + uint32_t v_tag, uint16_t port, int so_locked, #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING) @@ -5237,7 +5241,6 @@ sctp_lowlevel_chunk_output(struct sctp_i struct mbuf *newm; struct sctphdr *sctphdr; int packet_length; - uint32_t csum; int ret; uint32_t vrf_id; sctp_route_t *ro = NULL; @@ -5263,51 +5266,27 @@ sctp_lowlevel_chunk_output(struct sctp_i if ((auth != NULL) && (stcb != NULL)) { sctp_fill_hmac_digest_m(m, auth_offset, auth, stcb, auth_keyid); } - /* Calculate the csum and fill in the length of the packet */ - sctphdr = mtod(m, struct sctphdr *); - if (SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && - (stcb) && - (to->sa_family == AF_INET) && - (stcb->asoc.loopback_scope)) { - sctphdr->checksum = 0; - /* - * This can probably now be taken out since my audit shows - * no more bad pktlen's coming in. But we will wait a while - * yet. - */ - packet_length = sctp_calculate_len(m); - } else { - sctphdr->checksum = 0; - csum = sctp_calculate_sum(m, &packet_length, 0); - sctphdr->checksum = csum; - } - if (to->sa_family == AF_INET) { struct ip *ip = NULL; sctp_route_t iproute; uint8_t tos_value; + int len; + len = sizeof(struct ip) + sizeof(struct sctphdr); if (port) { - newm = sctp_get_mbuf_for_msg(sizeof(struct ip) + sizeof(struct udphdr), 1, M_DONTWAIT, 1, MT_DATA); - } else { - newm = sctp_get_mbuf_for_msg(sizeof(struct ip), 1, M_DONTWAIT, 1, MT_DATA); + len += sizeof(struct udphdr); } + newm = sctp_get_mbuf_for_msg(len, 1, M_DONTWAIT, 1, MT_DATA); if (newm == NULL) { sctp_m_freem(m); SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM); return (ENOMEM); } - if (port) { - SCTP_ALIGN_TO_END(newm, sizeof(struct ip) + sizeof(struct udphdr)); - SCTP_BUF_LEN(newm) = sizeof(struct ip) + sizeof(struct udphdr); - packet_length += sizeof(struct ip) + sizeof(struct udphdr); - } else { - SCTP_ALIGN_TO_END(newm, sizeof(struct ip)); - SCTP_BUF_LEN(newm) = sizeof(struct ip); - packet_length += sizeof(struct ip); - } + SCTP_ALIGN_TO_END(newm, len); + SCTP_BUF_LEN(newm) = len; SCTP_BUF_NEXT(newm) = m; m = newm; + packet_length = sctp_calculate_len(m); ip = mtod(m, struct ip *); ip->ip_v = IPVERSION; ip->ip_hl = (sizeof(struct ip) >> 2); @@ -5401,12 +5380,21 @@ sctp_lowlevel_chunk_output(struct sctp_i } } if (port) { - udp = (struct udphdr *)(ip + 1); + udp = (struct udphdr *)((caddr_t)ip + sizeof(struct ip)); udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons(packet_length - sizeof(struct ip)); udp->uh_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr, udp->uh_ulen + htons(IPPROTO_UDP)); + sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); + } else { + sctphdr = (struct sctphdr *)((caddr_t)ip + sizeof(struct ip)); } + + sctphdr->src_port = src_port; + sctphdr->dest_port = dest_port; + sctphdr->v_tag = v_tag; + sctphdr->checksum = 0; + /* * If source address selection fails and we find no route * then the ip_output should fail as well with a @@ -5517,7 +5505,25 @@ sctp_lowlevel_chunk_output(struct sctp_i #endif SCTP_ATTACH_CHAIN(o_pak, m, packet_length); if (port) { + if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (stcb) && + (stcb->asoc.loopback_scope))) { + sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip) + sizeof(struct udphdr)); + SCTP_STAT_INCR(sctps_sendswcrc); + } else { + SCTP_STAT_INCR(sctps_sendnocrc); + } SCTP_ENABLE_UDP_CSUM(o_pak); + } else { + if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (stcb) && + (stcb->asoc.loopback_scope))) { + m->m_pkthdr.csum_flags = CSUM_SCTP; + m->m_pkthdr.csum_data = 0; /* FIXME MT */ + SCTP_STAT_INCR(sctps_sendhwcrc); + } else { + SCTP_STAT_INCR(sctps_sendnocrc); + } } /* send it out. table id is taken from stcb */ #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) @@ -5591,6 +5597,7 @@ sctp_lowlevel_chunk_output(struct sctp_i struct sockaddr_in6 lsa6_storage; int error; u_short prev_port = 0; + int len; if (net != NULL) { flowlabel = net->tos_flowlabel; @@ -5598,27 +5605,21 @@ sctp_lowlevel_chunk_output(struct sctp_i flowlabel = ((struct in6pcb *)inp)->in6p_flowinfo; } + len = sizeof(struct ip6_hdr) + sizeof(struct sctphdr); if (port) { - newm = sctp_get_mbuf_for_msg(sizeof(struct ip6_hdr) + sizeof(struct udphdr), 1, M_DONTWAIT, 1, MT_DATA); - } else { - newm = sctp_get_mbuf_for_msg(sizeof(struct ip6_hdr), 1, M_DONTWAIT, 1, MT_DATA); + len += sizeof(struct udphdr); } + newm = sctp_get_mbuf_for_msg(len, 1, M_DONTWAIT, 1, MT_DATA); if (newm == NULL) { sctp_m_freem(m); SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_OUTPUT, ENOMEM); return (ENOMEM); } - if (port) { - SCTP_ALIGN_TO_END(newm, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); - SCTP_BUF_LEN(newm) = sizeof(struct ip6_hdr) + sizeof(struct udphdr); - packet_length += sizeof(struct ip6_hdr) + sizeof(struct udphdr); - } else { - SCTP_ALIGN_TO_END(newm, sizeof(struct ip6_hdr)); - SCTP_BUF_LEN(newm) = sizeof(struct ip6_hdr); - packet_length += sizeof(struct ip6_hdr); - } + SCTP_ALIGN_TO_END(newm, len); + SCTP_BUF_LEN(newm) = len; SCTP_BUF_NEXT(newm) = m; m = newm; + packet_length = sctp_calculate_len(m); ip6h = mtod(m, struct ip6_hdr *); /* @@ -5763,12 +5764,21 @@ sctp_lowlevel_chunk_output(struct sctp_i ip6h->ip6_src = lsa6->sin6_addr; if (port) { - udp = (struct udphdr *)(ip6h + 1); + udp = (struct udphdr *)((caddr_t)ip6h + sizeof(struct ip6_hdr)); udp->uh_sport = htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port)); udp->uh_dport = port; udp->uh_ulen = htons(packet_length - sizeof(struct ip6_hdr)); udp->uh_sum = 0; + sctphdr = (struct sctphdr *)((caddr_t)udp + sizeof(struct udphdr)); + } else { + sctphdr = (struct sctphdr *)((caddr_t)ip6h + sizeof(struct ip6_hdr)); } + + sctphdr->src_port = src_port; + sctphdr->dest_port = dest_port; + sctphdr->v_tag = v_tag; + sctphdr->checksum = 0; + /* * We set the hop limit now since there is a good chance * that our ro pointer is now filled @@ -5805,9 +5815,27 @@ sctp_lowlevel_chunk_output(struct sctp_i #endif SCTP_ATTACH_CHAIN(o_pak, m, packet_length); if (port) { + if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (stcb) && + (stcb->asoc.loopback_scope))) { + sctphdr->checksum = sctp_calculate_cksum(m, sizeof(struct ip6_hdr) + sizeof(struct udphdr)); + SCTP_STAT_INCR(sctps_sendswcrc); + } else { + SCTP_STAT_INCR(sctps_sendnocrc); + } if ((udp->uh_sum = in6_cksum(o_pak, IPPROTO_UDP, sizeof(struct ip6_hdr), packet_length - sizeof(struct ip6_hdr))) == 0) { udp->uh_sum = 0xffff; } + } else { + if (!(SCTP_BASE_SYSCTL(sctp_no_csum_on_loopback) && + (stcb) && + (stcb->asoc.loopback_scope))) { + m->m_pkthdr.csum_flags = CSUM_SCTP; + m->m_pkthdr.csum_data = 0; /* FIXME MT */ + SCTP_STAT_INCR(sctps_sendhwcrc); + } else { + SCTP_STAT_INCR(sctps_sendnocrc); + } } /* send it out. table id is taken from stcb */ #if defined (__APPLE__) || defined(SCTP_SO_LOCK_TESTING) @@ -5905,7 +5933,7 @@ sctp_send_initiate(struct sctp_inpcb *in { struct mbuf *m, *m_at, *mp_last; struct sctp_nets *net; - struct sctp_init_msg *initm; + struct sctp_init_chunk *init; struct sctp_supported_addr_param *sup_addr; struct sctp_adaptation_layer_indication *ali; struct sctp_ecn_supported_param *ecn; @@ -5961,7 +5989,7 @@ sctp_send_initiate(struct sctp_inpcb *in SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - mbuf?\n"); return; } - SCTP_BUF_LEN(m) = sizeof(struct sctp_init_msg); + SCTP_BUF_LEN(m) = sizeof(struct sctp_init_chunk); /* * assume peer supports asconf in order to be able to queue local * address changes while an INIT is in flight and before the assoc @@ -5969,28 +5997,24 @@ sctp_send_initiate(struct sctp_inpcb *in */ stcb->asoc.peer_supports_asconf = 1; /* Now lets put the SCTP header in place */ - initm = mtod(m, struct sctp_init_msg *); - initm->sh.src_port = inp->sctp_lport; - initm->sh.dest_port = stcb->rport; - initm->sh.v_tag = 0; - initm->sh.checksum = 0; /* calculate later */ + init = mtod(m, struct sctp_init_chunk *); /* now the chunk header */ - initm->msg.ch.chunk_type = SCTP_INITIATION; - initm->msg.ch.chunk_flags = 0; + init->ch.chunk_type = SCTP_INITIATION; + init->ch.chunk_flags = 0; /* fill in later from mbuf we build */ - initm->msg.ch.chunk_length = 0; + init->ch.chunk_length = 0; /* place in my tag */ - initm->msg.init.initiate_tag = htonl(stcb->asoc.my_vtag); + init->init.initiate_tag = htonl(stcb->asoc.my_vtag); /* set up some of the credits. */ - initm->msg.init.a_rwnd = htonl(max(SCTP_SB_LIMIT_RCV(inp->sctp_socket), + init->init.a_rwnd = htonl(max(SCTP_SB_LIMIT_RCV(inp->sctp_socket), SCTP_MINIMAL_RWND)); - initm->msg.init.num_outbound_streams = htons(stcb->asoc.pre_open_streams); - initm->msg.init.num_inbound_streams = htons(stcb->asoc.max_inbound_streams); - initm->msg.init.initial_tsn = htonl(stcb->asoc.init_seq_number); + init->init.num_outbound_streams = htons(stcb->asoc.pre_open_streams); + init->init.num_inbound_streams = htons(stcb->asoc.max_inbound_streams); + init->init.initial_tsn = htonl(stcb->asoc.init_seq_number); /* now the address restriction */ - sup_addr = (struct sctp_supported_addr_param *)((caddr_t)initm + - sizeof(*initm)); + sup_addr = (struct sctp_supported_addr_param *)((caddr_t)init + + sizeof(*init)); sup_addr->ph.param_type = htons(SCTP_SUPPORTED_ADDRTYPE); #ifdef INET6 /* we support 2 types: IPv6/IPv4 */ @@ -6004,7 +6028,6 @@ sctp_send_initiate(struct sctp_inpcb *in sup_addr->addr_type[1] = htons(0); /* this is the padding */ #endif SCTP_BUF_LEN(m) += sizeof(*sup_addr) + sizeof(uint16_t); - /* adaptation layer indication parameter */ ali = (struct sctp_adaptation_layer_indication *)((caddr_t)sup_addr + sizeof(*sup_addr) + sizeof(uint16_t)); ali->ph.param_type = htons(SCTP_ULP_ADAPTATION); @@ -6013,6 +6036,16 @@ sctp_send_initiate(struct sctp_inpcb *in SCTP_BUF_LEN(m) += sizeof(*ali); ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali)); + if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) { + /* Add NAT friendly parameter */ + struct sctp_paramhdr *ph; + + ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); + ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); + ph->param_length = htons(sizeof(struct sctp_paramhdr)); + SCTP_BUF_LEN(m) += sizeof(struct sctp_paramhdr); + ecn = (struct sctp_ecn_supported_param *)((caddr_t)ph + sizeof(*ph)); + } /* now any cookie time extensions */ if (stcb->asoc.cookie_preserve_req) { struct sctp_cookie_perserve_param *cookie_preserve; @@ -6052,19 +6085,22 @@ sctp_send_initiate(struct sctp_inpcb *in pr_supported->chunk_types[num_ext++] = SCTP_FORWARD_CUM_TSN; pr_supported->chunk_types[num_ext++] = SCTP_PACKET_DROPPED; pr_supported->chunk_types[num_ext++] = SCTP_STREAM_RESET; - if (!SCTP_BASE_SYSCTL(sctp_auth_disable)) + if (!SCTP_BASE_SYSCTL(sctp_auth_disable)) { pr_supported->chunk_types[num_ext++] = SCTP_AUTHENTICATION; + } /* * EY if the initiator supports nr_sacks, need to report that to * responder in INIT chunk */ - if (SCTP_BASE_SYSCTL(sctp_nr_sack_on_off)) + if (SCTP_BASE_SYSCTL(sctp_nr_sack_on_off)) { pr_supported->chunk_types[num_ext++] = SCTP_NR_SELECTIVE_ACK; + } p_len = sizeof(*pr_supported) + num_ext; pr_supported->ph.param_length = htons(p_len); bzero((caddr_t)pr_supported + p_len, SCTP_SIZE32(p_len) - p_len); SCTP_BUF_LEN(m) += SCTP_SIZE32(p_len); + /* ECN nonce: And now tell the peer we support ECN nonce */ if (SCTP_BASE_SYSCTL(sctp_ecn_nonce)) { ecn_nonce = (struct sctp_ecn_nonce_supported_param *) @@ -6073,15 +6109,6 @@ sctp_send_initiate(struct sctp_inpcb *in ecn_nonce->ph.param_length = htons(sizeof(*ecn_nonce)); SCTP_BUF_LEN(m) += sizeof(*ecn_nonce); } - if (SCTP_BASE_SYSCTL(sctp_inits_include_nat_friendly)) { - /* Add NAT friendly parameter */ - struct sctp_paramhdr *ph; - - ph = (struct sctp_paramhdr *)(mtod(m, caddr_t)+SCTP_BUF_LEN(m)); - ph->param_type = htons(SCTP_HAS_NAT_SUPPORT); - ph->param_length = htons(sizeof(struct sctp_paramhdr)); - SCTP_BUF_LEN(m) += sizeof(sizeof(struct sctp_paramhdr)); - } /* add authentication parameters */ if (!SCTP_BASE_SYSCTL(sctp_auth_disable)) { struct sctp_auth_random *randp; @@ -6160,7 +6187,7 @@ sctp_send_initiate(struct sctp_inpcb *in mp_last = m_at; p_len += SCTP_BUF_LEN(m_at); } - initm->msg.ch.chunk_length = htons((p_len - sizeof(struct sctphdr))); + init->ch.chunk_length = htons(p_len); /* * We sifa 0 here to NOT set IP_DF if its IPv4, we ignore the return * here since the timer will drive a retranmission. @@ -6185,7 +6212,9 @@ sctp_send_initiate(struct sctp_inpcb *in SCTPDBG(SCTP_DEBUG_OUTPUT4, "Sending INIT - calls lowlevel_output\n"); ret = sctp_lowlevel_chunk_output(inp, stcb, net, (struct sockaddr *)&net->ro._l_addr, - m, 0, NULL, 0, 0, 0, NULL, 0, net->port, so_locked, NULL); + m, 0, NULL, 0, 0, 0, NULL, 0, + inp->sctp_lport, stcb->rport, htonl(0), + net->port, so_locked, NULL); SCTPDBG(SCTP_DEBUG_OUTPUT4, "lowlevel_output - %d\n", ret); SCTP_STAT_INCR_COUNTER64(sctps_outcontrolchunks); sctp_timer_start(SCTP_TIMER_TYPE_INIT, inp, stcb, net); @@ -6711,7 +6740,7 @@ sctp_send_initiate_ack(struct sctp_inpcb { struct sctp_association *asoc; struct mbuf *m, *m_at, *m_tmp, *m_cookie, *op_err, *mp_last; - struct sctp_init_msg *initackm_out; + struct sctp_init_ack_chunk *initack; struct sctp_adaptation_layer_indication *ali; struct sctp_ecn_supported_param *ecn; struct sctp_prsctp_supported_param *prsctp; @@ -6776,7 +6805,7 @@ do_a_abort: sctp_m_freem(op_err); return; } - SCTP_BUF_LEN(m) = sizeof(struct sctp_init_msg); + SCTP_BUF_LEN(m) = sizeof(struct sctp_init_chunk); /* the time I built cookie */ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From thompsa at FreeBSD.org Tue Feb 3 07:24:01 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Tue Feb 3 07:24:07 2009 Subject: svn commit: r188074 - head/sys/dev/usb2/quirk Message-ID: <200902031524.n13FO0dn033824@svn.freebsd.org> Author: thompsa Date: Tue Feb 3 15:24:00 2009 New Revision: 188074 URL: http://svn.freebsd.org/changeset/base/188074 Log: Add missing string table for the usb quirk enum. Pointy hat: me Submitted by: rrs Modified: head/sys/dev/usb2/quirk/usb2_quirk.c head/sys/dev/usb2/quirk/usb2_quirk.h Modified: head/sys/dev/usb2/quirk/usb2_quirk.c ============================================================================== --- head/sys/dev/usb2/quirk/usb2_quirk.c Tue Feb 3 14:32:06 2009 (r188073) +++ head/sys/dev/usb2/quirk/usb2_quirk.c Tue Feb 3 15:24:00 2009 (r188074) @@ -112,7 +112,32 @@ static struct usb2_quirk_entry usb2_quir {USB_QUIRK_ENTRY(USB_VENDOR_METAGEEK, USB_PRODUCT_METAGEEK_WISPY24X, 0x0000, 0xFFFF, UQ_KBD_IGNORE, UQ_HID_IGNORE, UQ_NONE)}, }; -USB_MAKE_DEBUG_TABLE(USB_QUIRK); +static const char *usb_quirk_str[USB_QUIRK_MAX] = { + "UQ_NONE", + "UQ_AUDIO_SWAP_LR", /* left and right sound channels are swapped */ + "UQ_AU_INP_ASYNC", /* input is async despite claim of adaptive */ + "UQ_AU_NO_FRAC", /* don't adjust for fractional samples */ + "UQ_AU_NO_XU", /* audio device has broken extension unit */ + "UQ_BAD_ADC", /* bad audio spec version number */ + "UQ_BAD_AUDIO", /* device claims audio class, but isn't */ + "UQ_BROKEN_BIDIR", /* printer has broken bidir mode */ + "UQ_BUS_POWERED", /* device is bus powered, despite claim */ + "UQ_HID_IGNORE", /* device should be ignored by hid class */ + "UQ_KBD_IGNORE", /* device should be ignored by kbd class */ + "UQ_MS_BAD_CLASS", /* doesn't identify properly */ + "UQ_MS_LEADING_BYTE", /* mouse sends an unknown leading byte */ + "UQ_MS_REVZ", /* mouse has Z-axis reversed */ + "UQ_NO_STRINGS", /* string descriptors are broken */ + "UQ_OPEN_CLEARSTALL", /* device needs clear endpoint stall */ + "UQ_POWER_CLAIM", /* hub lies about power status */ + "UQ_SPUR_BUT_UP", /* spurious mouse button up events */ + "UQ_SWAP_UNICODE", /* has some Unicode strings swapped */ + "UQ_CFG_INDEX_1", /* select configuration index 1 by default */ + "UQ_CFG_INDEX_2", /* select configuration index 2 by default */ + "UQ_CFG_INDEX_3", /* select configuration index 3 by default */ + "UQ_CFG_INDEX_4", /* select configuration index 4 by default */ + "UQ_CFG_INDEX_0", /* select configuration index 0 by default */ +}; /*------------------------------------------------------------------------* * usb2_quirkstr @@ -123,7 +148,7 @@ static const char * usb2_quirkstr(uint16_t quirk) { return ((quirk < USB_QUIRK_MAX) ? - USB_QUIRK[quirk] : "USB_QUIRK_UNKNOWN"); + usb_quirk_str[quirk] : "USB_QUIRK_UNKNOWN"); } /*------------------------------------------------------------------------* Modified: head/sys/dev/usb2/quirk/usb2_quirk.h ============================================================================== --- head/sys/dev/usb2/quirk/usb2_quirk.h Tue Feb 3 14:32:06 2009 (r188073) +++ head/sys/dev/usb2/quirk/usb2_quirk.h Tue Feb 3 15:24:00 2009 (r188074) @@ -28,7 +28,7 @@ #define _USB2_QUIRK_H_ /* NOTE: UQ_NONE is not a valid quirk */ -enum { +enum { /* keep in sync with usb_quirk_str table */ UQ_NONE, UQ_AUDIO_SWAP_LR, /* left and right sound channels are swapped */ UQ_AU_INP_ASYNC, /* input is async despite claim of adaptive */ From obrien at FreeBSD.org Tue Feb 3 07:27:32 2009 From: obrien at FreeBSD.org (David E. O'Brien) Date: Tue Feb 3 07:27:38 2009 Subject: svn commit: r188075 - head/usr.bin/make Message-ID: <200902031527.n13FRTlf033941@svn.freebsd.org> Author: obrien Date: Tue Feb 3 15:27:29 2009 New Revision: 188075 URL: http://svn.freebsd.org/changeset/base/188075 Log: Partially revert r186559. Modified: head/usr.bin/make/job.c Modified: head/usr.bin/make/job.c ============================================================================== --- head/usr.bin/make/job.c Tue Feb 3 15:24:00 2009 (r188074) +++ head/usr.bin/make/job.c Tue Feb 3 15:27:29 2009 (r188075) @@ -2362,7 +2362,7 @@ Job_Init(int maxproc) makeErrors = 0; lastNode = NULL; - if ((maxJobs == 1 && fifoFd < 0) || is_posix || beQuiet) { + if ((maxJobs == 1 && fifoFd < 0) || !beVerbose || is_posix || beQuiet) { /* * If only one job can run at a time, there's no need for a * banner, no is there? From thompsa at FreeBSD.org Tue Feb 3 08:00:21 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Tue Feb 3 08:00:38 2009 Subject: svn commit: r188076 - in head/sys/dev/usb2: core quirk Message-ID: <200902031600.n13G0KAN034623@svn.freebsd.org> Author: thompsa Date: Tue Feb 3 16:00:20 2009 New Revision: 188076 URL: http://svn.freebsd.org/changeset/base/188076 Log: - Keep the same sorting on usb_errstr_table as the enum. - Use c99 array initializers for usb_quirk_str so the indexing isnt critical. Modified: head/sys/dev/usb2/core/usb2_error.c head/sys/dev/usb2/quirk/usb2_quirk.c Modified: head/sys/dev/usb2/core/usb2_error.c ============================================================================== --- head/sys/dev/usb2/core/usb2_error.c Tue Feb 3 15:27:29 2009 (r188075) +++ head/sys/dev/usb2/core/usb2_error.c Tue Feb 3 16:00:20 2009 (r188076) @@ -31,35 +31,36 @@ static const char* usb_errstr_table[USB_ERR_MAX] = { [USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION", + [USB_ERR_PENDING_REQUESTS] = "USB_ERR_PENDING_REQUESTS", + [USB_ERR_NOT_STARTED] = "USB_ERR_NOT_STARTED", + [USB_ERR_INVAL] = "USB_ERR_INVAL", + [USB_ERR_NOMEM] = "USB_ERR_NOMEM", + [USB_ERR_CANCELLED] = "USB_ERR_CANCELLED", [USB_ERR_BAD_ADDRESS] = "USB_ERR_BAD_ADDRESS", [USB_ERR_BAD_BUFSIZE] = "USB_ERR_BAD_BUFSIZE", - [USB_ERR_BAD_CONTEXT] = "USB_ERR_BAD_CONTEXT", [USB_ERR_BAD_FLAG] = "USB_ERR_BAD_FLAG", - [USB_ERR_CANCELLED] = "USB_ERR_CANCELLED", - [USB_ERR_DMA_LOAD_FAILED] = "USB_ERR_DMA_LOAD_FAILED", - [USB_ERR_INTERRUPTED] = "USB_ERR_INTERRUPTED", - [USB_ERR_INVAL] = "USB_ERR_INVAL", + [USB_ERR_NO_CALLBACK] = "USB_ERR_NO_CALLBACK", [USB_ERR_IN_USE] = "USB_ERR_IN_USE", - [USB_ERR_IOERROR] = "USB_ERR_IOERROR", - [USB_ERR_NOMEM] = "USB_ERR_NOMEM", - [USB_ERR_NOT_CONFIGURED] = "USB_ERR_NOT_CONFIGURED", - [USB_ERR_NOT_LOCKED] = "USB_ERR_NOT_LOCKED", - [USB_ERR_NOT_STARTED] = "USB_ERR_NOT_STARTED", [USB_ERR_NO_ADDR] = "USB_ERR_NO_ADDR", - [USB_ERR_NO_CALLBACK] = "USB_ERR_NO_CALLBACK", - [USB_ERR_NO_INTR_THREAD] = "USB_ERR_NO_INTR_THREAD", [USB_ERR_NO_PIPE] = "USB_ERR_NO_PIPE", - [USB_ERR_NO_POWER] = "USB_ERR_NO_POWER", - [USB_ERR_NO_ROOT_HUB] = "USB_ERR_NO_ROOT_HUB", - [USB_ERR_PENDING_REQUESTS] = "USB_ERR_PENDING_REQUESTS", + [USB_ERR_ZERO_NFRAMES] = "USB_ERR_ZERO_NFRAMES", + [USB_ERR_ZERO_MAXP] = "USB_ERR_ZERO_MAXP", [USB_ERR_SET_ADDR_FAILED] = "USB_ERR_SET_ADDR_FAILED", + [USB_ERR_NO_POWER] = "USB_ERR_NO_POWER", + [USB_ERR_TOO_DEEP] = "USB_ERR_TOO_DEEP", + [USB_ERR_IOERROR] = "USB_ERR_IOERROR", + [USB_ERR_NOT_CONFIGURED] = "USB_ERR_NOT_CONFIGURED", + [USB_ERR_TIMEOUT] = "USB_ERR_TIMEOUT", [USB_ERR_SHORT_XFER] = "USB_ERR_SHORT_XFER", [USB_ERR_STALLED] = "USB_ERR_STALLED", - [USB_ERR_TIMEOUT] = "USB_ERR_TIMEOUT", - [USB_ERR_TOO_DEEP] = "USB_ERR_TOO_DEEP", - [USB_ERR_ZERO_MAXP] = "USB_ERR_ZERO_MAXP", - [USB_ERR_ZERO_NFRAMES] = "USB_ERR_ZERO_NFRAMES", + [USB_ERR_INTERRUPTED] = "USB_ERR_INTERRUPTED", + [USB_ERR_DMA_LOAD_FAILED] = "USB_ERR_DMA_LOAD_FAILED", + [USB_ERR_BAD_CONTEXT] = "USB_ERR_BAD_CONTEXT", + [USB_ERR_NO_ROOT_HUB] = "USB_ERR_NO_ROOT_HUB", + [USB_ERR_NO_INTR_THREAD] = "USB_ERR_NO_INTR_THREAD", + [USB_ERR_NOT_LOCKED] = "USB_ERR_NOT_LOCKED", }; + /*------------------------------------------------------------------------* * usb2_errstr * Modified: head/sys/dev/usb2/quirk/usb2_quirk.c ============================================================================== --- head/sys/dev/usb2/quirk/usb2_quirk.c Tue Feb 3 15:27:29 2009 (r188075) +++ head/sys/dev/usb2/quirk/usb2_quirk.c Tue Feb 3 16:00:20 2009 (r188076) @@ -113,30 +113,30 @@ static struct usb2_quirk_entry usb2_quir }; static const char *usb_quirk_str[USB_QUIRK_MAX] = { - "UQ_NONE", - "UQ_AUDIO_SWAP_LR", /* left and right sound channels are swapped */ - "UQ_AU_INP_ASYNC", /* input is async despite claim of adaptive */ - "UQ_AU_NO_FRAC", /* don't adjust for fractional samples */ - "UQ_AU_NO_XU", /* audio device has broken extension unit */ - "UQ_BAD_ADC", /* bad audio spec version number */ - "UQ_BAD_AUDIO", /* device claims audio class, but isn't */ - "UQ_BROKEN_BIDIR", /* printer has broken bidir mode */ - "UQ_BUS_POWERED", /* device is bus powered, despite claim */ - "UQ_HID_IGNORE", /* device should be ignored by hid class */ - "UQ_KBD_IGNORE", /* device should be ignored by kbd class */ - "UQ_MS_BAD_CLASS", /* doesn't identify properly */ - "UQ_MS_LEADING_BYTE", /* mouse sends an unknown leading byte */ - "UQ_MS_REVZ", /* mouse has Z-axis reversed */ - "UQ_NO_STRINGS", /* string descriptors are broken */ - "UQ_OPEN_CLEARSTALL", /* device needs clear endpoint stall */ - "UQ_POWER_CLAIM", /* hub lies about power status */ - "UQ_SPUR_BUT_UP", /* spurious mouse button up events */ - "UQ_SWAP_UNICODE", /* has some Unicode strings swapped */ - "UQ_CFG_INDEX_1", /* select configuration index 1 by default */ - "UQ_CFG_INDEX_2", /* select configuration index 2 by default */ - "UQ_CFG_INDEX_3", /* select configuration index 3 by default */ - "UQ_CFG_INDEX_4", /* select configuration index 4 by default */ - "UQ_CFG_INDEX_0", /* select configuration index 0 by default */ + [UQ_NONE] = "UQ_NONE", + [UQ_AUDIO_SWAP_LR] = "UQ_AUDIO_SWAP_LR", + [UQ_AU_INP_ASYNC] = "UQ_AU_INP_ASYNC", + [UQ_AU_NO_FRAC] = "UQ_AU_NO_FRAC", + [UQ_AU_NO_XU] = "UQ_AU_NO_XU", + [UQ_BAD_ADC] = "UQ_BAD_ADC", + [UQ_BAD_AUDIO] = "UQ_BAD_AUDIO", + [UQ_BROKEN_BIDIR] = "UQ_BROKEN_BIDIR", + [UQ_BUS_POWERED] = "UQ_BUS_POWERED", + [UQ_HID_IGNORE] = "UQ_HID_IGNORE", + [UQ_KBD_IGNORE] = "UQ_KBD_IGNORE", + [UQ_MS_BAD_CLASS] = "UQ_MS_BAD_CLASS", + [UQ_MS_LEADING_BYTE] = "UQ_MS_LEADING_BYTE", + [UQ_MS_REVZ] = "UQ_MS_REVZ", + [UQ_NO_STRINGS] = "UQ_NO_STRINGS", + [UQ_OPEN_CLEARSTALL] = "UQ_OPEN_CLEARSTALL", + [UQ_POWER_CLAIM] = "UQ_POWER_CLAIM", + [UQ_SPUR_BUT_UP] = "UQ_SPUR_BUT_UP", + [UQ_SWAP_UNICODE] = "UQ_SWAP_UNICODE", + [UQ_CFG_INDEX_1] = "UQ_CFG_INDEX_1", + [UQ_CFG_INDEX_2] = "UQ_CFG_INDEX_2", + [UQ_CFG_INDEX_3] = "UQ_CFG_INDEX_3", + [UQ_CFG_INDEX_4] = "UQ_CFG_INDEX_4", + [UQ_CFG_INDEX_0] = "UQ_CFG_INDEX_0", }; /*------------------------------------------------------------------------* From jhb at FreeBSD.org Tue Feb 3 08:14:41 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Feb 3 08:14:53 2009 Subject: svn commit: r188077 - in head/sys/dev: ichsmb ipmi smbus Message-ID: <200902031614.n13GEbAt034978@svn.freebsd.org> Author: jhb Date: Tue Feb 3 16:14:37 2009 New Revision: 188077 URL: http://svn.freebsd.org/changeset/base/188077 Log: - Change ichsmb(4) to follow the format of all the other smbus controllers for slave addressing by using left-adjusted slave addresses (i.e. xxxxxxx0b). - Require the low bit of the slave address to always be zero in smb(4) to help catch broken applications. - Adjust some code in the IPMI driver to not convert the slave address for SSIF to a right-adjusted address. I (or possibly ambrisko@) added this in the past to (unknowingly) work around the bug in ichsmb(4). Submitted by: Andriy Gapon (1,2) MFC after: 1 month Modified: head/sys/dev/ichsmb/ichsmb.c head/sys/dev/ipmi/ipmi_smbios.c head/sys/dev/smbus/smb.c Modified: head/sys/dev/ichsmb/ichsmb.c ============================================================================== --- head/sys/dev/ichsmb/ichsmb.c Tue Feb 3 16:00:20 2009 (r188076) +++ head/sys/dev/ichsmb/ichsmb.c Tue Feb 3 16:14:37 2009 (r188077) @@ -182,7 +182,7 @@ ichsmb_quick(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_QUICK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | (how == SMB_QREAD ? + slave | (how == SMB_QREAD ? ICH_XMIT_SLVA_READ : ICH_XMIT_SLVA_WRITE)); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -208,7 +208,7 @@ ichsmb_sendb(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, byte); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -230,7 +230,7 @@ ichsmb_recvb(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); if ((smb_error = ichsmb_wait(sc)) == SMB_ENOERR) @@ -253,7 +253,7 @@ ichsmb_writeb(device_t dev, u_char slave mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, byte); bus_write_1(sc->io_res, ICH_HST_CNT, @@ -277,7 +277,7 @@ ichsmb_writew(device_t dev, u_char slave mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, word & 0xff); bus_write_1(sc->io_res, ICH_D1, word >> 8); @@ -301,7 +301,7 @@ ichsmb_readb(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BYTE_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -324,7 +324,7 @@ ichsmb_readw(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_WORD_DATA; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_HST_CNT, ICH_HST_CNT_START | ICH_HST_CNT_INTREN | sc->ich_cmd); @@ -352,7 +352,7 @@ ichsmb_pcall(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_PROC_CALL; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, sdata & 0xff); bus_write_1(sc->io_res, ICH_D1, sdata >> 8); @@ -403,7 +403,7 @@ ichsmb_bwrite(device_t dev, u_char slave mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_WRITE); + slave | ICH_XMIT_SLVA_WRITE); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, count); bus_write_1(sc->io_res, ICH_BLOCK_DB, buf[0]); @@ -434,7 +434,7 @@ ichsmb_bread(device_t dev, u_char slave, mtx_lock(&sc->mutex); sc->ich_cmd = ICH_HST_CNT_SMB_CMD_BLOCK; bus_write_1(sc->io_res, ICH_XMIT_SLVA, - (slave << 1) | ICH_XMIT_SLVA_READ); + slave | ICH_XMIT_SLVA_READ); bus_write_1(sc->io_res, ICH_HST_CMD, cmd); bus_write_1(sc->io_res, ICH_D0, *count); /* XXX? */ bus_write_1(sc->io_res, ICH_HST_CNT, Modified: head/sys/dev/ipmi/ipmi_smbios.c ============================================================================== --- head/sys/dev/ipmi/ipmi_smbios.c Tue Feb 3 16:00:20 2009 (r188076) +++ head/sys/dev/ipmi/ipmi_smbios.c Tue Feb 3 16:14:37 2009 (r188077) @@ -154,10 +154,10 @@ smbios_t38_proc_info(uint8_t *p, char ** case SSIF_MODE: if ((s->base_address & 0xffffffffffffff00) != 0) { printf("SMBIOS: Invalid SSIF SMBus address, using BMC I2C slave address instead\n"); - info->address = s->i2c_slave_address >> 1; + info->address = s->i2c_slave_address; break; } - info->address = IPMI_BAR_ADDR(s->base_address) >> 1; + info->address = IPMI_BAR_ADDR(s->base_address); break; default: return; Modified: head/sys/dev/smbus/smb.c ============================================================================== --- head/sys/dev/smbus/smb.c Tue Feb 3 16:00:20 2009 (r188076) +++ head/sys/dev/smbus/smb.c Tue Feb 3 16:14:37 2009 (r188077) @@ -180,6 +180,10 @@ smbioctl(struct cdev *dev, u_long cmd, c parent = device_get_parent(smbdev); + /* Make sure that LSB bit is cleared. */ + if (s->slave & 0x1) + return (EINVAL); + /* Allocate the bus. */ if ((error = smbus_request_bus(parent, smbdev, (flags & O_NONBLOCK) ? SMB_DONTWAIT : (SMB_WAIT | SMB_INTR)))) From jhb at FreeBSD.org Tue Feb 3 08:39:52 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Feb 3 08:40:29 2009 Subject: svn commit: r188078 - head/sys/dev/ipmi Message-ID: <200902031639.n13GdpCK035502@svn.freebsd.org> Author: jhb Date: Tue Feb 3 16:39:51 2009 New Revision: 188078 URL: http://svn.freebsd.org/changeset/base/188078 Log: Don't right-adjust the SMBus slave address for SSIF IPMI BMCs enumerated via ACPI either. This is somewhat academic since we don't currently support such devices though. Modified: head/sys/dev/ipmi/ipmi_acpi.c Modified: head/sys/dev/ipmi/ipmi_acpi.c ============================================================================== --- head/sys/dev/ipmi/ipmi_acpi.c Tue Feb 3 16:14:37 2009 (r188077) +++ head/sys/dev/ipmi/ipmi_acpi.c Tue Feb 3 16:39:51 2009 (r188078) @@ -104,7 +104,7 @@ ipmi_acpi_attach(device_t dev) case SSIF_MODE: if (ACPI_FAILURE(acpi_GetInteger(devh, "_ADR", &flags))) return (ENXIO); - info.address = flags >> 1; + info.address = flags; device_printf(dev, "SSIF interface not supported on ACPI\n"); return (0); default: From gavin at FreeBSD.org Tue Feb 3 08:45:23 2009 From: gavin at FreeBSD.org (Gavin Atkinson) Date: Tue Feb 3 08:45:35 2009 Subject: svn commit: r188077 - in head/sys/dev: ichsmb ipmi smbus In-Reply-To: <200902031614.n13GEbAt034978@svn.freebsd.org> References: <200902031614.n13GEbAt034978@svn.freebsd.org> Message-ID: <1233679515.51684.60.camel@buffy.york.ac.uk> On Tue, 2009-02-03 at 16:14 +0000, John Baldwin wrote: > Author: jhb > Date: Tue Feb 3 16:14:37 2009 > New Revision: 188077 > URL: http://svn.freebsd.org/changeset/base/188077 > > Log: > - Change ichsmb(4) to follow the format of all the other smbus controllers > for slave addressing by using left-adjusted slave addresses (i.e. > xxxxxxx0b). Thank you! This is kern/100513 (although the PR believed that ichsmb was the correct one, not the one at fault). >From my experience, the way FreeBSD now do it seems to be the "more standard" way, in that I2C datasheets usually give the xxxxxxx0b address as the device address, however NetBSD (at least) seems to use the address in the MSB=0 form. I suspect this is probably worth documenting explicitly somewhere. Gavin From sbruno at FreeBSD.org Tue Feb 3 09:13:38 2009 From: sbruno at FreeBSD.org (Sean Bruno) Date: Tue Feb 3 09:13:50 2009 Subject: svn commit: r188079 - head/sys/dev/firewire Message-ID: <200902031713.n13HDcB9036259@svn.freebsd.org> Author: sbruno Date: Tue Feb 3 17:13:37 2009 New Revision: 188079 URL: http://svn.freebsd.org/changeset/base/188079 Log: Delete fwohci_filt() as it is now unused Obtained from: Marius Strobl MFC after: 2 weeks Modified: head/sys/dev/firewire/fwohcivar.h Modified: head/sys/dev/firewire/fwohcivar.h ============================================================================== --- head/sys/dev/firewire/fwohcivar.h Tue Feb 3 16:39:51 2009 (r188078) +++ head/sys/dev/firewire/fwohcivar.h Tue Feb 3 17:13:37 2009 (r188079) @@ -78,7 +78,6 @@ typedef struct fwohci_softc { } fwohci_softc_t; void fwohci_intr (void *arg); -void fwohci_filt (void *arg); int fwohci_init (struct fwohci_softc *, device_t); void fwohci_poll (struct firewire_comm *, int, int); void fwohci_reset (struct fwohci_softc *, device_t); From danger at FreeBSD.org Tue Feb 3 09:58:22 2009 From: danger at FreeBSD.org (Daniel Gerzo) Date: Tue Feb 3 09:58:28 2009 Subject: svn commit: r188080 - head/lib/libc/string Message-ID: <200902031758.n13HwKHT037144@svn.freebsd.org> Author: danger (doc committer) Date: Tue Feb 3 17:58:20 2009 New Revision: 188080 URL: http://svn.freebsd.org/changeset/base/188080 Log: - ANSIfy function definitions - use nul when we are looking for a terminating character where appropriate Approved by: imp Modified: head/lib/libc/string/memccpy.c head/lib/libc/string/memchr.c head/lib/libc/string/memcmp.c head/lib/libc/string/memmem.c head/lib/libc/string/strcasecmp.c head/lib/libc/string/strcasestr.c head/lib/libc/string/strcmp.c head/lib/libc/string/strcoll.c head/lib/libc/string/strdup.c head/lib/libc/string/strmode.c head/lib/libc/string/strncmp.c head/lib/libc/string/strncpy.c head/lib/libc/string/strnstr.c head/lib/libc/string/strpbrk.c head/lib/libc/string/strsep.c head/lib/libc/string/strstr.c head/lib/libc/string/wcscat.c head/lib/libc/string/wcscmp.c head/lib/libc/string/wcscpy.c head/lib/libc/string/wcscspn.c head/lib/libc/string/wcslcat.c head/lib/libc/string/wcslcpy.c head/lib/libc/string/wcslen.c head/lib/libc/string/wcsncat.c head/lib/libc/string/wcsncmp.c head/lib/libc/string/wcspbrk.c head/lib/libc/string/wcsspn.c head/lib/libc/string/wcsstr.c head/lib/libc/string/wmemchr.c head/lib/libc/string/wmemcmp.c head/lib/libc/string/wmemcpy.c head/lib/libc/string/wmemmove.c head/lib/libc/string/wmemset.c Modified: head/lib/libc/string/memccpy.c ============================================================================== --- head/lib/libc/string/memccpy.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/memccpy.c Tue Feb 3 17:58:20 2009 (r188080) @@ -36,11 +36,7 @@ __FBSDID("$FreeBSD$"); #include void * -memccpy(t, f, c, n) - void *t; - const void *f; - int c; - size_t n; +memccpy(void *t, const void *f, int c, size_t n) { if (n) { Modified: head/lib/libc/string/memchr.c ============================================================================== --- head/lib/libc/string/memchr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/memchr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -39,10 +39,7 @@ __FBSDID("$FreeBSD$"); #include void * -memchr(s, c, n) - const void *s; - unsigned char c; - size_t n; +memchr(const void *s, unsigned char c, size_t n) { if (n != 0) { const unsigned char *p = s; Modified: head/lib/libc/string/memcmp.c ============================================================================== --- head/lib/libc/string/memcmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/memcmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); * Compare memory regions. */ int -memcmp(s1, s2, n) - const void *s1, *s2; - size_t n; +memcmp(const void *s1, const void *s2, size_t n) { if (n != 0) { const unsigned char *p1 = s1, *p2 = s2; Modified: head/lib/libc/string/memmem.c ============================================================================== --- head/lib/libc/string/memmem.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/memmem.c Tue Feb 3 17:58:20 2009 (r188080) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); */ void * -memmem(l, l_len, s, s_len) - const void *l; size_t l_len; - const void *s; size_t s_len; +memmem(const void *l, size_t l_len, const void *s, size_t s_len) { register char *cur, *last; const char *cl = (const char *)l; Modified: head/lib/libc/string/strcasecmp.c ============================================================================== --- head/lib/libc/string/strcasecmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strcasecmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -39,8 +39,7 @@ __FBSDID("$FreeBSD$"); typedef unsigned char u_char; int -strcasecmp(s1, s2) - const char *s1, *s2; +strcasecmp(const char *s1, const char *s2) { const u_char *us1 = (const u_char *)s1, @@ -53,9 +52,7 @@ strcasecmp(s1, s2) } int -strncasecmp(s1, s2, n) - const char *s1, *s2; - size_t n; +strncasecmp(const char *s1, const char *s2, size_t n) { if (n != 0) { const u_char Modified: head/lib/libc/string/strcasestr.c ============================================================================== --- head/lib/libc/string/strcasestr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strcasestr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -40,8 +40,7 @@ __FBSDID("$FreeBSD$"); * Find the first occurrence of find in s, ignore case. */ char * -strcasestr(s, find) - const char *s, *find; +strcasestr(const char *s, const char *find) { char c, sc; size_t len; Modified: head/lib/libc/string/strcmp.c ============================================================================== --- head/lib/libc/string/strcmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strcmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -42,11 +42,10 @@ __FBSDID("$FreeBSD$"); * Compare strings. */ int -strcmp(s1, s2) - const char *s1, *s2; +strcmp(const char *s1, const char *s2) { while (*s1 == *s2++) - if (*s1++ == 0) + if (*s1++ == '\0') return (0); return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); } Modified: head/lib/libc/string/strcoll.c ============================================================================== --- head/lib/libc/string/strcoll.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strcoll.c Tue Feb 3 17:58:20 2009 (r188080) @@ -33,8 +33,7 @@ __FBSDID("$FreeBSD$"); #include "collate.h" int -strcoll(s, s2) - const char *s, *s2; +strcoll(const char *s, const char *s2) { int len, len2, prim, prim2, sec, sec2, ret, ret2; const char *t, *t2; Modified: head/lib/libc/string/strdup.c ============================================================================== --- head/lib/libc/string/strdup.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strdup.c Tue Feb 3 17:58:20 2009 (r188080) @@ -38,8 +38,7 @@ __FBSDID("$FreeBSD$"); #include char * -strdup(str) - const char *str; +strdup(const char *str) { size_t len; char *copy; Modified: head/lib/libc/string/strmode.c ============================================================================== --- head/lib/libc/string/strmode.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strmode.c Tue Feb 3 17:58:20 2009 (r188080) @@ -38,9 +38,7 @@ __FBSDID("$FreeBSD$"); #include void -strmode(mode, p) - mode_t mode; - char *p; +strmode(mode_t mode, char *p) { /* print type */ switch (mode & S_IFMT) { Modified: head/lib/libc/string/strncmp.c ============================================================================== --- head/lib/libc/string/strncmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strncmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$"); #include int -strncmp(s1, s2, n) - const char *s1, *s2; - size_t n; +strncmp(const char *s1, const char *s2, size_t n) { if (n == 0) @@ -47,7 +45,7 @@ strncmp(s1, s2, n) if (*s1 != *s2++) return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); - if (*s1++ == 0) + if (*s1++ == '\0') break; } while (--n != 0); return (0); Modified: head/lib/libc/string/strncpy.c ============================================================================== --- head/lib/libc/string/strncpy.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strncpy.c Tue Feb 3 17:58:20 2009 (r188080) @@ -50,10 +50,10 @@ strncpy(char * __restrict dst, const cha const char *s = src; do { - if ((*d++ = *s++) == 0) { + if ((*d++ = *s++) == '\0') { /* NUL pad the remaining n-1 bytes */ while (--n != 0) - *d++ = 0; + *d++ = '\0'; break; } } while (--n != 0); Modified: head/lib/libc/string/strnstr.c ============================================================================== --- head/lib/libc/string/strnstr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strnstr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -44,10 +44,7 @@ __FBSDID("$FreeBSD$"); * first slen characters of s. */ char * -strnstr(s, find, slen) - const char *s; - const char *find; - size_t slen; +strnstr(const char *s, const char *find, size_t slen) { char c, sc; size_t len; Modified: head/lib/libc/string/strpbrk.c ============================================================================== --- head/lib/libc/string/strpbrk.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strpbrk.c Tue Feb 3 17:58:20 2009 (r188080) @@ -39,14 +39,13 @@ __FBSDID("$FreeBSD$"); * Find the first occurrence in s1 of a character in s2 (excluding NUL). */ char * -strpbrk(s1, s2) - const char *s1, *s2; +strpbrk(const char *s1, const char *s2) { const char *scanp; int c, sc; while ((c = *s1++) != 0) { - for (scanp = s2; (sc = *scanp++) != 0;) + for (scanp = s2; (sc = *scanp++) != '\0';) if (sc == c) return ((char *)(s1 - 1)); } Modified: head/lib/libc/string/strsep.c ============================================================================== --- head/lib/libc/string/strsep.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strsep.c Tue Feb 3 17:58:20 2009 (r188080) @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * If *stringp is NULL, strsep returns NULL. */ char * -strsep(stringp, delim) - char **stringp; - const char *delim; +strsep(char **stringp, const char *delim) { char *s; const char *spanp; Modified: head/lib/libc/string/strstr.c ============================================================================== --- head/lib/libc/string/strstr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/strstr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -42,17 +42,16 @@ __FBSDID("$FreeBSD$"); * Find the first occurrence of find in s. */ char * -strstr(s, find) - const char *s, *find; +strstr(const char *s, const char *find) { char c, sc; size_t len; - if ((c = *find++) != 0) { + if ((c = *find++) != '\0') { len = strlen(find); do { do { - if ((sc = *s++) == 0) + if ((sc = *s++) == '\0') return (NULL); } while (sc != c); } while (strncmp(s, find, len) != 0); Modified: head/lib/libc/string/wcscat.c ============================================================================== --- head/lib/libc/string/wcscat.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcscat.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wcscat(s1, s2) - wchar_t * __restrict s1; - const wchar_t * __restrict s2; +wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2) { wchar_t *cp; Modified: head/lib/libc/string/wcscmp.c ============================================================================== --- head/lib/libc/string/wcscmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcscmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -45,12 +45,11 @@ __FBSDID("$FreeBSD$"); * Compare strings. */ int -wcscmp(s1, s2) - const wchar_t *s1, *s2; +wcscmp(const wchar_t *s1, const wchar_t *s2) { while (*s1 == *s2++) - if (*s1++ == 0) + if (*s1++ == '\0') return (0); /* XXX assumes wchar_t = int */ return (*(const unsigned int *)s1 - *(const unsigned int *)--s2); Modified: head/lib/libc/string/wcscpy.c ============================================================================== --- head/lib/libc/string/wcscpy.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcscpy.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wcscpy(s1, s2) - wchar_t * __restrict s1; - const wchar_t * __restrict s2; +wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2) { wchar_t *cp; Modified: head/lib/libc/string/wcscspn.c ============================================================================== --- head/lib/libc/string/wcscspn.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcscspn.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include size_t -wcscspn(s, set) - const wchar_t *s; - const wchar_t *set; +wcscspn(const wchar_t *s, const wchar_t *set) { const wchar_t *p; const wchar_t *q; Modified: head/lib/libc/string/wcslcat.c ============================================================================== --- head/lib/libc/string/wcslcat.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcslcat.c Tue Feb 3 17:58:20 2009 (r188080) @@ -46,10 +46,7 @@ __FBSDID("$FreeBSD$"); * truncation occurred. */ size_t -wcslcat(dst, src, siz) - wchar_t *dst; - const wchar_t *src; - size_t siz; +wcslcat(wchar_t *dst, const wchar_t *src, size_t siz) { wchar_t *d = dst; const wchar_t *s = src; Modified: head/lib/libc/string/wcslcpy.c ============================================================================== --- head/lib/libc/string/wcslcpy.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcslcpy.c Tue Feb 3 17:58:20 2009 (r188080) @@ -44,10 +44,7 @@ __FBSDID("$FreeBSD$"); * Returns wcslen(src); if retval >= siz, truncation occurred. */ size_t -wcslcpy(dst, src, siz) - wchar_t *dst; - const wchar_t *src; - size_t siz; +wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz) { wchar_t *d = dst; const wchar_t *s = src; Modified: head/lib/libc/string/wcslen.c ============================================================================== --- head/lib/libc/string/wcslen.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcslen.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,8 +37,7 @@ __FBSDID("$FreeBSD$"); #include size_t -wcslen(s) - const wchar_t *s; +wcslen(const wchar_t *s) { const wchar_t *p; Modified: head/lib/libc/string/wcsncat.c ============================================================================== --- head/lib/libc/string/wcsncat.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcsncat.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wcsncat(s1, s2, n) - wchar_t * __restrict s1; - const wchar_t * __restrict s2; - size_t n; +wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n) { wchar_t *p; wchar_t *q; Modified: head/lib/libc/string/wcsncmp.c ============================================================================== --- head/lib/libc/string/wcsncmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcsncmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$"); #include int -wcsncmp(s1, s2, n) - const wchar_t *s1, *s2; - size_t n; +wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n) { if (n == 0) Modified: head/lib/libc/string/wcspbrk.c ============================================================================== --- head/lib/libc/string/wcspbrk.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcspbrk.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wcspbrk(s, set) - const wchar_t *s; - const wchar_t *set; +wcspbrk(const wchar_t *s, const wchar_t *set) { const wchar_t *p; const wchar_t *q; Modified: head/lib/libc/string/wcsspn.c ============================================================================== --- head/lib/libc/string/wcsspn.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcsspn.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$"); #include size_t -wcsspn(s, set) - const wchar_t *s; - const wchar_t *set; +wcsspn(const wchar_t *s, const wchar_t *set) { const wchar_t *p; const wchar_t *q; Modified: head/lib/libc/string/wcsstr.c ============================================================================== --- head/lib/libc/string/wcsstr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wcsstr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -49,7 +49,7 @@ wcsstr(const wchar_t * __restrict s, con wchar_t c, sc; size_t len; - if ((c = *find++) != 0) { + if ((c = *find++) != L'\0') { len = wcslen(find); do { do { Modified: head/lib/libc/string/wmemchr.c ============================================================================== --- head/lib/libc/string/wmemchr.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wmemchr.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wmemchr(s, c, n) - const wchar_t *s; - wchar_t c; - size_t n; +wmemchr(const wchar_t *s, wchar_t c, size_t n) { size_t i; Modified: head/lib/libc/string/wmemcmp.c ============================================================================== --- head/lib/libc/string/wmemcmp.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wmemcmp.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$"); #include int -wmemcmp(s1, s2, n) - const wchar_t *s1; - const wchar_t *s2; - size_t n; +wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n) { size_t i; Modified: head/lib/libc/string/wmemcpy.c ============================================================================== --- head/lib/libc/string/wmemcpy.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wmemcpy.c Tue Feb 3 17:58:20 2009 (r188080) @@ -38,11 +38,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wmemcpy(d, s, n) - wchar_t * __restrict d; - const wchar_t * __restrict s; - size_t n; +wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n) { - return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t)); } Modified: head/lib/libc/string/wmemmove.c ============================================================================== --- head/lib/libc/string/wmemmove.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wmemmove.c Tue Feb 3 17:58:20 2009 (r188080) @@ -38,11 +38,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wmemmove(d, s, n) - wchar_t *d; - const wchar_t *s; - size_t n; +wmemmove(wchar_t *d, const wchar_t *s, size_t n) { - return (wchar_t *)memmove(d, s, n * sizeof(wchar_t)); } Modified: head/lib/libc/string/wmemset.c ============================================================================== --- head/lib/libc/string/wmemset.c Tue Feb 3 17:13:37 2009 (r188079) +++ head/lib/libc/string/wmemset.c Tue Feb 3 17:58:20 2009 (r188080) @@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wmemset(s, c, n) - wchar_t *s; - wchar_t c; - size_t n; +wmemset(wchar_t *s, wchar_t *c, size_t n) { size_t i; wchar_t *p; From sam at FreeBSD.org Tue Feb 3 11:00:58 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:01:05 2009 Subject: svn commit: r188084 - in head/sys/dev/ath/ath_hal: . ar5416 Message-ID: <200902031900.n13J0vl1038649@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:00:56 2009 New Revision: 188084 URL: http://svn.freebsd.org/changeset/base/188084 Log: fix compilation w/ AH_DEBUG Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain.c Tue Feb 3 18:52:53 2009 (r188083) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Tue Feb 3 19:00:56 2009 (r188084) @@ -2219,7 +2219,7 @@ assignPrivateChannels(struct ath_hal *ah /* new entry, assign a private channel entry */ if (next >= N(AH_PRIVATE(ah)->ah_channels)) { HALDEBUG(ah, HAL_DEBUG_ANY, - "%s: too many channels, max %u\n", + "%s: too many channels, max %zu\n", __func__, N(AH_PRIVATE(ah)->ah_channels)); return AH_FALSE; } Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Tue Feb 3 18:52:53 2009 (r188083) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c Tue Feb 3 19:00:56 2009 (r188084) @@ -392,7 +392,7 @@ ar5416PerCalibrationN(struct ath_hal *ah HAL_CAL_LIST *currCal = cal->cal_curr; HAL_CHANNEL_INTERNAL *ichan; - OS_MARK(ah, AH_MARK_PERCAL, chan->channel); + OS_MARK(ah, AH_MARK_PERCAL, chan->ic_freq); *isCalDone = AH_TRUE; From sam at FreeBSD.org Tue Feb 3 11:06:13 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:06:24 2009 Subject: svn commit: r188085 - head/sys/arm/include Message-ID: <200902031906.n13J6CYC038788@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:06:12 2009 New Revision: 188085 URL: http://svn.freebsd.org/changeset/base/188085 Log: force atomic_cmpset_ptr types to match atomic_cmpset_32; this matches what powerpc does Submitted by: stass MFC after: 2 weeks Modified: head/sys/arm/include/atomic.h Modified: head/sys/arm/include/atomic.h ============================================================================== --- head/sys/arm/include/atomic.h Tue Feb 3 19:00:56 2009 (r188084) +++ head/sys/arm/include/atomic.h Tue Feb 3 19:06:12 2009 (r188085) @@ -344,7 +344,8 @@ atomic_readandclear_32(volatile u_int32_ #define atomic_clear_ptr atomic_clear_32 #define atomic_set_ptr atomic_set_32 -#define atomic_cmpset_ptr atomic_cmpset_32 +#define atomic_cmpset_ptr(dst, old, new) \ + atomic_cmpset_32((volatile u_int *)(dst), (u_int)(old), (u_int)(new)) #define atomic_cmpset_rel_ptr atomic_cmpset_ptr #define atomic_cmpset_acq_ptr atomic_cmpset_ptr #define atomic_store_ptr atomic_store_32 From sam at FreeBSD.org Tue Feb 3 11:07:42 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:08:03 2009 Subject: svn commit: r188086 - head/sys/dev/cfi Message-ID: <200902031907.n13J7f2f038855@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:07:41 2009 New Revision: 188086 URL: http://svn.freebsd.org/changeset/base/188086 Log: reorg ioctl code to simplify adding new requests Modified: head/sys/dev/cfi/cfi_dev.c Modified: head/sys/dev/cfi/cfi_dev.c ============================================================================== --- head/sys/dev/cfi/cfi_dev.c Tue Feb 3 19:06:12 2009 (r188085) +++ head/sys/dev/cfi/cfi_dev.c Tue Feb 3 19:07:41 2009 (r188086) @@ -252,26 +252,31 @@ cfi_devioctl(struct cdev *dev, u_long cm int error; u_char val; - if (cmd != CFIOCQRY) - return (ENOIOCTL); - sc = dev->si_drv1; + error = 0; - error = (sc->sc_writing) ? cfi_block_finish(sc) : 0; - if (error) - return (error); - - rq = (struct cfiocqry *)data; - - if (rq->offset >= sc->sc_size / sc->sc_width) - return (ESPIPE); - if (rq->offset + rq->count > sc->sc_size / sc->sc_width) - return (ENOSPC); - - while (!error && rq->count--) { - val = cfi_read_qry(sc, rq->offset++); - error = copyout(&val, rq->buffer++, 1); + switch(cmd) { + case CFIOCQRY: + if (sc->sc_writing) { + error = cfi_block_finish(sc); + if (error) + break; + } + + rq = (struct cfiocqry *)data; + if (rq->offset >= sc->sc_size / sc->sc_width) + return (ESPIPE); + if (rq->offset + rq->count > sc->sc_size / sc->sc_width) + return (ENOSPC); + + while (!error && rq->count--) { + val = cfi_read_qry(sc, rq->offset++); + error = copyout(&val, rq->buffer++, 1); + } + break; + default: + error = ENOIOCTL; + break; } - return (error); } From sam at FreeBSD.org Tue Feb 3 11:09:17 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:09:29 2009 Subject: svn commit: r188087 - head/sys/dev/cfi Message-ID: <200902031909.n13J9GFf038922@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:09:16 2009 New Revision: 188087 URL: http://svn.freebsd.org/changeset/base/188087 Log: honor any interface width (e.g. setup by the bus shim) and don't probe; this is needed for the moment to workaround bus shim issues Added: head/sys/dev/cfi/cfi_bus_ixp4xx.c (contents, props changed) Modified: head/sys/dev/cfi/cfi_core.c Added: head/sys/dev/cfi/cfi_bus_ixp4xx.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/cfi/cfi_bus_ixp4xx.c Tue Feb 3 19:09:16 2009 (r188087) @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 2009 Sam Leffler, Errno Consulting + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +static int +cfi_ixp4xx_probe(device_t dev) +{ + struct cfi_softc *sc = device_get_softc(dev); + /* + * NB: we assume the boot loader sets up EXP_TIMING_CS0_OFFSET + * according to the flash on the board. If it does not then it + * can be done here. + */ + if (bootverbose) { + struct ixp425_softc *sa = + device_get_softc(device_get_parent(dev)); + device_printf(dev, "EXP_TIMING_CS0_OFFSET 0x%x\n", + EXP_BUS_READ_4(sa, EXP_TIMING_CS0_OFFSET)); + } + sc->sc_width = 2; /* NB: don't probe interface width */ + return cfi_probe(dev); +} + +static device_method_t cfi_ixp4xx_methods[] = { + /* device interface */ + DEVMETHOD(device_probe, cfi_ixp4xx_probe), + DEVMETHOD(device_attach, cfi_attach), + DEVMETHOD(device_detach, cfi_detach), + + {0, 0} +}; + +static driver_t cfi_ixp4xx_driver = { + cfi_driver_name, + cfi_ixp4xx_methods, + sizeof(struct cfi_softc), +}; +DRIVER_MODULE (cfi, ixp, cfi_ixp4xx_driver, cfi_devclass, 0, 0); Modified: head/sys/dev/cfi/cfi_core.c ============================================================================== --- head/sys/dev/cfi/cfi_core.c Tue Feb 3 19:07:41 2009 (r188086) +++ head/sys/dev/cfi/cfi_core.c Tue Feb 3 19:09:16 2009 (r188087) @@ -150,11 +150,16 @@ cfi_probe(device_t dev) sc->sc_tag = rman_get_bustag(sc->sc_res); sc->sc_handle = rman_get_bushandle(sc->sc_res); - sc->sc_width = 1; - while (sc->sc_width <= 4) { - if (cfi_read_qry(sc, CFI_QRY_IDENT) == 'Q') - break; - sc->sc_width <<= 1; + if (sc->sc_width == 0) { + sc->sc_width = 1; + while (sc->sc_width <= 4) { + if (cfi_read_qry(sc, CFI_QRY_IDENT) == 'Q') + break; + sc->sc_width <<= 1; + } + } else if (cfi_read_qry(sc, CFI_QRY_IDENT) != 'Q') { + error = ENXIO; + goto out; } if (sc->sc_width > 4) { error = ENXIO; From sam at freebsd.org Tue Feb 3 11:11:32 2009 From: sam at freebsd.org (Sam Leffler) Date: Tue Feb 3 11:11:39 2009 Subject: svn commit: r188087 - head/sys/dev/cfi In-Reply-To: <200902031909.n13J9GFf038922@svn.freebsd.org> References: <200902031909.n13J9GFf038922@svn.freebsd.org> Message-ID: <498896E3.2080702@freebsd.org> Sam Leffler wrote: > Author: sam > Date: Tue Feb 3 19:09:16 2009 > New Revision: 188087 > URL: http://svn.freebsd.org/changeset/base/188087 > > Log: > honor any interface width (e.g. setup by the bus shim) and don't probe; > this is needed for the moment to workaround bus shim issues > > Added: > head/sys/dev/cfi/cfi_bus_ixp4xx.c (contents, props changed) > Modified: > head/sys/dev/cfi/cfi_core.c > > Sigh, this was supposed to only commit cfi_core.c but also caught the xscale bus shim. Not sure if there's any way to fix this. Sure wish svn worked like perforce and let you edit the commit list. Sam From sam at FreeBSD.org Tue Feb 3 11:16:06 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:16:13 2009 Subject: svn commit: r188088 - in head/sys/arm: conf xscale/ixp425 Message-ID: <200902031916.n13JG4X9039115@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:16:04 2009 New Revision: 188088 URL: http://svn.freebsd.org/changeset/base/188088 Log: Add support for the StrataFlash on 2348 boards: o add bus shim for cfi driver o add static mapping for CS0 (we map all 16M as the cfi driver doesn't support demand mapping) Note this needs some tweaking to work for 2358 boards which is why the CAMBRIA config is not touched. Modified: head/sys/arm/conf/AVILA head/sys/arm/conf/AVILA.hints head/sys/arm/xscale/ixp425/avila_machdep.c head/sys/arm/xscale/ixp425/files.ixp425 head/sys/arm/xscale/ixp425/ixp425.c head/sys/arm/xscale/ixp425/ixp425reg.h Modified: head/sys/arm/conf/AVILA ============================================================================== --- head/sys/arm/conf/AVILA Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/conf/AVILA Tue Feb 3 19:16:04 2009 (r188088) @@ -66,13 +66,15 @@ options BOOTP_COMPAT device pci device uart +device ixpwdog # watchdog timer +device cfi # flash support + # I2C Bus device iicbus device iicbb device iic device ixpiic # I2C bus glue -device ixpwdog # watchdog timer device ds1672 # DS1672 on I2C bus device ad7418 # AD7418 on I2C bus Modified: head/sys/arm/conf/AVILA.hints ============================================================================== --- head/sys/arm/conf/AVILA.hints Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/conf/AVILA.hints Tue Feb 3 19:16:04 2009 (r188088) @@ -29,6 +29,10 @@ hint.npe.1.mac="C" hint.npe.1.mii="B" hint.npe.1.phy=1 +# FLASH +hint.cfi.0.at="ixp0" +hint.cfi.0.addr=0x50000000 + # CF IDE controller hint.ata_avila.0.at="ixp0" Modified: head/sys/arm/xscale/ixp425/avila_machdep.c ============================================================================== --- head/sys/arm/xscale/ixp425/avila_machdep.c Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/xscale/ixp425/avila_machdep.c Tue Feb 3 19:16:04 2009 (r188088) @@ -154,6 +154,10 @@ static const struct pmap_devmap ixp425_d { IXP425_EXP_VBASE, IXP425_EXP_HWBASE, IXP425_EXP_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, + /* CFI Flash on the Expansion Bus */ + { IXP425_EXP_BUS_CS0_VBASE, IXP425_EXP_BUS_CS0_HWBASE, + IXP425_EXP_BUS_CS0_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, + /* IXP425 PCI Configuration */ { IXP425_PCI_VBASE, IXP425_PCI_HWBASE, IXP425_PCI_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, }, Modified: head/sys/arm/xscale/ixp425/files.ixp425 ============================================================================== --- head/sys/arm/xscale/ixp425/files.ixp425 Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/xscale/ixp425/files.ixp425 Tue Feb 3 19:16:04 2009 (r188088) @@ -15,6 +15,7 @@ arm/xscale/ixp425/uart_cpu_ixp425.c opti arm/xscale/ixp425/uart_bus_ixp425.c optional uart arm/xscale/ixp425/ixp425_a4x_space.c optional uart arm/xscale/ixp425/ixp425_a4x_io.S optional uart +dev/cfi/cfi_bus_ixp4xx.c optional cfi dev/uart/uart_dev_ns8250.c optional uart # # NPE-based Ethernet support (requires qmgr also). Modified: head/sys/arm/xscale/ixp425/ixp425.c ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425.c Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/xscale/ixp425/ixp425.c Tue Feb 3 19:16:04 2009 (r188088) @@ -329,6 +329,8 @@ static const struct { { IXP425_IO_HWBASE, IXP425_IO_SIZE, IXP425_IO_VBASE }, { IXP425_PCI_HWBASE, IXP425_PCI_SIZE, IXP425_PCI_VBASE }, { IXP425_PCI_MEM_HWBASE,IXP425_PCI_MEM_SIZE, IXP425_PCI_MEM_VBASE }, + { IXP425_EXP_BUS_CS0_HWBASE, IXP425_EXP_BUS_CS0_SIZE, + IXP425_EXP_BUS_CS0_VBASE }, /* NB: needed only for uart_cpu_getdev */ { IXP425_UART0_HWBASE, IXP425_REG_SIZE, IXP425_UART0_VBASE }, { IXP425_UART1_HWBASE, IXP425_REG_SIZE, IXP425_UART1_VBASE }, Modified: head/sys/arm/xscale/ixp425/ixp425reg.h ============================================================================== --- head/sys/arm/xscale/ixp425/ixp425reg.h Tue Feb 3 19:09:16 2009 (r188087) +++ head/sys/arm/xscale/ixp425/ixp425reg.h Tue Feb 3 19:16:04 2009 (r188088) @@ -76,6 +76,10 @@ * Global cache clean area * FF00 0000 --------------------------- * + * FE00 0000 --------------------------- + * 16M CFI Flash (on ext bus) + * FD00 0000 --------------------------- + * * FC00 0000 --------------------------- * PCI Data (memory space) * F800 0000 --------------------------- IXP425_PCI_MEM_VBASE @@ -649,6 +653,9 @@ #define IXP425_EXP_BUS_CSx_VBASE(i) \ (IXP425_MAC_B_VBASE + (i)*IXP425_MAC_B_SIZE) +#define IXP425_EXP_BUS_CS0_HWBASE IXP425_EXP_BUS_CSx_HWBASE(0) +#define IXP425_EXP_BUS_CS0_VBASE 0xFD000000UL +#define IXP425_EXP_BUS_CS0_SIZE 0x01000000 /* NB: 16M */ #define IXP425_EXP_BUS_CS1_HWBASE IXP425_EXP_BUS_CSx_HWBASE(1) #define IXP425_EXP_BUS_CS1_VBASE IXP425_EXP_BUS_CSx_VBASE(1) #define IXP425_EXP_BUS_CS1_SIZE 0x1000 @@ -663,7 +670,6 @@ #define IXP425_EXP_BUS_CS4_SIZE 0x1000 /* NB: not mapped (yet) */ -#define IXP425_EXP_BUS_CS0_HWBASE IXP425_EXP_BUS_CSx_HWBASE(0) #define IXP425_EXP_BUS_CS5_HWBASE IXP425_EXP_BUS_CSx_HWBASE(5) #define IXP425_EXP_BUS_CS6_HWBASE IXP425_EXP_BUS_CSx_HWBASE(6) #define IXP425_EXP_BUS_CS7_HWBASE IXP425_EXP_BUS_CSx_HWBASE(7) From sam at FreeBSD.org Tue Feb 3 11:21:16 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 11:21:23 2009 Subject: svn commit: r188089 - head/sys/dev/cfi Message-ID: <200902031921.n13JLFkL039243@svn.freebsd.org> Author: sam Date: Tue Feb 3 19:21:15 2009 New Revision: 188089 URL: http://svn.freebsd.org/changeset/base/188089 Log: add Roel's copyright as he did the initial version Modified: head/sys/dev/cfi/cfi_bus_ixp4xx.c Modified: head/sys/dev/cfi/cfi_bus_ixp4xx.c ============================================================================== --- head/sys/dev/cfi/cfi_bus_ixp4xx.c Tue Feb 3 19:16:04 2009 (r188088) +++ head/sys/dev/cfi/cfi_bus_ixp4xx.c Tue Feb 3 19:21:15 2009 (r188089) @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2009 Roelof Jonkman, Carlson Wireless Inc. * Copyright (c) 2009 Sam Leffler, Errno Consulting * All rights reserved. * From jhb at FreeBSD.org Tue Feb 3 11:49:22 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Tue Feb 3 11:49:35 2009 Subject: svn commit: r188093 - head/sys/dev/ppbus Message-ID: <200902031949.n13JnMM4040061@svn.freebsd.org> Author: jhb Date: Tue Feb 3 19:49:21 2009 New Revision: 188093 URL: http://svn.freebsd.org/changeset/base/188093 Log: Trim what we expose to userland in to just the constants used for the ppi(4) ioctls for bits in the control and status registers. Reviewed by: db Modified: head/sys/dev/ppbus/ppbconf.h Modified: head/sys/dev/ppbus/ppbconf.h ============================================================================== --- head/sys/dev/ppbus/ppbconf.h Tue Feb 3 19:47:31 2009 (r188092) +++ head/sys/dev/ppbus/ppbconf.h Tue Feb 3 19:49:21 2009 (r188093) @@ -29,6 +29,35 @@ #ifndef __PPBCONF_H #define __PPBCONF_H +#define n(flags) (~(flags) & (flags)) + +/* + * Parallel Port Chipset control bits. + */ +#define STROBE 0x01 +#define AUTOFEED 0x02 +#define nINIT 0x04 +#define SELECTIN 0x08 +#define IRQENABLE 0x10 +#define PCD 0x20 + +#define nSTROBE n(STROBE) +#define nAUTOFEED n(AUTOFEED) +#define INIT n(nINIT) +#define nSELECTIN n(SELECTIN) +#define nPCD n(PCD) + +/* + * Parallel Port Chipset status bits. + */ +#define TIMEOUT 0x01 +#define nFAULT 0x08 +#define SELECT 0x10 +#define PERROR 0x20 +#define nACK 0x40 +#define nBUSY 0x80 + +#ifdef _KERNEL #include /* @@ -59,34 +88,6 @@ #define PPB_IN_NIBBLE_MODE(bus) (ppb_get_mode (bus) & PPB_NIBBLE) #define PPB_IN_PS2_MODE(bus) (ppb_get_mode (bus) & PPB_PS2) -#define n(flags) (~(flags) & (flags)) - -/* - * Parallel Port Chipset control bits. - */ -#define STROBE 0x01 -#define AUTOFEED 0x02 -#define nINIT 0x04 -#define SELECTIN 0x08 -#define IRQENABLE 0x10 -#define PCD 0x20 - -#define nSTROBE n(STROBE) -#define nAUTOFEED n(AUTOFEED) -#define INIT n(nINIT) -#define nSELECTIN n(SELECTIN) -#define nPCD n(PCD) - -/* - * Parallel Port Chipset status bits. - */ -#define TIMEOUT 0x01 -#define nFAULT 0x08 -#define SELECT 0x10 -#define PERROR 0x20 -#define nACK 0x40 -#define nBUSY 0x80 - /* * Structure to store status information. */ @@ -251,7 +252,6 @@ struct callout; typedef int (*ppc_intr_handler)(void *); -#ifdef _KERNEL extern int ppb_attach_device(device_t); extern int ppb_request_bus(device_t, device_t, int); extern int ppb_release_bus(device_t, device_t); From danger at FreeBSD.org Tue Feb 3 11:52:22 2009 From: danger at FreeBSD.org (Daniel Gerzo) Date: Tue Feb 3 11:52:28 2009 Subject: svn commit: r188087 - head/sys/dev/cfi In-Reply-To: <498896E3.2080702@freebsd.org> References: <200902031909.n13J9GFf038922@svn.freebsd.org> <498896E3.2080702@freebsd.org> Message-ID: <1264011142.20090203203650@rulez.sk> Hello Sam, Tuesday, February 3, 2009, 8:11:31 PM, you wrote: > Sam Leffler wrote: >> Author: sam >> Date: Tue Feb 3 19:09:16 2009 >> New Revision: 188087 >> URL: http://svn.freebsd.org/changeset/base/188087 >> >> Log: >> honor any interface width (e.g. setup by the bus shim) and don't probe; >> this is needed for the moment to workaround bus shim issues >> >> Added: >> head/sys/dev/cfi/cfi_bus_ixp4xx.c (contents, props changed) >> Modified: >> head/sys/dev/cfi/cfi_core.c >> >> > Sigh, this was supposed to only commit cfi_core.c but also caught the > xscale bus shim. Not sure if there's any way to fix this. Sure wish > svn worked like perforce and let you edit the commit list. svn revert file? -- Best regards, Daniel mailto:danger@FreeBSD.org From christoph.mallon at gmx.de Tue Feb 3 11:58:23 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Tue Feb 3 11:58:31 2009 Subject: svn commit: r188087 - head/sys/dev/cfi In-Reply-To: <1264011142.20090203203650@rulez.sk> References: <200902031909.n13J9GFf038922@svn.freebsd.org> <498896E3.2080702@freebsd.org> <1264011142.20090203203650@rulez.sk> Message-ID: <4988A1D8.4040908@gmx.de> Daniel Gerzo schrieb: > Hello Sam, > > Tuesday, February 3, 2009, 8:11:31 PM, you wrote: > >> Sam Leffler wrote: >>> Author: sam >>> Date: Tue Feb 3 19:09:16 2009 >>> New Revision: 188087 >>> URL: http://svn.freebsd.org/changeset/base/188087 >>> >>> Log: >>> honor any interface width (e.g. setup by the bus shim) and don't probe; >>> this is needed for the moment to workaround bus shim issues >>> >>> Added: >>> head/sys/dev/cfi/cfi_bus_ixp4xx.c (contents, props changed) >>> Modified: >>> head/sys/dev/cfi/cfi_core.c >>> >>> >> Sigh, this was supposed to only commit cfi_core.c but also caught the >> xscale bus shim. Not sure if there's any way to fix this. Sure wish >> svn worked like perforce and let you edit the commit list. You can abort a commit by not modifying the commit log file at all or deleting *all* content of the commit log. You can also create changelists (svn help changelist). > svn revert file? svn revert is for throwing away local changes. But you can do the following to reverse-merge the revision: svn merge -c -$REVISION . Mind the "-" before the revision number. This is equivalent to -r $REVISION:($REVISION - 1). From ed at FreeBSD.org Tue Feb 3 11:58:34 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Tue Feb 3 11:58:48 2009 Subject: svn commit: r188096 - in head/sys: dev/snp kern sys Message-ID: <200902031958.n13JwSxQ040353@svn.freebsd.org> Author: ed Date: Tue Feb 3 19:58:28 2009 New Revision: 188096 URL: http://svn.freebsd.org/changeset/base/188096 Log: Slightly improve the design of the TTY buffer. The TTY buffers used the standard lists. Unfortunately they have a big shortcoming. If you want to have a double linked list, but no tail pointer, it's still not possible to obtain the previous element in the list. Inside the buffers we don't need them. This is why I switched to custom linked list macros. The macros will also keep track of the amount of items in the list. Because it doesn't use a sentinel, we can just initialize the queues with zero. In its simplest form (the output queue), we will only keep two references to blocks in the queue, namely the head of the list and the last block in use. All free blocks are stored behind the last block in use. I noticed there was a very subtle bug in the previous code: in a very uncommon corner case, it would uma_zfree() a block in the queue before calling memcpy() to extract the data from the block. Modified: head/sys/dev/snp/snp.c head/sys/kern/tty.c head/sys/kern/tty_inq.c head/sys/kern/tty_outq.c head/sys/sys/ttyqueue.h Modified: head/sys/dev/snp/snp.c ============================================================================== --- head/sys/dev/snp/snp.c Tue Feb 3 19:50:11 2009 (r188095) +++ head/sys/dev/snp/snp.c Tue Feb 3 19:58:28 2009 (r188096) @@ -127,7 +127,6 @@ snp_open(struct cdev *dev, int flag, int /* Allocate per-snoop data. */ ss = malloc(sizeof(struct snp_softc), M_SNP, M_WAITOK|M_ZERO); - ttyoutq_init(&ss->snp_outq); cv_init(&ss->snp_outwait, "snp out"); devfs_set_cdevpriv(ss, snp_dtor); Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Tue Feb 3 19:50:11 2009 (r188095) +++ head/sys/kern/tty.c Tue Feb 3 19:58:28 2009 (r188096) @@ -884,9 +884,6 @@ tty_alloc(struct ttydevsw *tsw, void *sc cv_init(&tp->t_bgwait, "ttybg"); cv_init(&tp->t_dcdwait, "ttydcd"); - ttyinq_init(&tp->t_inq); - ttyoutq_init(&tp->t_outq); - /* Allow drivers to use a custom mutex to lock the TTY. */ if (mutex != NULL) { tp->t_mtx = mutex; Modified: head/sys/kern/tty_inq.c ============================================================================== --- head/sys/kern/tty_inq.c Tue Feb 3 19:50:11 2009 (r188095) +++ head/sys/kern/tty_inq.c Tue Feb 3 19:58:28 2009 (r188096) @@ -79,13 +79,43 @@ SYSCTL_LONG(_kern, OID_AUTO, tty_inq_nsl ((tib)->tib_quotes[(boff) / BMSIZE] &= ~(1 << ((boff) % BMSIZE))) struct ttyinq_block { - TAILQ_ENTRY(ttyinq_block) tib_list; - uint32_t tib_quotes[TTYINQ_QUOTESIZE]; - char tib_data[TTYINQ_DATASIZE]; + struct ttyinq_block *tib_prev; + struct ttyinq_block *tib_next; + uint32_t tib_quotes[TTYINQ_QUOTESIZE]; + char tib_data[TTYINQ_DATASIZE]; }; static uma_zone_t ttyinq_zone; +#define TTYINQ_INSERT_TAIL(ti, tib) do { \ + if (ti->ti_end == 0) { \ + tib->tib_prev = NULL; \ + tib->tib_next = ti->ti_firstblock; \ + ti->ti_firstblock = tib; \ + } else { \ + tib->tib_prev = ti->ti_lastblock; \ + tib->tib_next = ti->ti_lastblock->tib_next; \ + ti->ti_lastblock->tib_next = tib; \ + } \ + if (tib->tib_next != NULL) \ + tib->tib_next->tib_prev = tib; \ + ti->ti_nblocks++; \ +} while (0) + +#define TTYINQ_REMOVE_HEAD(ti) do { \ + ti->ti_firstblock = ti->ti_firstblock->tib_next; \ + if (ti->ti_firstblock != NULL) \ + ti->ti_firstblock->tib_prev = NULL; \ + ti->ti_nblocks--; \ +} while (0) + +#define TTYINQ_RECYCLE(ti, tib) do { \ + if (ti->ti_quota <= ti->ti_nblocks) \ + uma_zfree(ttyinq_zone, tib); \ + else \ + TTYINQ_INSERT_TAIL(ti, tib); \ +} while (0) + void ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t size) { @@ -108,8 +138,7 @@ ttyinq_setsize(struct ttyinq *ti, struct tib = uma_zalloc(ttyinq_zone, M_WAITOK); tty_lock(tp); - TAILQ_INSERT_TAIL(&ti->ti_list, tib, tib_list); - ti->ti_nblocks++; + TTYINQ_INSERT_TAIL(ti, tib); } } @@ -121,10 +150,9 @@ ttyinq_free(struct ttyinq *ti) ttyinq_flush(ti); ti->ti_quota = 0; - while ((tib = TAILQ_FIRST(&ti->ti_list)) != NULL) { - TAILQ_REMOVE(&ti->ti_list, tib, tib_list); + while ((tib = ti->ti_firstblock) != NULL) { + TTYINQ_REMOVE_HEAD(ti); uma_zfree(ttyinq_zone, tib); - ti->ti_nblocks--; } MPASS(ti->ti_nblocks == 0); @@ -145,7 +173,7 @@ ttyinq_read_uio(struct ttyinq *ti, struc /* See if there still is data. */ if (ti->ti_begin == ti->ti_linestart) return (0); - tib = TAILQ_FIRST(&ti->ti_list); + tib = ti->ti_firstblock; if (tib == NULL) return (0); @@ -176,8 +204,7 @@ ttyinq_read_uio(struct ttyinq *ti, struc * Fast path: zero copy. Remove the first block, * so we can unlock the TTY temporarily. */ - TAILQ_REMOVE(&ti->ti_list, tib, tib_list); - ti->ti_nblocks--; + TTYINQ_REMOVE_HEAD(ti); ti->ti_begin = 0; /* @@ -185,11 +212,10 @@ ttyinq_read_uio(struct ttyinq *ti, struc * fix up the block offsets. */ #define CORRECT_BLOCK(t) do { \ - if (t <= TTYINQ_DATASIZE) { \ + if (t <= TTYINQ_DATASIZE) \ t = 0; \ - } else { \ + else \ t -= TTYINQ_DATASIZE; \ - } \ } while (0) CORRECT_BLOCK(ti->ti_linestart); CORRECT_BLOCK(ti->ti_reprint); @@ -207,12 +233,7 @@ ttyinq_read_uio(struct ttyinq *ti, struc tty_lock(tp); /* Block can now be readded to the list. */ - if (ti->ti_quota <= ti->ti_nblocks) { - uma_zfree(ttyinq_zone, tib); - } else { - TAILQ_INSERT_TAIL(&ti->ti_list, tib, tib_list); - ti->ti_nblocks++; - } + TTYINQ_RECYCLE(ti, tib); } else { char ob[TTYINQ_DATASIZE - 1]; atomic_add_long(&ttyinq_nslow, 1); @@ -264,25 +285,27 @@ ttyinq_write(struct ttyinq *ti, const vo size_t l; while (nbytes > 0) { - tib = ti->ti_lastblock; boff = ti->ti_end % TTYINQ_DATASIZE; if (ti->ti_end == 0) { /* First time we're being used or drained. */ MPASS(ti->ti_begin == 0); - tib = ti->ti_lastblock = TAILQ_FIRST(&ti->ti_list); + tib = ti->ti_firstblock; if (tib == NULL) { /* Queue has no blocks. */ break; } + ti->ti_lastblock = tib; } else if (boff == 0) { /* We reached the end of this block on last write. */ - tib = TAILQ_NEXT(tib, tib_list); + tib = ti->ti_lastblock->tib_next; if (tib == NULL) { /* We've reached the watermark. */ break; } ti->ti_lastblock = tib; + } else { + tib = ti->ti_lastblock; } /* Don't copy more than was requested. */ @@ -328,7 +351,7 @@ size_t ttyinq_findchar(struct ttyinq *ti, const char *breakc, size_t maxlen, char *lastc) { - struct ttyinq_block *tib = TAILQ_FIRST(&ti->ti_list); + struct ttyinq_block *tib = ti->ti_firstblock; unsigned int boff = ti->ti_begin; unsigned int bend = MIN(MIN(TTYINQ_DATASIZE, ti->ti_linestart), ti->ti_begin + maxlen); @@ -402,8 +425,7 @@ ttyinq_unputchar(struct ttyinq *ti) if (--ti->ti_end % TTYINQ_DATASIZE == 0) { /* Roll back to the previous block. */ - ti->ti_lastblock = TAILQ_PREV(ti->ti_lastblock, - ttyinq_bhead, tib_list); + ti->ti_lastblock = ti->ti_lastblock->tib_prev; /* * This can only fail if we are unputchar()'ing the * first character in the queue. @@ -437,7 +459,7 @@ ttyinq_line_iterate(struct ttyinq *ti, /* Use the proper block when we're at the queue head. */ if (offset == 0) - tib = TAILQ_FIRST(&ti->ti_list); + tib = ti->ti_firstblock; /* Iterate all characters and call the iterator function. */ for (; offset < ti->ti_end; offset++) { @@ -449,7 +471,7 @@ ttyinq_line_iterate(struct ttyinq *ti, /* Last byte iterated - go to the next block. */ if (boff == TTYINQ_DATASIZE - 1) - tib = TAILQ_NEXT(tib, tib_list); + tib = tib->tib_next; MPASS(tib != NULL); } } Modified: head/sys/kern/tty_outq.c ============================================================================== --- head/sys/kern/tty_outq.c Tue Feb 3 19:50:11 2009 (r188095) +++ head/sys/kern/tty_outq.c Tue Feb 3 19:58:28 2009 (r188096) @@ -61,12 +61,35 @@ SYSCTL_LONG(_kern, OID_AUTO, tty_outq_ns &ttyoutq_nslow, 0, "Buffered reads to userspace on output"); struct ttyoutq_block { - STAILQ_ENTRY(ttyoutq_block) tob_list; - char tob_data[TTYOUTQ_DATASIZE]; + struct ttyoutq_block *tob_next; + char tob_data[TTYOUTQ_DATASIZE]; }; static uma_zone_t ttyoutq_zone; +#define TTYOUTQ_INSERT_TAIL(to, tob) do { \ + if (to->to_end == 0) { \ + tob->tob_next = to->to_firstblock; \ + to->to_firstblock = tob; \ + } else { \ + tob->tob_next = to->to_lastblock->tob_next; \ + to->to_lastblock->tob_next = tob; \ + } \ + to->to_nblocks++; \ +} while (0) + +#define TTYOUTQ_REMOVE_HEAD(to) do { \ + to->to_firstblock = to->to_firstblock->tob_next; \ + to->to_nblocks--; \ +} while (0) + +#define TTYOUTQ_RECYCLE(to, tob) do { \ + if (to->to_quota <= to->to_nblocks) \ + uma_zfree(ttyoutq_zone, tob); \ + else \ + TTYOUTQ_INSERT_TAIL(to, tob); \ +} while(0) + void ttyoutq_flush(struct ttyoutq *to) { @@ -97,8 +120,7 @@ ttyoutq_setsize(struct ttyoutq *to, stru tob = uma_zalloc(ttyoutq_zone, M_WAITOK); tty_lock(tp); - STAILQ_INSERT_TAIL(&to->to_list, tob, tob_list); - to->to_nblocks++; + TTYOUTQ_INSERT_TAIL(to, tob); } } @@ -110,10 +132,9 @@ ttyoutq_free(struct ttyoutq *to) ttyoutq_flush(to); to->to_quota = 0; - while ((tob = STAILQ_FIRST(&to->to_list)) != NULL) { - STAILQ_REMOVE_HEAD(&to->to_list, tob_list); + while ((tob = to->to_firstblock) != NULL) { + TTYOUTQ_REMOVE_HEAD(to); uma_zfree(ttyoutq_zone, tob); - to->to_nblocks--; } MPASS(to->to_nblocks == 0); @@ -131,7 +152,7 @@ ttyoutq_read(struct ttyoutq *to, void *b /* See if there still is data. */ if (to->to_begin == to->to_end) break; - tob = STAILQ_FIRST(&to->to_list); + tob = to->to_firstblock; if (tob == NULL) break; @@ -146,30 +167,25 @@ ttyoutq_read(struct ttyoutq *to, void *b TTYOUTQ_DATASIZE); clen = cend - cbegin; - if (cend == TTYOUTQ_DATASIZE || cend == to->to_end) { + /* Copy the data out of the buffers. */ + memcpy(cbuf, tob->tob_data + cbegin, clen); + cbuf += clen; + len -= clen; + + if (cend == to->to_end) { + /* Read the complete queue. */ + to->to_begin = 0; + to->to_end = 0; + } else if (cend == TTYOUTQ_DATASIZE) { /* Read the block until the end. */ - STAILQ_REMOVE_HEAD(&to->to_list, tob_list); - if (to->to_quota < to->to_nblocks) { - uma_zfree(ttyoutq_zone, tob); - to->to_nblocks--; - } else { - STAILQ_INSERT_TAIL(&to->to_list, tob, tob_list); - } + TTYOUTQ_REMOVE_HEAD(to); to->to_begin = 0; - if (to->to_end <= TTYOUTQ_DATASIZE) { - to->to_end = 0; - } else { - to->to_end -= TTYOUTQ_DATASIZE; - } + to->to_end -= TTYOUTQ_DATASIZE; + TTYOUTQ_RECYCLE(to, tob); } else { /* Read the block partially. */ to->to_begin += clen; } - - /* Copy the data out of the buffers. */ - memcpy(cbuf, tob->tob_data + cbegin, clen); - cbuf += clen; - len -= clen; } return (cbuf - (char *)buf); @@ -197,7 +213,7 @@ ttyoutq_read_uio(struct ttyoutq *to, str /* See if there still is data. */ if (to->to_begin == to->to_end) return (0); - tob = STAILQ_FIRST(&to->to_list); + tob = to->to_firstblock; if (tob == NULL) return (0); @@ -226,14 +242,12 @@ ttyoutq_read_uio(struct ttyoutq *to, str * Fast path: zero copy. Remove the first block, * so we can unlock the TTY temporarily. */ - STAILQ_REMOVE_HEAD(&to->to_list, tob_list); - to->to_nblocks--; + TTYOUTQ_REMOVE_HEAD(to); to->to_begin = 0; - if (to->to_end <= TTYOUTQ_DATASIZE) { + if (to->to_end <= TTYOUTQ_DATASIZE) to->to_end = 0; - } else { + else to->to_end -= TTYOUTQ_DATASIZE; - } /* Temporary unlock and copy the data to userspace. */ tty_unlock(tp); @@ -241,12 +255,7 @@ ttyoutq_read_uio(struct ttyoutq *to, str tty_lock(tp); /* Block can now be readded to the list. */ - if (to->to_quota <= to->to_nblocks) { - uma_zfree(ttyoutq_zone, tob); - } else { - STAILQ_INSERT_TAIL(&to->to_list, tob, tob_list); - to->to_nblocks++; - } + TTYOUTQ_RECYCLE(to, tob); } else { char ob[TTYOUTQ_DATASIZE - 1]; atomic_add_long(&ttyoutq_nslow, 1); @@ -280,26 +289,27 @@ ttyoutq_write(struct ttyoutq *to, const size_t l; while (nbytes > 0) { - /* Offset in current block. */ - tob = to->to_lastblock; boff = to->to_end % TTYOUTQ_DATASIZE; if (to->to_end == 0) { /* First time we're being used or drained. */ MPASS(to->to_begin == 0); - tob = to->to_lastblock = STAILQ_FIRST(&to->to_list); + tob = to->to_firstblock; if (tob == NULL) { /* Queue has no blocks. */ break; } + to->to_lastblock = tob; } else if (boff == 0) { /* We reached the end of this block on last write. */ - tob = STAILQ_NEXT(tob, tob_list); + tob = to->to_lastblock->tob_next; if (tob == NULL) { /* We've reached the watermark. */ break; } to->to_lastblock = tob; + } else { + tob = to->to_lastblock; } /* Don't copy more than was requested. */ Modified: head/sys/sys/ttyqueue.h ============================================================================== --- head/sys/sys/ttyqueue.h Tue Feb 3 19:50:11 2009 (r188095) +++ head/sys/sys/ttyqueue.h Tue Feb 3 19:58:28 2009 (r188096) @@ -43,29 +43,29 @@ struct uio; /* Data input queue. */ struct ttyinq { - TAILQ_HEAD(ttyinq_bhead, ttyinq_block) ti_list; - struct ttyinq_block *ti_startblock; - struct ttyinq_block *ti_reprintblock; - struct ttyinq_block *ti_lastblock; - unsigned int ti_begin; - unsigned int ti_linestart; - unsigned int ti_reprint; - unsigned int ti_end; - unsigned int ti_nblocks; - unsigned int ti_quota; + struct ttyinq_block *ti_firstblock; + struct ttyinq_block *ti_startblock; + struct ttyinq_block *ti_reprintblock; + struct ttyinq_block *ti_lastblock; + unsigned int ti_begin; + unsigned int ti_linestart; + unsigned int ti_reprint; + unsigned int ti_end; + unsigned int ti_nblocks; + unsigned int ti_quota; }; #define TTYINQ_DATASIZE 128 /* Data output queue. */ struct ttyoutq { - STAILQ_HEAD(, ttyoutq_block) to_list; - struct ttyoutq_block *to_lastblock; - unsigned int to_begin; - unsigned int to_end; - unsigned int to_nblocks; - unsigned int to_quota; + struct ttyoutq_block *to_firstblock; + struct ttyoutq_block *to_lastblock; + unsigned int to_begin; + unsigned int to_end; + unsigned int to_nblocks; + unsigned int to_quota; }; -#define TTYOUTQ_DATASIZE (256 - sizeof(STAILQ_ENTRY(ttyoutq_block))) +#define TTYOUTQ_DATASIZE (256 - sizeof(struct ttyoutq_block *)) #ifdef _KERNEL /* Input queue handling routines. */ @@ -86,13 +86,6 @@ void ttyinq_unputchar(struct ttyinq *ti) void ttyinq_reprintpos_set(struct ttyinq *ti); void ttyinq_reprintpos_reset(struct ttyinq *ti); -static __inline void -ttyinq_init(struct ttyinq *ti) -{ - - TAILQ_INIT(&ti->ti_list); -} - static __inline size_t ttyinq_getsize(struct ttyinq *ti) { @@ -143,13 +136,6 @@ int ttyoutq_read_uio(struct ttyoutq *to, size_t ttyoutq_write(struct ttyoutq *to, const void *buf, size_t len); int ttyoutq_write_nofrag(struct ttyoutq *to, const void *buf, size_t len); -static __inline void -ttyoutq_init(struct ttyoutq *to) -{ - - STAILQ_INIT(&to->to_list); -} - static __inline size_t ttyoutq_getsize(struct ttyoutq *to) { From imp at FreeBSD.org Tue Feb 3 12:25:37 2009 From: imp at FreeBSD.org (Warner Losh) Date: Tue Feb 3 12:25:49 2009 Subject: svn commit: r188098 - head/lib/libc/string Message-ID: <200902032025.n13KPaCV041012@svn.freebsd.org> Author: imp Date: Tue Feb 3 20:25:36 2009 New Revision: 188098 URL: http://svn.freebsd.org/changeset/base/188098 Log: Fix the functions to match prototypes. The K&R definitions differ from the ANSI-C prototype due to the 'int promotion' rule. Modified: head/lib/libc/string/memchr.c head/lib/libc/string/strmode.c head/lib/libc/string/wmemset.c Modified: head/lib/libc/string/memchr.c ============================================================================== --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include void * -memchr(const void *s, unsigned char c, size_t n) +memchr(const void *s, int c, size_t n) { if (n != 0) { const unsigned char *p = s; Modified: head/lib/libc/string/strmode.c ============================================================================== --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); #include void -strmode(mode_t mode, char *p) +strmode(/* mode_t */ int mode, char *p) { /* print type */ switch (mode & S_IFMT) { Modified: head/lib/libc/string/wmemset.c ============================================================================== --- head/lib/libc/string/wmemset.c Tue Feb 3 20:01:51 2009 (r188097) +++ head/lib/libc/string/wmemset.c Tue Feb 3 20:25:36 2009 (r188098) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); #include wchar_t * -wmemset(wchar_t *s, wchar_t *c, size_t n) +wmemset(wchar_t *s, wchar_t c, size_t n) { size_t i; wchar_t *p; From christoph.mallon at gmx.de Tue Feb 3 12:28:53 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Tue Feb 3 12:28:59 2009 Subject: svn commit: r188080 - head/lib/libc/string In-Reply-To: <200902031758.n13HwKHT037144@svn.freebsd.org> References: <200902031758.n13HwKHT037144@svn.freebsd.org> Message-ID: <4988A8F8.9050409@gmx.de> Daniel Gerzo schrieb: > Author: danger (doc committer) > Date: Tue Feb 3 17:58:20 2009 > New Revision: 188080 > URL: http://svn.freebsd.org/changeset/base/188080 > > Log: > - ANSIfy function definitions > - use nul when we are looking for a terminating character where appropriate > > Approved by: imp [...] > Modified: head/lib/libc/string/memchr.c > ============================================================================== > --- head/lib/libc/string/memchr.c Tue Feb 3 17:13:37 2009 (r188079) > +++ head/lib/libc/string/memchr.c Tue Feb 3 17:58:20 2009 (r188080) > @@ -39,10 +39,7 @@ __FBSDID("$FreeBSD$"); > #include > > void * > -memchr(s, c, n) > - const void *s; > - unsigned char c; > - size_t n; > +memchr(const void *s, unsigned char c, size_t n) > { > if (n != 0) { > const unsigned char *p = s; K&R style function definitions work slightly different than ANSI. void f(x) char x; {} fits to the prototype declaration void f(int x); int in the prototype because it has to fit to the default promoted type of the parameter of the K&R function definition! So just moving types < int from the K&R declaration list into the parameter list will break things (as it does here with memchr(), because the prototype declaration correctly uses type int). Conversely void g(char x); void g(x) char x; {} are NOT compatible, but GCC incorrectly accepts this. From ed at FreeBSD.org Tue Feb 3 12:31:27 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Tue Feb 3 12:31:38 2009 Subject: svn commit: r188099 - head/sys/sys Message-ID: <200902032031.n13KVQb4041142@svn.freebsd.org> Author: ed Date: Tue Feb 3 20:31:26 2009 New Revision: 188099 URL: http://svn.freebsd.org/changeset/base/188099 Log: Remove NUMCDEVSW, which is unused since RELENG_5. Discussed with: kib Modified: head/sys/sys/conf.h Modified: head/sys/sys/conf.h ============================================================================== --- head/sys/sys/conf.h Tue Feb 3 20:25:36 2009 (r188098) +++ head/sys/sys/conf.h Tue Feb 3 20:31:26 2009 (r188099) @@ -219,8 +219,6 @@ struct cdevsw { #define d_gianttrick __d_giant.gianttrick #define d_postfree_list __d_giant.postfree_list -#define NUMCDEVSW 256 - struct module; struct devsw_module_data { From rrs at FreeBSD.org Tue Feb 3 12:33:29 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Tue Feb 3 12:33:36 2009 Subject: svn commit: r188100 - head/sys/netinet Message-ID: <200902032033.n13KXSrY041231@svn.freebsd.org> Author: rrs Date: Tue Feb 3 20:33:28 2009 New Revision: 188100 URL: http://svn.freebsd.org/changeset/base/188100 Log: LOR fix - Lock only when calling the actual code that is messing with the UDP tunnel. This means that if two users actually tried to change the tunnel port at the same time interesting things COULD result, but its probably very unlikely to happen :-) Modified: head/sys/netinet/sctp_sysctl.c Modified: head/sys/netinet/sctp_sysctl.c ============================================================================== --- head/sys/netinet/sctp_sysctl.c Tue Feb 3 20:31:26 2009 (r188099) +++ head/sys/netinet/sctp_sysctl.c Tue Feb 3 20:33:28 2009 (r188100) @@ -519,8 +519,9 @@ sysctl_sctp_udp_tunneling_check(SYSCTL_H int error; uint32_t old_sctp_udp_tunneling_port; - SCTP_INP_INFO_WLOCK(); + SCTP_INP_INFO_RLOCK(); old_sctp_udp_tunneling_port = SCTP_BASE_SYSCTL(sctp_udp_tunneling_port); + SCTP_INP_INFO_RUNLOCK(); error = sysctl_handle_int(oidp, oidp->oid_arg1, oidp->oid_arg2, req); if (error == 0) { RANGECHK(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port), SCTPCTL_UDP_TUNNELING_PORT_MIN, SCTPCTL_UDP_TUNNELING_PORT_MAX); @@ -528,6 +529,7 @@ sysctl_sctp_udp_tunneling_check(SYSCTL_H error = 0; goto out; } + SCTP_INP_INFO_WLOCK(); if (old_sctp_udp_tunneling_port) { sctp_over_udp_stop(); } @@ -536,9 +538,9 @@ sysctl_sctp_udp_tunneling_check(SYSCTL_H SCTP_BASE_SYSCTL(sctp_udp_tunneling_port) = 0; } } + SCTP_INP_INFO_WUNLOCK(); } out: - SCTP_INP_INFO_WUNLOCK(); return (error); } From christoph.mallon at gmx.de Tue Feb 3 12:35:20 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Tue Feb 3 12:35:27 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <200902032025.n13KPaCV041012@svn.freebsd.org> References: <200902032025.n13KPaCV041012@svn.freebsd.org> Message-ID: <4988AA81.6010903@gmx.de> Warner Losh schrieb: > Author: imp > Date: Tue Feb 3 20:25:36 2009 > New Revision: 188098 > URL: http://svn.freebsd.org/changeset/base/188098 > > Log: > Fix the functions to match prototypes. The K&R definitions differ > from the ANSI-C prototype due to the 'int promotion' rule. > > Modified: > head/lib/libc/string/memchr.c > head/lib/libc/string/strmode.c > head/lib/libc/string/wmemset.c > > Modified: head/lib/libc/string/memchr.c > ============================================================================== > --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) > +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) > @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); > #include > > void * > -memchr(const void *s, unsigned char c, size_t n) > +memchr(const void *s, int c, size_t n) > { > if (n != 0) { > const unsigned char *p = s; > This is not correct either, because now *p (of type unsigned char) gets compared with c (now type int). The manpage of memchr() states that "The memchr() function locates the first occurrence of c (converted to an unsigned char) in string b." The part in parentheses now is missing. This will break when you pass a negative number (e.g. -1, which should locate a byte with all bits set) to memchr(). From christoph.mallon at gmx.de Tue Feb 3 12:39:34 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Tue Feb 3 12:39:40 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <200902032025.n13KPaCV041012@svn.freebsd.org> References: <200902032025.n13KPaCV041012@svn.freebsd.org> Message-ID: <4988AB83.2050203@gmx.de> Warner Losh schrieb: > Author: imp > Date: Tue Feb 3 20:25:36 2009 > New Revision: 188098 > URL: http://svn.freebsd.org/changeset/base/188098 > > Log: > Fix the functions to match prototypes. The K&R definitions differ > from the ANSI-C prototype due to the 'int promotion' rule. > > Modified: > head/lib/libc/string/memchr.c > head/lib/libc/string/strmode.c > head/lib/libc/string/wmemset.c [...] > Modified: head/lib/libc/string/strmode.c > ============================================================================== > --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) > +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) > @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); > #include > > void > -strmode(mode_t mode, char *p) > +strmode(/* mode_t */ int mode, char *p) > { > /* print type */ > switch (mode & S_IFMT) { The manpage states that the first parameter of strmode() is a mode_t. What's wrong - the implementation (both in header and definition) or the documentation? From imp at bsdimp.com Tue Feb 3 12:43:43 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Tue Feb 3 12:44:00 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <4988AA81.6010903@gmx.de> References: <200902032025.n13KPaCV041012@svn.freebsd.org> <4988AA81.6010903@gmx.de> Message-ID: <20090203.134142.-2002504318.imp@bsdimp.com> In message: <4988AA81.6010903@gmx.de> Christoph Mallon writes: : Warner Losh schrieb: : > Author: imp : > Date: Tue Feb 3 20:25:36 2009 : > New Revision: 188098 : > URL: http://svn.freebsd.org/changeset/base/188098 : > : > Log: : > Fix the functions to match prototypes. The K&R definitions differ : > from the ANSI-C prototype due to the 'int promotion' rule. : > : > Modified: : > head/lib/libc/string/memchr.c : > head/lib/libc/string/strmode.c : > head/lib/libc/string/wmemset.c : > : > Modified: head/lib/libc/string/memchr.c : > ============================================================================== : > --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) : > +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) : > @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); : > #include : > : > void * : > -memchr(const void *s, unsigned char c, size_t n) : > +memchr(const void *s, int c, size_t n) : > { : > if (n != 0) { : > const unsigned char *p = s; : > : : This is not correct either, because now *p (of type unsigned char) gets : compared with c (now type int). The manpage of memchr() states that : : "The memchr() function locates the first occurrence of c (converted to : an unsigned char) in string b." : : The part in parentheses now is missing. This will break when you pass a : negative number (e.g. -1, which should locate a byte with all bits set) : to memchr(). I was just trying to fix the build... I'll look into the issues here. There's likely some missing casts. Warner From gabor at FreeBSD.org Tue Feb 3 12:46:06 2009 From: gabor at FreeBSD.org (Gabor Kovesdan) Date: Tue Feb 3 12:46:17 2009 Subject: svn commit: r188102 - head Message-ID: <200902032046.n13Kk5sl041527@svn.freebsd.org> Author: gabor (doc,ports committer) Date: Tue Feb 3 20:46:05 2009 New Revision: 188102 URL: http://svn.freebsd.org/changeset/base/188102 Log: Reflect adding_user.8 -> adding_user.7 rename Reminded by: kib Modified: head/ObsoleteFiles.inc Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Tue Feb 3 20:37:38 2009 (r188101) +++ head/ObsoleteFiles.inc Tue Feb 3 20:46:05 2009 (r188102) @@ -14,6 +14,8 @@ # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last. # +# 20090203: adding_user.8 moved to adding_user.7 +OLD_FILES+=usr/share/man/man8/adding_user.8.gz # 20090122: tzdata2009a import OLD_FILES+=usr/share/zoneinfo/Asia/Katmandu # 20090102: file 4.26 import From sam at FreeBSD.org Tue Feb 3 14:32:27 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Tue Feb 3 14:32:37 2009 Subject: svn commit: r188106 - head/sys/net80211 Message-ID: <200902032232.n13MWQpm044102@svn.freebsd.org> Author: sam Date: Tue Feb 3 22:32:26 2009 New Revision: 188106 URL: http://svn.freebsd.org/changeset/base/188106 Log: When crafting a media setting w/ an auto (non-fixed) rate mask out the turbo option in addition to the mode bits; otherwise if the current channel is a turbo mode channel we'll form an invalid media setting and the ifmedia_set operation in vap_attach will panic. While here use C99-style initialization for an array indexed by mode; this makes it consistent w/ other usage and avoids breakage if we should ever change the set of modes. Modified: head/sys/net80211/ieee80211.c Modified: head/sys/net80211/ieee80211.c ============================================================================== --- head/sys/net80211/ieee80211.c Tue Feb 3 22:22:07 2009 (r188105) +++ head/sys/net80211/ieee80211.c Tue Feb 3 22:32:26 2009 (r188106) @@ -472,7 +472,8 @@ ieee80211_vap_attach(struct ieee80211vap vap->iv_opmode == IEEE80211_M_STA, media_change, media_stat); ieee80211_media_status(ifp, &imr); /* NB: strip explicit mode; we're actually in autoselect */ - ifmedia_set(&vap->iv_media, imr.ifm_active &~ IFM_MMASK); + ifmedia_set(&vap->iv_media, + imr.ifm_active &~ (IFM_MMASK | IFM_IEEE80211_TURBO)); if (maxrate) ifp->if_baudrate = IF_Mbps(maxrate); @@ -857,16 +858,16 @@ addmedia(struct ifmedia *media, int caps ifmedia_add(media, \ IFM_MAKEWORD(IFM_IEEE80211, (_s), (_o), 0), 0, NULL) static const u_int mopts[IEEE80211_MODE_MAX] = { - IFM_AUTO, - IFM_IEEE80211_11A, - IFM_IEEE80211_11B, - IFM_IEEE80211_11G, - IFM_IEEE80211_FH, - IFM_IEEE80211_11A | IFM_IEEE80211_TURBO, - IFM_IEEE80211_11G | IFM_IEEE80211_TURBO, - IFM_IEEE80211_11A | IFM_IEEE80211_TURBO, - IFM_IEEE80211_11NA, - IFM_IEEE80211_11NG, + [IEEE80211_MODE_AUTO] = IFM_AUTO, + [IEEE80211_MODE_11A] = IFM_IEEE80211_11A, + [IEEE80211_MODE_11B] = IFM_IEEE80211_11B, + [IEEE80211_MODE_11G] = IFM_IEEE80211_11G, + [IEEE80211_MODE_FH] = IFM_IEEE80211_FH, + [IEEE80211_MODE_TURBO_A] = IFM_IEEE80211_11A|IFM_IEEE80211_TURBO, + [IEEE80211_MODE_TURBO_G] = IFM_IEEE80211_11G|IFM_IEEE80211_TURBO, + [IEEE80211_MODE_STURBO_A] = IFM_IEEE80211_11A|IFM_IEEE80211_TURBO, + [IEEE80211_MODE_11NA] = IFM_IEEE80211_11NA, + [IEEE80211_MODE_11NG] = IFM_IEEE80211_11NG, }; u_int mopt; @@ -996,7 +997,8 @@ ieee80211_media_init(struct ieee80211com ieee80211com_media_change, ieee80211com_media_status); /* NB: strip explicit mode; we're actually in autoselect */ ifmedia_set(&ic->ic_media, - media_status(ic->ic_opmode, ic->ic_curchan) &~ IFM_MMASK); + media_status(ic->ic_opmode, ic->ic_curchan) &~ + (IFM_MMASK | IFM_IEEE80211_TURBO)); if (maxrate) ifp->if_baudrate = IF_Mbps(maxrate); From mckusick at FreeBSD.org Tue Feb 3 17:02:57 2009 From: mckusick at FreeBSD.org (Kirk McKusick) Date: Tue Feb 3 17:03:04 2009 Subject: svn commit: r188110 - head/sbin/fsck_ffs Message-ID: <200902040102.n1412u40047515@svn.freebsd.org> Author: mckusick Date: Wed Feb 4 01:02:56 2009 New Revision: 188110 URL: http://svn.freebsd.org/changeset/base/188110 Log: Update the actions previously attempted by the -D option to make them robust. With these changes fsck is now able to detect and reliably rebuild corrupted cylinder group maps. The -D option is no longer necessary as it has been replaced by a prompt asking whether the corrupted cylinder group should be rebuilt and doing so when requested. These actions are only offered and taken when running fsck in manual mode. Corrupted cylinder groups found during preen mode cause the fsck to fail. Add the -r option to free up excess unused inodes. Decreasing the number of preallocated inodes reduces the running time of future runs of fsck and frees up space that can allocated to files. The -r option is ignored when running in preen mode. Reviewed by: Xin LI Sponsored by: Rsync.net Modified: head/sbin/fsck_ffs/fsck.h head/sbin/fsck_ffs/fsck_ffs.8 head/sbin/fsck_ffs/fsutil.c head/sbin/fsck_ffs/inode.c head/sbin/fsck_ffs/main.c head/sbin/fsck_ffs/pass1.c Modified: head/sbin/fsck_ffs/fsck.h ============================================================================== --- head/sbin/fsck_ffs/fsck.h Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/fsck.h Wed Feb 4 01:02:56 2009 (r188110) @@ -270,7 +270,7 @@ char yflag; /* assume a yes response * int bkgrdflag; /* use a snapshot to run on an active system */ int bflag; /* location of alternate super block */ int debug; /* output debugging info */ -char damagedflag; /* run in damaged mode */ +int inoopt; /* trim out unused inodes */ char ckclean; /* only do work if not cleanly unmounted */ int cvtlevel; /* convert to newer file system format */ int bkgrdcheck; /* determine if background check is possible */ @@ -337,7 +337,7 @@ void cacheino(union dinode *dp, ino_t i void catch(int); void catchquit(int); int changeino(ino_t dir, const char *name, ino_t newnum); -void check_cgmagic(int cg, struct cg *cgp); +int check_cgmagic(int cg, struct cg *cgp); int chkrange(ufs2_daddr_t blk, int cnt); void ckfini(int markclean); int ckinode(union dinode *dp, struct inodesc *); @@ -362,7 +362,7 @@ int ftypeok(union dinode *dp); void getblk(struct bufarea *bp, ufs2_daddr_t blk, long size); struct bufarea *getdatablk(ufs2_daddr_t blkno, long size); struct inoinfo *getinoinfo(ino_t inumber); -union dinode *getnextinode(ino_t inumber); +union dinode *getnextinode(ino_t inumber, int rebuildcg); void getpathname(char *namebuf, ino_t curdir, ino_t ino); union dinode *ginode(ino_t inumber); void infohandler(int sig); Modified: head/sbin/fsck_ffs/fsck_ffs.8 ============================================================================== --- head/sbin/fsck_ffs/fsck_ffs.8 Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/fsck_ffs.8 Wed Feb 4 01:02:56 2009 (r188110) @@ -38,7 +38,7 @@ .Nd file system consistency check and interactive repair .Sh SYNOPSIS .Nm -.Op Fl BDFpfny +.Op Fl BFprfny .Op Fl b Ar block .Op Fl c Ar level .Op Fl m Ar mode @@ -216,22 +216,6 @@ are being converted at once. The format of a file system can be determined from the first line of output from .Xr dumpfs 8 . -.It Fl D -Run -.Nm -in 'damaged recovery' mode, which will enable certain aggressive -operations that can make -.Nm -to survive with file systems that has very serious data damage, which -is an useful last resort when on disk data damage is very serious -and causes -.Nm -to crash otherwise. Be -.Em very careful -using this flag, it is dangerous if there are data transmission hazards -because a false positive cylinder group magic number mismatch could -cause -.Em irrevertible data loss! .Pp This option implies the .Fl f @@ -259,6 +243,15 @@ which is assumed to be affirmative; do not open the file system for writing. .It Fl p Preen file systems (see above). +.It Fl r +Free up excess unused inodes. +Decreasing the number of preallocated inodes reduces the +running time of future runs of +.Nm +and frees up space that can allocated to files. +The +.Fl r +option is ignored when running in preen mode. .It Fl y Assume a yes response to all questions asked by .Nm ; Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/fsutil.c Wed Feb 4 01:02:56 2009 (r188110) @@ -333,9 +333,13 @@ ckfini(int markclean) if (!markclean) rerun = 1; } - } else if (!preen && !markclean) { - printf("\n***** FILE SYSTEM STILL DIRTY *****\n"); - rerun = 1; + } else if (!preen) { + if (markclean) { + printf("\n***** FILE SYSTEM IS CLEAN *****\n"); + } else { + printf("\n***** FILE SYSTEM STILL DIRTY *****\n"); + rerun = 1; + } } if (debug && totalreads > 0) printf("cache missed %ld of %ld (%d%%)\n", diskreads, @@ -418,32 +422,73 @@ blwrite(int fd, char *buf, ufs2_daddr_t } /* - * Check cg's magic number. If catastrophic mode is enabled and the cg's - * magic number is bad, offer an option to clear the whole cg. + * Verify cylinder group's magic number and other parameters. If the + * test fails, offer an option to rebuild the whole cylinder group. */ -void +int check_cgmagic(int cg, struct cg *cgp) { - if (!cg_chkmagic(cgp)) { - pwarn("CG %d: BAD MAGIC NUMBER\n", cg); - if (damagedflag) { - if (reply("CLEAR CG")) { - memset(cgp, 0, (size_t)sblock.fs_cgsize); - cgp->cg_initediblk = sblock.fs_ipg; - cgp->cg_old_niblk = sblock.fs_ipg; - cgp->cg_old_ncyl = sblock.fs_old_cpg; - cgp->cg_cgx = cg; - cgp->cg_niblk = sblock.fs_ipg; - cgp->cg_ndblk = sblock.fs_size - cgbase(&sblock, cg); - cgp->cg_magic = CG_MAGIC; - cgdirty(); - printf("PLEASE RERUN FSCK.\n"); - rerun = 1; - } - } else - printf("YOU MAY NEED TO RERUN FSCK WITH -D IF IT CRASHED.\n"); + /* + * Extended cylinder group checks. + */ + if (cg_chkmagic(cgp) && + ((sblock.fs_magic == FS_UFS1_MAGIC && + cgp->cg_old_niblk == sblock.fs_ipg && + cgp->cg_ndblk <= sblock.fs_fpg && + cgp->cg_old_ncyl == sblock.fs_old_cpg) || + (sblock.fs_magic == FS_UFS2_MAGIC && + cgp->cg_niblk == sblock.fs_ipg && + cgp->cg_ndblk <= sblock.fs_fpg && + cgp->cg_initediblk <= sblock.fs_ipg))) { + return (1); + } + pfatal("CYLINDER GROUP %d: BAD MAGIC NUMBER", cg); + if (!reply("REBUILD CYLINDER GROUP")) { + printf("YOU WILL NEED TO RERUN FSCK.\n"); + rerun = 1; + return (1); } + /* + * Zero out the cylinder group and then initialize critical fields. + * Bit maps and summaries will be recalculated by later passes. + */ + memset(cgp, 0, (size_t)sblock.fs_cgsize); + cgp->cg_magic = CG_MAGIC; + cgp->cg_cgx = cg; + cgp->cg_niblk = sblock.fs_ipg; + cgp->cg_initediblk = sblock.fs_ipg < 2 * INOPB(&sblock) ? + sblock.fs_ipg : 2 * INOPB(&sblock); + if (cgbase(&sblock, cg) + sblock.fs_fpg < sblock.fs_size) + cgp->cg_ndblk = sblock.fs_fpg; + else + cgp->cg_ndblk = sblock.fs_size - cgbase(&sblock, cg); + cgp->cg_iusedoff = &cgp->cg_space[0] - (u_char *)(&cgp->cg_firstfield); + if (sblock.fs_magic == FS_UFS1_MAGIC) { + cgp->cg_niblk = 0; + cgp->cg_initediblk = 0; + cgp->cg_old_ncyl = sblock.fs_old_cpg; + cgp->cg_old_niblk = sblock.fs_ipg; + cgp->cg_old_btotoff = cgp->cg_iusedoff; + cgp->cg_old_boff = cgp->cg_old_btotoff + + sblock.fs_old_cpg * sizeof(int32_t); + cgp->cg_iusedoff = cgp->cg_old_boff + + sblock.fs_old_cpg * sizeof(u_int16_t); + } + cgp->cg_freeoff = cgp->cg_iusedoff + howmany(sblock.fs_ipg, CHAR_BIT); + cgp->cg_nextfreeoff = cgp->cg_freeoff + howmany(sblock.fs_fpg,CHAR_BIT); + if (sblock.fs_contigsumsize > 0) { + cgp->cg_nclusterblks = cgp->cg_ndblk / sblock.fs_frag; + cgp->cg_clustersumoff = + roundup(cgp->cg_nextfreeoff, sizeof(u_int32_t)); + cgp->cg_clustersumoff -= sizeof(u_int32_t); + cgp->cg_clusteroff = cgp->cg_clustersumoff + + (sblock.fs_contigsumsize + 1) * sizeof(u_int32_t); + cgp->cg_nextfreeoff = cgp->cg_clusteroff + + howmany(fragstoblks(&sblock, sblock.fs_fpg), CHAR_BIT); + } + cgdirty(); + return (0); } /* @@ -470,7 +515,8 @@ allocblk(long frags) } cg = dtog(&sblock, i + j); getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize); - check_cgmagic(cg, cgp); + if (!check_cgmagic(cg, cgp)) + return (0); baseblk = dtogd(&sblock, i + j); for (k = 0; k < frags; k++) { setbmap(i + j + k); Modified: head/sbin/fsck_ffs/inode.c ============================================================================== --- head/sbin/fsck_ffs/inode.c Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/inode.c Wed Feb 4 01:02:56 2009 (r188110) @@ -309,10 +309,12 @@ static long readcnt, readpercg, fullcnt, static caddr_t inodebuf; union dinode * -getnextinode(ino_t inumber) +getnextinode(ino_t inumber, int rebuildcg) { + int j; long size; - ufs2_daddr_t dblk; + mode_t mode; + ufs2_daddr_t ndb, dblk; union dinode *dp; static caddr_t nextinop; @@ -336,6 +338,54 @@ getnextinode(ino_t inumber) nextinop = inodebuf; } dp = (union dinode *)nextinop; + if (rebuildcg && nextinop == inodebuf) { + /* + * Try to determine if we have reached the end of the + * allocated inodes. + */ + mode = DIP(dp, di_mode) & IFMT; + if (mode == 0) { + if (memcmp(dp->dp2.di_db, ufs2_zino.di_db, + NDADDR * sizeof(ufs2_daddr_t)) || + memcmp(dp->dp2.di_ib, ufs2_zino.di_ib, + NIADDR * sizeof(ufs2_daddr_t)) || + dp->dp2.di_mode || dp->dp2.di_size) + return (NULL); + goto inodegood; + } + if (!ftypeok(dp)) + return (NULL); + ndb = howmany(DIP(dp, di_size), sblock.fs_bsize); + if (ndb < 0) + return (NULL); + if (mode == IFBLK || mode == IFCHR) + ndb++; + if (mode == IFLNK) { + /* + * Fake ndb value so direct/indirect block checks below + * will detect any garbage after symlink string. + */ + if (DIP(dp, di_size) < (off_t)sblock.fs_maxsymlinklen) { + ndb = howmany(DIP(dp, di_size), + sizeof(ufs2_daddr_t)); + if (ndb > NDADDR) { + j = ndb - NDADDR; + for (ndb = 1; j > 1; j--) + ndb *= NINDIR(&sblock); + ndb += NDADDR; + } + } + } + for (j = ndb; ndb < NDADDR && j < NDADDR; j++) + if (DIP(dp, di_db[j]) != 0) + return (NULL); + for (j = 0, ndb -= NDADDR; ndb > 0; j++) + ndb /= NINDIR(&sblock); + for (; j < NIADDR; j++) + if (DIP(dp, di_ib[j]) != 0) + return (NULL); + } +inodegood: if (sblock.fs_magic == FS_UFS1_MAGIC) nextinop += sizeof(struct ufs1_dinode); else @@ -617,7 +667,8 @@ allocino(ino_t request, int type) return (0); cg = ino_to_cg(&sblock, ino); getblk(&cgblk, cgtod(&sblock, cg), sblock.fs_cgsize); - check_cgmagic(cg, cgp); + if (!check_cgmagic(cg, cgp)) + return (0); setbit(cg_inosused(cgp), ino % sblock.fs_ipg); cgp->cg_cs.cs_nifree--; switch (type & IFMT) { Modified: head/sbin/fsck_ffs/main.c ============================================================================== --- head/sbin/fsck_ffs/main.c Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/main.c Wed Feb 4 01:02:56 2009 (r188110) @@ -81,8 +81,8 @@ main(int argc, char *argv[]) sync(); skipclean = 1; - damagedflag = 0; - while ((ch = getopt(argc, argv, "b:Bc:CdDfFm:npy")) != -1) { + inoopt = 0; + while ((ch = getopt(argc, argv, "b:Bc:CdfFm:npry")) != -1) { switch (ch) { case 'b': skipclean = 0; @@ -106,10 +106,6 @@ main(int argc, char *argv[]) debug++; break; - case 'D': - damagedflag = 1; - /* FALLTHROUGH */ - case 'f': skipclean = 0; break; @@ -138,6 +134,10 @@ main(int argc, char *argv[]) ckclean++; break; + case 'r': + inoopt++; + break; + case 'y': yflag++; nflag = 0; @@ -606,7 +606,7 @@ static void usage(void) { (void) fprintf(stderr, - "usage: %s [-BCFpfny] [-b block] [-c level] [-m mode] " + "usage: %s [-BFprfny] [-b block] [-c level] [-m mode] " "filesystem ...\n", getprogname()); exit(1); Modified: head/sbin/fsck_ffs/pass1.c ============================================================================== --- head/sbin/fsck_ffs/pass1.c Wed Feb 4 00:45:25 2009 (r188109) +++ head/sbin/fsck_ffs/pass1.c Wed Feb 4 01:02:56 2009 (r188110) @@ -54,17 +54,17 @@ static ufs2_daddr_t badblk; static ufs2_daddr_t dupblk; static ino_t lastino; /* last inode in use */ -static void checkinode(ino_t inumber, struct inodesc *); +static int checkinode(ino_t inumber, struct inodesc *, int rebuildcg); void pass1(void) { struct inostat *info; struct inodesc idesc; - ino_t inumber, inosused; + ino_t inumber, inosused, mininos; ufs2_daddr_t i, cgd; u_int8_t *cp; - int c; + int c, rebuildcg; /* * Set file system reserved blocks in used block map. @@ -93,7 +93,10 @@ pass1(void) inumber = c * sblock.fs_ipg; setinodebuf(inumber); getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize); - if (sblock.fs_magic == FS_UFS2_MAGIC) { + rebuildcg = 0; + if (!check_cgmagic(c, &cgrp)) + rebuildcg = 1; + if (!rebuildcg && sblock.fs_magic == FS_UFS2_MAGIC) { inosused = cgrp.cg_initediblk; if (inosused > sblock.fs_ipg) inosused = sblock.fs_ipg; @@ -117,9 +120,7 @@ pass1(void) * to find the inodes that are really in use, and then * read only those inodes in from disk. */ - if (preen && usedsoftdep) { - if (!cg_chkmagic(&cgrp)) - pfatal("CG %d: BAD MAGIC NUMBER\n", c); + if ((preen || inoopt) && usedsoftdep && !rebuildcg) { cp = &cg_inosused(&cgrp)[(inosused - 1) / CHAR_BIT]; for ( ; inosused > 0; inosused -= CHAR_BIT, cp--) { if (*cp == 0) @@ -152,24 +153,60 @@ pass1(void) */ for (i = 0; i < inosused; i++, inumber++) { if (inumber < ROOTINO) { - (void)getnextinode(inumber); + (void)getnextinode(inumber, rebuildcg); continue; } - checkinode(inumber, &idesc); + /* + * NULL return indicates probable end of allocated + * inodes during cylinder group rebuild attempt. + * We always keep trying until we get to the minimum + * valid number for this cylinder group. + */ + if (checkinode(inumber, &idesc, rebuildcg) == 0 && + i > cgrp.cg_initediblk) + break; } - lastino += 1; - if (inosused < sblock.fs_ipg || inumber == lastino) + /* + * This optimization speeds up future runs of fsck + * by trimming down the number of inodes in cylinder + * groups that formerly had many inodes but now have + * fewer in use. + */ + mininos = roundup(inosused + INOPB(&sblock), INOPB(&sblock)); + if (inoopt && !preen && !rebuildcg && + sblock.fs_magic == FS_UFS2_MAGIC && + cgrp.cg_initediblk > 2 * INOPB(&sblock) && + mininos < cgrp.cg_initediblk) { + i = cgrp.cg_initediblk; + if (mininos < 2 * INOPB(&sblock)) + cgrp.cg_initediblk = 2 * INOPB(&sblock); + else + cgrp.cg_initediblk = mininos; + pwarn("CYLINDER GROUP %d: RESET FROM %ju TO %d %s\n", + c, i, cgrp.cg_initediblk, "VALID INODES"); + cgdirty(); + } + if (inosused < sblock.fs_ipg) continue; + lastino += 1; + if (lastino < (c * sblock.fs_ipg)) + inosused = 0; + else + inosused = lastino - (c * sblock.fs_ipg); + if (rebuildcg && inosused > cgrp.cg_initediblk && + sblock.fs_magic == FS_UFS2_MAGIC) { + cgrp.cg_initediblk = roundup(inosused, INOPB(&sblock)); + pwarn("CYLINDER GROUP %d: FOUND %d VALID INODES\n", c, + cgrp.cg_initediblk); + } /* * If we were not able to determine in advance which inodes * were in use, then reduce the size of the inoinfo structure * to the size necessary to describe the inodes that we * really found. */ - if (lastino < (c * sblock.fs_ipg)) - inosused = 0; - else - inosused = lastino - (c * sblock.fs_ipg); + if (inumber == lastino) + continue; inostathead[c].il_numalloced = inosused; if (inosused == 0) { free(inostathead[c].il_stat); @@ -187,8 +224,8 @@ pass1(void) freeinodebuf(); } -static void -checkinode(ino_t inumber, struct inodesc *idesc) +static int +checkinode(ino_t inumber, struct inodesc *idesc, int rebuildcg) { union dinode *dp; off_t kernmaxfilesize; @@ -196,7 +233,8 @@ checkinode(ino_t inumber, struct inodesc mode_t mode; int j, ret, offset; - dp = getnextinode(inumber); + if ((dp = getnextinode(inumber, rebuildcg)) == NULL) + return (0); mode = DIP(dp, di_mode) & IFMT; if (mode == 0) { if ((sblock.fs_magic == FS_UFS1_MAGIC && @@ -220,7 +258,7 @@ checkinode(ino_t inumber, struct inodesc } } inoinfo(inumber)->ino_state = USTATE; - return; + return (1); } lastino = inumber; /* This should match the file size limit in ffs_mountfs(). */ @@ -352,7 +390,7 @@ checkinode(ino_t inumber, struct inodesc if (preen) printf(" (CORRECTED)\n"); else if (reply("CORRECT") == 0) - return; + return (1); if (bkgrdflag == 0) { dp = ginode(inumber); DIP_SET(dp, di_blocks, idesc->id_entryno); @@ -368,7 +406,7 @@ checkinode(ino_t inumber, struct inodesc rwerror("ADJUST INODE BLOCK COUNT", cmd.value); } } - return; + return (1); unknown: pfatal("UNKNOWN FILE TYPE I=%lu", (u_long)inumber); inoinfo(inumber)->ino_state = FCLEAR; @@ -378,6 +416,7 @@ unknown: clearinode(dp); inodirty(); } + return (1); } int From cognet at FreeBSD.org Tue Feb 3 17:14:07 2009 From: cognet at FreeBSD.org (Olivier Houchard) Date: Tue Feb 3 17:14:13 2009 Subject: svn commit: r188112 - head/sys/arm/arm Message-ID: <200902040114.n141E6mu047838@svn.freebsd.org> Author: cognet Date: Wed Feb 4 01:14:06 2009 New Revision: 188112 URL: http://svn.freebsd.org/changeset/base/188112 Log: Erm... Report the buffer as being bounced even when it's the entire buffer, or we would end up invalidating the cache line for what we just copied... Reported by: thompsa Pointy at to: cognet MFC after: 3 days Modified: head/sys/arm/arm/busdma_machdep.c Modified: head/sys/arm/arm/busdma_machdep.c ============================================================================== --- head/sys/arm/arm/busdma_machdep.c Wed Feb 4 01:11:37 2009 (r188111) +++ head/sys/arm/arm/busdma_machdep.c Wed Feb 4 01:14:06 2009 (r188112) @@ -1168,7 +1168,7 @@ _bus_dma_buf_is_in_bp(bus_dmamap_t map, STAILQ_FOREACH(bpage, &map->bpages, links) { if ((vm_offset_t)buf >= bpage->datavaddr && - (vm_offset_t)buf + len < bpage->datavaddr + + (vm_offset_t)buf + len <= bpage->datavaddr + bpage->datacount) return (1); } From bms at FreeBSD.org Tue Feb 3 18:35:31 2009 From: bms at FreeBSD.org (Bruce M. Simpson) Date: Tue Feb 3 18:35:42 2009 Subject: svn commit: r187993 - head/sys/dev/firewire In-Reply-To: <200902012328.n11NSqYG069209@svn.freebsd.org> References: <200902012328.n11NSqYG069209@svn.freebsd.org> Message-ID: <4988FEEE.1030800@FreeBSD.org> This probably explains why fwcontrol -r often wouldn't actually reset the bus :-) From bz at FreeBSD.org Wed Feb 4 02:35:29 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Wed Feb 4 02:35:34 2009 Subject: svn commit: r188113 - head/sys/netinet6 Message-ID: <200902041035.n14AZS0q066480@svn.freebsd.org> Author: bz Date: Wed Feb 4 10:35:27 2009 New Revision: 188113 URL: http://svn.freebsd.org/changeset/base/188113 Log: When iterating through the list trying to find a router in defrouter_select(), NULL the cached llentry after unlocking as we are no longer interested in it and with the second iteration would try to unlock it again resulting in panic: Lock (rw) lle not locked @ ... Reported by: Mark Atkinson Tested by: Mark Atkinson PR: kern/128247 (in follow-up, unrelated to original report) Modified: head/sys/netinet6/nd6_rtr.c Modified: head/sys/netinet6/nd6_rtr.c ============================================================================== --- head/sys/netinet6/nd6_rtr.c Wed Feb 4 01:14:06 2009 (r188112) +++ head/sys/netinet6/nd6_rtr.c Wed Feb 4 10:35:27 2009 (r188113) @@ -651,8 +651,10 @@ defrouter_select(void) selected_dr = dr; } IF_AFDATA_UNLOCK(dr->ifp); - if (ln != NULL) + if (ln != NULL) { LLE_RUNLOCK(ln); + ln = NULL; + } if (dr->installed && installed_dr == NULL) installed_dr = dr; From brde at optusnet.com.au Wed Feb 4 03:28:04 2009 From: brde at optusnet.com.au (Bruce Evans) Date: Wed Feb 4 03:28:17 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <4988AB83.2050203@gmx.de> References: <200902032025.n13KPaCV041012@svn.freebsd.org> <4988AB83.2050203@gmx.de> Message-ID: <20090204212854.F51932@delplex.bde.org> On Tue, 3 Feb 2009, Christoph Mallon wrote: > Warner Losh schrieb: >> Modified: head/lib/libc/string/strmode.c >> ============================================================================== >> --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 >> (r188097) >> +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 >> (r188098) >> @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); >> #include >> void >> -strmode(mode_t mode, char *p) >> +strmode(/* mode_t */ int mode, char *p) >> { >> /* print type */ >> switch (mode & S_IFMT) { > > The manpage states that the first parameter of strmode() is a mode_t. What's > wrong - the implementation (both in header and definition) or the > documentation? The man page is wrong. strtomode() should take an int arg (actually the default (unary) promotion of a mode_t) for the the same reasons that memchr() does -- because these interfaces should be usable by K&R compilers and/or by standard C compilers without a protoype in scope. Even if this is no longer required, binary compatibily requires the interfaces to be the same as the ones that used to be required. The requirement for binary compatibility also prevents "fixing" interfaces to be "ANSI" in headers (if you "fix" prototypes there then you will get obscure runtime errors instead of tinderbox errors). mode_t causes even more problems on systems with 16-bit ints since its default promotion is unsigned int. Thus the correct declaration of strmode() is machine-dependent. Similarly for memchr() on systems with sizeof(char) == sizeof(int). Standard C doesn't support variant interfaces so memchr() cannot work quite right on such systems. This problem used to be much larger for POSIX. POSIX.1-1988 didn't require prototypes, but it required use of mode_t and lots of other probably-sub-integer typedefed types too much in its interfaces (unlike standard C which uses ints and longs too much), and it declares all its interfaces using prototypes so the ones that involve sub-integer types cannot be implemented by either K&R compilers or Standard C compilers (for K&R, sub-integer types are not supported, and for Standard C the literal prototypes don't match the default promotions). Now, POSIX requires prototypes (to be supported by the compiler), and, like standard C, it requires a prototype to be in scope if the type of any function parameter is incompatible with its default promotion, so the problems are limited mainly to loss of bits on exotic machines in the forced conversions between signed and unsigned values. Since the prototypes aren't variant, sometimes there are forced conversions that mess up the values even if the initial and final types are the same. I probably missed fixing strmode.3 because of the gcc bug that you pointed out -- the prototype is incompatible with the declaration in strmode.3, so the behaviour is undefined, but gcc's implementation of the undefined behaviour is to do the right thing if a prototype is in scope and to do the wrong thing if a prototype is not in scope. Since my man page checker puts the wrong prototype in scope but doesn't put the correct prototype from string.h in scope, the error goes undetected. Bruce From Alexander at Leidinger.net Wed Feb 4 06:44:29 2009 From: Alexander at Leidinger.net (Alexander Leidinger) Date: Wed Feb 4 06:44:41 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <20090204212854.F51932@delplex.bde.org> References: <200902032025.n13KPaCV041012@svn.freebsd.org> <4988AB83.2050203@gmx.de> <20090204212854.F51932@delplex.bde.org> Message-ID: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> Quoting Bruce Evans (from Wed, 4 Feb 2009 22:27:59 +1100 (EST)): > On Tue, 3 Feb 2009, Christoph Mallon wrote: > >> Warner Losh schrieb: >>> Modified: head/lib/libc/string/strmode.c >>> ============================================================================== >>> --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) >>> +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) >>> @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); >>> #include >>> void >>> -strmode(mode_t mode, char *p) >>> +strmode(/* mode_t */ int mode, char *p) >>> { >>> /* print type */ >>> switch (mode & S_IFMT) { >> >> The manpage states that the first parameter of strmode() is a >> mode_t. What's wrong - the implementation (both in header and >> definition) or the documentation? > > The man page is wrong. strtomode() should take an int arg (actually > the default (unary) promotion of a mode_t) for the the same reasons > that memchr() does -- because these interfaces should be usable by K&R > compilers and/or by standard C compilers without a protoype in scope. > Even if this is no longer required, binary compatibily requires the > interfaces to be the same as the ones that used to be required. The > requirement for binary compatibility also prevents "fixing" interfaces > to be "ANSI" in headers (if you "fix" prototypes there then you will > get obscure runtime errors instead of tinderbox errors). Is this also true for the current use of symbol versioning in our libc? I thought this is supposed to "fix" this problem (assuming we add an UPDATING entry that users have to make sure that they to a full installworld to habe the includes and the lib in sync)? Bye, Alexander. -- Sometimes the best medicine is to stop taking something. http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 From ed at FreeBSD.org Wed Feb 4 09:10:03 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Wed Feb 4 09:10:25 2009 Subject: svn commit: r188115 - in head/sys: kern sys Message-ID: <200902041710.n14HA2Wc082064@svn.freebsd.org> Author: ed Date: Wed Feb 4 17:10:01 2009 New Revision: 188115 URL: http://svn.freebsd.org/changeset/base/188115 Log: Remove slush space from clists. Right now we only have a very small amount of drivers that use clists, but we still allocate 50 cblocks as slush space, which allows drivers to temporarily overcommit their storage. Most of the drivers don't allow this anyway. I've performed the following changes: - We don't allocate any cblocks on startup. - I've removed the DDB command, because it has nothing useful to print now. You can obtain the amount of allocated blocks by running `vmstat -m | grep clist'. - I've removed cfreecount, which is now unused. - The old code first tries to allocate using M_NOWAIT, followed by M_WAITOK. This doesn't make any sense, so just remove this logic. It seems the drivers allow us to sleep anyway. We can even remove ccmax from clist_alloc_cblocks and c_cbmax from struct clist, but this breaks binary compatibility. This reduces the amount of allocated cblocks on my system from 54 to 4. Modified: head/sys/kern/subr_clist.c head/sys/sys/clist.h Modified: head/sys/kern/subr_clist.c ============================================================================== --- head/sys/kern/subr_clist.c Wed Feb 4 15:02:57 2009 (r188114) +++ head/sys/kern/subr_clist.c Wed Feb 4 17:10:01 2009 (r188115) @@ -38,58 +38,15 @@ __FBSDID("$FreeBSD$"); #include #include -static void clist_init(void *); -SYSINIT(clist, SI_SUB_CLIST, SI_ORDER_FIRST, clist_init, NULL); - static MALLOC_DEFINE(M_CLIST, "clist", "clist queue blocks"); static struct cblock *cfreelist = NULL; -int cfreecount = 0; -static int cslushcount; -static int ctotcount; - -#ifndef INITIAL_CBLOCKS -#define INITIAL_CBLOCKS 50 -#endif static struct cblock *cblock_alloc(void); static void cblock_alloc_cblocks(int number); static void cblock_free(struct cblock *cblockp); static void cblock_free_cblocks(int number); -#include "opt_ddb.h" -#ifdef DDB -#include - -DB_SHOW_COMMAND(cbstat, cbstat) -{ - int cbsize = CBSIZE; - - printf( - "tot = %d (active = %d, free = %d (reserved = %d, slush = %d))\n", - ctotcount * cbsize, ctotcount * cbsize - cfreecount, cfreecount, - cfreecount - cslushcount * cbsize, cslushcount * cbsize); -} -#endif /* DDB */ - -/* - * Called from init_main.c - */ -/* ARGSUSED*/ -static void -clist_init(void *dummy) -{ - /* - * Allocate an initial base set of cblocks as a 'slush'. - * We allocate non-slush cblocks with each initial tty_open() and - * deallocate them with each tty_close(). - * We should adjust the slush allocation. This can't be done in - * the i/o routines because they are sometimes called from - * interrupt handlers when it may be unsafe to call malloc(). - */ - cblock_alloc_cblocks(cslushcount = INITIAL_CBLOCKS); -} - /* * Remove a cblock from the cfreelist queue and return a pointer * to it. @@ -104,7 +61,6 @@ cblock_alloc(void) panic("clist reservation botch"); cfreelist = cblockp->c_next; cblockp->c_next = NULL; - cfreecount -= CBSIZE; return (cblockp); } @@ -116,7 +72,6 @@ cblock_free(struct cblock *cblockp) { cblockp->c_next = cfreelist; cfreelist = cblockp; - cfreecount += CBSIZE; } /* @@ -129,19 +84,13 @@ cblock_alloc_cblocks(int number) struct cblock *cbp; for (i = 0; i < number; ++i) { - cbp = malloc(sizeof *cbp, M_CLIST, M_NOWAIT); - if (cbp == NULL) { - printf( -"cblock_alloc_cblocks: M_NOWAIT malloc failed, trying M_WAITOK\n"); - cbp = malloc(sizeof *cbp, M_CLIST, M_WAITOK); - } + cbp = malloc(sizeof *cbp, M_CLIST, M_WAITOK); /* * Freed cblocks have zero quotes and garbage elsewhere. * Set the may-have-quote bit to force zeroing the quotes. */ cblock_free(cbp); } - ctotcount += number; } /* @@ -184,7 +133,6 @@ cblock_free_cblocks(int number) for (i = 0; i < number; ++i) free(cblock_alloc(), M_CLIST); - ctotcount -= number; } /* @@ -237,8 +185,7 @@ getc(struct clist *clistp) clistp->c_cf = clistp->c_cl = NULL; } cblock_free(cblockp); - if (--clistp->c_cbcount >= clistp->c_cbreserved) - ++cslushcount; + --clistp->c_cbcount; } } @@ -285,8 +232,7 @@ q_to_b(struct clist *clistp, char *dest, clistp->c_cf = clistp->c_cl = NULL; } cblock_free(cblockp); - if (--clistp->c_cbcount >= clistp->c_cbreserved) - ++cslushcount; + --clistp->c_cbcount; } } @@ -328,8 +274,7 @@ ndflush(struct clist *clistp, int amount clistp->c_cf = clistp->c_cl = NULL; } cblock_free(cblockp); - if (--clistp->c_cbcount >= clistp->c_cbreserved) - ++cslushcount; + --clistp->c_cbcount; } } @@ -364,12 +309,8 @@ putc(char chr, struct clist *clistp) struct cblock *prev = (cblockp - 1); if (clistp->c_cbcount >= clistp->c_cbreserved) { - if (clistp->c_cbcount >= clistp->c_cbmax - || cslushcount <= 0) { - splx(s); - return (-1); - } - --cslushcount; + splx(s); + return (-1); } cblockp = cblock_alloc(); clistp->c_cbcount++; @@ -430,12 +371,8 @@ b_to_q(char *src, int amount, struct cli struct cblock *prev = cblockp - 1; if (clistp->c_cbcount >= clistp->c_cbreserved) { - if (clistp->c_cbcount >= clistp->c_cbmax - || cslushcount <= 0) { - splx(s); - return (amount); - } - --cslushcount; + splx(s); + return (amount); } cblockp = cblock_alloc(); clistp->c_cbcount++; @@ -510,8 +447,7 @@ unputc(struct clist *clistp) */ clistp->c_cl = (char *)(cbp+1); cblock_free(cblockp); - if (--clistp->c_cbcount >= clistp->c_cbreserved) - ++cslushcount; + --clistp->c_cbcount; cbp->c_next = NULL; } } @@ -523,8 +459,7 @@ unputc(struct clist *clistp) if ((clistp->c_cc == 0) && clistp->c_cl) { cblockp = (struct cblock *)((intptr_t)clistp->c_cl & ~CROUND); cblock_free(cblockp); - if (--clistp->c_cbcount >= clistp->c_cbreserved) - ++cslushcount; + --clistp->c_cbcount; clistp->c_cf = clistp->c_cl = NULL; } Modified: head/sys/sys/clist.h ============================================================================== --- head/sys/sys/clist.h Wed Feb 4 15:02:57 2009 (r188114) +++ head/sys/sys/clist.h Wed Feb 4 17:10:01 2009 (r188115) @@ -54,8 +54,6 @@ struct cblock { }; #ifdef _KERNEL -extern int cfreecount; - int b_to_q(char *cp, int cc, struct clist *q); void clist_alloc_cblocks(struct clist *q, int ccmax, int ccres); void clist_free_cblocks(struct clist *q); From imp at bsdimp.com Wed Feb 4 09:33:29 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Wed Feb 4 09:33:41 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> References: <4988AB83.2050203@gmx.de> <20090204212854.F51932@delplex.bde.org> <20090204154414.1949765y56lfhi80@webmail.leidinger.net> Message-ID: <20090204.103220.1763804960.imp@bsdimp.com> In message: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> Alexander Leidinger writes: : Quoting Bruce Evans (from Wed, 4 Feb 2009 : 22:27:59 +1100 (EST)): : : > On Tue, 3 Feb 2009, Christoph Mallon wrote: : > : >> Warner Losh schrieb: : >>> Modified: head/lib/libc/string/strmode.c : >>> ============================================================================== : >>> --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) : >>> +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) : >>> @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); : >>> #include : >>> void : >>> -strmode(mode_t mode, char *p) : >>> +strmode(/* mode_t */ int mode, char *p) : >>> { : >>> /* print type */ : >>> switch (mode & S_IFMT) { : >> : >> The manpage states that the first parameter of strmode() is a : >> mode_t. What's wrong - the implementation (both in header and : >> definition) or the documentation? : > : > The man page is wrong. strtomode() should take an int arg (actually : > the default (unary) promotion of a mode_t) for the the same reasons : > that memchr() does -- because these interfaces should be usable by K&R : > compilers and/or by standard C compilers without a protoype in scope. : > Even if this is no longer required, binary compatibily requires the : > interfaces to be the same as the ones that used to be required. The : > requirement for binary compatibility also prevents "fixing" interfaces : > to be "ANSI" in headers (if you "fix" prototypes there then you will : > get obscure runtime errors instead of tinderbox errors). : : Is this also true for the current use of symbol versioning in our : libc? I thought this is supposed to "fix" this problem (assuming we : add an UPDATING entry that users have to make sure that they to a full : installworld to habe the includes and the lib in sync)? Maybe, but it is a problem worth fixing? What we have now is correct for both cases (prototypes and no prototypes) on all the architectures that FreeBSD supports (or even kinda supports). Does it make sense to add a lot of extra hair just to have a slightly more proper prototype? Warner From phk at FreeBSD.org Wed Feb 4 10:14:31 2009 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed Feb 4 10:14:42 2009 Subject: svn commit: r188117 - head/tools/tools/sysbuild Message-ID: <200902041814.n14IEUuA086671@svn.freebsd.org> Author: phk Date: Wed Feb 4 18:14:30 2009 New Revision: 188117 URL: http://svn.freebsd.org/changeset/base/188117 Log: Get the right system makefiles for make distribution. Modified: head/tools/tools/sysbuild/sysbuild.sh Modified: head/tools/tools/sysbuild/sysbuild.sh ============================================================================== --- head/tools/tools/sysbuild/sysbuild.sh Wed Feb 4 17:35:21 2009 (r188116) +++ head/tools/tools/sysbuild/sysbuild.sh Wed Feb 4 18:14:30 2009 (r188117) @@ -420,7 +420,8 @@ log_it Installworld > /mnt/_.iw 2>&1 log_it distribution -(cd /usr/src/etc && make distribution DESTDIR=/mnt ${SRCCONF} ) \ +(cd /usr/src/etc && make -m /usr/src/share/mk distribution \ + DESTDIR=/mnt ${SRCCONF} ) \ > /mnt/_.dist 2>&1 log_it Installkernel From thompsa at FreeBSD.org Wed Feb 4 10:20:28 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Wed Feb 4 10:20:39 2009 Subject: svn commit: r188118 - head/etc Message-ID: <200902041820.n14IKRg9087304@svn.freebsd.org> Author: thompsa Date: Wed Feb 4 18:20:27 2009 New Revision: 188118 URL: http://svn.freebsd.org/changeset/base/188118 Log: Check for NOAUTO on child interfaces (eg wlanX) so they can be created via rc.conf but not necessarily started. Modified: head/etc/network.subr Modified: head/etc/network.subr ============================================================================== --- head/etc/network.subr Wed Feb 4 18:14:30 2009 (r188117) +++ head/etc/network.subr Wed Feb 4 18:20:27 2009 (r188118) @@ -515,7 +515,9 @@ childif_create() i=`ifconfig wlan create ${create_args}` ifconfig $i name $child && cfg=0 fi - ifn_start $child + if autoif $child; then + ifn_start $child + fi done return ${cfg} From jhb at FreeBSD.org Wed Feb 4 10:44:32 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Wed Feb 4 10:44:39 2009 Subject: svn commit: r188119 - in head/sys/ia64: ia64 include Message-ID: <200902041844.n14IiTu0088005@svn.freebsd.org> Author: jhb Date: Wed Feb 4 18:44:29 2009 New Revision: 188119 URL: http://svn.freebsd.org/changeset/base/188119 Log: Tweak the ia64 machine check handling code to not register new sysctl nodes while holding a spin mutex. Instead, it now shoves the machine check records onto a queue that is later drained to add sysctl nodes for each record. While a routine to drain the queue is present, it is not currently called. Reviewed by: marcel Modified: head/sys/ia64/ia64/mca.c head/sys/ia64/include/mca.h Modified: head/sys/ia64/ia64/mca.c ============================================================================== --- head/sys/ia64/ia64/mca.c Wed Feb 4 18:20:27 2009 (r188118) +++ head/sys/ia64/ia64/mca.c Wed Feb 4 18:44:29 2009 (r188119) @@ -42,6 +42,16 @@ MALLOC_DEFINE(M_MCA, "MCA", "Machine Check Architecture"); +struct mca_info { + STAILQ_ENTRY(mca_info) mi_link; + char mi_name[32]; + size_t mi_recsz; + char mi_record[0]; +}; + +static STAILQ_HEAD(, mca_info) mca_records = + STAILQ_HEAD_INITIALIZER(mca_records); + int64_t mca_info_size[SAL_INFO_TYPES]; vm_offset_t mca_info_block; struct mtx mca_info_block_lock; @@ -76,14 +86,32 @@ mca_sysctl_handler(SYSCTL_HANDLER_ARGS) } void +ia64_mca_populate(void) +{ + struct mca_info *rec; + + mtx_lock_spin(&mca_info_block_lock); + while (!STAILQ_EMPTY(&mca_records)) { + rec = STAILQ_FIRST(&mca_records); + STAILQ_REMOVE_HEAD(&mca_records, mi_link); + mtx_unlock_spin(&mca_info_block_lock); + (void)SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), + OID_AUTO, rec->mi_name, CTLTYPE_OPAQUE | CTLFLAG_RD, + rec->mi_record, rec->mi_recsz, mca_sysctl_handler, "S,MCA", + "Error record"); + mtx_lock_spin(&mca_info_block_lock); + } + mtx_unlock_spin(&mca_info_block_lock); +} + +void ia64_mca_save_state(int type) { struct ia64_sal_result result; struct mca_record_header *hdr; - struct sysctl_oid *oidp; - char *name, *state; + struct mca_info *rec; uint64_t seqnr; - size_t recsz, totsz; + size_t recsz; /* * Don't try to get the state if we couldn't get the size of @@ -95,9 +123,8 @@ ia64_mca_save_state(int type) if (mca_info_block == 0) return; + mtx_lock_spin(&mca_info_block_lock); while (1) { - mtx_lock_spin(&mca_info_block_lock); - result = ia64_sal_entry(SAL_GET_STATE_INFO, type, 0, mca_info_block, 0, 0, 0, 0); if (result.sal_status < 0) { @@ -111,11 +138,13 @@ ia64_mca_save_state(int type) mtx_unlock_spin(&mca_info_block_lock); - totsz = sizeof(struct sysctl_oid) + recsz + 32; - oidp = malloc(totsz, M_MCA, M_NOWAIT|M_ZERO); - state = (char*)(oidp + 1); - name = state + recsz; - sprintf(name, "%lld", (long long)seqnr); + rec = malloc(sizeof(struct mca_info) + recsz, M_MCA, + M_NOWAIT | M_ZERO); + if (rec == NULL) + /* XXX: Not sure what to do. */ + return; + + sprintf(rec->mi_name, "%lld", (long long)seqnr); mtx_lock_spin(&mca_info_block_lock); @@ -133,24 +162,14 @@ ia64_mca_save_state(int type) mca_info_block, 0, 0, 0, 0); if (seqnr != hdr->rh_seqnr) { mtx_unlock_spin(&mca_info_block_lock); - free(oidp, M_MCA); + free(rec, M_MCA); + mtx_lock_spin(&mca_info_block_lock); continue; } } - bcopy((char*)mca_info_block, state, recsz); - - oidp->oid_parent = &sysctl__hw_mca_children; - oidp->oid_number = OID_AUTO; - oidp->oid_kind = CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_DYN; - oidp->oid_arg1 = state; - oidp->oid_arg2 = recsz; - oidp->oid_name = name; - oidp->oid_handler = mca_sysctl_handler; - oidp->oid_fmt = "S,MCA"; - oidp->oid_descr = "Error record"; - - sysctl_register_oid(oidp); + rec->mi_recsz = recsz; + bcopy((char*)mca_info_block, rec->mi_record, recsz); if (mca_count > 0) { if (seqnr < mca_first) @@ -161,6 +180,7 @@ ia64_mca_save_state(int type) mca_first = mca_last = seqnr; mca_count++; + STAILQ_INSERT_TAIL(&mca_records, rec, mi_link); /* * Clear the state so that we get any other records when @@ -168,8 +188,6 @@ ia64_mca_save_state(int type) */ result = ia64_sal_entry(SAL_CLEAR_STATE_INFO, type, 0, 0, 0, 0, 0, 0); - - mtx_unlock_spin(&mca_info_block_lock); } } Modified: head/sys/ia64/include/mca.h ============================================================================== --- head/sys/ia64/include/mca.h Wed Feb 4 18:20:27 2009 (r188118) +++ head/sys/ia64/include/mca.h Wed Feb 4 18:44:29 2009 (r188119) @@ -239,6 +239,7 @@ struct mca_pcidev_reg { #ifdef _KERNEL void ia64_mca_init(void); +void ia64_mca_populate(void); void ia64_mca_save_state(int); #endif /* _KERNEL */ From rwatson at FreeBSD.org Wed Feb 4 11:56:39 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Wed Feb 4 11:56:45 2009 Subject: svn commit: r188122 - head/sys/security/audit Message-ID: <200902041956.n14JubCQ089511@svn.freebsd.org> Author: rwatson Date: Wed Feb 4 19:56:37 2009 New Revision: 188122 URL: http://svn.freebsd.org/changeset/base/188122 Log: Eliminate the local variable 'ape' in audit_pipe_kqread(), as it's only used for an assertion that we don't really need anymore. MFC after: 1 week Reported by: Christoph Mallon Modified: head/sys/security/audit/audit_pipe.c Modified: head/sys/security/audit/audit_pipe.c ============================================================================== --- head/sys/security/audit/audit_pipe.c Wed Feb 4 19:43:08 2009 (r188121) +++ head/sys/security/audit/audit_pipe.c Wed Feb 4 19:56:37 2009 (r188122) @@ -1077,18 +1077,13 @@ audit_pipe_kqfilter(struct cdev *dev, st static int audit_pipe_kqread(struct knote *kn, long hint) { - struct audit_pipe_entry *ape; struct audit_pipe *ap; ap = (struct audit_pipe *)kn->kn_hook; KASSERT(ap != NULL, ("audit_pipe_kqread: ap == NULL")); - AUDIT_PIPE_LOCK_ASSERT(ap); if (ap->ap_qlen != 0) { - ape = TAILQ_FIRST(&ap->ap_queue); - KASSERT(ape != NULL, ("audit_pipe_kqread: ape == NULL")); - kn->kn_data = ap->ap_qbyteslen - ap->ap_qoffset; return (1); } else { From rwatson at FreeBSD.org Wed Feb 4 12:00:18 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Wed Feb 4 12:00:30 2009 Subject: svn commit: r188123 - head/sys/kern Message-ID: <200902042000.n14K0HlD089637@svn.freebsd.org> Author: rwatson Date: Wed Feb 4 20:00:17 2009 New Revision: 188123 URL: http://svn.freebsd.org/changeset/base/188123 Log: Remove written-to but never read local variable 'offset' from soreceive_dgram(). Submitted by: Christoph Mallon MFC after: 1 week Modified: head/sys/kern/uipc_socket.c Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Wed Feb 4 19:56:37 2009 (r188122) +++ head/sys/kern/uipc_socket.c Wed Feb 4 20:00:17 2009 (r188123) @@ -1858,7 +1858,7 @@ soreceive_dgram(struct socket *so, struc struct mbuf **mp0, struct mbuf **controlp, int *flagsp) { struct mbuf *m, *m2; - int flags, len, error, offset; + int flags, len, error; struct protosw *pr = so->so_proto; struct mbuf *nextrecord; @@ -2008,7 +2008,6 @@ soreceive_dgram(struct socket *so, struc } KASSERT(m->m_type == MT_DATA, ("soreceive_dgram: !data")); - offset = 0; while (m != NULL && uio->uio_resid > 0) { len = uio->uio_resid; if (len > m->m_len) From rwatson at FreeBSD.org Wed Feb 4 12:04:34 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Wed Feb 4 12:04:45 2009 Subject: svn commit: r188124 - head/sys/netatalk Message-ID: <200902042004.n14K4Xix089742@svn.freebsd.org> Author: rwatson Date: Wed Feb 4 20:04:32 2009 New Revision: 188124 URL: http://svn.freebsd.org/changeset/base/188124 Log: Remove local variable 'ddp' from DDP's attach and detach routines; they were used only for assertions, and rather than ifdef'ing them INVARIANTS and using local variables, just directly access so_pcb. Submitted by: Christoph Mallon MFC after: 1 week Modified: head/sys/netatalk/ddp_usrreq.c Modified: head/sys/netatalk/ddp_usrreq.c ============================================================================== --- head/sys/netatalk/ddp_usrreq.c Wed Feb 4 20:00:17 2009 (r188123) +++ head/sys/netatalk/ddp_usrreq.c Wed Feb 4 20:04:32 2009 (r188124) @@ -75,11 +75,9 @@ static struct ifqueue atintrq1, atintrq2 static int ddp_attach(struct socket *so, int proto, struct thread *td) { - struct ddpcb *ddp; int error = 0; - ddp = sotoddpcb(so); - KASSERT(ddp == NULL, ("ddp_attach: ddp != NULL")); + KASSERT(sotoddpcb(so) == NULL, ("ddp_attach: ddp != NULL")); /* * Allocate socket buffer space first so that it's present @@ -175,10 +173,8 @@ ddp_disconnect(struct socket *so) static int ddp_shutdown(struct socket *so) { - struct ddpcb *ddp; - ddp = sotoddpcb(so); - KASSERT(ddp != NULL, ("ddp_shutdown: ddp == NULL")); + KASSERT(sotoddpcb(so) != NULL, ("ddp_shutdown: ddp == NULL")); socantsendmore(so); return (0); From imp at FreeBSD.org Wed Feb 4 12:23:43 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Feb 4 12:23:54 2009 Subject: svn commit: r188125 - head/sys/dev/ata Message-ID: <200902042023.n14KNgJS090142@svn.freebsd.org> Author: imp Date: Wed Feb 4 20:23:42 2009 New Revision: 188125 URL: http://svn.freebsd.org/changeset/base/188125 Log: Correct signature for the identify routine. The bad parameter wasn't used at all, so this is just a tidiness excersize. Modified: head/sys/dev/ata/atapi-cam.c Modified: head/sys/dev/ata/atapi-cam.c ============================================================================== --- head/sys/dev/ata/atapi-cam.c Wed Feb 4 20:04:32 2009 (r188124) +++ head/sys/dev/ata/atapi-cam.c Wed Feb 4 20:23:42 2009 (r188125) @@ -91,7 +91,7 @@ struct atapi_hcb { enum reinit_reason { BOOT_ATTACH, ATTACH, RESET }; /* Device methods */ -static void atapi_cam_identify(device_t *dev, device_t parent); +static void atapi_cam_identify(driver_t *dev, device_t parent); static int atapi_cam_probe(device_t dev); static int atapi_cam_attach(device_t dev); static int atapi_cam_detach(device_t dev); @@ -144,7 +144,7 @@ MODULE_DEPEND(atapicam, ata, 1, 1, 1); MODULE_DEPEND(atapicam, cam, 1, 1, 1); static void -atapi_cam_identify(device_t *dev, device_t parent) +atapi_cam_identify(driver_t *driver, device_t parent) { struct atapi_xpt_softc *scp = malloc (sizeof (struct atapi_xpt_softc), M_ATACAM, M_NOWAIT|M_ZERO); From imp at FreeBSD.org Wed Feb 4 12:26:29 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Feb 4 12:26:40 2009 Subject: svn commit: r188126 - head/sys/dev/ata Message-ID: <200902042026.n14KQSAN090227@svn.freebsd.org> Author: imp Date: Wed Feb 4 20:26:27 2009 New Revision: 188126 URL: http://svn.freebsd.org/changeset/base/188126 Log: Fix shutdown routine to return 0 and change signature from void return to int. Modified: head/sys/dev/ata/ata-disk.c head/sys/dev/ata/atapi-cd.c head/sys/dev/ata/atapi-fd.c head/sys/dev/ata/atapi-tape.c Modified: head/sys/dev/ata/ata-disk.c ============================================================================== --- head/sys/dev/ata/ata-disk.c Wed Feb 4 20:23:42 2009 (r188125) +++ head/sys/dev/ata/ata-disk.c Wed Feb 4 20:26:27 2009 (r188126) @@ -182,13 +182,14 @@ ad_detach(device_t dev) return 0; } -static void +static int ad_shutdown(device_t dev) { struct ata_device *atadev = device_get_softc(dev); if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); + return 0; } static int Modified: head/sys/dev/ata/atapi-cd.c ============================================================================== --- head/sys/dev/ata/atapi-cd.c Wed Feb 4 20:23:42 2009 (r188125) +++ head/sys/dev/ata/atapi-cd.c Wed Feb 4 20:26:27 2009 (r188126) @@ -143,13 +143,14 @@ acd_detach(device_t dev) return 0; } -static void +static int acd_shutdown(device_t dev) { struct ata_device *atadev = device_get_softc(dev); if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); + return 0; } static int Modified: head/sys/dev/ata/atapi-fd.c ============================================================================== --- head/sys/dev/ata/atapi-fd.c Wed Feb 4 20:23:42 2009 (r188125) +++ head/sys/dev/ata/atapi-fd.c Wed Feb 4 20:26:27 2009 (r188126) @@ -132,13 +132,14 @@ afd_detach(device_t dev) return 0; } -static void +static int afd_shutdown(device_t dev) { struct ata_device *atadev = device_get_softc(dev); if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); + return 0; } static int Modified: head/sys/dev/ata/atapi-tape.c ============================================================================== --- head/sys/dev/ata/atapi-tape.c Wed Feb 4 20:23:42 2009 (r188125) +++ head/sys/dev/ata/atapi-tape.c Wed Feb 4 20:26:27 2009 (r188126) @@ -175,13 +175,14 @@ ast_detach(device_t dev) return 0; } -static void +static int ast_shutdown(device_t dev) { struct ata_device *atadev = device_get_softc(dev); if (atadev->param.support.command2 & ATA_SUPPORT_FLUSHCACHE) ata_controlcmd(dev, ATA_FLUSHCACHE, 0, 0, 0); + return 0; } static int From imp at FreeBSD.org Wed Feb 4 12:35:23 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Feb 4 12:35:29 2009 Subject: svn commit: r188127 - head/sys/dev/ae Message-ID: <200902042035.n14KZMA9090435@svn.freebsd.org> Author: imp Date: Wed Feb 4 20:35:22 2009 New Revision: 188127 URL: http://svn.freebsd.org/changeset/base/188127 Log: detach doesn't return an unsinged int, but returns an int. Modified: head/sys/dev/ae/if_ae.c Modified: head/sys/dev/ae/if_ae.c ============================================================================== --- head/sys/dev/ae/if_ae.c Wed Feb 4 20:26:27 2009 (r188126) +++ head/sys/dev/ae/if_ae.c Wed Feb 4 20:35:22 2009 (r188127) @@ -105,7 +105,7 @@ static void ae_phy_init(ae_softc_t *sc); static int ae_reset(ae_softc_t *sc); static void ae_init(void *arg); static int ae_init_locked(ae_softc_t *sc); -static unsigned int ae_detach(device_t dev); +static int ae_detach(device_t dev); static int ae_miibus_readreg(device_t dev, int phy, int reg); static int ae_miibus_writereg(device_t dev, int phy, int reg, int val); static void ae_miibus_statchg(device_t dev); @@ -746,7 +746,7 @@ ae_init_locked(ae_softc_t *sc) return (0); } -static unsigned int +static int ae_detach(device_t dev) { struct ae_softc *sc; From imp at FreeBSD.org Wed Feb 4 12:39:46 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Feb 4 12:39:53 2009 Subject: svn commit: r188128 - head/sys/dev/an Message-ID: <200902042039.n14KdkxQ090545@svn.freebsd.org> Author: imp Date: Wed Feb 4 20:39:45 2009 New Revision: 188128 URL: http://svn.freebsd.org/changeset/base/188128 Log: Shutdown routine returns int. Modified: head/sys/dev/an/if_an.c head/sys/dev/an/if_anreg.h Modified: head/sys/dev/an/if_an.c ============================================================================== --- head/sys/dev/an/if_an.c Wed Feb 4 20:35:22 2009 (r188127) +++ head/sys/dev/an/if_an.c Wed Feb 4 20:39:45 2009 (r188128) @@ -2989,7 +2989,7 @@ an_watchdog(struct ifnet *ifp) return; } -void +int an_shutdown(device_t dev) { struct an_softc *sc; @@ -2998,7 +2998,7 @@ an_shutdown(device_t dev) an_stop(sc); sc->an_gone = 1; - return; + return 0; } void Modified: head/sys/dev/an/if_anreg.h ============================================================================== --- head/sys/dev/an/if_anreg.h Wed Feb 4 20:35:22 2009 (r188127) +++ head/sys/dev/an/if_anreg.h Wed Feb 4 20:39:45 2009 (r188128) @@ -511,7 +511,7 @@ int an_alloc_aux_memory (device_t, int, int an_alloc_irq (device_t, int, int); int an_pci_probe (device_t); int an_probe (device_t); -void an_shutdown (device_t); +int an_shutdown (device_t); void an_resume (device_t); int an_attach (struct an_softc *, int, int); int an_detach (device_t); From imp at FreeBSD.org Wed Feb 4 13:11:33 2009 From: imp at FreeBSD.org (Warner Losh) Date: Wed Feb 4 13:11:39 2009 Subject: svn commit: r188129 - head/sys/dev/pccbb Message-ID: <200902042111.n14LBWsr091214@svn.freebsd.org> Author: imp Date: Wed Feb 4 21:11:31 2009 New Revision: 188129 URL: http://svn.freebsd.org/changeset/base/188129 Log: Correct signatures to match kobj function definitions. Modified: head/sys/dev/pccbb/pccbb.c head/sys/dev/pccbb/pccbb_pci.c head/sys/dev/pccbb/pccbbvar.h Modified: head/sys/dev/pccbb/pccbb.c ============================================================================== --- head/sys/dev/pccbb/pccbb.c Wed Feb 4 20:39:45 2009 (r188128) +++ head/sys/dev/pccbb/pccbb.c Wed Feb 4 21:11:31 2009 (r188129) @@ -175,7 +175,7 @@ static int cbb_cardbus_release_resource( int type, int rid, struct resource *res); static int cbb_cardbus_power_enable_socket(device_t brdev, device_t child); -static void cbb_cardbus_power_disable_socket(device_t brdev, +static int cbb_cardbus_power_disable_socket(device_t brdev, device_t child); static int cbb_func_filt(void *arg); static void cbb_func_intr(void *arg); @@ -998,11 +998,12 @@ cbb_cardbus_power_enable_socket(device_t return (0); } -static void +static int cbb_cardbus_power_disable_socket(device_t brdev, device_t child) { cbb_power(brdev, CARD_OFF); cbb_cardbus_reset(brdev, child, 0); + return (0); } /************************************************************************/ @@ -1262,7 +1263,7 @@ cbb_pcic_power_enable_socket(device_t br return (0); } -static void +static int cbb_pcic_power_disable_socket(device_t brdev, device_t child) { struct cbb_softc *sc = device_get_softc(brdev); @@ -1282,6 +1283,7 @@ cbb_pcic_power_disable_socket(device_t b /* enable CSC interrupts */ exca_putb(&sc->exca[0], EXCA_INTR, EXCA_INTR_ENABLE); + return (0); } /************************************************************************/ @@ -1295,18 +1297,16 @@ cbb_power_enable_socket(device_t brdev, if (sc->flags & CBB_16BIT_CARD) return (cbb_pcic_power_enable_socket(brdev, child)); - else - return (cbb_cardbus_power_enable_socket(brdev, child)); + return (cbb_cardbus_power_enable_socket(brdev, child)); } -void +int cbb_power_disable_socket(device_t brdev, device_t child) { struct cbb_softc *sc = device_get_softc(brdev); if (sc->flags & CBB_16BIT_CARD) - cbb_pcic_power_disable_socket(brdev, child); - else - cbb_cardbus_power_disable_socket(brdev, child); + return (cbb_pcic_power_disable_socket(brdev, child)); + return (cbb_cardbus_power_disable_socket(brdev, child)); } static int @@ -1404,7 +1404,7 @@ cbb_pcic_release_resource(device_t brdev int cbb_pcic_set_res_flags(device_t brdev, device_t child, int type, int rid, - uint32_t flags) + u_long flags) { struct cbb_softc *sc = device_get_softc(brdev); struct resource *res; @@ -1579,9 +1579,9 @@ cbb_resume(device_t self) } int -cbb_child_present(device_t self) +cbb_child_present(device_t parent, device_t child) { - struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(self); + struct cbb_softc *sc = (struct cbb_softc *)device_get_softc(parent); uint32_t sockstate; sockstate = cbb_get(sc, CBB_SOCKET_STATE); Modified: head/sys/dev/pccbb/pccbb_pci.c ============================================================================== --- head/sys/dev/pccbb/pccbb_pci.c Wed Feb 4 20:39:45 2009 (r188128) +++ head/sys/dev/pccbb/pccbb_pci.c Wed Feb 4 21:11:31 2009 (r188129) @@ -785,20 +785,17 @@ cbb_maxslots(device_t brdev) } static uint32_t -cbb_read_config(device_t brdev, int b, int s, int f, int reg, int width) +cbb_read_config(device_t brdev, u_int b, u_int s, u_int f, u_int reg, int width) { - uint32_t rv; - /* * Pass through to the next ppb up the chain (i.e. our grandparent). */ - rv = PCIB_READ_CONFIG(device_get_parent(device_get_parent(brdev)), - b, s, f, reg, width); - return (rv); + return (PCIB_READ_CONFIG(device_get_parent(device_get_parent(brdev)), + b, s, f, reg, width)); } static void -cbb_write_config(device_t brdev, int b, int s, int f, int reg, uint32_t val, +cbb_write_config(device_t brdev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width) { /* Modified: head/sys/dev/pccbb/pccbbvar.h ============================================================================== --- head/sys/dev/pccbb/pccbbvar.h Wed Feb 4 20:39:45 2009 (r188128) +++ head/sys/dev/pccbb/pccbbvar.h Wed Feb 4 21:11:31 2009 (r188129) @@ -116,7 +116,7 @@ struct resource *cbb_alloc_resource(devi int type, int *rid, u_long start, u_long end, u_long count, u_int flags); void cbb_child_detached(device_t brdev, device_t child); -int cbb_child_present(device_t self); +int cbb_child_present(device_t parent, device_t child); int cbb_deactivate_resource(device_t brdev, device_t child, int type, int rid, struct resource *r); int cbb_detach(device_t brdev); @@ -126,10 +126,10 @@ void cbb_event_thread(void *arg); int cbb_pcic_set_memory_offset(device_t brdev, device_t child, int rid, uint32_t cardaddr, uint32_t *deltap); int cbb_pcic_set_res_flags(device_t brdev, device_t child, int type, - int rid, uint32_t flags); + int rid, u_long flags); int cbb_power(device_t brdev, int volts); int cbb_power_enable_socket(device_t brdev, device_t child); -void cbb_power_disable_socket(device_t brdev, device_t child); +int cbb_power_disable_socket(device_t brdev, device_t child); int cbb_read_ivar(device_t brdev, device_t child, int which, uintptr_t *result); int cbb_release_resource(device_t brdev, device_t child, From emax at FreeBSD.org Wed Feb 4 14:04:07 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Wed Feb 4 14:04:19 2009 Subject: svn commit: r188130 - in head: usr.bin/bluetooth/rfcomm_sppd usr.sbin/bluetooth/hcsecd usr.sbin/bluetooth/hcseriald usr.sbin/bluetooth/rfcomm_pppd Message-ID: <200902042204.n14M46j0095320@svn.freebsd.org> Author: emax Date: Wed Feb 4 22:04:06 2009 New Revision: 188130 URL: http://svn.freebsd.org/changeset/base/188130 Log: Clenup code a bit and do not call fork(2) before dameon(3) where not needed. MFC after: 1 month Modified: head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c head/usr.sbin/bluetooth/hcsecd/hcsecd.c head/usr.sbin/bluetooth/hcseriald/hcseriald.c head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Modified: head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c ============================================================================== --- head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c Wed Feb 4 21:11:31 2009 (r188129) +++ head/usr.bin/bluetooth/rfcomm_sppd/rfcomm_sppd.c Wed Feb 4 22:04:06 2009 (r188130) @@ -281,22 +281,8 @@ main(int argc, char *argv[]) } /* Became daemon if required */ - if (background) { - switch (fork()) { - case -1: - err(1, "Could not fork()"); - /* NOT REACHED */ - - case 0: - exit(0); - /* NOT REACHED */ - - default: - if (daemon(0, 0) < 0) - err(1, "Could not daemon()"); - break; - } - } + if (background && daemon(0, 0) < 0) + err(1, "Could not daemon()"); openlog(SPPD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "Starting on %s...", (tty != NULL)? tty : "stdin/stdout"); Modified: head/usr.sbin/bluetooth/hcsecd/hcsecd.c ============================================================================== --- head/usr.sbin/bluetooth/hcsecd/hcsecd.c Wed Feb 4 21:11:31 2009 (r188129) +++ head/usr.sbin/bluetooth/hcsecd/hcsecd.c Wed Feb 4 22:04:06 2009 (r188130) @@ -128,9 +128,8 @@ main(int argc, char *argv[]) (void * const) &filter, sizeof(filter)) < 0) err(1, "Could not set HCI socket filter"); - if (detach) - if (daemon(0, 0) < 0) - err(1, "Could not daemon()ize"); + if (detach && daemon(0, 0) < 0) + err(1, "Could not daemon()ize"); openlog(HCSECD_IDENT, LOG_NDELAY|LOG_PERROR|LOG_PID, LOG_DAEMON); Modified: head/usr.sbin/bluetooth/hcseriald/hcseriald.c ============================================================================== --- head/usr.sbin/bluetooth/hcseriald/hcseriald.c Wed Feb 4 21:11:31 2009 (r188129) +++ head/usr.sbin/bluetooth/hcseriald/hcseriald.c Wed Feb 4 22:04:06 2009 (r188130) @@ -101,23 +101,10 @@ main(int argc, char *argv[]) /* Open device */ n = open_device(device, speed, name); - if (detach) { - pid_t pid = fork(); - - if (pid == (pid_t) -1) { - syslog(LOG_ERR, "Could not fork(). %s (%d)", - strerror(errno), errno); - exit(1); - } - - if (pid != 0) - exit(0); - - if (daemon(0, 0) < 0) { - syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", - strerror(errno), errno); - exit(1); - } + if (detach && daemon(0, 0) < 0) { + syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", + strerror(errno), errno); + exit(1); } /* Write PID file */ Modified: head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c ============================================================================== --- head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Wed Feb 4 21:11:31 2009 (r188129) +++ head/usr.sbin/bluetooth/rfcomm_pppd/rfcomm_pppd.c Wed Feb 4 22:04:06 2009 (r188130) @@ -166,22 +166,10 @@ main(int argc, char *argv[]) openlog(RFCOMM_PPPD, LOG_PID | LOG_PERROR | LOG_NDELAY, LOG_USER); - if (detach) { - pid = fork(); - if (pid == (pid_t) -1) { - syslog(LOG_ERR, "Could not fork(). %s (%d)", - strerror(errno), errno); - exit(1); - } - - if (pid != 0) - exit(0); - - if (daemon(0, 0) < 0) { - syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", - strerror(errno), errno); - exit(1); - } + if (detach && daemon(0, 0) < 0) { + syslog(LOG_ERR, "Could not daemon(0, 0). %s (%d)", + strerror(errno), errno); + exit(1); } s = socket(PF_BLUETOOTH, SOCK_STREAM, BLUETOOTH_PROTO_RFCOMM); From nwhitehorn at FreeBSD.org Wed Feb 4 14:16:29 2009 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Wed Feb 4 14:16:41 2009 Subject: svn commit: r188131 - head/sys/dev/bm Message-ID: <200902042216.n14MGSK6096491@svn.freebsd.org> Author: nwhitehorn Date: Wed Feb 4 22:16:27 2009 New Revision: 188131 URL: http://svn.freebsd.org/changeset/base/188131 Log: Fix bm_shutdown() KOBJ method to correspond to return int, as it should. Found by: Andriy Gapon Modified: head/sys/dev/bm/if_bm.c Modified: head/sys/dev/bm/if_bm.c ============================================================================== --- head/sys/dev/bm/if_bm.c Wed Feb 4 22:04:06 2009 (r188130) +++ head/sys/dev/bm/if_bm.c Wed Feb 4 22:16:27 2009 (r188131) @@ -81,7 +81,7 @@ MODULE_DEPEND(bm, miibus, 1, 1, 1); static int bm_probe (device_t); static int bm_attach (device_t); static int bm_detach (device_t); -static void bm_shutdown (device_t); +static int bm_shutdown (device_t); static void bm_start (struct ifnet *); static void bm_start_locked (struct ifnet *); @@ -654,7 +654,7 @@ bm_detach(device_t dev) return (0); } -static void +static int bm_shutdown(device_t dev) { struct bm_softc *sc; @@ -664,6 +664,8 @@ bm_shutdown(device_t dev) BM_LOCK(sc); bm_stop(sc); BM_UNLOCK(sc); + + return (0); } static void From emax at FreeBSD.org Wed Feb 4 14:44:10 2009 From: emax at FreeBSD.org (Maksim Yevmenkin) Date: Wed Feb 4 14:44:21 2009 Subject: svn commit: r188132 - head/sys/netgraph/bluetooth/socket Message-ID: <200902042244.n14Mi9J0097100@svn.freebsd.org> Author: emax Date: Wed Feb 4 22:44:09 2009 New Revision: 188132 URL: http://svn.freebsd.org/changeset/base/188132 Log: Allow unprivileged users to run l2ping(8). MFC after: 1 month Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c ============================================================================== --- head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Wed Feb 4 22:16:27 2009 (r188131) +++ head/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c Wed Feb 4 22:44:09 2009 (r188132) @@ -947,11 +947,6 @@ ng_btsocket_l2cap_raw_control(struct soc ng_l2cap_l2ca_ping_ip *ip = NULL; ng_l2cap_l2ca_ping_op *op = NULL; - if (!(pcb->flags & NG_BTSOCKET_L2CAP_RAW_PRIVILEGED)) { - error = EPERM; - break; - } - if ((p->echo_size != 0 && p->echo_data == NULL) || p->echo_size > NG_L2CAP_MAX_ECHO_SIZE) { error = EINVAL; From kmacy at FreeBSD.org Wed Feb 4 18:01:19 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Wed Feb 4 18:01:30 2009 Subject: svn commit: r188134 - head/sys/i386/xen Message-ID: <200902050201.n1521IbK003857@svn.freebsd.org> Author: kmacy Date: Thu Feb 5 02:01:18 2009 New Revision: 188134 URL: http://svn.freebsd.org/changeset/base/188134 Log: adjust the way that idle happens so as to avoid missing timer interrupts Modified: head/sys/i386/xen/clock.c Modified: head/sys/i386/xen/clock.c ============================================================================== --- head/sys/i386/xen/clock.c Thu Feb 5 01:59:28 2009 (r188133) +++ head/sys/i386/xen/clock.c Thu Feb 5 02:01:18 2009 (r188134) @@ -246,24 +246,29 @@ static void __get_time_values_from_xen(v shared_info_t *s = HYPERVISOR_shared_info; struct vcpu_time_info *src; struct shadow_time_info *dst; + uint32_t pre_version, post_version; src = &s->vcpu_info[smp_processor_id()].time; dst = &per_cpu(shadow_time, smp_processor_id()); + spinlock_enter(); do { - dst->version = src->version; + pre_version = dst->version = src->version; rmb(); dst->tsc_timestamp = src->tsc_timestamp; dst->system_timestamp = src->system_time; dst->tsc_to_nsec_mul = src->tsc_to_system_mul; dst->tsc_shift = src->tsc_shift; rmb(); + post_version = src->version; } - while ((src->version & 1) | (dst->version ^ src->version)); + while ((pre_version & 1) | (pre_version ^ post_version)); dst->tsc_to_usec_mul = dst->tsc_to_nsec_mul / 1000; + spinlock_exit(); } + static inline int time_values_up_to_date(int cpu) { struct vcpu_time_info *src; @@ -311,15 +316,15 @@ clkintr(void *arg) } /* Process elapsed ticks since last call. */ - if (delta >= NS_PER_TICK) { - processed_system_time += (delta / NS_PER_TICK) * NS_PER_TICK; - per_cpu(processed_system_time, cpu) += (delta_cpu / NS_PER_TICK) * NS_PER_TICK; + while (delta >= NS_PER_TICK) { + delta -= NS_PER_TICK; + processed_system_time += NS_PER_TICK; + per_cpu(processed_system_time, cpu) += NS_PER_TICK; + if (PCPU_GET(cpuid) == 0) + hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); + else + hardclock_cpu(TRAPF_USERMODE(frame)); } - if (PCPU_GET(cpuid) == 0) - hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); - else - hardclock_cpu(TRAPF_USERMODE(frame)); - /* * Take synchronised time from Xen once a minute if we're not * synchronised ourselves, and we haven't chosen to keep an independent @@ -334,61 +339,25 @@ clkintr(void *arg) /* XXX TODO */ return (FILTER_HANDLED); } - -int clkintr2(void *arg); - -int -clkintr2(void *arg) -{ - int64_t delta_cpu, delta; - struct trapframe *frame = (struct trapframe *)arg; - int cpu = smp_processor_id(); - struct shadow_time_info *shadow = &per_cpu(shadow_time, cpu); - - do { - __get_time_values_from_xen(); - - delta = delta_cpu = - shadow->system_timestamp + get_nsec_offset(shadow); - delta -= processed_system_time; - delta_cpu -= per_cpu(processed_system_time, cpu); - - } while (!time_values_up_to_date(cpu)); - - if (unlikely(delta < (int64_t)0) || unlikely(delta_cpu < (int64_t)0)) { - printf("Timer ISR: Time went backwards: %lld\n", delta); - return (FILTER_HANDLED); - } - - /* Process elapsed ticks since last call. */ - if (delta >= NS_PER_TICK) { - processed_system_time += (delta / NS_PER_TICK) * NS_PER_TICK; - per_cpu(processed_system_time, cpu) += (delta_cpu / NS_PER_TICK) * NS_PER_TICK; - } - hardclock(TRAPF_USERMODE(frame), TRAPF_PC(frame)); - - /* - * Take synchronised time from Xen once a minute if we're not - * synchronised ourselves, and we haven't chosen to keep an independent - * time base. - */ - - if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) { - update_wallclock(); - tc_setclock(&shadow_tv); - } - - /* XXX TODO */ - return (FILTER_HANDLED); -} - static uint32_t getit(void) { struct shadow_time_info *shadow; + uint64_t time; + uint32_t local_time_version; + shadow = &per_cpu(shadow_time, smp_processor_id()); - __get_time_values_from_xen(); - return shadow->system_timestamp + get_nsec_offset(shadow); + + do { + local_time_version = shadow->version; + barrier(); + time = shadow->system_timestamp + get_nsec_offset(shadow); + if (!time_values_up_to_date(cpu)) + __get_time_values_from_xen(/*cpu */); + barrier(); + } while (local_time_version != shadow->version); + + return (time); } @@ -552,7 +521,6 @@ startrtclock() timer_freq = xen_timecounter.tc_frequency = 1000000000LL; tc_init(&xen_timecounter); - rdtscll(alarm); } @@ -903,13 +871,44 @@ xen_get_offset(void) return edx; } #endif + +/* Convert jiffies to system time. */ +static uint64_t +ticks_to_system_time(unsigned long newticks) +{ +#if 0 + unsigned long seq; +#endif + long delta; + uint64_t st; + + + delta = newticks - ticks; + if (delta < 1) { + /* Triggers in some wrap-around cases, but that's okay: + * we just end up with a shorter timeout. */ + st = processed_system_time + NS_PER_TICK; + } else if (((unsigned long)delta >> (BITS_PER_LONG-3)) != 0) { + /* Very long timeout means there is no pending timer. + * We indicate this to Xen by passing zero timeout. */ + st = 0; + } else { + st = processed_system_time + delta * (uint64_t)NS_PER_TICK; + } + + return (st); +} + void idle_block(void) { + uint64_t timeout; - __get_time_values_from_xen(); - PANIC_IF(HYPERVISOR_set_timer_op(processed_system_time + NS_PER_TICK) != 0); - HYPERVISOR_sched_op(SCHEDOP_block, 0); + timeout = ticks_to_system_time(ticks + 1) + NS_PER_TICK/2; + + __get_time_values_from_xen(); + PANIC_IF(HYPERVISOR_set_timer_op(timeout) != 0); + HYPERVISOR_sched_op(SCHEDOP_block, 0); } int From kmacy at FreeBSD.org Wed Feb 4 20:00:56 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Wed Feb 4 20:01:02 2009 Subject: svn commit: r188138 - head/sys/i386/xen Message-ID: <200902050400.n1540tgU008169@svn.freebsd.org> Author: kmacy Date: Thu Feb 5 04:00:55 2009 New Revision: 188138 URL: http://svn.freebsd.org/changeset/base/188138 Log: pass in smp_processor_id to identify the cpu in use Modified: head/sys/i386/xen/clock.c Modified: head/sys/i386/xen/clock.c ============================================================================== --- head/sys/i386/xen/clock.c Thu Feb 5 02:16:05 2009 (r188137) +++ head/sys/i386/xen/clock.c Thu Feb 5 04:00:55 2009 (r188138) @@ -352,7 +352,7 @@ getit(void) local_time_version = shadow->version; barrier(); time = shadow->system_timestamp + get_nsec_offset(shadow); - if (!time_values_up_to_date(cpu)) + if (!time_values_up_to_date(smp_processor_id())) __get_time_values_from_xen(/*cpu */); barrier(); } while (local_time_version != shadow->version); From Alexander at Leidinger.net Wed Feb 4 22:22:07 2009 From: Alexander at Leidinger.net (Alexander Leidinger) Date: Wed Feb 4 22:22:19 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <20090204.103220.1763804960.imp@bsdimp.com> References: <4988AB83.2050203@gmx.de> <20090204212854.F51932@delplex.bde.org> <20090204154414.1949765y56lfhi80@webmail.leidinger.net> <20090204.103220.1763804960.imp@bsdimp.com> Message-ID: <20090205072158.23811u1p5tpfkakk@webmail.leidinger.net> Quoting "M. Warner Losh" (from Wed, 04 Feb 2009 10:32:20 -0700 (MST)): > In message: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> > Alexander Leidinger writes: > : Quoting Bruce Evans (from Wed, 4 Feb 2009 > : 22:27:59 +1100 (EST)): > : > : > On Tue, 3 Feb 2009, Christoph Mallon wrote: > : > > : >> Warner Losh schrieb: > : >>> Modified: head/lib/libc/string/strmode.c > : >>> > ============================================================================== > : >>> --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) > : >>> +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) > : >>> @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); > : >>> #include > : >>> void > : >>> -strmode(mode_t mode, char *p) > : >>> +strmode(/* mode_t */ int mode, char *p) > : >>> { > : >>> /* print type */ > : >>> switch (mode & S_IFMT) { > : >> > : >> The manpage states that the first parameter of strmode() is a > : >> mode_t. What's wrong - the implementation (both in header and > : >> definition) or the documentation? > : > > : > The man page is wrong. strtomode() should take an int arg (actually > : > the default (unary) promotion of a mode_t) for the the same reasons > : > that memchr() does -- because these interfaces should be usable by K&R > : > compilers and/or by standard C compilers without a protoype in scope. > : > Even if this is no longer required, binary compatibily requires the > : > interfaces to be the same as the ones that used to be required. The > : > requirement for binary compatibility also prevents "fixing" interfaces > : > to be "ANSI" in headers (if you "fix" prototypes there then you will > : > get obscure runtime errors instead of tinderbox errors). > : > : Is this also true for the current use of symbol versioning in our > : libc? I thought this is supposed to "fix" this problem (assuming we > : add an UPDATING entry that users have to make sure that they to a full > : installworld to habe the includes and the lib in sync)? > > Maybe, but it is a problem worth fixing? What we have now is correct It depends if this is seen as a broken window (http://www.pragprog.com/the-pragmatic-programmer/extracts/software-entropy) or not... At least we should not talk a lot against fixing it. If someone wants to fix it, he should be welcome. Bye, Alexander. -- Phosflink, v: To flick a bulb on and off when it burns out (as if, somehow, that will bring it back to life). -- Rich Hall & Friends, "Sniglets" http://www.Leidinger.net Alexander @ Leidinger.net: PGP ID = B0063FE7 http://www.FreeBSD.org netchild @ FreeBSD.org : PGP ID = 72077137 From imp at bsdimp.com Wed Feb 4 23:51:18 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Wed Feb 4 23:51:30 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <20090205072158.23811u1p5tpfkakk@webmail.leidinger.net> References: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> <20090204.103220.1763804960.imp@bsdimp.com> <20090205072158.23811u1p5tpfkakk@webmail.leidinger.net> Message-ID: <20090205.004849.-906919470.imp@bsdimp.com> In message: <20090205072158.23811u1p5tpfkakk@webmail.leidinger.net> Alexander Leidinger writes: : Quoting "M. Warner Losh" (from Wed, 04 Feb 2009 : 10:32:20 -0700 (MST)): : : > In message: <20090204154414.1949765y56lfhi80@webmail.leidinger.net> : > Alexander Leidinger writes: : > : Quoting Bruce Evans (from Wed, 4 Feb 2009 : > : 22:27:59 +1100 (EST)): : > : : > : > On Tue, 3 Feb 2009, Christoph Mallon wrote: : > : > : > : >> Warner Losh schrieb: : > : >>> Modified: head/lib/libc/string/strmode.c : > : >>> : > ============================================================================== : > : >>> --- head/lib/libc/string/strmode.c Tue Feb 3 20:01:51 2009 (r188097) : > : >>> +++ head/lib/libc/string/strmode.c Tue Feb 3 20:25:36 2009 (r188098) : > : >>> @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); : > : >>> #include : > : >>> void : > : >>> -strmode(mode_t mode, char *p) : > : >>> +strmode(/* mode_t */ int mode, char *p) : > : >>> { : > : >>> /* print type */ : > : >>> switch (mode & S_IFMT) { : > : >> : > : >> The manpage states that the first parameter of strmode() is a : > : >> mode_t. What's wrong - the implementation (both in header and : > : >> definition) or the documentation? : > : > : > : > The man page is wrong. strtomode() should take an int arg (actually : > : > the default (unary) promotion of a mode_t) for the the same reasons : > : > that memchr() does -- because these interfaces should be usable by K&R : > : > compilers and/or by standard C compilers without a protoype in scope. : > : > Even if this is no longer required, binary compatibily requires the : > : > interfaces to be the same as the ones that used to be required. The : > : > requirement for binary compatibility also prevents "fixing" interfaces : > : > to be "ANSI" in headers (if you "fix" prototypes there then you will : > : > get obscure runtime errors instead of tinderbox errors). : > : : > : Is this also true for the current use of symbol versioning in our : > : libc? I thought this is supposed to "fix" this problem (assuming we : > : add an UPDATING entry that users have to make sure that they to a full : > : installworld to habe the includes and the lib in sync)? : > : > Maybe, but it is a problem worth fixing? What we have now is correct : : It depends if this is seen as a broken window : (http://www.pragprog.com/the-pragmatic-programmer/extracts/software-entropy) : or not... : : At least we should not talk a lot against fixing it. If someone wants : to fix it, he should be welcome. Yea. A lot of hair to get right, to test, and to make sure works everywhere. If someone has that, and can still make things work in the no-prototype case, then go for it. Warner From trasz at FreeBSD.org Thu Feb 5 00:46:19 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Thu Feb 5 00:46:31 2009 Subject: svn commit: r188141 - head/sys/kern Message-ID: <200902050846.n158kI1D020988@svn.freebsd.org> Author: trasz Date: Thu Feb 5 08:46:18 2009 New Revision: 188141 URL: http://svn.freebsd.org/changeset/base/188141 Log: In some situations, mnt_lockref could go negative due to vfs_unbusy() being called without calling vfs_busy() first. This made umount(8) hang waiting for mnt_lockref to become zero, which would never happen. Reviewed by: kib Approved by: rwatson (mentor) Reported by: pho Found with: stress2 Sponsored by: FreeBSD Foundation Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Thu Feb 5 04:02:15 2009 (r188140) +++ head/sys/kern/vfs_syscalls.c Thu Feb 5 08:46:18 2009 (r188141) @@ -395,14 +395,16 @@ kern_fstatfs(struct thread *td, int fd, vfs_ref(mp); VOP_UNLOCK(vp, 0); fdrop(fp, td); - if (vp->v_iflag & VI_DOOMED) { + if (mp == NULL) { error = EBADF; goto out; } error = vfs_busy(mp, 0); vfs_rel(mp); - if (error) - goto out; + if (error) { + VFS_UNLOCK_GIANT(vfslocked); + return (error); + } #ifdef MAC error = mac_mount_check_stat(td->td_ucred, mp); if (error) From dfr at FreeBSD.org Thu Feb 5 03:48:11 2009 From: dfr at FreeBSD.org (Doug Rabson) Date: Thu Feb 5 03:48:23 2009 Subject: svn commit: r188142 - head/sys/rpc Message-ID: <200902051148.n15BmA54026164@svn.freebsd.org> Author: dfr Date: Thu Feb 5 11:48:10 2009 New Revision: 188142 URL: http://svn.freebsd.org/changeset/base/188142 Log: Use the correct creds when reconnecting so that we have enough privilege to bind reserved ports (if necessary). Submitted by: Jaakko Heinonen Modified: head/sys/rpc/clnt_rc.c Modified: head/sys/rpc/clnt_rc.c ============================================================================== --- head/sys/rpc/clnt_rc.c Thu Feb 5 08:46:18 2009 (r188141) +++ head/sys/rpc/clnt_rc.c Thu Feb 5 11:48:10 2009 (r188142) @@ -181,11 +181,12 @@ again: rpc_createerr.cf_error.re_errno = 0; goto out; } - if (rc->rc_privport) - bindresvport(so, NULL); oldcred = td->td_ucred; td->td_ucred = rc->rc_ucred; + if (rc->rc_privport) + bindresvport(so, NULL); + if (rc->rc_nconf->nc_semantics == NC_TPI_CLTS) rc->rc_client = clnt_dg_create(so, (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, From jamie at FreeBSD.org Thu Feb 5 06:06:11 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Thu Feb 5 06:06:24 2009 Subject: svn commit: r188144 - in head: lib/libc/sys sys/kern sys/net sys/netinet sys/netinet6 Message-ID: <200902051406.n15E6AeB028715@svn.freebsd.org> Author: jamie Date: Thu Feb 5 14:06:09 2009 New Revision: 188144 URL: http://svn.freebsd.org/changeset/base/188144 Log: Standardize the various prison_foo_ip[46] functions and prison_if to return zero on success and an error code otherwise. The possible errors are EADDRNOTAVAIL if an address being checked for doesn't match the prison, and EAFNOSUPPORT if the prison doesn't have any addresses in that address family. For most callers of these functions, use the returned error code instead of e.g. a hard-coded EADDRNOTAVAIL or EINVAL. Always include a jailed() check in these functions, where a non-jailed cred always returns success (and makes no changes). Remove the explicit jailed() checks that preceded many of the function calls. Approved by: bz (mentor) Modified: head/lib/libc/sys/send.2 head/sys/kern/kern_jail.c head/sys/net/if.c head/sys/net/rtsock.c head/sys/netinet/in.c head/sys/netinet/in_pcb.c head/sys/netinet/raw_ip.c head/sys/netinet/tcp_usrreq.c head/sys/netinet/udp_usrreq.c head/sys/netinet6/in6.c head/sys/netinet6/in6_pcb.c head/sys/netinet6/in6_src.c head/sys/netinet6/raw_ip6.c head/sys/netinet6/udp6_usrreq.c Modified: head/lib/libc/sys/send.2 ============================================================================== --- head/lib/libc/sys/send.2 Thu Feb 5 14:02:04 2009 (r188143) +++ head/lib/libc/sys/send.2 Thu Feb 5 14:06:09 2009 (r188144) @@ -28,7 +28,7 @@ .\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 .\" $FreeBSD$ .\" -.Dd September 13, 2006 +.Dd February 5, 2009 .Dt SEND 2 .Os .Sh NAME @@ -190,7 +190,7 @@ receiver is not listening on the remote The remote host was down. .It Bq Er ENETDOWN The remote network was down. -.It Bq Er EPERM +.It Bq Er EADDRNOTAVAIL The process using a .Dv SOCK_RAW socket was jailed and the source Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/kern/kern_jail.c Thu Feb 5 14:06:09 2009 (r188144) @@ -217,7 +217,7 @@ prison_check_conflicting_ips(struct pris if ((p->pr_ip4s >= 1 && pr->pr_ip4s > 1) || (p->pr_ip4s > 1 && pr->pr_ip4s >= 1)) { for (i = 0; i < p->pr_ip4s; i++) { - if (_prison_check_ip4(pr, &p->pr_ip4[i])) + if (_prison_check_ip4(pr, &p->pr_ip4[i]) == 0) return (EINVAL); } } @@ -226,7 +226,7 @@ prison_check_conflicting_ips(struct pris if ((p->pr_ip6s >= 1 && pr->pr_ip6s > 1) || (p->pr_ip6s > 1 && pr->pr_ip6s >= 1)) { for (i = 0; i < p->pr_ip6s; i++) { - if (_prison_check_ip6(pr, &p->pr_ip6[i])) + if (_prison_check_ip6(pr, &p->pr_ip6[i]) == 0) return (EINVAL); } } @@ -807,9 +807,10 @@ prison_proc_free(struct prison *pr) * Pass back primary IPv4 address of this jail. * * If not jailed return success but do not alter the address. Caller has to - * make sure to intialize it correctly (INADDR_ANY). + * make sure to intialize it correctly (e.g. INADDR_ANY). * - * Returns 0 on success, 1 on error. Address returned in NBO. + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address returned in NBO. */ int prison_get_ip4(struct ucred *cred, struct in_addr *ia) @@ -823,7 +824,7 @@ prison_get_ip4(struct ucred *cred, struc return (0); if (cred->cr_prison->pr_ip4 == NULL) - return (1); + return (EAFNOSUPPORT); ia->s_addr = cred->cr_prison->pr_ip4[0].s_addr; return (0); @@ -833,8 +834,9 @@ prison_get_ip4(struct ucred *cred, struc * Make sure our (source) address is set to something meaningful to this * jail. * - * Returns 0 on success, 1 on error. Address passed in in NBO and returned - * in NBO. + * Returns 0 if not jailed or if address belongs to jail, EADDRNOTAVAIL if + * the address doesn't belong, or EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address passed in in NBO and returned in NBO. */ int prison_local_ip4(struct ucred *cred, struct in_addr *ia) @@ -847,7 +849,7 @@ prison_local_ip4(struct ucred *cred, str if (!jailed(cred)) return (0); if (cred->cr_prison->pr_ip4 == NULL) - return (1); + return (EAFNOSUPPORT); ia0.s_addr = ntohl(ia->s_addr); if (ia0.s_addr == INADDR_LOOPBACK) { @@ -855,25 +857,23 @@ prison_local_ip4(struct ucred *cred, str return (0); } - /* - * In case there is only 1 IPv4 address, bind directly. - */ - if (ia0.s_addr == INADDR_ANY && cred->cr_prison->pr_ip4s == 1) { - ia->s_addr = cred->cr_prison->pr_ip4[0].s_addr; + if (ia0.s_addr == INADDR_ANY) { + /* + * In case there is only 1 IPv4 address, bind directly. + */ + if (cred->cr_prison->pr_ip4s == 1) + ia->s_addr = cred->cr_prison->pr_ip4[0].s_addr; return (0); } - if (ia0.s_addr == INADDR_ANY || prison_check_ip4(cred, ia)) - return (0); - - return (1); + return (_prison_check_ip4(cred->cr_prison, ia)); } /* * Rewrite destination address in case we will connect to loopback address. * - * Returns 0 on success, 1 on error. Address passed in in NBO and returned - * in NBO. + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address passed in in NBO and returned in NBO. */ int prison_remote_ip4(struct ucred *cred, struct in_addr *ia) @@ -885,7 +885,8 @@ prison_remote_ip4(struct ucred *cred, st if (!jailed(cred)) return (0); if (cred->cr_prison->pr_ip4 == NULL) - return (1); + return (EAFNOSUPPORT); + if (ntohl(ia->s_addr) == INADDR_LOOPBACK) { ia->s_addr = cred->cr_prison->pr_ip4[0].s_addr; return (0); @@ -898,23 +899,22 @@ prison_remote_ip4(struct ucred *cred, st } /* - * Check if given address belongs to the jail referenced by cred. + * Check if given address belongs to the jail referenced by cred/prison. * - * Returns 1 if address belongs to jail, 0 if not. Address passed in in NBO. + * Returns 0 if not jailed or if address belongs to jail, EADDRNOTAVAIL if + * the address doesn't belong, or EAFNOSUPPORT if the jail doesn't allow IPv4. + * Address passed in in NBO. */ static int _prison_check_ip4(struct prison *pr, struct in_addr *ia) { int i, a, z, d; - if (pr->pr_ip4 == NULL) - return (0); - /* * Check the primary IP. */ if (pr->pr_ip4[0].s_addr == ia->s_addr) - return (1); + return (0); /* * All the other IPs are sorted so we can do a binary search. @@ -929,9 +929,10 @@ _prison_check_ip4(struct prison *pr, str else if (d < 0) a = i + 1; else - return (1); + return (0); } - return (0); + + return (EADDRNOTAVAIL); } int @@ -942,7 +943,9 @@ prison_check_ip4(struct ucred *cred, str KASSERT(ia != NULL, ("%s: ia is NULL", __func__)); if (!jailed(cred)) - return (1); + return (0); + if (cred->cr_prison->pr_ip4 == NULL) + return (EAFNOSUPPORT); return (_prison_check_ip4(cred->cr_prison, ia)); } @@ -953,9 +956,9 @@ prison_check_ip4(struct ucred *cred, str * Pass back primary IPv6 address for this jail. * * If not jailed return success but do not alter the address. Caller has to - * make sure to intialize it correctly (IN6ADDR_ANY_INIT). + * make sure to intialize it correctly (e.g. IN6ADDR_ANY_INIT). * - * Returns 0 on success, 1 on error. + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. */ int prison_get_ip6(struct ucred *cred, struct in6_addr *ia6) @@ -967,7 +970,8 @@ prison_get_ip6(struct ucred *cred, struc if (!jailed(cred)) return (0); if (cred->cr_prison->pr_ip6 == NULL) - return (1); + return (EAFNOSUPPORT); + bcopy(&cred->cr_prison->pr_ip6[0], ia6, sizeof(struct in6_addr)); return (0); } @@ -978,7 +982,8 @@ prison_get_ip6(struct ucred *cred, struc * v6only should be set based on (inp->inp_flags & IN6P_IPV6_V6ONLY != 0) * when needed while binding. * - * Returns 0 on success, 1 on error. + * Returns 0 if not jailed or if address belongs to jail, EADDRNOTAVAIL if + * the address doesn't belong, or EAFNOSUPPORT if the jail doesn't allow IPv6. */ int prison_local_ip6(struct ucred *cred, struct in6_addr *ia6, int v6only) @@ -990,32 +995,32 @@ prison_local_ip6(struct ucred *cred, str if (!jailed(cred)) return (0); if (cred->cr_prison->pr_ip6 == NULL) - return (1); + return (EAFNOSUPPORT); + if (IN6_IS_ADDR_LOOPBACK(ia6)) { bcopy(&cred->cr_prison->pr_ip6[0], ia6, sizeof(struct in6_addr)); return (0); } - /* - * In case there is only 1 IPv6 address, and v6only is true, then - * bind directly. - */ - if (v6only != 0 && IN6_IS_ADDR_UNSPECIFIED(ia6) && - cred->cr_prison->pr_ip6s == 1) { - bcopy(&cred->cr_prison->pr_ip6[0], ia6, - sizeof(struct in6_addr)); + if (IN6_IS_ADDR_UNSPECIFIED(ia6)) { + /* + * In case there is only 1 IPv6 address, and v6only is true, + * then bind directly. + */ + if (v6only != 0 && cred->cr_prison->pr_ip6s == 1) + bcopy(&cred->cr_prison->pr_ip6[0], ia6, + sizeof(struct in6_addr)); return (0); } - if (IN6_IS_ADDR_UNSPECIFIED(ia6) || prison_check_ip6(cred, ia6)) - return (0); - return (1); + + return (_prison_check_ip6(cred->cr_prison, ia6)); } /* * Rewrite destination address in case we will connect to loopback address. * - * Returns 0 on success, 1 on error. + * Returns 0 on success, EAFNOSUPPORT if the jail doesn't allow IPv6. */ int prison_remote_ip6(struct ucred *cred, struct in6_addr *ia6) @@ -1027,7 +1032,8 @@ prison_remote_ip6(struct ucred *cred, st if (!jailed(cred)) return (0); if (cred->cr_prison->pr_ip6 == NULL) - return (1); + return (EAFNOSUPPORT); + if (IN6_IS_ADDR_LOOPBACK(ia6)) { bcopy(&cred->cr_prison->pr_ip6[0], ia6, sizeof(struct in6_addr)); @@ -1041,23 +1047,21 @@ prison_remote_ip6(struct ucred *cred, st } /* - * Check if given address belongs to the jail referenced by cred. + * Check if given address belongs to the jail referenced by cred/prison. * - * Returns 1 if address belongs to jail, 0 if not. + * Returns 0 if not jailed or if address belongs to jail, EADDRNOTAVAIL if + * the address doesn't belong, or EAFNOSUPPORT if the jail doesn't allow IPv6. */ static int _prison_check_ip6(struct prison *pr, struct in6_addr *ia6) { int i, a, z, d; - if (pr->pr_ip6 == NULL) - return (0); - /* * Check the primary IP. */ if (IN6_ARE_ADDR_EQUAL(&pr->pr_ip6[0], ia6)) - return (1); + return (0); /* * All the other IPs are sorted so we can do a binary search. @@ -1072,9 +1076,10 @@ _prison_check_ip6(struct prison *pr, str else if (d < 0) a = i + 1; else - return (1); + return (0); } - return (0); + + return (EADDRNOTAVAIL); } int @@ -1085,7 +1090,9 @@ prison_check_ip6(struct ucred *cred, str KASSERT(ia6 != NULL, ("%s: ia6 is NULL", __func__)); if (!jailed(cred)) - return (1); + return (0); + if (cred->cr_prison->pr_ip6 == NULL) + return (EAFNOSUPPORT); return (_prison_check_ip6(cred->cr_prison, ia6)); } @@ -1095,8 +1102,9 @@ prison_check_ip6(struct ucred *cred, str * Check if given address belongs to the jail referenced by cred (wrapper to * prison_check_ip[46]). * - * Returns 1 if address belongs to jail, 0 if not. IPv4 Address passed in in - * NBO. + * Returns 0 if not jailed or if address belongs to jail, EADDRNOTAVAIL if + * the address doesn't belong, or EAFNOSUPPORT if the jail doesn't allow + * the address family. IPv4 Address passed in in NBO. */ int prison_if(struct ucred *cred, struct sockaddr *sa) @@ -1107,35 +1115,31 @@ prison_if(struct ucred *cred, struct soc #ifdef INET6 struct sockaddr_in6 *sai6; #endif - int ok; + int error; KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); KASSERT(sa != NULL, ("%s: sa is NULL", __func__)); - ok = 0; - switch(sa->sa_family) + error = 0; + switch (sa->sa_family) { #ifdef INET case AF_INET: sai = (struct sockaddr_in *)sa; - if (prison_check_ip4(cred, &sai->sin_addr)) - ok = 1; + error = prison_check_ip4(cred, &sai->sin_addr); break; - #endif #ifdef INET6 case AF_INET6: sai6 = (struct sockaddr_in6 *)sa; - if (prison_check_ip6(cred, (struct in6_addr *)&sai6->sin6_addr)) - ok = 1; + error = prison_check_ip6(cred, &sai6->sin6_addr); break; - #endif default: - if (!jail_socket_unixiproute_only) - ok = 1; + if (jailed(cred) && jail_socket_unixiproute_only) + error = EAFNOSUPPORT; } - return (ok); + return (error); } /* Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/net/if.c Thu Feb 5 14:06:09 2009 (r188144) @@ -2271,8 +2271,7 @@ again: TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { struct sockaddr *sa = ifa->ifa_addr; - if (jailed(curthread->td_ucred) && - !prison_if(curthread->td_ucred, sa)) + if (prison_if(curthread->td_ucred, sa) != 0) continue; addrs++; #ifdef COMPAT_43 Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/net/rtsock.c Thu Feb 5 14:06:09 2009 (r188144) @@ -347,7 +347,7 @@ rtm_get_jailed(struct rt_addrinfo *info, * 1. Check if the returned address is part of the jail. */ ia = ((struct sockaddr_in *)rt->rt_ifa->ifa_addr)->sin_addr; - if (prison_check_ip4(cred, &ia) != 0) { + if (prison_check_ip4(cred, &ia) == 0) { info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } else { @@ -366,7 +366,7 @@ rtm_get_jailed(struct rt_addrinfo *info, if (sa->sa_family != AF_INET) continue; ia = ((struct sockaddr_in *)sa)->sin_addr; - if (prison_check_ip4(cred, &ia) != 0) { + if (prison_check_ip4(cred, &ia) == 0) { found = 1; break; } @@ -399,7 +399,7 @@ rtm_get_jailed(struct rt_addrinfo *info, */ bcopy(&((struct sockaddr_in6 *)rt->rt_ifa->ifa_addr)->sin6_addr, &ia6, sizeof(struct in6_addr)); - if (prison_check_ip6(cred, &ia6) != 0) { + if (prison_check_ip6(cred, &ia6) == 0) { info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } else { struct ifaddr *ifa; @@ -418,7 +418,7 @@ rtm_get_jailed(struct rt_addrinfo *info, continue; bcopy(&((struct sockaddr_in6 *)sa)->sin6_addr, &ia6, sizeof(struct in6_addr)); - if (prison_check_ip6(cred, &ia6) != 0) { + if (prison_check_ip6(cred, &ia6) == 0) { found = 1; break; } @@ -612,9 +612,10 @@ route_output(struct mbuf *m, struct sock case RTM_GET: report: RT_LOCK_ASSERT(rt); - if (jailed(curthread->td_ucred) && - ((rt->rt_flags & RTF_HOST) == 0 || - !prison_if(curthread->td_ucred, rt_key(rt)))) { + if ((rt->rt_flags & RTF_HOST) == 0 + ? jailed(curthread->td_ucred) + : prison_if(curthread->td_ucred, + rt_key(rt)) != 0) { RT_UNLOCK(rt); senderr(ESRCH); } @@ -1263,9 +1264,9 @@ sysctl_dumpentry(struct radix_node *rn, if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg)) return 0; - if (jailed(w->w_req->td->td_ucred) && - ((rt->rt_flags & RTF_HOST) == 0 || - !prison_if(w->w_req->td->td_ucred, rt_key(rt)))) + if ((rt->rt_flags & RTF_HOST) == 0 + ? jailed(w->w_req->td->td_ucred) + : prison_if(w->w_req->td->td_ucred, rt_key(rt)) != 0) return (0); bzero((caddr_t)&info, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(rt); @@ -1327,8 +1328,8 @@ sysctl_iflist(int af, struct walkarg *w) while ((ifa = TAILQ_NEXT(ifa, ifa_link)) != NULL) { if (af && af != ifa->ifa_addr->sa_family) continue; - if (jailed(w->w_req->td->td_ucred) && - !prison_if(w->w_req->td->td_ucred, ifa->ifa_addr)) + if (prison_if(w->w_req->td->td_ucred, + ifa->ifa_addr) != 0) continue; info.rti_info[RTAX_IFA] = ifa->ifa_addr; info.rti_info[RTAX_NETMASK] = ifa->ifa_netmask; @@ -1376,8 +1377,8 @@ sysctl_ifmalist(int af, struct walkarg * TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (af && af != ifma->ifma_addr->sa_family) continue; - if (jailed(w->w_req->td->td_ucred) && - !prison_if(w->w_req->td->td_ucred, ifma->ifma_addr)) + if (prison_if(w->w_req->td->td_ucred, + ifma->ifma_addr) != 0) continue; info.rti_info[RTAX_IFA] = ifma->ifma_addr; info.rti_info[RTAX_GATEWAY] = Modified: head/sys/netinet/in.c ============================================================================== --- head/sys/netinet/in.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet/in.c Thu Feb 5 14:06:09 2009 (r188144) @@ -264,7 +264,7 @@ in_control(struct socket *so, u_long cmd if (iap->ia_ifp == ifp && iap->ia_addr.sin_addr.s_addr == dst.s_addr) { if (td == NULL || prison_check_ip4( - td->td_ucred, &dst)) + td->td_ucred, &dst) == 0) ia = iap; break; } @@ -273,8 +273,8 @@ in_control(struct socket *so, u_long cmd iap = ifatoia(ifa); if (iap->ia_addr.sin_family == AF_INET) { if (td != NULL && - !prison_check_ip4(td->td_ucred, - &iap->ia_addr.sin_addr)) + prison_check_ip4(td->td_ucred, + &iap->ia_addr.sin_addr) != 0) continue; ia = iap; break; @@ -1199,8 +1199,7 @@ in_lltable_dump(struct lltable *llt, str if ((lle->la_flags & (LLE_DELETED|LLE_VALID)) != LLE_VALID) continue; /* Skip if jailed and not a valid IP of the prison. */ - if (jailed(wr->td->td_ucred) && - !prison_if(wr->td->td_ucred, L3_ADDR(lle))) + if (prison_if(wr->td->td_ucred, L3_ADDR(lle)) != 0) continue; /* * produce a msg made of: Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet/in_pcb.c Thu Feb 5 14:06:09 2009 (r188144) @@ -325,8 +325,9 @@ in_pcbbind_setup(struct inpcb *inp, stru if (sin->sin_family != AF_INET) return (EAFNOSUPPORT); #endif - if (prison_local_ip4(cred, &sin->sin_addr)) - return (EINVAL); + error = prison_local_ip4(cred, &sin->sin_addr); + if (error) + return (error); if (sin->sin_port != *lportp) { /* Don't allow the port to change. */ if (*lportp != 0) @@ -391,8 +392,9 @@ in_pcbbind_setup(struct inpcb *inp, stru t->inp_cred->cr_uid)) return (EADDRINUSE); } - if (prison_local_ip4(cred, &sin->sin_addr)) - return (EADDRNOTAVAIL); + error = prison_local_ip4(cred, &sin->sin_addr); + if (error) + return (error); t = in_pcblookup_local(pcbinfo, sin->sin_addr, lport, wild, cred); if (t && (t->inp_vflag & INP_TIMEWAIT)) { @@ -426,8 +428,9 @@ in_pcbbind_setup(struct inpcb *inp, stru u_short first, last, aux; int count; - if (prison_local_ip4(cred, &laddr)) - return (EINVAL); + error = prison_local_ip4(cred, &laddr); + if (error) + return (error); if (inp->inp_flags & INP_HIGHPORT) { first = V_ipport_hifirstauto; /* sysctl */ @@ -493,8 +496,9 @@ in_pcbbind_setup(struct inpcb *inp, stru } while (in_pcblookup_local(pcbinfo, laddr, lport, wild, cred)); } - if (prison_local_ip4(cred, &laddr)) - return (EINVAL); + error = prison_local_ip4(cred, &laddr); + if (error) + return (error); *laddrp = laddr.s_addr; *lportp = lport; return (0); @@ -614,7 +618,7 @@ in_pcbladdr(struct inpcb *inp, struct in if (sa->sa_family != AF_INET) continue; sin = (struct sockaddr_in *)sa; - if (prison_check_ip4(cred, &sin->sin_addr)) { + if (prison_check_ip4(cred, &sin->sin_addr) == 0) { ia = (struct in_ifaddr *)ifa; break; } @@ -625,8 +629,7 @@ in_pcbladdr(struct inpcb *inp, struct in } /* 3. As a last resort return the 'default' jail address. */ - if (prison_get_ip4(cred, laddr) != 0) - error = EADDRNOTAVAIL; + error = prison_get_ip4(cred, laddr); goto done; } @@ -651,7 +654,7 @@ in_pcbladdr(struct inpcb *inp, struct in /* Jailed. */ /* 1. Check if the iface address belongs to the jail. */ sin = (struct sockaddr_in *)sro.ro_rt->rt_ifa->ifa_addr; - if (prison_check_ip4(cred, &sin->sin_addr)) { + if (prison_check_ip4(cred, &sin->sin_addr) == 0) { ia = (struct in_ifaddr *)sro.ro_rt->rt_ifa; laddr->s_addr = ia->ia_addr.sin_addr.s_addr; goto done; @@ -667,7 +670,7 @@ in_pcbladdr(struct inpcb *inp, struct in if (sa->sa_family != AF_INET) continue; sin = (struct sockaddr_in *)sa; - if (prison_check_ip4(cred, &sin->sin_addr)) { + if (prison_check_ip4(cred, &sin->sin_addr) == 0) { ia = (struct in_ifaddr *)ifa; break; } @@ -678,8 +681,7 @@ in_pcbladdr(struct inpcb *inp, struct in } /* 3. As a last resort return the 'default' jail address. */ - if (prison_get_ip4(cred, laddr) != 0) - error = EADDRNOTAVAIL; + error = prison_get_ip4(cred, laddr); goto done; } @@ -729,7 +731,8 @@ in_pcbladdr(struct inpcb *inp, struct in if (sa->sa_family != AF_INET) continue; sin = (struct sockaddr_in *)sa; - if (prison_check_ip4(cred, &sin->sin_addr)) { + if (prison_check_ip4(cred, + &sin->sin_addr) == 0) { ia = (struct in_ifaddr *)ifa; break; } @@ -741,8 +744,7 @@ in_pcbladdr(struct inpcb *inp, struct in } /* 3. As a last resort return the 'default' jail address. */ - if (prison_get_ip4(cred, laddr) != 0) - error = EADDRNOTAVAIL; + error = prison_get_ip4(cred, laddr); goto done; } @@ -776,7 +778,7 @@ in_pcbconnect_setup(struct inpcb *inp, s struct sockaddr_in *sin = (struct sockaddr_in *)nam; struct in_ifaddr *ia; struct inpcb *oinp; - struct in_addr laddr, faddr, jailia; + struct in_addr laddr, faddr; u_short lport, fport; int error; @@ -809,15 +811,11 @@ in_pcbconnect_setup(struct inpcb *inp, s * choose the broadcast address for that interface. */ if (faddr.s_addr == INADDR_ANY) { - if (cred != NULL && jailed(cred)) { - if (prison_get_ip4(cred, &jailia) != 0) - return (EADDRNOTAVAIL); - faddr.s_addr = jailia.s_addr; - } else { - faddr = - IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))-> - sin_addr; - } + faddr = + IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr; + if (cred != NULL && + (error = prison_get_ip4(cred, &faddr)) != 0) + return (error); } else if (faddr.s_addr == (u_long)INADDR_BROADCAST && (TAILQ_FIRST(&V_in_ifaddrhead)->ia_ifp->if_flags & IFF_BROADCAST)) @@ -1375,7 +1373,8 @@ in_pcblookup_hash(struct inpcbinfo *pcbi injail = jailed(inp->inp_cred); if (injail) { - if (!prison_check_ip4(inp->inp_cred, &laddr)) + if (prison_check_ip4(inp->inp_cred, + &laddr) != 0) continue; } else { if (local_exact != NULL) Modified: head/sys/netinet/raw_ip.c ============================================================================== --- head/sys/netinet/raw_ip.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet/raw_ip.c Thu Feb 5 14:06:09 2009 (r188144) @@ -276,10 +276,8 @@ rip_input(struct mbuf *m, int off) continue; if (inp->inp_faddr.s_addr != ip->ip_src.s_addr) continue; - if (jailed(inp->inp_cred)) { - if (!prison_check_ip4(inp->inp_cred, &ip->ip_dst)) - continue; - } + if (prison_check_ip4(inp->inp_cred, &ip->ip_dst) != 0) + continue; if (last != NULL) { struct mbuf *n; @@ -306,10 +304,8 @@ rip_input(struct mbuf *m, int off) if (inp->inp_faddr.s_addr && inp->inp_faddr.s_addr != ip->ip_src.s_addr) continue; - if (jailed(inp->inp_cred)) { - if (!prison_check_ip4(inp->inp_cred, &ip->ip_dst)) - continue; - } + if (prison_check_ip4(inp->inp_cred, &ip->ip_dst) != 0) + continue; if (last != NULL) { struct mbuf *n; @@ -370,14 +366,12 @@ rip_output(struct mbuf *m, struct socket ip->ip_off = 0; ip->ip_p = inp->inp_ip_p; ip->ip_len = m->m_pkthdr.len; - if (jailed(inp->inp_cred)) { - if (prison_get_ip4(inp->inp_cred, &ip->ip_src) != 0) { - INP_RUNLOCK(inp); - m_freem(m); - return (EPERM); - } - } else { - ip->ip_src = inp->inp_laddr; + ip->ip_src = inp->inp_laddr; + error = prison_get_ip4(inp->inp_cred, &ip->ip_src); + if (error != 0) { + INP_RUNLOCK(inp); + m_freem(m); + return (error); } ip->ip_dst.s_addr = dst; ip->ip_ttl = inp->inp_ip_ttl; @@ -388,10 +382,11 @@ rip_output(struct mbuf *m, struct socket } INP_RLOCK(inp); ip = mtod(m, struct ip *); - if (!prison_check_ip4(inp->inp_cred, &ip->ip_src)) { + error = prison_check_ip4(inp->inp_cred, &ip->ip_src); + if (error != 0) { INP_RUNLOCK(inp); m_freem(m); - return (EPERM); + return (error); } /* @@ -803,12 +798,14 @@ rip_bind(struct socket *so, struct socka INIT_VNET_INET(so->so_vnet); struct sockaddr_in *addr = (struct sockaddr_in *)nam; struct inpcb *inp; + int error; if (nam->sa_len != sizeof(*addr)) return (EINVAL); - if (!prison_check_ip4(td->td_ucred, &addr->sin_addr)) - return (EADDRNOTAVAIL); + error = prison_check_ip4(td->td_ucred, &addr->sin_addr); + if (error != 0) + return (error); if (TAILQ_EMPTY(&V_ifnet) || (addr->sin_family != AF_INET && addr->sin_family != AF_IMPLINK) || Modified: head/sys/netinet/tcp_usrreq.c ============================================================================== --- head/sys/netinet/tcp_usrreq.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet/tcp_usrreq.c Thu Feb 5 14:06:09 2009 (r188144) @@ -441,8 +441,8 @@ tcp_usr_connect(struct socket *so, struc if (sinp->sin_family == AF_INET && IN_MULTICAST(ntohl(sinp->sin_addr.s_addr))) return (EAFNOSUPPORT); - if (prison_remote_ip4(td->td_ucred, &sinp->sin_addr) != 0) - return (EINVAL); + if ((error = prison_remote_ip4(td->td_ucred, &sinp->sin_addr)) != 0) + return (error); TCPDEBUG0; INP_INFO_WLOCK(&V_tcbinfo); @@ -508,10 +508,9 @@ tcp6_usr_connect(struct socket *so, stru in6_sin6_2_sin(&sin, sin6p); inp->inp_vflag |= INP_IPV4; inp->inp_vflag &= ~INP_IPV6; - if (prison_remote_ip4(td->td_ucred, &sin.sin_addr) != 0) { - error = EINVAL; + if ((error = prison_remote_ip4(td->td_ucred, + &sin.sin_addr)) != 0) goto out; - } if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0) goto out; error = tcp_output_connect(so, nam); @@ -520,10 +519,8 @@ tcp6_usr_connect(struct socket *so, stru inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; inp->inp_inc.inc_flags |= INC_ISIPV6; - if (prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr) != 0) { - error = EINVAL; + if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0) goto out; - } if ((error = tcp6_connect(tp, nam, td)) != 0) goto out; error = tcp_output_connect(so, nam); Modified: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet/udp_usrreq.c Thu Feb 5 14:06:09 2009 (r188144) @@ -982,10 +982,9 @@ udp_output(struct inpcb *inp, struct mbu * Jail may rewrite the destination address, so let it do * that before we use it. */ - if (prison_remote_ip4(td->td_ucred, &sin->sin_addr) != 0) { - error = EINVAL; + error = prison_remote_ip4(td->td_ucred, &sin->sin_addr); + if (error) goto release; - } /* * If a local address or port hasn't yet been selected, or if @@ -1271,10 +1270,11 @@ udp_connect(struct socket *so, struct so return (EISCONN); } sin = (struct sockaddr_in *)nam; - if (prison_remote_ip4(td->td_ucred, &sin->sin_addr) != 0) { + error = prison_remote_ip4(td->td_ucred, &sin->sin_addr); + if (error != 0) { INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_udbinfo); - return (EAFNOSUPPORT); + return (error); } error = in_pcbconnect(inp, nam, td->td_ucred); if (error == 0) Modified: head/sys/netinet6/in6.c ============================================================================== --- head/sys/netinet6/in6.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet6/in6.c Thu Feb 5 14:06:09 2009 (r188144) @@ -330,9 +330,9 @@ in6_control(struct socket *so, u_long cm error = in6_setscope(&sa6->sin6_addr, ifp, NULL); if (error != 0) return (error); - if (td != NULL && !prison_check_ip6(td->td_ucred, - &sa6->sin6_addr)) - return (EADDRNOTAVAIL); + if (td != NULL && (error = prison_check_ip6(td->td_ucred, + &sa6->sin6_addr)) != 0) + return (error); ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr); } else ia = NULL; @@ -2241,8 +2241,7 @@ in6_lltable_dump(struct lltable *llt, st if ((lle->la_flags & (LLE_DELETED|LLE_VALID)) != LLE_VALID) continue; /* Skip if jailed and not a valid IP of the prison. */ - if (jailed(wr->td->td_ucred) && - !prison_if(wr->td->td_ucred, L3_ADDR(lle))) + if (prison_if(wr->td->td_ucred, L3_ADDR(lle)) != 0) continue; /* * produce a msg made of: Modified: head/sys/netinet6/in6_pcb.c ============================================================================== --- head/sys/netinet6/in6_pcb.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet6/in6_pcb.c Thu Feb 5 14:06:09 2009 (r188144) @@ -119,7 +119,7 @@ in6_pcbbind(register struct inpcb *inp, struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)NULL; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; u_short lport = 0; - int wild = 0, reuseport = (so->so_options & SO_REUSEPORT); + int error, wild = 0, reuseport = (so->so_options & SO_REUSEPORT); INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); @@ -131,8 +131,6 @@ in6_pcbbind(register struct inpcb *inp, if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) wild = INPLOOKUP_WILDCARD; if (nam) { - int error; - sin6 = (struct sockaddr_in6 *)nam; if (nam->sa_len != sizeof(*sin6)) return (EINVAL); @@ -145,9 +143,9 @@ in6_pcbbind(register struct inpcb *inp, if ((error = sa6_embedscope(sin6, V_ip6_use_defzone)) != 0) return(error); - if (prison_local_ip6(cred, &sin6->sin6_addr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) - return (EINVAL); + if ((error = prison_local_ip6(cred, &sin6->sin6_addr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) + return (error); lport = sin6->sin6_port; if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { @@ -223,9 +221,9 @@ in6_pcbbind(register struct inpcb *inp, return (EADDRINUSE); } } - if (prison_local_ip6(cred, &sin6->sin6_addr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) - return (EADDRNOTAVAIL); + if ((error = prison_local_ip6(cred, &sin6->sin6_addr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) + return (error); t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, lport, wild, cred); if (t && (reuseport & ((t->inp_vflag & INP_TIMEWAIT) ? @@ -258,13 +256,12 @@ in6_pcbbind(register struct inpcb *inp, } inp->in6p_laddr = sin6->sin6_addr; } - if (prison_local_ip6(cred, &inp->in6p_laddr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) - return (EINVAL); + if ((error = prison_local_ip6(cred, &inp->in6p_laddr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) + return (error); if (lport == 0) { - int e; - if ((e = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) - return (e); + if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) + return (error); } else { inp->inp_lport = lport; if (in_pcbinshash(inp) != 0) { @@ -320,8 +317,8 @@ in6_pcbladdr(register struct inpcb *inp, if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) sin6->sin6_addr = in6addr_loopback; } - if (prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr) != 0) - return (EADDRNOTAVAIL); + if ((error = prison_remote_ip6(inp->inp_cred, &sin6->sin6_addr)) != 0) + return (error); /* * XXX: in6_selectsrc might replace the bound local address @@ -885,7 +882,8 @@ in6_pcblookup_hash(struct inpcbinfo *pcb injail = jailed(inp->inp_cred); if (injail) { - if (!prison_check_ip6(inp->inp_cred, laddr)) + if (prison_check_ip6(inp->inp_cred, + laddr) != 0) continue; } else { if (local_exact != NULL) Modified: head/sys/netinet6/in6_src.c ============================================================================== --- head/sys/netinet6/in6_src.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet6/in6_src.c Thu Feb 5 14:06:09 2009 (r188144) @@ -240,11 +240,10 @@ in6_selectsrc(struct sockaddr_in6 *dstso if (*errorp != 0) return (NULL); } - if (cred != NULL && prison_local_ip6(cred, &srcsock.sin6_addr, - (inp != NULL && (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) { - *errorp = EADDRNOTAVAIL; + if (cred != NULL && (*errorp = prison_local_ip6(cred, + &srcsock.sin6_addr, (inp != NULL && + (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) return (NULL); - } ia6 = (struct in6_ifaddr *)ifa_ifwithaddr((struct sockaddr *)(&srcsock)); if (ia6 == NULL || @@ -262,11 +261,10 @@ in6_selectsrc(struct sockaddr_in6 *dstso * Otherwise, if the socket has already bound the source, just use it. */ if (inp != NULL && !IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) { - if (cred != NULL && prison_local_ip6(cred, &inp->in6p_laddr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) { - *errorp = EADDRNOTAVAIL; + if (cred != NULL && + (*errorp = prison_local_ip6(cred, &inp->in6p_laddr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) return (NULL); - } return (&inp->in6p_laddr); } @@ -823,15 +821,16 @@ in6_pcbsetport(struct in6_addr *laddr, s INIT_VNET_INET(curvnet); struct socket *so = inp->inp_socket; u_int16_t lport = 0, first, last, *lastport; - int count, error = 0, wild = 0, dorandom; + int count, error, wild = 0, dorandom; struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); - if (prison_local_ip6(cred, laddr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)) != 0) - return(EINVAL); + error = prison_local_ip6(cred, laddr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0)); + if (error) + return(error); /* XXX: this is redundant when called from in6_pcbbind */ if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) Modified: head/sys/netinet6/raw_ip6.c ============================================================================== --- head/sys/netinet6/raw_ip6.c Thu Feb 5 14:02:04 2009 (r188143) +++ head/sys/netinet6/raw_ip6.c Thu Feb 5 14:06:09 2009 (r188144) @@ -179,10 +179,8 @@ rip6_input(struct mbuf **mp, int *offp, if (!IN6_IS_ADDR_UNSPECIFIED(&in6p->in6p_faddr) && !IN6_ARE_ADDR_EQUAL(&in6p->in6p_faddr, &ip6->ip6_src)) continue; - if (jailed(in6p->inp_cred)) { - if (!prison_check_ip6(in6p->inp_cred, &ip6->ip6_dst)) - continue; - } + if (prison_check_ip6(in6p->inp_cred, &ip6->ip6_dst) != 0) + continue; INP_RLOCK(in6p); if (in6p->in6p_cksum != -1) { V_rip6stat.rip6s_isum++; @@ -411,11 +409,9 @@ rip6_output(m, va_alist) error = EADDRNOTAVAIL; goto bad; } - if (jailed(in6p->inp_cred)) - if (prison_get_ip6(in6p->inp_cred, in6a) != 0) { - error = EPERM; - goto bad; - } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From jamie at FreeBSD.org Thu Feb 5 06:15:19 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Thu Feb 5 06:15:32 2009 Subject: svn commit: r188146 - in head/sys: kern sys Message-ID: <200902051415.n15EFIMY029070@svn.freebsd.org> Author: jamie Date: Thu Feb 5 14:15:18 2009 New Revision: 188146 URL: http://svn.freebsd.org/changeset/base/188146 Log: Don't allow creating a socket with a protocol family that the current jail doesn't support. This involves a new function prison_check_af, like prison_check_ip[46] but that checks only the family. With this change, most of the errors generated by jailed sockets shouldn't ever occur, at least until jails are changeable. Approved by: bz (mentor) Modified: head/sys/kern/kern_jail.c head/sys/kern/uipc_socket.c head/sys/sys/jail.h Modified: head/sys/kern/kern_jail.c ============================================================================== --- head/sys/kern/kern_jail.c Thu Feb 5 14:06:43 2009 (r188145) +++ head/sys/kern/kern_jail.c Thu Feb 5 14:15:18 2009 (r188146) @@ -1099,6 +1099,48 @@ prison_check_ip6(struct ucred *cred, str #endif /* + * Check if a jail supports the given address family. + * + * Returns 0 if not jailed or the address family is supported, EAFNOSUPPORT + * if not. + */ +int +prison_check_af(struct ucred *cred, int af) +{ + int error; + + KASSERT(cred != NULL, ("%s: cred is NULL", __func__)); + + + if (!jailed(cred)) + return (0); + + error = 0; + switch (af) + { +#ifdef INET + case AF_INET: + if (cred->cr_prison->pr_ip4 == NULL) + error = EAFNOSUPPORT; + break; +#endif +#ifdef INET6 + case AF_INET6: + if (cred->cr_prison->pr_ip6 == NULL) + error = EAFNOSUPPORT; + break; +#endif + case AF_LOCAL: + case AF_ROUTE: + break; + default: + if (jail_socket_unixiproute_only) + error = EAFNOSUPPORT; + } + return (error); +} + +/* * Check if given address belongs to the jail referenced by cred (wrapper to * prison_check_ip[46]). * Modified: head/sys/kern/uipc_socket.c ============================================================================== --- head/sys/kern/uipc_socket.c Thu Feb 5 14:06:43 2009 (r188145) +++ head/sys/kern/uipc_socket.c Thu Feb 5 14:15:18 2009 (r188146) @@ -347,15 +347,8 @@ socreate(int dom, struct socket **aso, i prp->pr_usrreqs->pru_attach == pru_attach_notsupp) return (EPROTONOSUPPORT); - if (jailed(cred) && jail_socket_unixiproute_only && - prp->pr_domain->dom_family != PF_LOCAL && - prp->pr_domain->dom_family != PF_INET && -#ifdef INET6 - prp->pr_domain->dom_family != PF_INET6 && -#endif - prp->pr_domain->dom_family != PF_ROUTE) { + if (prison_check_af(cred, prp->pr_domain->dom_family) != 0) return (EPROTONOSUPPORT); - } if (prp->pr_type != type) return (EPROTOTYPE); Modified: head/sys/sys/jail.h ============================================================================== --- head/sys/sys/jail.h Thu Feb 5 14:06:43 2009 (r188145) +++ head/sys/sys/jail.h Thu Feb 5 14:15:18 2009 (r188146) @@ -191,6 +191,7 @@ int prison_local_ip6(struct ucred *, str int prison_remote_ip6(struct ucred *, struct in6_addr *); int prison_check_ip6(struct ucred *, struct in6_addr *); #endif +int prison_check_af(struct ucred *cred, int af); int prison_if(struct ucred *cred, struct sockaddr *sa); int prison_priv_check(struct ucred *cred, int priv); From ed at FreeBSD.org Thu Feb 5 06:21:11 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Thu Feb 5 06:21:23 2009 Subject: svn commit: r188147 - in head: sys/kern sys/sys usr.sbin/pstat Message-ID: <200902051421.n15EL9mp029230@svn.freebsd.org> Author: ed Date: Thu Feb 5 14:21:09 2009 New Revision: 188147 URL: http://svn.freebsd.org/changeset/base/188147 Log: Don't leave the console TTY constantly open. When we leave the console TTY constantly open, we never reset the termios attributes. This causes output processing, echoing, etc. not to be reset to the proper values when going into single user mode after the system has booted. It also causes nl-to-crnl-conversion not to take place during shutdown, which causes a `staircase effect'. This patch adds a new TTY flag, TF_OPENED_CONS, which is set when the TTY is opened through /dev/console. Because the flags are only used by the kernel and the pstat(8) utility, I've decided to renumber the TTY flags. This shouldn't be an issue, because the TTY layer is not yet part of a stable release. Reported by: Mark Atkinson Tested by: sepotvin Modified: head/sys/kern/tty.c head/sys/sys/tty.h head/usr.sbin/pstat/pstat.8 head/usr.sbin/pstat/pstat.c Modified: head/sys/kern/tty.c ============================================================================== --- head/sys/kern/tty.c Thu Feb 5 14:15:18 2009 (r188146) +++ head/sys/kern/tty.c Thu Feb 5 14:21:09 2009 (r188147) @@ -291,11 +291,12 @@ ttydev_open(struct cdev *dev, int oflags } } - if (TTY_CALLOUT(tp, dev)) { + if (dev == dev_console) + tp->t_flags |= TF_OPENED_CONS; + else if (TTY_CALLOUT(tp, dev)) tp->t_flags |= TF_OPENED_OUT; - } else { + else tp->t_flags |= TF_OPENED_IN; - } done: tp->t_flags &= ~TF_OPENCLOSE; ttydev_leave(tp); @@ -308,22 +309,28 @@ ttydev_close(struct cdev *dev, int fflag { struct tty *tp = dev->si_drv1; + tty_lock(tp); + /* * Don't actually close the device if it is being used as the * console. */ - if (dev_console_filename != NULL && - strcmp(dev_console_filename, tty_devname(tp)) == 0) - return (0); + MPASS((tp->t_flags & TF_OPENED) != TF_OPENED); + if (dev == dev_console) + tp->t_flags &= ~TF_OPENED_CONS; + else + tp->t_flags &= ~(TF_OPENED_IN|TF_OPENED_OUT); - tty_lock(tp); + if (tp->t_flags & TF_OPENED) { + tty_unlock(tp); + return (0); + } /* * This can only be called once. The callin and the callout * devices cannot be opened at the same time. */ - MPASS((tp->t_flags & TF_OPENED) != TF_OPENED); - tp->t_flags &= ~(TF_OPENED|TF_EXCLUDE|TF_STOPPED); + tp->t_flags &= ~(TF_EXCLUDE|TF_STOPPED); /* Properly wake up threads that are stuck - revoke(). */ tp->t_revokecnt++; @@ -1797,13 +1804,14 @@ ttyconsdev_write(struct cdev *dev, struc } /* - * /dev/console is a little different than normal TTY's. Unlike regular - * TTY device nodes, this device node will not revoke the entire TTY - * upon closure and all data written to it will be logged. + * /dev/console is a little different than normal TTY's. When opened, + * it determines which TTY to use. When data gets written to it, it + * will be logged in the kernel message buffer. */ static struct cdevsw ttyconsdev_cdevsw = { .d_version = D_VERSION, .d_open = ttyconsdev_open, + .d_close = ttydev_close, .d_read = ttydev_read, .d_write = ttyconsdev_write, .d_ioctl = ttydev_ioctl, @@ -1845,33 +1853,34 @@ static struct { char val; } ttystates[] = { #if 0 - { TF_NOPREFIX, 'N' }, + { TF_NOPREFIX, 'N' }, #endif - { TF_INITLOCK, 'I' }, - { TF_CALLOUT, 'C' }, + { TF_INITLOCK, 'I' }, + { TF_CALLOUT, 'C' }, /* Keep these together -> 'Oi' and 'Oo'. */ - { TF_OPENED, 'O' }, - { TF_OPENED_IN, 'i' }, - { TF_OPENED_OUT,'o' }, - - { TF_GONE, 'G' }, - { TF_OPENCLOSE, 'B' }, - { TF_ASYNC, 'Y' }, - { TF_LITERAL, 'L' }, + { TF_OPENED, 'O' }, + { TF_OPENED_IN, 'i' }, + { TF_OPENED_OUT, 'o' }, + { TF_OPENED_CONS, 'c' }, + + { TF_GONE, 'G' }, + { TF_OPENCLOSE, 'B' }, + { TF_ASYNC, 'Y' }, + { TF_LITERAL, 'L' }, /* Keep these together -> 'Hi' and 'Ho'. */ - { TF_HIWAT, 'H' }, - { TF_HIWAT_IN, 'i' }, - { TF_HIWAT_OUT, 'o' }, - - { TF_STOPPED, 'S' }, - { TF_EXCLUDE, 'X' }, - { TF_BYPASS, 'l' }, - { TF_ZOMBIE, 'Z' }, - { TF_HOOK, 's' }, + { TF_HIWAT, 'H' }, + { TF_HIWAT_IN, 'i' }, + { TF_HIWAT_OUT, 'o' }, + + { TF_STOPPED, 'S' }, + { TF_EXCLUDE, 'X' }, + { TF_BYPASS, 'l' }, + { TF_ZOMBIE, 'Z' }, + { TF_HOOK, 's' }, - { 0, '\0' }, + { 0, '\0'}, }; #define TTY_FLAG_BITS \ Modified: head/sys/sys/tty.h ============================================================================== --- head/sys/sys/tty.h Thu Feb 5 14:15:18 2009 (r188146) +++ head/sys/sys/tty.h Thu Feb 5 14:21:09 2009 (r188147) @@ -64,24 +64,25 @@ struct tty { TAILQ_ENTRY(tty) t_list; /* (l) TTY list entry. */ unsigned int t_flags; /* (t) Terminal option flags. */ /* Keep flags in sync with db_show_tty and pstat(8). */ -#define TF_NOPREFIX 0x0001 /* Don't prepend "tty" to device name. */ -#define TF_INITLOCK 0x0002 /* Create init/lock state devices. */ -#define TF_CALLOUT 0x0004 /* Create "cua" devices. */ -#define TF_OPENED_IN 0x0008 /* "tty" node is in use. */ -#define TF_OPENED_OUT 0x0010 /* "cua" node is in use. */ -#define TF_OPENED (TF_OPENED_IN|TF_OPENED_OUT) -#define TF_GONE 0x0020 /* Device node is gone. */ -#define TF_OPENCLOSE 0x0040 /* Device is in open()/close(). */ -#define TF_ASYNC 0x0080 /* Asynchronous I/O enabled. */ -#define TF_LITERAL 0x0100 /* Accept the next character literally. */ -#define TF_HIWAT_IN 0x0200 /* We've reached the input watermark. */ -#define TF_HIWAT_OUT 0x0400 /* We've reached the output watermark. */ +#define TF_NOPREFIX 0x00001 /* Don't prepend "tty" to device name. */ +#define TF_INITLOCK 0x00002 /* Create init/lock state devices. */ +#define TF_CALLOUT 0x00004 /* Create "cua" devices. */ +#define TF_OPENED_IN 0x00008 /* "tty" node is in use. */ +#define TF_OPENED_OUT 0x00010 /* "cua" node is in use. */ +#define TF_OPENED_CONS 0x00020 /* Device in use as console. */ +#define TF_OPENED (TF_OPENED_IN|TF_OPENED_OUT|TF_OPENED_CONS) +#define TF_GONE 0x00040 /* Device node is gone. */ +#define TF_OPENCLOSE 0x00080 /* Device is in open()/close(). */ +#define TF_ASYNC 0x00100 /* Asynchronous I/O enabled. */ +#define TF_LITERAL 0x00200 /* Accept the next character literally. */ +#define TF_HIWAT_IN 0x00400 /* We've reached the input watermark. */ +#define TF_HIWAT_OUT 0x00800 /* We've reached the output watermark. */ #define TF_HIWAT (TF_HIWAT_IN|TF_HIWAT_OUT) -#define TF_STOPPED 0x0800 /* Output flow control - stopped. */ -#define TF_EXCLUDE 0x1000 /* Exclusive access. */ -#define TF_BYPASS 0x2000 /* Optimized input path. */ -#define TF_ZOMBIE 0x4000 /* Modem disconnect received. */ -#define TF_HOOK 0x8000 /* TTY has hook attached. */ +#define TF_STOPPED 0x01000 /* Output flow control - stopped. */ +#define TF_EXCLUDE 0x02000 /* Exclusive access. */ +#define TF_BYPASS 0x04000 /* Optimized input path. */ +#define TF_ZOMBIE 0x08000 /* Modem disconnect received. */ +#define TF_HOOK 0x10000 /* TTY has hook attached. */ unsigned int t_revokecnt; /* (t) revoke() count. */ /* Buffering mechanisms. */ Modified: head/usr.sbin/pstat/pstat.8 ============================================================================== --- head/usr.sbin/pstat/pstat.8 Thu Feb 5 14:15:18 2009 (r188146) +++ head/usr.sbin/pstat/pstat.8 Thu Feb 5 14:21:09 2009 (r188147) @@ -183,6 +183,8 @@ init/lock-state device nodes present callout device nodes present .It O opened +.It c +console in use .It G gone .It B Modified: head/usr.sbin/pstat/pstat.c ============================================================================== --- head/usr.sbin/pstat/pstat.c Thu Feb 5 14:15:18 2009 (r188146) +++ head/usr.sbin/pstat/pstat.c Thu Feb 5 14:21:09 2009 (r188147) @@ -288,33 +288,34 @@ static struct { char val; } ttystates[] = { #if 0 - { TF_NOPREFIX, 'N' }, + { TF_NOPREFIX, 'N' }, #endif - { TF_INITLOCK, 'I' }, - { TF_CALLOUT, 'C' }, + { TF_INITLOCK, 'I' }, + { TF_CALLOUT, 'C' }, /* Keep these together -> 'Oi' and 'Oo'. */ - { TF_OPENED, 'O' }, - { TF_OPENED_IN, 'i' }, - { TF_OPENED_OUT,'o' }, - - { TF_GONE, 'G' }, - { TF_OPENCLOSE, 'B' }, - { TF_ASYNC, 'Y' }, - { TF_LITERAL, 'L' }, + { TF_OPENED, 'O' }, + { TF_OPENED_IN, 'i' }, + { TF_OPENED_OUT, 'o' }, + { TF_OPENED_CONS, 'c' }, + + { TF_GONE, 'G' }, + { TF_OPENCLOSE, 'B' }, + { TF_ASYNC, 'Y' }, + { TF_LITERAL, 'L' }, /* Keep these together -> 'Hi' and 'Ho'. */ - { TF_HIWAT, 'H' }, - { TF_HIWAT_IN, 'i' }, - { TF_HIWAT_OUT, 'o' }, - - { TF_STOPPED, 'S' }, - { TF_EXCLUDE, 'X' }, - { TF_BYPASS, 'l' }, - { TF_ZOMBIE, 'Z' }, - { TF_HOOK, 's' }, + { TF_HIWAT, 'H' }, + { TF_HIWAT_IN, 'i' }, + { TF_HIWAT_OUT, 'o' }, + + { TF_STOPPED, 'S' }, + { TF_EXCLUDE, 'X' }, + { TF_BYPASS, 'l' }, + { TF_ZOMBIE, 'Z' }, + { TF_HOOK, 's' }, - { 0, '\0' }, + { 0, '\0'}, }; static void From jamie at FreeBSD.org Thu Feb 5 06:25:54 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Thu Feb 5 06:26:06 2009 Subject: svn commit: r188148 - in head/sys: netinet netinet6 Message-ID: <200902051425.n15EPsrY029368@svn.freebsd.org> Author: jamie Date: Thu Feb 5 14:25:53 2009 New Revision: 188148 URL: http://svn.freebsd.org/changeset/base/188148 Log: Remove redundant calls of prison_local_ip4 in in_pcbbind_setup, and of prison_local_ip6 in in6_pcbbind. Approved by: bz (mentor) Modified: head/sys/netinet/in_pcb.c head/sys/netinet6/in6_pcb.c Modified: head/sys/netinet/in_pcb.c ============================================================================== --- head/sys/netinet/in_pcb.c Thu Feb 5 14:21:09 2009 (r188147) +++ head/sys/netinet/in_pcb.c Thu Feb 5 14:25:53 2009 (r188148) @@ -313,7 +313,10 @@ in_pcbbind_setup(struct inpcb *inp, stru return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) wild = INPLOOKUP_WILDCARD; - if (nam) { + if (nam == NULL) { + if ((error = prison_local_ip4(cred, &laddr)) != 0) + return (error); + } else { sin = (struct sockaddr_in *)nam; if (nam->sa_len != sizeof (*sin)) return (EINVAL); @@ -392,9 +395,6 @@ in_pcbbind_setup(struct inpcb *inp, stru t->inp_cred->cr_uid)) return (EADDRINUSE); } - error = prison_local_ip4(cred, &sin->sin_addr); - if (error) - return (error); t = in_pcblookup_local(pcbinfo, sin->sin_addr, lport, wild, cred); if (t && (t->inp_vflag & INP_TIMEWAIT)) { @@ -428,10 +428,6 @@ in_pcbbind_setup(struct inpcb *inp, stru u_short first, last, aux; int count; - error = prison_local_ip4(cred, &laddr); - if (error) - return (error); - if (inp->inp_flags & INP_HIGHPORT) { first = V_ipport_hifirstauto; /* sysctl */ last = V_ipport_hilastauto; @@ -496,9 +492,6 @@ in_pcbbind_setup(struct inpcb *inp, stru } while (in_pcblookup_local(pcbinfo, laddr, lport, wild, cred)); } - error = prison_local_ip4(cred, &laddr); - if (error) - return (error); *laddrp = laddr.s_addr; *lportp = lport; return (0); Modified: head/sys/netinet6/in6_pcb.c ============================================================================== --- head/sys/netinet6/in6_pcb.c Thu Feb 5 14:21:09 2009 (r188147) +++ head/sys/netinet6/in6_pcb.c Thu Feb 5 14:25:53 2009 (r188148) @@ -130,7 +130,11 @@ in6_pcbbind(register struct inpcb *inp, return (EINVAL); if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT)) == 0) wild = INPLOOKUP_WILDCARD; - if (nam) { + if (nam == NULL) { + if ((error = prison_local_ip6(cred, &inp->in6p_laddr, + ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) + return (error); + } else { sin6 = (struct sockaddr_in6 *)nam; if (nam->sa_len != sizeof(*sin6)) return (EINVAL); @@ -221,9 +225,6 @@ in6_pcbbind(register struct inpcb *inp, return (EADDRINUSE); } } - if ((error = prison_local_ip6(cred, &sin6->sin6_addr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) - return (error); t = in6_pcblookup_local(pcbinfo, &sin6->sin6_addr, lport, wild, cred); if (t && (reuseport & ((t->inp_vflag & INP_TIMEWAIT) ? @@ -256,9 +257,6 @@ in6_pcbbind(register struct inpcb *inp, } inp->in6p_laddr = sin6->sin6_addr; } - if ((error = prison_local_ip6(cred, &inp->in6p_laddr, - ((inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) - return (error); if (lport == 0) { if ((error = in6_pcbsetport(&inp->in6p_laddr, inp, cred)) != 0) return (error); From jamie at FreeBSD.org Thu Feb 5 06:58:17 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Thu Feb 5 06:58:29 2009 Subject: svn commit: r188149 - head/sys/net Message-ID: <200902051458.n15EwGIE029995@svn.freebsd.org> Author: jamie Date: Thu Feb 5 14:58:16 2009 New Revision: 188149 URL: http://svn.freebsd.org/changeset/base/188149 Log: Call prison_if from rtm_get_jailed, instead of splitting it out into prison_check_ip4 and prison_check_ip6. As prison_if includes a jailed() check, remove that check before calling rtm_get_jailed. Approved by: bz (mentor) Modified: head/sys/net/rtsock.c Modified: head/sys/net/rtsock.c ============================================================================== --- head/sys/net/rtsock.c Thu Feb 5 14:25:53 2009 (r188148) +++ head/sys/net/rtsock.c Thu Feb 5 14:58:16 2009 (r188149) @@ -337,55 +337,48 @@ rtm_get_jailed(struct rt_addrinfo *info, struct rtentry *rt, union sockaddr_union *saun, struct ucred *cred) { + /* First, see if the returned address is part of the jail. */ + if (prison_if(cred, rt->rt_ifa->ifa_addr) == 0) { + info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; + return (0); + } + switch (info->rti_info[RTAX_DST]->sa_family) { #ifdef INET case AF_INET: { struct in_addr ia; + struct ifaddr *ifa; + int found; + found = 0; /* - * 1. Check if the returned address is part of the jail. + * Try to find an address on the given outgoing interface + * that belongs to the jail. */ - ia = ((struct sockaddr_in *)rt->rt_ifa->ifa_addr)->sin_addr; - if (prison_check_ip4(cred, &ia) == 0) { - info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; - - } else { - struct ifaddr *ifa; - int found; - - found = 0; - + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + struct sockaddr *sa; + sa = ifa->ifa_addr; + if (sa->sa_family != AF_INET) + continue; + ia = ((struct sockaddr_in *)sa)->sin_addr; + if (prison_check_ip4(cred, &ia) == 0) { + found = 1; + break; + } + } + if (!found) { /* - * 2. Try to find an address on the given outgoing - * interface that belongs to the jail. + * As a last resort return the 'default' jail address. */ - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - struct sockaddr *sa; - sa = ifa->ifa_addr; - if (sa->sa_family != AF_INET) - continue; - ia = ((struct sockaddr_in *)sa)->sin_addr; - if (prison_check_ip4(cred, &ia) == 0) { - found = 1; - break; - } - } - if (!found) { - /* - * 3. As a last resort return the 'default' - * jail address. - */ - if (prison_get_ip4(cred, &ia) != 0) - return (ESRCH); - } - bzero(&saun->sin, sizeof(struct sockaddr_in)); - saun->sin.sin_len = sizeof(struct sockaddr_in); - saun->sin.sin_family = AF_INET; - saun->sin.sin_addr.s_addr = ia.s_addr; - info->rti_info[RTAX_IFA] = - (struct sockaddr *)&saun->sin; + if (prison_get_ip4(cred, &ia) != 0) + return (ESRCH); } + bzero(&saun->sin, sizeof(struct sockaddr_in)); + saun->sin.sin_len = sizeof(struct sockaddr_in); + saun->sin.sin_family = AF_INET; + saun->sin.sin_addr.s_addr = ia.s_addr; + info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin; break; } #endif @@ -393,54 +386,40 @@ rtm_get_jailed(struct rt_addrinfo *info, case AF_INET6: { struct in6_addr ia6; + struct ifaddr *ifa; + int found; + found = 0; /* - * 1. Check if the returned address is part of the jail. + * Try to find an address on the given outgoing interface + * that belongs to the jail. */ - bcopy(&((struct sockaddr_in6 *)rt->rt_ifa->ifa_addr)->sin6_addr, - &ia6, sizeof(struct in6_addr)); - if (prison_check_ip6(cred, &ia6) == 0) { - info->rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; - } else { - struct ifaddr *ifa; - int found; - - found = 0; - + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { + struct sockaddr *sa; + sa = ifa->ifa_addr; + if (sa->sa_family != AF_INET6) + continue; + bcopy(&((struct sockaddr_in6 *)sa)->sin6_addr, + &ia6, sizeof(struct in6_addr)); + if (prison_check_ip6(cred, &ia6) == 0) { + found = 1; + break; + } + } + if (!found) { /* - * 2. Try to find an address on the given outgoing - * interface that belongs to the jail. + * As a last resort return the 'default' jail address. */ - TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { - struct sockaddr *sa; - sa = ifa->ifa_addr; - if (sa->sa_family != AF_INET6) - continue; - bcopy(&((struct sockaddr_in6 *)sa)->sin6_addr, - &ia6, sizeof(struct in6_addr)); - if (prison_check_ip6(cred, &ia6) == 0) { - found = 1; - break; - } - } - if (!found) { - /* - * 3. As a last resort return the 'default' - * jail address. - */ - if (prison_get_ip6(cred, &ia6) != 0) - return (ESRCH); - } - bzero(&saun->sin6, sizeof(struct sockaddr_in6)); - saun->sin6.sin6_len = sizeof(struct sockaddr_in6); - saun->sin6.sin6_family = AF_INET6; - bcopy(&ia6, &saun->sin6.sin6_addr, - sizeof(struct in6_addr)); - if (sa6_recoverscope(&saun->sin6) != 0) + if (prison_get_ip6(cred, &ia6) != 0) return (ESRCH); - info->rti_info[RTAX_IFA] = - (struct sockaddr *)&saun->sin6; } + bzero(&saun->sin6, sizeof(struct sockaddr_in6)); + saun->sin6.sin6_len = sizeof(struct sockaddr_in6); + saun->sin6.sin6_family = AF_INET6; + bcopy(&ia6, &saun->sin6.sin6_addr, sizeof(struct in6_addr)); + if (sa6_recoverscope(&saun->sin6) != 0) + return (ESRCH); + info->rti_info[RTAX_IFA] = (struct sockaddr *)&saun->sin6; break; } #endif @@ -628,17 +607,11 @@ route_output(struct mbuf *m, struct sock if (ifp) { info.rti_info[RTAX_IFP] = ifp->if_addr->ifa_addr; - if (jailed(curthread->td_ucred)) { - error = rtm_get_jailed( - &info, ifp, rt, &saun, - curthread->td_ucred); - if (error != 0) { - RT_UNLOCK(rt); - senderr(ESRCH); - } - } else { - info.rti_info[RTAX_IFA] = - rt->rt_ifa->ifa_addr; + error = rtm_get_jailed(&info, ifp, rt, + &saun, curthread->td_ucred); + if (error != 0) { + RT_UNLOCK(rt); + senderr(error); } if (ifp->if_flags & IFF_POINTOPOINT) info.rti_info[RTAX_BRD] = From attilio at FreeBSD.org Thu Feb 5 07:03:36 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Thu Feb 5 07:03:43 2009 Subject: svn commit: r188150 - head/sys/kern Message-ID: <200902051503.n15F3ZZg030151@svn.freebsd.org> Author: attilio Date: Thu Feb 5 15:03:35 2009 New Revision: 188150 URL: http://svn.freebsd.org/changeset/base/188150 Log: Add more KTR_VFS logging point in order to have a more effective tracing. Reviewed by: brueffer, kib Tested by: Gianni Trematerra Modified: head/sys/kern/vfs_mount.c head/sys/kern/vfs_subr.c Modified: head/sys/kern/vfs_mount.c ============================================================================== --- head/sys/kern/vfs_mount.c Thu Feb 5 14:58:16 2009 (r188149) +++ head/sys/kern/vfs_mount.c Thu Feb 5 15:03:35 2009 (r188150) @@ -386,6 +386,8 @@ nmount(td, uap) u_int iovcnt; AUDIT_ARG(fflags, uap->flags); + CTR4(KTR_VFS, "%s: iovp %p with iovcnt %d and flags %d", __func__, + uap->iovp, uap->iovcnt, uap->flags); /* * Filter out MNT_ROOTFS. We do not want clients of nmount() in @@ -400,16 +402,24 @@ nmount(td, uap) * Check that we have an even number of iovec's * and that we have at least two options. */ - if ((iovcnt & 1) || (iovcnt < 4)) + if ((iovcnt & 1) || (iovcnt < 4)) { + CTR2(KTR_VFS, "%s: failed for invalid iovcnt %d", __func__, + uap->iovcnt); return (EINVAL); + } error = copyinuio(uap->iovp, iovcnt, &auio); - if (error) + if (error) { + CTR2(KTR_VFS, "%s: failed for invalid uio op with %d errno", + __func__, error); return (error); + } iov = auio->uio_iov; for (i = 0; i < iovcnt; i++) { if (iov->iov_len > MMAXOPTIONLEN) { free(auio, M_IOV); + CTR1(KTR_VFS, "%s: failed for invalid new auio", + __func__); return (EINVAL); } iov++; @@ -429,6 +439,7 @@ void vfs_ref(struct mount *mp) { + CTR2(KTR_VFS, "%s: mp %p", __func__, mp); MNT_ILOCK(mp); MNT_REF(mp); MNT_IUNLOCK(mp); @@ -438,6 +449,7 @@ void vfs_rel(struct mount *mp) { + CTR2(KTR_VFS, "%s: mp %p", __func__, mp); MNT_ILOCK(mp); MNT_REL(mp); MNT_IUNLOCK(mp); Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Thu Feb 5 14:58:16 2009 (r188149) +++ head/sys/kern/vfs_subr.c Thu Feb 5 15:03:35 2009 (r188150) @@ -341,6 +341,7 @@ vfs_busy(struct mount *mp, int flags) { MPASS((flags & ~MBF_MASK) == 0); + CTR3(KTR_VFS, "%s: mp %p with flags %d", __func__, mp, flags); MNT_ILOCK(mp); MNT_REF(mp); @@ -348,6 +349,8 @@ vfs_busy(struct mount *mp, int flags) if (flags & MBF_NOWAIT || mp->mnt_kern_flag & MNTK_REFEXPIRE) { MNT_REL(mp); MNT_IUNLOCK(mp); + CTR1(KTR_VFS, "%s: failed busying before sleeping", + __func__); return (ENOENT); } if (flags & MBF_MNTLSTLOCK) @@ -358,6 +361,7 @@ vfs_busy(struct mount *mp, int flags) MNT_IUNLOCK(mp); if (flags & MBF_MNTLSTLOCK) mtx_lock(&mountlist_mtx); + CTR1(KTR_VFS, "%s: failed busying after sleep", __func__); return (ENOENT); } if (flags & MBF_MNTLSTLOCK) @@ -374,11 +378,13 @@ void vfs_unbusy(struct mount *mp) { + CTR2(KTR_VFS, "%s: mp %p", __func__, mp); MNT_ILOCK(mp); MNT_REL(mp); mp->mnt_lockref--; if (mp->mnt_lockref == 0 && (mp->mnt_kern_flag & MNTK_DRAINING) != 0) { MPASS(mp->mnt_kern_flag & MNTK_UNMOUNT); + CTR1(KTR_VFS, "%s: waking up waiters", __func__); mp->mnt_kern_flag &= ~MNTK_DRAINING; wakeup(&mp->mnt_lockref); } @@ -393,6 +399,7 @@ vfs_getvfs(fsid_t *fsid) { struct mount *mp; + CTR2(KTR_VFS, "%s: fsid %p", __func__, fsid); mtx_lock(&mountlist_mtx); TAILQ_FOREACH(mp, &mountlist, mnt_list) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && @@ -403,6 +410,7 @@ vfs_getvfs(fsid_t *fsid) } } mtx_unlock(&mountlist_mtx); + CTR2(KTR_VFS, "%s: lookup failed for %p id", __func__, fsid); return ((struct mount *) 0); } @@ -416,6 +424,7 @@ vfs_busyfs(fsid_t *fsid) struct mount *mp; int error; + CTR2(KTR_VFS, "%s: fsid %p", __func__, fsid); mtx_lock(&mountlist_mtx); TAILQ_FOREACH(mp, &mountlist, mnt_list) { if (mp->mnt_stat.f_fsid.val[0] == fsid->val[0] && @@ -428,6 +437,7 @@ vfs_busyfs(fsid_t *fsid) return (mp); } } + CTR2(KTR_VFS, "%s: lookup failed for %p id", __func__, fsid); mtx_unlock(&mountlist_mtx); return ((struct mount *) 0); } @@ -498,6 +508,7 @@ vfs_getnewfsid(struct mount *mp) fsid_t tfsid; int mtype; + CTR2(KTR_VFS, "%s: mp %p", __func__, mp); mtx_lock(&mntid_mtx); mtype = mp->mnt_vfc->vfc_typenum; tfsid.val[1] = mtype; @@ -822,7 +833,7 @@ vdestroy(struct vnode *vp) { struct bufobj *bo; - CTR1(KTR_VFS, "vdestroy vp %p", vp); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); mtx_lock(&vnode_free_list_mtx); numvnodes--; mtx_unlock(&vnode_free_list_mtx); @@ -867,20 +878,27 @@ vtryrecycle(struct vnode *vp) { struct mount *vnmp; - CTR1(KTR_VFS, "vtryrecycle: trying vp %p", vp); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); VNASSERT(vp->v_holdcnt, vp, ("vtryrecycle: Recycling vp %p without a reference.", vp)); /* * This vnode may found and locked via some other list, if so we * can't recycle it yet. */ - if (VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT) != 0) + if (VOP_LOCK(vp, LK_EXCLUSIVE | LK_NOWAIT) != 0) { + CTR2(KTR_VFS, + "%s: impossible to recycle, vp %p lock is already held", + __func__, vp); return (EWOULDBLOCK); + } /* * Don't recycle if its filesystem is being suspended. */ if (vn_start_write(vp, &vnmp, V_NOWAIT) != 0) { VOP_UNLOCK(vp, 0); + CTR2(KTR_VFS, + "%s: impossible to recycle, cannot start the write for %p", + __func__, vp); return (EBUSY); } /* @@ -893,13 +911,15 @@ vtryrecycle(struct vnode *vp) if (vp->v_usecount) { VOP_UNLOCK(vp, LK_INTERLOCK); vn_finished_write(vnmp); + CTR2(KTR_VFS, + "%s: impossible to recycle, %p is already referenced", + __func__, vp); return (EBUSY); } if ((vp->v_iflag & VI_DOOMED) == 0) vgonel(vp); VOP_UNLOCK(vp, LK_INTERLOCK); vn_finished_write(vnmp); - CTR1(KTR_VFS, "vtryrecycle: recycled vp %p", vp); return (0); } @@ -913,6 +933,7 @@ getnewvnode(const char *tag, struct moun struct vnode *vp = NULL; struct bufobj *bo; + CTR3(KTR_VFS, "%s: mp %p with tag %s", __func__, mp, tag); mtx_lock(&vnode_free_list_mtx); /* * Lend our context to reclaim vnodes if they've exceeded the max. @@ -995,7 +1016,6 @@ alloc: vp->v_vflag |= VV_NOKNOTE; } - CTR2(KTR_VFS, "getnewvnode: mp %p vp %p", mp, vp); *vpp = vp; return (0); } @@ -1173,7 +1193,7 @@ int vinvalbuf(struct vnode *vp, int flags, int slpflag, int slptimeo) { - CTR2(KTR_VFS, "vinvalbuf vp %p flags %d", vp, flags); + CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags); ASSERT_VOP_LOCKED(vp, "vinvalbuf"); return (bufobj_invalbuf(&vp->v_bufobj, flags, slpflag, slptimeo)); } @@ -1265,7 +1285,9 @@ vtruncbuf(struct vnode *vp, struct ucred int trunclbn; struct bufobj *bo; - CTR2(KTR_VFS, "vtruncbuf vp %p length %jd", vp, length); + CTR5(KTR_VFS, "%s: vp %p with cred %p and block %d:%ju", __func__, + vp, cred, blksize, (uintmax_t)length); + /* * Round up to the *next* lbn. */ @@ -1974,8 +1996,7 @@ static void v_incr_usecount(struct vnode *vp) { - CTR3(KTR_VFS, "v_incr_usecount: vp %p holdcnt %d usecount %d\n", - vp, vp->v_holdcnt, vp->v_usecount); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount++; if (vp->v_type == VCHR && vp->v_rdev != NULL) { dev_lock(); @@ -1993,8 +2014,7 @@ static void v_upgrade_usecount(struct vnode *vp) { - CTR3(KTR_VFS, "v_upgrade_usecount: vp %p holdcnt %d usecount %d\n", - vp, vp->v_holdcnt, vp->v_usecount); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount++; if (vp->v_type == VCHR && vp->v_rdev != NULL) { dev_lock(); @@ -2012,11 +2032,10 @@ static void v_decr_usecount(struct vnode *vp) { - CTR3(KTR_VFS, "v_decr_usecount: vp %p holdcnt %d usecount %d\n", - vp, vp->v_holdcnt, vp->v_usecount); ASSERT_VI_LOCKED(vp, __FUNCTION__); VNASSERT(vp->v_usecount > 0, vp, ("v_decr_usecount: negative usecount")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount--; if (vp->v_type == VCHR && vp->v_rdev != NULL) { dev_lock(); @@ -2036,11 +2055,10 @@ static void v_decr_useonly(struct vnode *vp) { - CTR3(KTR_VFS, "v_decr_useonly: vp %p holdcnt %d usecount %d\n", - vp, vp->v_holdcnt, vp->v_usecount); ASSERT_VI_LOCKED(vp, __FUNCTION__); VNASSERT(vp->v_usecount > 0, vp, ("v_decr_useonly: negative usecount")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_usecount--; if (vp->v_type == VCHR && vp->v_rdev != NULL) { dev_lock(); @@ -2065,11 +2083,15 @@ vget(struct vnode *vp, int flags, struct VFS_ASSERT_GIANT(vp->v_mount); VNASSERT((flags & LK_TYPE_MASK) != 0, vp, ("vget: invalid lock operation")); + CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags); + if ((flags & LK_INTERLOCK) == 0) VI_LOCK(vp); vholdl(vp); if ((error = vn_lock(vp, flags | LK_INTERLOCK)) != 0) { vdrop(vp); + CTR2(KTR_VFS, "%s: impossible to lock vnode %p", __func__, + vp); return (error); } if (vp->v_iflag & VI_DOOMED && (flags & LK_RETRY) == 0) @@ -2100,6 +2122,7 @@ void vref(struct vnode *vp) { + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); VI_LOCK(vp); v_incr_usecount(vp); VI_UNLOCK(vp); @@ -2144,6 +2167,7 @@ vrele(struct vnode *vp) /* Skip this v_writecount check if we're going to panic below. */ VNASSERT(vp->v_writecount < vp->v_usecount || vp->v_usecount < 1, vp, ("vrele: missed vn_close")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if (vp->v_usecount > 1 || ((vp->v_iflag & VI_DOINGINACT) && vp->v_usecount == 1)) { @@ -2157,6 +2181,7 @@ vrele(struct vnode *vp) VI_UNLOCK(vp); panic("vrele: negative ref cnt"); } + CTR2(KTR_VFS, "%s: return vnode %p to the freelist", __func__, vp); /* * We want to hold the vnode until the inactive finishes to * prevent vgone() races. We drop the use count here and the @@ -2197,6 +2222,7 @@ vput(struct vnode *vp) KASSERT(vp != NULL, ("vput: null vp")); ASSERT_VOP_LOCKED(vp, "vput"); VFS_ASSERT_GIANT(vp->v_mount); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); VI_LOCK(vp); /* Skip this v_writecount check if we're going to panic below. */ VNASSERT(vp->v_writecount < vp->v_usecount || vp->v_usecount < 1, vp, @@ -2216,6 +2242,7 @@ vput(struct vnode *vp) #endif panic("vput: negative ref cnt"); } + CTR2(KTR_VFS, "%s: return to freelist the vnode %p", __func__, vp); /* * We want to hold the vnode until the inactive finishes to * prevent vgone() races. We drop the use count here and the @@ -2257,6 +2284,7 @@ void vholdl(struct vnode *vp) { + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_holdcnt++; if (VSHOULDBUSY(vp)) vbusy(vp); @@ -2284,11 +2312,14 @@ vdropl(struct vnode *vp) { ASSERT_VI_LOCKED(vp, "vdropl"); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if (vp->v_holdcnt <= 0) panic("vdrop: holdcnt %d", vp->v_holdcnt); vp->v_holdcnt--; if (vp->v_holdcnt == 0) { if (vp->v_iflag & VI_DOOMED) { + CTR2(KTR_VFS, "%s: destroying the vnode %p", __func__, + vp); vdestroy(vp); return; } else @@ -2311,6 +2342,7 @@ vinactive(struct vnode *vp, struct threa ASSERT_VI_LOCKED(vp, "vinactive"); VNASSERT((vp->v_iflag & VI_DOINGINACT) == 0, vp, ("vinactive: recursed on VI_DOINGINACT")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); vp->v_iflag |= VI_DOINGINACT; vp->v_iflag &= ~VI_OWEINACT; VI_UNLOCK(vp); @@ -2353,7 +2385,8 @@ vflush( struct mount *mp, int rootrefs, struct vattr vattr; int busy = 0, error; - CTR1(KTR_VFS, "vflush: mp %p", mp); + CTR4(KTR_VFS, "%s: mp %p with rootrefs %d and flags %d", __func__, mp, + rootrefs, flags); if (rootrefs > 0) { KASSERT((flags & (SKIPSYSTEM | WRITECLOSE)) == 0, ("vflush: bad args")); @@ -2361,8 +2394,11 @@ vflush( struct mount *mp, int rootrefs, * Get the filesystem root vnode. We can vput() it * immediately, since with rootrefs > 0, it won't go away. */ - if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rootvp, td)) != 0) + if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rootvp, td)) != 0) { + CTR2(KTR_VFS, "%s: vfs_root lookup failed with %d", + __func__, error); return (error); + } vput(rootvp); } @@ -2449,8 +2485,11 @@ loop: } else VI_UNLOCK(rootvp); } - if (busy) + if (busy) { + CTR2(KTR_VFS, "%s: failing as %d vnodes are busy", __func__, + busy); return (EBUSY); + } for (; rootrefs > 0; rootrefs--) vrele(rootvp); return (0); @@ -2465,6 +2504,7 @@ vrecycle(struct vnode *vp, struct thread int recycled; ASSERT_VOP_ELOCKED(vp, "vrecycle"); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); recycled = 0; VI_LOCK(vp); if (vp->v_usecount == 0) { @@ -2498,11 +2538,11 @@ vgonel(struct vnode *vp) int active; struct mount *mp; - CTR1(KTR_VFS, "vgonel: vp %p", vp); ASSERT_VOP_ELOCKED(vp, "vgonel"); ASSERT_VI_LOCKED(vp, "vgonel"); VNASSERT(vp->v_holdcnt, vp, ("vgonel: vp %p has no reference.", vp)); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); td = curthread; /* @@ -3099,7 +3139,9 @@ vfs_unmountall(void) int error; KASSERT(curthread != NULL, ("vfs_unmountall: NULL curthread")); + CTR1(KTR_VFS, "%s: unmounting all filesystems", __func__); td = curthread; + /* * Since this only runs when rebooting, it is not interlocked. */ @@ -3140,6 +3182,7 @@ vfs_msync(struct mount *mp, int flags) struct vnode *vp, *mvp; struct vm_object *obj; + CTR2(KTR_VFS, "%s: mp %p", __func__, mp); MNT_ILOCK(mp); MNT_VNODE_FOREACH(vp, mp, mvp) { VI_LOCK(vp); @@ -3179,7 +3222,6 @@ static void vfree(struct vnode *vp) { - CTR1(KTR_VFS, "vfree vp %p", vp); ASSERT_VI_LOCKED(vp, "vfree"); mtx_lock(&vnode_free_list_mtx); VNASSERT(vp->v_op != NULL, vp, ("vfree: vnode already reclaimed.")); @@ -3187,6 +3229,7 @@ vfree(struct vnode *vp) VNASSERT(VSHOULDFREE(vp), vp, ("vfree: freeing when we shouldn't")); VNASSERT((vp->v_iflag & VI_DOOMED) == 0, vp, ("vfree: Freeing doomed vnode")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if (vp->v_iflag & VI_AGE) { TAILQ_INSERT_HEAD(&vnode_free_list, vp, v_freelist); } else { @@ -3204,10 +3247,10 @@ vfree(struct vnode *vp) static void vbusy(struct vnode *vp) { - CTR1(KTR_VFS, "vbusy vp %p", vp); ASSERT_VI_LOCKED(vp, "vbusy"); VNASSERT((vp->v_iflag & VI_FREE) != 0, vp, ("vnode not free")); VNASSERT(vp->v_op != NULL, vp, ("vbusy: vnode already reclaimed.")); + CTR2(KTR_VFS, "%s: vp %p", __func__, vp); mtx_lock(&vnode_free_list_mtx); TAILQ_REMOVE(&vnode_free_list, vp, v_freelist); From jamie at FreeBSD.org Thu Feb 5 07:04:24 2009 From: jamie at FreeBSD.org (Jamie Gritton) Date: Thu Feb 5 07:04:48 2009 Subject: svn commit: r188151 - head/sys/netinet6 Message-ID: <200902051504.n15F4O46030207@svn.freebsd.org> Author: jamie Date: Thu Feb 5 15:04:23 2009 New Revision: 188151 URL: http://svn.freebsd.org/changeset/base/188151 Log: Don't bother null-checking the thread pointer before the prison checks in udp6_connect (td is already dereferenced elsewhere without such a check). This makes the conversion from a sockaddr to a sockaddr_in6 always happen, so convert once at the beginning of the function rather than twice in the middle. Approved by: bz (mentor) Modified: head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Thu Feb 5 15:03:35 2009 (r188150) +++ head/sys/netinet6/udp6_usrreq.c Thu Feb 5 15:04:23 2009 (r188151) @@ -883,48 +883,43 @@ udp6_connect(struct socket *so, struct s { INIT_VNET_INET(so->so_vnet); struct inpcb *inp; + struct sockaddr_in6 *sin6; int error; inp = sotoinpcb(so); + sin6 = (struct sockaddr_in6 *)nam; KASSERT(inp != NULL, ("udp6_connect: inp == NULL")); INP_INFO_WLOCK(&V_udbinfo); INP_WLOCK(inp); - if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) { - struct sockaddr_in6 *sin6_p; - - sin6_p = (struct sockaddr_in6 *)nam; - if (IN6_IS_ADDR_V4MAPPED(&sin6_p->sin6_addr)) { - struct sockaddr_in sin; + if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0 && + IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { + struct sockaddr_in sin; - if (inp->inp_faddr.s_addr != INADDR_ANY) { - error = EISCONN; - goto out; - } - in6_sin6_2_sin(&sin, sin6_p); - if (td && (error = prison_remote_ip4(td->td_ucred, - &sin.sin_addr)) != 0) - goto out; - error = in_pcbconnect(inp, (struct sockaddr *)&sin, - td->td_ucred); - if (error == 0) { - inp->inp_vflag |= INP_IPV4; - inp->inp_vflag &= ~INP_IPV6; - soisconnected(so); - } + if (inp->inp_faddr.s_addr != INADDR_ANY) { + error = EISCONN; goto out; } + in6_sin6_2_sin(&sin, sin6); + error = prison_remote_ip4(td->td_ucred, &sin.sin_addr); + if (error != 0) + goto out; + error = in_pcbconnect(inp, (struct sockaddr *)&sin, + td->td_ucred); + if (error == 0) { + inp->inp_vflag |= INP_IPV4; + inp->inp_vflag &= ~INP_IPV6; + soisconnected(so); + } + goto out; } if (!IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_faddr)) { error = EISCONN; goto out; } - if (td) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; - if ((error = prison_remote_ip6(td->td_ucred, - &sin6->sin6_addr)) != 0) - goto out; - } + error = prison_remote_ip6(td->td_ucred, &sin6->sin6_addr); + if (error != 0) + goto out; error = in6_pcbconnect(inp, nam, td->td_ucred); if (error == 0) { if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) { From attilio at FreeBSD.org Thu Feb 5 07:09:05 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Thu Feb 5 07:09:17 2009 Subject: svn commit: r188152 - in head: share/man/man9 sys/sys Message-ID: <200902051509.n15F94bL030325@svn.freebsd.org> Author: attilio Date: Thu Feb 5 15:09:04 2009 New Revision: 188152 URL: http://svn.freebsd.org/changeset/base/188152 Log: Remove the assertive KA_HELD and KA_UNHELD as long as they are dangerous, and not really helpful. Modified: head/share/man/man9/lock.9 head/sys/sys/lockmgr.h Modified: head/share/man/man9/lock.9 ============================================================================== --- head/share/man/man9/lock.9 Thu Feb 5 15:04:23 2009 (r188151) +++ head/share/man/man9/lock.9 Thu Feb 5 15:09:04 2009 (r188152) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 12, 2008 +.Dd February 05, 2009 .Dt LOCK 9 .Os .Sh NAME @@ -279,14 +279,6 @@ lock pointed to by the first argument. Assert that the current thread has no lock on the .Vt lkp lock pointed to by the first argument. -.It Dv KA_HELD -Assert that an unspecified thread has a lock on the -.Vt lkp -lock pointed to by the first argument. -.It Dv KA_UNHELD -Assert that no thread has a lock on the -.Vt lkp -lock pointed to by the first argument. .El .Pp In addition, one of the following optional assertions can be used with @@ -305,15 +297,6 @@ Assert that the current thread does not .Fa lkp . .El .Pp -Note that -.Dv KA_HELD -and -.Dv KA_UNHELD -usage is highly discouraged. -They are intended to cater a bad behaviour -introduced by buffer cache lock handling. -They will hopefully be -made useless by revisiting such locks. .Sh RETURN VALUES The .Fn lockmgr Modified: head/sys/sys/lockmgr.h ============================================================================== --- head/sys/sys/lockmgr.h Thu Feb 5 15:04:23 2009 (r188151) +++ head/sys/sys/lockmgr.h Thu Feb 5 15:09:04 2009 (r188152) @@ -183,8 +183,6 @@ _lockmgr_args_rw(struct lock *lk, u_int #define KA_UNLOCKED LA_UNLOCKED #define KA_RECURSED LA_RECURSED #define KA_NOTRECURSED LA_NOTRECURSED -#define KA_HELD -#define KA_UNHELD #endif #endif /* _KERNEL */ From imp at FreeBSD.org Thu Feb 5 09:43:13 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 09:43:19 2009 Subject: svn commit: r188154 - head/sys/opencrypto Message-ID: <200902051743.n15HhCMx033130@svn.freebsd.org> Author: imp Date: Thu Feb 5 17:43:12 2009 New Revision: 188154 URL: http://svn.freebsd.org/changeset/base/188154 Log: Fix return type for detach routine (should be int) Fix first parameter for identify routine (should be driver_t *) Modified: head/sys/opencrypto/cryptosoft.c Modified: head/sys/opencrypto/cryptosoft.c ============================================================================== --- head/sys/opencrypto/cryptosoft.c Thu Feb 5 15:09:42 2009 (r188153) +++ head/sys/opencrypto/cryptosoft.c Thu Feb 5 17:43:12 2009 (r188154) @@ -986,7 +986,7 @@ done: } static void -swcr_identify(device_t *dev, device_t parent) +swcr_identify(driver_t *drv, device_t parent) { /* NB: order 10 is so we get attached after h/w devices */ if (device_find_child(parent, "cryptosoft", -1) == NULL && @@ -1040,12 +1040,13 @@ swcr_attach(device_t dev) return 0; } -static void +static int swcr_detach(device_t dev) { crypto_unregister_all(swcr_id); if (swcr_sessions != NULL) free(swcr_sessions, M_CRYPTO_DATA); + return 0; } static device_method_t swcr_methods[] = { From sam at FreeBSD.org Thu Feb 5 09:51:47 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 09:51:54 2009 Subject: svn commit: r188155 - head/sbin/ifconfig Message-ID: <200902051751.n15HpkEP033327@svn.freebsd.org> Author: sam Date: Thu Feb 5 17:51:46 2009 New Revision: 188155 URL: http://svn.freebsd.org/changeset/base/188155 Log: add support for max antenna gain (not used at the moment) Modified: head/sbin/ifconfig/regdomain.c head/sbin/ifconfig/regdomain.h Modified: head/sbin/ifconfig/regdomain.c ============================================================================== --- head/sbin/ifconfig/regdomain.c Thu Feb 5 17:43:12 2009 (r188154) +++ head/sbin/ifconfig/regdomain.c Thu Feb 5 17:51:46 2009 (r188155) @@ -289,6 +289,10 @@ end_element(void *data, const char *name mt->netband->maxPowerDFS = strtoul(p, NULL, 0); goto done; } + if (iseq(name, "maxantgain") && mt->netband != NULL) { + mt->netband->maxAntGain = strtoul(p, NULL, 0); + goto done; + } /* ... */ if (iseq(name, "isocc") && mt->country != NULL) { Modified: head/sbin/ifconfig/regdomain.h ============================================================================== --- head/sbin/ifconfig/regdomain.h Thu Feb 5 17:43:12 2009 (r188154) +++ head/sbin/ifconfig/regdomain.h Thu Feb 5 17:51:46 2009 (r188155) @@ -49,6 +49,7 @@ struct netband { const struct freqband *band; /* channel list description */ uint8_t maxPower; /* regulatory cap on tx power (dBm) */ uint8_t maxPowerDFS; /* regulatory cap w/ DFS (dBm) */ + uint8_t maxAntGain; /* max allowed antenna gain (.5 dBm) */ uint32_t flags; /* net80211 channel flags */ LIST_ENTRY(netband) next; From sam at FreeBSD.org Thu Feb 5 10:12:08 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 10:12:20 2009 Subject: svn commit: r188156 - in head/sys: conf dev/cfi sys Message-ID: <200902051812.n15IC7Tp033732@svn.freebsd.org> Author: sam Date: Thu Feb 5 18:12:07 2009 New Revision: 188156 URL: http://svn.freebsd.org/changeset/base/188156 Log: Add support for frobbing Intel StrataFlash Protection Registers: o add CFI_SUPPORT_STRATAFLASH compile option to enable support o add new ioctls to get/set the factory and user/oem segments of the PR and to get/set Protection Lock Register that fuses the user segment o add #defines for bits in the status register o update cfi_wait_ready to take an offset so it can be used to wait for PR write completion and replace constants w/ symbolic names Note: writing the user segment isn't correct; committing now to get review. Sponsored by: Carlson Wireless Reviewed by: imp, Chris Anderson Modified: head/sys/conf/options head/sys/dev/cfi/cfi_core.c head/sys/dev/cfi/cfi_dev.c head/sys/dev/cfi/cfi_reg.h head/sys/dev/cfi/cfi_var.h head/sys/sys/cfictl.h Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/conf/options Thu Feb 5 18:12:07 2009 (r188156) @@ -804,3 +804,7 @@ TDMA_TXRATE_11A_DEFAULT opt_tdma.h # Virtualize the network stack VIMAGE opt_global.h VIMAGE_GLOBALS opt_global.h + +# Common Flash Interface (CFI) options +CFI_SUPPORT_STRATAFLASH opt_cfi.h +CFI_ARMEDANDDANGEROUS opt_cfi.h Modified: head/sys/dev/cfi/cfi_core.c ============================================================================== --- head/sys/dev/cfi/cfi_core.c Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/dev/cfi/cfi_core.c Thu Feb 5 18:12:07 2009 (r188156) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_cfi.h" + #include #include #include @@ -70,7 +72,6 @@ cfi_read(struct cfi_softc *sc, u_int ofs val = ~0; break; } - return (val); } @@ -300,10 +301,10 @@ cfi_detach(device_t dev) } static int -cfi_wait_ready(struct cfi_softc *sc, u_int timeout) +cfi_wait_ready(struct cfi_softc *sc, u_int ofs, u_int timeout) { int done, error; - uint32_t st0, st; + uint32_t st0 = 0, st = 0; done = 0; error = 0; @@ -315,21 +316,27 @@ cfi_wait_ready(struct cfi_softc *sc, u_i switch (sc->sc_cmdset) { case CFI_VEND_INTEL_ECS: case CFI_VEND_INTEL_SCS: - st = cfi_read(sc, sc->sc_wrofs); - done = (st & 0x80); + st = cfi_read(sc, ofs); + done = (st & CFI_INTEL_STATUS_WSMS); if (done) { - if (st & 0x02) + /* NB: bit 0 is reserved */ + st &= ~(CFI_INTEL_XSTATUS_RSVD | + CFI_INTEL_STATUS_WSMS | + CFI_INTEL_STATUS_RSVD); + if (st & CFI_INTEL_STATUS_DPS) error = EPERM; - else if (st & 0x10) + else if (st & CFI_INTEL_STATUS_PSLBS) error = EIO; - else if (st & 0x20) + else if (st & CFI_INTEL_STATUS_ECLBS) error = ENXIO; + else if (st) + error = EACCES; } break; case CFI_VEND_AMD_SCS: case CFI_VEND_AMD_ECS: - st0 = cfi_read(sc, sc->sc_wrofs); - st = cfi_read(sc, sc->sc_wrofs); + st0 = cfi_read(sc, ofs); + st = cfi_read(sc, ofs); done = ((st & 0x40) == (st0 & 0x40)) ? 1 : 0; break; } @@ -337,7 +344,7 @@ cfi_wait_ready(struct cfi_softc *sc, u_i if (!done && !error) error = ETIMEDOUT; if (error) - printf("\nerror=%d\n", error); + printf("\nerror=%d (st 0x%x st0 0x%x)\n", error, st, st0); return (error); } @@ -369,7 +376,7 @@ cfi_write_block(struct cfi_softc *sc) /* Better safe than sorry... */ return (ENODEV); } - error = cfi_wait_ready(sc, sc->sc_erase_timeout); + error = cfi_wait_ready(sc, sc->sc_wrofs, sc->sc_erase_timeout); if (error) goto out; @@ -411,7 +418,7 @@ cfi_write_block(struct cfi_softc *sc) intr_restore(intr); - error = cfi_wait_ready(sc, sc->sc_write_timeout); + error = cfi_wait_ready(sc, sc->sc_wrofs, sc->sc_write_timeout); if (error) goto out; } @@ -422,3 +429,145 @@ cfi_write_block(struct cfi_softc *sc) cfi_write(sc, 0, CFI_BCS_READ_ARRAY); return (error); } + +#ifdef CFI_SUPPORT_STRATAFLASH +/* + * Intel StrataFlash Protection Register Support. + * + * The memory includes a 128-bit Protection Register that can be + * used for security. There are two 64-bit segments; one is programmed + * at the factory with a unique 64-bit number which is immutable. + * The other segment is left blank for User (OEM) programming. + * Once the User/OEM segment is programmed it can be locked + * to prevent future programming by writing bit 0 of the Protection + * Lock Register (PLR). The PLR can written only once. + */ + +static uint16_t +cfi_get16(struct cfi_softc *sc, int off) +{ + uint16_t v = bus_space_read_2(sc->sc_tag, sc->sc_handle, off<<1); + return v; +} + +static void +cfi_put16(struct cfi_softc *sc, int off, uint16_t v) +{ + bus_space_write_2(sc->sc_tag, sc->sc_handle, off<<1, v); +} + +/* + * Read the factory-defined 64-bit segment of the PR. + */ +int +cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *id) +{ + if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) + return EOPNOTSUPP; + KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); + + cfi_write(sc, 0, CFI_INTEL_READ_ID); + *id = ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(0)))<<48 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(1)))<<32 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(2)))<<16 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(3))); + cfi_write(sc, 0, CFI_BCS_READ_ARRAY); + return 0; +} + +/* + * Read the User/OEM 64-bit segment of the PR. + */ +int +cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *id) +{ + if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) + return EOPNOTSUPP; + KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); + + cfi_write(sc, 0, CFI_INTEL_READ_ID); + *id = ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(4)))<<48 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(5)))<<32 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(6)))<<16 | + ((uint64_t)cfi_get16(sc, CFI_INTEL_PR(7))); + cfi_write(sc, 0, CFI_BCS_READ_ARRAY); + return 0; +} + +/* + * Write the User/OEM 64-bit segment of the PR. + */ +int +cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t id) +{ + register_t intr; + int i, error; + + if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) + return EOPNOTSUPP; + KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); + + for (i = 7; i >= 4; i--, id >>= 16) { + intr = intr_disable(); + cfi_write(sc, 0, CFI_INTEL_PP_SETUP); + cfi_put16(sc, CFI_INTEL_PR(i), id&0xffff); + intr_restore(intr); + error = cfi_wait_ready(sc, CFI_BCS_READ_STATUS, + sc->sc_write_timeout); + if (error) + break; + } + cfi_write(sc, 0, CFI_BCS_READ_ARRAY); + return error; +} + +/* + * Read the contents of the Protection Lock Register. + */ +int +cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *plr) +{ + if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) + return EOPNOTSUPP; + KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); + + cfi_write(sc, 0, CFI_INTEL_READ_ID); + *plr = cfi_get16(sc, CFI_INTEL_PLR); + cfi_write(sc, 0, CFI_BCS_READ_ARRAY); + return 0; +} + +/* + * Write the Protection Lock Register to lock down the + * user-settable segment of the Protection Register. + * NOTE: this operation is not reversible. + */ +int +cfi_intel_set_plr(struct cfi_softc *sc) +{ +#ifdef CFI_ARMEDANDDANGEROUS + register_t intr; +#endif + int error; + + if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) + return EOPNOTSUPP; + KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); + +#ifdef CFI_ARMEDANDDANGEROUS + /* worthy of console msg */ + device_printf(sc->sc_dev, "set PLR\n"); + intr = intr_disable(); + cfi_write(sc, 0, CFI_INTEL_PP_SETUP); + cfi_put16(sc, CFI_INTEL_PLR, 0xFFFD); + intr_restore(intr); + error = cfi_wait_ready(sc, CFI_BCS_READ_STATUS, sc->sc_write_timeout); + cfi_write(sc, 0, CFI_BCS_READ_ARRAY); +#else + device_printf(sc->sc_dev, "%s: PLR not set, " + "CFI_ARMEDANDDANGEROUS not configured\n", __func__); + error = ENXIO; +#endif + return error; +} +#endif /* CFI_SUPPORT_STRATAFLASH */ Modified: head/sys/dev/cfi/cfi_dev.c ============================================================================== --- head/sys/dev/cfi/cfi_dev.c Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/dev/cfi/cfi_dev.c Thu Feb 5 18:12:07 2009 (r188156) @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_cfi.h" + #include #include #include @@ -255,14 +257,13 @@ cfi_devioctl(struct cdev *dev, u_long cm sc = dev->si_drv1; error = 0; - switch(cmd) { + switch (cmd) { case CFIOCQRY: if (sc->sc_writing) { error = cfi_block_finish(sc); if (error) break; } - rq = (struct cfiocqry *)data; if (rq->offset >= sc->sc_size / sc->sc_width) return (ESPIPE); @@ -274,6 +275,23 @@ cfi_devioctl(struct cdev *dev, u_long cm error = copyout(&val, rq->buffer++, 1); } break; +#ifdef CFI_SUPPORT_STRATAFLASH + case CFIOCGFACTORYPR: + error = cfi_intel_get_factory_pr(sc, (uint64_t *)data); + break; + case CFIOCGOEMPR: + error = cfi_intel_get_oem_pr(sc, (uint64_t *)data); + break; + case CFIOCSOEMPR: + error = cfi_intel_set_oem_pr(sc, *(uint64_t *)data); + break; + case CFIOCGPLR: + error = cfi_intel_get_plr(sc, (uint32_t *)data); + break; + case CFIOCSPLR: + error = cfi_intel_set_plr(sc); + break; +#endif /* CFI_SUPPORT_STRATAFLASH */ default: error = ENOIOCTL; break; Modified: head/sys/dev/cfi/cfi_reg.h ============================================================================== --- head/sys/dev/cfi/cfi_reg.h Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/dev/cfi/cfi_reg.h Thu Feb 5 18:12:07 2009 (r188156) @@ -104,6 +104,28 @@ struct cfi_qry { #define CFI_BCS_CONFIRM 0xd0 #define CFI_BCS_READ_ARRAY 0xff +/* Intel commands. */ +#define CFI_INTEL_READ_ID 0x90 /* Read Identifier */ +#define CFI_INTEL_PP_SETUP 0xc0 /* Protection Program Setup */ + +/* NB: these are addresses for 16-bit accesses */ +#define CFI_INTEL_PLR 0x80 /* Protection Lock Register */ +#define CFI_INTEL_PR(n) (0x81+(n)) /* Protection Register */ + +/* Status register definitions */ +#define CFI_INTEL_STATUS_WSMS 0x0080 /* Write Machine Status */ +#define CFI_INTEL_STATUS_ESS 0x0040 /* Erase Suspend Status */ +#define CFI_INTEL_STATUS_ECLBS 0x0020 /* Erase and Clear Lock-Bit Status */ +#define CFI_INTEL_STATUS_PSLBS 0x0010 /* Program and Set Lock-Bit Status */ +#define CFI_INTEL_STATUS_VPENS 0x0008 /* Programming Voltage Status */ +#define CFI_INTEL_STATUS_PSS 0x0004 /* Program Suspend Status */ +#define CFI_INTEL_STATUS_DPS 0x0002 /* Device Protect Status */ +#define CFI_INTEL_STATUS_RSVD 0x0001 /* reserved */ + +/* eXtended Status register definitions */ +#define CFI_INTEL_XSTATUS_WBS 0x8000 /* Write Buffer Status */ +#define CFI_INTEL_XSTATUS_RSVD 0x7f00 /* reserved */ + /* AMD commands. */ #define CFI_AMD_BLOCK_ERASE 0x30 #define CFI_AMD_UNLOCK_ACK 0x55 Modified: head/sys/dev/cfi/cfi_var.h ============================================================================== --- head/sys/dev/cfi/cfi_var.h Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/dev/cfi/cfi_var.h Thu Feb 5 18:12:07 2009 (r188156) @@ -74,4 +74,11 @@ uint32_t cfi_read(struct cfi_softc *, u_ uint8_t cfi_read_qry(struct cfi_softc *, u_int); int cfi_write_block(struct cfi_softc *); +#ifdef CFI_SUPPORT_STRATAFLASH +int cfi_intel_get_factory_pr(struct cfi_softc *sc, uint64_t *); +int cfi_intel_get_oem_pr(struct cfi_softc *sc, uint64_t *); +int cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t); +int cfi_intel_get_plr(struct cfi_softc *sc, uint32_t *); +int cfi_intel_set_plr(struct cfi_softc *sc); +#endif /* CFI_SUPPORT_STRATAFLASH */ #endif /* _DEV_CFI_VAR_H_ */ Modified: head/sys/sys/cfictl.h ============================================================================== --- head/sys/sys/cfictl.h Thu Feb 5 17:51:46 2009 (r188155) +++ head/sys/sys/cfictl.h Thu Feb 5 18:12:07 2009 (r188156) @@ -44,4 +44,10 @@ struct cfiocqry { #define CFIOCQRY _IOWR('q', 0, struct cfiocqry) +/* Intel StrataFlash Protection Register support */ +#define CFIOCGFACTORYPR _IOR('q', 1, uint64_t) /* get factory protection reg */ +#define CFIOCGOEMPR _IOR('q', 2, uint64_t) /* get oem protection reg */ +#define CFIOCSOEMPR _IOW('q', 3, uint64_t) /* set oem protection reg */ +#define CFIOCGPLR _IOR('q', 4, uint32_t) /* get protection lock reg */ +#define CFIOCSPLR _IO('q', 5) /* set protection log reg */ #endif /* _SYS_CFICTL_H_ */ From sam at FreeBSD.org Thu Feb 5 10:15:22 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 10:15:34 2009 Subject: svn commit: r188157 - in head/tools/tools: . cfi Message-ID: <200902051815.n15IFKwc033830@svn.freebsd.org> Author: sam Date: Thu Feb 5 18:15:20 2009 New Revision: 188157 URL: http://svn.freebsd.org/changeset/base/188157 Log: add cfi test tool Sponsored by: Carlson Wireless Reviewed by: imp, Chris Andreson Added: head/tools/tools/cfi/ head/tools/tools/cfi/Makefile (contents, props changed) head/tools/tools/cfi/cfi.c (contents, props changed) Modified: head/tools/tools/README Modified: head/tools/tools/README ============================================================================== --- head/tools/tools/README Thu Feb 5 18:12:07 2009 (r188156) +++ head/tools/tools/README Thu Feb 5 18:15:20 2009 (r188157) @@ -12,6 +12,7 @@ ansify Convert K&R-style function defin ath Tools specific to the Atheros 802.11 support backout_commit A tool for reading in a commit message and generating a script that will backout the commit. +cfi Common Flash Interface (CFI) tool commitsdb A tool for reconstructing commit history using md5 checksums of the commit logs. crypto Test and exercise tools related to the crypto framework Added: head/tools/tools/cfi/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/cfi/Makefile Thu Feb 5 18:15:20 2009 (r188157) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +PROG= cfi +BINDIR= /usr/local/bin +NO_MAN= + +.include Added: head/tools/tools/cfi/cfi.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/cfi/cfi.c Thu Feb 5 18:15:20 2009 (r188157) @@ -0,0 +1,156 @@ +/*- + * Copyright (c) 2009 Sam Leffler, Errno Consulting + * 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. + * + * 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. + * + * $FreeBSD$ + */ + +/* + * cfi [-f device] op + * (default device is /dev/cfi0). + */ +#include +#include +#include +#include + +#include +#include +#include + +const char *progname; +const char *dvname; + +static void +usage(void) +{ + int i; + + fprintf(stderr, "usage: %s [-f device] op...\n", progname); + fprintf(stderr, "where op's are:\n"); + fprintf(stderr, "fact\t\tread factory PR segment\n"); + fprintf(stderr, "oem\t\tread OEM segment\n"); + fprintf(stderr, "woem value\twrite OEM segment\n"); + fprintf(stderr, "plr\t\tread PLR\n"); + fprintf(stderr, "wplr\t\twrite PLR\n"); + exit(-1); +} + +static int +getfd(int mode) +{ + int fd = open(dvname, mode, 0); + if (fd < 0) + err(-1, "open"); + return fd; +} + +static uint64_t +getfactorypr(void) +{ + uint64_t v; + int fd = getfd(O_RDONLY); + if (ioctl(fd, CFIOCGFACTORYPR, &v) < 0) + err(-1, "ioctl(CFIOCGFACTORYPR)"); + close(fd); + return v; +} + +static uint64_t +getoempr(void) +{ + uint64_t v; + int fd = getfd(O_RDONLY); + if (ioctl(fd, CFIOCGOEMPR, &v) < 0) + err(-1, "ioctl(CFIOCGOEMPR)"); + close(fd); + return v; +} + +static void +setoempr(uint64_t v) +{ + int fd = getfd(O_WRONLY); + if (ioctl(fd, CFIOCSOEMPR, &v) < 0) + err(-1, "ioctl(CFIOCGOEMPR)"); + close(fd); +} + +static uint32_t +getplr(void) +{ + uint32_t plr; + int fd = getfd(O_RDONLY); + if (ioctl(fd, CFIOCGPLR, &plr) < 0) + err(-1, "ioctl(CFIOCGPLR)"); + close(fd); + return plr; +} + +static void +setplr(void) +{ + int fd = getfd(O_WRONLY); + if (ioctl(fd, CFIOCSPLR, 0) < 0) + err(-1, "ioctl(CFIOCPLR)"); + close(fd); +} + +int +main(int argc, char *argv[]) +{ + dvname = getenv("CFI"); + if (dvname == NULL) + dvname = "/dev/cfi0"; + progname = argv[0]; + if (argc > 1) { + if (strcmp(argv[1], "-f") == 0) { + if (argc < 2) + errx(1, "missing device name for -f option"); + dvname = argv[2]; + argc -= 2, argv += 2; + } else if (strcmp(argv[1], "-?") == 0) + usage(); + } + for (; argc > 1; argc--, argv++) { + if (strcasecmp(argv[1], "fact") == 0) { + printf("0x%llx\n", (unsigned long long) getfactorypr()); + } else if (strcasecmp(argv[1], "oem") == 0) { + printf("0x%llx\n", (unsigned long long) getoempr()); + } else if (strcasecmp(argv[1], "woem") == 0) { + if (argc < 2) + errx(1, "missing value for woem"); + setoempr((uint64_t) strtoull(argv[2], NULL, 0)); + argc--, argv++; + } else if (strcasecmp(argv[1], "plr") == 0) { + printf("0x%x\n", getplr()); + } else if (strcasecmp(argv[1], "wplr") == 0) { + setplr(); + } else + usage(); + } +} From niclas.zeising at gmail.com Thu Feb 5 10:23:44 2009 From: niclas.zeising at gmail.com (Niclas Zeising) Date: Thu Feb 5 10:23:50 2009 Subject: svn commit: r188154 - head/sys/opencrypto In-Reply-To: <200902051743.n15HhCMx033130@svn.freebsd.org> References: <200902051743.n15HhCMx033130@svn.freebsd.org> Message-ID: <498B2829.9000608@gmail.com> Warner Losh wrote: > Author: imp > Date: Thu Feb 5 17:43:12 2009 > New Revision: 188154 > URL: http://svn.freebsd.org/changeset/base/188154 > > Log: > Fix return type for detach routine (should be int) > Fix first parameter for identify routine (should be driver_t *) > > Modified: > head/sys/opencrypto/cryptosoft.c > > Modified: head/sys/opencrypto/cryptosoft.c > ============================================================================== > --- head/sys/opencrypto/cryptosoft.c Thu Feb 5 15:09:42 2009 (r188153) > +++ head/sys/opencrypto/cryptosoft.c Thu Feb 5 17:43:12 2009 (r188154) > @@ -986,7 +986,7 @@ done: > } > > static void > -swcr_identify(device_t *dev, device_t parent) > +swcr_identify(driver_t *drv, device_t parent) ^^^ Was this name change intentional? > { > /* NB: order 10 is so we get attached after h/w devices */ > if (device_find_child(parent, "cryptosoft", -1) == NULL && > @@ -1040,12 +1040,13 @@ swcr_attach(device_t dev) > return 0; > } > > -static void > +static int > swcr_detach(device_t dev) > { > crypto_unregister_all(swcr_id); > if (swcr_sessions != NULL) > free(swcr_sessions, M_CRYPTO_DATA); > + return 0; > } > > static device_method_t swcr_methods[] = { Regards! //Niclas From imp at bsdimp.com Thu Feb 5 10:36:11 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Thu Feb 5 10:36:23 2009 Subject: svn commit: r188154 - head/sys/opencrypto In-Reply-To: <498B2829.9000608@gmail.com> References: <200902051743.n15HhCMx033130@svn.freebsd.org> <498B2829.9000608@gmail.com> Message-ID: <20090205.113516.113804072.imp@bsdimp.com> In message: <498B2829.9000608@gmail.com> Niclas Zeising writes: : Warner Losh wrote: : > Author: imp : > Date: Thu Feb 5 17:43:12 2009 : > New Revision: 188154 : > URL: http://svn.freebsd.org/changeset/base/188154 : > : > Log: : > Fix return type for detach routine (should be int) : > Fix first parameter for identify routine (should be driver_t *) : > : > Modified: : > head/sys/opencrypto/cryptosoft.c : > : > Modified: head/sys/opencrypto/cryptosoft.c : > ============================================================================== : > --- head/sys/opencrypto/cryptosoft.c Thu Feb 5 15:09:42 2009 (r188153) : > +++ head/sys/opencrypto/cryptosoft.c Thu Feb 5 17:43:12 2009 (r188154) : > @@ -986,7 +986,7 @@ done: : > } : > : > static void : > -swcr_identify(device_t *dev, device_t parent) : > +swcr_identify(driver_t *drv, device_t parent) : ^^^ : : Was this name change intentional? Yes. It 'dev' is typically used for 'device_t' types. However, by changing this to drv, it shows it isn't a device_t, and also breaks any code that used the old variable with a compiler error. Warner : > { : > /* NB: order 10 is so we get attached after h/w devices */ : > if (device_find_child(parent, "cryptosoft", -1) == NULL && : > @@ -1040,12 +1040,13 @@ swcr_attach(device_t dev) : > return 0; : > } : > : > -static void : > +static int : > swcr_detach(device_t dev) : > { : > crypto_unregister_all(swcr_id); : > if (swcr_sessions != NULL) : > free(swcr_sessions, M_CRYPTO_DATA); : > + return 0; : > } : > : > static device_method_t swcr_methods[] = { : : Regards! : //Niclas : : From imp at FreeBSD.org Thu Feb 5 10:38:41 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 10:38:47 2009 Subject: svn commit: r188160 - head/sys/dev/atkbdc Message-ID: <200902051838.n15IceDM034480@svn.freebsd.org> Author: imp Date: Thu Feb 5 18:38:39 2009 New Revision: 188160 URL: http://svn.freebsd.org/changeset/base/188160 Log: bus_add_child takes a const char *. Modified: head/sys/dev/atkbdc/atkbdc_isa.c Modified: head/sys/dev/atkbdc/atkbdc_isa.c ============================================================================== --- head/sys/dev/atkbdc/atkbdc_isa.c Thu Feb 5 18:23:28 2009 (r188159) +++ head/sys/dev/atkbdc/atkbdc_isa.c Thu Feb 5 18:38:39 2009 (r188160) @@ -47,8 +47,8 @@ __FBSDID("$FreeBSD$"); static int atkbdc_isa_probe(device_t dev); static int atkbdc_isa_attach(device_t dev); -static device_t atkbdc_isa_add_child(device_t bus, int order, char *name, - int unit); +static device_t atkbdc_isa_add_child(device_t bus, int order, const char *name, + int unit); static device_method_t atkbdc_isa_methods[] = { DEVMETHOD(device_probe, atkbdc_isa_probe), @@ -227,7 +227,7 @@ atkbdc_isa_attach(device_t dev) } static device_t -atkbdc_isa_add_child(device_t bus, int order, char *name, int unit) +atkbdc_isa_add_child(device_t bus, int order, const char *name, int unit) { atkbdc_device_t *ivar; device_t child; From imp at FreeBSD.org Thu Feb 5 10:39:34 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 10:39:46 2009 Subject: svn commit: r188162 - head/sys/dev/acpi_support Message-ID: <200902051839.n15IdXQK034574@svn.freebsd.org> Author: imp Date: Thu Feb 5 18:39:33 2009 New Revision: 188162 URL: http://svn.freebsd.org/changeset/base/188162 Log: device_shutdown returns int. Modified: head/sys/dev/acpi_support/acpi_panasonic.c Modified: head/sys/dev/acpi_support/acpi_panasonic.c ============================================================================== --- head/sys/dev/acpi_support/acpi_panasonic.c Thu Feb 5 18:39:28 2009 (r188161) +++ head/sys/dev/acpi_support/acpi_panasonic.c Thu Feb 5 18:39:33 2009 (r188162) @@ -79,7 +79,7 @@ typedef int hkey_fn_t(ACPI_HANDLE, int, static int acpi_panasonic_probe(device_t dev); static int acpi_panasonic_attach(device_t dev); static int acpi_panasonic_detach(device_t dev); -static void acpi_panasonic_shutdown(device_t dev); +static int acpi_panasonic_shutdown(device_t dev); static int acpi_panasonic_sysctl(SYSCTL_HANDLER_ARGS); static ACPI_INTEGER acpi_panasonic_sinf(ACPI_HANDLE h, ACPI_INTEGER index); static void acpi_panasonic_sset(ACPI_HANDLE h, ACPI_INTEGER index, @@ -220,7 +220,7 @@ acpi_panasonic_detach(device_t dev) return (0); } -static void +static int acpi_panasonic_shutdown(device_t dev) { struct acpi_panasonic_softc *sc; @@ -230,6 +230,7 @@ acpi_panasonic_shutdown(device_t dev) sc = device_get_softc(dev); mute = 1; hkey_sound_mute(sc->handle, HKEY_SET, &mute); + return (0); } static int From imp at FreeBSD.org Thu Feb 5 10:40:45 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 10:40:51 2009 Subject: svn commit: r188163 - head/sys/dev/acpica Message-ID: <200902051840.n15Iegbd034638@svn.freebsd.org> Author: imp Date: Thu Feb 5 18:40:42 2009 New Revision: 188163 URL: http://svn.freebsd.org/changeset/base/188163 Log: pcib_read_config and pcib_write_config take u_int params. Modified: head/sys/dev/acpica/acpi_pcib_acpi.c Modified: head/sys/dev/acpica/acpi_pcib_acpi.c ============================================================================== --- head/sys/dev/acpica/acpi_pcib_acpi.c Thu Feb 5 18:39:33 2009 (r188162) +++ head/sys/dev/acpica/acpi_pcib_acpi.c Thu Feb 5 18:40:42 2009 (r188163) @@ -68,10 +68,11 @@ static int acpi_pcib_read_ivar(device_t int which, uintptr_t *result); static int acpi_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value); -static uint32_t acpi_pcib_read_config(device_t dev, int bus, int slot, - int func, int reg, int bytes); -static void acpi_pcib_write_config(device_t dev, int bus, int slot, - int func, int reg, uint32_t data, int bytes); +static uint32_t acpi_pcib_read_config(device_t dev, u_int bus, + u_int slot, u_int func, u_int reg, int bytes); +static void acpi_pcib_write_config(device_t dev, u_int bus, + u_int slot, u_int func, u_int reg, uint32_t data, + int bytes); static int acpi_pcib_acpi_route_interrupt(device_t pcib, device_t dev, int pin); static int acpi_pcib_alloc_msi(device_t pcib, device_t dev, @@ -297,15 +298,15 @@ acpi_pcib_write_ivar(device_t dev, devic } static uint32_t -acpi_pcib_read_config(device_t dev, int bus, int slot, int func, int reg, - int bytes) +acpi_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) { return (pci_cfgregread(bus, slot, func, reg, bytes)); } static void -acpi_pcib_write_config(device_t dev, int bus, int slot, int func, int reg, - uint32_t data, int bytes) +acpi_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, uint32_t data, int bytes) { pci_cfgregwrite(bus, slot, func, reg, data, bytes); } From imp at FreeBSD.org Thu Feb 5 10:43:14 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 10:43:25 2009 Subject: svn commit: r188164 - head/sys/dev/bge Message-ID: <200902051843.n15IhEvR034721@svn.freebsd.org> Author: imp Date: Thu Feb 5 18:43:13 2009 New Revision: 188164 URL: http://svn.freebsd.org/changeset/base/188164 Log: device_shutdown returns an int. Modified: head/sys/dev/bge/if_bge.c Modified: head/sys/dev/bge/if_bge.c ============================================================================== --- head/sys/dev/bge/if_bge.c Thu Feb 5 18:40:42 2009 (r188163) +++ head/sys/dev/bge/if_bge.c Thu Feb 5 18:43:13 2009 (r188164) @@ -348,7 +348,7 @@ static void bge_init_locked(struct bge_s static void bge_init(void *); static void bge_stop(struct bge_softc *); static void bge_watchdog(struct bge_softc *); -static void bge_shutdown(device_t); +static int bge_shutdown(device_t); static int bge_ifmedia_upd_locked(struct ifnet *); static int bge_ifmedia_upd(struct ifnet *); static void bge_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -4280,17 +4280,18 @@ bge_stop(struct bge_softc *sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int bge_shutdown(device_t dev) { struct bge_softc *sc; sc = device_get_softc(dev); - BGE_LOCK(sc); bge_stop(sc); bge_reset(sc); BGE_UNLOCK(sc); + + return (0); } static int From imp at FreeBSD.org Thu Feb 5 10:51:15 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 10:51:22 2009 Subject: svn commit: r188167 - head/sys/dev/exca Message-ID: <200902051851.n15IpEqD034995@svn.freebsd.org> Author: imp Date: Thu Feb 5 18:51:14 2009 New Revision: 188167 URL: http://svn.freebsd.org/changeset/base/188167 Log: Add some additional debugging for the memory code. Modified: head/sys/dev/exca/exca.c Modified: head/sys/dev/exca/exca.c ============================================================================== --- head/sys/dev/exca/exca.c Thu Feb 5 18:46:01 2009 (r188166) +++ head/sys/dev/exca/exca.c Thu Feb 5 18:51:14 2009 (r188167) @@ -209,12 +209,9 @@ exca_do_mem_map(struct exca_softc *sc, i exca_putb(sc, map->cardmem_msb, ((offset >> 8) & EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | attrmem); -#ifdef EXCA_DEBUG - if (mem->kind & PCCARD_MEM_ATTR) - printf("attribtue memory\n"); - else - printf("common memory\n"); -#endif + DPRINTF("%s %d-bit memory", + mem->kind & PCCARD_MEM_ATTR ? "attrubute" : "common", + mem->kind & PCCARD_MEM_16BIT ? 16 : 8); exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->memenable | EXCA_ADDRWIN_ENABLE_MEMCS16); @@ -229,11 +226,11 @@ exca_do_mem_map(struct exca_softc *sc, i r5 = exca_getb(sc, map->cardmem_msb); r6 = exca_getb(sc, map->cardmem_lsb); r7 = exca_getb(sc, map->sysmem_win); - printf("exca_do_mem_map win %d: %02x%02x %02x%02x " - "%02x%02x %02x (%08x+%06x.%06x*%06x)\n", + printf("exca_do_mem_map win %d: %#02x%#02x %#02x%#02x " + "%#02x%#02x %#02x (%#08x+%#06x.%#06x*%#06x) flags %#x\n", win, r1, r2, r3, r4, r5, r6, r7, mem->addr, mem->size, mem->realsize, - mem->cardaddr); + mem->cardaddr, mem->kind); } #endif } @@ -259,10 +256,18 @@ exca_mem_map(struct exca_softc *sc, int } if (win >= EXCA_MEM_WINS) return (ENOSPC); - if (((rman_get_start(res) >> EXCA_MEMREG_WIN_SHIFT) & 0xff) != 0 && - (sc->flags & EXCA_HAS_MEMREG_WIN) == 0) { - device_printf(sc->dev, "Does not support mapping above 24M."); - return (EINVAL); + if (sc->flags & EXCA_HAS_MEMREG_WIN) { + if (rman_get_start(res) >> (EXCA_MEMREG_WIN_SHIFT + 8) != 0) { + device_printf(sc->dev, + "Does not support mapping above 4GB."); + return (EINVAL); + } + } else { + if (rman_get_start(res) >> EXCA_MEMREG_WIN_SHIFT != 0) { + device_printf(sc->dev, + "Does not support mapping above 16M."); + return (EINVAL); + } } sc->mem[win].cardaddr = 0; From niclas.zeising at gmail.com Thu Feb 5 10:59:42 2009 From: niclas.zeising at gmail.com (Niclas Zeising) Date: Thu Feb 5 10:59:48 2009 Subject: svn commit: r188154 - head/sys/opencrypto In-Reply-To: <20090205.113516.113804072.imp@bsdimp.com> References: <200902051743.n15HhCMx033130@svn.freebsd.org> <498B2829.9000608@gmail.com> <20090205.113516.113804072.imp@bsdimp.com> Message-ID: <498B370F.5090805@gmail.com> M. Warner Losh wrote: > In message: <498B2829.9000608@gmail.com> > Niclas Zeising writes: > : Warner Losh wrote: > : > Author: imp > : > Date: Thu Feb 5 17:43:12 2009 > : > New Revision: 188154 > : > URL: http://svn.freebsd.org/changeset/base/188154 > : > > : > Log: > : > Fix return type for detach routine (should be int) > : > Fix first parameter for identify routine (should be driver_t *) > : > > : > Modified: > : > head/sys/opencrypto/cryptosoft.c > : > > : > Modified: head/sys/opencrypto/cryptosoft.c > : > ============================================================================== > : > --- head/sys/opencrypto/cryptosoft.c Thu Feb 5 15:09:42 2009 (r188153) > : > +++ head/sys/opencrypto/cryptosoft.c Thu Feb 5 17:43:12 2009 (r188154) > : > @@ -986,7 +986,7 @@ done: > : > } > : > > : > static void > : > -swcr_identify(device_t *dev, device_t parent) > : > +swcr_identify(driver_t *drv, device_t parent) > : ^^^ > : > : Was this name change intentional? > > Yes. It 'dev' is typically used for 'device_t' types. However, by > changing this to drv, it shows it isn't a device_t, and also breaks > any code that used the old variable with a compiler error. > > Warner Ok, thanks for the education and sorry for the noise :) Regards Niclas > > : > { > : > /* NB: order 10 is so we get attached after h/w devices */ > : > if (device_find_child(parent, "cryptosoft", -1) == NULL && > : > @@ -1040,12 +1040,13 @@ swcr_attach(device_t dev) > : > return 0; > : > } > : > > : > -static void > : > +static int > : > swcr_detach(device_t dev) > : > { > : > crypto_unregister_all(swcr_id); > : > if (swcr_sessions != NULL) > : > free(swcr_sessions, M_CRYPTO_DATA); > : > + return 0; > : > } > : > > : > static device_method_t swcr_methods[] = { > : > : Regards! > : //Niclas > : > : > From sam at FreeBSD.org Thu Feb 5 11:20:35 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 11:20:42 2009 Subject: svn commit: r188170 - head/sys/net80211 Message-ID: <200902051920.n15JKZwA035715@svn.freebsd.org> Author: sam Date: Thu Feb 5 19:20:34 2009 New Revision: 188170 URL: http://svn.freebsd.org/changeset/base/188170 Log: o add IEEE80211_KEY_BITS for %b printing of wk_flags o replace hand-rolled code to print wk_flags o add display of ni_ucastkey in show sta o fix \n in _db_show_key Modified: head/sys/net80211/ieee80211_crypto.h head/sys/net80211/ieee80211_ddb.c Modified: head/sys/net80211/ieee80211_crypto.h ============================================================================== --- head/sys/net80211/ieee80211_crypto.h Thu Feb 5 19:09:15 2009 (r188169) +++ head/sys/net80211/ieee80211_crypto.h Thu Feb 5 19:20:34 2009 (r188170) @@ -104,6 +104,10 @@ struct ieee80211_key { (IEEE80211_KEY_SWENCRYPT | IEEE80211_KEY_SWDECRYPT) #define IEEE80211_KEY_SWMIC (IEEE80211_KEY_SWENMIC | IEEE80211_KEY_SWDEMIC) +#define IEEE80211_KEY_BITS \ + "\20\1XMIT\2RECV\3GROUP\4SWENCRYPT\5SWDECRYPT\6SWENMIC\7SWDEMIC" \ + "\10DEVKEY\11CIPHER0\12CIPHER1" + #define IEEE80211_KEYIX_NONE ((ieee80211_keyix) -1) /* Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Thu Feb 5 19:09:15 2009 (r188169) +++ head/sys/net80211/ieee80211_ddb.c Thu Feb 5 19:20:34 2009 (r188170) @@ -219,6 +219,7 @@ _db_show_sta(const struct ieee80211_node ni->ni_rxfragstamp); db_printf("\trxfrag[0] %p rxfrag[1] %p rxfrag[2] %p\n", ni->ni_rxfrag[0], ni->ni_rxfrag[1], ni->ni_rxfrag[2]); + _db_show_key("\tucastkey", 0, &ni->ni_ucastkey); db_printf("\trstamp %u avgrssi 0x%x (rssi %d) noise %d\n", ni->ni_rstamp, ni->ni_avgrssi, IEEE80211_RSSI_GET(ni->ni_avgrssi), ni->ni_noise); @@ -670,6 +671,8 @@ _db_show_key(const char *tag, int ix, co cip->ic_cipher, wk->wk_keyix, 8*keylen); break; } + if (wk->wk_rxkeyix != wk->wk_keyix) + db_printf(" rxkeyix %u", wk->wk_rxkeyix); if (memcmp(wk->wk_key, zerodata, keylen) != 0) { int i; @@ -683,22 +686,9 @@ _db_show_key(const char *tag, int ix, co if (cip->ic_cipher != IEEE80211_CIPHER_WEP && wk->wk_keytsc != 0) db_printf(" tsc %ju", (uintmax_t)wk->wk_keytsc); - if (wk->wk_flags != 0) { - const char *sep = " "; - - if (wk->wk_flags & IEEE80211_KEY_XMIT) - db_printf("%stx", sep), sep = "+"; - if (wk->wk_flags & IEEE80211_KEY_RECV) - db_printf("%srx", sep), sep = "+"; - if (wk->wk_flags & IEEE80211_KEY_DEFAULT) - db_printf("%sdef", sep), sep = "+"; - if (wk->wk_flags & IEEE80211_KEY_SWCRYPT) - db_printf("%sswcrypt", sep), sep = "+"; - if (wk->wk_flags & IEEE80211_KEY_SWMIC) - db_printf("%sswmic", sep), sep = "+"; - } - db_printf("\n"); + db_printf(" flags=%b", wk->wk_flags, IEEE80211_KEY_BITS); } + db_printf("\n"); } static void From imp at FreeBSD.org Thu Feb 5 11:30:30 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:30:41 2009 Subject: svn commit: r188171 - head/sys/crypto/via Message-ID: <200902051930.n15JUS76035937@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:30:28 2009 New Revision: 188171 URL: http://svn.freebsd.org/changeset/base/188171 Log: identify routine takes driver_t *, not device_t *. Modified: head/sys/crypto/via/padlock.c Modified: head/sys/crypto/via/padlock.c ============================================================================== --- head/sys/crypto/via/padlock.c Thu Feb 5 19:20:34 2009 (r188170) +++ head/sys/crypto/via/padlock.c Thu Feb 5 19:30:28 2009 (r188171) @@ -72,7 +72,7 @@ static int padlock_process(device_t, str MALLOC_DEFINE(M_PADLOCK, "padlock_data", "PadLock Data"); static void -padlock_identify(device_t *dev, device_t parent) +padlock_identify(driver_t *drv, device_t parent) { /* NB: order 10 is so we get attached after h/w devices */ if (device_find_child(parent, "padlock", -1) == NULL && From imp at FreeBSD.org Thu Feb 5 11:30:56 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:31:02 2009 Subject: svn commit: r188172 - head/sys/dev/my Message-ID: <200902051930.n15JUtt9035979@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:30:55 2009 New Revision: 188172 URL: http://svn.freebsd.org/changeset/base/188172 Log: Shutdown returns an int. Modified: head/sys/dev/my/if_my.c Modified: head/sys/dev/my/if_my.c ============================================================================== --- head/sys/dev/my/if_my.c Thu Feb 5 19:30:28 2009 (r188171) +++ head/sys/dev/my/if_my.c Thu Feb 5 19:30:55 2009 (r188172) @@ -127,7 +127,7 @@ static void my_init(void *); static void my_init_locked(struct my_softc *); static void my_stop(struct my_softc *); static void my_watchdog(struct ifnet *); -static void my_shutdown(device_t); +static int my_shutdown(device_t); static int my_ifmedia_upd(struct ifnet *); static void my_ifmedia_sts(struct ifnet *, struct ifmediareq *); static u_int16_t my_phy_readreg(struct my_softc *, int); @@ -1753,7 +1753,7 @@ my_stop(struct my_softc * sc) * Stop all chip I/O so that the kernel's probe routines don't get confused * by errant DMAs when rebooting. */ -static void +static int my_shutdown(device_t dev) { struct my_softc *sc; @@ -1762,5 +1762,5 @@ my_shutdown(device_t dev) MY_LOCK(sc); my_stop(sc); MY_UNLOCK(sc); - return; + return 0; } From imp at FreeBSD.org Thu Feb 5 11:31:57 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:32:02 2009 Subject: svn commit: r188173 - head/sys/dev/ppc Message-ID: <200902051931.n15JVtnO036035@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:31:55 2009 New Revision: 188173 URL: http://svn.freebsd.org/changeset/base/188173 Log: reset_epp and ecp_sync both return int. Modified: head/sys/dev/ppc/ppc.c head/sys/dev/ppc/ppcvar.h Modified: head/sys/dev/ppc/ppc.c ============================================================================== --- head/sys/dev/ppc/ppc.c Thu Feb 5 19:30:55 2009 (r188172) +++ head/sys/dev/ppc/ppc.c Thu Feb 5 19:31:55 2009 (r188173) @@ -115,7 +115,7 @@ static char *ppc_epp_protocol[] = { " (E /* * ppc_ecp_sync() XXX */ -void +int ppc_ecp_sync(device_t dev) { int i, r; @@ -123,22 +123,22 @@ ppc_ecp_sync(device_t dev) PPC_ASSERT_LOCKED(ppc); if (!(ppc->ppc_avm & PPB_ECP) && !(ppc->ppc_dtm & PPB_ECP)) - return; + return 0; r = r_ecr(ppc); if ((r & 0xe0) != PPC_ECR_EPP) - return; + return 0; for (i = 0; i < 100; i++) { r = r_ecr(ppc); if (r & 0x1) - return; + return 0; DELAY(100); } device_printf(dev, "ECP sync failed as data still present in FIFO.\n"); - return; + return 0; } /* @@ -1613,7 +1613,7 @@ ppc_write(device_t dev, char *buf, int l return (EINVAL); } -void +int ppc_reset_epp(device_t dev) { struct ppc_data *ppc = DEVTOSOFTC(dev); @@ -1621,7 +1621,7 @@ ppc_reset_epp(device_t dev) PPC_ASSERT_LOCKED(ppc); ppc_reset_epp_timeout(ppc); - return; + return 0; } int Modified: head/sys/dev/ppc/ppcvar.h ============================================================================== --- head/sys/dev/ppc/ppcvar.h Thu Feb 5 19:30:55 2009 (r188172) +++ head/sys/dev/ppc/ppcvar.h Thu Feb 5 19:31:55 2009 (r188173) @@ -44,8 +44,8 @@ struct resource *ppc_alloc_resource(devi int *rid, u_long start, u_long end, u_long count, u_int flags); int ppc_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r); -void ppc_reset_epp(device_t); -void ppc_ecp_sync(device_t); +int ppc_reset_epp(device_t); +int ppc_ecp_sync(device_t); int ppc_setmode(device_t, int); extern devclass_t ppc_devclass; From imp at FreeBSD.org Thu Feb 5 11:32:35 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:32:47 2009 Subject: svn commit: r188174 - head/sys/dev/scc Message-ID: <200902051932.n15JWYMg036086@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:32:34 2009 New Revision: 188174 URL: http://svn.freebsd.org/changeset/base/188174 Log: Make iclear return int, since that matches all function definitions of it. Modified: head/sys/dev/scc/scc_if.m Modified: head/sys/dev/scc/scc_if.m ============================================================================== --- head/sys/dev/scc/scc_if.m Thu Feb 5 19:31:55 2009 (r188173) +++ head/sys/dev/scc/scc_if.m Thu Feb 5 19:32:34 2009 (r188174) @@ -66,7 +66,7 @@ METHOD int enabled { } DEFAULT default_enabled; # iclear() -METHOD void iclear { +METHOD int iclear { struct scc_softc *this; struct scc_chan *chan; }; From imp at FreeBSD.org Thu Feb 5 11:33:21 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:33:37 2009 Subject: svn commit: r188175 - head/sys/dev/nve Message-ID: <200902051933.n15JXKKe036149@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:33:20 2009 New Revision: 188175 URL: http://svn.freebsd.org/changeset/base/188175 Log: writereg returns an int. Modified: head/sys/dev/nve/if_nve.c Modified: head/sys/dev/nve/if_nve.c ============================================================================== --- head/sys/dev/nve/if_nve.c Thu Feb 5 19:32:34 2009 (r188174) +++ head/sys/dev/nve/if_nve.c Thu Feb 5 19:33:20 2009 (r188175) @@ -147,7 +147,7 @@ static int nve_ifmedia_upd(struct i static void nve_ifmedia_upd_locked(struct ifnet *); static void nve_ifmedia_sts(struct ifnet *, struct ifmediareq *); static int nve_miibus_readreg(device_t, int, int); -static void nve_miibus_writereg(device_t, int, int, int); +static int nve_miibus_writereg(device_t, int, int, int); static void nve_dmamap_cb(void *, bus_dma_segment_t *, int, int); static void nve_dmamap_tx_cb(void *, bus_dma_segment_t *, int, bus_size_t, int); @@ -1292,7 +1292,7 @@ nve_miibus_readreg(device_t dev, int phy } /* miibus Write PHY register wrapper - calls Nvidia API entry point */ -static void +static int nve_miibus_writereg(device_t dev, int phy, int reg, int data) { struct nve_softc *sc = device_get_softc(dev); @@ -1303,7 +1303,7 @@ nve_miibus_writereg(device_t dev, int ph DEBUGOUT(NVE_DEBUG_MII, "nve: nve_miibus_writereg - exit\n"); - return; + return 0; } /* Watchdog timer to prevent PHY lockups */ From imp at FreeBSD.org Thu Feb 5 11:33:36 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:33:48 2009 Subject: svn commit: r188176 - head/sys/dev/fxp Message-ID: <200902051933.n15JXZ2j036189@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:33:35 2009 New Revision: 188176 URL: http://svn.freebsd.org/changeset/base/188176 Log: writereg returns an int. Modified: head/sys/dev/fxp/if_fxp.c Modified: head/sys/dev/fxp/if_fxp.c ============================================================================== --- head/sys/dev/fxp/if_fxp.c Thu Feb 5 19:33:20 2009 (r188175) +++ head/sys/dev/fxp/if_fxp.c Thu Feb 5 19:33:35 2009 (r188176) @@ -255,7 +255,7 @@ static int fxp_serial_ifmedia_upd(struc static void fxp_serial_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); static int fxp_miibus_readreg(device_t dev, int phy, int reg); -static void fxp_miibus_writereg(device_t dev, int phy, int reg, +static int fxp_miibus_writereg(device_t dev, int phy, int reg, int value); static void fxp_load_ucode(struct fxp_softc *sc); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, @@ -2642,7 +2642,7 @@ fxp_miibus_readreg(device_t dev, int phy return (value & 0xffff); } -static void +static int fxp_miibus_writereg(device_t dev, int phy, int reg, int value) { struct fxp_softc *sc = device_get_softc(dev); @@ -2658,6 +2658,7 @@ fxp_miibus_writereg(device_t dev, int ph if (count <= 0) device_printf(dev, "fxp_miibus_writereg: timed out\n"); + return (0); } static int From imp at FreeBSD.org Thu Feb 5 11:36:15 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:36:20 2009 Subject: svn commit: r188177 - head/sys/dev/pcn Message-ID: <200902051936.n15JaEBE036282@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:36:14 2009 New Revision: 188177 URL: http://svn.freebsd.org/changeset/base/188177 Log: shutdown returns an int Modified: head/sys/dev/pcn/if_pcn.c Modified: head/sys/dev/pcn/if_pcn.c ============================================================================== --- head/sys/dev/pcn/if_pcn.c Thu Feb 5 19:33:35 2009 (r188176) +++ head/sys/dev/pcn/if_pcn.c Thu Feb 5 19:36:14 2009 (r188177) @@ -144,7 +144,7 @@ static void pcn_init(void *); static void pcn_init_locked(struct pcn_softc *); static void pcn_stop(struct pcn_softc *); static void pcn_watchdog(struct ifnet *); -static void pcn_shutdown(device_t); +static int pcn_shutdown(device_t); static int pcn_ifmedia_upd(struct ifnet *); static void pcn_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -1458,8 +1458,7 @@ pcn_watchdog(ifp) * RX and TX lists. */ static void -pcn_stop(sc) - struct pcn_softc *sc; +pcn_stop(struct pcn_softc *sc) { register int i; struct ifnet *ifp; @@ -1510,9 +1509,8 @@ pcn_stop(sc) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void -pcn_shutdown(dev) - device_t dev; +static int +pcn_shutdown(device_t dev) { struct pcn_softc *sc; @@ -1523,5 +1521,5 @@ pcn_shutdown(dev) pcn_stop(sc); PCN_UNLOCK(sc); - return; + return 0; } From imp at FreeBSD.org Thu Feb 5 11:37:50 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:38:04 2009 Subject: svn commit: r188178 - in head/sys/dev: hifn lmc safe Message-ID: <200902051937.n15JbnuC036350@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:37:49 2009 New Revision: 188178 URL: http://svn.freebsd.org/changeset/base/188178 Log: shutdown returns an int Modified: head/sys/dev/hifn/hifn7751.c head/sys/dev/lmc/if_lmc.c head/sys/dev/lmc/if_lmc.h head/sys/dev/safe/safe.c Modified: head/sys/dev/hifn/hifn7751.c ============================================================================== --- head/sys/dev/hifn/hifn7751.c Thu Feb 5 19:36:14 2009 (r188177) +++ head/sys/dev/hifn/hifn7751.c Thu Feb 5 19:37:49 2009 (r188178) @@ -98,7 +98,7 @@ static int hifn_attach(device_t); static int hifn_detach(device_t); static int hifn_suspend(device_t); static int hifn_resume(device_t); -static void hifn_shutdown(device_t); +static int hifn_shutdown(device_t); static int hifn_newsession(device_t, u_int32_t *, struct cryptoini *); static int hifn_freesession(device_t, u_int64_t); @@ -691,12 +691,13 @@ hifn_detach(device_t dev) * Stop all chip I/O so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int hifn_shutdown(device_t dev) { #ifdef notyet hifn_stop(device_get_softc(dev)); #endif + return (0); } /* Modified: head/sys/dev/lmc/if_lmc.c ============================================================================== --- head/sys/dev/lmc/if_lmc.c Thu Feb 5 19:36:14 2009 (r188177) +++ head/sys/dev/lmc/if_lmc.c Thu Feb 5 19:37:49 2009 (r188178) @@ -5643,10 +5643,11 @@ fbsd_detach(device_t dev) return 0; /* no error */ } -static void +static int fbsd_shutdown(device_t dev) { shutdown_card(device_get_softc(dev)); + return 0; } static int Modified: head/sys/dev/lmc/if_lmc.h ============================================================================== --- head/sys/dev/lmc/if_lmc.h Thu Feb 5 19:36:14 2009 (r188177) +++ head/sys/dev/lmc/if_lmc.h Thu Feb 5 19:37:49 2009 (r188178) @@ -1642,7 +1642,7 @@ static void detach_card(softc_t *); #ifdef __FreeBSD__ static int fbsd_probe(device_t); static int fbsd_detach(device_t); -static void fbsd_shutdown(device_t); +static int fbsd_shutdown(device_t); static int fbsd_attach(device_t); #endif /* __FreeBSD__ */ Modified: head/sys/dev/safe/safe.c ============================================================================== --- head/sys/dev/safe/safe.c Thu Feb 5 19:36:14 2009 (r188177) +++ head/sys/dev/safe/safe.c Thu Feb 5 19:37:49 2009 (r188178) @@ -84,7 +84,7 @@ static int safe_attach(device_t); static int safe_detach(device_t); static int safe_suspend(device_t); static int safe_resume(device_t); -static void safe_shutdown(device_t); +static int safe_shutdown(device_t); static int safe_newsession(device_t, u_int32_t *, struct cryptoini *); static int safe_freesession(device_t, u_int64_t); @@ -503,12 +503,13 @@ safe_detach(device_t dev) * Stop all chip i/o so that the kernel's probe routines don't * get confused by errant DMAs when rebooting. */ -static void +static int safe_shutdown(device_t dev) { #ifdef notyet safe_stop(device_get_softc(dev)); #endif + return (0); } /* From imp at FreeBSD.org Thu Feb 5 11:38:32 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:38:44 2009 Subject: svn commit: r188179 - head/sys/dev/pccard Message-ID: <200902051938.n15JcVRh036405@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:38:31 2009 New Revision: 188179 URL: http://svn.freebsd.org/changeset/base/188179 Log: Fix parameter types for set_res_flags and read_ivars Modified: head/sys/dev/pccard/pccard.c Modified: head/sys/dev/pccard/pccard.c ============================================================================== --- head/sys/dev/pccard/pccard.c Thu Feb 5 19:37:49 2009 (r188178) +++ head/sys/dev/pccard/pccard.c Thu Feb 5 19:38:31 2009 (r188179) @@ -105,14 +105,14 @@ static int pccard_get_resource(device_t static void pccard_delete_resource(device_t dev, device_t child, int type, int rid); static int pccard_set_res_flags(device_t dev, device_t child, int type, - int rid, uint32_t flags); + int rid, u_long flags); static int pccard_set_memory_offset(device_t dev, device_t child, int rid, uint32_t offset, uint32_t *deltap); static int pccard_probe_and_attach_child(device_t dev, device_t child, struct pccard_function *pf); static void pccard_probe_nomatch(device_t cbdev, device_t child); static int pccard_read_ivar(device_t bus, device_t child, int which, - u_char *result); + uintptr_t *result); static void pccard_driver_added(device_t dev, driver_t *driver); static struct resource *pccard_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, @@ -972,7 +972,7 @@ pccard_delete_resource(device_t dev, dev static int pccard_set_res_flags(device_t dev, device_t child, int type, int rid, - uint32_t flags) + u_long flags) { return (CARD_SET_RES_FLAGS(device_get_parent(dev), child, type, rid, flags)); @@ -1055,7 +1055,7 @@ pccard_child_pnpinfo_str(device_t bus, d } static int -pccard_read_ivar(device_t bus, device_t child, int which, u_char *result) +pccard_read_ivar(device_t bus, device_t child, int which, uintptr_t *result) { struct pccard_ivar *devi = PCCARD_IVAR(child); struct pccard_function *pf = devi->pf; From imp at FreeBSD.org Thu Feb 5 11:39:08 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 11:39:19 2009 Subject: svn commit: r188180 - head/sys/dev/pccard Message-ID: <200902051939.n15Jd70M036458@svn.freebsd.org> Author: imp Date: Thu Feb 5 19:39:07 2009 New Revision: 188180 URL: http://svn.freebsd.org/changeset/base/188180 Log: do_product_lookup should return a const struct pccard_product *. Modified: head/sys/dev/pccard/card_if.m Modified: head/sys/dev/pccard/card_if.m ============================================================================== --- head/sys/dev/pccard/card_if.m Thu Feb 5 19:38:31 2009 (r188179) +++ head/sys/dev/pccard/card_if.m Thu Feb 5 19:39:07 2009 (r188180) @@ -93,7 +93,7 @@ METHOD int detach_card { # # Find "dev" in the passed table of devices. Return it or NULL. # -METHOD struct pccard_product * do_product_lookup { +METHOD const struct pccard_product * do_product_lookup { device_t bus; device_t dev; const struct pccard_product *tab; From sam at FreeBSD.org Thu Feb 5 12:26:54 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:27:04 2009 Subject: svn commit: r188182 - head/sys/net80211 Message-ID: <200902052026.n15KQrmK037481@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:26:53 2009 New Revision: 188182 URL: http://svn.freebsd.org/changeset/base/188182 Log: o change _db_show_key to always dump the contents instead of checking IEEE80211_KEY_DEVKEY o fix channel power printing (they are signed values) o add show statab to dump a node table and automatically dump the sta table of a com structure with /s Modified: head/sys/net80211/ieee80211_ddb.c Modified: head/sys/net80211/ieee80211_ddb.c ============================================================================== --- head/sys/net80211/ieee80211_ddb.c Thu Feb 5 20:13:51 2009 (r188181) +++ head/sys/net80211/ieee80211_ddb.c Thu Feb 5 20:26:53 2009 (r188182) @@ -61,6 +61,8 @@ static void _db_show_vap(const struct ie static void _db_show_com(const struct ieee80211com *, int showvaps, int showsta, int showprocs); +static void _db_show_node_table(const char *tag, + const struct ieee80211_node_table *); static void _db_show_channel(const char *tag, const struct ieee80211_channel *); static void _db_show_ssid(const char *tag, int ix, int len, const uint8_t *); static void _db_show_appie(const char *tag, const struct ieee80211_appie *); @@ -80,6 +82,15 @@ DB_SHOW_COMMAND(sta, db_show_sta) _db_show_sta((const struct ieee80211_node *) addr); } +DB_SHOW_COMMAND(statab, db_show_statab) +{ + if (!have_addr) { + db_printf("usage: show statab \n"); + return; + } + _db_show_node_table("", (const struct ieee80211_node_table *) addr); +} + DB_SHOW_COMMAND(vap, db_show_vap) { int i, showprocs = 0; @@ -509,9 +520,12 @@ _db_show_com(const struct ieee80211com * db_printf("\n"); db_printf("\tmax_keyix %d", ic->ic_max_keyix); - db_printf(" sta %p", &ic->ic_sta); db_printf(" wme %p", &ic->ic_wme); + if (!showsta) + db_printf(" sta %p", &ic->ic_sta); db_printf("\n"); + if (showsta) + _db_show_node_table("\t", &ic->ic_sta); db_printf("\tprotmode %d", ic->ic_protmode); db_printf(" nonerpsta %u", ic->ic_nonerpsta); @@ -576,6 +590,26 @@ _db_show_com(const struct ieee80211com * } static void +_db_show_node_table(const char *tag, const struct ieee80211_node_table *nt) +{ + int i; + + db_printf("%s%s@%p:\n", tag, nt->nt_name, nt); + db_printf("%s nodelock %p", tag, &nt->nt_nodelock); + db_printf(" inact_init %d", nt->nt_inact_init); + db_printf(" scanlock %p", &nt->nt_scanlock); + db_printf(" scangen %u\n", nt->nt_scangen); + db_printf("%s keyixmax %d keyixmap %p\n", + tag, nt->nt_keyixmax, nt->nt_keyixmap); + for (i = 0; i < nt->nt_keyixmax; i++) { + const struct ieee80211_node *ni = nt->nt_keyixmap[i]; + if (ni != NULL) + db_printf("%s [%3u] %p %s\n", tag, i, ni, + ether_sprintf(ni->ni_macaddr)); + } +} + +static void _db_show_channel(const char *tag, const struct ieee80211_channel *c) { db_printf("%s ", tag); @@ -584,7 +618,7 @@ _db_show_channel(const char *tag, const else if (c == IEEE80211_CHAN_ANYC) db_printf(""); else - db_printf("[%u (%u) flags=%b maxreg %u maxpow %u minpow %u state 0x%x extieee %u]", + db_printf("[%u (%u) flags=%b maxreg %d maxpow %d minpow %d state 0x%x extieee %u]", c->ic_freq, c->ic_ieee, c->ic_flags, IEEE80211_CHAN_BITS, c->ic_maxregpower, c->ic_maxpower, c->ic_minpower, @@ -639,8 +673,6 @@ _db_show_key(const char *tag, int ix, co const struct ieee80211_cipher *cip = wk->wk_cipher; int keylen = wk->wk_keylen; - if ((wk->wk_flags & IEEE80211_KEY_DEVKEY) == 0) - return; db_printf(tag, ix); switch (cip->ic_cipher) { case IEEE80211_CIPHER_WEP: From sam at FreeBSD.org Thu Feb 5 12:39:54 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:40:00 2009 Subject: svn commit: r188187 - head/tools/tools/net80211/wlanstats Message-ID: <200902052039.n15KdrmU038027@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:39:53 2009 New Revision: 188187 URL: http://svn.freebsd.org/changeset/base/188187 Log: o fix identification of ahdemo mode o split out code to get the bssid for use in the future o include more information in error diags when unable to collect sta info/stats Modified: head/tools/tools/net80211/wlanstats/wlanstats.c Modified: head/tools/tools/net80211/wlanstats/wlanstats.c ============================================================================== --- head/tools/tools/net80211/wlanstats/wlanstats.c Thu Feb 5 20:37:07 2009 (r188186) +++ head/tools/tools/net80211/wlanstats/wlanstats.c Thu Feb 5 20:39:53 2009 (r188187) @@ -390,9 +390,12 @@ wlan_getopmode(struct wlanstatfoo *wf0) strlcpy(ifmr.ifm_name, wf->ifr.ifr_name, sizeof(ifmr.ifm_name)); if (ioctl(wf->s, SIOCGIFMEDIA, &ifmr) < 0) err(1, "%s (SIOCGIFMEDIA)", wf->ifr.ifr_name); - if (ifmr.ifm_current & IFM_IEEE80211_ADHOC) - wf->opmode = IEEE80211_M_IBSS; /* XXX ahdemo */ - else if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP) + if (ifmr.ifm_current & IFM_IEEE80211_ADHOC) { + if (ifmr.ifm_current & IFM_FLAG0) + wf->opmode = IEEE80211_M_AHDEMO; + else + wf->opmode = IEEE80211_M_IBSS; + } else if (ifmr.ifm_current & IFM_IEEE80211_HOSTAP) wf->opmode = IEEE80211_M_HOSTAP; else if (ifmr.ifm_current & IFM_IEEE80211_MONITOR) wf->opmode = IEEE80211_M_MONITOR; @@ -422,6 +425,15 @@ getlladdr(struct wlanstatfoo_p *wf) freeifaddrs(ifp); } +static int +getbssid(struct wlanstatfoo_p *wf) +{ + wf->ireq.i_type = IEEE80211_IOC_BSSID; + wf->ireq.i_data = wf->mac; + wf->ireq.i_len = IEEE80211_ADDR_LEN; + return ioctl(wf->s, SIOCG80211, &wf->ireq); +} + static void wlan_setstamac(struct wlanstatfoo *wf0, const uint8_t *mac) { @@ -436,11 +448,9 @@ wlan_setstamac(struct wlanstatfoo *wf0, getlladdr(wf); break; case IEEE80211_M_STA: - wf->ireq.i_type = IEEE80211_IOC_BSSID; - wf->ireq.i_data = wf->mac; - wf->ireq.i_len = IEEE80211_ADDR_LEN; - if (ioctl(wf->s, SIOCG80211, &wf->ireq) <0) - err(1, "%s (IEEE80211_IOC_BSSID)", wf->ireq.i_name); + if (getbssid(wf) < 0) + err(1, "%s (IEEE80211_IOC_BSSID)", + wf->ireq.i_name); break; } } else @@ -457,15 +467,18 @@ wlan_collect(struct wlanstatfoo_p *wf, wf->ireq.i_type = IEEE80211_IOC_STA_INFO; wf->ireq.i_data = (caddr_t) &wf->u_info; wf->ireq.i_len = sizeof(wf->u_info); - if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0) - warn("%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name); + if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0) { + warn("%s:%s (IEEE80211_IOC_STA_INFO)", wf->ireq.i_name, + ether_ntoa((const struct ether_addr*) wf->mac)); + } IEEE80211_ADDR_COPY(nstats->is_u.macaddr, wf->mac); wf->ireq.i_type = IEEE80211_IOC_STA_STATS; wf->ireq.i_data = (caddr_t) nstats; wf->ireq.i_len = sizeof(*nstats); if (ioctl(wf->s, SIOCG80211, &wf->ireq) < 0) - warn("%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name); + warn("%s:%s (IEEE80211_IOC_STA_STATS)", wf->ireq.i_name, + ether_ntoa((const struct ether_addr*) wf->mac)); wf->ifr.ifr_data = (caddr_t) stats; if (ioctl(wf->s, SIOCG80211STATS, &wf->ifr) < 0) From imp at FreeBSD.org Thu Feb 5 12:44:07 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 12:44:18 2009 Subject: svn commit: r188190 - head/sys/dev/exca Message-ID: <200902052044.n15Ki6CM038265@svn.freebsd.org> Author: imp Date: Thu Feb 5 20:44:06 2009 New Revision: 188190 URL: http://svn.freebsd.org/changeset/base/188190 Log: Don't check for mapping above 4GB on 32-bit platforms. Modified: head/sys/dev/exca/exca.c Modified: head/sys/dev/exca/exca.c ============================================================================== --- head/sys/dev/exca/exca.c Thu Feb 5 20:43:47 2009 (r188189) +++ head/sys/dev/exca/exca.c Thu Feb 5 20:44:06 2009 (r188190) @@ -257,11 +257,13 @@ exca_mem_map(struct exca_softc *sc, int if (win >= EXCA_MEM_WINS) return (ENOSPC); if (sc->flags & EXCA_HAS_MEMREG_WIN) { +#ifdef _LP64 if (rman_get_start(res) >> (EXCA_MEMREG_WIN_SHIFT + 8) != 0) { device_printf(sc->dev, "Does not support mapping above 4GB."); return (EINVAL); } +#endif } else { if (rman_get_start(res) >> EXCA_MEMREG_WIN_SHIFT != 0) { device_printf(sc->dev, From sam at FreeBSD.org Thu Feb 5 12:48:31 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:48:43 2009 Subject: svn commit: r188191 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902052048.n15KmUvP038381@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:48:30 2009 New Revision: 188191 URL: http://svn.freebsd.org/changeset/base/188191 Log: replace r/w idiom with OS_REG_SET_BIT (to match other code) Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:44:06 2009 (r188190) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:48:30 2009 (r188191) @@ -990,9 +990,8 @@ ar5212PerCalibrationN(struct ath_hal *ah if (powerMeasI && powerMeasQ) break; /* Do we really need this??? */ - OS_REG_WRITE (ah, AR_PHY_TIMING_CTRL4, - OS_REG_READ(ah, AR_PHY_TIMING_CTRL4) | - AR_PHY_TIMING_CTRL4_DO_IQCAL); + OS_REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4, + AR_PHY_TIMING_CTRL4_DO_IQCAL); } while (++i < IQ_CAL_TRIES); /* From sam at FreeBSD.org Thu Feb 5 12:49:14 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:49:25 2009 Subject: svn commit: r188192 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902052049.n15KnD28038435@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:49:13 2009 New Revision: 188192 URL: http://svn.freebsd.org/changeset/base/188192 Log: style Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:48:30 2009 (r188191) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:49:13 2009 (r188192) @@ -1047,7 +1047,8 @@ ar5212PerCalibrationN(struct ath_hal *ah ichan->iCoff = iCoff; ichan->qCoff = qCoff; } - } else if (!IEEE80211_IS_CHAN_B(chan) && ahp->ah_bIQCalibration == IQ_CAL_DONE && + } else if (!IEEE80211_IS_CHAN_B(chan) && + ahp->ah_bIQCalibration == IQ_CAL_DONE && (ichan->privFlags & CHANNEL_IQVALID) == 0) { /* * Start IQ calibration if configured channel has changed. From sam at FreeBSD.org Thu Feb 5 12:51:53 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:52:26 2009 Subject: svn commit: r188193 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902052051.n15Kprce038517@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:51:53 2009 New Revision: 188193 URL: http://svn.freebsd.org/changeset/base/188193 Log: fill in ar5212ResetCalValid; reset the IQ valid flag on the channel so IQ calibration will be started on the next periodic cal Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:49:13 2009 (r188192) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:51:53 2009 (r188193) @@ -1089,7 +1089,16 @@ ar5212PerCalibration(struct ath_hal *ah, HAL_BOOL ar5212ResetCalValid(struct ath_hal *ah, const struct ieee80211_channel *chan) { - /* XXX */ + HAL_CHANNEL_INTERNAL *ichan; + + ichan = ath_hal_checkchannel(ah, chan); + if (ichan == AH_NULL) { + HALDEBUG(ah, HAL_DEBUG_ANY, + "%s: invalid channel %u/0x%x; no mapping\n", + __func__, chan->ic_freq, chan->ic_flags); + return AH_FALSE; + } + ichan->privFlags &= ~CHANNEL_IQVALID; return AH_TRUE; } From sam at FreeBSD.org Thu Feb 5 12:56:34 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 12:56:41 2009 Subject: svn commit: r188194 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902052056.n15KuX6X038751@svn.freebsd.org> Author: sam Date: Thu Feb 5 20:56:33 2009 New Revision: 188194 URL: http://svn.freebsd.org/changeset/base/188194 Log: improve IQ cal debug msgs; in particular don't scare people by screaming "MISGATED IQ CAL!" when it's not Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:51:53 2009 (r188193) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_reset.c Thu Feb 5 20:56:33 2009 (r188194) @@ -994,6 +994,12 @@ ar5212PerCalibrationN(struct ath_hal *ah AR_PHY_TIMING_CTRL4_DO_IQCAL); } while (++i < IQ_CAL_TRIES); + HALDEBUG(ah, HAL_DEBUG_PERCAL, + "%s: IQ cal finished: %d tries\n", __func__, i); + HALDEBUG(ah, HAL_DEBUG_PERCAL, + "%s: powerMeasI %u powerMeasQ %u iqCorrMeas %d\n", + __func__, powerMeasI, powerMeasQ, iqCorrMeas); + /* * Prescale these values to remove 64-bit operation * requirement at the loss of a little precision. @@ -1020,19 +1026,7 @@ ar5212PerCalibrationN(struct ath_hal *ah } HALDEBUG(ah, HAL_DEBUG_PERCAL, - "****************** MISGATED IQ CAL! *******************\n"); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "time = %d, i = %d, \n", OS_GETUPTIME(ah), i); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "powerMeasI = 0x%08x\n", powerMeasI); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "powerMeasQ = 0x%08x\n", powerMeasQ); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "iqCorrMeas = 0x%08x\n", iqCorrMeas); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "iCoff = %d\n", iCoff); - HALDEBUG(ah, HAL_DEBUG_PERCAL, - "qCoff = %d\n", qCoff); + "%s: iCoff %d qCoff %d\n", __func__, iCoff, qCoff); /* Write values and enable correction */ OS_REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4, From sam at FreeBSD.org Thu Feb 5 13:02:41 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 13:02:48 2009 Subject: svn commit: r188195 - head/sys/dev/ath Message-ID: <200902052102.n15L2ejF038929@svn.freebsd.org> Author: sam Date: Thu Feb 5 21:02:40 2009 New Revision: 188195 URL: http://svn.freebsd.org/changeset/base/188195 Log: Minor packet drop improvements: o change tdma packet drop msg when ack required to ATH_DEBUG_TDMA (ATH_DEBUG_XMIT is too noisy) o add a debug msg for raw packet drop due to interface down/invalid o add stats for these two cases o explain how another drop case is handled Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_athioctl.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Thu Feb 5 20:56:33 2009 (r188194) +++ head/sys/dev/ath/if_ath.c Thu Feb 5 21:02:40 2009 (r188195) @@ -4994,9 +4994,9 @@ ath_tx_start(struct ath_softc *sc, struc sc->sc_stats.ast_tx_noack++; #ifdef ATH_SUPPORT_TDMA if (sc->sc_tdma && (flags & HAL_TXDESC_NOACK) == 0) { - DPRINTF(sc, ATH_DEBUG_XMIT, "%s: ACK required w/ TDMA\n", - __func__); - /* XXX statistic */ + DPRINTF(sc, ATH_DEBUG_TDMA, + "%s: discard frame, ACK required w/ TDMA\n", __func__); + sc->sc_stats.ast_tdma_ack++; ath_freetx(m0); return EIO; } @@ -7198,6 +7198,10 @@ ath_raw_xmit(struct ieee80211_node *ni, struct ath_buf *bf; if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 || sc->sc_invalid) { + DPRINTF(sc, ATH_DEBUG_XMIT, "%s: discard frame, %s", __func__, + (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ? + "!running" : "invalid"); + sc->sc_stats.ast_tx_raw_fail++; ieee80211_free_node(ni); m_freem(m); return ENETDOWN; @@ -7207,6 +7211,7 @@ ath_raw_xmit(struct ieee80211_node *ni, */ bf = ath_getbuf(sc); if (bf == NULL) { + /* NB: ath_getbuf handles stat+msg */ ieee80211_free_node(ni); m_freem(m); return ENOBUFS; Modified: head/sys/dev/ath/if_athioctl.h ============================================================================== --- head/sys/dev/ath/if_athioctl.h Thu Feb 5 20:56:33 2009 (r188194) +++ head/sys/dev/ath/if_athioctl.h Thu Feb 5 21:02:40 2009 (r188195) @@ -115,7 +115,9 @@ struct ath_stats { u_int32_t ast_tdma_tsf; /* TDMA slot update set TSF */ u_int16_t ast_tdma_tsfadjp;/* TDMA slot adjust+ (usec, smoothed)*/ u_int16_t ast_tdma_tsfadjm;/* TDMA slot adjust- (usec, smoothed)*/ - u_int32_t ast_pad[17]; + u_int32_t ast_tdma_ack; /* TDMA tx failed 'cuz ACK required */ + u_int32_t ast_tx_raw_fail;/* raw tx failed 'cuz h/w down */ + u_int32_t ast_pad[15]; }; #define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) From sam at FreeBSD.org Thu Feb 5 13:09:47 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 13:09:53 2009 Subject: svn commit: r188196 - head/tools/tools/ath/athstats Message-ID: <200902052109.n15L9klk039093@svn.freebsd.org> Author: sam Date: Thu Feb 5 21:09:46 2009 New Revision: 188196 URL: http://svn.freebsd.org/changeset/base/188196 Log: add new stats and missing tx_raw stat Modified: head/tools/tools/ath/athstats/athstats.c Modified: head/tools/tools/ath/athstats/athstats.c ============================================================================== --- head/tools/tools/ath/athstats/athstats.c Thu Feb 5 21:02:40 2009 (r188195) +++ head/tools/tools/ath/athstats/athstats.c Thu Feb 5 21:09:46 2009 (r188196) @@ -217,7 +217,9 @@ static const struct fmt athstats[] = { { 5, "tdmat", "tdmat", "TDMA slot update set TSF" }, #define S_TDMA_TSFADJ AFTER(S_TDMA_TSF) { 8, "tdmadj", "tdmadj", "TDMA slot adjust (usecs, smoothed)" }, -#define S_RATE_CALLS AFTER(S_TDMA_TSFADJ) +#define S_TDMA_ACK AFTER(S_TDMA_TSFADJ) + { 5, "tdmack", "tdmack", "TDMA tx failed 'cuz ACK required" }, +#define S_RATE_CALLS AFTER(S_TDMA_ACK) #else #define S_RATE_CALLS AFTER(S_PER_RFGAIN) #endif @@ -236,7 +238,9 @@ static const struct fmt athstats[] = { { 5, "bmissphantom", "bmissphantom", "phantom beacon misses" }, #define S_TX_RAW AFTER(S_BMISS_PHANTOM) { 5, "txraw", "txraw", "tx frames through raw api" }, -#define S_RX_TOOBIG AFTER(S_TX_RAW) +#define S_TX_RAW_FAIL AFTER(S_TX_RAW) + { 5, "txrawfail", "txrawfail", "raw tx failed 'cuz interface/hw down" }, +#define S_RX_TOOBIG AFTER(S_TX_RAW_FAIL) { 5, "rx2big", "rx2big", "rx failed 'cuz frame too large" }, #ifndef __linux__ #define S_CABQ_XMIT AFTER(S_RX_TOOBIG) @@ -557,6 +561,8 @@ ath_get_curstat(struct statfoo *sf, int case S_TX_SHORTPRE: STAT(tx_shortpre); case S_TX_ALTRATE: STAT(tx_altrate); case S_TX_PROTECT: STAT(tx_protect); + case S_TX_RAW: STAT(tx_raw); + case S_TX_RAW_FAIL: STAT(tx_raw_fail); case S_RX_NOMBUF: STAT(rx_nombuf); #ifdef S_RX_BUSDMA case S_RX_BUSDMA: STAT(rx_busdma); @@ -609,6 +615,7 @@ ath_get_curstat(struct statfoo *sf, int snprintf(b, bs, "-%d/+%d", wf->cur.ath.ast_tdma_tsfadjm, wf->cur.ath.ast_tdma_tsfadjp); return 1; + case S_TDMA_ACK: STAT(tdma_ack); #endif case S_RATE_CALLS: STAT(rate_calls); case S_RATE_RAISE: STAT(rate_raise); @@ -771,6 +778,8 @@ ath_get_totstat(struct statfoo *sf, int case S_TX_SHORTPRE: STAT(tx_shortpre); case S_TX_ALTRATE: STAT(tx_altrate); case S_TX_PROTECT: STAT(tx_protect); + case S_TX_RAW: STAT(tx_raw); + case S_TX_RAW_FAIL: STAT(tx_raw_fail); case S_RX_NOMBUF: STAT(rx_nombuf); #ifdef S_RX_BUSDMA case S_RX_BUSDMA: STAT(rx_busdma); @@ -824,6 +833,7 @@ ath_get_totstat(struct statfoo *sf, int wf->total.ath.ast_tdma_tsfadjm, wf->total.ath.ast_tdma_tsfadjp); return 1; + case S_TDMA_ACK: STAT(tdma_ack); #endif case S_RATE_CALLS: STAT(rate_calls); case S_RATE_RAISE: STAT(rate_raise); From sam at FreeBSD.org Thu Feb 5 13:13:31 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 13:13:44 2009 Subject: svn commit: r188197 - head/sys/dev/ath/ath_hal/ar5212 Message-ID: <200902052113.n15LDVxT039271@svn.freebsd.org> Author: sam Date: Thu Feb 5 21:13:31 2009 New Revision: 188197 URL: http://svn.freebsd.org/changeset/base/188197 Log: eliminate gainFCorrection; just have ar5212GetGainFCorrection return the calculated value as it's only used in one place Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h head/sys/dev/ath/ath_hal/ar5212/ar5212_rfgain.c Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212.h Thu Feb 5 21:09:46 2009 (r188196) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212.h Thu Feb 5 21:13:31 2009 (r188197) @@ -122,7 +122,6 @@ typedef struct { uint32_t targetGain; uint32_t loTrig; uint32_t hiTrig; - uint32_t gainFCorrection; uint32_t active; const GAIN_OPTIMIZATION_STEP *currStep; } GAIN_VALUES; Modified: head/sys/dev/ath/ath_hal/ar5212/ar5212_rfgain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5212/ar5212_rfgain.c Thu Feb 5 21:09:46 2009 (r188196) +++ head/sys/dev/ath/ath_hal/ar5212/ar5212_rfgain.c Thu Feb 5 21:13:31 2009 (r188197) @@ -239,34 +239,36 @@ ar5212AdjustGain(struct ath_hal *ah, GAI /* * Read rf register to determine if gainF needs correction */ -static void +static uint32_t ar5212GetGainFCorrection(struct ath_hal *ah) { struct ath_hal_5212 *ahp = AH5212(ah); - GAIN_VALUES *gv = &ahp->ah_gainValues; + uint32_t correction; HALASSERT(IS_RADX112_REV2(ah)); - gv->gainFCorrection = 0; + correction = 0; if (ar5212GetRfField(ar5212GetRfBank(ah, 7), 1, 36, 0) == 1) { + const GAIN_VALUES *gv = &ahp->ah_gainValues; uint32_t mixGain = gv->currStep->paramVal[0]; uint32_t gainStep = ar5212GetRfField(ar5212GetRfBank(ah, 7), 4, 32, 0); switch (mixGain) { case 0 : - gv->gainFCorrection = 0; + correction = 0; break; case 1 : - gv->gainFCorrection = gainStep; + correction = gainStep; break; case 2 : - gv->gainFCorrection = 2 * gainStep - 5; + correction = 2 * gainStep - 5; break; case 3 : - gv->gainFCorrection = 2 * gainStep; + correction = 2 * gainStep; break; } } + return correction; } /* @@ -303,9 +305,9 @@ ar5212GetRfgain(struct ath_hal *ah) gv->currGain += PHY_PROBE_CCK_CORRECTION; } if (IS_RADX112_REV2(ah)) { - ar5212GetGainFCorrection(ah); - if (gv->currGain >= gv->gainFCorrection) - gv->currGain -= gv->gainFCorrection; + uint32_t correct = ar5212GetGainFCorrection(ah); + if (gv->currGain >= correct) + gv->currGain -= correct; else gv->currGain = 0; } From kmacy at FreeBSD.org Thu Feb 5 13:18:39 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Thu Feb 5 13:18:45 2009 Subject: svn commit: r188198 - head/sys/dev/xen/netfront Message-ID: <200902052118.n15LIdTp039423@svn.freebsd.org> Author: kmacy Date: Thu Feb 5 21:18:39 2009 New Revision: 188198 URL: http://svn.freebsd.org/changeset/base/188198 Log: fix non-witness compile Modified: head/sys/dev/xen/netfront/netfront.c Modified: head/sys/dev/xen/netfront/netfront.c ============================================================================== --- head/sys/dev/xen/netfront/netfront.c Thu Feb 5 21:13:31 2009 (r188197) +++ head/sys/dev/xen/netfront/netfront.c Thu Feb 5 21:18:39 2009 (r188198) @@ -24,6 +24,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include From kmacy at FreeBSD.org Thu Feb 5 13:35:41 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Thu Feb 5 13:35:47 2009 Subject: svn commit: r188199 - head/sys/i386/i386 Message-ID: <200902052135.n15LZeCR039770@svn.freebsd.org> Author: kmacy Date: Thu Feb 5 21:35:40 2009 New Revision: 188199 URL: http://svn.freebsd.org/changeset/base/188199 Log: reboot instance on reset Modified: head/sys/i386/i386/vm_machdep.c Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Thu Feb 5 21:18:39 2009 (r188198) +++ head/sys/i386/i386/vm_machdep.c Thu Feb 5 21:35:40 2009 (r188199) @@ -616,7 +616,10 @@ cpu_reset_real() disable_intr(); #ifdef XEN - HYPERVISOR_shutdown(SHUTDOWN_poweroff); + if (smp_processor_id() == 0) + HYPERVISOR_shutdown(SHUTDOWN_reboot); + else + HYPERVISOR_shutdown(SHUTDOWN_reboot); #endif #ifdef CPU_ELAN if (elan_mmcr != NULL) From kmacy at FreeBSD.org Thu Feb 5 13:41:28 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Thu Feb 5 13:41:38 2009 Subject: svn commit: r188200 - head/sys/i386/i386 Message-ID: <200902052141.n15LfRnB039904@svn.freebsd.org> Author: kmacy Date: Thu Feb 5 21:41:27 2009 New Revision: 188200 URL: http://svn.freebsd.org/changeset/base/188200 Log: halt APs on reboot Modified: head/sys/i386/i386/vm_machdep.c Modified: head/sys/i386/i386/vm_machdep.c ============================================================================== --- head/sys/i386/i386/vm_machdep.c Thu Feb 5 21:35:40 2009 (r188199) +++ head/sys/i386/i386/vm_machdep.c Thu Feb 5 21:41:27 2009 (r188200) @@ -619,7 +619,7 @@ cpu_reset_real() if (smp_processor_id() == 0) HYPERVISOR_shutdown(SHUTDOWN_reboot); else - HYPERVISOR_shutdown(SHUTDOWN_reboot); + HYPERVISOR_shutdown(SHUTDOWN_poweroff); #endif #ifdef CPU_ELAN if (elan_mmcr != NULL) From sam at FreeBSD.org Thu Feb 5 14:16:10 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 14:16:21 2009 Subject: svn commit: r188205 - head/tools/tools/ath/athstats Message-ID: <200902052216.n15MG9uV040888@svn.freebsd.org> Author: sam Date: Thu Feb 5 22:16:09 2009 New Revision: 188205 URL: http://svn.freebsd.org/changeset/base/188205 Log: unbreak -o Modified: head/tools/tools/ath/athstats/main.c Modified: head/tools/tools/ath/athstats/main.c ============================================================================== --- head/tools/tools/ath/athstats/main.c Thu Feb 5 22:06:41 2009 (r188204) +++ head/tools/tools/ath/athstats/main.c Thu Feb 5 22:16:09 2009 (r188205) @@ -72,8 +72,7 @@ getfmt(const char *tag) for (i = 0; i < N(tags); i++) if (strcasecmp(tags[i].tag, tag) == 0) return tags[i].fmt; - errx(-1, "unknown tag \%s\"", tag); - /*NOTREACHED*/ + return tag; #undef N } From sam at FreeBSD.org Thu Feb 5 14:17:13 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 14:17:25 2009 Subject: svn commit: r188206 - head/tools/tools/net80211/wlanstats Message-ID: <200902052217.n15MHBxL040943@svn.freebsd.org> Author: sam Date: Thu Feb 5 22:17:10 2009 New Revision: 188206 URL: http://svn.freebsd.org/changeset/base/188206 Log: make -o handling like athstats Modified: head/tools/tools/net80211/wlanstats/main.c Modified: head/tools/tools/net80211/wlanstats/main.c ============================================================================== --- head/tools/tools/net80211/wlanstats/main.c Thu Feb 5 22:16:09 2009 (r188205) +++ head/tools/tools/net80211/wlanstats/main.c Thu Feb 5 22:17:10 2009 (r188206) @@ -48,10 +48,30 @@ #include "wlanstats.h" -#define S_DEFAULT \ - "input,rx_mgmt,output,rx_badkeyid,scan_active,scan_bg,bmiss,rssi,noise,rate" -#define S_AMPDU \ - "input,output,ampdu_reorder,ampdu_oor,rx_dup,ampdu_flush,ampdu_move,ampdu_drop,ampdu_bar,ampdu_baroow,ampdu_barmove,rssi,rate" +static struct { + const char *tag; + const char *fmt; +} tags[] = { + { "default", + "input,rx_mgmt,output,rx_badkeyid,scan_active,scan_bg,bmiss,rssi,noise,rate" + }, + { "ampdu", + "input,output,ampdu_reorder,ampdu_oor,rx_dup,ampdu_flush,ampdu_move," + "ampdu_drop,ampdu_bar,ampdu_baroow,ampdu_barmove,rssi,rate" + }, +}; + +static const char * +getfmt(const char *tag) +{ +#define N(a) (sizeof(a)/sizeof(a[0])) + int i; + for (i = 0; i < N(tags); i++) + if (strcasecmp(tags[i].tag, tag) == 0) + return tags[i].fmt; + return tag; +#undef N +} static int signalled; @@ -138,10 +158,14 @@ main(int argc, char *argv[]) struct wlanstatfoo *wf; struct ether_addr *ea; const uint8_t *mac = NULL; + const char *ifname; int allnodes = 0; int c, mode; - wf = wlanstats_new("wlan0", S_DEFAULT); + ifname = getenv("WLAN"); + if (ifname == NULL) + ifname = "wlan0"; + wf = wlanstats_new(ifname, getfmt("default")); while ((c = getopt(argc, argv, "ai:lm:o:")) != -1) { switch (c) { case 'a': @@ -160,10 +184,7 @@ main(int argc, char *argv[]) mac = ea->octet; break; case 'o': - if (strcasecmp(optarg, "ampdu") == 0) - wf->setfmt(wf, S_AMPDU); - else - wf->setfmt(wf, optarg); + wf->setfmt(wf, getfmt(optarg)); break; default: errx(-1, "usage: %s [-a] [-i ifname] [-l] [-o fmt] [interval]\n", argv[0]); From jhb at FreeBSD.org Thu Feb 5 15:01:37 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Feb 5 15:01:48 2009 Subject: svn commit: r188209 - head/sys/kern Message-ID: <200902052301.n15N1a04041963@svn.freebsd.org> Author: jhb Date: Thu Feb 5 23:01:36 2009 New Revision: 188209 URL: http://svn.freebsd.org/changeset/base/188209 Log: Drop the kernel linker lock while running SYSUNINIT routines and removing sysctls during a linker file unload. We drop the lock when doing similar operations during a linker file load. To close races, clear the LINKED flag before dropping the lock so that the linker file is no longer visible to userland. MFC after: 1 week Modified: head/sys/kern/kern_linker.c Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Thu Feb 5 22:19:13 2009 (r188208) +++ head/sys/kern/kern_linker.c Thu Feb 5 23:01:36 2009 (r188209) @@ -643,8 +643,11 @@ linker_file_unload(linker_file_t file, i * link error. */ if (file->flags & LINKER_FILE_LINKED) { + file->flags &= ~LINKER_FILE_LINKED; + KLD_UNLOCK(); linker_file_sysuninit(file); linker_file_unregister_sysctls(file); + KLD_LOCK(); } TAILQ_REMOVE(&linker_files, file, link); From sam at FreeBSD.org Thu Feb 5 15:15:41 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 15:15:52 2009 Subject: svn commit: r188210 - head/tools/tools/net80211/wlanstats Message-ID: <200902052315.n15NFewu042235@svn.freebsd.org> Author: sam Date: Thu Feb 5 23:15:39 2009 New Revision: 188210 URL: http://svn.freebsd.org/changeset/base/188210 Log: for adhoc and ahdemo modes try to find the "bss node": use the bssid unless it's not setup or zero's; this may not work as the bssid of the ibss isn't certain to the "right mac address" but for many cases it is Modified: head/tools/tools/net80211/wlanstats/wlanstats.c Modified: head/tools/tools/net80211/wlanstats/wlanstats.c ============================================================================== --- head/tools/tools/net80211/wlanstats/wlanstats.c Thu Feb 5 23:01:36 2009 (r188209) +++ head/tools/tools/net80211/wlanstats/wlanstats.c Thu Feb 5 23:15:39 2009 (r188210) @@ -437,15 +437,24 @@ getbssid(struct wlanstatfoo_p *wf) static void wlan_setstamac(struct wlanstatfoo *wf0, const uint8_t *mac) { + static const uint8_t zeromac[IEEE80211_ADDR_LEN]; struct wlanstatfoo_p *wf = (struct wlanstatfoo_p *) wf0; if (mac == NULL) { switch (wlan_getopmode(wf0)) { case IEEE80211_M_HOSTAP: case IEEE80211_M_MONITOR: + getlladdr(wf); + break; case IEEE80211_M_IBSS: case IEEE80211_M_AHDEMO: - getlladdr(wf); + /* + * NB: this may not work in which case the + * mac must be specified on the command line + */ + if (getbssid(wf) < 0 || + IEEE80211_ADDR_EQ(wf->mac, zeromac)) + getlladdr(wf); break; case IEEE80211_M_STA: if (getbssid(wf) < 0) From wkoszek at FreeBSD.org Thu Feb 5 15:51:12 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Thu Feb 5 15:51:25 2009 Subject: svn commit: r188212 - head/sys/dev/pccard Message-ID: <200902052351.n15NpBKq042945@svn.freebsd.org> Author: wkoszek Date: Thu Feb 5 23:51:11 2009 New Revision: 188212 URL: http://svn.freebsd.org/changeset/base/188212 Log: Bring consistent debugging output for all values that are supposed to be printed in a hexadecimal format. Otherwise, '270' doesn't say much. Reviewed by: imp Modified: head/sys/dev/pccard/pccard.c head/sys/dev/pccard/pccard_cis.c Modified: head/sys/dev/pccard/pccard.c ============================================================================== --- head/sys/dev/pccard/pccard.c Thu Feb 5 23:16:33 2009 (r188211) +++ head/sys/dev/pccard/pccard.c Thu Feb 5 23:51:11 2009 (r188212) @@ -173,7 +173,7 @@ pccard_set_default_descr(device_t dev) if (pccard_get_product(dev, &prod)) return (0); str = malloc(100, M_DEVBUF, M_WAITOK); - snprintf(str, 100, "vendor=0x%x product=0x%x", vendor, prod); + snprintf(str, 100, "vendor=%#x product=%#x", vendor, prod); device_set_desc_copy(dev, str); free(str, M_DEVBUF); } @@ -297,8 +297,8 @@ pccard_probe_and_attach_child(device_t d if (pccard_function_enable(pf) == 0 && pccard_set_default_descr(child) == 0 && device_attach(child) == 0) { - DEVPRINTF((sc->dev, "function %d CCR at %d offset %x mask %x: " - "%x %x %x %x, %x %x %x %x, %x\n", + DEVPRINTF((sc->dev, "function %d CCR at %d offset %#x " + "mask %#x: %#x %#x %#x %#x, %#x %#x %#x %#x, %#x\n", pf->number, pf->pf_ccr_window, pf->pf_ccr_offset, pf->ccr_mask, pccard_ccr_read(pf, 0x00), pccard_ccr_read(pf, 0x02), pccard_ccr_read(pf, 0x04), @@ -506,7 +506,7 @@ pccard_function_init(struct pccard_funct end = start + cfe->iospace[i].length - 1; else end = ~0UL; - DEVPRINTF((bus, "I/O rid %d start %lx end %lx\n", + DEVPRINTF((bus, "I/O rid %d start %#lx end %#lx\n", i, start, end)); rid = i; len = cfe->iospace[i].length; @@ -528,7 +528,7 @@ pccard_function_init(struct pccard_funct end = start + cfe->memspace[i].length - 1; else end = ~0UL; - DEVPRINTF((bus, "Memory rid %d start %lx end %lx\n", + DEVPRINTF((bus, "Memory rid %d start %#lx end %#lx\n", i, start, end)); rid = i; len = cfe->memspace[i].length; @@ -594,7 +594,7 @@ pccard_function_free(struct pccard_funct device_printf(pf->sc->dev, "function_free: Resource still owned by " "child, oops. " - "(type=%d, rid=%d, addr=%lx)\n", + "(type=%d, rid=%d, addr=%#lx)\n", rle->type, rle->rid, rman_get_start(rle->res)); BUS_RELEASE_RESOURCE(device_get_parent(pf->sc->dev), @@ -689,7 +689,7 @@ pccard_function_enable(struct pccard_fun &pf->ccr_rid, 0, ~0, PCCARD_MEM_PAGE_SIZE, RF_ACTIVE); if (!pf->ccr_res) goto bad; - DEVPRINTF((dev, "ccr_res == %lx-%lx, base=%x\n", + DEVPRINTF((dev, "ccr_res == %#lx-%#lx, base=%#x\n", rman_get_start(pf->ccr_res), rman_get_end(pf->ccr_res), pf->ccr_base)); CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, @@ -726,8 +726,8 @@ pccard_function_enable(struct pccard_fun if (pccard_debug) { STAILQ_FOREACH(tmp, &pf->sc->card.pf_head, pf_list) { device_printf(tmp->sc->dev, - "function %d CCR at %d offset %x: " - "%x %x %x %x, %x %x %x %x, %x\n", + "function %d CCR at %d offset %#x: " + "%#x %#x %#x %#x, %#x %#x %#x %#x, %#x\n", tmp->number, tmp->pf_ccr_window, tmp->pf_ccr_offset, pccard_ccr_read(tmp, 0x00), @@ -1185,7 +1185,7 @@ pccard_release_resource(device_t dev, de if (!rle) { device_printf(dev, "Allocated resource not found, " - "%d %x %lx %lx\n", + "%d %#x %#lx %#lx\n", type, rid, rman_get_start(r), rman_get_size(r)); return ENOENT; } Modified: head/sys/dev/pccard/pccard_cis.c ============================================================================== --- head/sys/dev/pccard/pccard_cis.c Thu Feb 5 23:16:33 2009 (r188211) +++ head/sys/dev/pccard/pccard_cis.c Thu Feb 5 23:51:11 2009 (r188212) @@ -151,7 +151,7 @@ pccard_scan_cis(device_t bus, device_t d tuple.memh = rman_get_bushandle(res); tuple.ptr = 0; - DPRINTF(("cis mem map 0x%x (resource: 0x%lx)\n", + DPRINTF(("cis mem map %#x (resource: %#lx)\n", (unsigned int) tuple.memh, rman_get_start(res))); tuple.mult = 2; @@ -230,7 +230,7 @@ pccard_scan_cis(device_t bus, device_t d longlink_common = (tuple.code == CISTPL_LONGLINK_C) ? 1 : 0; longlink_addr = pccard_tuple_read_4(&tuple, 0); - DPRINTF(("CISTPL_LONGLINK_%s %lx\n", + DPRINTF(("CISTPL_LONGLINK_%s %#lx\n", longlink_common ? "C" : "A", longlink_addr)); break; @@ -264,8 +264,8 @@ pccard_scan_cis(device_t bus, device_t d addr = tuple.ptr + offset; - DPRINTF(("CISTPL_CHECKSUM addr=%lx " - "len=%lx cksum=%x", + DPRINTF(("CISTPL_CHECKSUM addr=%#lx " + "len=%#lx cksum=%#x", addr, length, cksum)); /* @@ -286,7 +286,7 @@ pccard_scan_cis(device_t bus, device_t d tuple.memh, addr + tuple.mult * i); if (cksum != (sum & 0xff)) { - DPRINTF((" failed sum=%x\n", + DPRINTF((" failed sum=%#x\n", sum)); device_printf(dev, "CIS checksum failed\n"); @@ -361,7 +361,7 @@ pccard_scan_cis(device_t bus, device_t d mfc[i].addr = pccard_tuple_read_4(&tuple, 1 + 5 * i + 1); - DPRINTF((" %s:%lx", + DPRINTF((" %s:%#lx", mfc[i].common ? "common" : "attr", mfc[i].addr)); } @@ -386,11 +386,11 @@ pccard_scan_cis(device_t bus, device_t d { int i; - DPRINTF((" %02x %02x", tuple.code, + DPRINTF((" %#02x %#02x", tuple.code, tuple.length)); for (i = 0; i < tuple.length; i++) { - DPRINTF((" %02x", + DPRINTF((" %#02x", pccard_tuple_read_1(&tuple, i))); if ((i % 16) == 13) DPRINTF(("\n")); @@ -416,7 +416,7 @@ pccard_scan_cis(device_t bus, device_t d CARD_SET_RES_FLAGS(bus, dev, SYS_RES_MEMORY, rid, longlink_common ? PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); - DPRINTF(("cis mem map %x\n", + DPRINTF(("cis mem map %#x\n", (unsigned int) tuple.memh)); tuple.mult = longlink_common ? 1 : 2; tuple.ptr = longlink_addr; @@ -427,7 +427,7 @@ pccard_scan_cis(device_t bus, device_t d CARD_SET_RES_FLAGS(bus, dev, SYS_RES_MEMORY, rid, mfc[mfc_index].common ? PCCARD_A_MEM_COM : PCCARD_A_MEM_ATTR); - DPRINTF(("cis mem map %x\n", + DPRINTF(("cis mem map %#x\n", (unsigned int) tuple.memh)); /* set parse state, and point at the next one */ tuple.mult = mfc[mfc_index].common ? 1 : 2; @@ -441,7 +441,7 @@ pccard_scan_cis(device_t bus, device_t d tuple.code = pccard_cis_read_1(&tuple, tuple.ptr); if (tuple.code != CISTPL_LINKTARGET) { DPRINTF(("CISTPL_LINKTARGET expected, " - "code %02x observed\n", tuple.code)); + "code %#02x observed\n", tuple.code)); continue; } tuple.length = pccard_cis_read_1(&tuple, tuple.ptr + 1); @@ -504,7 +504,7 @@ pccard_print_cis(device_t dev) } printf("\n"); - device_printf(dev, "Manufacturer code 0x%x, product 0x%x\n", + device_printf(dev, "Manufacturer code %#x, product %#x\n", card->manufacturer, card->product); STAILQ_FOREACH(pf, &card->pf_head, pf_list) { @@ -552,7 +552,7 @@ pccard_print_cis(device_t dev) break; } - printf(", ccr addr %x mask %x\n", pf->ccr_base, pf->ccr_mask); + printf(", ccr addr %#x mask %#x\n", pf->ccr_base, pf->ccr_mask); STAILQ_FOREACH(cfe, &pf->cfe_head, cfe_list) { device_printf(dev, "function %d, config table entry " @@ -570,15 +570,15 @@ pccard_print_cis(device_t dev) break; } - printf("; irq mask %x", cfe->irqmask); + printf("; irq mask %#x", cfe->irqmask); if (cfe->num_iospace) { - printf("; iomask %lx, iospace", cfe->iomask); + printf("; iomask %#lx, iospace", cfe->iomask); for (i = 0; i < cfe->num_iospace; i++) { - printf(" %lx", cfe->iospace[i].start); + printf(" %#lx", cfe->iospace[i].start); if (cfe->iospace[i].length) - printf("-%lx", + printf("-%#lx", cfe->iospace[i].start + cfe->iospace[i].length - 1); } @@ -587,14 +587,14 @@ pccard_print_cis(device_t dev) printf("; memspace"); for (i = 0; i < cfe->num_memspace; i++) { - printf(" %lx", + printf(" %#lx", cfe->memspace[i].cardaddr); if (cfe->memspace[i].length) - printf("-%lx", + printf("-%#lx", cfe->memspace[i].cardaddr + cfe->memspace[i].length - 1); if (cfe->memspace[i].hostaddr) - printf("@%lx", + printf("@%#lx", cfe->memspace[i].hostaddr); } } @@ -1264,7 +1264,7 @@ pccard_parse_cis_tuple(const struct pcca DPRINTF(("CISTPL_CFTABLE_ENTRY\n")); break; default: - DPRINTF(("unhandled CISTPL %x\n", tuple->code)); + DPRINTF(("unhandled CISTPL %#x\n", tuple->code)); break; } From sam at FreeBSD.org Thu Feb 5 16:48:57 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Thu Feb 5 16:49:38 2009 Subject: svn commit: r188213 - head/sys/dev/ath/ath_hal Message-ID: <200902060048.n160muWY044106@svn.freebsd.org> Author: sam Date: Fri Feb 6 00:48:56 2009 New Revision: 188213 URL: http://svn.freebsd.org/changeset/base/188213 Log: add PSB channels to the calibration list Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain.c Thu Feb 5 23:51:11 2009 (r188212) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Fri Feb 6 00:48:56 2009 (r188213) @@ -1026,9 +1026,18 @@ static REG_DOMAIN regDomains[] = { {.regDmnEnum = DEBUG_REG_DMN, .conformanceTestLimit = FCC, .dfsMask = DFS_FCC3, - .chan11a = BM3(F1_5120_5240, F1_5260_5700, F1_5745_5825), - .chan11a_half = BM3(F2_5120_5240, F2_5260_5700, F7_5745_5825), - .chan11a_quarter = BM3(F3_5120_5240, F3_5260_5700, F8_5745_5825), + .chan11a = BM4(F1_4950_4980, + F1_5120_5240, + F1_5260_5700, + F1_5745_5825), + .chan11a_half = BM4(F1_4945_4985, + F2_5120_5240, + F2_5260_5700, + F7_5745_5825), + .chan11a_quarter = BM4(F1_4942_4987, + F3_5120_5240, + F3_5260_5700, + F8_5745_5825), .chan11a_turbo = BM8(T1_5130_5210, T1_5250_5330, T1_5370_5490, From wkoszek at FreeBSD.org Thu Feb 5 16:50:22 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Thu Feb 5 16:50:49 2009 Subject: svn commit: r188214 - head/usr.sbin/config Message-ID: <200902060050.n160oLBS044185@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 00:50:21 2009 New Revision: 188214 URL: http://svn.freebsd.org/changeset/base/188214 Log: Make config -x only return non-zero characters, so that: config -x | grep just works. Reported by: Danny Braniss Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Fri Feb 6 00:48:56 2009 (r188213) +++ head/usr.sbin/config/main.c Fri Feb 6 00:50:21 2009 (r188214) @@ -669,7 +669,7 @@ kernconfdump(const char *file) struct stat st; FILE *fp, *pp; int error, len, osz, r; - unsigned int off, size; + unsigned int i, off, size; char *cmd, *o; r = open(file, O_RDONLY); @@ -707,7 +707,18 @@ kernconfdump(const char *file) r = fseek(fp, off, SEEK_CUR); if (r != 0) errx(EXIT_FAILURE, "fseek() failed"); - while ((r = fgetc(fp)) != EOF && size-- > 0) + for (i = 0; i < size - 1; i++) { + r = fgetc(fp); + if (r == EOF) + break; + /* + * If '\0' is present in the middle of the configuration + * string, this means something very weird is happening. + * Make such case very visible. + */ + assert(r != '\0' && ("Char present in the configuration " + "string mustn't be equal to 0")); fputc(r, stdout); + } fclose(fp); } From wkoszek at FreeBSD.org Thu Feb 5 16:55:20 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Thu Feb 5 16:55:27 2009 Subject: svn commit: r188216 - head/sys/dev/cardbus Message-ID: <200902060055.n160tKn0044348@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 00:55:19 2009 New Revision: 188216 URL: http://svn.freebsd.org/changeset/base/188216 Log: Remove unused variable. Found with: Coverity Prevent(tm) CID: 4138 Modified: head/sys/dev/cardbus/cardbus_device.c Modified: head/sys/dev/cardbus/cardbus_device.c ============================================================================== --- head/sys/dev/cardbus/cardbus_device.c Fri Feb 6 00:50:46 2009 (r188215) +++ head/sys/dev/cardbus/cardbus_device.c Fri Feb 6 00:55:19 2009 (r188216) @@ -98,12 +98,10 @@ static int cardbus_device_buffer_cis(device_t parent, device_t child, struct cis_buffer *cbp) { - struct cardbus_softc *sc; struct tuple_callbacks cb[] = { {CISTPL_GENERIC, "GENERIC", cardbus_build_cis} }; - sc = device_get_softc(parent); return (cardbus_parse_cis(parent, child, cb, cbp)); } From rodrigc at FreeBSD.org Thu Feb 5 23:42:22 2009 From: rodrigc at FreeBSD.org (Craig Rodrigues) Date: Thu Feb 5 23:42:34 2009 Subject: svn commit: r188217 - head/sbin/mount_nfs Message-ID: <200902060742.n167gLGj053426@svn.freebsd.org> Author: rodrigc Date: Fri Feb 6 07:42:21 2009 New Revision: 188217 URL: http://svn.freebsd.org/changeset/base/188217 Log: Set NFSMNT_ACREGMIN, NFSMNT_ACREGMAX, and NFSMNT_ACDIRMIN flags in fallback_mount() function. Add a comment to indicate that the fallback_mount() function should eventually go away. Submitted by: Jaakko Heinonen Modified: head/sbin/mount_nfs/mount_nfs.c Modified: head/sbin/mount_nfs/mount_nfs.c ============================================================================== --- head/sbin/mount_nfs/mount_nfs.c Fri Feb 6 00:55:19 2009 (r188216) +++ head/sbin/mount_nfs/mount_nfs.c Fri Feb 6 07:42:21 2009 (r188217) @@ -469,6 +469,12 @@ copyopt(struct iovec **newiov, int *newi build_iovec(newiov, newiovlen, name, value, len); } +/* + * XXX: This function is provided for backwards + * compatibility with older kernels which did not support + * passing NFS mount options to nmount() as individual + * parameters. It should be eventually be removed. + */ int fallback_mount(struct iovec *iov, int iovlen, int mntflags) { @@ -587,18 +593,21 @@ fallback_mount(struct iovec *iov, int io if (ret != 1 || args.acregmin < 0) { errx(1, "illegal acregmin: %s", opt); } + args.flags |= NFSMNT_ACREGMIN; } if (findopt(iov, iovlen, "acregmax", &opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.acregmax); if (ret != 1 || args.acregmax < 0) { errx(1, "illegal acregmax: %s", opt); } + args.flags |= NFSMNT_ACREGMAX; } if (findopt(iov, iovlen, "acdirmin", &opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.acdirmin); if (ret != 1 || args.acdirmin < 0) { errx(1, "illegal acdirmin: %s", opt); } + args.flags |= NFSMNT_ACDIRMIN; } if (findopt(iov, iovlen, "acdirmax", &opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.acdirmax); From rodrigc at FreeBSD.org Thu Feb 5 23:47:54 2009 From: rodrigc at FreeBSD.org (Craig Rodrigues) Date: Thu Feb 5 23:48:05 2009 Subject: svn commit: r188218 - head/sbin/mount_nfs Message-ID: <200902060747.n167lrPB053568@svn.freebsd.org> Author: rodrigc Date: Fri Feb 6 07:47:53 2009 New Revision: 188218 URL: http://svn.freebsd.org/changeset/base/188218 Log: Set NFSMNT_ACDIRMAX flag in fallback_mount() function. Modified: head/sbin/mount_nfs/mount_nfs.c Modified: head/sbin/mount_nfs/mount_nfs.c ============================================================================== --- head/sbin/mount_nfs/mount_nfs.c Fri Feb 6 07:42:21 2009 (r188217) +++ head/sbin/mount_nfs/mount_nfs.c Fri Feb 6 07:47:53 2009 (r188218) @@ -614,6 +614,7 @@ fallback_mount(struct iovec *iov, int io if (ret != 1 || args.acdirmax < 0) { errx(1, "illegal acdirmax: %s", opt); } + args.flags |= NFSMNT_ACDIRMAX; } if (findopt(iov, iovlen, "deadthresh", &opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.deadthresh); From imp at FreeBSD.org Thu Feb 5 23:49:04 2009 From: imp at FreeBSD.org (Warner Losh) Date: Thu Feb 5 23:49:15 2009 Subject: svn commit: r188219 - head/sys/dev/pccard Message-ID: <200902060749.n167n3DZ053641@svn.freebsd.org> Author: imp Date: Fri Feb 6 07:49:03 2009 New Revision: 188219 URL: http://svn.freebsd.org/changeset/base/188219 Log: Store the entire funce for disk type functions (eg CF cards and the like). Modified: head/sys/dev/pccard/pccard_cis.c head/sys/dev/pccard/pccardvarp.h Modified: head/sys/dev/pccard/pccard_cis.c ============================================================================== --- head/sys/dev/pccard/pccard_cis.c Fri Feb 6 07:47:53 2009 (r188218) +++ head/sys/dev/pccard/pccard_cis.c Fri Feb 6 07:49:03 2009 (r188219) @@ -1283,6 +1283,8 @@ decode_funce(const struct pccard_tuple * if (type == PCCARD_TPLFE_TYPE_DISK_DEVICE_INTERFACE) { pf->pf_funce_disk_interface = pccard_tuple_read_1(tuple, 1); + pf->pf_funce_disk_power + = pccard_tuple_read_1(tuple, 2); } break; case PCCARD_FUNCTION_NETWORK: Modified: head/sys/dev/pccard/pccardvarp.h ============================================================================== --- head/sys/dev/pccard/pccardvarp.h Fri Feb 6 07:47:53 2009 (r188218) +++ head/sys/dev/pccard/pccardvarp.h Fri Feb 6 07:49:03 2009 (r188219) @@ -75,7 +75,23 @@ struct pccard_config_entry { }; struct pccard_funce_disk { - int pfd_interface; + uint8_t pfd_interface; +#define PFD_I_V_MASK 0x3 +#define PFD_I_V_NONE_REQUIRED 0x0 +#define PFD_I_V_REQ_MOD_ACC 0x1 +#define PFD_I_V_REQ_ACC 0x2 +#define PFD_I_V_REQ_ALWYS 0x1 +#define PFD_I_S 0x4 /* 0 rotating, 1 silicon */ +#define PFD_I_U 0x8 /* SN Uniq? */ +#define PFD_I_D 0x10 /* 0 - 1 drive, 1 - 2 drives */ + uint8_t pfd_power; +#define PFD_P_P0 0x1 +#define PFD_P_P1 0x2 +#define PFD_P_P2 0x4 +#define PFD_P_P3 0x8 +#define PFD_P_N 0x10 /* 3f7/377 excluded? */ +#define PFD_P_E 0x20 /* Index bit supported? */ +#define PFD_P_I 0x40 /* twincard */ }; struct pccard_funce_lan { @@ -119,6 +135,7 @@ struct pccard_function { union pccard_funce pf_funce; /* CISTPL_FUNCE */ #define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface +#define pf_funce_disk_power pf_funce.pfv_disk.pfd_power #define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid #define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen }; From imp at FreeBSD.org Fri Feb 6 01:34:18 2009 From: imp at FreeBSD.org (Warner Losh) Date: Fri Feb 6 01:34:24 2009 Subject: svn commit: r188220 - head/sys/dev/exca Message-ID: <200902060934.n169YIgk055606@svn.freebsd.org> Author: imp Date: Fri Feb 6 09:34:17 2009 New Revision: 188220 URL: http://svn.freebsd.org/changeset/base/188220 Log: fix spelling error Submitted by: trasz Modified: head/sys/dev/exca/exca.c Modified: head/sys/dev/exca/exca.c ============================================================================== --- head/sys/dev/exca/exca.c Fri Feb 6 07:49:03 2009 (r188219) +++ head/sys/dev/exca/exca.c Fri Feb 6 09:34:17 2009 (r188220) @@ -210,7 +210,7 @@ exca_do_mem_map(struct exca_softc *sc, i EXCA_CARDMEM_ADDRX_MSB_ADDR_MASK) | attrmem); DPRINTF("%s %d-bit memory", - mem->kind & PCCARD_MEM_ATTR ? "attrubute" : "common", + mem->kind & PCCARD_MEM_ATTR ? "attribute" : "common", mem->kind & PCCARD_MEM_16BIT ? 16 : 8); exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->memenable | EXCA_ADDRWIN_ENABLE_MEMCS16); From wkoszek at FreeBSD.org Fri Feb 6 02:30:47 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 02:30:59 2009 Subject: svn commit: r188221 - head/sys/conf Message-ID: <200902061030.n16AUknS058570@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 10:30:46 2009 New Revision: 188221 URL: http://svn.freebsd.org/changeset/base/188221 Log: Consistently use instead of spaces as option name and file separator. Modified: head/sys/conf/options head/sys/conf/options.mips Modified: head/sys/conf/options ============================================================================== --- head/sys/conf/options Fri Feb 6 09:34:17 2009 (r188220) +++ head/sys/conf/options Fri Feb 6 10:30:46 2009 (r188221) @@ -36,7 +36,7 @@ AHC_TMODE_ENABLE opt_aic7xxx.h AHC_DUMP_EEPROM opt_aic7xxx.h AHC_DEBUG opt_aic7xxx.h AHC_DEBUG_OPTS opt_aic7xxx.h -AHC_REG_PRETTY_PRINT opt_aic7xxx.h +AHC_REG_PRETTY_PRINT opt_aic7xxx.h AHD_DEBUG opt_aic79xx.h AHD_DEBUG_OPTS opt_aic79xx.h AHD_TMODE_ENABLE opt_aic79xx.h @@ -137,7 +137,7 @@ NSWBUF_MIN opt_swap.h MBUF_PACKET_ZONE_DISABLE opt_global.h PANIC_REBOOT_WAIT_TIME opt_panic.h PPC_DEBUG opt_ppc.h -PPC_PROBE_CHIPSET opt_ppc.h +PPC_PROBE_CHIPSET opt_ppc.h PPS_SYNC opt_ntp.h PREEMPTION opt_sched.h QUOTA @@ -424,13 +424,13 @@ XBONEHACK # SCTP opt_sctp.h SCTP_DEBUG opt_sctp.h # Enable debug printfs -SCTP_WITH_NO_CSUM opt_sctp.h # Use this at your peril -SCTP_LOCK_LOGGING opt_sctp.h # Log to KTR lock activity -SCTP_MBUF_LOGGING opt_sctp.h # Log to KTR general mbuf aloc/free +SCTP_WITH_NO_CSUM opt_sctp.h # Use this at your peril +SCTP_LOCK_LOGGING opt_sctp.h # Log to KTR lock activity +SCTP_MBUF_LOGGING opt_sctp.h # Log to KTR general mbuf aloc/free SCTP_MBCNT_LOGGING opt_sctp.h # Log to KTR mbcnt activity -SCTP_PACKET_LOGGING opt_sctp.h # Log to a packet buffer last N packets -SCTP_LTRACE_CHUNKS opt_sctp.h # Log to KTR chunks processed -SCTP_LTRACE_ERRORS opt_sctp.h # Log to KTR error returns. +SCTP_PACKET_LOGGING opt_sctp.h # Log to a packet buffer last N packets +SCTP_LTRACE_CHUNKS opt_sctp.h # Log to KTR chunks processed +SCTP_LTRACE_ERRORS opt_sctp.h # Log to KTR error returns. # # # Modified: head/sys/conf/options.mips ============================================================================== --- head/sys/conf/options.mips Fri Feb 6 09:34:17 2009 (r188220) +++ head/sys/conf/options.mips Fri Feb 6 10:30:46 2009 (r188221) @@ -48,7 +48,7 @@ CFE_CONSOLE opt_global.h KERNPHYSADDR opt_global.h KERNVIRTADDR opt_global.h PHYSADDR opt_global.h -SOFTFLOAT opt_global.h +SOFTFLOAT opt_global.h TARGET_OCTEON opt_global.h TARGET_EMULATOR opt_ddb.h From jhb at FreeBSD.org Fri Feb 6 06:51:33 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 06:51:40 2009 Subject: svn commit: r188232 - in head/sys: kern sys Message-ID: <200902061451.n16EpWoJ064143@svn.freebsd.org> Author: jhb Date: Fri Feb 6 14:51:32 2009 New Revision: 188232 URL: http://svn.freebsd.org/changeset/base/188232 Log: Expand the scope of the sysctllock sx lock to protect the sysctl tree itself. Back in 1.1 of kern_sysctl.c the sysctl() routine wired the "old" userland buffer for most sysctls (everything except kern.vnode.*). I think to prevent issues with wiring too much memory it used a 'memlock' to serialize all sysctl(2) invocations, meaning that only one user buffer could be wired at a time. In 5.0 the 'memlock' was converted to an sx lock and renamed to 'sysctl lock'. However, it still only served the purpose of serializing sysctls to avoid wiring too much memory and didn't actually protect the sysctl tree as its name suggested. These changes expand the lock to actually protect the tree. Later on in 5.0, sysctl was changed to not wire buffers for requests by default (sysctl_handle_opaque() will still wire buffers larger than a single page, however). As a result, user buffers are no longer wired as often. However, many sysctl handlers still wire user buffers, so it is still desirable to serialize userland sysctl requests. Kernel sysctl requests are allowed to run in parallel, however. - Expose sysctl_lock()/sysctl_unlock() routines to exclusively lock the sysctl tree for a few places outside of kern_sysctl.c that manipulate the sysctl tree directly including the kernel linker and vfs_register(). - sysctl_register() and sysctl_unregister() require the caller to lock the sysctl lock using sysctl_lock() and sysctl_unlock(). The rest of the public sysctl API manage the locking internally. - Add a locked variant of sysctl_remove_oid() for internal use so that external uses of the API do not need to be aware of locking requirements. - The kernel linker no longer needs Giant when manipulating the sysctl tree. - Add a missing break to the loop in vfs_register() so that we stop looking at the sysctl MIB once we have changed it. MFC after: 1 month Modified: head/sys/kern/kern_linker.c head/sys/kern/kern_sysctl.c head/sys/kern/vfs_init.c head/sys/sys/sysctl.h Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Fri Feb 6 12:39:42 2009 (r188231) +++ head/sys/kern/kern_linker.c Fri Feb 6 14:51:32 2009 (r188232) @@ -293,10 +293,10 @@ linker_file_register_sysctls(linker_file if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_register_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static void @@ -310,10 +310,10 @@ linker_file_unregister_sysctls(linker_fi if (linker_file_lookup_set(lf, "sysctl_set", &start, &stop, NULL) != 0) return; - mtx_lock(&Giant); + sysctl_lock(); for (oidp = start; oidp < stop; oidp++) sysctl_unregister_oid(*oidp); - mtx_unlock(&Giant); + sysctl_unlock(); } static int Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Fri Feb 6 12:39:42 2009 (r188231) +++ head/sys/kern/kern_sysctl.c Fri Feb 6 14:51:32 2009 (r188232) @@ -65,24 +65,41 @@ static MALLOC_DEFINE(M_SYSCTLOID, "sysct static MALLOC_DEFINE(M_SYSCTLTMP, "sysctltmp", "sysctl temp output buffer"); /* - * Locking - this locks the sysctl tree in memory. + * The sysctllock protects the MIB tree. It also protects sysctl + * contexts used with dynamic sysctls. The sysctl_register_oid() and + * sysctl_unregister_oid() routines require the sysctllock to already + * be held, so the sysctl_lock() and sysctl_unlock() routines are + * provided for the few places in the kernel which need to use that + * API rather than using the dynamic API. Use of the dynamic API is + * strongly encouraged for most code. + * + * This lock is also used to serialize userland sysctl requests. Some + * sysctls wire user memory, and serializing the requests limits the + * amount of wired user memory in use. */ static struct sx sysctllock; -#define SYSCTL_LOCK() sx_xlock(&sysctllock) -#define SYSCTL_UNLOCK() sx_xunlock(&sysctllock) -#define SYSCTL_LOCK_ASSERT() sx_assert(&sysctllock, SX_XLOCKED) +#define SYSCTL_SLOCK() sx_slock(&sysctllock) +#define SYSCTL_SUNLOCK() sx_sunlock(&sysctllock) +#define SYSCTL_XLOCK() sx_xlock(&sysctllock) +#define SYSCTL_XUNLOCK() sx_xunlock(&sysctllock) +#define SYSCTL_ASSERT_XLOCKED() sx_assert(&sysctllock, SA_XLOCKED) +#define SYSCTL_ASSERT_LOCKED() sx_assert(&sysctllock, SA_LOCKED) #define SYSCTL_INIT() sx_init(&sysctllock, "sysctl lock") static int sysctl_root(SYSCTL_HANDLER_ARGS); struct sysctl_oid_list sysctl__children; /* root list */ +static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, + int recurse); + static struct sysctl_oid * sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) { struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, list, oid_link) { if (strcmp(oidp->oid_name, name) == 0) { return (oidp); @@ -96,6 +113,19 @@ sysctl_find_oidname(const char *name, st * * Order by number in each list. */ +void +sysctl_lock(void) +{ + + SYSCTL_XLOCK(); +} + +void +sysctl_unlock(void) +{ + + SYSCTL_XUNLOCK(); +} void sysctl_register_oid(struct sysctl_oid *oidp) @@ -108,6 +138,7 @@ sysctl_register_oid(struct sysctl_oid *o * First check if another oid with the same name already * exists in the parent's list. */ + SYSCTL_ASSERT_XLOCKED(); p = sysctl_find_oidname(oidp->oid_name, parent); if (p != NULL) { if ((p->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -160,6 +191,7 @@ sysctl_unregister_oid(struct sysctl_oid struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); error = ENOENT; if (oidp->oid_number == OID_AUTO) { error = EINVAL; @@ -191,6 +223,12 @@ sysctl_ctx_init(struct sysctl_ctx_list * if (c == NULL) { return (EINVAL); } + + /* + * No locking here, the caller is responsible for not adding + * new nodes to a context until after this function has + * returned. + */ TAILQ_INIT(c); return (0); } @@ -209,8 +247,9 @@ sysctl_ctx_free(struct sysctl_ctx_list * * XXX This algorithm is a hack. But I don't know any * XXX better solution for now... */ + SYSCTL_XLOCK(); TAILQ_FOREACH(e, clist, link) { - error = sysctl_remove_oid(e->entry, 0, 0); + error = sysctl_remove_oid_locked(e->entry, 0, 0); if (error) break; } @@ -227,19 +266,22 @@ sysctl_ctx_free(struct sysctl_ctx_list * sysctl_register_oid(e1->entry); e1 = TAILQ_PREV(e1, sysctl_ctx_list, link); } - if (error) + if (error) { + SYSCTL_XUNLOCK(); return(EBUSY); + } /* Now really delete the entries */ e = TAILQ_FIRST(clist); while (e != NULL) { e1 = TAILQ_NEXT(e, link); - error = sysctl_remove_oid(e->entry, 1, 0); + error = sysctl_remove_oid_locked(e->entry, 1, 0); if (error) panic("sysctl_remove_oid: corrupt tree, entry: %s", e->entry->oid_name); free(e, M_SYSCTLOID); e = e1; } + SYSCTL_XUNLOCK(); return (error); } @@ -249,6 +291,7 @@ sysctl_ctx_entry_add(struct sysctl_ctx_l { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_XLOCKED(); if (clist == NULL || oidp == NULL) return(NULL); e = malloc(sizeof(struct sysctl_ctx_entry), M_SYSCTLOID, M_WAITOK); @@ -263,6 +306,7 @@ sysctl_ctx_entry_find(struct sysctl_ctx_ { struct sysctl_ctx_entry *e; + SYSCTL_ASSERT_LOCKED(); if (clist == NULL || oidp == NULL) return(NULL); TAILQ_FOREACH(e, clist, link) { @@ -284,13 +328,17 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l if (clist == NULL || oidp == NULL) return (EINVAL); + SYSCTL_XLOCK(); e = sysctl_ctx_entry_find(clist, oidp); if (e != NULL) { TAILQ_REMOVE(clist, e, link); + SYSCTL_XUNLOCK(); free(e, M_SYSCTLOID); return (0); - } else + } else { + SYSCTL_XUNLOCK(); return (ENOENT); + } } /* @@ -302,9 +350,21 @@ sysctl_ctx_entry_del(struct sysctl_ctx_l int sysctl_remove_oid(struct sysctl_oid *oidp, int del, int recurse) { + int error; + + SYSCTL_XLOCK(); + error = sysctl_remove_oid_locked(oidp, del, recurse); + SYSCTL_XUNLOCK(); + return (error); +} + +static int +sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, int recurse) +{ struct sysctl_oid *p; int error; + SYSCTL_ASSERT_XLOCKED(); if (oidp == NULL) return(EINVAL); if ((oidp->oid_kind & CTLFLAG_DYN) == 0) { @@ -323,7 +383,8 @@ sysctl_remove_oid(struct sysctl_oid *oid SLIST_FOREACH(p, SYSCTL_CHILDREN(oidp), oid_link) { if (!recurse) return (ENOTEMPTY); - error = sysctl_remove_oid(p, del, recurse); + error = sysctl_remove_oid_locked(p, del, + recurse); if (error) return (error); } @@ -368,6 +429,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c if (parent == NULL) return(NULL); /* Check if the node already exists, otherwise create it */ + SYSCTL_XLOCK(); oidp = sysctl_find_oidname(name, parent); if (oidp != NULL) { if ((oidp->oid_kind & CTLTYPE) == CTLTYPE_NODE) { @@ -375,8 +437,10 @@ sysctl_add_oid(struct sysctl_ctx_list *c /* Update the context */ if (clist != NULL) sysctl_ctx_entry_add(clist, oidp); + SYSCTL_XUNLOCK(); return (oidp); } else { + SYSCTL_XUNLOCK(); printf("can't re-use a leaf (%s)!\n", name); return (NULL); } @@ -414,6 +478,7 @@ sysctl_add_oid(struct sysctl_ctx_list *c sysctl_ctx_entry_add(clist, oidp); /* Register this oid */ sysctl_register_oid(oidp); + SYSCTL_XUNLOCK(); return (oidp); } @@ -427,12 +492,14 @@ sysctl_rename_oid(struct sysctl_oid *oid char *newname; void *oldname; - oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; len = strlen(name); newname = malloc(len + 1, M_SYSCTLOID, M_WAITOK); bcopy(name, newname, len + 1); newname[len] = '\0'; + SYSCTL_XLOCK(); + oldname = (void *)(uintptr_t)(const void *)oidp->oid_name; oidp->oid_name = newname; + SYSCTL_XUNLOCK(); free(oldname, M_SYSCTLOID); } @@ -444,15 +511,21 @@ sysctl_move_oid(struct sysctl_oid *oid, { struct sysctl_oid *oidp; - if (oid->oid_parent == parent) + SYSCTL_XLOCK(); + if (oid->oid_parent == parent) { + SYSCTL_XUNLOCK(); return (0); + } oidp = sysctl_find_oidname(oid->oid_name, parent); - if (oidp != NULL) + if (oidp != NULL) { + SYSCTL_XUNLOCK(); return (EEXIST); + } sysctl_unregister_oid(oid); oid->oid_parent = parent; oid->oid_number = OID_AUTO; sysctl_register_oid(oid); + SYSCTL_XUNLOCK(); return (0); } @@ -467,8 +540,10 @@ sysctl_register_all(void *arg) struct sysctl_oid **oidp; SYSCTL_INIT(); + SYSCTL_XLOCK(); SET_FOREACH(oidp, sysctl_set) sysctl_register_oid(*oidp); + SYSCTL_XUNLOCK(); } SYSINIT(sysctl, SI_SUB_KMEM, SI_ORDER_ANY, sysctl_register_all, 0); @@ -498,6 +573,7 @@ sysctl_sysctl_debug_dump_node(struct sys int k; struct sysctl_oid *oidp; + SYSCTL_ASSERT_LOCKED(); SLIST_FOREACH(oidp, l, oid_link) { for (k=0; koid_number; @@ -687,7 +765,7 @@ name2oid (char *name, int *oid, int *len struct sysctl_oid_list *lsp = &sysctl__children; char *p; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!*name) return (ENOENT); @@ -745,7 +823,7 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_AR int error, oid[CTL_MAXNAME], len; struct sysctl_oid *op = 0; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); if (!req->newlen) return (ENOENT); @@ -1091,9 +1169,9 @@ kernel_sysctl(struct thread *td, int *na req.newfunc = sysctl_new_kernel; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_SLOCK(); error = sysctl_root(0, name, namelen, &req); - SYSCTL_UNLOCK(); + SYSCTL_SUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); @@ -1125,6 +1203,9 @@ kernel_sysctlbyname(struct thread *td, c /* * XXX: Prone to a possible race condition between lookup and * execution? Maybe put locking around it? + * + * Userland is just as racy, so I think the current implementation + * is fine. */ error = kernel_sysctl(td, oid, 2, oid, &oidlen, @@ -1236,6 +1317,7 @@ sysctl_find_oid(int *name, u_int namelen struct sysctl_oid *oid; int indx; + SYSCTL_ASSERT_LOCKED(); oid = SLIST_FIRST(&sysctl__children); indx = 0; while (oid && indx < CTL_MAXNAME) { @@ -1279,7 +1361,7 @@ sysctl_root(SYSCTL_HANDLER_ARGS) struct sysctl_oid *oid; int error, indx, lvl; - SYSCTL_LOCK_ASSERT(); + SYSCTL_ASSERT_LOCKED(); error = sysctl_find_oid(arg1, arg2, &oid, &indx, req); if (error) @@ -1357,7 +1439,7 @@ struct sysctl_args { int __sysctl(struct thread *td, struct sysctl_args *uap) { - int error, name[CTL_MAXNAME]; + int error, i, name[CTL_MAXNAME]; size_t j; if (uap->namelen > CTL_MAXNAME || uap->namelen < 2) @@ -1373,7 +1455,7 @@ __sysctl(struct thread *td, struct sysct if (error && error != ENOMEM) return (error); if (uap->oldlenp) { - int i = copyout(&j, uap->oldlenp, sizeof(j)); + i = copyout(&j, uap->oldlenp, sizeof(j)); if (i) return (i); } @@ -1425,7 +1507,7 @@ userland_sysctl(struct thread *td, int * req.newfunc = sysctl_new_user; req.lock = REQ_LOCKED; - SYSCTL_LOCK(); + SYSCTL_XLOCK(); CURVNET_SET(TD_TO_VNET(curthread)); for (;;) { @@ -1438,7 +1520,7 @@ userland_sysctl(struct thread *td, int * } CURVNET_RESTORE(); - SYSCTL_UNLOCK(); + SYSCTL_XUNLOCK(); if (req.lock == REQ_WIRED && req.validlen > 0) vsunlock(req.oldptr, req.validlen); Modified: head/sys/kern/vfs_init.c ============================================================================== --- head/sys/kern/vfs_init.c Fri Feb 6 12:39:42 2009 (r188231) +++ head/sys/kern/vfs_init.c Fri Feb 6 14:51:32 2009 (r188232) @@ -165,12 +165,15 @@ vfs_register(struct vfsconf *vfc) * preserved by re-registering the oid after modifying its * number. */ + sysctl_lock(); SLIST_FOREACH(oidp, &sysctl__vfs_children, oid_link) if (strcmp(oidp->oid_name, vfc->vfc_name) == 0) { sysctl_unregister_oid(oidp); oidp->oid_number = vfc->vfc_typenum; sysctl_register_oid(oidp); + break; } + sysctl_unlock(); /* * Initialise unused ``struct vfsops'' fields, to use Modified: head/sys/sys/sysctl.h ============================================================================== --- head/sys/sys/sysctl.h Fri Feb 6 12:39:42 2009 (r188231) +++ head/sys/sys/sysctl.h Fri Feb 6 14:51:32 2009 (r188232) @@ -799,6 +799,8 @@ int userland_sysctl(struct thread *td, i size_t *retval, int flags); int sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid, int *nindx, struct sysctl_req *req); +void sysctl_lock(void); +void sysctl_unlock(void); int sysctl_wire_old_buffer(struct sysctl_req *req, size_t len); #else /* !_KERNEL */ From jhb at FreeBSD.org Fri Feb 6 07:03:15 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 07:03:32 2009 Subject: svn commit: r188233 - head Message-ID: <200902061503.n16F3F76064413@svn.freebsd.org> Author: jhb Date: Fri Feb 6 15:03:14 2009 New Revision: 188233 URL: http://svn.freebsd.org/changeset/base/188233 Log: Add a note to document that ichsmb(4) now uses left-justified SMBus slave addresses. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Fri Feb 6 14:51:32 2009 (r188232) +++ head/UPDATING Fri Feb 6 15:03:14 2009 (r188233) @@ -22,6 +22,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20090203: + The ichsmb(4) driver has been changed to require SMBus slave + addresses be left-justified (xxxxxxx0b) rather than right-justified. + All of the other SMBus controller drivers require left-justified + slave addresses, so this change makes all the drivers provide the + same interface. + 20090201: INET6 statistics (struct ip6stat) was updated. netstat(1) needs to be recompiled. From kevlo at FreeBSD.org Fri Feb 6 07:03:18 2009 From: kevlo at FreeBSD.org (Kevin Lo) Date: Fri Feb 6 07:03:32 2009 Subject: svn commit: r188234 - in head: share/man/man4 sys/dev/usb sys/dev/usb2/wlan Message-ID: <200902061503.n16F3HdW064449@svn.freebsd.org> Author: kevlo Date: Fri Feb 6 15:03:17 2009 New Revision: 188234 URL: http://svn.freebsd.org/changeset/base/188234 Log: Add the Buffalo WLI-U2-SG54HG Modified: head/share/man/man4/rum.4 head/sys/dev/usb/if_rum.c head/sys/dev/usb/usbdevs head/sys/dev/usb2/wlan/if_rum2.c Modified: head/share/man/man4/rum.4 ============================================================================== --- head/share/man/man4/rum.4 Fri Feb 6 15:03:14 2009 (r188233) +++ head/share/man/man4/rum.4 Fri Feb 6 15:03:17 2009 (r188234) @@ -91,6 +91,7 @@ including: .It "Belkin F5D7050 ver 3" Ta USB .It "Belkin F5D9050 ver 3" Ta USB .It "Buffalo WLI-U2-SG54HP" Ta USB +.It "Buffalo WLI-U2-SG54HG" Ta USB .It "Buffalo WLI-U2-G54HP" Ta USB .It "CNet CWD-854 ver F" Ta USB .It "Conceptronic C54RU ver 2" Ta USB Modified: head/sys/dev/usb/if_rum.c ============================================================================== --- head/sys/dev/usb/if_rum.c Fri Feb 6 15:03:14 2009 (r188233) +++ head/sys/dev/usb/if_rum.c Fri Feb 6 15:03:17 2009 (r188234) @@ -108,6 +108,7 @@ static const struct usb_devno rum_devs[] { USB_VENDOR_HUAWEI3COM, USB_PRODUCT_HUAWEI3COM_WUB320G }, { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_G54HP }, { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HP }, + { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HG }, { USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_1 }, { USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_2 }, { USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_3 }, Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Fri Feb 6 15:03:14 2009 (r188233) +++ head/sys/dev/usb/usbdevs Fri Feb 6 15:03:17 2009 (r188234) @@ -1681,6 +1681,7 @@ product MELCO PCOPRS1 0x00b3 PC-OP-RS1 product MELCO SG54HP 0x00d8 WLI-U2-SG54HP product MELCO G54HP 0x00d9 WLI-U2-G54HP product MELCO KG54L 0x00da WLI-U2-KG54L +product MELCO SG54HG 0x00f4 WLI-U2-SG54HG /* Merlin products */ product MERLIN V620 0x1110 Merlin V620 Modified: head/sys/dev/usb2/wlan/if_rum2.c ============================================================================== --- head/sys/dev/usb2/wlan/if_rum2.c Fri Feb 6 15:03:14 2009 (r188233) +++ head/sys/dev/usb2/wlan/if_rum2.c Fri Feb 6 15:03:17 2009 (r188234) @@ -188,6 +188,7 @@ static const struct usb2_device_id rum_d {USB_VPI(USB_VENDOR_HUAWEI3COM, USB_PRODUCT_HUAWEI3COM_WUB320G, 0)}, {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_G54HP, 0)}, {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HP, 0)}, + {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HG, 0)}, {USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_1, 0)}, {USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_2, 0)}, {USB_VPI(USB_VENDOR_MSI, USB_PRODUCT_MSI_RT2573_3, 0)}, From kevlo at FreeBSD.org Fri Feb 6 07:04:07 2009 From: kevlo at FreeBSD.org (Kevin Lo) Date: Fri Feb 6 07:04:13 2009 Subject: svn commit: r188235 - head/sys/dev/usb2/include Message-ID: <200902061504.n16F46SU064513@svn.freebsd.org> Author: kevlo Date: Fri Feb 6 15:04:06 2009 New Revision: 188235 URL: http://svn.freebsd.org/changeset/base/188235 Log: Regen Modified: head/sys/dev/usb2/include/usb2_devid.h head/sys/dev/usb2/include/usb2_devtable.h Modified: head/sys/dev/usb2/include/usb2_devid.h ============================================================================== --- head/sys/dev/usb2/include/usb2_devid.h Fri Feb 6 15:03:17 2009 (r188234) +++ head/sys/dev/usb2/include/usb2_devid.h Fri Feb 6 15:04:06 2009 (r188235) @@ -4,7 +4,7 @@ * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * FreeBSD: head/sys/dev/usb/usbdevs 187726 2009-01-26 17:43:58Z thompsa + * FreeBSD: head/sys/dev/usb/usbdevs 188234 2009-02-06 15:03:17Z kevlo */ /* $NetBSD: usbdevs,v 1.392 2004/12/29 08:38:44 imp Exp $ */ @@ -1688,6 +1688,7 @@ #define USB_PRODUCT_MELCO_SG54HP 0x00d8 /* WLI-U2-SG54HP */ #define USB_PRODUCT_MELCO_G54HP 0x00d9 /* WLI-U2-G54HP */ #define USB_PRODUCT_MELCO_KG54L 0x00da /* WLI-U2-KG54L */ +#define USB_PRODUCT_MELCO_SG54HG 0x00f4 /* WLI-U2-SG54HG */ /* Merlin products */ #define USB_PRODUCT_MERLIN_V620 0x1110 /* Merlin V620 */ Modified: head/sys/dev/usb2/include/usb2_devtable.h ============================================================================== --- head/sys/dev/usb2/include/usb2_devtable.h Fri Feb 6 15:03:17 2009 (r188234) +++ head/sys/dev/usb2/include/usb2_devtable.h Fri Feb 6 15:04:06 2009 (r188235) @@ -4,7 +4,7 @@ * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * FreeBSD: head/sys/dev/usb/usbdevs 187726 2009-01-26 17:43:58Z thompsa + * FreeBSD: head/sys/dev/usb/usbdevs 188234 2009-02-06 15:03:17Z kevlo */ /* $NetBSD: usbdevs,v 1.392 2004/12/29 08:38:44 imp Exp $ */ @@ -4133,6 +4133,12 @@ const struct usb_knowndev usb_knowndevs[ "WLI-U2-KG54L", }, { + USB_VENDOR_MELCO, USB_PRODUCT_MELCO_SG54HG, + 0, + "Melco", + "WLI-U2-SG54HG", + }, + { USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620, 0, "Merlin", From jhb at FreeBSD.org Fri Feb 6 07:09:33 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 07:09:45 2009 Subject: svn commit: r188236 - head/share/man/man4 Message-ID: <200902061509.n16F9V6U064634@svn.freebsd.org> Author: jhb Date: Fri Feb 6 15:09:31 2009 New Revision: 188236 URL: http://svn.freebsd.org/changeset/base/188236 Log: Note that the slave address passed to smb(4) commands must be left-justified (LSB is 0). The iic(4) manpage probably needs similar language to describe the format it expects. Modified: head/share/man/man4/smb.4 Modified: head/share/man/man4/smb.4 ============================================================================== --- head/share/man/man4/smb.4 Fri Feb 6 15:04:06 2009 (r188235) +++ head/share/man/man4/smb.4 Fri Feb 6 15:09:31 2009 (r188236) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 25, 1998 +.Dd February 6, 2009 .Dt SMB 4 .Os .Sh NAME @@ -72,6 +72,9 @@ The .Fa slave field is always used, and provides the address of the SMBus slave device to talk to. +The slave address is specified in the seven most significant bits +.Pq i.e. Dq "left-justified" . +The least significant bit of the slave address must be zero. .Pp .Bl -column ".Dv SMB_QUICK_WRITE" -compact .It Em Ioctl Ta Em Description From kevlo at FreeBSD.org Fri Feb 6 07:27:41 2009 From: kevlo at FreeBSD.org (Kevin Lo) Date: Fri Feb 6 07:27:52 2009 Subject: svn commit: r188237 - head/sys/dev/usb Message-ID: <200902061527.n16FRemZ064990@svn.freebsd.org> Author: kevlo Date: Fri Feb 6 15:27:40 2009 New Revision: 188237 URL: http://svn.freebsd.org/changeset/base/188237 Log: In urtw_init() call urtw_stop(ifp, 0) rather than urtw_stop(ifp, 1) to stop the device. Modified: head/sys/dev/usb/if_urtw.c Modified: head/sys/dev/usb/if_urtw.c ============================================================================== --- head/sys/dev/usb/if_urtw.c Fri Feb 6 15:09:31 2009 (r188236) +++ head/sys/dev/usb/if_urtw.c Fri Feb 6 15:27:40 2009 (r188237) @@ -2076,7 +2076,7 @@ urtw_init(void *arg) struct ifnet *ifp = sc->sc_ifp; usbd_status error; - urtw_stop(ifp, 1); + urtw_stop(ifp, 0); error = urtw_adapter_start(sc); if (error != 0) From trasz at FreeBSD.org Fri Feb 6 09:14:08 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Feb 6 09:14:20 2009 Subject: svn commit: r188240 - head/sys/ufs/ffs Message-ID: <200902061714.n16HE7Lr066980@svn.freebsd.org> Author: trasz Date: Fri Feb 6 17:14:07 2009 New Revision: 188240 URL: http://svn.freebsd.org/changeset/base/188240 Log: When a device containing mounted UFS filesystem disappears, the type of devvp becomes VBAD, which UFS incorrectly interprets as snapshot vnode, which in turns causes panic. Fix it by replacing '!= VCHR' with '== VREG'. With this fix in place, you should no longer be able to panic the system by removing a device with an UFS filesystem mounted from it - assuming you don't use softupdates. Reviewed by: kib Tested by: pho Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: head/sys/ufs/ffs/ffs_alloc.c Modified: head/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_alloc.c Fri Feb 6 16:05:00 2009 (r188239) +++ head/sys/ufs/ffs/ffs_alloc.c Fri Feb 6 17:14:07 2009 (r188240) @@ -1858,7 +1858,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, i struct cdev *dev; cg = dtog(fs, bno); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgblkno = fragstoblks(fs, cgtod(fs, cg)); @@ -1903,7 +1903,7 @@ ffs_blkfree(ump, fs, devvp, bno, size, i if (size == fs->fs_bsize) { fragno = fragstoblks(fs, cgbno); if (!ffs_isfreeblock(fs, blksfree, fragno)) { - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { UFS_UNLOCK(ump); /* devvp is a snapshot */ brelse(bp); @@ -2056,7 +2056,7 @@ ffs_freefile(ump, fs, devvp, ino, mode) struct cdev *dev; cg = ino_to_cg(fs, ino); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ dev = VTOI(devvp)->i_devvp->v_rdev; cgbno = fragstoblks(fs, cgtod(fs, cg)); @@ -2122,7 +2122,7 @@ ffs_checkfreefile(fs, devvp, ino) u_int8_t *inosused; cg = ino_to_cg(fs, ino); - if (devvp->v_type != VCHR) { + if (devvp->v_type == VREG) { /* devvp is a snapshot */ cgbno = fragstoblks(fs, cgtod(fs, cg)); } else { From trasz at FreeBSD.org Fri Feb 6 10:16:02 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Fri Feb 6 10:16:08 2009 Subject: svn commit: r188243 - in head/sys: kern sys Message-ID: <200902061816.n16IG1u2068210@svn.freebsd.org> Author: trasz Date: Fri Feb 6 18:16:01 2009 New Revision: 188243 URL: http://svn.freebsd.org/changeset/base/188243 Log: Add KASSERTs to make it easier to debug problems like the one fixed in r188141. Reviewed by: kib,attilio Approved by: rwatson (mentor) Tested by: pho Sponsored by: FreeBSD Foundation Modified: head/sys/kern/vfs_subr.c head/sys/sys/mount.h Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Fri Feb 6 17:21:41 2009 (r188242) +++ head/sys/kern/vfs_subr.c Fri Feb 6 18:16:01 2009 (r188243) @@ -381,6 +381,7 @@ vfs_unbusy(struct mount *mp) CTR2(KTR_VFS, "%s: mp %p", __func__, mp); MNT_ILOCK(mp); MNT_REL(mp); + KASSERT(mp->mnt_lockref > 0, ("negative mnt_lockref")); mp->mnt_lockref--; if (mp->mnt_lockref == 0 && (mp->mnt_kern_flag & MNTK_DRAINING) != 0) { MPASS(mp->mnt_kern_flag & MNTK_UNMOUNT); Modified: head/sys/sys/mount.h ============================================================================== --- head/sys/sys/mount.h Fri Feb 6 17:21:41 2009 (r188242) +++ head/sys/sys/mount.h Fri Feb 6 18:16:01 2009 (r188243) @@ -206,6 +206,7 @@ void __mnt_vnode_markerfree(str #define MNT_MTX(mp) (&(mp)->mnt_mtx) #define MNT_REF(mp) (mp)->mnt_ref++ #define MNT_REL(mp) do { \ + KASSERT((mp)->mnt_ref > 0, ("negative mnt_ref")); \ (mp)->mnt_ref--; \ if ((mp)->mnt_ref == 0) \ wakeup((mp)); \ From jhb at FreeBSD.org Fri Feb 6 12:06:49 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 12:07:24 2009 Subject: svn commit: r188244 - in head/sys: fs/fifofs kern Message-ID: <200902062006.n16K6mNa070274@svn.freebsd.org> Author: jhb Date: Fri Feb 6 20:06:48 2009 New Revision: 188244 URL: http://svn.freebsd.org/changeset/base/188244 Log: Tweak the output of VOP_PRINT/vn_printf() some. - Align the fifo output in fifo_print() with other vn_printf() output. - Remove the leading space from lockmgr_printinfo() so its output lines up in vn_printf(). - lockmgr_printinfo() now ends with a newline, so remove an extra newline from vn_printf(). Modified: head/sys/fs/fifofs/fifo_vnops.c head/sys/kern/kern_lock.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_subr.c Modified: head/sys/fs/fifofs/fifo_vnops.c ============================================================================== --- head/sys/fs/fifofs/fifo_vnops.c Fri Feb 6 18:16:01 2009 (r188243) +++ head/sys/fs/fifofs/fifo_vnops.c Fri Feb 6 20:06:48 2009 (r188244) @@ -468,6 +468,7 @@ fifo_print(ap) struct vnode *a_vp; } */ *ap; { + printf(" "); fifo_printinfo(ap->a_vp); printf("\n"); return (0); Modified: head/sys/kern/kern_lock.c ============================================================================== --- head/sys/kern/kern_lock.c Fri Feb 6 18:16:01 2009 (r188243) +++ head/sys/kern/kern_lock.c Fri Feb 6 20:06:48 2009 (r188244) @@ -897,14 +897,14 @@ lockmgr_printinfo(struct lock *lk) uintptr_t x; if (lk->lk_lock == LK_UNLOCKED) - printf(" lock type %s: UNLOCKED\n", lk->lock_object.lo_name); + printf("lock type %s: UNLOCKED\n", lk->lock_object.lo_name); else if (lk->lk_lock & LK_SHARE) - printf(" lock type %s: SHARED (count %ju)\n", + printf("lock type %s: SHARED (count %ju)\n", lk->lock_object.lo_name, (uintmax_t)LK_SHARERS(lk->lk_lock)); else { td = lockmgr_xholder(lk); - printf(" lock type %s: EXCL by thread %p (pid %d)\n", + printf("lock type %s: EXCL by thread %p (pid %d)\n", lk->lock_object.lo_name, td, td->td_proc->p_pid); } Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Fri Feb 6 18:16:01 2009 (r188243) +++ head/sys/kern/vfs_bio.c Fri Feb 6 20:06:48 2009 (r188244) @@ -3920,6 +3920,7 @@ DB_SHOW_COMMAND(buffer, db_show_buffer) } db_printf("\n"); } + db_printf(" "); lockmgr_printinfo(&bp->b_lock); } Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Fri Feb 6 18:16:01 2009 (r188243) +++ head/sys/kern/vfs_subr.c Fri Feb 6 20:06:48 2009 (r188244) @@ -2719,7 +2719,6 @@ vn_printf(struct vnode *vp, const char * vp->v_object->resident_page_count); printf(" "); lockmgr_printinfo(vp->v_vnlock); - printf("\n"); if (vp->v_data != NULL) VOP_PRINT(vp); } From jhb at FreeBSD.org Fri Feb 6 12:09:15 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 12:09:21 2009 Subject: svn commit: r188245 - head/sys/fs/udf Message-ID: <200902062009.n16K9Esa070354@svn.freebsd.org> Author: jhb Date: Fri Feb 6 20:09:14 2009 New Revision: 188245 URL: http://svn.freebsd.org/changeset/base/188245 Log: Add support for fifos to UDF: - Add a separate set of vnode operations that inherits from the fifo ops and use it for fifo nodes. - Add a VOP_SETATTR() method that allows setting the size (by silently ignoring the requests) of fifos. This is to allow O_TRUNC opens of fifo devices (e.g. I/O redirection in shells using ">"). - Add a VOP_PRINT() handler while I'm here. Modified: head/sys/fs/udf/udf.h head/sys/fs/udf/udf_vfsops.c head/sys/fs/udf/udf_vnops.c Modified: head/sys/fs/udf/udf.h ============================================================================== --- head/sys/fs/udf/udf.h Fri Feb 6 20:06:48 2009 (r188244) +++ head/sys/fs/udf/udf.h Fri Feb 6 20:09:14 2009 (r188245) @@ -137,3 +137,5 @@ int udf_vget(struct mount *, ino_t, int, extern uma_zone_t udf_zone_trans; extern uma_zone_t udf_zone_node; extern uma_zone_t udf_zone_ds; + +extern struct vop_vector udf_fifoops; Modified: head/sys/fs/udf/udf_vfsops.c ============================================================================== --- head/sys/fs/udf/udf_vfsops.c Fri Feb 6 20:06:48 2009 (r188244) +++ head/sys/fs/udf/udf_vfsops.c Fri Feb 6 20:09:14 2009 (r188245) @@ -680,6 +680,7 @@ udf_vget(struct mount *mp, ino_t ino, in break; case 9: vp->v_type = VFIFO; + vp->v_op = &udf_fifoops; break; case 10: vp->v_type = VSOCK; Modified: head/sys/fs/udf/udf_vnops.c ============================================================================== --- head/sys/fs/udf/udf_vnops.c Fri Feb 6 20:06:48 2009 (r188244) +++ head/sys/fs/udf/udf_vnops.c Fri Feb 6 20:09:14 2009 (r188245) @@ -48,6 +48,7 @@ #include +#include #include #include #include @@ -60,9 +61,11 @@ static vop_getattr_t udf_getattr; static vop_open_t udf_open; static vop_ioctl_t udf_ioctl; static vop_pathconf_t udf_pathconf; +static vop_print_t udf_print; static vop_read_t udf_read; static vop_readdir_t udf_readdir; static vop_readlink_t udf_readlink; +static vop_setattr_t udf_setattr; static vop_strategy_t udf_strategy; static vop_bmap_t udf_bmap; static vop_cachedlookup_t udf_lookup; @@ -84,14 +87,26 @@ static struct vop_vector udf_vnodeops = .vop_lookup = vfs_cache_lookup, .vop_open = udf_open, .vop_pathconf = udf_pathconf, + .vop_print = udf_print, .vop_read = udf_read, .vop_readdir = udf_readdir, .vop_readlink = udf_readlink, .vop_reclaim = udf_reclaim, + .vop_setattr = udf_setattr, .vop_strategy = udf_strategy, .vop_vptofh = udf_vptofh, }; +struct vop_vector udf_fifoops = { + .vop_default = &fifo_specops, + .vop_access = udf_access, + .vop_getattr = udf_getattr, + .vop_print = udf_print, + .vop_reclaim = udf_reclaim, + .vop_setattr = udf_setattr, + .vop_vptofh = udf_vptofh, +}; + MALLOC_DEFINE(M_UDFFID, "udf_fid", "UDF FileId structure"); MALLOC_DEFINE(M_UDFDS, "udf_ds", "UDF Dirstream structure"); @@ -318,6 +333,38 @@ udf_getattr(struct vop_getattr_args *a) return (0); } +static int +udf_setattr(struct vop_setattr_args *a) +{ + struct vnode *vp; + struct vattr *vap; + + vp = a->a_vp; + vap = a->a_vap; + if (vap->va_flags != (u_long)VNOVAL || vap->va_uid != (uid_t)VNOVAL || + vap->va_gid != (gid_t)VNOVAL || vap->va_atime.tv_sec != VNOVAL || + vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL) + return (EROFS); + if (vap->va_size != (u_quad_t)VNOVAL) { + switch (vp->v_type) { + case VDIR: + return (EISDIR); + case VLNK: + case VREG: + return (EROFS); + case VCHR: + case VBLK: + case VSOCK: + case VFIFO: + case VNON: + case VBAD: + case VMARKER: + return (0); + } + } + return (0); +} + /* * File specific ioctls. */ @@ -354,6 +401,20 @@ udf_pathconf(struct vop_pathconf_args *a } } +static int +udf_print(struct vop_print_args *ap) +{ + struct vnode *vp = ap->a_vp; + struct udf_node *node = VTON(vp); + + printf(" ino %lu, on dev %s", (u_long)node->hash_id, + devtoname(node->udfmp->im_dev)); + if (vp->v_type == VFIFO) + fifo_printinfo(vp); + printf("\n"); + return (0); +} + #define lblkno(udfmp, loc) ((loc) >> (udfmp)->bshift) #define blkoff(udfmp, loc) ((loc) & (udfmp)->bmask) #define lblktosize(imp, blk) ((blk) << (udfmp)->bshift) From wkoszek at FreeBSD.org Fri Feb 6 12:57:12 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 12:57:18 2009 Subject: svn commit: r188247 - in head/sys: amd64/conf conf dev/agp i386/conf pc98/conf Message-ID: <200902062057.n16KvA98071296@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 20:57:10 2009 New Revision: 188247 URL: http://svn.freebsd.org/changeset/base/188247 Log: Fix AGP debugging code: - correct format strings - fill opt_agp.h if AGP_DEBUG is defined - bring AGP_DEBUG to LINT by mentioning it in NOTES This should hopefully fix a warning that was... Found by: Coverity Prevent(tm) CID: 3676 Tested on: amd64, i386 Modified: head/sys/amd64/conf/NOTES head/sys/conf/options.amd64 head/sys/conf/options.i386 head/sys/conf/options.pc98 head/sys/dev/agp/agp.c head/sys/i386/conf/NOTES head/sys/pc98/conf/NOTES Modified: head/sys/amd64/conf/NOTES ============================================================================== --- head/sys/amd64/conf/NOTES Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/amd64/conf/NOTES Fri Feb 6 20:57:10 2009 (r188247) @@ -150,6 +150,11 @@ device pci # AGP GART support device agp +# +# AGP debugging. +# +options AGP_DEBUG + ##################################################################### # HARDWARE DEVICE CONFIGURATION Modified: head/sys/conf/options.amd64 ============================================================================== --- head/sys/conf/options.amd64 Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/conf/options.amd64 Fri Feb 6 20:57:10 2009 (r188247) @@ -37,6 +37,9 @@ VGA_NO_MODE_CHANGE opt_vga.h VGA_SLOW_IOACCESS opt_vga.h VGA_WIDTH90 opt_vga.h +# AGP debugging support +AGP_DEBUG opt_agp.h + ATKBD_DFLT_KEYMAP opt_atkbd.h # ------------------------------- Modified: head/sys/conf/options.i386 ============================================================================== --- head/sys/conf/options.i386 Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/conf/options.i386 Fri Feb 6 20:57:10 2009 (r188247) @@ -88,6 +88,9 @@ VGA_WIDTH90 opt_vga.h VESA VESA_DEBUG opt_vesa.h +# AGP debugging support +AGP_DEBUG opt_agp.h + PSM_DEBUG opt_psm.h PSM_HOOKRESUME opt_psm.h PSM_RESETAFTERSUSPEND opt_psm.h Modified: head/sys/conf/options.pc98 ============================================================================== --- head/sys/conf/options.pc98 Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/conf/options.pc98 Fri Feb 6 20:57:10 2009 (r188247) @@ -96,6 +96,7 @@ DEV_NPX opt_npx.h # Debugging NPX_DEBUG opt_npx.h STOP_NMI opt_cpu.h +AGP_DEBUG opt_agp.h # BPF just-in-time compiler BPF_JITTER opt_bpf.h Modified: head/sys/dev/agp/agp.c ============================================================================== --- head/sys/dev/agp/agp.c Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/dev/agp/agp.c Fri Feb 6 20:57:10 2009 (r188247) @@ -27,6 +27,7 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_agp.h" #include "opt_bus.h" #include @@ -554,7 +555,7 @@ agp_generic_bind_memory(device_t dev, st */ m = vm_page_grab(mem->am_obj, OFF_TO_IDX(i), VM_ALLOC_WIRED | VM_ALLOC_ZERO | VM_ALLOC_RETRY); - AGP_DPF("found page pa=%#x\n", VM_PAGE_TO_PHYS(m)); + AGP_DPF("found page pa=%#jx\n", (uintmax_t)VM_PAGE_TO_PHYS(m)); } VM_OBJECT_UNLOCK(mem->am_obj); @@ -585,8 +586,8 @@ agp_generic_bind_memory(device_t dev, st for (j = 0; j < PAGE_SIZE && i + j < mem->am_size; j += AGP_PAGE_SIZE) { vm_offset_t pa = VM_PAGE_TO_PHYS(m) + j; - AGP_DPF("binding offset %#x to pa %#x\n", - offset + i + j, pa); + AGP_DPF("binding offset %#jx to pa %#jx\n", + (uintmax_t)offset + i + j, (uintmax_t)pa); error = AGP_BIND_PAGE(dev, offset + i + j, pa); if (error) { /* Modified: head/sys/i386/conf/NOTES ============================================================================== --- head/sys/i386/conf/NOTES Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/i386/conf/NOTES Fri Feb 6 20:57:10 2009 (r188247) @@ -347,6 +347,9 @@ device pci # AGP GART support device agp +# AGP debugging. +options AGP_DEBUG + ##################################################################### # HARDWARE DEVICE CONFIGURATION Modified: head/sys/pc98/conf/NOTES ============================================================================== --- head/sys/pc98/conf/NOTES Fri Feb 6 20:41:30 2009 (r188246) +++ head/sys/pc98/conf/NOTES Fri Feb 6 20:57:10 2009 (r188247) @@ -288,6 +288,9 @@ device pci # AGP GART support device agp +# AGP debugging. +options AGP_DEBUG + ##################################################################### # HARDWARE DEVICE CONFIGURATION From wkoszek at FreeBSD.org Fri Feb 6 13:56:56 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 13:57:02 2009 Subject: svn commit: r188249 - head/sys/amd64/conf Message-ID: <200902062156.n16Lut8x072398@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 21:56:55 2009 New Revision: 188249 URL: http://svn.freebsd.org/changeset/base/188249 Log: ural(4) is already present in global NOTES, thus there is no need to explicitly list it here once again. This removes: WARNING: duplicate option `DEV_URAL' encountered. WARNING: duplicate device `ural' encountered. Warnings when compiling LINT on amd64. Modified: head/sys/amd64/conf/NOTES Modified: head/sys/amd64/conf/NOTES ============================================================================== --- head/sys/amd64/conf/NOTES Fri Feb 6 21:22:35 2009 (r188248) +++ head/sys/amd64/conf/NOTES Fri Feb 6 21:56:55 2009 (r188249) @@ -272,7 +272,6 @@ options DRM_DEBUG # Include debug print # nfe: nVidia nForce MCP on-board Ethernet Networking (BSD open source) # nve: nVidia nForce MCP on-board Ethernet Networking # ral: Ralink Technology IEEE 802.11 wireless adapter -# ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter # wpi: Intel 3945ABG Wireless LAN controller device ed @@ -285,7 +284,6 @@ device ipw device nfe # nVidia nForce MCP on-board Ethernet Networking device nve # nVidia nForce MCP on-board Ethernet Networking device ral -device ural device wpi device ath # Atheros pci/cardbus NIC's From wkoszek at FreeBSD.org Fri Feb 6 14:22:09 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 14:22:20 2009 Subject: svn commit: r188250 - head/sys/i386/conf Message-ID: <200902062222.n16MM9xZ072914@svn.freebsd.org> Author: wkoszek Date: Fri Feb 6 22:22:08 2009 New Revision: 188250 URL: http://svn.freebsd.org/changeset/base/188250 Log: Comment about ural(4) isn't approprate here, since the driver is present in global NOTES file. cx(4) driver isn't present in this file, though it could be. However, cx(4) seems to be more or less dead -- it hasn't been linked to the modules build, and after TTY-ng transformations it doesn't compile. Remove it until cx(4) is broken. Modified: head/sys/i386/conf/NOTES Modified: head/sys/i386/conf/NOTES ============================================================================== --- head/sys/i386/conf/NOTES Fri Feb 6 21:56:55 2009 (r188249) +++ head/sys/i386/conf/NOTES Fri Feb 6 22:22:08 2009 (r188250) @@ -542,8 +542,6 @@ hint.mse.0.irq="5" # ctau: Cronyx Tau sync dual port V.35/RS-232/RS-530/RS-449/X.21/G.703/E1 # serial adaptor (requires sppp (default), or NETGRAPH if # NETGRAPH_CRONYX is configured) -# cx: Cronyx Sigma multiport sync/async adapter (requires sppp (default), -# or NETGRAPH if NETGRAPH_CRONYX is configured) # ed: Western Digital and SMC 80xx; Novell NE1000 and NE2000; 3Com 3C503 # HP PC Lan+, various PC Card devices # (requires miibus) @@ -557,7 +555,6 @@ hint.mse.0.irq="5" # ral: Ralink Technology IEEE 802.11 wireless adapter # sbni: Granch SBNI12-xx ISA and PCI adapters # sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp) -# ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter # wl: Lucent Wavelan (ISA card only). # wpi: Intel 3945ABG Wireless LAN controller From jhb at FreeBSD.org Fri Feb 6 14:24:04 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Fri Feb 6 14:24:16 2009 Subject: svn commit: r188251 - head/sys/fs/udf Message-ID: <200902062224.n16MO3gm072994@svn.freebsd.org> Author: jhb Date: Fri Feb 6 22:24:03 2009 New Revision: 188251 URL: http://svn.freebsd.org/changeset/base/188251 Log: Add rudimentary support for symbolic links on UDF. Links are stored as a sequence of pathname components. We walk the list building a string in the caller's passed in buffer. Currently this only handles path names in CS8 (character set 8) as that is what mkisofs generates for UDF images. MFC after: 1 month Modified: head/sys/fs/udf/ecma167-udf.h head/sys/fs/udf/udf_vnops.c Modified: head/sys/fs/udf/ecma167-udf.h ============================================================================== --- head/sys/fs/udf/ecma167-udf.h Fri Feb 6 22:22:08 2009 (r188250) +++ head/sys/fs/udf/ecma167-udf.h Fri Feb 6 22:24:03 2009 (r188251) @@ -354,6 +354,18 @@ struct file_entry { #define UDF_FENTRY_PERM_GRP_MASK 0xE0 #define UDF_FENTRY_PERM_OWNER_MASK 0x1C00 +/* Path Component [4/14.16.1] */ +struct path_component { + uint8_t type; + uint8_t length; + uint16_t version; + uint8_t identifier[0]; +} __packed; +#define UDF_PATH_ROOT 2 +#define UDF_PATH_DOTDOT 3 +#define UDF_PATH_DOT 4 +#define UDF_PATH_PATH 5 + union dscrptr { struct desc_tag tag; struct anchor_vdp avdp; Modified: head/sys/fs/udf/udf_vnops.c ============================================================================== --- head/sys/fs/udf/udf_vnops.c Fri Feb 6 22:22:08 2009 (r188250) +++ head/sys/fs/udf/udf_vnops.c Fri Feb 6 22:24:03 2009 (r188251) @@ -859,12 +859,121 @@ udf_readdir(struct vop_readdir_args *a) return (error); } -/* Are there any implementations out there that do soft-links? */ static int udf_readlink(struct vop_readlink_args *ap) { - printf("%s called\n", __func__); - return (EOPNOTSUPP); + struct path_component *pc, *end; + struct vnode *vp; + struct uio uio; + struct iovec iov[1]; + struct udf_node *node; + void *buf; + char *cp; + int error, len, root; + + /* + * A symbolic link in UDF is a list of variable-length path + * component structures. We build a pathname in the caller's + * uio by traversing this list. + */ + vp = ap->a_vp; + node = VTON(vp); + len = le64toh(node->fentry->inf_len); + buf = malloc(iov[0].iov_len, M_DEVBUF, M_WAITOK); + iov[0].iov_base = buf; + iov[0].iov_len = len; + uio.uio_iov = iov; + uio.uio_iovcnt = 1; + uio.uio_offset = 0; + uio.uio_resid = iov[0].iov_len; + uio.uio_segflg = UIO_SYSSPACE; + uio.uio_rw = UIO_READ; + uio.uio_td = curthread; + error = VOP_READ(vp, &uio, 0, ap->a_cred); + if (error) + goto error; + + pc = buf; + end = (void *)((char *)buf + len); + root = 0; + while (pc < end) { + switch (pc->type) { + case UDF_PATH_ROOT: + /* Only allow this at the beginning of a path. */ + if ((void *)pc != buf) { + error = EINVAL; + goto error; + } + cp = "/"; + len = 1; + root = 1; + break; + case UDF_PATH_DOT: + cp = "."; + len = 1; + break; + case UDF_PATH_DOTDOT: + cp = ".."; + len = 2; + break; + case UDF_PATH_PATH: + if (pc->length == 0) { + error = EINVAL; + goto error; + } + /* + * XXX: We only support CS8 which appears to map + * to ASCII directly. + */ + switch (pc->identifier[0]) { + case 8: + cp = pc->identifier + 1; + len = pc->length - 1; + break; + default: + error = EOPNOTSUPP; + goto error; + } + break; + default: + error = EINVAL; + goto error; + } + + /* + * If this is not the first component, insert a path + * separator. + */ + if (pc != buf) { + /* If we started with root we already have a "/". */ + if (root) + goto skipslash; + root = 0; + if (ap->a_uio->uio_resid < 1) { + error = ENAMETOOLONG; + goto error; + } + error = uiomove("/", 1, ap->a_uio); + if (error) + break; + } + skipslash: + + /* Append string at 'cp' of length 'len' to our path. */ + if (len > ap->a_uio->uio_resid) { + error = ENAMETOOLONG; + goto error; + } + error = uiomove(cp, len, ap->a_uio); + if (error) + break; + + /* Advance to next component. */ + pc = (void *)((char *)pc + 4 + pc->length); + } +error: + free(buf, M_DEVBUF); + return (error); } static int From wkoszek at FreeBSD.org Fri Feb 6 16:01:12 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 16:01:23 2009 Subject: svn commit: r188254 - head/sys/amd64/conf Message-ID: <200902070001.n1701B4s074970@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 00:01:10 2009 New Revision: 188254 URL: http://svn.freebsd.org/changeset/base/188254 Log: Tidy NOTES a bit: - remove misleading nve/nfe comments, which make it hard to distinguish those two at a first glance - bring pbio documentation to the block comment together with other drivers I also brought commented out line responsible for si(4), since it seems to compile and already has respective comment in this file. Modified: head/sys/amd64/conf/NOTES Modified: head/sys/amd64/conf/NOTES ============================================================================== --- head/sys/amd64/conf/NOTES Fri Feb 6 23:56:02 2009 (r188253) +++ head/sys/amd64/conf/NOTES Sat Feb 7 00:01:10 2009 (r188254) @@ -281,8 +281,8 @@ options ED_SIC device iwi device iwn device ipw -device nfe # nVidia nForce MCP on-board Ethernet Networking -device nve # nVidia nForce MCP on-board Ethernet Networking +device nfe +device nve device ral device wpi @@ -359,9 +359,11 @@ options SAFE_RNDTEST # enable rndtest s # Miscellaneous hardware: # # ipmi: Intelligent Platform Management Interface +# pbio: Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) # smbios: DMI/SMBIOS entry point # vpd: Vital Product Data kernel interface # asmc: Apple System Management Controller +# si: Specialix International SI/XIO or SX intelligent serial card # Notes on the Specialix SI/XIO driver: # The host card is memory, not IO mapped. @@ -370,13 +372,14 @@ options SAFE_RNDTEST # enable rndtest s # The cards can use an IRQ of 11, 12 or 15. device ipmi -# Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) device pbio hint.pbio.0.at="isa" hint.pbio.0.port="0x360" device smbios device vpd device asmc +#device si + # # Laptop/Notebook options: # From wkoszek at FreeBSD.org Fri Feb 6 16:06:15 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 16:06:27 2009 Subject: svn commit: r188256 - head/sys/i386/conf Message-ID: <200902070006.n1706EZJ075150@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 00:06:13 2009 New Revision: 188256 URL: http://svn.freebsd.org/changeset/base/188256 Log: Tidy NOTES a bit: - leave pmtimer comment that is common to other architectures. - bring pbio explanation to the block comment relating to other drivers in the same block. Modified: head/sys/i386/conf/NOTES Modified: head/sys/i386/conf/NOTES ============================================================================== --- head/sys/i386/conf/NOTES Sat Feb 7 00:05:10 2009 (r188255) +++ head/sys/i386/conf/NOTES Sat Feb 7 00:06:13 2009 (r188256) @@ -714,10 +714,11 @@ device glxsb # AMD Geode LX Security B # # apm: Laptop Advanced Power Management (experimental) # ipmi: Intelligent Platform Management Interface -# pmtimer: Timer device driver for power management events (APM or ACPI) # smapi: System Management Application Program Interface driver # smbios: DMI/SMBIOS entry point # vpd: Vital Product Data kernel interface +# pmtimer: Adjust system timer at wakeup time +# pbio: Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) # spic: Sony Programmable I/O controller (VAIO notebooks) # asmc: Apple System Management Controller @@ -749,8 +750,7 @@ device ipmi device smapi device smbios device vpd -device pmtimer # Adjust system timer at wakeup time -# Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) +device pmtimer device pbio hint.pbio.0.at="isa" hint.pbio.0.port="0x360" From wkoszek at FreeBSD.org Fri Feb 6 16:15:31 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 16:15:46 2009 Subject: svn commit: r188257 - head/sys/pc98/conf Message-ID: <200902070015.n170FU58075372@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 00:15:30 2009 New Revision: 188257 URL: http://svn.freebsd.org/changeset/base/188257 Log: Tidy NOTES a bit: - ath(4) is the last listed device, so make it's comment last as well - since we have hints for le(4), bring it back by inserting commented out line until I check, if it can be safely enabled. - bring snc(4) explanation - put pmtimer comment together with other drivers' comments in a block - bring comments for canbus, canbepm, pmc olpt comment has been left blank, since I don't know how does this driver differ from other printer drivers. Modified: head/sys/pc98/conf/NOTES Modified: head/sys/pc98/conf/NOTES ============================================================================== --- head/sys/pc98/conf/NOTES Sat Feb 7 00:06:13 2009 (r188256) +++ head/sys/pc98/conf/NOTES Sat Feb 7 00:15:30 2009 (r188257) @@ -271,6 +271,9 @@ device isa # BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to # reset the CPU for reboot. This is needed on some systems with broken # keyboard controllers. +# +# EPSON_BOUNCEDMA: XXX +# EPSON_MEMWIN: XXX options AUTO_EOI_1 @@ -368,7 +371,6 @@ hint.mse.0.irq="13" # ar: Arnet SYNC/570i hdlc sync 2/4 port V.35/X.21 serial driver # (requires sppp) -# ath: Atheros a/b/g WiFi adapters (requires ath_hal and wlan) # ce: Cronyx Tau-PCI/32 sync single/dual port G.703/E1 serial adaptor # with 32 HDLC subchannels (requires sppp (default), or NETGRAPH if # NETGRAPH_CRONYX is configured) @@ -382,10 +384,13 @@ hint.mse.0.irq="13" # (requires miibus) # ie: AT&T StarLAN 10 and EN100; 3Com 3C507; unknown NI5210; # Intel EtherExpress +# le: AMD Am7900 LANCE and Am79C9xx ILACC/PCnet Ethernet interface driver # ral: Ralink Technology IEEE 802.11 wireless adapter # sbni: Granch SBNI12-xx ISA and PCI adapters +# snc: National Semiconductor DP8393X SONIC Ethernet adapter driver # sr: RISCom/N2 hdlc sync 1/2 port V.35/X.21 serial driver (requires sppp) # ural: Ralink Technology RT2500USB IEEE 802.11 wireless adapter +# ath: Atheros a/b/g WiFi adapters (requires ath_hal and wlan) # Order for ISA/EISA devices is important here @@ -403,6 +408,7 @@ hint.ie.2.at="isa" hint.ie.2.port="0x300" hint.ie.2.irq="5" hint.ie.2.maddr="0xd0000" +#device le # Hint for the PC98-only C-NET(98)S C-bus front-end of le(4). hint.le.0.at="isa" hint.le.0.port="0x03d0" @@ -464,8 +470,13 @@ options SAFE_RNDTEST # enable rndtest s # Miscellaneous hardware: # # apm: Laptop Advanced Power Management (experimental) +# canbus: CanBe I/O Bus +# canbepm: CanBe Power Management Controller +# olpt: XXX +# pmc: Power Management Controller of NEC PC-98Note # pmtimer: Timer device driver for power management events (APM or ACPI) - +# Adjusts system timer at wakeup time +# # Notes on APM # The flags takes the following meaning for apm0: # 0x0020 Statclock is broken. @@ -480,7 +491,7 @@ hint.olpt.0.port="0x040" device pmc hint.pmc.0.at="isa" hint.pmc.0.port="0x8f0" -device pmtimer # Adjust system timer at wakeup time +device pmtimer # # Laptop/Notebook options: From wkoszek at FreeBSD.org Fri Feb 6 16:52:13 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 16:52:24 2009 Subject: svn commit: r188257 - head/sys/pc98/conf In-Reply-To: <200902070015.n170FU58075372@svn.freebsd.org> References: <200902070015.n170FU58075372@svn.freebsd.org> Message-ID: <20090206235424.GK83537@FreeBSD.org> On Sat, Feb 07, 2009 at 12:15:30AM +0000, Wojciech A. Koszek wrote: > Author: wkoszek > Date: Sat Feb 7 00:15:30 2009 > New Revision: 188257 > URL: http://svn.freebsd.org/changeset/base/188257 > [..] > Modified: head/sys/pc98/conf/NOTES > ============================================================================== > --- head/sys/pc98/conf/NOTES Sat Feb 7 00:06:13 2009 (r188256) > +++ head/sys/pc98/conf/NOTES Sat Feb 7 00:15:30 2009 (r188257) > @@ -271,6 +271,9 @@ device isa > # BROKEN_KEYBOARD_RESET disables the use of the keyboard controller to > # reset the CPU for reboot. This is needed on some systems with broken > # keyboard controllers. > +# > +# EPSON_BOUNCEDMA: XXX > +# EPSON_MEMWIN: XXX Those had no respective comment lines, and I didn't know what those options do. I expect someone to fill those, or at least present 'ready to commit' comments on what they do. -- Wojciech A. Koszek wkoszek@FreeBSD.org http://people.freebsd.org/~wkoszek/ From sam at FreeBSD.org Fri Feb 6 17:12:52 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 17:12:59 2009 Subject: svn commit: r188258 - head/sbin/ifconfig Message-ID: <200902070112.n171CpZg076468@svn.freebsd.org> Author: sam Date: Sat Feb 7 01:12:51 2009 New Revision: 188258 URL: http://svn.freebsd.org/changeset/base/188258 Log: Regulatory fixups: o add missing channel flags for ECM, indoor, and outdoor constraints o use HT capabilities to short-circuit HT20/HT40 channel construction o rewrite 1/2 and 1/4 width channel handling yet again; previously we assumed there was a full-width version of the channel in the calibration table but that's not always true (e.g. for the Public Safety Band), now we first check the calibration table for the exact channel we want then fall back to the heuristics we used before o fix HT channel construction; wasn't adjusting band edges for HT40 channel bandwidth requirements Modified: head/sbin/ifconfig/ifieee80211.c head/sbin/ifconfig/regdomain.c head/sbin/ifconfig/regdomain.h Modified: head/sbin/ifconfig/ifieee80211.c ============================================================================== --- head/sbin/ifconfig/ifieee80211.c Sat Feb 7 00:15:30 2009 (r188257) +++ head/sbin/ifconfig/ifieee80211.c Sat Feb 7 01:12:51 2009 (r188258) @@ -99,10 +99,6 @@ #define IEEE80211_FIXED_RATE_NONE 0xff #endif -#define REQ_ECM 0x01000000 /* enable if ECM set */ -#define REQ_OUTDOOR 0x02000000 /* enable for outdoor operation */ -#define REQ_FLAGS 0xff000000 /* private flags, don't pass to os */ - /* XXX need these publicly defined or similar */ #ifndef IEEE80211_NODE_AUTH #define IEEE80211_NODE_AUTH 0x0001 /* authorized for data */ @@ -1802,6 +1798,57 @@ chanfind(const struct ieee80211_channel return 0; } +/* + * Check channel compatibility. + */ +static int +checkchan(const struct ieee80211req_chaninfo *avail, int freq, int flags) +{ + flags &= ~REQ_FLAGS; + /* + * Check if exact channel is in the calibration table; + * everything below is to deal with channels that we + * want to include but that are not explicitly listed. + */ + if (flags & IEEE80211_CHAN_HT40) { + /* NB: we use an HT40 channel center that matches HT20 */ + flags = (flags &~ IEEE80211_CHAN_HT40) | IEEE80211_CHAN_HT20; + } + if (chanlookup(avail->ic_chans, avail->ic_nchans, freq, flags) != NULL) + return 1; + if (flags & IEEE80211_CHAN_GSM) { + /* + * XXX GSM frequency mapping is handled in the kernel + * so we cannot find them in the calibration table; + * just accept the channel and the kernel will reject + * the channel list if it's wrong. + */ + return 1; + } + /* + * If this is a 1/2 or 1/4 width channel allow it if a full + * width channel is present for this frequency, and the device + * supports fractional channels on this band. This is a hack + * that avoids bloating the calibration table; it may be better + * by per-band attributes though (we are effectively calculating + * this attribute by scanning the channel list ourself). + */ + if ((flags & (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER)) == 0) + return 0; + if (chanlookup(avail->ic_chans, avail->ic_nchans, freq, + flags &~ (IEEE80211_CHAN_HALF | IEEE80211_CHAN_QUARTER)) == NULL) + return 0; + if (flags & IEEE80211_CHAN_HALF) { + return chanfind(avail->ic_chans, avail->ic_nchans, + IEEE80211_CHAN_HALF | + (flags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); + } else { + return chanfind(avail->ic_chans, avail->ic_nchans, + IEEE80211_CHAN_QUARTER | + (flags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); + } +} + static void regdomain_addchans(struct ieee80211req_chaninfo *ci, const netband_head *bands, @@ -1812,15 +1859,12 @@ regdomain_addchans(struct ieee80211req_c const struct netband *nb; const struct freqband *b; struct ieee80211_channel *c, *prev; - int freq, channelSep, hasHalfChans, hasQuarterChans; + int freq, hi_adj, lo_adj, channelSep; + uint32_t flags; + hi_adj = (chanFlags & IEEE80211_CHAN_HT40U) ? -20 : 0; + lo_adj = (chanFlags & IEEE80211_CHAN_HT40D) ? 20 : 0; channelSep = (chanFlags & IEEE80211_CHAN_2GHZ) ? 0 : 40; - hasHalfChans = chanfind(avail->ic_chans, avail->ic_nchans, - IEEE80211_CHAN_HALF | - (chanFlags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); - hasQuarterChans = chanfind(avail->ic_chans, avail->ic_nchans, - IEEE80211_CHAN_QUARTER | - (chanFlags & (IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_5GHZ))); LIST_FOREACH(nb, bands, next) { b = nb->band; if (verbose) { @@ -1831,63 +1875,80 @@ regdomain_addchans(struct ieee80211req_c putchar('\n'); } prev = NULL; - for (freq = b->freqStart; freq <= b->freqEnd; freq += b->chanSep) { - uint32_t flags = nb->flags | b->flags; - - /* check if device can operate on this frequency */ + for (freq = b->freqStart + lo_adj; + freq <= b->freqEnd + hi_adj; freq += b->chanSep) { + /* + * Construct flags for the new channel. We take + * the attributes from the band descriptions except + * for HT40 which is enabled generically (i.e. +/- + * extension channel) in the band description and + * then constrained according by channel separation. + */ + flags = nb->flags | b->flags; + if (flags & IEEE80211_CHAN_HT) { + /* + * HT channels are generated specially; we're + * called to add HT20, HT40+, and HT40- chan's + * so we need to expand only band specs for + * the HT channel type being added. + */ + if ((chanFlags & IEEE80211_CHAN_HT20) && + (flags & IEEE80211_CHAN_HT20) == 0) { + if (verbose) + printf("%u: skip, not an " + "HT20 channel\n", freq); + continue; + } + if ((chanFlags & IEEE80211_CHAN_HT40) && + (flags & IEEE80211_CHAN_HT40) == 0) { + if (verbose) + printf("%u: skip, not an " + "HT40 channel\n", freq); + continue; + } + /* + * DFS and HT40 don't mix. This should be + * expressed in the regdomain database but + * just in case enforce it here. + */ + if ((chanFlags & IEEE80211_CHAN_HT40) && + (flags & IEEE80211_CHAN_DFS)) { + if (verbose) + printf("%u: skip, HT40+DFS " + "not permitted\n", freq); + continue; + } + /* NB: HT attribute comes from caller */ + flags &= ~IEEE80211_CHAN_HT; + flags |= chanFlags & IEEE80211_CHAN_HT; + } /* - * XXX GSM frequency mapping is handled in the kernel - * so we cannot find them in the calibration table; - * just construct the list and the kernel will reject - * if it's wrong. + * Check if device can operate on this frequency. */ - if (chanlookup(avail->ic_chans, avail->ic_nchans, freq, chanFlags) == NULL && - (flags & IEEE80211_CHAN_GSM) == 0) { + if (!checkchan(avail, freq, flags)) { if (verbose) { printf("%u: skip, ", freq); - printb("flags", chanFlags, + printb("flags", flags, IEEE80211_CHAN_BITS); printf(" not available\n"); } continue; } - if ((flags & IEEE80211_CHAN_HALF) && !hasHalfChans) { + if ((flags & REQ_ECM) && !reg->ecm) { if (verbose) - printf("%u: skip, device does not " - "support half-rate channel\n", - freq); + printf("%u: skip, ECM channel\n", freq); continue; } - if ((flags & IEEE80211_CHAN_QUARTER) && - !hasQuarterChans) { + if ((flags & REQ_INDOOR) && reg->location == 'O') { if (verbose) - printf("%u: skip, device does not " - "support quarter-rate channel\n", + printf("%u: skip, indoor channel\n", freq); continue; } - if ((flags & IEEE80211_CHAN_HT20) && - (chanFlags & IEEE80211_CHAN_HT20) == 0) { - if (verbose) - printf("%u: skip, device does not " - "support HT20 operation\n", freq); - continue; - } - if ((flags & IEEE80211_CHAN_HT40) && - (chanFlags & IEEE80211_CHAN_HT40) == 0) { - if (verbose) - printf("%u: skip, device does not " - "support HT40 operation\n", freq); - continue; - } - if ((flags & REQ_ECM) && !reg->ecm) { - if (verbose) - printf("%u: skip, ECM channel\n", freq); - continue; - } if ((flags & REQ_OUTDOOR) && reg->location == 'I') { if (verbose) - printf("%u: skip, outdoor channel\n", freq); + printf("%u: skip, outdoor channel\n", + freq); continue; } if ((flags & IEEE80211_CHAN_HT40) && @@ -1907,8 +1968,7 @@ regdomain_addchans(struct ieee80211req_c c = &ci->ic_chans[ci->ic_nchans++]; memset(c, 0, sizeof(*c)); c->ic_freq = freq; - c->ic_flags = chanFlags | - (flags &~ (REQ_FLAGS | IEEE80211_CHAN_HT40)); + c->ic_flags = flags; if (c->ic_flags & IEEE80211_CHAN_DFS) c->ic_maxregpower = nb->maxPowerDFS; else @@ -1973,27 +2033,31 @@ regdomain_makechannels( if (!LIST_EMPTY(&rd->bands_11a)) regdomain_addchans(ci, &rd->bands_11a, reg, IEEE80211_CHAN_A, &dc->dc_chaninfo); - if (!LIST_EMPTY(&rd->bands_11na)) { + if (!LIST_EMPTY(&rd->bands_11na) && dc->dc_htcaps != 0) { regdomain_addchans(ci, &rd->bands_11na, reg, IEEE80211_CHAN_A | IEEE80211_CHAN_HT20, &dc->dc_chaninfo); - regdomain_addchans(ci, &rd->bands_11na, reg, - IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U, - &dc->dc_chaninfo); - regdomain_addchans(ci, &rd->bands_11na, reg, - IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D, - &dc->dc_chaninfo); + if (dc->dc_htcaps & IEEE80211_HTCAP_CHWIDTH40) { + regdomain_addchans(ci, &rd->bands_11na, reg, + IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U, + &dc->dc_chaninfo); + regdomain_addchans(ci, &rd->bands_11na, reg, + IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D, + &dc->dc_chaninfo); + } } - if (!LIST_EMPTY(&rd->bands_11ng)) { + if (!LIST_EMPTY(&rd->bands_11ng) && dc->dc_htcaps != 0) { regdomain_addchans(ci, &rd->bands_11ng, reg, IEEE80211_CHAN_G | IEEE80211_CHAN_HT20, &dc->dc_chaninfo); - regdomain_addchans(ci, &rd->bands_11ng, reg, - IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U, - &dc->dc_chaninfo); - regdomain_addchans(ci, &rd->bands_11ng, reg, - IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D, - &dc->dc_chaninfo); + if (dc->dc_htcaps & IEEE80211_HTCAP_CHWIDTH40) { + regdomain_addchans(ci, &rd->bands_11ng, reg, + IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U, + &dc->dc_chaninfo); + regdomain_addchans(ci, &rd->bands_11ng, reg, + IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D, + &dc->dc_chaninfo); + } } qsort(ci->ic_chans, ci->ic_nchans, sizeof(ci->ic_chans[0]), regdomain_sort); Modified: head/sbin/ifconfig/regdomain.c ============================================================================== --- head/sbin/ifconfig/regdomain.c Sat Feb 7 00:15:30 2009 (r188257) +++ head/sbin/ifconfig/regdomain.c Sat Feb 7 01:12:51 2009 (r188258) @@ -208,6 +208,9 @@ decode_flag(struct mystate *mt, const ch FLAG(IEEE80211_CHAN_108A), FLAG(IEEE80211_CHAN_108G), #undef FLAG + { "ECM", 3, REQ_ECM }, + { "INDOOR", 6, REQ_INDOOR }, + { "OUTDOOR", 7, REQ_OUTDOOR }, }; int i; Modified: head/sbin/ifconfig/regdomain.h ============================================================================== --- head/sbin/ifconfig/regdomain.h Sat Feb 7 00:15:30 2009 (r188257) +++ head/sbin/ifconfig/regdomain.h Sat Feb 7 01:12:51 2009 (r188258) @@ -45,6 +45,13 @@ struct freqband { LIST_ENTRY(freqband) next; }; +/* private flags, don't pass to os */ +#define REQ_ECM 0x1 /* enable if ECM set */ +#define REQ_INDOOR 0x2 /* enable only for indoor operation */ +#define REQ_OUTDOOR 0x4 /* enable only for outdoor operation */ + +#define REQ_FLAGS (REQ_ECM|REQ_INDOOR|REQ_OUTDOOR) + struct netband { const struct freqband *band; /* channel list description */ uint8_t maxPower; /* regulatory cap on tx power (dBm) */ From nwhitehorn at FreeBSD.org Fri Feb 6 17:15:14 2009 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Fri Feb 6 17:15:20 2009 Subject: svn commit: r188259 - head/sys/dev/sound/macio Message-ID: <200902070115.n171FD48076553@svn.freebsd.org> Author: nwhitehorn Date: Sat Feb 7 01:15:13 2009 New Revision: 188259 URL: http://svn.freebsd.org/changeset/base/188259 Log: Rearrange this code slightly to pass softcs around instead of device_t, solving a possible panic when snd_ai2s is loaded at boot time. Also change the device setup to indicate to the pcm layer that the device is MPSAFE. Submitted by: Marco Trillo Suggestions by: Ariff Abdullah Modified: head/sys/dev/sound/macio/aoa.c head/sys/dev/sound/macio/aoa.h head/sys/dev/sound/macio/davbus.c head/sys/dev/sound/macio/i2s.c head/sys/dev/sound/macio/snapper.c head/sys/dev/sound/macio/tumbler.c Modified: head/sys/dev/sound/macio/aoa.c ============================================================================== --- head/sys/dev/sound/macio/aoa.c Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/aoa.c Sat Feb 7 01:15:13 2009 (r188259) @@ -104,13 +104,14 @@ aoa_dma_set_program(struct aoa_dma *dma) #define AOA_BUFFER_SIZE 65536 static struct aoa_dma * -aoa_dma_create(device_t self) +aoa_dma_create(struct aoa_softc *sc) { - struct aoa_softc *sc = pcm_getdevinfo(self); struct aoa_dma *dma; bus_dma_tag_t tag; int err; + device_t self; + self = sc->sc_dev; err = bus_dma_tag_create(bus_get_dma_tag(self), 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, AOA_BUFFER_SIZE, 1, AOA_BUFFER_SIZE, 0, NULL, NULL, &tag); @@ -214,14 +215,13 @@ static void * aoa_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir) { - device_t self = devinfo; - struct aoa_softc *sc = pcm_getdevinfo(self); + struct aoa_softc *sc = devinfo; struct aoa_dma *dma; int max_slots, err; KASSERT(dir == PCMDIR_PLAY, ("bad dir")); - dma = aoa_dma_create(self); + dma = aoa_dma_create(sc); if (!dma) return (NULL); dma->pcm = c; @@ -230,7 +230,7 @@ aoa_chan_init(kobj_t obj, void *devinfo, /* One slot per block, plus branch to 0 plus STOP. */ max_slots = 2 + dma->bufsz / dma->blksz; - err = dbdma_allocate_channel(dma->reg, 0, bus_get_dma_tag(self), + err = dbdma_allocate_channel(dma->reg, 0, bus_get_dma_tag(sc->sc_dev), max_slots, &dma->channel ); if (err != 0) { aoa_dma_delete(dma); @@ -308,9 +308,9 @@ aoa_chan_free(kobj_t obj, void *data) } void -aoa_interrupt(void *arg) +aoa_interrupt(void *xsc) { - struct aoa_softc *sc = arg; + struct aoa_softc *sc = xsc; struct aoa_dma *dma; if (!(dma = sc->sc_intrp) || !dma->running) @@ -357,11 +357,16 @@ static kobj_method_t aoa_chan_methods[] CHANNEL_DECLARE(aoa_chan); int -aoa_attach(device_t self, void *sc) +aoa_attach(void *xsc) { char status[SND_STATUSLEN]; + struct aoa_softc *sc; + device_t self; int err; + sc = xsc; + self = sc->sc_dev; + if (pcm_register(self, sc, 1, 0)) return (ENXIO); @@ -369,7 +374,7 @@ aoa_attach(device_t self, void *sc) AOA_BUFFER_SIZE); DPRINTF(("pcm_getbuffersize returned %d\n", err)); - pcm_addchan(self, PCMDIR_PLAY, &aoa_chan_class, self); + pcm_addchan(self, PCMDIR_PLAY, &aoa_chan_class, sc); snprintf(status, sizeof(status), "at %s", ofw_bus_get_name(self)); pcm_setstatus(self, status); Modified: head/sys/dev/sound/macio/aoa.h ============================================================================== --- head/sys/dev/sound/macio/aoa.h Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/aoa.h Sat Feb 7 01:15:13 2009 (r188259) @@ -35,12 +35,13 @@ #endif struct aoa_softc { - void *sc_intrp; - struct resource *sc_odma; + device_t sc_dev; + void *sc_intrp; + struct resource *sc_odma; }; void aoa_interrupt(void *); -int aoa_attach(device_t, void *sc); +int aoa_attach(void *xsc); #endif /* SOUND_AOA_H */ Modified: head/sys/dev/sound/macio/davbus.c ============================================================================== --- head/sys/dev/sound/macio/davbus.c Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/davbus.c Sat Feb 7 01:15:13 2009 (r188259) @@ -52,7 +52,6 @@ struct davbus_softc { struct aoa_softc aoa; - device_t dev; phandle_t node; phandle_t soundnode; struct resource *reg; @@ -497,7 +496,7 @@ davbus_attach(device_t self) sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); - sc->dev = self; + sc->aoa.sc_dev = self; sc->node = ofw_bus_get_node(self); sc->soundnode = OF_child(sc->node); @@ -529,8 +528,8 @@ davbus_attach(device_t self) if (err != 0) return (err); - bus_setup_intr(self, dbdma_irq, INTR_TYPE_AV | INTR_MPSAFE, - NULL, aoa_interrupt, sc, &cookie); + snd_setup_intr(self, dbdma_irq, INTR_MPSAFE, aoa_interrupt, + sc, &cookie); /* Now initialize the controller. */ @@ -555,7 +554,7 @@ davbus_attach(device_t self) DAVBUS_OUTPUT_SUBFRAME0 | DAVBUS_RATE_44100 | DAVBUS_INTR_PORTCHG); /* Attach DBDMA engine and PCM layer */ - err = aoa_attach(self,sc); + err = aoa_attach(sc); if (err) return (err); Modified: head/sys/dev/sound/macio/i2s.c ============================================================================== --- head/sys/dev/sound/macio/i2s.c Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/i2s.c Sat Feb 7 01:15:13 2009 (r188259) @@ -78,7 +78,6 @@ struct i2s_softc { struct aoa_softc aoa; - device_t dev; phandle_t node; phandle_t soundnode; struct resource *reg; @@ -179,7 +178,7 @@ i2s_attach(device_t self) sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); - sc->dev = self; + sc->aoa.sc_dev = self; sc->node = ofw_bus_get_node(self); port = of_find_firstchild_byname(sc->node, "i2s-a"); @@ -216,8 +215,8 @@ i2s_attach(device_t self) if (err != 0) return (err); - bus_setup_intr(self, dbdma_irq, INTR_TYPE_AV | INTR_MPSAFE, NULL, - aoa_interrupt, sc, &dbdma_ih); + snd_setup_intr(self, dbdma_irq, INTR_MPSAFE, aoa_interrupt, + sc, &dbdma_ih); oirq = rman_get_start(dbdma_irq); err = powerpc_config_intr(oirq, INTR_TRIGGER_EDGE, INTR_POLARITY_LOW); @@ -233,12 +232,12 @@ i2s_attach(device_t self) return (ENOMEM); i2s_delayed_attach->ich_func = i2s_postattach; - i2s_delayed_attach->ich_arg = self; + i2s_delayed_attach->ich_arg = sc; if (config_intrhook_establish(i2s_delayed_attach) != 0) return (ENOMEM); - return (aoa_attach(self,sc)); + return (aoa_attach(sc)); } /***************************************************************************** @@ -717,16 +716,13 @@ i2s_set_outputs(void *ptr, u_int mask) } static void -i2s_postattach(void *arg) +i2s_postattach(void *xsc) { - device_t self = arg; - struct i2s_softc *sc; + struct i2s_softc *sc = xsc; + device_t self; int i; - KASSERT(self != NULL, ("bad arg")); - KASSERT(i2s_delayed_attach != NULL, ("bogus call")); - - sc = pcm_getdevinfo(self); + self = sc->aoa.sc_dev; /* Reset the codec. */ i2s_audio_hw_reset(sc); Modified: head/sys/dev/sound/macio/snapper.c ============================================================================== --- head/sys/dev/sound/macio/snapper.c Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/snapper.c Sat Feb 7 01:15:13 2009 (r188259) @@ -433,10 +433,14 @@ static int snapper_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) { struct snapper_softc *sc; + struct mtx *mixer_lock; + int locked; u_int l, r; u_char reg[6]; sc = device_get_softc(mix_getdevinfo(m)); + mixer_lock = mixer_get_lock(m); + locked = mtx_owned(mixer_lock); if (left > 100 || right > 100) return (0); @@ -452,8 +456,22 @@ snapper_set(struct snd_mixer *m, unsigne reg[3] = (r & 0xff0000) >> 16; reg[4] = (r & 0x00ff00) >> 8; reg[5] = r & 0x0000ff; + + /* + * We need to unlock the mixer lock because iicbus_transfer() + * may sleep. The mixer lock itself is unnecessary here + * because it is meant to serialize hardware access, which + * is taken care of by the I2C layer, so this is safe. + */ + + if (locked) + mtx_unlock(mixer_lock); + snapper_write(sc, SNAPPER_VOLUME, reg); + if (locked) + mtx_lock(mixer_lock); + return (left | (right << 8)); } Modified: head/sys/dev/sound/macio/tumbler.c ============================================================================== --- head/sys/dev/sound/macio/tumbler.c Sat Feb 7 01:12:51 2009 (r188258) +++ head/sys/dev/sound/macio/tumbler.c Sat Feb 7 01:15:13 2009 (r188259) @@ -95,8 +95,6 @@ static int tumbler_reinit(struct snd_mix static int tumbler_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right); static int tumbler_setrecsrc(struct snd_mixer *m, u_int32_t src); -static int tumbler_set_volume(struct tumbler_softc *sc, int left, - int right); static device_method_t tumbler_methods[] = { /* Device interface. */ @@ -381,12 +379,46 @@ static int tumbler_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) { struct tumbler_softc *sc; + struct mtx *mixer_lock; + int locked; + u_int l, r; + u_char reg[6]; sc = device_get_softc(mix_getdevinfo(m)); + mixer_lock = mixer_get_lock(m); + locked = mtx_owned(mixer_lock); switch (dev) { case SOUND_MIXER_VOLUME: - return (tumbler_set_volume(sc, left, right)); + if (left > 100 || right > 100) + return (0); + + l = (left == 0 ? 0 : tumbler_volume_table[left - 1]); + r = (right == 0 ? 0 : tumbler_volume_table[right - 1]); + + reg[0] = (l & 0xff0000) >> 16; + reg[1] = (l & 0x00ff00) >> 8; + reg[2] = l & 0x0000ff; + reg[3] = (r & 0xff0000) >> 16; + reg[4] = (r & 0x00ff00) >> 8; + reg[5] = r & 0x0000ff; + + /* + * We need to unlock the mixer lock because iicbus_transfer() + * may sleep. The mixer lock itself is unnecessary here + * because it is meant to serialize hardware access, which + * is taken care of by the I2C layer, so this is safe. + */ + + if (locked) + mtx_unlock(mixer_lock); + + tumbler_write(sc, TUMBLER_VOLUME, reg); + + if (locked) + mtx_lock(mixer_lock); + + return (left | (right << 8)); } return (0); @@ -398,26 +430,3 @@ tumbler_setrecsrc(struct snd_mixer *m, u return (0); } -static int -tumbler_set_volume(struct tumbler_softc *sc, int left, int right) -{ - u_int l, r; - u_char reg[6]; - - if (left > 100 || right > 100) - return (0); - - l = (left == 0 ? 0 : tumbler_volume_table[left - 1]); - r = (right == 0 ? 0 : tumbler_volume_table[right - 1]); - - reg[0] = (l & 0xff0000) >> 16; - reg[1] = (l & 0x00ff00) >> 8; - reg[2] = l & 0x0000ff; - reg[3] = (r & 0xff0000) >> 16; - reg[4] = (r & 0x00ff00) >> 8; - reg[5] = r & 0x0000ff; - tumbler_write(sc, TUMBLER_VOLUME, reg); - - return (left | (right << 8)); -} - From sam at FreeBSD.org Fri Feb 6 17:53:44 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 17:53:56 2009 Subject: svn commit: r188263 - head/sys/dev/ath/ath_hal Message-ID: <200902070153.n171riGu077517@svn.freebsd.org> Author: sam Date: Sat Feb 7 01:53:44 2009 New Revision: 188263 URL: http://svn.freebsd.org/changeset/base/188263 Log: add macro for future regulatory mods Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain.c Sat Feb 7 01:51:22 2009 (r188262) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Sat Feb 7 01:53:44 2009 (r188263) @@ -74,6 +74,11 @@ typedef uint64_t chanbmask_t[BMLEN]; W0(_fg) | W0(_fh) , \ W1(_fa) | W1(_fb) | W1(_fc) | W1(_fd) | W1(_fe) | W1(_ff) | \ W1(_fg) | W1(_fh) } +#define BM9(_fa, _fb, _fc, _fd, _fe, _ff, _fg, _fh, _fi) \ + { W0(_fa) | W0(_fb) | W0(_fc) | W0(_fd) | W0(_fe) | W0(_ff) | \ + W0(_fg) | W0(_fh) | W0(_fi) , \ + W1(_fa) | W1(_fb) | W1(_fc) | W1(_fd) | W1(_fe) | W1(_ff) | \ + W1(_fg) | W1(_fh) | W1(_fi) } /* * Mask to check whether a domain is a multidomain or a single domain From sam at FreeBSD.org Fri Feb 6 17:54:58 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 17:55:10 2009 Subject: svn commit: r188264 - head/sys/dev/ath/ath_hal Message-ID: <200902070154.n171svoE077604@svn.freebsd.org> Author: sam Date: Sat Feb 7 01:54:57 2009 New Revision: 188264 URL: http://svn.freebsd.org/changeset/base/188264 Log: fix 11n channel construction Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c Modified: head/sys/dev/ath/ath_hal/ah_regdomain.c ============================================================================== --- head/sys/dev/ath/ath_hal/ah_regdomain.c Sat Feb 7 01:53:44 2009 (r188263) +++ head/sys/dev/ath/ath_hal/ah_regdomain.c Sat Feb 7 01:54:57 2009 (r188264) @@ -1706,16 +1706,16 @@ static const struct cmode modes[] = { IEEE80211_CHAN_G | IEEE80211_CHAN_QUARTER }, { HAL_MODE_11G_HALF_RATE, IEEE80211_CHAN_G | IEEE80211_CHAN_HALF }, - { HAL_MODE_11NG_HT20, IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_HT20 }, + { HAL_MODE_11NG_HT20, IEEE80211_CHAN_G | IEEE80211_CHAN_HT20 }, { HAL_MODE_11NG_HT40PLUS, - IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_HT40U }, + IEEE80211_CHAN_G | IEEE80211_CHAN_HT40U }, { HAL_MODE_11NG_HT40MINUS, - IEEE80211_CHAN_2GHZ | IEEE80211_CHAN_HT40D }, - { HAL_MODE_11NA_HT20, IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_HT20 }, + IEEE80211_CHAN_G | IEEE80211_CHAN_HT40D }, + { HAL_MODE_11NA_HT20, IEEE80211_CHAN_A | IEEE80211_CHAN_HT20 }, { HAL_MODE_11NA_HT40PLUS, - IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_HT40U }, + IEEE80211_CHAN_A | IEEE80211_CHAN_HT40U }, { HAL_MODE_11NA_HT40MINUS, - IEEE80211_CHAN_5GHZ | IEEE80211_CHAN_HT40D }, + IEEE80211_CHAN_A | IEEE80211_CHAN_HT40D }, }; static OS_INLINE uint16_t From wkoszek at FreeBSD.org Fri Feb 6 18:14:28 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Fri Feb 6 18:14:40 2009 Subject: svn commit: r188266 - head/sys/dev/si Message-ID: <200902070214.n172ESMM078224@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 02:14:27 2009 New Revision: 188266 URL: http://svn.freebsd.org/changeset/base/188266 Log: si_cmdname() is defined only when SI_DEBUG is enabled, thus using this function in simple printf() causes compile-time problems. Use conditionally enabled DPRINT() macro instead. Modified: head/sys/dev/si/si.c Modified: head/sys/dev/si/si.c ============================================================================== --- head/sys/dev/si/si.c Sat Feb 7 01:59:34 2009 (r188265) +++ head/sys/dev/si/si.c Sat Feb 7 02:14:27 2009 (r188266) @@ -1549,7 +1549,7 @@ si_command(struct si_port *pp, int cmd, /* This is very very bad. The card has crashed. */ /* XXX the driver breaks at this point */ if (err == ETIMEDOUT) - printf("%s: tsleep1 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)); + DPRINT(("%s: tsleep1 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); splx(oldspl); return; } @@ -1586,7 +1586,7 @@ si_command(struct si_port *pp, int cmd, if (err) { DPRINT((pp, DBG_PARAM, "sicmd2 tsleep error: hi_stat (%s) sp_pend (%s)\n", si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); if (err == ETIMEDOUT) { - printf("%s: tsleep2 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend)); + DPRINT(("%s: tsleep2 timeout. hi_stat %s, sp_pend %s\n", pp->sp_name, si_cmdname(ccbp->hi_stat), si_cmdname(pp->sp_pend))); } break; } From sam at FreeBSD.org Fri Feb 6 21:03:25 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 21:03:37 2009 Subject: svn commit: r188267 - head/sys/dev/cfi Message-ID: <200902070503.n1753Pdg081570@svn.freebsd.org> Author: sam Date: Sat Feb 7 05:03:25 2009 New Revision: 188267 URL: http://svn.freebsd.org/changeset/base/188267 Log: expand CFI_ARMEDANDDANGEROUS to include writing the user segment of the PR; this register is actually write-once so deserves the safety-belt as much as the PLR Modified: head/sys/dev/cfi/cfi_core.c Modified: head/sys/dev/cfi/cfi_core.c ============================================================================== --- head/sys/dev/cfi/cfi_core.c Sat Feb 7 02:14:27 2009 (r188266) +++ head/sys/dev/cfi/cfi_core.c Sat Feb 7 05:03:25 2009 (r188267) @@ -438,9 +438,9 @@ cfi_write_block(struct cfi_softc *sc) * used for security. There are two 64-bit segments; one is programmed * at the factory with a unique 64-bit number which is immutable. * The other segment is left blank for User (OEM) programming. - * Once the User/OEM segment is programmed it can be locked - * to prevent future programming by writing bit 0 of the Protection - * Lock Register (PLR). The PLR can written only once. + * The User/OEM segment is One Time Programmable (OTP). It can also + * be locked to prevent any firther writes by setting bit 0 of the + * Protection Lock Register (PLR). The PLR can written only once. */ static uint16_t @@ -496,17 +496,21 @@ cfi_intel_get_oem_pr(struct cfi_softc *s /* * Write the User/OEM 64-bit segment of the PR. + * XXX should allow writing individual words/bytes */ int cfi_intel_set_oem_pr(struct cfi_softc *sc, uint64_t id) { +#ifdef CFI_ARMEDANDDANGEROUS register_t intr; int i, error; +#endif if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) return EOPNOTSUPP; KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); +#ifdef CFI_ARMEDANDDANGEROUS for (i = 7; i >= 4; i--, id >>= 16) { intr = intr_disable(); cfi_write(sc, 0, CFI_INTEL_PP_SETUP); @@ -519,6 +523,11 @@ cfi_intel_set_oem_pr(struct cfi_softc *s } cfi_write(sc, 0, CFI_BCS_READ_ARRAY); return error; +#else + device_printf(sc->sc_dev, "%s: OEM PR not set, " + "CFI_ARMEDANDDANGEROUS not configured\n", __func__); + return ENXIO; +#endif } /* From sam at FreeBSD.org Fri Feb 6 21:32:19 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 21:32:25 2009 Subject: svn commit: r188268 - head/sys/dev/cfi Message-ID: <200902070532.n175WJrp082067@svn.freebsd.org> Author: sam Date: Sat Feb 7 05:32:19 2009 New Revision: 188268 URL: http://svn.freebsd.org/changeset/base/188268 Log: fix building w/o CFI_ARMEDANDDANGEROUS Modified: head/sys/dev/cfi/cfi_core.c Modified: head/sys/dev/cfi/cfi_core.c ============================================================================== --- head/sys/dev/cfi/cfi_core.c Sat Feb 7 05:03:25 2009 (r188267) +++ head/sys/dev/cfi/cfi_core.c Sat Feb 7 05:32:19 2009 (r188268) @@ -450,11 +450,13 @@ cfi_get16(struct cfi_softc *sc, int off) return v; } +#ifdef CFI_ARMEDANDDANGEROUS static void cfi_put16(struct cfi_softc *sc, int off, uint16_t v) { bus_space_write_2(sc->sc_tag, sc->sc_handle, off<<1, v); } +#endif /* * Read the factory-defined 64-bit segment of the PR. @@ -556,9 +558,8 @@ cfi_intel_set_plr(struct cfi_softc *sc) { #ifdef CFI_ARMEDANDDANGEROUS register_t intr; -#endif int error; - +#endif if (sc->sc_cmdset != CFI_VEND_INTEL_ECS) return EOPNOTSUPP; KASSERT(sc->sc_width == 2, ("sc_width %d", sc->sc_width)); @@ -572,11 +573,11 @@ cfi_intel_set_plr(struct cfi_softc *sc) intr_restore(intr); error = cfi_wait_ready(sc, CFI_BCS_READ_STATUS, sc->sc_write_timeout); cfi_write(sc, 0, CFI_BCS_READ_ARRAY); + return error; #else device_printf(sc->sc_dev, "%s: PLR not set, " "CFI_ARMEDANDDANGEROUS not configured\n", __func__); - error = ENXIO; + return ENXIO; #endif - return error; } #endif /* CFI_SUPPORT_STRATAFLASH */ From sam at FreeBSD.org Fri Feb 6 21:34:42 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Fri Feb 6 21:34:53 2009 Subject: svn commit: r188269 - head/sys/dev/ath Message-ID: <200902070534.n175Yfcs082154@svn.freebsd.org> Author: sam Date: Sat Feb 7 05:34:41 2009 New Revision: 188269 URL: http://svn.freebsd.org/changeset/base/188269 Log: count stuck beacon events Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Sat Feb 7 05:32:19 2009 (r188268) +++ head/sys/dev/ath/if_ath.c Sat Feb 7 05:34:41 2009 (r188269) @@ -3343,6 +3343,7 @@ ath_bstuck_proc(void *arg, int pending) if_printf(ifp, "stuck beacon; resetting (bmiss count %u)\n", sc->sc_bmisscount); + sc->sc_stats.ast_bstuck++; ath_reset(ifp); } From das at FreeBSD.org Fri Feb 6 21:41:25 2009 From: das at FreeBSD.org (David Schultz) Date: Fri Feb 6 21:41:36 2009 Subject: svn commit: r188272 - head/lib/msun/src Message-ID: <200902070541.n175fOQh082420@svn.freebsd.org> Author: das Date: Sat Feb 7 05:41:24 2009 New Revision: 188272 URL: http://svn.freebsd.org/changeset/base/188272 Log: C99 TC2 now wants FP_FAST_FMA* to be defined to 1, if the macros are defined at all. See also: defect report #223. Modified: head/lib/msun/src/math.h Modified: head/lib/msun/src/math.h ============================================================================== --- head/lib/msun/src/math.h Sat Feb 7 05:39:05 2009 (r188271) +++ head/lib/msun/src/math.h Sat Feb 7 05:41:24 2009 (r188272) @@ -70,12 +70,12 @@ extern const union __nan_un { /* XXX We need a . */ #if defined(__ia64__) || defined(__sparc64__) -#define FP_FAST_FMA +#define FP_FAST_FMA 1 #endif #ifdef __ia64__ -#define FP_FAST_FMAL +#define FP_FAST_FMAL 1 #endif -#define FP_FAST_FMAF +#define FP_FAST_FMAF 1 /* Symbolic constants to classify floating point numbers. */ #define FP_INFINITE 0x01 From thompsa at FreeBSD.org Fri Feb 6 22:27:18 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Fri Feb 6 22:27:24 2009 Subject: svn commit: r188273 - head/sys/dev/usb2/controller Message-ID: <200902070627.n176RGEa083276@svn.freebsd.org> Author: thompsa Date: Sat Feb 7 06:27:16 2009 New Revision: 188273 URL: http://svn.freebsd.org/changeset/base/188273 Log: Dont hold the lock over the controller init, we are still attaching. Modified: head/sys/dev/usb2/controller/ehci2.c head/sys/dev/usb2/controller/ohci2.c head/sys/dev/usb2/controller/uhci2.c Modified: head/sys/dev/usb2/controller/ehci2.c ============================================================================== --- head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 05:41:24 2009 (r188272) +++ head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 06:27:16 2009 (r188273) @@ -223,8 +223,6 @@ ehci_init(ehci_softc_t *sc) uint16_t bit; usb2_error_t err = 0; - USB_BUS_LOCK(&sc->sc_bus); - DPRINTF("start\n"); usb2_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx, 0); @@ -259,10 +257,12 @@ ehci_init(ehci_softc_t *sc) /* Reset the controller */ DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev)); + USB_BUS_LOCK(&sc->sc_bus); err = ehci_hc_reset(sc); + USB_BUS_UNLOCK(&sc->sc_bus); if (err) { device_printf(sc->sc_bus.bdev, "reset timeout\n"); - goto done; + return (error); } /* * use current frame-list-size selection 0: 1024*4 bytes 1: 512*4 @@ -270,8 +270,7 @@ ehci_init(ehci_softc_t *sc) */ if (EHCI_CMD_FLS(EOREAD4(sc, EHCI_USBCMD)) == 3) { device_printf(sc->sc_bus.bdev, "invalid frame-list-size\n"); - err = USB_ERR_IOERROR; - goto done; + return (USB_ERR_IOERROR); } /* set up the bus struct */ sc->sc_bus.methods = &ehci_bus_methods; @@ -479,7 +478,7 @@ ehci_init(ehci_softc_t *sc) EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF); for (i = 0; i < 100; i++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(NULL, 1); hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; if (!hcr) { break; @@ -487,11 +486,8 @@ ehci_init(ehci_softc_t *sc) } if (hcr) { device_printf(sc->sc_bus.bdev, "run timeout\n"); - err = USB_ERR_IOERROR; - goto done; + return (USB_ERR_IOERROR); } -done: - USB_BUS_UNLOCK(&sc->sc_bus); if (!err) { /* catch any lost interrupts */ Modified: head/sys/dev/usb2/controller/ohci2.c ============================================================================== --- head/sys/dev/usb2/controller/ohci2.c Sat Feb 7 05:41:24 2009 (r188272) +++ head/sys/dev/usb2/controller/ohci2.c Sat Feb 7 06:27:16 2009 (r188273) @@ -168,7 +168,7 @@ ohci_controller_init(ohci_softc_t *sc) DPRINTF("SMM active, request owner change\n"); OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_OCR); for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(NULL, 1); ctl = OREAD4(sc, OHCI_CONTROL); } if (ctl & OHCI_IR) { @@ -181,8 +181,7 @@ ohci_controller_init(ohci_softc_t *sc) DPRINTF("cold started\n"); reset: /* controller was cold started */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_BUS_RESET_DELAY); + usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY); } /* @@ -192,8 +191,7 @@ reset: DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev)); OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); - usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_BUS_RESET_DELAY); + usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY); /* we now own the host controller and the bus has been reset */ ival = OHCI_GET_IVAL(OREAD4(sc, OHCI_FM_INTERVAL)); @@ -255,8 +253,7 @@ reset: desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A); OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP); OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, - OHCI_ENABLE_POWER_DELAY); + usb2_pause_mtx(NULL, OHCI_ENABLE_POWER_DELAY); OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca); /* @@ -265,8 +262,7 @@ reset: */ sc->sc_noport = 0; for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, - OHCI_READ_DESC_DELAY); + usb2_pause_mtx(NULL, OHCI_READ_DESC_DELAY); sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A)); } @@ -304,8 +300,6 @@ ohci_init(ohci_softc_t *sc) uint16_t x; uint16_t y; - USB_BUS_LOCK(&sc->sc_bus); - DPRINTF("start\n"); sc->sc_eintrs = OHCI_NORMAL_INTRS; @@ -402,10 +396,8 @@ ohci_init(ohci_softc_t *sc) sc->sc_bus.usbrev = USB_REV_1_0; if (ohci_controller_init(sc)) { - USB_BUS_UNLOCK(&sc->sc_bus); return (USB_ERR_INVAL); } else { - USB_BUS_UNLOCK(&sc->sc_bus); /* catch any lost interrupts */ ohci_do_poll(&sc->sc_bus); return (USB_ERR_NORMAL_COMPLETION); @@ -473,8 +465,6 @@ ohci_resume(ohci_softc_t *sc) { uint32_t ctl; - USB_BUS_LOCK(&sc->sc_bus); - #if USB_DEBUG DPRINTF("\n"); if (ohcidebug > 2) { @@ -484,6 +474,7 @@ ohci_resume(ohci_softc_t *sc) /* some broken BIOSes never initialize the Controller chip */ ohci_controller_init(sc); + USB_BUS_LOCK(&sc->sc_bus); if (sc->sc_intre) { OWRITE4(sc, OHCI_INTERRUPT_ENABLE, sc->sc_intre & (OHCI_ALL_INTRS | OHCI_MIE)); Modified: head/sys/dev/usb2/controller/uhci2.c ============================================================================== --- head/sys/dev/usb2/controller/uhci2.c Sat Feb 7 05:41:24 2009 (r188272) +++ head/sys/dev/usb2/controller/uhci2.c Sat Feb 7 06:27:16 2009 (r188273) @@ -406,8 +406,6 @@ uhci_init(uhci_softc_t *sc) uint16_t x; uint16_t y; - USB_BUS_LOCK(&sc->sc_bus); - DPRINTF("start\n"); #if USB_DEBUG @@ -597,12 +595,12 @@ uhci_init(uhci_softc_t *sc) /* set up the bus struct */ sc->sc_bus.methods = &uhci_bus_methods; + USB_BUS_LOCK(&sc->sc_bus); /* reset the controller */ uhci_reset(sc); /* start the controller */ uhci_start(sc); - USB_BUS_UNLOCK(&sc->sc_bus); /* catch lost interrupts */ From wkoszek at FreeBSD.org Sat Feb 7 01:57:15 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sat Feb 7 01:57:27 2009 Subject: svn commit: r188274 - in head/sys: conf ia64/conf Message-ID: <200902070957.n179vEGd087181@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 09:57:14 2009 New Revision: 188274 URL: http://svn.freebsd.org/changeset/base/188274 Log: Don't forget to create opt_agp.h on ia64, which also uses agp(4). Modified: head/sys/conf/options.ia64 head/sys/ia64/conf/NOTES Modified: head/sys/conf/options.ia64 ============================================================================== --- head/sys/conf/options.ia64 Sat Feb 7 06:27:16 2009 (r188273) +++ head/sys/conf/options.ia64 Sat Feb 7 09:57:14 2009 (r188274) @@ -20,6 +20,9 @@ VGA_NO_MODE_CHANGE opt_vga.h VGA_SLOW_IOACCESS opt_vga.h VGA_WIDTH90 opt_vga.h +# AGP debugging. +AGP_DEBUG opt_agp.h + PSM_HOOKRESUME opt_psm.h PSM_RESETAFTERSUSPEND opt_psm.h PSM_DEBUG opt_psm.h Modified: head/sys/ia64/conf/NOTES ============================================================================== --- head/sys/ia64/conf/NOTES Sat Feb 7 06:27:16 2009 (r188273) +++ head/sys/ia64/conf/NOTES Sat Feb 7 09:57:14 2009 (r188274) @@ -101,6 +101,9 @@ options VGA_WIDTH90 # support 90 colum # Debugging. options VGA_DEBUG +# AGP debugging. +options AGP_DEBUG + # The following devices are not supported. nodevice fdc nooption FDC_DEBUG From niclas.zeising at gmail.com Sat Feb 7 02:59:36 2009 From: niclas.zeising at gmail.com (Niclas Zeising) Date: Sat Feb 7 02:59:47 2009 Subject: svn commit: r188273 - head/sys/dev/usb2/controller In-Reply-To: <200902070627.n176RGEa083276@svn.freebsd.org> References: <200902070627.n176RGEa083276@svn.freebsd.org> Message-ID: <498D698B.5000101@gmail.com> Andrew Thompson wrote: > Author: thompsa > Date: Sat Feb 7 06:27:16 2009 > New Revision: 188273 > URL: http://svn.freebsd.org/changeset/base/188273 > > Log: > Dont hold the lock over the controller init, we are still attaching. > > Modified: > head/sys/dev/usb2/controller/ehci2.c > head/sys/dev/usb2/controller/ohci2.c > head/sys/dev/usb2/controller/uhci2.c > > Modified: head/sys/dev/usb2/controller/ehci2.c > ============================================================================== > --- head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 05:41:24 2009 (r188272) > +++ head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 06:27:16 2009 (r188273) > @@ -223,8 +223,6 @@ ehci_init(ehci_softc_t *sc) > uint16_t bit; > usb2_error_t err = 0; > > - USB_BUS_LOCK(&sc->sc_bus); > - > DPRINTF("start\n"); > > usb2_callout_init_mtx(&sc->sc_tmo_pcd, &sc->sc_bus.bus_mtx, 0); > @@ -259,10 +257,12 @@ ehci_init(ehci_softc_t *sc) > /* Reset the controller */ > DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev)); > > + USB_BUS_LOCK(&sc->sc_bus); > err = ehci_hc_reset(sc); > + USB_BUS_UNLOCK(&sc->sc_bus); > if (err) { > device_printf(sc->sc_bus.bdev, "reset timeout\n"); > - goto done; > + return (error); ^^^^^^^^^^^^^^^ This broke the build. I'm not familiar with the code, but might it be err you want to return since you set it a bit earlier, and it is of the correct type. [SNIP the rest of the diff] Regards! //Niclas -- From wkoszek at FreeBSD.org Sat Feb 7 03:12:31 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sat Feb 7 03:12:42 2009 Subject: svn commit: r188277 - head/usr.sbin/config Message-ID: <200902071112.n17BCVOi090160@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 11:12:30 2009 New Revision: 188277 URL: http://svn.freebsd.org/changeset/base/188277 Log: Remove leftover of alpha support for config(8)--we have MAP_FAILED globally defined. Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Sat Feb 7 10:29:07 2009 (r188276) +++ head/usr.sbin/config/main.c Sat Feb 7 11:12:30 2009 (r188277) @@ -565,9 +565,6 @@ moveifchanged(const char *from_name, con if (!changed) { p = mmap(NULL, tsize, PROT_READ, MAP_SHARED, from_fd, (off_t)0); -#ifndef MAP_FAILED -#define MAP_FAILED ((caddr_t) -1) -#endif if (p == MAP_FAILED) err(EX_OSERR, "mmap %s", from_name); q = mmap(NULL, tsize, PROT_READ, MAP_SHARED, to_fd, (off_t)0); From wkoszek at FreeBSD.org Sat Feb 7 03:40:49 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sat Feb 7 03:41:00 2009 Subject: svn commit: r188280 - head/usr.sbin/config Message-ID: <200902071140.n17Belhp091008@svn.freebsd.org> Author: wkoszek Date: Sat Feb 7 11:40:47 2009 New Revision: 188280 URL: http://svn.freebsd.org/changeset/base/188280 Log: Move the comment to it's correct place. Modified: head/usr.sbin/config/main.c Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Sat Feb 7 11:27:35 2009 (r188279) +++ head/usr.sbin/config/main.c Sat Feb 7 11:40:47 2009 (r188280) @@ -466,6 +466,11 @@ configfile_filebased(struct sbuf *sb) struct cfgfile *cf; int i; + /* + * Try to read all configuration files. Since those will be present as + * C string in the macro, we have to slash their ends then the line + * wraps. + */ STAILQ_FOREACH(cf, &cfgfiles, cfg_next) { cff = fopen(cf->cfg_path, "r"); if (cff == NULL) { @@ -500,11 +505,6 @@ configfile(void) sb = sbuf_new(NULL, NULL, 2048, SBUF_AUTOEXTEND); assert(sb != NULL); sbuf_clear(sb); - /* - * Try to read all configuration files. Since those will be present as - * C string in the macro, we have to slash their ends then the line - * wraps. - */ if (filebased) { /* Is needed, can be used for backward compatibility. */ configfile_filebased(sb); From thompsa at FreeBSD.org Sat Feb 7 07:51:33 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Sat Feb 7 07:51:49 2009 Subject: svn commit: r188292 - head/sys/dev/usb2/controller Message-ID: <200902071551.n17FpWM4097480@svn.freebsd.org> Author: thompsa Date: Sat Feb 7 15:51:32 2009 New Revision: 188292 URL: http://svn.freebsd.org/changeset/base/188292 Log: Fix build, sigh. Modified: head/sys/dev/usb2/controller/ehci2.c Modified: head/sys/dev/usb2/controller/ehci2.c ============================================================================== --- head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 15:51:21 2009 (r188291) +++ head/sys/dev/usb2/controller/ehci2.c Sat Feb 7 15:51:32 2009 (r188292) @@ -262,7 +262,7 @@ ehci_init(ehci_softc_t *sc) USB_BUS_UNLOCK(&sc->sc_bus); if (err) { device_printf(sc->sc_bus.bdev, "reset timeout\n"); - return (error); + return (err); } /* * use current frame-list-size selection 0: 1024*4 bytes 1: 512*4 From bz at FreeBSD.org Sat Feb 7 08:37:03 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Sat Feb 7 08:37:15 2009 Subject: svn commit: r188293 - head/etc/rc.d Message-ID: <200902071637.n17Gb25u098377@svn.freebsd.org> Author: bz Date: Sat Feb 7 16:37:02 2009 New Revision: 188293 URL: http://svn.freebsd.org/changeset/base/188293 Log: Named normally cannot be started chrooted inside a jail. Thus treat the jail case specifically. In case we find a proper pre-seeded devfs in the chroot path (mounted from the base system) permit starting chrooted else give proper warn/error messages. PR: conf/103489 Reviewed by: dougb MFC after: 5 days Modified: head/etc/rc.d/named Modified: head/etc/rc.d/named ============================================================================== --- head/etc/rc.d/named Sat Feb 7 15:51:32 2009 (r188292) +++ head/etc/rc.d/named Sat Feb 7 16:37:02 2009 (r188293) @@ -61,10 +61,23 @@ chroot_autoupdate() # Mount a devfs in the chroot directory if needed # - umount ${named_chrootdir}/dev 2>/dev/null - devfs_domount ${named_chrootdir}/dev devfsrules_hide_all - devfs -m ${named_chrootdir}/dev rule apply path null unhide - devfs -m ${named_chrootdir}/dev rule apply path random unhide + if [ `${SYSCTL_N} security.jail.jailed` -eq 0 ]; then + umount ${named_chrootdir}/dev 2>/dev/null + devfs_domount ${named_chrootdir}/dev devfsrules_hide_all + devfs -m ${named_chrootdir}/dev rule apply path null unhide + devfs -m ${named_chrootdir}/dev rule apply path random unhide + else + if [ -c ${named_chrootdir}/dev/null -a \ + -c ${named_chrootdir}/dev/random ]; then + info "named chroot: using pre-mounted devfs." + else + err 1 "named chroot: devfs cannot be mounted from" \ + "within a jail. Thus a chrooted named cannot" \ + "be run from within a jail." \ + "To run named without chrooting it, set" \ + "named_chrootdir=\"\" in /etc/rc.conf." + fi + fi # Copy and/or update key files to the chroot /etc # @@ -113,7 +126,12 @@ named_stop() named_poststop() { if [ -n "${named_chrootdir}" -a -c ${named_chrootdir}/dev/null ]; then - umount ${named_chrootdir}/dev 2>/dev/null || true + if [ `${SYSCTL_N} security.jail.jailed` -eq 0 ]; then + umount ${named_chrootdir}/dev 2>/dev/null || true + else + warn "named chroot:" \ + "cannot unmount devfs from inside jail!" + fi fi } From piso at FreeBSD.org Sat Feb 7 10:49:43 2009 From: piso at FreeBSD.org (Paolo Pisati) Date: Sat Feb 7 10:49:56 2009 Subject: svn commit: r188294 - in head: sbin sbin/ipfw sys sys/modules/libalias/libalias sys/netinet sys/netinet/libalias Message-ID: <200902071849.n17IngZN000950@svn.freebsd.org> Author: piso Date: Sat Feb 7 18:49:42 2009 New Revision: 188294 URL: http://svn.freebsd.org/changeset/base/188294 Log: Add SCTP NAT support. Submitted by: CAIA (http://caia.swin.edu.au) Added: head/sys/netinet/libalias/alias_sctp.c - copied, changed from r186543, user/piso/sys/netinet/libalias/alias_sctp.c head/sys/netinet/libalias/alias_sctp.h - copied, changed from r186543, user/piso/sys/netinet/libalias/alias_sctp.h Modified: head/sbin/ (props changed) head/sbin/ipfw/ipfw.8 head/sbin/ipfw/nat.c head/sys/ (props changed) head/sys/modules/libalias/libalias/Makefile head/sys/netinet/ip_fw_nat.c head/sys/netinet/libalias/alias.c head/sys/netinet/libalias/alias_db.c head/sys/netinet/libalias/alias_local.h head/sys/netinet/sctp_crc32.c head/sys/netinet/sctp_crc32.h Modified: head/sbin/ipfw/ipfw.8 ============================================================================== --- head/sbin/ipfw/ipfw.8 Sat Feb 7 16:37:02 2009 (r188293) +++ head/sbin/ipfw/ipfw.8 Sat Feb 7 18:49:42 2009 (r188294) @@ -2183,17 +2183,173 @@ Redirect and LSNAT support follow closel See Section .Sx EXAMPLES for some examples on how to do redirect and lsnat. +.Sh SCTP NAT SUPPORT +Sctp nat can be configured in a simillar manner to TCP through the +ipfw command line tool +.Xr ipfw 8 +, the main difference is that +.Nm sctp nat +does not do port +translation. Since the local and global side ports will be the same, +there is no need to specify both. Ports are redirected as follows: +.Bd -ragged -offset indent +.Bk -words +.Cm nat +.Ar nat_number +.Cm config if +.Ar nic +.Cm redirect_port sctp +.Ar ip_address [,addr_list] {[port | port-port] [,ports]} +.Ek +.Ed +.Pp +. +Most +.B sctp nat +configuration can be done in real-time through the +.B sysctl(8) +interface. All may be changed dynamically, though the hash_table size will only +change for new +.Nm nat +instances. See +.Sx SYSCTL VARIABLES +for more info. .Sh SYSCTL VARIABLES A set of .Xr sysctl 8 variables controls the behaviour of the firewall and associated modules -.Pq Nm dummynet , bridge . +.Pq Nm dummynet , bridge , sctp nat . These are shown below together with their default value (but always check with the .Xr sysctl 8 command what value is actually in use) and meaning: .Bl -tag -width indent +.It Va net.inet.ip.alias.sctp.accept_global_ootb_addip: No 0 +Defines how the +.Nm nat +responds to receipt of global OOTB ASCONF-AddIP: +.Bl -tag -width indent +.It Cm 0 +No response (unless a partially matching association exists - +ports and vtags match but global address does not) +.It Cm 1 +.Nm nat +will accept and process all OOTB global AddIP messages. +.El +.Pp +Option 1 should never be selected as this forms a security risk. An attacker can +establish multiple fake associations by sending AddIP messages. +.It Va net.inet.ip.alias.sctp.chunk_proc_limit: No 5 +Defines the maximum number of chunks in an SCTP packet that will be parsed for a +packet that matches an existing association. This value is enforced to be greater or equal +than +.Cm net.inet.ip.alias.sctp.initialising_chunk_proc_limit . +A high value is +a DoS risk yet setting too low a value may result in important control chunks in +the packet not being located and parsed. +.It Va net.inet.ip.alias.sctp.error_on_ootb: No 1 +Defines when the +.Nm nat +responds to any Out-of-the-Blue (OOTB) packets with ErrorM +packets. An OOTB packet is a packet that arrives with no existing association +registered in the +.Nm nat +and is not an INIT or ASCONF-AddIP packet: +.Bl -tag -width indent +.It Cm 0 +ErrorM is never sent in response to OOTB packets. +.It Cm 1 +ErrorM is only sent to OOTB packets received on the local side. +.It Cm 2 +ErrorM is sent to the local side and on the global side ONLY if there is a +partial match (ports and vtags match but the source global IP does not). This +value is only useful if the +.Nm nat +is tracking global IP addresses. +.It Cm 3 +ErrorM is sent in response to all OOTB packets on both the local and global side +(DoS risk). +.El +.Pp +At the moment the default is 0, since the ErrorM packet is not yet +supported by most SCTP stacks. When it is supported, and if not tracking +global addresses, we recommend setting this value to 1 to allow +multi-homed local hosts to function with the +.Nm nat . +To track global addresses, we recommend setting this value to 2 to +allow global hosts to be informed when they need to (re)send an +ASCONF-AddIP. Value 3 should never be chosen (except for debugging) as +the +.Nm nat +will respond to all OOTB global packets (a DoS risk). +.It Va net.inet.ip.alias.sctp.hashtable_size: No 2003 +Size of hash tables used for +.Nm nat +lookups (100 < prime_number > 1000001) +This value sets the +.Nm hash table +size for any future created +.Nm nat +instance and therefore must be set prior to creating a +.Nm nat +instance. +The table sizes my be changed to suit specific needs. If there will be few +concurrent associations, and memory is scarce, you may make these smaller. If +there will be many thousands (or millions) of concurrent associations, you +should make these larger. A prime number is best for the table size. The sysctl +update function will adjust your input value to the next highest prime number. +.It Va net.inet.ip.alias.sctp.holddown_time: No 0 +Hold association in table for this many seconds after receiving a +SHUTDOWN-COMPLETE. This allows endpoints to correct shutdown gracefully if a +shutdown_complete is lost and retransmissions are required. +.It Va net.inet.ip.alias.sctp.init_timer: No 15 +Timeout value while waiting for (INIT-ACK|AddIP-ACK). +This value cannot be 0. +.It Va net.inet.ip.alias.sctp.initialising_chunk_proc_limit: No 2 +Defines the maximum number of chunks in an SCTP packet that will be parsed when +no existing association exists that matches that packet. Ideally this packet +will only be an INIT or ASCONF-AddIP packet. A higher value may become a DoS +risk as malformed packets can consume processing resources. +.It Va net.inet.ip.alias.sctp.param_proc_limit: No 25 +Defines the maximum number of parameters within a chunk that will be parsed in a +packet. As for other similar sysctl variables, larger values pose a DoS risk. +.It Va net.inet.ip.alias.sctp.log_level: No 0 +Level of detail in the system log messages (0 \- minimal, 1 \- event, +2 \- info, 3 \- detail, 4 \- debug, 5 \- max debug). May be a good +option in high loss environments. +.It Va net.inet.ip.alias.sctp.shutdown_time: No 15 +Timeout value while waiting for SHUTDOWN-COMPLETE. +This value cannot be 0. +.It Va net.inet.ip.alias.sctp.track_global_addresses: No 0 +Enables/disables global IP address tracking within the +.Nm nat +and places an +upper limit on the number of addresses tracked for each association: +.Bl -tag -width indent +.It Cm 0 +Global tracking is disabled +.It Cm >1 +Enables tracking, the maximum number of addresses tracked for each +association is limited to this value +.El +.Pp +This variable is fully dynamic, the new value will be adopted for all newly +arriving associations, existing association are treated as they were previously. +Global tracking will decrease the number of collisions within the +.Nm nat +at a cost +of increased processing load, memory usage, complexity, and possible +.Nm nat +state +problems in complex networks with multiple +.Nm nats . +We recommend not tracking +global IP addresses, this will still result in a fully functional +.Nm nat . +.It Va net.inet.ip.alias.sctp.up_timer: No 300 +Timeout value to keep an association up with no traffic. +This value cannot be 0. .It Va net.inet.ip.dummynet.expire : No 1 Lazily delete dynamic pipes/queue once they have no pending traffic. You can disable this by setting the variable to 0, in which case @@ -2718,6 +2874,15 @@ as part of a Summer of Code 2005 project Work on .Nm dummynet traffic shaper supported by Akamba Corp. +.Pp +Sctp +.Nm nat +support has been developed by +.An The Centre for Advanced Internet Architectures (CAIA) Aq http://www.caia.swin.edu.au . +The primary developers and maintainers are David Hayes and Jason But. +For further information visit: +.Aq http://www.caia.swin.edu.au/urp/SONATA +. .Sh BUGS The syntax has grown over the years and sometimes it might be confusing. Unfortunately, backward compatibility prevents cleaning up mistakes Modified: head/sbin/ipfw/nat.c ============================================================================== --- head/sbin/ipfw/nat.c Sat Feb 7 16:37:02 2009 (r188293) +++ head/sbin/ipfw/nat.c Sat Feb 7 18:49:42 2009 (r188294) @@ -257,7 +257,9 @@ StrToProto (const char* str) if (!strcmp (str, "udp")) return IPPROTO_UDP; - errx (EX_DATAERR, "unknown protocol %s. Expected tcp or udp", str); + if (!strcmp (str, "sctp")) + return IPPROTO_SCTP; + errx (EX_DATAERR, "unknown protocol %s. Expected sctp, tcp or udp", str); } static int @@ -433,13 +435,27 @@ setup_redir_port(char *spool_buf, int le strncpy(tmp_spool_buf, *av, strlen(*av)+1); lsnat = 1; } else { - if (StrToAddrAndPortRange (*av, &r->laddr, protoName, - &portRange) != 0) - errx(EX_DATAERR, "redirect_port:" - "invalid local port range"); + /* + * The sctp nat does not allow the port numbers to be mapped to + * new port numbers. Therefore, no ports are to be specified + * in the target port field. + */ + if (r->proto == IPPROTO_SCTP) { + if (strchr (*av, ':')) + errx(EX_DATAERR, "redirect_port:" + "port numbers do not change in sctp, so do not " + "specify them as part of the target"); + else + StrToAddr(*av, &r->laddr); + } else { + if (StrToAddrAndPortRange (*av, &r->laddr, protoName, + &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid local port range"); - r->lport = GETLOPORT(portRange); - numLocalPorts = GETNUMPORTS(portRange); + r->lport = GETLOPORT(portRange); + numLocalPorts = GETNUMPORTS(portRange); + } } INC_ARGCV(); @@ -463,6 +479,10 @@ setup_redir_port(char *spool_buf, int le } r->pport = GETLOPORT(portRange); + if (r->proto == IPPROTO_SCTP) { /* so the logic below still works */ + numLocalPorts = GETNUMPORTS(portRange); + r->lport = r->pport; + } r->pport_cnt = GETNUMPORTS(portRange); INC_ARGCV(); @@ -518,14 +538,31 @@ setup_redir_port(char *spool_buf, int le goto nospace; len -= SOF_SPOOL; space += SOF_SPOOL; - if (StrToAddrAndPortRange(sep, &tmp->addr, protoName, - &portRange) != 0) - errx(EX_DATAERR, "redirect_port:" - "invalid local port range"); - if (GETNUMPORTS(portRange) != 1) - errx(EX_DATAERR, "redirect_port: local port" - "must be single in this context"); - tmp->port = GETLOPORT(portRange); + /* + * The sctp nat does not allow the port numbers to be mapped to new port numbers + * Therefore, no ports are to be specified in the target port field + */ + if (r->proto == IPPROTO_SCTP) { + if (strchr (sep, ':')) { + errx(EX_DATAERR, "redirect_port:" + "port numbers do not change in " + "sctp, so do not specify them as " + "part of the target"); + } else { + StrToAddr(sep, &tmp->addr); + tmp->port = r->pport; + } + } else { + if (StrToAddrAndPortRange(sep, &tmp->addr, + protoName, &portRange) != 0) + errx(EX_DATAERR, "redirect_port:" + "invalid local port range"); + if (GETNUMPORTS(portRange) != 1) + errx(EX_DATAERR, "redirect_port: " + "local port must be single in " + "this context"); + tmp->port = GETLOPORT(portRange); + } r->spool_cnt++; /* Point to the next possible cfg_spool. */ spool_buf = &spool_buf[SOF_SPOOL]; Modified: head/sys/modules/libalias/libalias/Makefile ============================================================================== --- head/sys/modules/libalias/libalias/Makefile Sat Feb 7 16:37:02 2009 (r188293) +++ head/sys/modules/libalias/libalias/Makefile Sat Feb 7 18:49:42 2009 (r188294) @@ -3,6 +3,6 @@ .PATH: ${.CURDIR}/../../../netinet/libalias KMOD= libalias -SRCS= alias.c alias_db.c alias_proxy.c alias_util.c alias_mod.c +SRCS= alias.c alias_db.c alias_proxy.c alias_util.c alias_mod.c alias_sctp.c .include Modified: head/sys/netinet/ip_fw_nat.c ============================================================================== --- head/sys/netinet/ip_fw_nat.c Sat Feb 7 16:37:02 2009 (r188293) +++ head/sys/netinet/ip_fw_nat.c Sat Feb 7 18:49:42 2009 (r188294) @@ -326,6 +326,10 @@ ipfw_nat(struct ip_fw_args *args, struct else retval = LibAliasOut(t->lib, c, mcl->m_len + M_TRAILINGSPACE(mcl)); + if (retval == PKT_ALIAS_RESPOND) { + m->m_flags |= M_SKIP_FIREWALL; + retval = PKT_ALIAS_OK; + } if (retval != PKT_ALIAS_OK && retval != PKT_ALIAS_FOUND_HEADER_FRAGMENT) { /* XXX - should i add some logging? */ Modified: head/sys/netinet/libalias/alias.c ============================================================================== --- head/sys/netinet/libalias/alias.c Sat Feb 7 16:37:02 2009 (r188293) +++ head/sys/netinet/libalias/alias.c Sat Feb 7 18:49:42 2009 (r188294) @@ -115,6 +115,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #else #include #include @@ -143,6 +144,17 @@ __FBSDID("$FreeBSD$"); #include "alias_mod.h" #endif +/* + * Define libalias SYSCTL Node + */ +#ifdef SYSCTL_NODE + +SYSCTL_DECL(_net_inet); +SYSCTL_DECL(_net_inet_ip); +SYSCTL_NODE(_net_inet_ip, OID_AUTO, alias, CTLFLAG_RW, NULL, "Libalias sysctl API"); + +#endif + static __inline int twowords(void *p) { @@ -1335,6 +1347,11 @@ LibAliasInLocked(struct libalias *la, ch case IPPROTO_TCP: iresult = TcpAliasIn(la, pip); break; +#ifdef _KERNEL + case IPPROTO_SCTP: + iresult = SctpAlias(la, pip, SN_TO_LOCAL); + break; +#endif case IPPROTO_GRE: { int error; struct alias_data ad = { @@ -1477,10 +1494,15 @@ LibAliasOutLocked(struct libalias *la, c case IPPROTO_UDP: iresult = UdpAliasOut(la, pip, maxpacketsize, create); break; - case IPPROTO_TCP: + case IPPROTO_TCP: iresult = TcpAliasOut(la, pip, maxpacketsize, create); break; - case IPPROTO_GRE: { +#ifdef _KERNEL + case IPPROTO_SCTP: + iresult = SctpAlias(la, pip, SN_TO_GLOBAL); + break; +#endif + case IPPROTO_GRE: { int error; struct alias_data ad = { .lnk = NULL, Modified: head/sys/netinet/libalias/alias_db.c ============================================================================== --- head/sys/netinet/libalias/alias_db.c Sat Feb 7 16:37:02 2009 (r188293) +++ head/sys/netinet/libalias/alias_db.c Sat Feb 7 18:49:42 2009 (r188294) @@ -411,6 +411,8 @@ static void ShowAliasStats(struct libali static int InitPacketAliasLog(struct libalias *); static void UninitPacketAliasLog(struct libalias *); +void SctpShowAliasStats(struct libalias *la); + static u_int StartPointIn(struct in_addr alias_addr, u_short alias_port, @@ -489,15 +491,17 @@ ShowAliasStats(struct libalias *la) /* Used for debugging */ if (la->logDesc) { int tot = la->icmpLinkCount + la->udpLinkCount + + (la->sctpLinkCount>>1) + /* sctp counts half associations */ la->tcpLinkCount + la->pptpLinkCount + la->protoLinkCount + la->fragmentIdLinkCount + la->fragmentPtrLinkCount; AliasLog(la->logDesc, - "icmp=%u, udp=%u, tcp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", + "icmp=%u, udp=%u, tcp=%u, sctp=%u, pptp=%u, proto=%u, frag_id=%u frag_ptr=%u / tot=%u", la->icmpLinkCount, la->udpLinkCount, la->tcpLinkCount, + la->sctpLinkCount>>1, /* sctp counts half associations */ la->pptpLinkCount, la->protoLinkCount, la->fragmentIdLinkCount, @@ -508,6 +512,13 @@ ShowAliasStats(struct libalias *la) } } +void SctpShowAliasStats(struct libalias *la) +{ + + ShowAliasStats(la); +} + + /* Internal routines for finding, deleting and adding links Port Allocation: @@ -1278,6 +1289,11 @@ _FindLinkIn(struct libalias *la, struct src_port = lnk->src_port; } + if (link_type == LINK_SCTP) { + lnk->src_addr = src_addr; + lnk->src_port = src_port; + return(lnk); + } lnk = ReLink(lnk, src_addr, dst_addr, alias_addr, src_port, dst_port, alias_port, @@ -2277,10 +2293,13 @@ LibAliasRedirectPort(struct libalias *la case IPPROTO_TCP: link_type = LINK_TCP; break; + case IPPROTO_SCTP: + link_type = LINK_SCTP; + break; default: #ifdef LIBALIAS_DEBUG fprintf(stderr, "PacketAliasRedirectPort(): "); - fprintf(stderr, "only TCP and UDP protocols allowed\n"); + fprintf(stderr, "only SCTP, TCP and UDP protocols allowed\n"); #endif lnk = NULL; goto getout; @@ -2496,6 +2515,9 @@ LibAliasInit(struct libalias *la) LIST_INIT(&la->linkTableOut[i]); for (i = 0; i < LINK_TABLE_IN_SIZE; i++) LIST_INIT(&la->linkTableIn[i]); +#ifdef _KERNEL + AliasSctpInit(la); +#endif LIBALIAS_LOCK_INIT(la); LIBALIAS_LOCK(la); } else { @@ -2503,6 +2525,10 @@ LibAliasInit(struct libalias *la) la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; +#ifdef _KERNEL + AliasSctpTerm(la); + AliasSctpInit(la); +#endif } la->aliasAddress.s_addr = INADDR_ANY; @@ -2511,6 +2537,7 @@ LibAliasInit(struct libalias *la) la->icmpLinkCount = 0; la->udpLinkCount = 0; la->tcpLinkCount = 0; + la->sctpLinkCount = 0; la->pptpLinkCount = 0; la->protoLinkCount = 0; la->fragmentIdLinkCount = 0; @@ -2539,6 +2566,9 @@ LibAliasUninit(struct libalias *la) { LIBALIAS_LOCK(la); +#ifdef _KERNEL + AliasSctpTerm(la); +#endif la->deleteAllLinks = 1; CleanupAliasData(la); la->deleteAllLinks = 0; @@ -2879,3 +2909,30 @@ LibAliasSetSkinnyPort(struct libalias *l la->skinnyPort = port; LIBALIAS_UNLOCK(la); } + +/* + * Find the address to redirect incoming packets + */ +struct in_addr +FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm) +{ + struct alias_link *lnk; + struct in_addr redir; + + LIBALIAS_LOCK_ASSERT(la); + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + sm->sctp_hdr->dest_port,sm->sctp_hdr->dest_port, LINK_SCTP, 1); + if (lnk != NULL) { + return(lnk->src_addr); /* port redirect */ + } else { + redir = FindOriginalAddress(la,sm->ip_hdr->ip_dst); + if (redir.s_addr == la->aliasAddress.s_addr || + redir.s_addr == la->targetAddress.s_addr) { /* No address found */ + lnk = FindLinkIn(la, sm->ip_hdr->ip_src, sm->ip_hdr->ip_dst, + NO_DEST_PORT, 0, LINK_SCTP, 1); + if (lnk != NULL) + return(lnk->src_addr); /* redirect proto */ + } + return(redir); /* address redirect */ + } +} Modified: head/sys/netinet/libalias/alias_local.h ============================================================================== --- head/sys/netinet/libalias/alias_local.h Sat Feb 7 16:37:02 2009 (r188293) +++ head/sys/netinet/libalias/alias_local.h Sat Feb 7 18:49:42 2009 (r188294) @@ -57,6 +57,10 @@ /* XXX: LibAliasSetTarget() uses this constant. */ #define INADDR_NONE 0xffffffff + +#include +#else +#include "alias_sctp.h" #endif /* Sizes of input and output link tables */ @@ -147,7 +151,29 @@ struct libalias { struct in_addr true_addr; /* in network byte order. */ u_short true_port; /* in host byte order. */ + + /* + * sctp code support + */ + + /* counts associations that have progressed to UP and not yet removed */ + int sctpLinkCount; #ifdef _KERNEL + /* timing queue for keeping track of association timeouts */ + struct sctp_nat_timer sctpNatTimer; + + /* size of hash table used in this instance */ + u_int sctpNatTableSize; + +/* + * local look up table sorted by l_vtag/l_port + */ + LIST_HEAD(sctpNatTableL, sctp_nat_assoc) *sctpTableLocal; +/* + * global look up table sorted by g_vtag/g_port + */ + LIST_HEAD(sctpNatTableG, sctp_nat_assoc) *sctpTableGlobal; + /* * avoid races in libalias: every public function has to use it. */ @@ -199,6 +225,14 @@ struct libalias { /* Prototypes */ /* + * SctpFunction prototypes + * + */ +void AliasSctpInit(struct libalias *la); +void AliasSctpTerm(struct libalias *la); +int SctpAlias(struct libalias *la, struct ip *ip, int direction); + +/* * We do not calculate TCP checksums when libalias is a kernel * module, since it has no idea about checksum offloading. * If TCP data has changed, then we just set checksum to zero, @@ -264,6 +298,8 @@ struct in_addr FindOriginalAddress(struct libalias *la, struct in_addr _alias_addr); struct in_addr FindAliasAddress(struct libalias *la, struct in_addr _original_addr); +struct in_addr +FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); /* External data access/modification */ int Copied and modified: head/sys/netinet/libalias/alias_sctp.c (from r186543, user/piso/sys/netinet/libalias/alias_sctp.c) ============================================================================== --- user/piso/sys/netinet/libalias/alias_sctp.c Sun Dec 28 17:16:32 2008 (r186543, copy source) +++ head/sys/netinet/libalias/alias_sctp.c Sat Feb 7 18:49:42 2009 (r188294) @@ -1,34 +1,9 @@ -//* $Id$ */ -//#ifndef lint -//static char vcid[] = "$Id$"; -//#endif /* lint */ /** * @file alias_sctp.c * Copyright (c) 2008, Centre for Advanced Internet Architectures * Swinburne University of Technology, Melbourne, Australia * (CRICOS number 00111D). * - * Alias_sctp forms part of the libalias kernel module to handle - * Network Address Translation (NAT) for the SCTP protocol. - * - * This software was developed by David A. Hayes and Jason But - * - * The design is outlined in CAIA technical report number 080618A - * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") - * - * Development is part of the CAIA SONATA project, - * proposed by Jason But and Grenville Armitage: - * http://caia.swin.edu.au/urp/sonata/ - * - * - * This project has been made possible in part by a grant from - * the Cisco University Research Program Fund at Community - * Foundation Silicon Valley. - * - * - * - * All rights reserved. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -54,6 +29,23 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * Alias_sctp forms part of the libalias kernel module to handle + * Network Address Translation (NAT) for the SCTP protocol. + * + * This software was developed by David A. Hayes and Jason But + * + * The design is outlined in CAIA technical report number 080618A + * (D. Hayes and J. But, "Alias_sctp Version 0.1: SCTP NAT implementation in IPFW") + * + * Development is part of the CAIA SONATA project, + * proposed by Jason But and Grenville Armitage: + * http://caia.swin.edu.au/urp/sonata/ + * + * + * This project has been made possible in part by a grant from + * the Cisco University Research Program Fund at Community + * Foundation Silicon Valley. + * */ /** @mainpage * Alias_sctp is part of the SONATA (http://caia.swin.edu.au/urp/sonata) project @@ -80,6 +72,8 @@ * - Dynamic control of hash-table size */ +/* $FreeBSD$ */ + #ifdef _KERNEL #include #include @@ -107,9 +101,9 @@ */ /* Packet Parsing Functions */ static int sctp_PktParser(struct libalias *la, int direction, struct ip *pip, - struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); + struct sctp_nat_msg *sm, struct sctp_nat_assoc **passoc); static int GetAsconfVtags(struct libalias *la, struct sctp_nat_msg *sm, - uint32_t *l_vtag, uint32_t *g_vtag, int direction); + uint32_t *l_vtag, uint32_t *g_vtag, int direction); static int IsASCONFack(struct libalias *la, struct sctp_nat_msg *sm, int direction); static void AddGlobalIPAddresses(struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc, int direction); @@ -119,20 +113,20 @@ static int IsADDorDEL(struct libalias *l /* State Machine Functions */ static int ProcessSctpMsg(struct libalias *la, int direction, \ - struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc); + struct sctp_nat_msg *sm, struct sctp_nat_assoc *assoc); static int ID_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int INi_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int INa_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int UP_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static int CL_process(struct libalias *la, int direction,\ - struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); + struct sctp_nat_assoc *assoc, struct sctp_nat_msg *sm); static void TxAbortErrorM(struct libalias *la, struct sctp_nat_msg *sm,\ - struct sctp_nat_assoc *assoc, int sndrply, int direction); + struct sctp_nat_assoc *assoc, int sndrply, int direction); /* Hash Table Functions */ static struct sctp_nat_assoc* @@ -189,22 +183,6 @@ static void SctpAliasLog(const char *for */ void SctpShowAliasStats(struct libalias *la); -/** @ingroup external - * @brief Find the address to redirect incoming packets - * - * This function is defined in alias_db.c, since it calls static functions in - * this file - * - * Given a destination port for incoming packets to the NAT, discover what - * (if any) internal IP address this packet should be re-directed to - * - * @param la Pointer to the libalias instance - * @param sm Pointer to the incoming message - * - * @return Address to redirect an incoming INIT to - */ -struct in_addr FindSctpRedirectAddress(struct libalias *la, struct sctp_nat_msg *sm); - #ifdef _KERNEL MALLOC_DEFINE(M_SCTPNAT, "sctpnat", "sctp nat dbs"); @@ -364,9 +342,9 @@ static u_int sysctl_holddown_timer = 0; static u_int sysctl_hashtable_size = SN_DEFAULT_HASH_SIZE; /**< Sets the hash table size for any NEW NAT instances (existing instances retain their existing Hash Table */ /** @brief net.inet.ip.alias.sctp.error_on_ootb */ static u_int sysctl_error_on_ootb = 1; /**< NAT response to receipt of OOTB packet - (0 - No response, 1 - NAT will send ErrorM only to local side, - 2 - NAT will send local ErrorM and global ErrorM if there was a partial association match - 3 - NAT will send ErrorM to both local and global) */ + (0 - No response, 1 - NAT will send ErrorM only to local side, + 2 - NAT will send local ErrorM and global ErrorM if there was a partial association match + 3 - NAT will send ErrorM to both local and global) */ /** @brief net.inet.ip.alias.sctp.accept_global_ootb_addip */ static u_int sysctl_accept_global_ootb_addip = 0; /** 0 - enables tracking but limits the number of global IP addresses to this value) - If set to >=1 the NAT will track that many global IP addresses. This may reduce look up table conflicts, but increases processing */ + If set to >=1 the NAT will track that many global IP addresses. This may reduce look up table conflicts, but increases processing */ #define SN_NO_ERROR_ON_OOTB 0 /**< Send no errorM on out of the blue packets */ #define SN_LOCAL_ERROR_ON_OOTB 1 /**< Send only local errorM on out of the blue packets */ @@ -393,41 +371,41 @@ SYSCTL_DECL(_net_inet_ip_alias); SYSCTL_NODE(_net_inet_ip_alias, OID_AUTO, sctp, CTLFLAG_RW, NULL, "SCTP NAT"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, log_level, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_log_level, 0, sysctl_chg_loglevel, "IU", - "Level of detail (0 - default, 1 - event, 2 - info, 3 - detail, 4 - debug, 5 - max debug)"); + &sysctl_log_level, 0, sysctl_chg_loglevel, "IU", + "Level of detail (0 - default, 1 - event, 2 - info, 3 - detail, 4 - debug, 5 - max debug)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, init_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_init_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) while waiting for (INIT-ACK|AddIP-ACK)"); + &sysctl_init_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) while waiting for (INIT-ACK|AddIP-ACK)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, up_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_up_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) to keep an association up with no traffic"); + &sysctl_up_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) to keep an association up with no traffic"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, shutdown_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_shutdown_timer, 0, sysctl_chg_timer, "IU", - "Timeout value (s) while waiting for SHUTDOWN-COMPLETE"); + &sysctl_shutdown_timer, 0, sysctl_chg_timer, "IU", + "Timeout value (s) while waiting for SHUTDOWN-COMPLETE"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, holddown_timer, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_holddown_timer, 0, sysctl_chg_timer, "IU", - "Hold association in table for this many seconds after receiving a SHUTDOWN-COMPLETE"); + &sysctl_holddown_timer, 0, sysctl_chg_timer, "IU", + "Hold association in table for this many seconds after receiving a SHUTDOWN-COMPLETE"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, hashtable_size, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_hashtable_size, 0, sysctl_chg_hashtable_size, "IU", - "Size of hash tables used for NAT lookups (100 < prime_number > 1000001)"); + &sysctl_hashtable_size, 0, sysctl_chg_hashtable_size, "IU", + "Size of hash tables used for NAT lookups (100 < prime_number > 1000001)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, error_on_ootb, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_error_on_ootb, 0, sysctl_chg_error_on_ootb, "IU", - "ErrorM sent on receipt of ootb packet:\n\t0 - none,\n\t1 - to local only,\n\t2 - to local and global if a partial association match,\n\t3 - to local and global (DoS risk)"); + &sysctl_error_on_ootb, 0, sysctl_chg_error_on_ootb, "IU", + "ErrorM sent on receipt of ootb packet:\n\t0 - none,\n\t1 - to local only,\n\t2 - to local and global if a partial association match,\n\t3 - to local and global (DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, accept_global_ootb_addip, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_accept_global_ootb_addip, 0, sysctl_chg_accept_global_ootb_addip, "IU", - "NAT response to receipt of global OOTB AddIP:\n\t0 - No response,\n\t1 - NAT will accept OOTB global AddIP messages for processing (Security risk)"); + &sysctl_accept_global_ootb_addip, 0, sysctl_chg_accept_global_ootb_addip, "IU", + "NAT response to receipt of global OOTB AddIP:\n\t0 - No response,\n\t1 - NAT will accept OOTB global AddIP messages for processing (Security risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, initialising_chunk_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_initialising_chunk_proc_limit, 0, sysctl_chg_initialising_chunk_proc_limit, "IU", - "Number of chunks that should be processed if there is no current association found:\n\t > 0 (A high value is a DoS risk)"); + &sysctl_initialising_chunk_proc_limit, 0, sysctl_chg_initialising_chunk_proc_limit, "IU", + "Number of chunks that should be processed if there is no current association found:\n\t > 0 (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, chunk_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_chunk_proc_limit, 0, sysctl_chg_chunk_proc_limit, "IU", - "Number of chunks that should be processed to find key chunk:\n\t>= initialising_chunk_proc_limit (A high value is a DoS risk)"); + &sysctl_chunk_proc_limit, 0, sysctl_chg_chunk_proc_limit, "IU", + "Number of chunks that should be processed to find key chunk:\n\t>= initialising_chunk_proc_limit (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, param_proc_limit, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_param_proc_limit, 0, sysctl_chg_param_proc_limit, "IU", - "Number of parameters (in a chunk) that should be processed to find key parameters:\n\t> 1 (A high value is a DoS risk)"); + &sysctl_param_proc_limit, 0, sysctl_chg_param_proc_limit, "IU", + "Number of parameters (in a chunk) that should be processed to find key parameters:\n\t> 1 (A high value is a DoS risk)"); SYSCTL_PROC(_net_inet_ip_alias_sctp, OID_AUTO, track_global_addresses, CTLTYPE_UINT | CTLFLAG_RW, - &sysctl_track_global_addresses, 0, sysctl_chg_track_global_addresses, "IU", - "Configures the global address tracking option within the NAT:\n\t0 - Global tracking is disabled,\n\t> 0 - enables tracking but limits the number of global IP addresses to this value"); + &sysctl_track_global_addresses, 0, sysctl_chg_track_global_addresses, "IU", + "Configures the global address tracking option within the NAT:\n\t0 - Global tracking is disabled,\n\t> 0 - enables tracking but limits the number of global IP addresses to this value"); #endif /* SYSCTL_NODE */ @@ -440,16 +418,16 @@ SYSCTL_PROC(_net_inet_ip_alias_sctp, OID */ int sysctl_chg_loglevel(SYSCTL_HANDLER_ARGS) { - u_int level = *(u_int *)arg1; - int error; + u_int level = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &level, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &level, 0, req); + if (error) return (error); - sysctl_log_level = (level > SN_LOG_DEBUG_MAX)?(SN_LOG_DEBUG_MAX):(level); - sysctl_log_level = (level < SN_LOG_LOW)?(SN_LOG_LOW):(level); + sysctl_log_level = (level > SN_LOG_DEBUG_MAX)?(SN_LOG_DEBUG_MAX):(level); + sysctl_log_level = (level < SN_LOG_LOW)?(SN_LOG_LOW):(level); - return (0); + return (0); } /** @ingroup sysctl @@ -461,22 +439,22 @@ int sysctl_chg_loglevel(SYSCTL_HANDLER_A */ int sysctl_chg_timer(SYSCTL_HANDLER_ARGS) { - u_int timer = *(u_int *)arg1; - int error; + u_int timer = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &timer, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &timer, 0, req); + if (error) return (error); - timer = (timer > SN_MAX_TIMER)?(SN_MAX_TIMER):(timer); + timer = (timer > SN_MAX_TIMER)?(SN_MAX_TIMER):(timer); - if (((u_int *)arg1) != &sysctl_holddown_timer) - { - timer = (timer < SN_MIN_TIMER)?(SN_MIN_TIMER):(timer); - } + if (((u_int *)arg1) != &sysctl_holddown_timer) + { + timer = (timer < SN_MIN_TIMER)?(SN_MIN_TIMER):(timer); + } - *(u_int *)arg1 = timer; + *(u_int *)arg1 = timer; - return (0); + return (0); } /** @ingroup sysctl @@ -490,20 +468,20 @@ int sysctl_chg_timer(SYSCTL_HANDLER_ARGS */ int sysctl_chg_hashtable_size(SYSCTL_HANDLER_ARGS) { - u_int size = *(u_int *)arg1; - int error; + u_int size = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &size, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &size, 0, req); + if (error) return (error); - size = (size < SN_MIN_HASH_SIZE)?(SN_MIN_HASH_SIZE):((size > SN_MAX_HASH_SIZE)?(SN_MAX_HASH_SIZE):(size)); + size = (size < SN_MIN_HASH_SIZE)?(SN_MIN_HASH_SIZE):((size > SN_MAX_HASH_SIZE)?(SN_MAX_HASH_SIZE):(size)); - size |= 0x00000001; /* make odd */ + size |= 0x00000001; /* make odd */ - for(;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2); - sysctl_hashtable_size = size; + for(;(((size % 3) == 0) || ((size % 5) == 0) || ((size % 7) == 0) || ((size % 11) == 0)); size+=2); + sysctl_hashtable_size = size; - return (0); + return (0); } /** @ingroup sysctl @@ -518,15 +496,15 @@ int sysctl_chg_hashtable_size(SYSCTL_HAN */ int sysctl_chg_error_on_ootb(SYSCTL_HANDLER_ARGS) { - u_int flag = *(u_int *)arg1; - int error; + u_int flag = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &flag, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &flag, 0, req); + if (error) return (error); - sysctl_error_on_ootb = (flag > SN_ERROR_ON_OOTB) ? SN_ERROR_ON_OOTB: flag; + sysctl_error_on_ootb = (flag > SN_ERROR_ON_OOTB) ? SN_ERROR_ON_OOTB: flag; - return (0); + return (0); } /** @ingroup sysctl @@ -537,15 +515,15 @@ int sysctl_chg_error_on_ootb(SYSCTL_HAND */ int sysctl_chg_accept_global_ootb_addip(SYSCTL_HANDLER_ARGS) { - u_int flag = *(u_int *)arg1; - int error; + u_int flag = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &flag, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &flag, 0, req); + if (error) return (error); - sysctl_accept_global_ootb_addip = (flag == 1) ? 1: 0; + sysctl_accept_global_ootb_addip = (flag == 1) ? 1: 0; - return (0); + return (0); } /** @ingroup sysctl @@ -557,17 +535,17 @@ int sysctl_chg_accept_global_ootb_addip( */ int sysctl_chg_initialising_chunk_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_initialising_chunk_proc_limit = (proclimit < 1) ? 1: proclimit; - sysctl_chunk_proc_limit = - (sysctl_chunk_proc_limit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : sysctl_chunk_proc_limit; + sysctl_initialising_chunk_proc_limit = (proclimit < 1) ? 1: proclimit; + sysctl_chunk_proc_limit = + (sysctl_chunk_proc_limit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : sysctl_chunk_proc_limit; - return (0); + return (0); } /** @ingroup sysctl @@ -579,16 +557,16 @@ int sysctl_chg_initialising_chunk_proc_l */ int sysctl_chg_chunk_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_chunk_proc_limit = - (proclimit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : proclimit; + sysctl_chunk_proc_limit = + (proclimit < sysctl_initialising_chunk_proc_limit) ? sysctl_initialising_chunk_proc_limit : proclimit; - return (0); + return (0); } @@ -601,16 +579,16 @@ int sysctl_chg_chunk_proc_limit(SYSCTL_H */ int sysctl_chg_param_proc_limit(SYSCTL_HANDLER_ARGS) { - u_int proclimit = *(u_int *)arg1; - int error; + u_int proclimit = *(u_int *)arg1; + int error; - error = sysctl_handle_int(oidp, &proclimit, 0, req); - if (error) return (error); + error = sysctl_handle_int(oidp, &proclimit, 0, req); + if (error) return (error); - sysctl_param_proc_limit = - (proclimit < 2) ? 2 : proclimit; + sysctl_param_proc_limit = *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From ache at nagual.pp.ru Sat Feb 7 11:17:11 2009 From: ache at nagual.pp.ru (Andrey Chernov) Date: Sat Feb 7 11:17:18 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <200902032025.n13KPaCV041012@svn.freebsd.org> References: <200902032025.n13KPaCV041012@svn.freebsd.org> Message-ID: <20090207190418.GA336@nagual.pp.ru> On Tue, Feb 03, 2009 at 08:25:36PM +0000, Warner Losh wrote: > ============================================================================== > --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) > +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) > @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); > #include > > void * > -memchr(const void *s, unsigned char c, size_t n) > +memchr(const void *s, int c, size_t n) > { > if (n != 0) { > const unsigned char *p = s; You just broke comparison with negative chars, as memchr(3) says: "The memchr() function locates the first occurrence of c (converted to an unsigned char)" Please change if (*p++ == c) to if (*p++ == (unsigned char)c) (as in memrchr.c) -- http://ache.pp.ru/ From imp at bsdimp.com Sat Feb 7 11:33:14 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Sat Feb 7 11:33:25 2009 Subject: svn commit: r188098 - head/lib/libc/string In-Reply-To: <20090207190418.GA336@nagual.pp.ru> References: <200902032025.n13KPaCV041012@svn.freebsd.org> <20090207190418.GA336@nagual.pp.ru> Message-ID: <20090207.123253.-1775864766.imp@bsdimp.com> In message: <20090207190418.GA336@nagual.pp.ru> Andrey Chernov writes: : On Tue, Feb 03, 2009 at 08:25:36PM +0000, Warner Losh wrote: : > ============================================================================== : > --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) : > +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) : > @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); : > #include : > : > void * : > -memchr(const void *s, unsigned char c, size_t n) : > +memchr(const void *s, int c, size_t n) : > { : > if (n != 0) { : > const unsigned char *p = s; : : You just broke comparison with negative chars, as memchr(3) says: : "The memchr() function locates the first occurrence of c (converted to an : unsigned char)" : : Please change : if (*p++ == c) : to : if (*p++ == (unsigned char)c) : (as in memrchr.c) Yes. Thanks. Warner From imp at FreeBSD.org Sat Feb 7 11:34:45 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Feb 7 11:34:56 2009 Subject: svn commit: r188295 - head/lib/libc/string Message-ID: <200902071934.n17JYiji001769@svn.freebsd.org> Author: imp Date: Sat Feb 7 19:34:44 2009 New Revision: 188295 URL: http://svn.freebsd.org/changeset/base/188295 Log: Make sure the comparison is done with an unsigned char. Modified: head/lib/libc/string/memchr.c Modified: head/lib/libc/string/memchr.c ============================================================================== --- head/lib/libc/string/memchr.c Sat Feb 7 18:49:42 2009 (r188294) +++ head/lib/libc/string/memchr.c Sat Feb 7 19:34:44 2009 (r188295) @@ -45,7 +45,7 @@ memchr(const void *s, int c, size_t n) const unsigned char *p = s; do { - if (*p++ == c) + if (*p++ == (unsigned char)c) return ((void *)(p - 1)); } while (--n != 0); } From christoph.mallon at gmx.de Sat Feb 7 13:23:04 2009 From: christoph.mallon at gmx.de (Christoph Mallon) Date: Sat Feb 7 13:23:16 2009 Subject: svn commit: r188251 - head/sys/fs/udf In-Reply-To: <200902062224.n16MO3gm072994@svn.freebsd.org> References: <200902062224.n16MO3gm072994@svn.freebsd.org> Message-ID: <498DFBB5.9080309@gmx.de> John Baldwin schrieb: > Modified: head/sys/fs/udf/ecma167-udf.h > ============================================================================== > --- head/sys/fs/udf/ecma167-udf.h Fri Feb 6 22:22:08 2009 (r188250) > +++ head/sys/fs/udf/ecma167-udf.h Fri Feb 6 22:24:03 2009 (r188251) > @@ -354,6 +354,18 @@ struct file_entry { > #define UDF_FENTRY_PERM_GRP_MASK 0xE0 > #define UDF_FENTRY_PERM_OWNER_MASK 0x1C00 > > +/* Path Component [4/14.16.1] */ > +struct path_component { > + uint8_t type; > + uint8_t length; > + uint16_t version; > + uint8_t identifier[0]; > +} __packed; [0] is a GCCism. The standard way to declare a flexible array member is [] (cf. ISO/IEC 9899:1999 (E) ?6.7.2.1:16). From wkoszek at FreeBSD.org Sat Feb 7 16:16:27 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sat Feb 7 16:16:38 2009 Subject: svn commit: r188297 - head/sys/conf Message-ID: <200902080016.n180GOP7006827@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 00:16:24 2009 New Revision: 188297 URL: http://svn.freebsd.org/changeset/base/188297 Log: Resort NOTES a bit to easily distinguish, which comments are actual and refer to used options, and which comments are obseleted. Reviewed by: imp Modified: head/sys/conf/NOTES Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Sat Feb 7 21:07:58 2009 (r188296) +++ head/sys/conf/NOTES Sun Feb 8 00:16:24 2009 (r188297) @@ -714,40 +714,81 @@ device mn # Munich32x/Falc54 Nx64kbit/s # # Network interfaces: # The `loop' device is MANDATORY when networking is enabled. +device loop + # The `ether' device provides generic code to handle # Ethernets; it is MANDATORY when an Ethernet device driver is # configured or token-ring is enabled. +device ether + # The `vlan' device implements the VLAN tagging of Ethernet frames # according to IEEE 802.1Q. It requires `device miibus'. +device vlan + # The `wlan' device provides generic code to support 802.11 # drivers, including host AP mode; it is MANDATORY for the wi, # and ath drivers and will eventually be required by all 802.11 drivers. +device wlan +options IEEE80211_DEBUG #enable debugging msgs +options IEEE80211_AMPDU_AGE #age frames in AMPDU reorder q's + # The `wlan_wep', `wlan_tkip', and `wlan_ccmp' devices provide # support for WEP, TKIP, and AES-CCMP crypto protocols optionally # used with 802.11 devices that depend on the `wlan' module. +device wlan_wep +device wlan_ccmp +device wlan_tkip + # The `wlan_xauth' device provides support for external (i.e. user-mode) # authenticators for use with 802.11 drivers that use the `wlan' # module and support 802.1x and/or WPA security protocols. +device wlan_xauth + # The `wlan_acl' device provides a MAC-based access control mechanism # for use with 802.11 drivers operating in ap mode and using the # `wlan' module. +# The 'wlan_amrr' device provides AMRR transmit rate control algorithm +device wlan_acl +device wlan_amrr + +# Generic TokenRing +device token + # The `fddi' device provides generic code to support FDDI. +device fddi + # The `arcnet' device provides generic code to support Arcnet. +device arcnet + # The `sppp' device serves a similar role for certain types # of synchronous PPP links (like `cx', `ar'). +device sppp + # The `sl' device implements the Serial Line IP (SLIP) service. # The `ppp' device implements the Point-to-Point Protocol. + + # The `bpf' device enables the Berkeley Packet Filter. Be # aware of the legal and administrative consequences of enabling this # option. The number of devices determines the maximum number of # simultaneous BPF clients programs runnable. DHCP requires bpf. +device bpf + # The `disc' device implements a minimal network interface, # which throws away all packets sent and never receives any. It is # included for testing and benchmarking purposes. +device disc + # The `edsc' device implements a minimal Ethernet interface, # which discards all packets sent and receives none. +device edsc + # The `tap' device is a pty-like virtual Ethernet interface -# The `tun' device implements (user-)ppp and nos-tun +device tap + +# The `tun' device implements (user-)ppp and nos-tun(8) +device tun + # The `gif' device implements IPv6 over IP4 tunneling, # IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling and # IPv6 over IPv6 tunneling. @@ -755,17 +796,45 @@ device mn # Munich32x/Falc54 Nx64kbit/s # GRE and MOBILE, as specified in the RFC1701 and RFC2004. # The XBONEHACK option allows the same pair of addresses to be configured on # multiple gif interfaces. +device gif +device gre +options XBONEHACK + # The `faith' device captures packets sent to it and diverts them # to the IPv4/IPv6 translation daemon. # The `stf' device implements 6to4 encapsulation. +device faith +device stf + # The `ef' device provides support for multiple ethernet frame types # specified via ETHER_* options. See ef(4) for details. -# +device ef +options ETHER_II # enable Ethernet_II frame +options ETHER_8023 # enable Ethernet_802.3 (Novell) frame +options ETHER_8022 # enable Ethernet_802.2 frame +options ETHER_SNAP # enable Ethernet_802.2/SNAP frame + # The pf packet filter consists of three devices: # The `pf' device provides /dev/pf and the firewall code itself. # The `pflog' device provides the pflog0 interface which logs packets. # The `pfsync' device provides the pfsync0 interface used for # synchronization of firewall state tables (over the net). +device pf +device pflog +device pfsync + +# Bridge interface. +device if_bridge + +# Common Address Redundancy Protocol. See carp(4) for more details. +device carp + +# IPsec interface. +device enc + +# Link aggregation interface. +device lagg + # # The PPP_BSDCOMP option enables support for compress(1) style entire # packet compression, the PPP_DEFLATE is for zlib/gzip style compression. @@ -773,47 +842,7 @@ device mn # Munich32x/Falc54 Nx64kbit/s # events for resetting the demand dial activity timer - requires bpf. # See pppd(8) for more details. # -device ether #Generic Ethernet -device vlan #VLAN support (needs miibus) -device wlan #802.11 support -options IEEE80211_DEBUG #enable debugging msgs -options IEEE80211_AMPDU_AGE #age frames in AMPDU reorder q's -device wlan_wep #802.11 WEP support -device wlan_ccmp #802.11 CCMP support -device wlan_tkip #802.11 TKIP support -device wlan_xauth #802.11 external authenticator support -device wlan_acl #802.11 MAC ACL support -device wlan_amrr #AMRR transmit rate control algorithm -device token #Generic TokenRing -device fddi #Generic FDDI -device arcnet #Generic Arcnet -device sppp #Generic Synchronous PPP -device loop #Network loopback device -device bpf #Berkeley packet filter -device disc #Discard device based on loopback -device edsc #Ethernet discard device -device tap #Virtual Ethernet driver -device tun #Tunnel driver (ppp(8), nos-tun(8)) -device gre #IP over IP tunneling -device if_bridge #Bridge interface -device pf #PF OpenBSD packet-filter firewall -device pflog #logging support interface for PF -device pfsync #synchronization interface for PF -device carp #Common Address Redundancy Protocol -device enc #IPsec interface -device lagg #Link aggregation interface - -device ef # Multiple ethernet frames support -options ETHER_II # enable Ethernet_II frame -options ETHER_8023 # enable Ethernet_802.3 (Novell) frame -options ETHER_8022 # enable Ethernet_802.2 frame -options ETHER_SNAP # enable Ethernet_802.2/SNAP frame -# for IPv6 -device gif #IPv6 and IPv4 tunneling -options XBONEHACK -device faith #for IPv6 and IPv4 translation -device stf #6to4 IPv6 over IPv4 encapsulation # # Internet family options: From piso at FreeBSD.org Sat Feb 7 19:02:06 2009 From: piso at FreeBSD.org (Paolo Pisati) Date: Sat Feb 7 19:02:17 2009 Subject: svn commit: r188298 - head/sys/conf Message-ID: <200902080302.n18326KV009975@svn.freebsd.org> Author: piso Date: Sun Feb 8 03:02:06 2009 New Revision: 188298 URL: http://svn.freebsd.org/changeset/base/188298 Log: Fix LIBALIAS option for a static kernel. Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Feb 8 00:16:24 2009 (r188297) +++ head/sys/conf/files Sun Feb 8 03:02:06 2009 (r188298) @@ -2387,6 +2387,7 @@ netinet/libalias/alias_db.c optional lib netinet/libalias/alias_mod.c optional libalias | netgraph_nat netinet/libalias/alias_proxy.c optional libalias | netgraph_nat netinet/libalias/alias_util.c optional libalias | netgraph_nat +netinet/libalias/alias_sctp.c optional libalias | netgraph_nat netinet6/dest6.c optional inet6 netinet6/frag6.c optional inet6 netinet6/icmp6.c optional inet6 From piso at FreeBSD.org Sat Feb 7 19:03:55 2009 From: piso at FreeBSD.org (Paolo Pisati) Date: Sat Feb 7 19:04:07 2009 Subject: svn commit: r188299 - head/sys/netinet Message-ID: <200902080303.n1833trt010041@svn.freebsd.org> Author: piso Date: Sun Feb 8 03:03:55 2009 New Revision: 188299 URL: http://svn.freebsd.org/changeset/base/188299 Log: Silent LINT: add 2 stubs (update_crc32 and sctp_finalize_crc32) to fix LIBALIAS + SCTP_NO_CSUM case. Modified: head/sys/netinet/sctp_crc32.c Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Sun Feb 8 03:02:06 2009 (r188298) +++ head/sys/netinet/sctp_crc32.c Sun Feb 8 03:03:55 2009 (r188299) @@ -729,7 +729,18 @@ sctp_finalize_crc32(uint32_t crc32c) #endif return (crc32c); } +#else +uint32_t +update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) { + + return (0); +} +uint32_t +sctp_finalize_crc32(uint32_t crc32c) +{ + return (0); +} #endif /* !defined(SCTP_WITH_NO_CSUM) */ #if defined(SCTP_WITH_NO_CSUM) From nyan at jp.FreeBSD.org Sat Feb 7 19:25:19 2009 From: nyan at jp.FreeBSD.org (Takahashi Yoshihiro) Date: Sat Feb 7 19:25:31 2009 Subject: svn commit: r188257 - head/sys/pc98/conf In-Reply-To: <20090206235424.GK83537@FreeBSD.org> References: <200902070015.n170FU58075372@svn.freebsd.org> <20090206235424.GK83537@FreeBSD.org> Message-ID: <20090208.122514.27801215.nyan@jp.FreeBSD.org> In article <20090206235424.GK83537@FreeBSD.org> "Wojciech A. Koszek" writes: >> +# EPSON_BOUNCEDMA: XXX >> +# EPSON_MEMWIN: XXX > > Those had no respective comment lines, and I didn't know what those options do. > I expect someone to fill those, or at least present 'ready to commit' comments > on what they do. EPSON_BOUNCEDMA was to use a bounce buffer to upper 15MB, but it's broken now. EPSON_MEMWIN disables 15-16MB chunk, and enables EPSON memory window. --- TAKAHASHI Yoshihiro From deischen at FreeBSD.org Sat Feb 7 22:44:59 2009 From: deischen at FreeBSD.org (Daniel Eischen) Date: Sat Feb 7 22:45:05 2009 Subject: svn commit: r188300 - head/lib/libc_r/uthread Message-ID: <200902080644.n186iwcN014293@svn.freebsd.org> Author: deischen Date: Sun Feb 8 06:44:58 2009 New Revision: 188300 URL: http://svn.freebsd.org/changeset/base/188300 Log: Fix leak of kqueue() file descriptors when linked with static libc_r. PR: 58687 Submitted by: Jonathon Lennox Modified: head/lib/libc_r/uthread/uthread_init.c Modified: head/lib/libc_r/uthread/uthread_init.c ============================================================================== --- head/lib/libc_r/uthread/uthread_init.c Sun Feb 8 03:03:55 2009 (r188299) +++ head/lib/libc_r/uthread/uthread_init.c Sun Feb 8 06:44:58 2009 (r188300) @@ -95,6 +95,7 @@ static void *references[] = { &_getsockopt, &_ioctl, &_kevent, + &_kqueue, &_listen, &_nanosleep, &_open, From imp at FreeBSD.org Sat Feb 7 23:02:43 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Feb 7 23:02:49 2009 Subject: svn commit: r188301 - head/sys/amd64/pci Message-ID: <200902080702.n1872gbB014670@svn.freebsd.org> Author: imp Date: Sun Feb 8 07:02:42 2009 New Revision: 188301 URL: http://svn.freebsd.org/changeset/base/188301 Log: Correct parameter types for pcib_{read,write}_config by fixing the protptyoes for the legacy_* impelemtnations of these kobj methods. Modified: head/sys/amd64/pci/pci_bus.c Modified: head/sys/amd64/pci/pci_bus.c ============================================================================== --- head/sys/amd64/pci/pci_bus.c Sun Feb 8 06:44:58 2009 (r188300) +++ head/sys/amd64/pci/pci_bus.c Sun Feb 8 07:02:42 2009 (r188301) @@ -55,9 +55,9 @@ legacy_pcib_maxslots(device_t dev) /* read configuration space register */ -u_int32_t -legacy_pcib_read_config(device_t dev, int bus, int slot, int func, - int reg, int bytes) +uint32_t +legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, int bytes) { return(pci_cfgregread(bus, slot, func, reg, bytes)); } @@ -65,8 +65,8 @@ legacy_pcib_read_config(device_t dev, in /* write configuration space register */ void -legacy_pcib_write_config(device_t dev, int bus, int slot, int func, - int reg, u_int32_t data, int bytes) +legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, + u_int reg, uint32_t data, int bytes) { pci_cfgregwrite(bus, slot, func, reg, data, bytes); } From imp at FreeBSD.org Sat Feb 7 23:03:35 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Feb 7 23:03:41 2009 Subject: svn commit: r188302 - head/sys/amd64/include Message-ID: <200902080703.n1873YQi014722@svn.freebsd.org> Author: imp Date: Sun Feb 8 07:03:34 2009 New Revision: 188302 URL: http://svn.freebsd.org/changeset/base/188302 Log: Companion for r188301: fix the prototypes. Modified: head/sys/amd64/include/legacyvar.h Modified: head/sys/amd64/include/legacyvar.h ============================================================================== --- head/sys/amd64/include/legacyvar.h Sun Feb 8 07:02:42 2009 (r188301) +++ head/sys/amd64/include/legacyvar.h Sun Feb 8 07:03:34 2009 (r188302) @@ -43,12 +43,12 @@ LEGACY_ACCESSOR(pcibus, PCIBUS, uint3 #undef LEGACY_ACCESSOR int legacy_pcib_maxslots(device_t dev); -uint32_t legacy_pcib_read_config(device_t dev, int bus, int slot, int func, - int reg, int bytes); +uint32_t legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, int bytes); int legacy_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); -void legacy_pcib_write_config(device_t dev, int bus, int slot, int func, - int reg, u_int32_t data, int bytes); +void legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, + u_int func, u_int reg, uint32_t data, int bytes); int legacy_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value); struct resource *legacy_pcib_alloc_resource(device_t dev, device_t child, From imp at FreeBSD.org Sat Feb 7 23:05:24 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sat Feb 7 23:05:31 2009 Subject: svn commit: r188303 - head/sys/geom/part Message-ID: <200902080705.n1875NNd014796@svn.freebsd.org> Author: imp Date: Sun Feb 8 07:05:23 2009 New Revision: 188303 URL: http://svn.freebsd.org/changeset/base/188303 Log: Fix g_part_*dumpconf to return void to match kobj definition. Fix g_part_*name to return a const char * rather than a char *. Modified: head/sys/geom/part/g_part_bsd.c head/sys/geom/part/g_part_mbr.c Modified: head/sys/geom/part/g_part_bsd.c ============================================================================== --- head/sys/geom/part/g_part_bsd.c Sun Feb 8 07:03:34 2009 (r188302) +++ head/sys/geom/part/g_part_bsd.c Sun Feb 8 07:05:23 2009 (r188303) @@ -60,12 +60,12 @@ static int g_part_bsd_add(struct g_part_ struct g_part_parms *); static int g_part_bsd_create(struct g_part_table *, struct g_part_parms *); static int g_part_bsd_destroy(struct g_part_table *, struct g_part_parms *); -static int g_part_bsd_dumpconf(struct g_part_table *, struct g_part_entry *, +static void g_part_bsd_dumpconf(struct g_part_table *, struct g_part_entry *, struct sbuf *, const char *); static int g_part_bsd_dumpto(struct g_part_table *, struct g_part_entry *); static int g_part_bsd_modify(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); -static char *g_part_bsd_name(struct g_part_table *, struct g_part_entry *, +static const char *g_part_bsd_name(struct g_part_table *, struct g_part_entry *, char *, size_t); static int g_part_bsd_probe(struct g_part_table *, struct g_consumer *); static int g_part_bsd_read(struct g_part_table *, struct g_consumer *); @@ -216,7 +216,7 @@ g_part_bsd_destroy(struct g_part_table * return (0); } -static int +static void g_part_bsd_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) { @@ -233,7 +233,6 @@ g_part_bsd_dumpconf(struct g_part_table } else { /* confxml: scheme information */ } - return (0); } static int @@ -262,7 +261,7 @@ g_part_bsd_modify(struct g_part_table *b return (0); } -static char * +static const char * g_part_bsd_name(struct g_part_table *table, struct g_part_entry *baseentry, char *buf, size_t bufsz) { Modified: head/sys/geom/part/g_part_mbr.c ============================================================================== --- head/sys/geom/part/g_part_mbr.c Sun Feb 8 07:03:34 2009 (r188302) +++ head/sys/geom/part/g_part_mbr.c Sun Feb 8 07:05:23 2009 (r188303) @@ -62,12 +62,12 @@ static int g_part_mbr_add(struct g_part_ static int g_part_mbr_bootcode(struct g_part_table *, struct g_part_parms *); static int g_part_mbr_create(struct g_part_table *, struct g_part_parms *); static int g_part_mbr_destroy(struct g_part_table *, struct g_part_parms *); -static int g_part_mbr_dumpconf(struct g_part_table *, struct g_part_entry *, +static void g_part_mbr_dumpconf(struct g_part_table *, struct g_part_entry *, struct sbuf *, const char *); static int g_part_mbr_dumpto(struct g_part_table *, struct g_part_entry *); static int g_part_mbr_modify(struct g_part_table *, struct g_part_entry *, struct g_part_parms *); -static char *g_part_mbr_name(struct g_part_table *, struct g_part_entry *, +static const char *g_part_mbr_name(struct g_part_table *, struct g_part_entry *, char *, size_t); static int g_part_mbr_probe(struct g_part_table *, struct g_consumer *); static int g_part_mbr_read(struct g_part_table *, struct g_consumer *); @@ -256,7 +256,7 @@ g_part_mbr_destroy(struct g_part_table * return (0); } -static int +static void g_part_mbr_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, struct sbuf *sb, const char *indent) { @@ -275,7 +275,6 @@ g_part_mbr_dumpconf(struct g_part_table } else { /* confxml: scheme information */ } - return (0); } static int @@ -303,7 +302,7 @@ g_part_mbr_modify(struct g_part_table *b return (0); } -static char * +static const char * g_part_mbr_name(struct g_part_table *table, struct g_part_entry *baseentry, char *buf, size_t bufsz) { From imp at FreeBSD.org Sun Feb 8 00:13:36 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sun Feb 8 00:14:00 2009 Subject: svn commit: r188304 - head/sys/mips/mips Message-ID: <200902080813.n188DaPV016088@svn.freebsd.org> Author: imp Date: Sun Feb 8 08:13:36 2009 New Revision: 188304 URL: http://svn.freebsd.org/changeset/base/188304 Log: Retire NO_DMA completely. Modified: head/sys/mips/mips/busdma_machdep.c Modified: head/sys/mips/mips/busdma_machdep.c ============================================================================== --- head/sys/mips/mips/busdma_machdep.c Sun Feb 8 07:05:23 2009 (r188303) +++ head/sys/mips/mips/busdma_machdep.c Sun Feb 8 08:13:36 2009 (r188304) @@ -187,7 +187,6 @@ busdma_lock_mutex(void *arg, bus_dma_loc * with the tag are meant to never be defered. * XXX Should have a way to identify which driver is responsible here. */ -#ifndef NO_DMA static void dflt_lock(void *arg, bus_dma_lock_op_t op) { @@ -197,7 +196,6 @@ dflt_lock(void *arg, bus_dma_lock_op_t o printf("DRIVER_ERROR: busdma dflt_lock called\n"); #endif } -#endif static __inline bus_dmamap_t _busdma_alloc_dmamap(void) @@ -238,7 +236,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t maxsegsz, int flags, bus_dma_lock_t *lockfunc, void *lockfuncarg, bus_dma_tag_t *dmat) { -#ifndef NO_DMA bus_dma_tag_t newtag; int error = 0; @@ -313,10 +310,6 @@ bus_dma_tag_create(bus_dma_tag_t parent, CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d", __func__, newtag, (newtag != NULL ? newtag->flags : 0), error); return (error); -#else - return ENOSYS; -#endif - } int From keramida at FreeBSD.org Sun Feb 8 00:26:59 2009 From: keramida at FreeBSD.org (Giorgos Keramidas) Date: Sun Feb 8 00:27:05 2009 Subject: svn commit: r188305 - head/lib/libc/stdlib Message-ID: <200902080826.n188QwpD016349@svn.freebsd.org> Author: keramida (doc committer) Date: Sun Feb 8 08:26:58 2009 New Revision: 188305 URL: http://svn.freebsd.org/changeset/base/188305 Log: Fix language on atol(3) manpage. Add a COMPATIBILITY section stating that in FreeBSD the atol() and atoll() functions affect errno in the same way as strtol() and stroll(). PR: docs/126487 Submitted by: edwin Reviewed by: trhodes, gabor MFC after: 1 week Modified: head/lib/libc/stdlib/atol.3 Modified: head/lib/libc/stdlib/atol.3 ============================================================================== --- head/lib/libc/stdlib/atol.3 Sun Feb 8 08:13:36 2009 (r188304) +++ head/lib/libc/stdlib/atol.3 Sun Feb 8 08:26:58 2009 (r188305) @@ -32,7 +32,7 @@ .\" @(#)atol.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd November 28, 2001 +.Dd February 1, 2009 .Dt ATOL 3 .Os .Sh NAME @@ -78,13 +78,42 @@ representation. It is equivalent to: .Pp .Dl "strtoll(nptr, (char **)NULL, 10);" +.Sh COMPATIBILITY +The +.Fx +implementations of the +.Fn atol +and +.Fn atoll +functions are thin wrappers around +.Fn strtol +and +.Fn stroll +respectively, so these functions will affect the value of +.Va errno +in the same way that the +.Fn strtol +and +.Fn stroll +functions are able to. +This behavior of +.Fn atol +and +.Fn atoll +is not required by +.St -isoC +or +.St -isoC-c99 , +but it is allowed by all of +.St -isoC , St -isoC-99 +and +.St -p1003.1-2001 . .Sh ERRORS The functions .Fn atol and .Fn atoll -need not -affect the value of +may affect the value of .Va errno on an error. .Sh SEE ALSO From bz at FreeBSD.org Sun Feb 8 01:27:08 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Sun Feb 8 01:27:16 2009 Subject: svn commit: r188306 - in head/sys: netinet netinet6 netipsec Message-ID: <200902080927.n189R7B4017499@svn.freebsd.org> Author: bz Date: Sun Feb 8 09:27:07 2009 New Revision: 188306 URL: http://svn.freebsd.org/changeset/base/188306 Log: Try to remove/assimilate as much of formerly IPv4/6 specific (duplicate) code in sys/netipsec/ipsec.c and fold it into common, INET/6 independent functions. The file local functions ipsec4_setspidx_inpcb() and ipsec6_setspidx_inpcb() were 1:1 identical after the change in r186528. Rename to ipsec_setspidx_inpcb() and remove the duplicate. Public functions ipsec[46]_get_policy() were 1:1 identical. Remove one copy and merge in the factored out code from ipsec_get_policy() into the other. The public function left is now called ipsec_get_policy() and callers were adapted. Public functions ipsec[46]_set_policy() were 1:1 identical. Rename file local ipsec_set_policy() function to ipsec_set_policy_internal(). Remove one copy of the public functions, rename the other to ipsec_set_policy() and adapt callers. Public functions ipsec[46]_hdrsiz() were logically identical (ignoring one questionable assert in the v6 version). Rename the file local ipsec_hdrsiz() to ipsec_hdrsiz_internal(), the public function to ipsec_hdrsiz(), remove the duplicate copy and adapt the callers. The v6 version had been unused anyway. Cleanup comments. Public functions ipsec[46]_in_reject() were logically identical apart from statistics. Move the common code into a file local ipsec46_in_reject() leaving vimage+statistics in small AF specific wrapper functions. Note: unfortunately we already have a public ipsec_in_reject(). Reviewed by: sam Discussed with: rwatson (renaming to *_internal) MFC after: 26 days X-MFC: keep wrapper functions for public symbols? Modified: head/sys/netinet/ip_ipsec.c head/sys/netinet/ip_output.c head/sys/netinet/tcp_subr.c head/sys/netinet6/ip6_forward.c head/sys/netinet6/ip6_ipsec.c head/sys/netinet6/ip6_output.c head/sys/netipsec/ipsec.c head/sys/netipsec/ipsec.h head/sys/netipsec/ipsec6.h Modified: head/sys/netinet/ip_ipsec.c ============================================================================== --- head/sys/netinet/ip_ipsec.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet/ip_ipsec.c Sun Feb 8 09:27:07 2009 (r188306) @@ -218,9 +218,7 @@ ip_ipsec_mtu(struct mbuf *m, int mtu) &ipsecerror); if (sp != NULL) { /* count IPsec header size */ - ipsechdr = ipsec4_hdrsiz(m, - IPSEC_DIR_OUTBOUND, - NULL); + ipsechdr = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL); /* * find the correct route for outer IPv4 Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet/ip_output.c Sun Feb 8 09:27:07 2009 (r188306) @@ -1050,7 +1050,7 @@ ip_ctloutput(struct socket *so, struct s if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */ break; req = mtod(m, caddr_t); - error = ipsec4_set_policy(inp, sopt->sopt_name, req, + error = ipsec_set_policy(inp, sopt->sopt_name, req, m->m_len, (sopt->sopt_td != NULL) ? sopt->sopt_td->td_ucred : NULL); m_freem(m); @@ -1171,7 +1171,7 @@ ip_ctloutput(struct socket *so, struct s req = mtod(m, caddr_t); len = m->m_len; } - error = ipsec4_get_policy(sotoinpcb(so), req, len, &m); + error = ipsec_get_policy(sotoinpcb(so), req, len, &m); if (error == 0) error = soopt_mcopyout(sopt, m); /* XXX */ if (error == 0) Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet/tcp_subr.c Sun Feb 8 09:27:07 2009 (r188306) @@ -1744,7 +1744,7 @@ ipsec_hdrsiz_tcp(struct tcpcb *tp) m->m_pkthdr.len = m->m_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr); tcpip_fillheaders(inp, ip6, th); - hdrsiz = ipsec6_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp); + hdrsiz = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp); } else #endif /* INET6 */ { @@ -1752,7 +1752,7 @@ ipsec_hdrsiz_tcp(struct tcpcb *tp) th = (struct tcphdr *)(ip + 1); m->m_pkthdr.len = m->m_len = sizeof(struct tcpiphdr); tcpip_fillheaders(inp, ip, th); - hdrsiz = ipsec4_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp); + hdrsiz = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, inp); } m_free(m); Modified: head/sys/netinet6/ip6_forward.c ============================================================================== --- head/sys/netinet6/ip6_forward.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet6/ip6_forward.c Sun Feb 8 09:27:07 2009 (r188306) @@ -457,7 +457,7 @@ skip_routing: sp = ipsec_getpolicybyaddr(mcopy, IPSEC_DIR_OUTBOUND, IP_FORWARDING, &ipsecerror); if (sp) { - ipsechdrsiz = ipsec6_hdrsiz(mcopy, + ipsechdrsiz = ipsec_hdrsiz(mcopy, IPSEC_DIR_OUTBOUND, NULL); if (ipsechdrsiz < mtu) mtu -= ipsechdrsiz; Modified: head/sys/netinet6/ip6_ipsec.c ============================================================================== --- head/sys/netinet6/ip6_ipsec.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet6/ip6_ipsec.c Sun Feb 8 09:27:07 2009 (r188306) @@ -341,9 +341,7 @@ ip6_ipsec_mtu(struct mbuf *m) &ipsecerror); if (sp != NULL) { /* count IPsec header size */ - ipsechdr = ipsec4_hdrsiz(m, - IPSEC_DIR_OUTBOUND, - NULL); + ipsechdr = ipsec_hdrsiz(m, IPSEC_DIR_OUTBOUND, NULL); /* * find the correct route for outer IPv4 Modified: head/sys/netinet6/ip6_output.c ============================================================================== --- head/sys/netinet6/ip6_output.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netinet6/ip6_output.c Sun Feb 8 09:27:07 2009 (r188306) @@ -1799,7 +1799,7 @@ do { \ if ((error = soopt_mcopyin(sopt, m)) != 0) /* XXX */ break; req = mtod(m, caddr_t); - error = ipsec6_set_policy(in6p, optname, req, + error = ipsec_set_policy(in6p, optname, req, m->m_len, (sopt->sopt_td != NULL) ? sopt->sopt_td->td_ucred : NULL); m_freem(m); @@ -2024,7 +2024,7 @@ do { \ req = mtod(m, caddr_t); len = m->m_len; } - error = ipsec6_get_policy(in6p, req, len, mp); + error = ipsec_get_policy(in6p, req, len, mp); if (error == 0) error = soopt_mcopyout(sopt, m); /* XXX */ if (error == 0 && m) Modified: head/sys/netipsec/ipsec.c ============================================================================== --- head/sys/netipsec/ipsec.c Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netipsec/ipsec.c Sun Feb 8 09:27:07 2009 (r188306) @@ -228,10 +228,7 @@ SYSCTL_V_STRUCT(V_NET, vnet_ipsec, _net_ "IPsec IPv6 statistics."); #endif /* INET6 */ -static int ipsec4_setspidx_inpcb __P((struct mbuf *, struct inpcb *)); -#ifdef INET6 -static int ipsec6_setspidx_inpcb __P((struct mbuf *, struct inpcb *)); -#endif +static int ipsec_setspidx_inpcb __P((struct mbuf *, struct inpcb *)); static int ipsec_setspidx __P((struct mbuf *, struct secpolicyindex *, int)); static void ipsec4_get_ulp __P((struct mbuf *m, struct secpolicyindex *, int)); static int ipsec4_setspidx_ipaddr __P((struct mbuf *, struct secpolicyindex *)); @@ -241,11 +238,7 @@ static int ipsec6_setspidx_ipaddr __P((s #endif static void ipsec_delpcbpolicy __P((struct inpcbpolicy *)); static struct secpolicy *ipsec_deepcopy_policy __P((struct secpolicy *src)); -static int ipsec_set_policy __P((struct secpolicy **pcb_sp, - int optname, caddr_t request, size_t len, struct ucred *cred)); -static int ipsec_get_policy __P((struct secpolicy *pcb_sp, struct mbuf **mp)); static void vshiftl __P((unsigned char *, int, int)); -static size_t ipsec_hdrsiz __P((struct secpolicy *)); MALLOC_DEFINE(M_IPSEC_INPCB, "inpcbpolicy", "inpcb-resident ipsec policy"); @@ -358,7 +351,7 @@ static struct secpolicy * ipsec_getpolicybysock(struct mbuf *m, u_int dir, struct inpcb *inp, int *error) { INIT_VNET_IPSEC(curvnet); - struct inpcbpolicy *pcbsp = NULL; + struct inpcbpolicy *pcbsp; struct secpolicy *currsp = NULL; /* Policy on socket. */ struct secpolicy *sp; @@ -369,20 +362,11 @@ ipsec_getpolicybysock(struct mbuf *m, u_ ("invalid direction %u", dir)); /* Set spidx in pcb. */ - if (inp->inp_vflag & INP_IPV6PROTO) { -#ifdef INET6 - *error = ipsec6_setspidx_inpcb(m, inp); - pcbsp = inp->inp_sp; -#else - *error = EINVAL; /* Should not happen. */ -#endif - } else { - *error = ipsec4_setspidx_inpcb(m, inp); - pcbsp = inp->inp_sp; - } + *error = ipsec_setspidx_inpcb(m, inp); if (*error) return (NULL); + pcbsp = inp->inp_sp; IPSEC_ASSERT(pcbsp != NULL, ("null pcbsp")); switch (dir) { case IPSEC_DIR_INBOUND: @@ -538,7 +522,7 @@ ipsec4_checkpolicy(struct mbuf *m, u_int } static int -ipsec4_setspidx_inpcb(struct mbuf *m, struct inpcb *inp) +ipsec_setspidx_inpcb(struct mbuf *m, struct inpcb *inp) { int error; @@ -561,33 +545,6 @@ ipsec4_setspidx_inpcb(struct mbuf *m, st return (error); } -#ifdef INET6 -static int -ipsec6_setspidx_inpcb(struct mbuf *m, struct inpcb *inp) -{ - int error; - - IPSEC_ASSERT(inp != NULL, ("null inp")); - IPSEC_ASSERT(inp->inp_sp != NULL, ("null inp_sp")); - IPSEC_ASSERT(inp->inp_sp->sp_out != NULL && inp->inp_sp->sp_in != NULL, - ("null sp_in || sp_out")); - - error = ipsec_setspidx(m, &inp->inp_sp->sp_in->spidx, 1); - if (error == 0) { - inp->inp_sp->sp_in->spidx.dir = IPSEC_DIR_INBOUND; - inp->inp_sp->sp_out->spidx = inp->inp_sp->sp_in->spidx; - inp->inp_sp->sp_out->spidx.dir = IPSEC_DIR_OUTBOUND; - } else { - bzero(&inp->inp_sp->sp_in->spidx, - sizeof(inp->inp_sp->sp_in->spidx)); - bzero(&inp->inp_sp->sp_out->spidx, - sizeof(inp->inp_sp->sp_in->spidx)); - } - - return (error); -} -#endif - /* * Configure security policy index (src/dst/proto/sport/dport) * by looking at the content of mbuf. @@ -1036,8 +993,8 @@ fail: /* Set policy and IPsec request if present. */ static int -ipsec_set_policy(struct secpolicy **pcb_sp, int optname, caddr_t request, - size_t len, struct ucred *cred) +ipsec_set_policy_internal(struct secpolicy **pcb_sp, int optname, + caddr_t request, size_t len, struct ucred *cred) { INIT_VNET_IPSEC(curvnet); struct sadb_x_policy *xpl; @@ -1056,7 +1013,7 @@ ipsec_set_policy(struct secpolicy **pcb_ kdebug_sadb_x_policy((struct sadb_ext *)xpl)); /* Check policy type. */ - /* ipsec_set_policy() accepts IPSEC, ENTRUST and BYPASS. */ + /* ipsec_set_policy_internal() accepts IPSEC, ENTRUST and BYPASS. */ if (xpl->sadb_x_policy_type == IPSEC_POLICY_DISCARD || xpl->sadb_x_policy_type == IPSEC_POLICY_NONE) return (EINVAL); @@ -1084,30 +1041,8 @@ ipsec_set_policy(struct secpolicy **pcb_ return (0); } -static int -ipsec_get_policy(struct secpolicy *pcb_sp, struct mbuf **mp) -{ - INIT_VNET_IPSEC(curvnet); - - /* Sanity check. */ - if (pcb_sp == NULL || mp == NULL) - return (EINVAL); - - *mp = key_sp2msg(pcb_sp); - if (!*mp) { - ipseclog((LOG_DEBUG, "%s: No more memory.\n", __func__)); - return (ENOBUFS); - } - - (*mp)->m_type = MT_DATA; - KEYDEBUG(KEYDEBUG_IPSEC_DUMP, - printf("%s:\n", __func__); kdebug_mbuf(*mp)); - - return (0); -} - int -ipsec4_set_policy(struct inpcb *inp, int optname, caddr_t request, +ipsec_set_policy(struct inpcb *inp, int optname, caddr_t request, size_t len, struct ucred *cred) { INIT_VNET_IPSEC(curvnet); @@ -1135,11 +1070,11 @@ ipsec4_set_policy(struct inpcb *inp, int return (EINVAL); } - return (ipsec_set_policy(pcb_sp, optname, request, len, cred)); + return (ipsec_set_policy_internal(pcb_sp, optname, request, len, cred)); } int -ipsec4_get_policy(struct inpcb *inp, caddr_t request, size_t len, +ipsec_get_policy(struct inpcb *inp, caddr_t request, size_t len, struct mbuf **mp) { INIT_VNET_IPSEC(curvnet); @@ -1168,7 +1103,21 @@ ipsec4_get_policy(struct inpcb *inp, cad return (EINVAL); } - return (ipsec_get_policy(pcb_sp, mp)); + /* Sanity check. Should be an IPSEC_ASSERT. */ + if (pcb_sp == NULL) + return (EINVAL); + + *mp = key_sp2msg(pcb_sp); + if (!*mp) { + ipseclog((LOG_DEBUG, "%s: No more memory.\n", __func__)); + return (ENOBUFS); + } + + (*mp)->m_type = MT_DATA; + KEYDEBUG(KEYDEBUG_IPSEC_DUMP, + printf("%s:\n", __func__); kdebug_mbuf(*mp)); + + return (0); } /* Delete policy in PCB. */ @@ -1192,73 +1141,6 @@ ipsec_delete_pcbpolicy(struct inpcb *inp return (0); } -#ifdef INET6 -int -ipsec6_set_policy(struct inpcb *inp, int optname, caddr_t request, - size_t len, struct ucred *cred) -{ - INIT_VNET_IPSEC(curvnet); - struct sadb_x_policy *xpl; - struct secpolicy **pcb_sp; - - /* Sanity check. */ - if (inp == NULL || request == NULL) - return (EINVAL); - if (len < sizeof(*xpl)) - return (EINVAL); - xpl = (struct sadb_x_policy *)request; - - /* Select direction. */ - switch (xpl->sadb_x_policy_dir) { - case IPSEC_DIR_INBOUND: - pcb_sp = &inp->inp_sp->sp_in; - break; - case IPSEC_DIR_OUTBOUND: - pcb_sp = &inp->inp_sp->sp_out; - break; - default: - ipseclog((LOG_ERR, "%s: invalid direction=%u\n", __func__, - xpl->sadb_x_policy_dir)); - return (EINVAL); - } - - return (ipsec_set_policy(pcb_sp, optname, request, len, cred)); -} - -int -ipsec6_get_policy(struct inpcb *inp, caddr_t request, size_t len, - struct mbuf **mp) -{ - INIT_VNET_IPSEC(curvnet); - struct sadb_x_policy *xpl; - struct secpolicy *pcb_sp; - - /* Sanity check. */ - if (inp == NULL || request == NULL || mp == NULL) - return (EINVAL); - IPSEC_ASSERT(inp->inp_sp != NULL, ("null inp_sp")); - if (len < sizeof(*xpl)) - return (EINVAL); - xpl = (struct sadb_x_policy *)request; - - /* Select direction. */ - switch (xpl->sadb_x_policy_dir) { - case IPSEC_DIR_INBOUND: - pcb_sp = inp->inp_sp->sp_in; - break; - case IPSEC_DIR_OUTBOUND: - pcb_sp = inp->inp_sp->sp_out; - break; - default: - ipseclog((LOG_ERR, "%s: invalid direction=%u\n", __func__, - xpl->sadb_x_policy_dir)); - return (EINVAL); - } - - return (ipsec_get_policy(pcb_sp, mp)); -} -#endif - /* * Return current level. * Either IPSEC_LEVEL_USE or IPSEC_LEVEL_REQUIRE are always returned. @@ -1437,15 +1319,9 @@ ipsec_in_reject(struct secpolicy *sp, st return (0); /* Valid. */ } -/* - * Check AH/ESP integrity. - * This function is called from tcp_input(), udp_input(), - * and {ah,esp}4_input for tunnel mode. - */ -int -ipsec4_in_reject(struct mbuf *m, struct inpcb *inp) +static int +ipsec46_in_reject(struct mbuf *m, struct inpcb *inp) { - INIT_VNET_IPSEC(curvnet); struct secpolicy *sp; int error; int result; @@ -1464,8 +1340,6 @@ ipsec4_in_reject(struct mbuf *m, struct if (sp != NULL) { result = ipsec_in_reject(sp, m); - if (result) - V_ipsec4stat.ips_in_polvio++; KEY_FREESP(&sp); } else { result = 0; /* XXX Should be panic? @@ -1474,6 +1348,24 @@ ipsec4_in_reject(struct mbuf *m, struct return (result); } +/* + * Check AH/ESP integrity. + * This function is called from tcp_input(), udp_input(), + * and {ah,esp}4_input for tunnel mode. + */ +int +ipsec4_in_reject(struct mbuf *m, struct inpcb *inp) +{ + INIT_VNET_IPSEC(curvnet); + int result; + + result = ipsec46_in_reject(m, inp); + if (result) + V_ipsec4stat.ips_in_polvio++; + + return (result); +} + #ifdef INET6 /* * Check AH/ESP integrity. @@ -1484,31 +1376,12 @@ int ipsec6_in_reject(struct mbuf *m, struct inpcb *inp) { INIT_VNET_IPSEC(curvnet); - struct secpolicy *sp = NULL; - int error; int result; - /* Sanity check. */ - if (m == NULL) - return (0); /* XXX Should be panic? */ - - /* Get SP for this packet. - * When we are called from ip_forward(), we call - * ipsec_getpolicybyaddr() with IP_FORWARDING flag. - */ - if (inp == NULL) - sp = ipsec_getpolicybyaddr(m, IPSEC_DIR_INBOUND, IP_FORWARDING, &error); - else - sp = ipsec_getpolicybysock(m, IPSEC_DIR_INBOUND, inp, &error); + result = ipsec46_in_reject(m, inp); + if (result) + V_ipsec6stat.ips_in_polvio++; - if (sp != NULL) { - result = ipsec_in_reject(sp, m); - if (result) - V_ipsec6stat.ips_in_polvio++; - KEY_FREESP(&sp); - } else { - result = 0; - } return (result); } #endif @@ -1519,7 +1392,7 @@ ipsec6_in_reject(struct mbuf *m, struct * NOTE: SP passed is freed in this function. */ static size_t -ipsec_hdrsiz(struct secpolicy *sp) +ipsec_hdrsiz_internal(struct secpolicy *sp) { INIT_VNET_IPSEC(curvnet); struct ipsecrequest *isr; @@ -1577,9 +1450,12 @@ ipsec_hdrsiz(struct secpolicy *sp) return (size); } -/* This function is called from ip_forward() and ipsec4_hdrsize_tcp(). */ +/* + * This function is called from ipsec_hdrsiz_tcp(), ip_ipsec_mtu(), + * disabled ip6_ipsec_mtu() and ip6_forward(). + */ size_t -ipsec4_hdrsiz(struct mbuf *m, u_int dir, struct inpcb *inp) +ipsec_hdrsiz(struct mbuf *m, u_int dir, struct inpcb *inp) { INIT_VNET_IPSEC(curvnet); struct secpolicy *sp; @@ -1598,7 +1474,7 @@ ipsec4_hdrsiz(struct mbuf *m, u_int dir, sp = ipsec_getpolicybysock(m, dir, inp, &error); if (sp != NULL) { - size = ipsec_hdrsiz(sp); + size = ipsec_hdrsiz_internal(sp); KEYDEBUG(KEYDEBUG_IPSEC_DATA, printf("%s: size:%lu.\n", __func__, (unsigned long)size)); @@ -1612,40 +1488,6 @@ ipsec4_hdrsiz(struct mbuf *m, u_int dir, return (size); } -#ifdef INET6 -/* This function is called from ipsec6_hdrsize_tcp(), - * and maybe from ip6_forward(). - */ -size_t -ipsec6_hdrsiz(struct mbuf *m, u_int dir, struct inpcb *inp) -{ - INIT_VNET_IPSEC(curvnet); - struct secpolicy *sp; - int error; - size_t size; - - IPSEC_ASSERT(m != NULL, ("null mbuf")); - IPSEC_ASSERT(inp == NULL || inp->inp_socket != NULL, - ("socket w/o inpcb")); - - /* Get SP for this packet. */ - /* XXX Is it right to call with IP_FORWARDING. */ - if (inp == NULL) - sp = ipsec_getpolicybyaddr(m, dir, IP_FORWARDING, &error); - else - sp = ipsec_getpolicybysock(m, dir, inp, &error); - - if (sp == NULL) - return (0); - size = ipsec_hdrsiz(sp); - KEYDEBUG(KEYDEBUG_IPSEC_DATA, - printf("%s: size:%lu.\n", __func__, (unsigned long)size)); - KEY_FREESP(&sp); - - return (size); -} -#endif /*INET6*/ - /* * Check the variable replay window. * ipsec_chkreplay() performs replay check before ICV verification. Modified: head/sys/netipsec/ipsec.h ============================================================================== --- head/sys/netipsec/ipsec.h Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netipsec/ipsec.h Sun Feb 8 09:27:07 2009 (r188306) @@ -374,9 +374,9 @@ extern int ipsec_copy_policy extern u_int ipsec_get_reqlevel __P((struct ipsecrequest *)); extern int ipsec_in_reject __P((struct secpolicy *, struct mbuf *)); -extern int ipsec4_set_policy __P((struct inpcb *inp, int optname, +extern int ipsec_set_policy __P((struct inpcb *inp, int optname, caddr_t request, size_t len, struct ucred *cred)); -extern int ipsec4_get_policy __P((struct inpcb *inpcb, caddr_t request, +extern int ipsec_get_policy __P((struct inpcb *inpcb, caddr_t request, size_t len, struct mbuf **mp)); extern int ipsec_delete_pcbpolicy __P((struct inpcb *)); extern int ipsec4_in_reject __P((struct mbuf *, struct inpcb *)); @@ -386,7 +386,7 @@ struct tcpcb; extern int ipsec_chkreplay __P((u_int32_t, struct secasvar *)); extern int ipsec_updatereplay __P((u_int32_t, struct secasvar *)); -extern size_t ipsec4_hdrsiz __P((struct mbuf *, u_int, struct inpcb *)); +extern size_t ipsec_hdrsiz __P((struct mbuf *, u_int, struct inpcb *)); extern size_t ipsec_hdrsiz_tcp __P((struct tcpcb *)); union sockaddr_union; Modified: head/sys/netipsec/ipsec6.h ============================================================================== --- head/sys/netipsec/ipsec6.h Sun Feb 8 08:26:58 2009 (r188305) +++ head/sys/netipsec/ipsec6.h Sun Feb 8 09:27:07 2009 (r188306) @@ -50,16 +50,8 @@ extern int ip6_ipsec_ecn; struct inpcb; -extern int ipsec6_set_policy __P((struct inpcb *inp, int optname, - caddr_t request, size_t len, struct ucred *cred)); -extern int ipsec6_get_policy - __P((struct inpcb *inp, caddr_t request, size_t len, struct mbuf **mp)); extern int ipsec6_in_reject __P((struct mbuf *, struct inpcb *)); -struct tcp6cb; - -extern size_t ipsec6_hdrsiz __P((struct mbuf *, u_int, struct inpcb *)); - struct ip6_hdr; extern const char *ipsec6_logpacketstr __P((struct ip6_hdr *, u_int32_t)); From wkoszek at FreeBSD.org Sun Feb 8 02:21:26 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sun Feb 8 02:21:33 2009 Subject: svn commit: r188307 - head/sys/pc98/conf Message-ID: <200902081021.n18ALQd5020824@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 10:21:25 2009 New Revision: 188307 URL: http://svn.freebsd.org/changeset/base/188307 Log: Bring missing comments on EPSON_BOUNCEDMA and EPSON_MEMWIN flags. Submitted by: nyan Modified: head/sys/pc98/conf/NOTES Modified: head/sys/pc98/conf/NOTES ============================================================================== --- head/sys/pc98/conf/NOTES Sun Feb 8 09:27:07 2009 (r188306) +++ head/sys/pc98/conf/NOTES Sun Feb 8 10:21:25 2009 (r188307) @@ -272,8 +272,11 @@ device isa # reset the CPU for reboot. This is needed on some systems with broken # keyboard controllers. # -# EPSON_BOUNCEDMA: XXX -# EPSON_MEMWIN: XXX +# EPSON_BOUNCEDMA was to use a bounce buffer to upper 15MB, but it's +# broken now. +# +# EPSON_MEMWIN disables 15-16MB chunk, and enables EPSON memory window. +# options AUTO_EOI_1 From wkoszek at FreeBSD.org Sun Feb 8 04:12:20 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sun Feb 8 04:12:31 2009 Subject: svn commit: r188308 - head/sys/conf Message-ID: <200902081212.n18CCJm5022822@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 12:12:19 2009 New Revision: 188308 URL: http://svn.freebsd.org/changeset/base/188308 Log: Add missing pcfclock description. Modified: head/sys/conf/NOTES Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Sun Feb 8 10:21:25 2009 (r188307) +++ head/sys/conf/NOTES Sun Feb 8 12:12:19 2009 (r188308) @@ -2352,6 +2352,7 @@ device ds1672 # ppi General-purpose I/O ("Geek Port") + IEEE1284 I/O # pps Pulse per second Timing Interface # lpbb Philips official parallel port I2C bit-banging interface +# pcfclock Parallel port clock driver. # # Supported interfaces: # ppc ISA-bus parallel port interfaces. From wkoszek at FreeBSD.org Sun Feb 8 04:33:06 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sun Feb 8 04:33:18 2009 Subject: svn commit: r188309 - head/sys/conf Message-ID: <200902081233.n18CX5n5023301@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 12:33:05 2009 New Revision: 188309 URL: http://svn.freebsd.org/changeset/base/188309 Log: Further NOTES cleanup -- following drivers didn't survive TTY-ng and aren't included in NOTES anyway: cy(4), rc(4), rp(4). si(4) doesn't belong to global NOTES. Modified: head/sys/conf/NOTES Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Sun Feb 8 12:12:19 2009 (r188308) +++ head/sys/conf/NOTES Sun Feb 8 12:33:05 2009 (r188309) @@ -2138,44 +2138,9 @@ device tnt4882 # scd: Sony CD-ROM using proprietary (non-ATAPI) interface # mcd: Mitsumi CD-ROM using proprietary (non-ATAPI) interface # bktr: Brooktree bt848/848a/849a/878/879 video capture and TV Tuner board -# cy: Cyclades serial driver # joy: joystick (including IO DATA PCJOY PC Card joystick) -# rc: RISCom/8 multiport card -# rp: Comtrol Rocketport(ISA/PCI) - single card -# si: Specialix SI/XIO 4-32 port terminal multiplexor # cmx: OmniKey CardMan 4040 pccard smartcard reader -# Notes on the Comtrol Rocketport driver: -# -# The exact values used for rp0 depend on how many boards you have -# in the system. The manufacturer's sample configs are listed as: -# -# device rp # core driver support -# -# Comtrol Rocketport ISA single card -# hint.rp.0.at="isa" -# hint.rp.0.port="0x280" -# -# If instead you have two ISA cards, one installed at 0x100 and the -# second installed at 0x180, then you should add the following to -# your kernel probe hints: -# hint.rp.0.at="isa" -# hint.rp.0.port="0x100" -# hint.rp.1.at="isa" -# hint.rp.1.port="0x180" -# -# For 4 ISA cards, it might be something like this: -# hint.rp.0.at="isa" -# hint.rp.0.port="0x180" -# hint.rp.1.at="isa" -# hint.rp.1.port="0x100" -# hint.rp.2.at="isa" -# hint.rp.2.port="0x340" -# hint.rp.3.at="isa" -# hint.rp.3.port="0x240" -# -# For PCI cards, you need no hints. - # Mitsumi CD-ROM device mcd hint.mcd.0.at="isa" From wkoszek at FreeBSD.org Sun Feb 8 04:40:36 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sun Feb 8 04:40:47 2009 Subject: svn commit: r188310 - head/sys/i386/conf Message-ID: <200902081240.n18CeYWh023470@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 12:40:33 2009 New Revision: 188310 URL: http://svn.freebsd.org/changeset/base/188310 Log: si(4) seems to build without a problem. However, since noone noticed lack of this driver, put it in a comment. Modified: head/sys/i386/conf/NOTES Modified: head/sys/i386/conf/NOTES ============================================================================== --- head/sys/i386/conf/NOTES Sun Feb 8 12:33:05 2009 (r188309) +++ head/sys/i386/conf/NOTES Sun Feb 8 12:40:33 2009 (r188310) @@ -721,6 +721,7 @@ device glxsb # AMD Geode LX Security B # pbio: Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) # spic: Sony Programmable I/O controller (VAIO notebooks) # asmc: Apple System Management Controller +# si: Specialix International SI/XIO or SX intelligent serial card driver # Notes on APM # The flags takes the following meaning for apm0: @@ -758,6 +759,8 @@ device spic hint.spic.0.at="isa" hint.spic.0.port="0x10a0" device asmc +#device si + # # Laptop/Notebook options: # From rwatson at FreeBSD.org Sun Feb 8 06:04:09 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Feb 8 06:04:21 2009 Subject: svn commit: r188311 - in head/sys: nfsserver security/audit Message-ID: <200902081404.n18E48RK025251@svn.freebsd.org> Author: rwatson Date: Sun Feb 8 14:04:08 2009 New Revision: 188311 URL: http://svn.freebsd.org/changeset/base/188311 Log: Audit the flag argument to the nfssvc(2) system call. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. Modified: head/sys/nfsserver/nfs_syscalls.c head/sys/security/audit/audit_bsm.c Modified: head/sys/nfsserver/nfs_syscalls.c ============================================================================== --- head/sys/nfsserver/nfs_syscalls.c Sun Feb 8 12:40:33 2009 (r188310) +++ head/sys/nfsserver/nfs_syscalls.c Sun Feb 8 14:04:08 2009 (r188311) @@ -137,6 +137,8 @@ nfssvc(struct thread *td, struct nfssvc_ KASSERT(!mtx_owned(&Giant), ("nfssvc(): called with Giant")); + AUDIT_ARG(cmd, uap->flag); + error = priv_check(td, PRIV_NFS_DAEMON); if (error) return (error); Modified: head/sys/security/audit/audit_bsm.c ============================================================================== --- head/sys/security/audit/audit_bsm.c Sun Feb 8 12:40:33 2009 (r188310) +++ head/sys/security/audit/audit_bsm.c Sun Feb 8 14:04:08 2009 (r188311) @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2005 Apple Inc. + * Copyright (c) 1999-2009 Apple Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -639,7 +639,6 @@ kaudit_to_bsm(struct kaudit_record *kar, case AUE_MODLOAD: case AUE_MODUNLOAD: case AUE_MSGSYS: - case AUE_NFS_SVC: case AUE_NTP_ADJTIME: case AUE_PIPE: case AUE_PROFILE: @@ -1017,6 +1016,13 @@ kaudit_to_bsm(struct kaudit_record *kar, } /* FALLTHROUGH */ + case AUE_NFS_SVC: + if (ARG_IS_VALID(kar, ARG_CMD)) { + tok = au_to_arg32(1, "request", ar->ar_arg_cmd); + kau_write(rec, tok); + } + break; + case AUE_UMOUNT: UPATH1_VNODE1_TOKENS; break; From rwatson at FreeBSD.org Sun Feb 8 06:24:36 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Feb 8 06:24:48 2009 Subject: svn commit: r188312 - head/sys/security/audit Message-ID: <200902081424.n18EOaCJ025721@svn.freebsd.org> Author: rwatson Date: Sun Feb 8 14:24:35 2009 New Revision: 188312 URL: http://svn.freebsd.org/changeset/base/188312 Log: Audit AUE_MAC_EXECVE; currently just the standard AUE_EXECVE arguments and not the label. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. MFC after: 1 week Modified: head/sys/security/audit/audit_bsm.c Modified: head/sys/security/audit/audit_bsm.c ============================================================================== --- head/sys/security/audit/audit_bsm.c Sun Feb 8 14:04:08 2009 (r188311) +++ head/sys/security/audit/audit_bsm.c Sun Feb 8 14:24:35 2009 (r188312) @@ -791,6 +791,7 @@ kaudit_to_bsm(struct kaudit_record *kar, /* FALLTHROUGH */ case AUE_EXECVE: + case AUE_MAC_EXECVE: if (ARG_IS_VALID(kar, ARG_ARGV)) { tok = au_to_exec_args(ar->ar_arg_argv, ar->ar_arg_argc); From rwatson at FreeBSD.org Sun Feb 8 06:39:36 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Feb 8 06:39:50 2009 Subject: svn commit: r188313 - head/sys/security/audit Message-ID: <200902081439.n18EdZuN026014@svn.freebsd.org> Author: rwatson Date: Sun Feb 8 14:39:35 2009 New Revision: 188313 URL: http://svn.freebsd.org/changeset/base/188313 Log: Change various routines that are responsible for transforming audit event IDs based on arguments to return au_event_t rather than int. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. MFC after: 1 week Modified: head/sys/security/audit/audit_bsm_klib.c head/sys/security/audit/audit_private.h Modified: head/sys/security/audit/audit_bsm_klib.c ============================================================================== --- head/sys/security/audit/audit_bsm_klib.c Sun Feb 8 14:24:35 2009 (r188312) +++ head/sys/security/audit/audit_bsm_klib.c Sun Feb 8 14:39:35 2009 (r188313) @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Apple Inc. + * Copyright (c) 1999-2009 Apple Inc. * Copyright (c) 2005 Robert N. M. Watson * All rights reserved. * @@ -346,7 +346,7 @@ audit_flags_and_error_to_openevent(int o /* * Convert a MSGCTL command to a specific event. */ -int +au_event_t audit_msgctl_to_event(int cmd) { @@ -369,7 +369,7 @@ audit_msgctl_to_event(int cmd) /* * Convert a SEMCTL command to a specific event. */ -int +au_event_t audit_semctl_to_event(int cmd) { @@ -413,7 +413,7 @@ audit_semctl_to_event(int cmd) /* * Convert a command for the auditon() system call to a audit event. */ -int +au_event_t auditon_command_event(int cmd) { Modified: head/sys/security/audit/audit_private.h ============================================================================== --- head/sys/security/audit/audit_private.h Sun Feb 8 14:24:35 2009 (r188312) +++ head/sys/security/audit/audit_private.h Sun Feb 8 14:39:35 2009 (r188313) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1999-2005 Apple Inc. + * Copyright (c) 1999-2009 Apple Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -306,10 +306,10 @@ void au_evclassmap_insert(au_event_t e au_class_t au_event_class(au_event_t event); au_event_t audit_ctlname_to_sysctlevent(int name[], uint64_t valid_arg); au_event_t audit_flags_and_error_to_openevent(int oflags, int error); -int audit_msgctl_to_event(int cmd); -int audit_semctl_to_event(int cmr); +au_event_t audit_msgctl_to_event(int cmd); +au_event_t audit_semctl_to_event(int cmr); void audit_canon_path(struct thread *td, char *path, char *cpath); -int auditon_command_event(int cmd); +au_event_t auditon_command_event(int cmd); /* * Audit trigger events notify user space of kernel audit conditions From wkoszek at FreeBSD.org Sun Feb 8 06:43:22 2009 From: wkoszek at FreeBSD.org (Wojciech A. Koszek) Date: Sun Feb 8 06:43:35 2009 Subject: svn commit: r188314 - head/sys/conf Message-ID: <200902081443.n18EhK23026117@svn.freebsd.org> Author: wkoszek Date: Sun Feb 8 14:43:20 2009 New Revision: 188314 URL: http://svn.freebsd.org/changeset/base/188314 Log: Fix several filenames for "make clean" target. Modified: head/sys/conf/files Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Sun Feb 8 14:39:35 2009 (r188313) +++ head/sys/conf/files Sun Feb 8 14:43:20 2009 (r188314) @@ -1036,7 +1036,7 @@ iwnfw.fwo optional iwnfw \ dependency "iwn.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} iwn.fw" \ no-implicit-rule \ - clean "iwn.fwo" + clean "iwnfw.fwo" iwn.fw optional iwnfw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/iwn/iwlwifi-4965-4.44.17.fw.uu" \ @@ -1234,7 +1234,7 @@ rt2561fw.fwo optional rt2561fw | ralfw dependency "rt2561.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} rt2561.fw" \ no-implicit-rule \ - clean "rt2561.fwo" + clean "rt2561fw.fwo" rt2561.fw optional rt2561fw | ralfw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/ral/rt2561.fw.uu" \ @@ -1248,7 +1248,7 @@ rt2561sfw.fwo optional rt2561sfw | ral dependency "rt2561s.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} rt2561s.fw" \ no-implicit-rule \ - clean "rt2561s.fwo" + clean "rt2561sfw.fwo" rt2561s.fw optional rt2561sfw | ralfw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/ral/rt2561s.fw.uu" \ @@ -1262,7 +1262,7 @@ rt2661fw.fwo optional rt2661fw | ralfw dependency "rt2661.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} rt2661.fw" \ no-implicit-rule \ - clean "rt2661.fwo" + clean "rt2661fw.fwo" rt2661.fw optional rt2661fw | ralfw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/ral/rt2661.fw.uu" \ @@ -1276,7 +1276,7 @@ rt2860fw.fwo optional rt2860fw | ralfw dependency "rt2860.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} rt2860.fw" \ no-implicit-rule \ - clean "rt2860.fwo" + clean "rt2860fw.fwo" rt2860.fw optional rt2860fw | ralfw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/ral/rt2860.fw.uu" \ @@ -1697,7 +1697,7 @@ wpifw.fwo optional wpifw \ dependency "wpi.fw" \ compile-with "${LD} -b binary -d -warn-common -r -d -o ${.TARGET} wpi.fw" \ no-implicit-rule \ - clean "wpi.fwo" + clean "wpifw.fwo" wpi.fw optional wpifw \ dependency ".PHONY" \ compile-with "uudecode -o ${.TARGET} $S/contrib/dev/wpi/iwlwifi-3945-2.14.4.fw.uu" \ From rwatson at FreeBSD.org Sun Feb 8 07:38:32 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Feb 8 07:38:44 2009 Subject: svn commit: r188315 - head/sys/security/audit Message-ID: <200902081538.n18FcVMN027121@svn.freebsd.org> Author: rwatson Date: Sun Feb 8 15:38:31 2009 New Revision: 188315 URL: http://svn.freebsd.org/changeset/base/188315 Log: Set the lower bound on queue size for an audit pipe to 1 instead of 0, as an audit pipe with a queue length of 0 is less useful. Obtained from: TrustedBSD Project Sponsored by: Apple, Inc. MFC after: 1 week Modified: head/sys/security/audit/audit_pipe.c Modified: head/sys/security/audit/audit_pipe.c ============================================================================== --- head/sys/security/audit/audit_pipe.c Sun Feb 8 14:43:20 2009 (r188314) +++ head/sys/security/audit/audit_pipe.c Sun Feb 8 15:38:31 2009 (r188315) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Robert N. M. Watson - * Copyright (c) 2008 Apple, Inc. + * Copyright (c) 2008-2009 Apple, Inc. * All rights reserved. * * This software was developed by Robert Watson for the TrustedBSD Project. @@ -76,7 +76,7 @@ static MALLOC_DEFINE(M_AUDIT_PIPE_PRESEL * Audit pipe buffer parameters. */ #define AUDIT_PIPE_QLIMIT_DEFAULT (128) -#define AUDIT_PIPE_QLIMIT_MIN (0) +#define AUDIT_PIPE_QLIMIT_MIN (1) #define AUDIT_PIPE_QLIMIT_MAX (1024) /* From sam at freebsd.org Sun Feb 8 08:43:47 2009 From: sam at freebsd.org (Sam Leffler) Date: Sun Feb 8 08:43:53 2009 Subject: svn commit: r188309 - head/sys/conf In-Reply-To: <200902081233.n18CX5n5023301@svn.freebsd.org> References: <200902081233.n18CX5n5023301@svn.freebsd.org> Message-ID: <498F0BC2.2050302@freebsd.org> Wojciech A. Koszek wrote: > Author: wkoszek > Date: Sun Feb 8 12:33:05 2009 > New Revision: 188309 > URL: http://svn.freebsd.org/changeset/base/188309 > > Log: > Further NOTES cleanup -- following drivers didn't survive TTY-ng > and aren't included in NOTES anyway: cy(4), rc(4), rp(4). > > si(4) doesn't belong to global NOTES. > > I'm not sure I agree w/ yanking drivers entirely because they don't work. If they are commented out w/ a note why this will help people find them and possibly resuscitate them. If they are well and truly gone from then tree then sure--but as of today they are still in svn. Sam From ume at FreeBSD.org Sun Feb 8 08:58:05 2009 From: ume at FreeBSD.org (Hajimu UMEMOTO) Date: Sun Feb 8 08:58:18 2009 Subject: svn commit: r188316 - head/lib/libc/net Message-ID: <200902081658.n18Gw5hN028634@svn.freebsd.org> Author: ume Date: Sun Feb 8 16:58:05 2009 New Revision: 188316 URL: http://svn.freebsd.org/changeset/base/188316 Log: Shutup warning for DNAME RR. PR: bin/127591 Submitted by: "Eugene M. Kim" <20080111.freebsd.org__at__ab.ote.we.lv> MFC after: 1 week Modified: head/lib/libc/net/getaddrinfo.c head/lib/libc/net/gethostbydns.c Modified: head/lib/libc/net/getaddrinfo.c ============================================================================== --- head/lib/libc/net/getaddrinfo.c Sun Feb 8 15:38:31 2009 (r188315) +++ head/lib/libc/net/getaddrinfo.c Sun Feb 8 16:58:05 2009 (r188316) @@ -1863,7 +1863,8 @@ getanswer(const querybuf *answer, int an } } else if (type != qtype) { #ifdef DEBUG - if (type != T_KEY && type != T_SIG) + if (type != T_KEY && type != T_SIG && + type != ns_t_dname) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype), Modified: head/lib/libc/net/gethostbydns.c ============================================================================== --- head/lib/libc/net/gethostbydns.c Sun Feb 8 15:38:31 2009 (r188315) +++ head/lib/libc/net/gethostbydns.c Sun Feb 8 16:58:05 2009 (r188316) @@ -294,7 +294,7 @@ gethostanswer(const querybuf *answer, in continue; } if (type != qtype) { - if (type != T_SIG) + if (type != T_SIG && type != ns_t_dname) syslog(LOG_NOTICE|LOG_AUTH, "gethostby*.gethostanswer: asked for \"%s %s %s\", got type \"%s\"", qname, p_class(C_IN), p_type(qtype), From kib at FreeBSD.org Sun Feb 8 11:18:34 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 11:18:39 2009 Subject: svn commit: r188318 - head/sys/fs/tmpfs Message-ID: <200902081918.n18JIXvD031637@svn.freebsd.org> Author: kib Date: Sun Feb 8 19:18:33 2009 New Revision: 188318 URL: http://svn.freebsd.org/changeset/base/188318 Log: Lookup up the directory entry for the tmpfs node that are deleted by both node pointer and name component. This does the right thing for hardlinks to the same node in the same directory. Submitted by: Yoshihiro Ota PR: kern/131356 MFC after: 2 weeks Modified: head/sys/fs/tmpfs/tmpfs.h head/sys/fs/tmpfs/tmpfs_subr.c head/sys/fs/tmpfs/tmpfs_vnops.c Modified: head/sys/fs/tmpfs/tmpfs.h ============================================================================== --- head/sys/fs/tmpfs/tmpfs.h Sun Feb 8 17:49:32 2009 (r188317) +++ head/sys/fs/tmpfs/tmpfs.h Sun Feb 8 19:18:33 2009 (r188318) @@ -408,9 +408,8 @@ int tmpfs_alloc_file(struct vnode *, str void tmpfs_dir_attach(struct vnode *, struct tmpfs_dirent *); void tmpfs_dir_detach(struct vnode *, struct tmpfs_dirent *); struct tmpfs_dirent * tmpfs_dir_lookup(struct tmpfs_node *node, + struct tmpfs_node *f, struct componentname *cnp); -struct tmpfs_dirent *tmpfs_dir_search(struct tmpfs_node *node, - struct tmpfs_node *f); int tmpfs_dir_getdotdent(struct tmpfs_node *, struct uio *); int tmpfs_dir_getdotdotdent(struct tmpfs_node *, struct uio *); struct tmpfs_dirent * tmpfs_dir_lookupbycookie(struct tmpfs_node *, off_t); Modified: head/sys/fs/tmpfs/tmpfs_subr.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_subr.c Sun Feb 8 17:49:32 2009 (r188317) +++ head/sys/fs/tmpfs/tmpfs_subr.c Sun Feb 8 19:18:33 2009 (r188318) @@ -571,7 +571,8 @@ tmpfs_dir_detach(struct vnode *vp, struc * Returns a pointer to the entry when found, otherwise NULL. */ struct tmpfs_dirent * -tmpfs_dir_lookup(struct tmpfs_node *node, struct componentname *cnp) +tmpfs_dir_lookup(struct tmpfs_node *node, struct tmpfs_node *f, + struct componentname *cnp) { boolean_t found; struct tmpfs_dirent *de; @@ -583,6 +584,8 @@ tmpfs_dir_lookup(struct tmpfs_node *node found = 0; TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { + if (f != NULL && de->td_node != f) + continue; MPASS(cnp->cn_namelen < 0xffff); if (de->td_namelen == (uint16_t)cnp->cn_namelen && bcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { @@ -595,20 +598,6 @@ tmpfs_dir_lookup(struct tmpfs_node *node return found ? de : NULL; } -struct tmpfs_dirent * -tmpfs_dir_search(struct tmpfs_node *node, struct tmpfs_node *f) -{ - struct tmpfs_dirent *de; - - TMPFS_VALIDATE_DIR(node); - node->tn_status |= TMPFS_NODE_ACCESSED; - TAILQ_FOREACH(de, &node->tn_dir.tn_dirhead, td_entries) { - if (de->td_node == f) - return (de); - } - return (NULL); -} - /* --------------------------------------------------------------------- */ /* Modified: head/sys/fs/tmpfs/tmpfs_vnops.c ============================================================================== --- head/sys/fs/tmpfs/tmpfs_vnops.c Sun Feb 8 17:49:32 2009 (r188317) +++ head/sys/fs/tmpfs/tmpfs_vnops.c Sun Feb 8 19:18:33 2009 (r188318) @@ -104,7 +104,7 @@ tmpfs_lookup(struct vop_cachedlookup_arg *vpp = dvp; error = 0; } else { - de = tmpfs_dir_lookup(dnode, cnp); + de = tmpfs_dir_lookup(dnode, NULL, cnp); if (de == NULL) { /* The entry was not found in the directory. * This is OK if we are creating or renaming an @@ -772,7 +772,7 @@ tmpfs_remove(struct vop_remove_args *v) dnode = VP_TO_TMPFS_DIR(dvp); node = VP_TO_TMPFS_NODE(vp); tmp = VFS_TO_TMPFS(vp->v_mount); - de = tmpfs_dir_search(dnode, node); + de = tmpfs_dir_lookup(dnode, node, v->a_cnp); MPASS(de != NULL); /* Files marked as immutable or append-only cannot be deleted. */ @@ -919,7 +919,7 @@ tmpfs_rename(struct vop_rename_args *v) } fdnode = VP_TO_TMPFS_DIR(fdvp); fnode = VP_TO_TMPFS_NODE(fvp); - de = tmpfs_dir_search(fdnode, fnode); + de = tmpfs_dir_lookup(fdnode, fnode, fcnp); /* Avoid manipulating '.' and '..' entries. */ if (de == NULL) { @@ -1031,7 +1031,7 @@ tmpfs_rename(struct vop_rename_args *v) * from the target directory. */ if (tvp != NULL) { /* Remove the old entry from the target directory. */ - de = tmpfs_dir_search(tdnode, tnode); + de = tmpfs_dir_lookup(tdnode, tnode, tcnp); tmpfs_dir_detach(tdvp, de); /* Free the directory entry we just deleted. Note that the @@ -1119,7 +1119,7 @@ tmpfs_rmdir(struct vop_rmdir_args *v) /* Get the directory entry associated with node (vp). This was * filled by tmpfs_lookup while looking up the entry. */ - de = tmpfs_dir_search(dnode, node); + de = tmpfs_dir_lookup(dnode, node, v->a_cnp); MPASS(TMPFS_DIRENT_MATCHES(de, v->a_cnp->cn_nameptr, v->a_cnp->cn_namelen)); From kib at FreeBSD.org Sun Feb 8 11:37:03 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 11:37:09 2009 Subject: svn commit: r188319 - head/sys/vm Message-ID: <200902081937.n18Jb2gq032004@svn.freebsd.org> Author: kib Date: Sun Feb 8 19:37:01 2009 New Revision: 188319 URL: http://svn.freebsd.org/changeset/base/188319 Log: Style. Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Feb 8 19:18:33 2009 (r188318) +++ head/sys/vm/vm_fault.c Sun Feb 8 19:37:01 2009 (r188319) @@ -135,6 +135,7 @@ struct faultstate { static inline void release_page(struct faultstate *fs) { + vm_page_wakeup(fs->m); vm_page_lock_queues(); vm_page_deactivate(fs->m); @@ -145,6 +146,7 @@ release_page(struct faultstate *fs) static inline void unlock_map(struct faultstate *fs) { + if (fs->lookup_still_valid) { vm_map_lookup_done(fs->map, fs->entry); fs->lookup_still_valid = FALSE; From kib at FreeBSD.org Sun Feb 8 11:41:09 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 11:41:20 2009 Subject: svn commit: r188320 - head/sys/vm Message-ID: <200902081941.n18Jf834032117@svn.freebsd.org> Author: kib Date: Sun Feb 8 19:41:08 2009 New Revision: 188320 URL: http://svn.freebsd.org/changeset/base/188320 Log: Do not leak the MAP_ENTRY_IN_TRANSITION flag when copying map entry on fork. Otherwise, copied entry cannot be removed in the child map. Reviewed by: tegge MFC after: 2 weeks Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 19:37:01 2009 (r188319) +++ head/sys/vm/vm_map.c Sun Feb 8 19:41:08 2009 (r188320) @@ -2738,7 +2738,8 @@ vmspace_fork(struct vmspace *vm1) */ new_entry = vm_map_entry_create(new_map); *new_entry = *old_entry; - new_entry->eflags &= ~MAP_ENTRY_USER_WIRED; + new_entry->eflags &= ~(MAP_ENTRY_USER_WIRED | + MAP_ENTRY_IN_TRANSITION); new_entry->wired_count = 0; /* @@ -2764,7 +2765,8 @@ vmspace_fork(struct vmspace *vm1) */ new_entry = vm_map_entry_create(new_map); *new_entry = *old_entry; - new_entry->eflags &= ~MAP_ENTRY_USER_WIRED; + new_entry->eflags &= ~(MAP_ENTRY_USER_WIRED | + MAP_ENTRY_IN_TRANSITION); new_entry->wired_count = 0; new_entry->object.vm_object = NULL; vm_map_entry_link(new_map, new_map->header.prev, From kib at FreeBSD.org Sun Feb 8 11:44:51 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 11:45:02 2009 Subject: svn commit: r188321 - head/sys/vm Message-ID: <200902081944.n18Jiojs032224@svn.freebsd.org> Author: kib Date: Sun Feb 8 19:44:50 2009 New Revision: 188321 URL: http://svn.freebsd.org/changeset/base/188321 Log: Assert that vnode is exclusively locked when its vm object is resized. Reviewed by: tegge Modified: head/sys/vm/vnode_pager.c Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Sun Feb 8 19:41:08 2009 (r188320) +++ head/sys/vm/vnode_pager.c Sun Feb 8 19:44:50 2009 (r188321) @@ -367,6 +367,7 @@ vnode_pager_setsize(vp, nsize) if ((object = vp->v_object) == NULL) return; + ASSERT_VOP_ELOCKED(vp, "vnode_pager_setsize and not locked vnode"); VM_OBJECT_LOCK(object); if (nsize == object->un_pager.vnp.vnp_size) { /* From kib at FreeBSD.org Sun Feb 8 11:55:04 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 11:55:10 2009 Subject: svn commit: r188323 - head/sys/vm Message-ID: <200902081955.n18Jt3Po032530@svn.freebsd.org> Author: kib Date: Sun Feb 8 19:55:03 2009 New Revision: 188323 URL: http://svn.freebsd.org/changeset/base/188323 Log: Lock the new map in vmspace_fork(). The newly allocated map should not be accessible outside vmspace_fork() yet, but locking it would satisfy the protocol of the vm_map_entry_link() and other functions called from vmspace_fork(). Use trylock that is supposedly cannot fail, to silence WITNESS warning of the nested acquisition of the sx lock with the same name. Suggested and reviewed by: tegge Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 19:53:37 2009 (r188322) +++ head/sys/vm/vm_map.c Sun Feb 8 19:55:03 2009 (r188323) @@ -2679,6 +2679,7 @@ vmspace_fork(struct vmspace *vm1) vm_map_entry_t old_entry; vm_map_entry_t new_entry; vm_object_t object; + int locked; vm_map_lock(old_map); @@ -2689,6 +2690,8 @@ vmspace_fork(struct vmspace *vm1) vm2->vm_daddr = vm1->vm_daddr; vm2->vm_maxsaddr = vm1->vm_maxsaddr; new_map = &vm2->vm_map; /* XXX */ + locked = vm_map_trylock(new_map); /* trylock to silence WITNESS */ + KASSERT(locked, ("vmspace_fork: lock failed")); new_map->timestamp = 1; old_entry = old_map->header.next; @@ -2780,6 +2783,8 @@ vmspace_fork(struct vmspace *vm1) } unlock_and_return: vm_map_unlock(old_map); + if (vm2 != NULL) + vm_map_unlock(new_map); return (vm2); } From kib at FreeBSD.org Sun Feb 8 12:00:36 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 12:00:42 2009 Subject: svn commit: r188325 - head/sys/vm Message-ID: <200902082000.n18K0XQl032762@svn.freebsd.org> Author: kib Date: Sun Feb 8 20:00:33 2009 New Revision: 188325 URL: http://svn.freebsd.org/changeset/base/188325 Log: Add the comments to vm_map_simplify_entry() and vmspace_fork(), describing why several calls to vm_deallocate_object() with locked map do not result in the acquisition of the vnode lock after map lock. Suggested and reviewed by: tegge Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 19:55:13 2009 (r188324) +++ head/sys/vm/vm_map.c Sun Feb 8 20:00:33 2009 (r188325) @@ -1350,6 +1350,16 @@ vm_map_simplify_entry(vm_map_t map, vm_m entry->offset = prev->offset; if (entry->prev != &map->header) vm_map_entry_resize_free(map, entry->prev); + + /* + * If the backing object is the vnode object, + * vm_object_deallocate() results in a call to + * vrele(). Because the reference to the + * object is not last, vrele() does not lock + * the vnode, and map lock can be kept without + * causing vnode lock to be taken after the + * map lock. + */ if (prev->object.vm_object) vm_object_deallocate(prev->object.vm_object); vm_map_entry_dispose(map, prev); @@ -1371,6 +1381,10 @@ vm_map_simplify_entry(vm_map_t map, vm_m vm_map_entry_unlink(map, next); entry->end = next->end; vm_map_entry_resize_free(map, entry); + + /* + * See comment above. + */ if (next->object.vm_object) vm_object_deallocate(next->object.vm_object); vm_map_entry_dispose(map, next); @@ -2729,6 +2743,12 @@ vmspace_fork(struct vmspace *vm1) /* Transfer the second reference too. */ vm_object_reference( old_entry->object.vm_object); + + /* + * As in vm_map_simplify_entry(), the + * vnode lock may not be acquired in + * this call to vm_object_deallocate(). + */ vm_object_deallocate(object); object = old_entry->object.vm_object; } From sam at FreeBSD.org Sun Feb 8 12:02:59 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Sun Feb 8 12:03:04 2009 Subject: svn commit: r188327 - head/tools/tools/ath/athstats Message-ID: <200902082002.n18K2wwM032871@svn.freebsd.org> Author: sam Date: Sun Feb 8 20:02:58 2009 New Revision: 188327 URL: http://svn.freebsd.org/changeset/base/188327 Log: o use humanize_number to print totals o shrink some fields now that we don't have to worry about overflow Modified: head/tools/tools/ath/athstats/Makefile head/tools/tools/ath/athstats/athstats.c head/tools/tools/ath/athstats/statfoo.c Modified: head/tools/tools/ath/athstats/Makefile ============================================================================== --- head/tools/tools/ath/athstats/Makefile Sun Feb 8 20:00:36 2009 (r188326) +++ head/tools/tools/ath/athstats/Makefile Sun Feb 8 20:02:58 2009 (r188327) @@ -4,6 +4,9 @@ PROG= athstats SRCS= main.c statfoo.c athstats.c +DPADD= ${LIBUTIL} +LDADD= -lutil + .include SRCDIR= ${.CURDIR}/../../../.. Modified: head/tools/tools/ath/athstats/athstats.c ============================================================================== --- head/tools/tools/ath/athstats/athstats.c Sun Feb 8 20:00:36 2009 (r188326) +++ head/tools/tools/ath/athstats/athstats.c Sun Feb 8 20:02:58 2009 (r188327) @@ -46,6 +46,7 @@ #include #include #include +#include #include "ah.h" #include "ah_desc.h" @@ -67,15 +68,15 @@ static const struct fmt athstats[] = { #define S_INPUT 0 - { 8, "input", "input", "data frames received" }, + { 7, "input", "input", "data frames received" }, #define S_OUTPUT AFTER(S_INPUT) - { 8, "output", "output", "data frames transmit" }, + { 7, "output", "output", "data frames transmit" }, #define S_TX_ALTRATE AFTER(S_OUTPUT) { 7, "altrate", "altrate", "tx frames with an alternate rate" }, #define S_TX_SHORTRETRY AFTER(S_TX_ALTRATE) - { 7, "short", "short", "short on-chip tx retries" }, + { 6, "short", "short", "short on-chip tx retries" }, #define S_TX_LONGRETRY AFTER(S_TX_SHORTRETRY) - { 7, "long", "long", "long on-chip tx retries" }, + { 6, "long", "long", "long on-chip tx retries" }, #define S_TX_XRETRIES AFTER(S_TX_LONGRETRY) { 6, "xretry", "xretry", "tx failed 'cuz too many retries" }, #define S_MIB AFTER(S_TX_XRETRIES) @@ -201,7 +202,7 @@ static const struct fmt athstats[] = { #define S_BE_NOMBUF AFTER(S_RX_PHY_CCK_RESTART) { 4, "benombuf", "benombuf", "beacon setup failed 'cuz no mbuf" }, #define S_BE_XMIT AFTER(S_BE_NOMBUF) - { 7, "bexmit", "bexmit", "beacons transmitted" }, + { 6, "bexmit", "bexmit", "beacons transmitted" }, #define S_PER_CAL AFTER(S_BE_XMIT) { 4, "pcal", "pcal", "periodic calibrations" }, #define S_PER_CALFAIL AFTER(S_PER_CAL) @@ -210,13 +211,13 @@ static const struct fmt athstats[] = { { 4, "prfga", "prfga", "rfgain value change" }, #if ATH_SUPPORT_TDMA #define S_TDMA_UPDATE AFTER(S_PER_RFGAIN) - { 5, "tdmau", "tdmau", "TDMA slot timing updates" }, + { 6, "tdmau", "tdmau", "TDMA slot timing updates" }, #define S_TDMA_TIMERS AFTER(S_TDMA_UPDATE) - { 5, "tdmab", "tdmab", "TDMA slot update set beacon timers" }, + { 6, "tdmab", "tdmab", "TDMA slot update set beacon timers" }, #define S_TDMA_TSF AFTER(S_TDMA_TIMERS) - { 5, "tdmat", "tdmat", "TDMA slot update set TSF" }, + { 6, "tdmat", "tdmat", "TDMA slot update set TSF" }, #define S_TDMA_TSFADJ AFTER(S_TDMA_TSF) - { 8, "tdmadj", "tdmadj", "TDMA slot adjust (usecs, smoothed)" }, + { 6, "tdmadj", "tdmadj", "TDMA slot adjust (usecs, smoothed)" }, #define S_TDMA_ACK AFTER(S_TDMA_TSFADJ) { 5, "tdmack", "tdmack", "TDMA tx failed 'cuz ACK required" }, #define S_RATE_CALLS AFTER(S_TDMA_ACK) @@ -306,9 +307,9 @@ static const struct fmt athstats[] = { #define S_ANI_STEPDOWN AFTER(S_ANI_STEPUP) { 5, "step-","STEP-", "ANI decreased first step level" }, #define S_ANI_OFDMERRS AFTER(S_ANI_STEPDOWN) - { 8, "ofdm", "OFDM", "cumulative OFDM phy error count" }, + { 7, "ofdm", "OFDM", "cumulative OFDM phy error count" }, #define S_ANI_CCKERRS AFTER(S_ANI_OFDMERRS) - { 8, "cck", "CCK", "cumulative CCK phy error count" }, + { 7, "cck", "CCK", "cumulative CCK phy error count" }, #define S_ANI_RESET AFTER(S_ANI_CCKERRS) { 5, "reset","RESET", "ANI parameters zero'd for non-STA operation" }, #define S_ANI_LZERO AFTER(S_ANI_RESET) @@ -316,15 +317,15 @@ static const struct fmt athstats[] = { #define S_ANI_LNEG AFTER(S_ANI_LZERO) { 5, "lneg", "LNEG", "ANI calculated listen time < 0" }, #define S_MIB_ACKBAD AFTER(S_ANI_LNEG) - { 5, "ackbad","ACKBAD", "missing ACK's" }, + { 7, "ackbad","ACKBAD", "missing ACK's" }, #define S_MIB_RTSBAD AFTER(S_MIB_ACKBAD) - { 5, "rtsbad","RTSBAD", "RTS without CTS" }, + { 7, "rtsbad","RTSBAD", "RTS without CTS" }, #define S_MIB_RTSGOOD AFTER(S_MIB_RTSBAD) - { 5, "rtsgood","RTSGOOD", "successful RTS" }, + { 7, "rtsgood","RTSGOOD", "successful RTS" }, #define S_MIB_FCSBAD AFTER(S_MIB_RTSGOOD) - { 5, "fcsbad","FCSBAD", "bad FCS" }, + { 7, "fcsbad","FCSBAD", "bad FCS" }, #define S_MIB_BEACONS AFTER(S_MIB_FCSBAD) - { 5, "beacons","beacons", "beacons received" }, + { 7, "beacons","beacons", "beacons received" }, #define S_NODE_AVGBRSSI AFTER(S_MIB_BEACONS) { 3, "avgbrssi","BSI", "average rssi (beacons only)" }, #define S_NODE_AVGRSSI AFTER(S_NODE_AVGBRSSI) @@ -335,37 +336,37 @@ static const struct fmt athstats[] = { #else #define S_ANT_TX0 AFTER(S_ANT_TXSWITCH) #endif /* ATH_SUPPORT_ANI */ - { 8, "tx0", "ant0(tx)", "frames tx on antenna 0" }, + { 7, "tx0", "ant0(tx)", "frames tx on antenna 0" }, #define S_ANT_TX1 AFTER(S_ANT_TX0) - { 8, "tx1", "ant1(tx)", "frames tx on antenna 1" }, + { 7, "tx1", "ant1(tx)", "frames tx on antenna 1" }, #define S_ANT_TX2 AFTER(S_ANT_TX1) - { 8, "tx2", "ant2(tx)", "frames tx on antenna 2" }, + { 7, "tx2", "ant2(tx)", "frames tx on antenna 2" }, #define S_ANT_TX3 AFTER(S_ANT_TX2) - { 8, "tx3", "ant3(tx)", "frames tx on antenna 3" }, + { 7, "tx3", "ant3(tx)", "frames tx on antenna 3" }, #define S_ANT_TX4 AFTER(S_ANT_TX3) - { 8, "tx4", "ant4(tx)", "frames tx on antenna 4" }, + { 7, "tx4", "ant4(tx)", "frames tx on antenna 4" }, #define S_ANT_TX5 AFTER(S_ANT_TX4) - { 8, "tx5", "ant5(tx)", "frames tx on antenna 5" }, + { 7, "tx5", "ant5(tx)", "frames tx on antenna 5" }, #define S_ANT_TX6 AFTER(S_ANT_TX5) - { 8, "tx6", "ant6(tx)", "frames tx on antenna 6" }, + { 7, "tx6", "ant6(tx)", "frames tx on antenna 6" }, #define S_ANT_TX7 AFTER(S_ANT_TX6) - { 8, "tx7", "ant7(tx)", "frames tx on antenna 7" }, + { 7, "tx7", "ant7(tx)", "frames tx on antenna 7" }, #define S_ANT_RX0 AFTER(S_ANT_TX7) - { 8, "rx0", "ant0(rx)", "frames rx on antenna 0" }, + { 7, "rx0", "ant0(rx)", "frames rx on antenna 0" }, #define S_ANT_RX1 AFTER(S_ANT_RX0) - { 8, "rx1", "ant1(rx)", "frames rx on antenna 1" }, + { 7, "rx1", "ant1(rx)", "frames rx on antenna 1" }, #define S_ANT_RX2 AFTER(S_ANT_RX1) - { 8, "rx2", "ant2(rx)", "frames rx on antenna 2" }, + { 7, "rx2", "ant2(rx)", "frames rx on antenna 2" }, #define S_ANT_RX3 AFTER(S_ANT_RX2) - { 8, "rx3", "ant3(rx)", "frames rx on antenna 3" }, + { 7, "rx3", "ant3(rx)", "frames rx on antenna 3" }, #define S_ANT_RX4 AFTER(S_ANT_RX3) - { 8, "rx4", "ant4(rx)", "frames rx on antenna 4" }, + { 7, "rx4", "ant4(rx)", "frames rx on antenna 4" }, #define S_ANT_RX5 AFTER(S_ANT_RX4) - { 8, "rx5", "ant5(rx)", "frames rx on antenna 5" }, + { 7, "rx5", "ant5(rx)", "frames rx on antenna 5" }, #define S_ANT_RX6 AFTER(S_ANT_RX5) - { 8, "rx6", "ant6(rx)", "frames rx on antenna 6" }, + { 7, "rx6", "ant6(rx)", "frames rx on antenna 6" }, #define S_ANT_RX7 AFTER(S_ANT_RX6) - { 8, "rx7", "ant7(rx)", "frames rx on antenna 7" }, + { 7, "rx7", "ant7(rx)", "frames rx on antenna 7" }, #define S_TX_SIGNAL AFTER(S_ANT_RX7) { 4, "asignal", "asig", "signal of last ack (dBm)" }, #define S_RX_SIGNAL AFTER(S_TX_SIGNAL) @@ -710,32 +711,38 @@ ath_get_curstat(struct statfoo *sf, int #undef STAT } +int +hnprintf(char *b, size_t bs, const char *fmt, int64_t v) +{ + humanize_number(b, bs, v, "", HN_AUTOSCALE, HN_NOSPACE); +} + static int ath_get_totstat(struct statfoo *sf, int s, char b[], size_t bs) { struct athstatfoo_p *wf = (struct athstatfoo_p *) sf; #define STAT(x) \ - snprintf(b, bs, "%u", wf->total.ath.ast_##x); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ath.ast_##x); return 1 #define PHY(x) \ - snprintf(b, bs, "%u", wf->total.ath.ast_rx_phy[x]); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ath.ast_rx_phy[x]); return 1 #define ANI(x) \ - snprintf(b, bs, "%u", wf->total.ani_state.x); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ani_state.x); return 1 #define ANISTAT(x) \ - snprintf(b, bs, "%u", wf->total.ani_stats.ast_ani_##x); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ani_stats.ast_ani_##x); return 1 #define MIBSTAT(x) \ - snprintf(b, bs, "%u", wf->total.ani_stats.ast_mibstats.x); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ani_stats.ast_mibstats.x); return 1 #define TXANT(x) \ - snprintf(b, bs, "%u", wf->total.ath.ast_ant_tx[x]); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ath.ast_ant_tx[x]); return 1 #define RXANT(x) \ - snprintf(b, bs, "%u", wf->total.ath.ast_ant_rx[x]); return 1 + hnprintf(b, bs, "%u", (int64_t) wf->total.ath.ast_ant_rx[x]); return 1 switch (s) { case S_INPUT: - snprintf(b, bs, "%lu", + hnprintf(b, bs, "%lu", wf->total.ath.ast_rx_packets - wf->total.ath.ast_rx_mgt); return 1; case S_OUTPUT: - snprintf(b, bs, "%lu", wf->total.ath.ast_tx_packets); + hnprintf(b, bs, "%lu", wf->total.ath.ast_tx_packets); return 1; case S_RATE: snprintrate(b, bs, wf->total.ath.ast_tx_rate); Modified: head/tools/tools/ath/athstats/statfoo.c ============================================================================== --- head/tools/tools/ath/athstats/statfoo.c Sun Feb 8 20:00:36 2009 (r188326) +++ head/tools/tools/ath/athstats/statfoo.c Sun Feb 8 20:02:58 2009 (r188327) @@ -109,7 +109,7 @@ statfoo_print_current(struct statfoo *sf for (cp = sf->fmts; *cp != '\0'; cp++) { if (*cp & 0x80) { const struct fmt *f = &sf->stats[*cp &~ 0x80]; - if (sf->get_curstat(sf, *cp &~ 0x80, buf, sizeof(buf))) + if (sf->get_curstat(sf, *cp &~ 0x80, buf, f->width)) fprintf(fd, "%*s", f->width, buf); } else putc(*cp, fd); @@ -126,7 +126,7 @@ statfoo_print_total(struct statfoo *sf, for (cp = sf->fmts; *cp != '\0'; cp++) { if (*cp & 0x80) { const struct fmt *f = &sf->stats[*cp &~ 0x80]; - if (sf->get_totstat(sf, *cp &~ 0x80, buf, sizeof(buf))) + if (sf->get_totstat(sf, *cp &~ 0x80, buf, f->width)) fprintf(fd, "%*s", f->width, buf); } else putc(*cp, fd); From marcel at FreeBSD.org Sun Feb 8 12:15:09 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Sun Feb 8 12:15:15 2009 Subject: svn commit: r188329 - head/sys/geom/part Message-ID: <200902082015.n18KF8WA033177@svn.freebsd.org> Author: marcel Date: Sun Feb 8 20:15:08 2009 New Revision: 188329 URL: http://svn.freebsd.org/changeset/base/188329 Log: o Add the "PART::scheme" attribute that returns the name of the underlying partitioning scheme. o Put the start and end of the partition in the XML configuration. The start and end are the LBAs of the first and last sector (resp.) of the partition. They are currently identical to the offset and size attributes, which describe the partition as an offset and size in bytes, but may not in the future. The start and end will be used for the logical partition boundaries and may include metadata. The offset and size will always represent the useful storage space within the partition. Typically these two notions are the same, but for logical partitions in an extended partition, the EBR is more naturally treated as being part of the partition. Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Sun Feb 8 20:07:50 2009 (r188328) +++ head/sys/geom/part/g_part.c Sun Feb 8 20:15:08 2009 (r188329) @@ -1579,6 +1579,10 @@ g_part_dumpconf(struct sbuf *sb, const c entry = pp->private; if (entry == NULL) return; + sbuf_printf(sb, "%s%ju\n", indent, + (uintmax_t)entry->gpe_start); + sbuf_printf(sb, "%s%ju\n", indent, + (uintmax_t)entry->gpe_end); sbuf_printf(sb, "%s%u\n", indent, entry->gpe_index); sbuf_printf(sb, "%s%s\n", indent, @@ -1687,6 +1691,9 @@ g_part_start(struct bio *bp) if (g_handleattr_int(bp, "PART::offset", table->gpt_offset + entry->gpe_start)) return; + if (g_handleattr_str(bp, "PART::scheme", + table->gpt_scheme->name)) + return; if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) { /* * Check that the partition is suitable for kernel From marcel at FreeBSD.org Sun Feb 8 12:19:20 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Sun Feb 8 12:19:27 2009 Subject: svn commit: r188330 - head/sbin/geom/class/part Message-ID: <200902082019.n18KJJFk033280@svn.freebsd.org> Author: marcel Date: Sun Feb 8 20:19:19 2009 New Revision: 188330 URL: http://svn.freebsd.org/changeset/base/188330 Log: Prefer the start and end attributes over the offset and size attributes. The start and end more accurately describe the space taken by a partition. The offset and size are used to describe the effective (usable) storage of that partition. Modified: head/sbin/geom/class/part/geom_part.c Modified: head/sbin/geom/class/part/geom_part.c ============================================================================== --- head/sbin/geom/class/part/geom_part.c Sun Feb 8 20:15:08 2009 (r188329) +++ head/sbin/geom/class/part/geom_part.c Sun Feb 8 20:19:19 2009 (r188330) @@ -187,17 +187,23 @@ static struct gprovider * find_provider(struct ggeom *gp, unsigned long long minsector) { struct gprovider *pp, *bestpp; - unsigned long long offset; + const char *s; unsigned long long sector, bestsector; bestpp = NULL; LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { - offset = atoll(find_provcfg(pp, "offset")); - sector = offset / pp->lg_sectorsize; + s = find_provcfg(pp, "start"); + if (s == NULL) { + s = find_provcfg(pp, "offset"); + sector = atoll(s) / pp->lg_sectorsize; + } else + sector = atoll(s); + if (sector < minsector) continue; if (bestpp != NULL && sector >= bestsector) continue; + bestpp = pp; bestsector = sector; } @@ -240,7 +246,7 @@ gpart_show_geom(struct ggeom *gp, const struct gprovider *pp; const char *s, *scheme; unsigned long long first, last, sector, end; - unsigned long long offset, length, secsz; + unsigned long long length, secsz; int idx, wblocks, wname; scheme = find_geomcfg(gp, "scheme"); @@ -258,14 +264,24 @@ gpart_show_geom(struct ggeom *gp, const scheme, fmtsize(pp->lg_mediasize)); while ((pp = find_provider(gp, first)) != NULL) { - s = find_provcfg(pp, "offset"); - offset = atoll(s); - sector = offset / secsz; - s = find_provcfg(pp, "length"); - length = atoll(s); + s = find_provcfg(pp, "start"); + if (s == NULL) { + s = find_provcfg(pp, "offset"); + sector = atoll(s) / secsz; + } else + sector = atoll(s); + + s = find_provcfg(pp, "end"); + if (s == NULL) { + s = find_provcfg(pp, "length"); + length = atoll(s) / secsz; + end = sector + length - 1; + } else { + end = atoll(s); + length = end - sector + 1; + } s = find_provcfg(pp, "index"); idx = atoi(s); - end = sector + length / secsz; if (first < sector) { printf(" %*llu %*llu %*s - free - (%s)\n", wblocks, first, wblocks, sector - first, @@ -273,16 +289,17 @@ gpart_show_geom(struct ggeom *gp, const fmtsize((sector - first) * secsz)); } printf(" %*llu %*llu %*d %s %s (%s)\n", - wblocks, sector, wblocks, end - sector, + wblocks, sector, wblocks, length, wname, idx, find_provcfg(pp, element), fmtattrib(pp), fmtsize(pp->lg_mediasize)); - first = end; + first = end + 1; } if (first <= last) { + length = last - first + 1; printf(" %*llu %*llu %*s - free - (%s)\n", - wblocks, first, wblocks, last - first + 1, + wblocks, first, wblocks, length, wname, "", - fmtsize((last - first + 1) * secsz)); + fmtsize(length * secsz)); } printf("\n"); } From kib at FreeBSD.org Sun Feb 8 12:23:54 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 12:24:13 2009 Subject: svn commit: r188331 - head/sys/vm Message-ID: <200902082023.n18KNkdV033402@svn.freebsd.org> Author: kib Date: Sun Feb 8 20:23:46 2009 New Revision: 188331 URL: http://svn.freebsd.org/changeset/base/188331 Log: Do not sleep for vnode lock while holding map lock in vm_fault. Try to acquire vnode lock for OBJT_VNODE object after map lock is dropped. Because we have the busy page(s) in the object, sleeping there would result in deadlock with vnode resize. Try to get lock without sleeping, and, if the attempt failed, drop the state, lock the vnode, and restart the fault handler from the start with already locked vnode. Because the vnode_pager_lock() function is inlined in vm_fault(), axe it. Based on suggestion by: alc Reviewed by: tegge, alc Tested by: pho Modified: head/sys/vm/vm_fault.c head/sys/vm/vnode_pager.c head/sys/vm/vnode_pager.h Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Feb 8 20:19:19 2009 (r188330) +++ head/sys/vm/vm_fault.c Sun Feb 8 20:23:46 2009 (r188331) @@ -130,6 +130,7 @@ struct faultstate { vm_map_entry_t entry; int lookup_still_valid; struct vnode *vp; + int vfslocked; }; static inline void @@ -171,13 +172,11 @@ unlock_and_deallocate(struct faultstate vm_object_deallocate(fs->first_object); unlock_map(fs); if (fs->vp != NULL) { - int vfslocked; - - vfslocked = VFS_LOCK_GIANT(fs->vp->v_mount); vput(fs->vp); fs->vp = NULL; - VFS_UNLOCK_GIANT(vfslocked); } + VFS_UNLOCK_GIANT(fs->vfslocked); + fs->vfslocked = 0; } /* @@ -218,12 +217,17 @@ vm_fault(vm_map_t map, vm_offset_t vaddr vm_object_t next_object; vm_page_t marray[VM_FAULT_READ]; int hardfault; - int faultcount; + int faultcount, ahead, behind; struct faultstate fs; + struct vnode *vp; + int locked, error; hardfault = 0; growstack = TRUE; PCPU_INC(cnt.v_vm_faults); + fs.vp = NULL; + fs.vfslocked = 0; + faultcount = behind = 0; RetryFault:; @@ -289,21 +293,9 @@ RetryFault:; * Bump the paging-in-progress count to prevent size changes (e.g. * truncation operations) during I/O. This must be done after * obtaining the vnode lock in order to avoid possible deadlocks. - * - * XXX vnode_pager_lock() can block without releasing the map lock. */ - if (fs.first_object->flags & OBJ_NEEDGIANT) - mtx_lock(&Giant); VM_OBJECT_LOCK(fs.first_object); vm_object_reference_locked(fs.first_object); - fs.vp = vnode_pager_lock(fs.first_object); - KASSERT(fs.vp == NULL || !fs.map->system_map, - ("vm_fault: vnode-backed object mapped by system map")); - KASSERT((fs.first_object->flags & OBJ_NEEDGIANT) == 0 || - !fs.map->system_map, - ("vm_fault: Object requiring giant mapped by system map")); - if (fs.first_object->flags & OBJ_NEEDGIANT) - mtx_unlock(&Giant); vm_object_pip_add(fs.first_object, 1); fs.lookup_still_valid = TRUE; @@ -380,14 +372,6 @@ RetryFault:; fs.first_m = NULL; } unlock_map(&fs); - if (fs.vp != NULL) { - int vfslck; - - vfslck = VFS_LOCK_GIANT(fs.vp->v_mount); - vput(fs.vp); - fs.vp = NULL; - VFS_UNLOCK_GIANT(vfslck); - } VM_OBJECT_LOCK(fs.object); if (fs.m == vm_page_lookup(fs.object, fs.pindex)) { @@ -441,7 +425,9 @@ RetryFault:; } #endif fs.m = vm_page_alloc(fs.object, fs.pindex, - (fs.vp || fs.object->backing_object)? VM_ALLOC_NORMAL: VM_ALLOC_ZERO); + (fs.object->type == OBJT_VNODE || + fs.object->backing_object != NULL) ? + VM_ALLOC_NORMAL : VM_ALLOC_ZERO); } if (fs.m == NULL) { unlock_and_deallocate(&fs); @@ -464,7 +450,6 @@ readrest: if (TRYPAGER) { int rv; int reqpage = 0; - int ahead, behind; u_char behavior = vm_map_entry_behavior(fs.entry); if (behavior == MAP_ENTRY_BEHAV_RANDOM) { @@ -527,6 +512,65 @@ readrest: } if (is_first_object_locked) VM_OBJECT_UNLOCK(fs.first_object); + + /* + * Call the pager to retrieve the data, if any, after + * releasing the lock on the map. We hold a ref on + * fs.object and the pages are VPO_BUSY'd. + */ + unlock_map(&fs); + +vnode_lock: + if (fs.object->type == OBJT_VNODE) { + vp = fs.object->handle; + if (vp == fs.vp) + goto vnode_locked; + else if (fs.vp != NULL) { + vput(fs.vp); + fs.vp = NULL; + } + locked = VOP_ISLOCKED(vp); + + if (VFS_NEEDSGIANT(vp->v_mount) && !fs.vfslocked) { + fs.vfslocked = 1; + if (!mtx_trylock(&Giant)) { + VM_OBJECT_UNLOCK(fs.object); + mtx_lock(&Giant); + VM_OBJECT_LOCK(fs.object); + goto vnode_lock; + } + } + if (locked != LK_EXCLUSIVE) + locked = LK_SHARED; + /* Do not sleep for vnode lock while fs.m is busy */ + error = vget(vp, locked | LK_CANRECURSE | + LK_NOWAIT, curthread); + if (error != 0) { + int vfslocked; + + vfslocked = fs.vfslocked; + fs.vfslocked = 0; /* Keep Giant */ + vhold(vp); + release_page(&fs); + unlock_and_deallocate(&fs); + error = vget(vp, locked | LK_RETRY | + LK_CANRECURSE, curthread); + vdrop(vp); + fs.vp = vp; + fs.vfslocked = vfslocked; + KASSERT(error == 0, + ("vm_fault: vget failed")); + goto RetryFault; + } + fs.vp = vp; + } +vnode_locked: + KASSERT(fs.vp == NULL || !fs.map->system_map, + ("vm_fault: vnode-backed object mapped by system map")); + KASSERT((fs.first_object->flags & OBJ_NEEDGIANT) == 0 || + !fs.map->system_map, + ("vm_fault: Object requiring giant mapped by system map")); + /* * now we find out if any other pages should be paged * in at this time this routine checks to see if the @@ -547,22 +591,6 @@ readrest: faultcount = vm_fault_additional_pages( fs.m, behind, ahead, marray, &reqpage); - /* - * update lastr imperfectly (we do not know how much - * getpages will actually read), but good enough. - * - * XXX The following assignment modifies the map - * without holding a write lock on it. - */ - fs.entry->lastr = fs.pindex + faultcount - behind; - - /* - * Call the pager to retrieve the data, if any, after - * releasing the lock on the map. We hold a ref on - * fs.object and the pages are VPO_BUSY'd. - */ - unlock_map(&fs); - rv = faultcount ? vm_pager_get_pages(fs.object, marray, faultcount, reqpage) : VM_PAGER_FAIL; @@ -839,6 +867,15 @@ readrest: prot &= retry_prot; } } + /* + * update lastr imperfectly (we do not know how much + * getpages will actually read), but good enough. + * + * XXX The following assignment modifies the map + * without holding a write lock on it. + */ + fs.entry->lastr = fs.pindex + faultcount - behind; + if (prot & VM_PROT_WRITE) { vm_object_set_writeable_dirty(fs.object); Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Sun Feb 8 20:19:19 2009 (r188330) +++ head/sys/vm/vnode_pager.c Sun Feb 8 20:23:46 2009 (r188331) @@ -1174,56 +1174,3 @@ vnode_pager_generic_putpages(vp, m, byte } return rtvals[0]; } - -struct vnode * -vnode_pager_lock(vm_object_t first_object) -{ - struct vnode *vp; - vm_object_t backing_object, object; - int locked, lockf; - - VM_OBJECT_LOCK_ASSERT(first_object, MA_OWNED); - for (object = first_object; object != NULL; object = backing_object) { - if (object->type != OBJT_VNODE) { - if ((backing_object = object->backing_object) != NULL) - VM_OBJECT_LOCK(backing_object); - if (object != first_object) - VM_OBJECT_UNLOCK(object); - continue; - } - retry: - if (object->flags & OBJ_DEAD) { - if (object != first_object) - VM_OBJECT_UNLOCK(object); - return NULL; - } - vp = object->handle; - locked = VOP_ISLOCKED(vp); - VI_LOCK(vp); - VM_OBJECT_UNLOCK(object); - if (first_object != object) - VM_OBJECT_UNLOCK(first_object); - VFS_ASSERT_GIANT(vp->v_mount); - if (locked == LK_EXCLUSIVE) - lockf = LK_CANRECURSE | LK_INTERLOCK | LK_RETRY | - LK_EXCLUSIVE; - else - lockf = LK_CANRECURSE | LK_INTERLOCK | LK_RETRY | - LK_SHARED; - if (vget(vp, lockf, curthread)) { - VM_OBJECT_LOCK(first_object); - if (object != first_object) - VM_OBJECT_LOCK(object); - if (object->type != OBJT_VNODE) { - if (object != first_object) - VM_OBJECT_UNLOCK(object); - return NULL; - } - printf("vnode_pager_lock: retrying\n"); - goto retry; - } - VM_OBJECT_LOCK(first_object); - return (vp); - } - return NULL; -} Modified: head/sys/vm/vnode_pager.h ============================================================================== --- head/sys/vm/vnode_pager.h Sun Feb 8 20:19:19 2009 (r188330) +++ head/sys/vm/vnode_pager.h Sun Feb 8 20:23:46 2009 (r188331) @@ -39,7 +39,6 @@ #define _VNODE_PAGER_ 1 #ifdef _KERNEL -struct vnode *vnode_pager_lock(vm_object_t); /* * XXX Generic routines; currently called by badly written FS code; these From sam at FreeBSD.org Sun Feb 8 12:29:39 2009 From: sam at FreeBSD.org (Sam Leffler) Date: Sun Feb 8 12:29:51 2009 Subject: svn commit: r188332 - head/sys/dev/cfi Message-ID: <200902082029.n18KTbWP033595@svn.freebsd.org> Author: sam Date: Sun Feb 8 20:29:37 2009 New Revision: 188332 URL: http://svn.freebsd.org/changeset/base/188332 Log: fix typo Submitted by: Christoph Mallon Modified: head/sys/dev/cfi/cfi_core.c Modified: head/sys/dev/cfi/cfi_core.c ============================================================================== --- head/sys/dev/cfi/cfi_core.c Sun Feb 8 20:23:46 2009 (r188331) +++ head/sys/dev/cfi/cfi_core.c Sun Feb 8 20:29:37 2009 (r188332) @@ -439,7 +439,7 @@ cfi_write_block(struct cfi_softc *sc) * at the factory with a unique 64-bit number which is immutable. * The other segment is left blank for User (OEM) programming. * The User/OEM segment is One Time Programmable (OTP). It can also - * be locked to prevent any firther writes by setting bit 0 of the + * be locked to prevent any further writes by setting bit 0 of the * Protection Lock Register (PLR). The PLR can written only once. */ From kib at FreeBSD.org Sun Feb 8 12:30:54 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 12:31:01 2009 Subject: svn commit: r188333 - head/sys/vm Message-ID: <200902082030.n18KUpj1033655@svn.freebsd.org> Author: kib Date: Sun Feb 8 20:30:51 2009 New Revision: 188333 URL: http://svn.freebsd.org/changeset/base/188333 Log: In vm_map_sync(), do not call vm_object_sync() while holding map lock. Reference object, drop the map lock, and then call vm_object_sync(). The object sync might require vnode lock for OBJT_VNODE type objects. Reviewed by: tegge Tested by: pho Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 20:29:37 2009 (r188332) +++ head/sys/vm/vm_map.c Sun Feb 8 20:30:51 2009 (r188333) @@ -2304,6 +2304,7 @@ vm_map_sync( vm_size_t size; vm_object_t object; vm_ooffset_t offset; + unsigned int last_timestamp; vm_map_lock_read(map); VM_MAP_RANGE_CHECK(map, start, end); @@ -2338,8 +2339,7 @@ vm_map_sync( * Make a second pass, cleaning/uncaching pages from the indicated * objects as we go. */ - for (current = entry; current != &map->header && current->start < end; - current = current->next) { + for (current = entry; current != &map->header && current->start < end;) { offset = current->offset + (start - current->start); size = (end <= current->end ? end : current->end) - start; if (current->eflags & MAP_ENTRY_IS_SUB_MAP) { @@ -2359,8 +2359,16 @@ vm_map_sync( } else { object = current->object.vm_object; } + vm_object_reference(object); + last_timestamp = map->timestamp; + vm_map_unlock_read(map); vm_object_sync(object, offset, size, syncio, invalidate); start += size; + vm_object_deallocate(object); + vm_map_lock_read(map); + if (last_timestamp == map->timestamp || + !vm_map_lookup_entry(map, start, ¤t)) + current = current->next; } vm_map_unlock_read(map); From kib at FreeBSD.org Sun Feb 8 12:39:19 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 12:39:30 2009 Subject: svn commit: r188334 - head/sys/vm Message-ID: <200902082039.n18KdIZS033850@svn.freebsd.org> Author: kib Date: Sun Feb 8 20:39:17 2009 New Revision: 188334 URL: http://svn.freebsd.org/changeset/base/188334 Log: Do not call vm_object_deallocate() from vm_map_delete(), because we hold the map lock there, and might need the vnode lock for OBJT_VNODE objects. Postpone object deallocation until caller of vm_map_delete() drops the map lock. Link the map entries to be freed into the freelist, that is released by the new helper function vm_map_entry_free_freelist(). Reviewed by: tegge, alc Tested by: pho Modified: head/sys/vm/vm_kern.c head/sys/vm/vm_map.c head/sys/vm/vm_map.h head/sys/vm/vm_mmap.c head/sys/vm/vm_unix.c Modified: head/sys/vm/vm_kern.c ============================================================================== --- head/sys/vm/vm_kern.c Sun Feb 8 20:30:51 2009 (r188333) +++ head/sys/vm/vm_kern.c Sun Feb 8 20:39:17 2009 (r188334) @@ -271,7 +271,7 @@ kmem_malloc(map, size, flags) int flags; { vm_offset_t offset, i; - vm_map_entry_t entry; + vm_map_entry_t entry, freelist; vm_offset_t addr; vm_page_t m; int pflags; @@ -355,8 +355,10 @@ retry: vm_page_unlock_queues(); } VM_OBJECT_UNLOCK(kmem_object); - vm_map_delete(map, addr, addr + size); + freelist = NULL; + vm_map_delete(map, addr, addr + size, &freelist); vm_map_unlock(map); + vm_map_entry_free_freelist(map, freelist); return (0); } if (flags & M_ZERO && (m->flags & PG_ZERO) == 0) @@ -455,14 +457,18 @@ kmem_free_wakeup(map, addr, size) vm_offset_t addr; vm_size_t size; { + vm_map_entry_t freelist; + freelist = NULL; vm_map_lock(map); - (void) vm_map_delete(map, trunc_page(addr), round_page(addr + size)); + (void) vm_map_delete(map, trunc_page(addr), round_page(addr + size), + &freelist); if (map->needs_wakeup) { map->needs_wakeup = FALSE; vm_map_wakeup(map); } vm_map_unlock(map); + vm_map_entry_free_freelist(map, freelist); } /* Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 20:30:51 2009 (r188333) +++ head/sys/vm/vm_map.c Sun Feb 8 20:39:17 2009 (r188334) @@ -1261,16 +1261,19 @@ vm_map_fixed(vm_map_t map, vm_object_t o vm_offset_t start, vm_size_t length, vm_prot_t prot, vm_prot_t max, int cow) { + vm_map_entry_t freelist; vm_offset_t end; int result; - vm_map_lock(map); end = start + length; + freelist = NULL; + vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); - (void) vm_map_delete(map, start, end); + (void) vm_map_delete(map, start, end, &freelist); result = vm_map_insert(map, object, offset, start, end, prot, max, cow); vm_map_unlock(map); + vm_map_entry_free_freelist(map, freelist); return (result); } @@ -2392,6 +2395,23 @@ vm_map_entry_unwire(vm_map_t map, vm_map entry->wired_count = 0; } +void +vm_map_entry_free_freelist(vm_map_t map, vm_map_entry_t freelist) +{ + vm_map_entry_t e; + vm_object_t object; + + while (freelist != NULL) { + e = freelist; + freelist = freelist->next; + if ((e->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { + object = e->object.vm_object; + vm_object_deallocate(object); + } + vm_map_entry_dispose(map, e); + } +} + /* * vm_map_entry_delete: [ internal use only ] * @@ -2424,10 +2444,8 @@ vm_map_entry_delete(vm_map_t map, vm_map object->size = offidxstart; } VM_OBJECT_UNLOCK(object); - vm_object_deallocate(object); - } - - vm_map_entry_dispose(map, entry); + } else + entry->object.vm_object = NULL; } /* @@ -2437,7 +2455,8 @@ vm_map_entry_delete(vm_map_t map, vm_map * map. */ int -vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end) +vm_map_delete(vm_map_t map, vm_offset_t start, vm_offset_t end, + vm_map_entry_t *freelist) { vm_map_entry_t entry; vm_map_entry_t first_entry; @@ -2514,6 +2533,8 @@ vm_map_delete(vm_map_t map, vm_offset_t * modify bits will be set in the wrong object!) */ vm_map_entry_delete(map, entry); + entry->next = *freelist; + *freelist = entry; entry = next; } return (KERN_SUCCESS); @@ -2528,12 +2549,15 @@ vm_map_delete(vm_map_t map, vm_offset_t int vm_map_remove(vm_map_t map, vm_offset_t start, vm_offset_t end) { + vm_map_entry_t freelist; int result; + freelist = NULL; vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); - result = vm_map_delete(map, start, end); + result = vm_map_delete(map, start, end, &freelist); vm_map_unlock(map); + vm_map_entry_free_freelist(map, freelist); return (result); } Modified: head/sys/vm/vm_map.h ============================================================================== --- head/sys/vm/vm_map.h Sun Feb 8 20:30:51 2009 (r188333) +++ head/sys/vm/vm_map.h Sun Feb 8 20:39:17 2009 (r188334) @@ -157,6 +157,8 @@ vm_map_entry_system_wired_count(vm_map_e { return (entry->wired_count - vm_map_entry_user_wired_count(entry)); } + +void vm_map_entry_free_freelist(vm_map_t map, vm_map_entry_t freelist); #endif /* _KERNEL */ /* @@ -336,7 +338,7 @@ long vmspace_wired_count(struct vmspace #ifdef _KERNEL boolean_t vm_map_check_protection (vm_map_t, vm_offset_t, vm_offset_t, vm_prot_t); vm_map_t vm_map_create(pmap_t, vm_offset_t, vm_offset_t); -int vm_map_delete (vm_map_t, vm_offset_t, vm_offset_t); +int vm_map_delete(vm_map_t, vm_offset_t, vm_offset_t, vm_map_entry_t *); int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *, vm_size_t, int, vm_prot_t, vm_prot_t, int); int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t, Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Sun Feb 8 20:30:51 2009 (r188333) +++ head/sys/vm/vm_mmap.c Sun Feb 8 20:39:17 2009 (r188334) @@ -552,6 +552,7 @@ munmap(td, uap) vm_offset_t addr; vm_size_t size, pageoff; vm_map_t map; + vm_map_entry_t freelist; addr = (vm_offset_t) uap->addr; size = uap->len; @@ -571,6 +572,7 @@ munmap(td, uap) map = &td->td_proc->p_vmspace->vm_map; if (addr < vm_map_min(map) || addr + size > vm_map_max(map)) return (EINVAL); + freelist = NULL; vm_map_lock(map); #ifdef HWPMC_HOOKS /* @@ -593,8 +595,9 @@ munmap(td, uap) } #endif /* returns nothing but KERN_SUCCESS anyway */ - vm_map_delete(map, addr, addr + size); + vm_map_delete(map, addr, addr + size, &freelist); vm_map_unlock(map); + vm_map_entry_free_freelist(map, freelist); return (0); } Modified: head/sys/vm/vm_unix.c ============================================================================== --- head/sys/vm/vm_unix.c Sun Feb 8 20:30:51 2009 (r188333) +++ head/sys/vm/vm_unix.c Sun Feb 8 20:39:17 2009 (r188334) @@ -72,6 +72,7 @@ obreak(td, uap) struct obreak_args *uap; { struct vmspace *vm = td->td_proc->p_vmspace; + vm_map_entry_t freelist; vm_offset_t new, old, base; rlim_t datalim, vmemlim; int rv; @@ -85,6 +86,7 @@ obreak(td, uap) do_map_wirefuture = FALSE; new = round_page((vm_offset_t)uap->nsize); + freelist = NULL; vm_map_lock(&vm->vm_map); base = round_page((vm_offset_t) vm->vm_daddr); @@ -138,7 +140,7 @@ obreak(td, uap) do_map_wirefuture = TRUE; } } else if (new < old) { - rv = vm_map_delete(&vm->vm_map, new, old); + rv = vm_map_delete(&vm->vm_map, new, old, &freelist); if (rv != KERN_SUCCESS) { error = ENOMEM; goto done; @@ -147,6 +149,7 @@ obreak(td, uap) } done: vm_map_unlock(&vm->vm_map); + vm_map_entry_free_freelist(&vm->vm_map, freelist); if (do_map_wirefuture) (void) vm_map_wire(&vm->vm_map, old, new, From kib at FreeBSD.org Sun Feb 8 12:52:10 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 12:52:16 2009 Subject: svn commit: r188335 - head/sys/vm Message-ID: <200902082052.n18Kq91t034106@svn.freebsd.org> Author: kib Date: Sun Feb 8 20:52:09 2009 New Revision: 188335 URL: http://svn.freebsd.org/changeset/base/188335 Log: Improve comments, correct English. Submitted by: alc Modified: head/sys/vm/vm_map.c Modified: head/sys/vm/vm_map.c ============================================================================== --- head/sys/vm/vm_map.c Sun Feb 8 20:39:17 2009 (r188334) +++ head/sys/vm/vm_map.c Sun Feb 8 20:52:09 2009 (r188335) @@ -1355,13 +1355,13 @@ vm_map_simplify_entry(vm_map_t map, vm_m vm_map_entry_resize_free(map, entry->prev); /* - * If the backing object is the vnode object, - * vm_object_deallocate() results in a call to - * vrele(). Because the reference to the - * object is not last, vrele() does not lock - * the vnode, and map lock can be kept without - * causing vnode lock to be taken after the - * map lock. + * If the backing object is a vnode object, + * vm_object_deallocate() calls vrele(). + * However, vrele() does not lock the vnode + * because the vnode has additional + * references. Thus, the map lock can be kept + * without causing a lock-order reversal with + * the vnode lock. */ if (prev->object.vm_object) vm_object_deallocate(prev->object.vm_object); @@ -2778,7 +2778,7 @@ vmspace_fork(struct vmspace *vm1) /* * As in vm_map_simplify_entry(), the - * vnode lock may not be acquired in + * vnode lock will not be acquired in * this call to vm_object_deallocate(). */ vm_object_deallocate(object); From thompsa at FreeBSD.org Sun Feb 8 13:08:01 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Sun Feb 8 13:08:06 2009 Subject: svn commit: r188336 - head/sys/dev/usb2/controller Message-ID: <200902082108.n18L80vC034416@svn.freebsd.org> Author: thompsa Date: Sun Feb 8 21:08:00 2009 New Revision: 188336 URL: http://svn.freebsd.org/changeset/base/188336 Log: The NRL value in the queue head must be zero for interrupt transfers. This was diagnosed using a USB analyser obtained through a FreeBSD Foundation grant. Thanks to: FreeBSD Foundation Modified: head/sys/dev/usb2/controller/ehci2.c Modified: head/sys/dev/usb2/controller/ehci2.c ============================================================================== --- head/sys/dev/usb2/controller/ehci2.c Sun Feb 8 20:52:09 2009 (r188335) +++ head/sys/dev/usb2/controller/ehci2.c Sun Feb 8 21:08:00 2009 (r188336) @@ -1892,7 +1892,9 @@ ehci_setup_standard_chain(struct usb2_xf if (usb2_get_speed(xfer->xroot->udev) == USB_SPEED_HIGH) { qh_endp |= (EHCI_QH_SET_EPS(EHCI_QH_SPEED_HIGH) | - EHCI_QH_DTC | EHCI_QH_SET_NRL(8)); + EHCI_QH_DTC); + if (methods != &ehci_device_intr_methods) + qh_endp |= EHCI_QH_SET_NRL(8); } else { if (usb2_get_speed(xfer->xroot->udev) == USB_SPEED_FULL) { From kib at FreeBSD.org Sun Feb 8 13:20:13 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Feb 8 13:20:19 2009 Subject: svn commit: r188337 - head/sys/vm Message-ID: <200902082120.n18LKDYM034690@svn.freebsd.org> Author: kib Date: Sun Feb 8 21:20:13 2009 New Revision: 188337 URL: http://svn.freebsd.org/changeset/base/188337 Log: Remove no longer valid comment. Submitted by: alc Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Feb 8 21:08:00 2009 (r188336) +++ head/sys/vm/vm_fault.c Sun Feb 8 21:20:13 2009 (r188337) @@ -584,9 +584,6 @@ vnode_locked: * vm_page_t passed to the routine. * * fs.m plus the additional pages are VPO_BUSY'd. - * - * XXX vm_fault_additional_pages() can block - * without releasing the map lock. */ faultcount = vm_fault_additional_pages( fs.m, behind, ahead, marray, &reqpage); From xcllnt at mac.com Sun Feb 8 13:32:13 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Sun Feb 8 13:32:24 2009 Subject: svn commit: r188303 - head/sys/geom/part In-Reply-To: <200902080705.n1875NNd014796@svn.freebsd.org> References: <200902080705.n1875NNd014796@svn.freebsd.org> Message-ID: <2F95FB8C-44CA-4F1D-BF96-4C2C3C6BB06C@mac.com> On Feb 7, 2009, at 11:05 PM, Warner Losh wrote: > Author: imp > Date: Sun Feb 8 07:05:23 2009 > New Revision: 188303 > URL: http://svn.freebsd.org/changeset/base/188303 > > Log: > Fix g_part_*dumpconf to return void to match kobj definition. > Fix g_part_*name to return a const char * rather than a char *. This is worse than before because you didn't change apm, gpt, pc98 and vtoc8. Please change them all. Thanks, -- Marcel Moolenaar xcllnt@mac.com From kmacy at FreeBSD.org Sun Feb 8 13:54:53 2009 From: kmacy at FreeBSD.org (Kip Macy) Date: Sun Feb 8 13:54:59 2009 Subject: svn commit: r188341 - head/sys/i386/xen Message-ID: <200902082154.n18LspRB035509@svn.freebsd.org> Author: kmacy Date: Sun Feb 8 21:54:51 2009 New Revision: 188341 URL: http://svn.freebsd.org/changeset/base/188341 Log: Don't try to directly update page tables Modified: head/sys/i386/xen/pmap.c Modified: head/sys/i386/xen/pmap.c ============================================================================== --- head/sys/i386/xen/pmap.c Sun Feb 8 21:50:47 2009 (r188340) +++ head/sys/i386/xen/pmap.c Sun Feb 8 21:54:51 2009 (r188341) @@ -3713,14 +3713,17 @@ pmap_remove_write(vm_page_t m) retry: oldpte = *pte; if ((oldpte & PG_RW) != 0) { + vm_paddr_t newpte = oldpte & ~(PG_RW | PG_M); + /* * Regardless of whether a pte is 32 or 64 bits * in size, PG_RW and PG_M are among the least * significant 32 bits. */ - if (!atomic_cmpset_int((u_int *)pte, oldpte, - oldpte & ~(PG_RW | PG_M))) + PT_SET_VA_MA(pte, newpte, TRUE); + if (*pte != newpte) goto retry; + if ((oldpte & PG_M) != 0) vm_page_dirty(m); pmap_invalidate_page(pmap, pv->pv_va); From kientzle at FreeBSD.org Sun Feb 8 14:02:47 2009 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Sun Feb 8 14:02:53 2009 Subject: svn commit: r188343 - head/usr.bin/tar Message-ID: <200902082202.n18M2kQ3035843@svn.freebsd.org> Author: kientzle Date: Sun Feb 8 22:02:46 2009 New Revision: 188343 URL: http://svn.freebsd.org/changeset/base/188343 Log: When copying file data to the archive, don't write more than was read. This seems to have only affected the shar writer, since other formats proactively truncate output to the originally-advertised size. PR: bin/131244 MFC after: 7 days Modified: head/usr.bin/tar/write.c Modified: head/usr.bin/tar/write.c ============================================================================== --- head/usr.bin/tar/write.c Sun Feb 8 22:01:20 2009 (r188342) +++ head/usr.bin/tar/write.c Sun Feb 8 22:02:46 2009 (r188343) @@ -972,7 +972,7 @@ write_file_data(struct bsdtar *bsdtar, s siginfo_printinfo(bsdtar, progress); bytes_written = archive_write_data(a, bsdtar->buff, - FILEDATABUFLEN); + bytes_read); if (bytes_written < 0) { /* Write failed; this is bad */ bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a)); From kientzle at FreeBSD.org Sun Feb 8 14:04:18 2009 From: kientzle at FreeBSD.org (Tim Kientzle) Date: Sun Feb 8 14:04:29 2009 Subject: svn commit: r188344 - head/usr.bin/tar Message-ID: <200902082204.n18M4Hw5035990@svn.freebsd.org> Author: kientzle Date: Sun Feb 8 22:04:17 2009 New Revision: 188344 URL: http://svn.freebsd.org/changeset/base/188344 Log: Fix multiple -s options. MFC after: 7 days Modified: head/usr.bin/tar/subst.c Modified: head/usr.bin/tar/subst.c ============================================================================== --- head/usr.bin/tar/subst.c Sun Feb 8 22:02:46 2009 (r188343) +++ head/usr.bin/tar/subst.c Sun Feb 8 22:04:17 2009 (r188344) @@ -202,7 +202,7 @@ apply_substitution(struct bsdtar *bsdtar if (symlink_only && !rule->symlink) continue; if (regexec(&rule->re, name, 10, matches, 0)) - break; + continue; got_match = 1; print_match |= rule->print; From trasz at FreeBSD.org Sun Feb 8 14:08:49 2009 From: trasz at FreeBSD.org (Edward Tomasz Napierala) Date: Sun Feb 8 14:09:00 2009 Subject: svn commit: r188345 - head/sys/cam Message-ID: <200902082208.n18M8m8B036217@svn.freebsd.org> Author: trasz Date: Sun Feb 8 22:08:48 2009 New Revision: 188345 URL: http://svn.freebsd.org/changeset/base/188345 Log: Remove an overzealous check. Submitted by: das Reviewed by: scottl Approved by: rwatson (mentor, implicit) Sponsored by: FreeBSD Foundation Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Sun Feb 8 22:04:17 2009 (r188344) +++ head/sys/cam/cam_xpt.c Sun Feb 8 22:08:48 2009 (r188345) @@ -4178,7 +4178,7 @@ xpt_path_string(struct cam_path *path, c struct sbuf sb; #ifdef INVARIANTS - if (path != NULL && path->bus != NULL && path->bus->sim != NULL) + if (path != NULL && path->bus != NULL) mtx_assert(path->bus->sim->mtx, MA_OWNED); #endif From alc at FreeBSD.org Sun Feb 8 14:17:25 2009 From: alc at FreeBSD.org (Alan Cox) Date: Sun Feb 8 14:17:36 2009 Subject: svn commit: r188348 - head/sys/vm Message-ID: <200902082217.n18MHOdt036521@svn.freebsd.org> Author: alc Date: Sun Feb 8 22:17:24 2009 New Revision: 188348 URL: http://svn.freebsd.org/changeset/base/188348 Log: Eliminate OBJ_NEEDGIANT. After r188331, OBJ_NEEDGIANT's only use is by a redundant assertion in vm_fault(). Reviewed by: kib Modified: head/sys/vm/vm_fault.c head/sys/vm/vm_object.c head/sys/vm/vm_object.h head/sys/vm/vnode_pager.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Feb 8 22:13:57 2009 (r188347) +++ head/sys/vm/vm_fault.c Sun Feb 8 22:17:24 2009 (r188348) @@ -567,9 +567,6 @@ vnode_lock: vnode_locked: KASSERT(fs.vp == NULL || !fs.map->system_map, ("vm_fault: vnode-backed object mapped by system map")); - KASSERT((fs.first_object->flags & OBJ_NEEDGIANT) == 0 || - !fs.map->system_map, - ("vm_fault: Object requiring giant mapped by system map")); /* * now we find out if any other pages should be paged Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Sun Feb 8 22:13:57 2009 (r188347) +++ head/sys/vm/vm_object.c Sun Feb 8 22:17:24 2009 (r188348) @@ -1273,11 +1273,9 @@ vm_object_shadow( source->shadow_count++; source->generation++; #if VM_NRESERVLEVEL > 0 - result->flags |= source->flags & (OBJ_NEEDGIANT | OBJ_COLORED); + result->flags |= source->flags & OBJ_COLORED; result->pg_color = (source->pg_color + OFF_TO_IDX(*offset)) & ((1 << (VM_NFREEORDER - 1)) - 1); -#else - result->flags |= source->flags & OBJ_NEEDGIANT; #endif VM_OBJECT_UNLOCK(source); } @@ -1349,7 +1347,6 @@ vm_object_split(vm_map_entry_t entry) orig_object->backing_object_offset + entry->offset; new_object->backing_object = source; } - new_object->flags |= orig_object->flags & OBJ_NEEDGIANT; retry: if ((m = TAILQ_FIRST(&orig_object->memq)) != NULL) { if (m->pindex < offidxstart) { Modified: head/sys/vm/vm_object.h ============================================================================== --- head/sys/vm/vm_object.h Sun Feb 8 22:13:57 2009 (r188347) +++ head/sys/vm/vm_object.h Sun Feb 8 22:17:24 2009 (r188348) @@ -147,7 +147,6 @@ struct vm_object { #define OBJ_COLORED 0x1000 /* pg_color is defined */ #define OBJ_ONEMAPPING 0x2000 /* One USE (a single, non-forked) mapping flag */ #define OBJ_DISCONNECTWNT 0x4000 /* disconnect from vnode wanted */ -#define OBJ_NEEDGIANT 0x8000 /* object requires Giant */ #define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT) #define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT)) Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Sun Feb 8 22:13:57 2009 (r188347) +++ head/sys/vm/vnode_pager.c Sun Feb 8 22:17:24 2009 (r188348) @@ -223,8 +223,6 @@ retry: object->un_pager.vnp.vnp_size = size; object->handle = handle; - if (VFS_NEEDSGIANT(vp->v_mount)) - vm_object_set_flag(object, OBJ_NEEDGIANT); VI_LOCK(vp); if (vp->v_object != NULL) { /* From imp at bsdimp.com Sun Feb 8 14:42:31 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Sun Feb 8 14:43:11 2009 Subject: svn commit: r188303 - head/sys/geom/part In-Reply-To: <2F95FB8C-44CA-4F1D-BF96-4C2C3C6BB06C@mac.com> References: <200902080705.n1875NNd014796@svn.freebsd.org> <2F95FB8C-44CA-4F1D-BF96-4C2C3C6BB06C@mac.com> Message-ID: <20090208.153911.-2127818638.imp@bsdimp.com> In message: <2F95FB8C-44CA-4F1D-BF96-4C2C3C6BB06C@mac.com> Marcel Moolenaar writes: : : On Feb 7, 2009, at 11:05 PM, Warner Losh wrote: : : > Author: imp : > Date: Sun Feb 8 07:05:23 2009 : > New Revision: 188303 : > URL: http://svn.freebsd.org/changeset/base/188303 : > : > Log: : > Fix g_part_*dumpconf to return void to match kobj definition. : > Fix g_part_*name to return a const char * rather than a char *. : : This is worse than before because you didn't change : apm, gpt, pc98 and vtoc8. Please change them all. Will do. I'm working my way through the platforms with the extra-picky compile-time checking. Didn't think to grep for them all, but I really should have. My bad. Warner From imp at FreeBSD.org Sun Feb 8 14:55:00 2009 From: imp at FreeBSD.org (Warner Losh) Date: Sun Feb 8 14:55:06 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys Message-ID: <200902082254.n18MsxVt037307@svn.freebsd.org> Author: imp Date: Sun Feb 8 22:54:58 2009 New Revision: 188350 URL: http://svn.freebsd.org/changeset/base/188350 Log: When bouncing pages, allow a new option to preserve the intra-page offset. This is needed for the ehci hardware buffer rings that assume this behavior. This is an interim solution, and a more general one is being worked on. This solution doesn't break anything that doesn't ask for it directly. The mbuf and uio variants with this flag likely don't work and haven't been tested. Universe builds with these changes. I don't have a huge-memory machine to test these changes with, but will be happy to work with folks that do and hps if this changes turns out not to be sufficient. Submitted by: alfred@ from Hans Peter Selasky's original Modified: head/sys/amd64/amd64/busdma_machdep.c head/sys/arm/arm/busdma_machdep.c head/sys/dev/usb2/core/usb2_busdma.c head/sys/i386/i386/busdma_machdep.c head/sys/ia64/ia64/busdma_machdep.c head/sys/sys/bus_dma.h Modified: head/sys/amd64/amd64/busdma_machdep.c ============================================================================== --- head/sys/amd64/amd64/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/amd64/amd64/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1128,6 +1128,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/arm/arm/busdma_machdep.c ============================================================================== --- head/sys/arm/arm/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/arm/arm/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1417,6 +1417,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/dev/usb2/core/usb2_busdma.c ============================================================================== --- head/sys/dev/usb2/core/usb2_busdma.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/dev/usb2/core/usb2_busdma.c Sun Feb 8 22:54:58 2009 (r188350) @@ -351,7 +351,7 @@ usb2_dma_tag_create(struct usb2_dma_tag (2 + (size / USB_PAGE_SIZE)) : 1, /* maxsegsz */ (align == 1) ? USB_PAGE_SIZE : size, - /* flags */ 0, + /* flags */ BUS_DMA_KEEP_PG_OFFSET, /* lockfn */ &usb2_dma_lock_cb, /* lockarg */ NULL, &tag)) { Modified: head/sys/i386/i386/busdma_machdep.c ============================================================================== --- head/sys/i386/i386/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/i386/i386/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1146,6 +1146,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/ia64/ia64/busdma_machdep.c ============================================================================== --- head/sys/ia64/ia64/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/ia64/ia64/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -936,6 +936,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/sys/bus_dma.h ============================================================================== --- head/sys/sys/bus_dma.h Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/sys/bus_dma.h Sun Feb 8 22:54:58 2009 (r188350) @@ -102,6 +102,13 @@ #define BUS_DMA_NOWRITE 0x100 #define BUS_DMA_NOCACHE 0x200 +/* + * The following flag is a DMA tag hint that the page offset of the + * loaded kernel virtual address must be preserved in the first + * physical segment address, when the KVA is loaded into DMA. + */ +#define BUS_DMA_KEEP_PG_OFFSET 0x400 + /* Forwards needed by prototypes below. */ struct mbuf; struct uio; From xcllnt at mac.com Sun Feb 8 15:01:29 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Sun Feb 8 15:01:43 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <200902082254.n18MsxVt037307@svn.freebsd.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> Message-ID: <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> On Feb 8, 2009, at 2:54 PM, Warner Losh wrote: > Author: imp > Date: Sun Feb 8 22:54:58 2009 > New Revision: 188350 > URL: http://svn.freebsd.org/changeset/base/188350 > > Log: > When bouncing pages, allow a new option to preserve the intra-page > offset. This is needed for the ehci hardware buffer rings that > assume > this behavior. I thought we ended up with always doing that? Bounce buffers may or may not be used, so if the page offset must be zero for bounce buffers, they must be zero for the original DMA request. I see no value in re-aligning the DMA request to a page boundary when bounce buffers are used, but it is required in some cases to not realign. Hence, why not always (and unconditionally) preserve the alignment? -- Marcel Moolenaar xcllnt@mac.com From marcel at FreeBSD.org Sun Feb 8 15:39:31 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Sun Feb 8 15:39:42 2009 Subject: svn commit: r188352 - head/sys/geom/part Message-ID: <200902082339.n18NdUZw038263@svn.freebsd.org> Author: marcel Date: Sun Feb 8 23:39:30 2009 New Revision: 188352 URL: http://svn.freebsd.org/changeset/base/188352 Log: Allow gpe_offset to be set by the scheme. When gpe_offset is zero, or invalid, initialize it to the start of the partition. Adjust the mediasize when the offset lies somewhere inside the partition. Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Sun Feb 8 23:12:29 2009 (r188351) +++ head/sys/geom/part/g_part.c Sun Feb 8 23:39:30 2009 (r188352) @@ -244,7 +244,8 @@ g_part_new_entry(struct g_part_table *ta LIST_INSERT_HEAD(&table->gpt_entry, entry, gpe_entry); else LIST_INSERT_AFTER(last, entry, gpe_entry); - } + } else + entry->gpe_offset = 0; entry->gpe_start = start; entry->gpe_end = end; return (entry); @@ -257,11 +258,14 @@ g_part_new_provider(struct g_geom *gp, s char buf[32]; struct g_consumer *cp; struct g_provider *pp; + off_t offset; cp = LIST_FIRST(&gp->consumer); pp = cp->provider; - entry->gpe_offset = entry->gpe_start * pp->sectorsize; + offset = entry->gpe_start * pp->sectorsize; + if (entry->gpe_offset < offset) + entry->gpe_offset = offset; if (entry->gpe_pp == NULL) { entry->gpe_pp = g_new_providerf(gp, "%s%s", gp->name, @@ -271,6 +275,7 @@ g_part_new_provider(struct g_geom *gp, s entry->gpe_pp->index = entry->gpe_index - 1; /* index is 1-based. */ entry->gpe_pp->mediasize = (entry->gpe_end - entry->gpe_start + 1) * pp->sectorsize; + entry->gpe_pp->mediasize -= entry->gpe_offset - offset; entry->gpe_pp->sectorsize = pp->sectorsize; entry->gpe_pp->flags = pp->flags & G_PF_CANDELETE; if (pp->stripesize > 0) { From gonzo at FreeBSD.org Sun Feb 8 15:43:37 2009 From: gonzo at FreeBSD.org (Oleksandr Tymoshenko) Date: Sun Feb 8 15:43:44 2009 Subject: svn commit: r188353 - head/sys/mips/mips Message-ID: <200902082343.n18Nha37038365@svn.freebsd.org> Author: gonzo Date: Sun Feb 8 23:43:36 2009 New Revision: 188353 URL: http://svn.freebsd.org/changeset/base/188353 Log: - Fix in_cksum for big-endian MIPS: use correct compile-time check. Modified: head/sys/mips/mips/in_cksum.c Modified: head/sys/mips/mips/in_cksum.c ============================================================================== --- head/sys/mips/mips/in_cksum.c Sun Feb 8 23:39:30 2009 (r188352) +++ head/sys/mips/mips/in_cksum.c Sun Feb 8 23:43:36 2009 (r188353) @@ -69,7 +69,7 @@ __FBSDID("$FreeBSD$"); } static const u_int32_t in_masks[] = { -#ifndef _MISEB +#if _BYTE_ORDER == _LITTLE_ENDIAN /*0 bytes*/ /*1 byte*/ /*2 bytes*/ /*3 bytes*/ 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF, /* offset 0 */ 0x00000000, 0x0000FF00, 0x00FFFF00, 0xFFFFFF00, /* offset 1 */ From marcel at FreeBSD.org Sun Feb 8 15:51:45 2009 From: marcel at FreeBSD.org (Marcel Moolenaar) Date: Sun Feb 8 15:51:52 2009 Subject: svn commit: r188354 - in head/sys: geom/part modules/geom/geom_part modules/geom/geom_part/geom_part_ebr Message-ID: <200902082351.n18Npihc038550@svn.freebsd.org> Author: marcel Date: Sun Feb 8 23:51:44 2009 New Revision: 188354 URL: http://svn.freebsd.org/changeset/base/188354 Log: Add the EBR scheme. The EBR scheme supports the Extended Boot Records found inside extended partitions and used to create logical partitions. At this time write/modify support is not (yet) present. The EBR and MBR schemes both check the parent scheme. The MBR will back-off when nested under another MBR, whereas the EBR only nests under a MBR. Added: head/sys/geom/part/g_part_ebr.c (contents, props changed) head/sys/modules/geom/geom_part/geom_part_ebr/ head/sys/modules/geom/geom_part/geom_part_ebr/Makefile (contents, props changed) Modified: head/sys/geom/part/g_part_mbr.c head/sys/modules/geom/geom_part/Makefile Added: head/sys/geom/part/g_part_ebr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/geom/part/g_part_ebr.c Sun Feb 8 23:51:44 2009 (r188354) @@ -0,0 +1,339 @@ +/*- + * Copyright (c) 2007-2009 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "g_part_if.h" + +#define EBRSIZE 512 + +struct g_part_ebr_table { + struct g_part_table base; +}; + +struct g_part_ebr_entry { + struct g_part_entry base; + struct dos_partition ent; +}; + +static int g_part_ebr_add(struct g_part_table *, struct g_part_entry *, + struct g_part_parms *); +static int g_part_ebr_create(struct g_part_table *, struct g_part_parms *); +static int g_part_ebr_destroy(struct g_part_table *, struct g_part_parms *); +static void g_part_ebr_dumpconf(struct g_part_table *, struct g_part_entry *, + struct sbuf *, const char *); +static int g_part_ebr_dumpto(struct g_part_table *, struct g_part_entry *); +static int g_part_ebr_modify(struct g_part_table *, struct g_part_entry *, + struct g_part_parms *); +static const char *g_part_ebr_name(struct g_part_table *, struct g_part_entry *, + char *, size_t); +static int g_part_ebr_probe(struct g_part_table *, struct g_consumer *); +static int g_part_ebr_read(struct g_part_table *, struct g_consumer *); +static int g_part_ebr_setunset(struct g_part_table *, struct g_part_entry *, + const char *, unsigned int); +static const char *g_part_ebr_type(struct g_part_table *, struct g_part_entry *, + char *, size_t); +static int g_part_ebr_write(struct g_part_table *, struct g_consumer *); + +static kobj_method_t g_part_ebr_methods[] = { + KOBJMETHOD(g_part_add, g_part_ebr_add), + KOBJMETHOD(g_part_create, g_part_ebr_create), + KOBJMETHOD(g_part_destroy, g_part_ebr_destroy), + KOBJMETHOD(g_part_dumpconf, g_part_ebr_dumpconf), + KOBJMETHOD(g_part_dumpto, g_part_ebr_dumpto), + KOBJMETHOD(g_part_modify, g_part_ebr_modify), + KOBJMETHOD(g_part_name, g_part_ebr_name), + KOBJMETHOD(g_part_probe, g_part_ebr_probe), + KOBJMETHOD(g_part_read, g_part_ebr_read), + KOBJMETHOD(g_part_setunset, g_part_ebr_setunset), + KOBJMETHOD(g_part_type, g_part_ebr_type), + KOBJMETHOD(g_part_write, g_part_ebr_write), + { 0, 0 } +}; + +static struct g_part_scheme g_part_ebr_scheme = { + "EBR", + g_part_ebr_methods, + sizeof(struct g_part_ebr_table), + .gps_entrysz = sizeof(struct g_part_ebr_entry), + .gps_minent = 1, + .gps_maxent = INT_MAX, +}; +G_PART_SCHEME_DECLARE(g_part_ebr); + +static void +ebr_entry_decode(const char *p, struct dos_partition *ent) +{ + ent->dp_flag = p[0]; + ent->dp_shd = p[1]; + ent->dp_ssect = p[2]; + ent->dp_scyl = p[3]; + ent->dp_typ = p[4]; + ent->dp_ehd = p[5]; + ent->dp_esect = p[6]; + ent->dp_ecyl = p[7]; + ent->dp_start = le32dec(p + 8); + ent->dp_size = le32dec(p + 12); +} + +static int +g_part_ebr_add(struct g_part_table *basetable, struct g_part_entry *baseentry, + struct g_part_parms *gpp) +{ + + return (ENOSYS); +} + +static int +g_part_ebr_create(struct g_part_table *basetable, struct g_part_parms *gpp) +{ + + return (ENOSYS); +} + +static int +g_part_ebr_destroy(struct g_part_table *basetable, struct g_part_parms *gpp) +{ + + /* Wipe the first sector to clear the partitioning. */ + basetable->gpt_smhead |= 1; + return (0); +} + +static void +g_part_ebr_dumpconf(struct g_part_table *table, struct g_part_entry *baseentry, + struct sbuf *sb, const char *indent) +{ + struct g_part_ebr_entry *entry; + + entry = (struct g_part_ebr_entry *)baseentry; + if (indent == NULL) { + /* conftxt: libdisk compatibility */ + sbuf_printf(sb, " xs MBREXT xt %u", entry->ent.dp_typ); + } else if (entry != NULL) { + /* confxml: partition entry information */ + sbuf_printf(sb, "%s%u\n", indent, + entry->ent.dp_typ); + if (entry->ent.dp_flag & 0x80) + sbuf_printf(sb, "%sactive\n", indent); + } else { + /* confxml: scheme information */ + } +} + +static int +g_part_ebr_dumpto(struct g_part_table *table, struct g_part_entry *baseentry) +{ + struct g_part_ebr_entry *entry; + + /* Allow dumping to a FreeBSD partition only. */ + entry = (struct g_part_ebr_entry *)baseentry; + return ((entry->ent.dp_typ == DOSPTYP_386BSD) ? 1 : 0); +} + +static int +g_part_ebr_modify(struct g_part_table *basetable, + struct g_part_entry *baseentry, struct g_part_parms *gpp) +{ + + return (ENOSYS); +} + +static const char * +g_part_ebr_name(struct g_part_table *table, struct g_part_entry *entry, + char *buf, size_t bufsz) +{ + + snprintf(buf, bufsz, ".%08u", entry->gpe_index); + return (buf); +} + +static int +g_part_ebr_probe(struct g_part_table *table, struct g_consumer *cp) +{ + char psn[8]; + struct g_provider *pp; + u_char *buf, *p; + int error, index, res, sum; + uint16_t magic; + + pp = cp->provider; + + /* Sanity-check the provider. */ + if (pp->sectorsize < EBRSIZE || pp->mediasize < pp->sectorsize) + return (ENOSPC); + if (pp->sectorsize > 4096) + return (ENXIO); + + /* Check that we have a parent and that it's a MBR. */ + if (table->gpt_depth == 0) + return (ENXIO); + error = g_getattr("PART::scheme", cp, &psn); + if (error) + return (error); + if (strcmp(psn, "MBR")) + return (ENXIO); + + /* Check that there's a EBR. */ + buf = g_read_data(cp, 0L, pp->sectorsize, &error); + if (buf == NULL) + return (error); + + /* We goto out on mismatch. */ + res = ENXIO; + + magic = le16dec(buf + DOSMAGICOFFSET); + if (magic != DOSMAGIC) + goto out; + + /* The sector is all zeroes, except for the partition entries. */ + sum = 0; + for (index = 0; index < DOSPARTOFF; index++) + sum += buf[index]; + if (sum != 0) + goto out; + + for (index = 0; index < NDOSPART; index++) { + p = buf + DOSPARTOFF + index * DOSPARTSIZE; + if (p[0] != 0 && p[0] != 0x80) + goto out; + if (index < 2) + continue; + /* The 3rd & 4th entries are always zero. */ + if ((le64dec(p+0) + le64dec(p+8)) != 0) + goto out; + } + + res = G_PART_PROBE_PRI_HIGH; + + out: + g_free(buf); + return (res); +} + +static int +g_part_ebr_read(struct g_part_table *basetable, struct g_consumer *cp) +{ + struct dos_partition ent[2]; + struct g_provider *pp; + struct g_part_entry *baseentry; + struct g_part_ebr_table *table; + struct g_part_ebr_entry *entry; + u_char *buf; + off_t ofs, msize; + u_int lba; + int error, index; + + pp = cp->provider; + table = (struct g_part_ebr_table *)basetable; + msize = pp->mediasize / pp->sectorsize; + + lba = 0; + while (1) { + ofs = (off_t)lba * pp->sectorsize; + buf = g_read_data(cp, ofs, pp->sectorsize, &error); + if (buf == NULL) + return (error); + + ebr_entry_decode(buf + DOSPARTOFF + 0 * DOSPARTSIZE, ent + 0); + ebr_entry_decode(buf + DOSPARTOFF + 1 * DOSPARTSIZE, ent + 1); + g_free(buf); + + if (ent[0].dp_typ == 0) + break; + + if (ent[0].dp_typ == 5 && ent[1].dp_typ == 0) { + lba = ent[0].dp_start; + continue; + } + + index = (lba / basetable->gpt_sectors) + 1; + baseentry = (struct g_part_entry *)g_part_new_entry(basetable, + index, lba, lba + ent[0].dp_start + ent[0].dp_size - 1); + baseentry->gpe_offset = (off_t)(lba + ent[0].dp_start) * + pp->sectorsize; + entry = (struct g_part_ebr_entry *)baseentry; + entry->ent = ent[0]; + + if (ent[1].dp_typ == 0) + break; + + lba = ent[1].dp_start; + } + + basetable->gpt_entries = msize / basetable->gpt_sectors; + basetable->gpt_first = 0; + basetable->gpt_last = msize - (msize % basetable->gpt_sectors) - 1; + return (0); +} + +static int +g_part_ebr_setunset(struct g_part_table *table, struct g_part_entry *baseentry, + const char *attrib, unsigned int set) +{ + + return (ENOSYS); +} + +static const char * +g_part_ebr_type(struct g_part_table *basetable, struct g_part_entry *baseentry, + char *buf, size_t bufsz) +{ + struct g_part_ebr_entry *entry; + int type; + + entry = (struct g_part_ebr_entry *)baseentry; + type = entry->ent.dp_typ; + if (type == DOSPTYP_386BSD) + return (g_part_alias_name(G_PART_ALIAS_FREEBSD)); + snprintf(buf, bufsz, "!%d", type); + return (buf); +} + +static int +g_part_ebr_write(struct g_part_table *basetable, struct g_consumer *cp) +{ + + return (ENOSYS); +} Modified: head/sys/geom/part/g_part_mbr.c ============================================================================== --- head/sys/geom/part/g_part_mbr.c Sun Feb 8 23:43:36 2009 (r188353) +++ head/sys/geom/part/g_part_mbr.c Sun Feb 8 23:51:44 2009 (r188354) @@ -314,6 +314,7 @@ g_part_mbr_name(struct g_part_table *tab static int g_part_mbr_probe(struct g_part_table *table, struct g_consumer *cp) { + char psn[8]; struct g_provider *pp; u_char *buf, *p; int error, index, res, sum; @@ -327,6 +328,11 @@ g_part_mbr_probe(struct g_part_table *ta if (pp->sectorsize > 4096) return (ENXIO); + /* We don't nest under an MBR (see EBR instead). */ + error = g_getattr("PART::scheme", cp, &psn); + if (error == 0 && strcmp(psn, g_part_mbr_scheme.name) == 0) + return (ELOOP); + /* Check that there's a MBR. */ buf = g_read_data(cp, 0L, pp->sectorsize, &error); if (buf == NULL) Modified: head/sys/modules/geom/geom_part/Makefile ============================================================================== --- head/sys/modules/geom/geom_part/Makefile Sun Feb 8 23:43:36 2009 (r188353) +++ head/sys/modules/geom/geom_part/Makefile Sun Feb 8 23:51:44 2009 (r188354) @@ -2,6 +2,7 @@ SUBDIR= geom_part_apm \ geom_part_bsd \ + geom_part_ebr \ geom_part_gpt \ geom_part_mbr \ geom_part_pc98 \ Added: head/sys/modules/geom/geom_part/geom_part_ebr/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/geom/geom_part/geom_part_ebr/Makefile Sun Feb 8 23:51:44 2009 (r188354) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../../../geom/part + +KMOD= geom_part_ebr +SRCS= g_part_ebr.c + +SRCS+= bus_if.h device_if.h g_part_if.h + +MFILES= kern/bus_if.m kern/device_if.m geom/part/g_part_if.m + +.include From imp at bsdimp.com Sun Feb 8 16:06:28 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Sun Feb 8 16:06:40 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> Message-ID: <20090208.170515.1031215309.imp@bsdimp.com> In message: <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> Marcel Moolenaar writes: : : On Feb 8, 2009, at 2:54 PM, Warner Losh wrote: : : > Author: imp : > Date: Sun Feb 8 22:54:58 2009 : > New Revision: 188350 : > URL: http://svn.freebsd.org/changeset/base/188350 : > : > Log: : > When bouncing pages, allow a new option to preserve the intra-page : > offset. This is needed for the ehci hardware buffer rings that : > assume : > this behavior. : : I thought we ended up with always doing that? : : Bounce buffers may or may not be used, so if the page offset : must be zero for bounce buffers, they must be zero for the : original DMA request. I see no value in re-aligning the DMA : request to a page boundary when bounce buffers are used, but : it is required in some cases to not realign. Hence, why not : always (and unconditionally) preserve the alignment? I'm not entirely sure either. However, at this stage of the game I'd rather be a little conservative in what we change and do a more careful and thorough analysis. One area we do need to fix is the inability to flush a subset of the range. Warner From xcllnt at mac.com Sun Feb 8 16:10:00 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Sun Feb 8 16:10:11 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <20090208.170515.1031215309.imp@bsdimp.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> <20090208.170515.1031215309.imp@bsdimp.com> Message-ID: <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> On Feb 8, 2009, at 4:05 PM, M. Warner Losh wrote: > In message: <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> > Marcel Moolenaar writes: > : > : On Feb 8, 2009, at 2:54 PM, Warner Losh wrote: > : > : > Author: imp > : > Date: Sun Feb 8 22:54:58 2009 > : > New Revision: 188350 > : > URL: http://svn.freebsd.org/changeset/base/188350 > : > > : > Log: > : > When bouncing pages, allow a new option to preserve the intra- > page > : > offset. This is needed for the ehci hardware buffer rings that > : > assume > : > this behavior. > : > : I thought we ended up with always doing that? > : > : Bounce buffers may or may not be used, so if the page offset > : must be zero for bounce buffers, they must be zero for the > : original DMA request. I see no value in re-aligning the DMA > : request to a page boundary when bounce buffers are used, but > : it is required in some cases to not realign. Hence, why not > : always (and unconditionally) preserve the alignment? > > I'm not entirely sure either. However, at this stage of the game I'd > rather be a little conservative in what we change and do a more > careful and thorough analysis. Fair enough. -- Marcel Moolenaar xcllnt@mac.com From scottl at samsco.org Sun Feb 8 17:00:13 2009 From: scottl at samsco.org (Scott Long) Date: Sun Feb 8 17:00:25 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> <20090208.170515.1031215309.imp@bsdimp.com> <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> Message-ID: <498F8015.8000704@samsco.org> Marcel Moolenaar wrote: > > On Feb 8, 2009, at 4:05 PM, M. Warner Losh wrote: > >> In message: <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> >> Marcel Moolenaar writes: >> : >> : On Feb 8, 2009, at 2:54 PM, Warner Losh wrote: >> : >> : > Author: imp >> : > Date: Sun Feb 8 22:54:58 2009 >> : > New Revision: 188350 >> : > URL: http://svn.freebsd.org/changeset/base/188350 >> : > >> : > Log: >> : > When bouncing pages, allow a new option to preserve the intra-page >> : > offset. This is needed for the ehci hardware buffer rings that >> : > assume >> : > this behavior. >> : >> : I thought we ended up with always doing that? >> : >> : Bounce buffers may or may not be used, so if the page offset >> : must be zero for bounce buffers, they must be zero for the >> : original DMA request. I see no value in re-aligning the DMA >> : request to a page boundary when bounce buffers are used, but >> : it is required in some cases to not realign. Hence, why not >> : always (and unconditionally) preserve the alignment? >> >> I'm not entirely sure either. However, at this stage of the game I'd >> rather be a little conservative in what we change and do a more >> careful and thorough analysis. > > Fair enough. > Busdma allows you to request bouncing for realignment. Unconditionally preserving the page offset when bouncing defeats this. Also, it has never preserved the offset. I have no idea if this was intentional or not. Scott From weongyo at FreeBSD.org Sun Feb 8 20:39:17 2009 From: weongyo at FreeBSD.org (Weongyo Jeong) Date: Sun Feb 8 20:39:23 2009 Subject: svn commit: r188380 - head/sys/net80211 Message-ID: <200902090439.n194dGSK045564@svn.freebsd.org> Author: weongyo Date: Mon Feb 9 04:39:16 2009 New Revision: 188380 URL: http://svn.freebsd.org/changeset/base/188380 Log: mark M_LASTFRAG at the last fragment. Reviewed by: sam MFC after: 3 weeks Modified: head/sys/net80211/ieee80211_output.c Modified: head/sys/net80211/ieee80211_output.c ============================================================================== --- head/sys/net80211/ieee80211_output.c Mon Feb 9 04:02:53 2009 (r188379) +++ head/sys/net80211/ieee80211_output.c Mon Feb 9 04:39:16 2009 (r188380) @@ -1376,6 +1376,9 @@ ieee80211_fragment(struct ieee80211vap * remainder -= payload; off += payload; } while (remainder != 0); + + /* set the last fragment */ + m->m_flags |= M_LASTFRAG; whf->i_fc[1] &= ~IEEE80211_FC1_MORE_FRAG; /* strip first mbuf now that everything has been copied */ From yongari at FreeBSD.org Sun Feb 8 20:59:13 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Sun Feb 8 20:59:25 2009 Subject: svn commit: r188381 - head/sys/dev/re Message-ID: <200902090459.n194xDa3045928@svn.freebsd.org> Author: yongari Date: Mon Feb 9 04:59:13 2009 New Revision: 188381 URL: http://svn.freebsd.org/changeset/base/188381 Log: Reclaim transmitted frames in re_tick(). This is for PCIe controllers that lose Tx completion interrupts under certain conditions. With this change it's safe to use MSI on PCIe controllers so enable MSI on these controllers. Modified: head/sys/dev/re/if_re.c Modified: head/sys/dev/re/if_re.c ============================================================================== --- head/sys/dev/re/if_re.c Mon Feb 9 04:39:16 2009 (r188380) +++ head/sys/dev/re/if_re.c Mon Feb 9 04:59:13 2009 (r188381) @@ -156,7 +156,7 @@ MODULE_DEPEND(re, miibus, 1, 1, 1); #include "miibus_if.h" /* Tunables. */ -static int msi_disable = 1; +static int msi_disable = 0; TUNABLE_INT("hw.re.msi_disable", &msi_disable); #define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP) @@ -2064,6 +2064,13 @@ re_tick(void *xsc) mii_tick(mii); if ((sc->rl_flags & RL_FLAG_LINK) == 0) re_miibus_statchg(sc->rl_dev); + /* + * Reclaim transmitted frames here. Technically it is not + * necessary to do here but it ensures periodic reclamation + * regardless of Tx completion interrupt which seems to be + * lost on PCIe based controllers under certain situations. + */ + re_txeof(sc); re_watchdog(sc); callout_reset(&sc->rl_stat_callout, hz, re_tick, sc); } From yongari at FreeBSD.org Sun Feb 8 21:09:53 2009 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Sun Feb 8 21:10:04 2009 Subject: svn commit: r188382 - head/share/man/man4 Message-ID: <200902090509.n1959qEV046148@svn.freebsd.org> Author: yongari Date: Mon Feb 9 05:09:52 2009 New Revision: 188382 URL: http://svn.freebsd.org/changeset/base/188382 Log: Document loader tunable hw.re.msi_disable. Bump .Dd Modified: head/share/man/man4/re.4 Modified: head/share/man/man4/re.4 ============================================================================== --- head/share/man/man4/re.4 Mon Feb 9 04:59:13 2009 (r188381) +++ head/share/man/man4/re.4 Mon Feb 9 05:09:52 2009 (r188382) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 14, 2006 +.Dd February 9, 2009 .Dt RE 4 .Os .Sh NAME @@ -169,6 +169,16 @@ USRobotics USR997902 Gigabit Ethernet (8 .It Xterasys XN-152 10/100/1000 NIC (8169) .El +.Sh LOADER TUNABLES +Tunables can be set at the +.Xr loader 8 +prompt before booting the kernel or stored in +.Xr loader.conf 5 . +.Bl -tag -width "xxxxxx" +.It Va hw.re.msi_disable +This tunable disables MSI support on the Ethernet hardware. +The default value is 0. +.El .Sh DIAGNOSTICS .Bl -diag .It "re%d: couldn't map memory" From xcllnt at mac.com Sun Feb 8 21:37:56 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Sun Feb 8 21:38:08 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <498F8015.8000704@samsco.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> <20090208.170515.1031215309.imp@bsdimp.com> <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> <498F8015.8000704@samsco.org> Message-ID: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > Busdma allows you to request bouncing for realignment. How exactly? -- Marcel Moolenaar xcllnt@mac.com From alc at FreeBSD.org Sun Feb 8 22:23:22 2009 From: alc at FreeBSD.org (Alan Cox) Date: Sun Feb 8 22:23:29 2009 Subject: svn commit: r188383 - head/sys/vm Message-ID: <200902090623.n196NLmL047518@svn.freebsd.org> Author: alc Date: Mon Feb 9 06:23:21 2009 New Revision: 188383 URL: http://svn.freebsd.org/changeset/base/188383 Log: Avoid some cases of unnecessary page queues locking by vm_fault's delete- behind heuristic. Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Mon Feb 9 05:09:52 2009 (r188382) +++ head/sys/vm/vm_fault.c Mon Feb 9 06:23:21 2009 (r188383) @@ -212,7 +212,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr { vm_prot_t prot; int is_first_object_locked, result; - boolean_t growstack, wired; + boolean_t are_queues_locked, growstack, wired; int map_generation; vm_object_t next_object; vm_page_t marray[VM_FAULT_READ]; @@ -480,7 +480,7 @@ readrest: else firstpindex = fs.first_pindex - 2 * VM_FAULT_READ; - vm_page_lock_queues(); + are_queues_locked = FALSE; /* * note: partially valid pages cannot be * included in the lookahead - NFS piecemeal @@ -495,8 +495,13 @@ readrest: if (mt == NULL || (mt->valid != VM_PAGE_BITS_ALL)) break; if (mt->busy || - (mt->oflags & VPO_BUSY) || - mt->hold_count || + (mt->oflags & VPO_BUSY)) + continue; + if (!are_queues_locked) { + are_queues_locked = TRUE; + vm_page_lock_queues(); + } + if (mt->hold_count || mt->wire_count) continue; pmap_remove_all(mt); @@ -506,7 +511,8 @@ readrest: vm_page_cache(mt); } } - vm_page_unlock_queues(); + if (are_queues_locked) + vm_page_unlock_queues(); ahead += behind; behind = 0; } From ed at FreeBSD.org Mon Feb 9 03:28:07 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Mon Feb 9 03:28:14 2009 Subject: svn commit: r188385 - head/sys/kern Message-ID: <200902091127.n19BRuxi058642@svn.freebsd.org> Author: ed Date: Mon Feb 9 11:27:56 2009 New Revision: 188385 URL: http://svn.freebsd.org/changeset/base/188385 Log: Remove a stale comment from the clists code. We don't support quote bits. Modified: head/sys/kern/subr_clist.c Modified: head/sys/kern/subr_clist.c ============================================================================== --- head/sys/kern/subr_clist.c Mon Feb 9 10:28:16 2009 (r188384) +++ head/sys/kern/subr_clist.c Mon Feb 9 11:27:56 2009 (r188385) @@ -85,10 +85,6 @@ cblock_alloc_cblocks(int number) for (i = 0; i < number; ++i) { cbp = malloc(sizeof *cbp, M_CLIST, M_WAITOK); - /* - * Freed cblocks have zero quotes and garbage elsewhere. - * Set the may-have-quote bit to force zeroing the quotes. - */ cblock_free(cbp); } } From kib at FreeBSD.org Mon Feb 9 03:32:28 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Feb 9 03:32:35 2009 Subject: svn commit: r188386 - head/sys/vm Message-ID: <200902091132.n19BWNdc058763@svn.freebsd.org> Author: kib Date: Mon Feb 9 11:32:23 2009 New Revision: 188386 URL: http://svn.freebsd.org/changeset/base/188386 Log: Comment out the assertion from r188321. It is not valid for nfs. Reported by: alc Modified: head/sys/vm/vnode_pager.c Modified: head/sys/vm/vnode_pager.c ============================================================================== --- head/sys/vm/vnode_pager.c Mon Feb 9 11:27:56 2009 (r188385) +++ head/sys/vm/vnode_pager.c Mon Feb 9 11:32:23 2009 (r188386) @@ -365,7 +365,7 @@ vnode_pager_setsize(vp, nsize) if ((object = vp->v_object) == NULL) return; - ASSERT_VOP_ELOCKED(vp, "vnode_pager_setsize and not locked vnode"); +/* ASSERT_VOP_ELOCKED(vp, "vnode_pager_setsize and not locked vnode"); */ VM_OBJECT_LOCK(object); if (nsize == object->un_pager.vnp.vnp_size) { /* From rrs at FreeBSD.org Mon Feb 9 03:41:57 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Mon Feb 9 03:42:03 2009 Subject: svn commit: r188387 - head/sys/netinet Message-ID: <200902091141.n19Bfsk5058986@svn.freebsd.org> Author: rrs Date: Mon Feb 9 11:41:54 2009 New Revision: 188387 URL: http://svn.freebsd.org/changeset/base/188387 Log: Fix INET only build breakage with SCTP - pointy hat to me :-) Modified: head/sys/netinet/sctputil.c Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Mon Feb 9 11:32:23 2009 (r188386) +++ head/sys/netinet/sctputil.c Mon Feb 9 11:41:54 2009 (r188387) @@ -6550,7 +6550,9 @@ sctp_log_trace(uint32_t subsys, const ch #include #include #include +#ifdef INET6 #include +#endif static void sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored) From rrs at FreeBSD.org Mon Feb 9 03:42:26 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Mon Feb 9 03:42:32 2009 Subject: svn commit: r188388 - head/sys/netinet Message-ID: <200902091142.n19BgNnb059032@svn.freebsd.org> Author: rrs Date: Mon Feb 9 11:42:23 2009 New Revision: 188388 URL: http://svn.freebsd.org/changeset/base/188388 Log: Fix minor spacing problem found by s9indent from last commit. Modified: head/sys/netinet/sctp_crc32.c Modified: head/sys/netinet/sctp_crc32.c ============================================================================== --- head/sys/netinet/sctp_crc32.c Mon Feb 9 11:41:54 2009 (r188387) +++ head/sys/netinet/sctp_crc32.c Mon Feb 9 11:42:23 2009 (r188388) @@ -729,10 +729,11 @@ sctp_finalize_crc32(uint32_t crc32c) #endif return (crc32c); } + #else uint32_t -update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) { - +update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) +{ return (0); } @@ -741,6 +742,7 @@ sctp_finalize_crc32(uint32_t crc32c) { return (0); } + #endif /* !defined(SCTP_WITH_NO_CSUM) */ #if defined(SCTP_WITH_NO_CSUM) From dchagin at freebsd.org Mon Feb 9 04:58:28 2009 From: dchagin at freebsd.org (Chagin Dmitry) Date: Mon Feb 9 04:58:36 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <200902091142.n19BgNnb059032@svn.freebsd.org> References: <200902091142.n19BgNnb059032@svn.freebsd.org> Message-ID: <20090209124141.GA2071@dchagin.static.corbina.ru> On Mon, Feb 09, 2009 at 11:42:23AM +0000, Randall Stewart wrote: > Author: rrs > Date: Mon Feb 9 11:42:23 2009 > New Revision: 188388 > URL: http://svn.freebsd.org/changeset/base/188388 > > Log: > Fix minor spacing problem found by s9indent from last > commit. > > Modified: > head/sys/netinet/sctp_crc32.c > > Modified: head/sys/netinet/sctp_crc32.c > ============================================================================== > --- head/sys/netinet/sctp_crc32.c Mon Feb 9 11:41:54 2009 (r188387) > +++ head/sys/netinet/sctp_crc32.c Mon Feb 9 11:42:23 2009 (r188388) > @@ -729,10 +729,11 @@ sctp_finalize_crc32(uint32_t crc32c) > #endif > return (crc32c); > } > + > #else > uint32_t > -update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) { > - > +update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int length) > +{ > return (0); > } > > @@ -741,6 +742,7 @@ sctp_finalize_crc32(uint32_t crc32c) > { > return (0); > } > + > #endif /* !defined(SCTP_WITH_NO_CSUM) */ > > #if defined(SCTP_WITH_NO_CSUM) What would you say about this? (I do not have SCTP option in the kernel config) linking kernel.debug alias_sctp.o(.text+0x1744): In function `TxAbortErrorM': /work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `update_crc32' alias_sctp.o(.text+0x174b):/work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `sctp_finalize_crc32' *** Error code 1 Stop in /tank/obj/work/pub/head/sys/YOY. *** Error code 1 -- Have fun! chd From bzeeb-lists at lists.zabbadoz.net Mon Feb 9 05:15:09 2009 From: bzeeb-lists at lists.zabbadoz.net (Bjoern A. Zeeb) Date: Mon Feb 9 05:15:15 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <20090209124141.GA2071@dchagin.static.corbina.ru> References: <200902091142.n19BgNnb059032@svn.freebsd.org> <20090209124141.GA2071@dchagin.static.corbina.ru> Message-ID: <20090209130910.C93725@maildrop.int.zabbadoz.net> On Mon, 9 Feb 2009, Chagin Dmitry wrote: Hi, > What would you say about this? (I do not have SCTP option in the kernel config) > > linking kernel.debug > alias_sctp.o(.text+0x1744): In function `TxAbortErrorM': > /work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `update_crc32' > alias_sctp.o(.text+0x174b):/work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `sctp_finalize_crc32' > *** Error code 1 This is unrelated to this commit. This is a problem with piso's libalias commit; you have to remove that option from your kernel config as well if you remove SCTP. /bz -- Bjoern A. Zeeb The greatest risk is not taking one. From mbr at FreeBSD.org Mon Feb 9 05:29:04 2009 From: mbr at FreeBSD.org (Martin Blapp) Date: Mon Feb 9 05:29:15 2009 Subject: svn commit: r188390 - head/sys/kern Message-ID: <200902091329.n19DT2eH061117@svn.freebsd.org> Author: mbr Date: Mon Feb 9 13:29:01 2009 New Revision: 188390 URL: http://svn.freebsd.org/changeset/base/188390 Log: s/SS_FDREF/SS_NOFDREF/ Modified: head/sys/kern/uipc_debug.c Modified: head/sys/kern/uipc_debug.c ============================================================================== --- head/sys/kern/uipc_debug.c Mon Feb 9 12:22:49 2009 (r188389) +++ head/sys/kern/uipc_debug.c Mon Feb 9 13:29:01 2009 (r188390) @@ -145,7 +145,7 @@ db_print_sostate(short so_state) comma = 0; if (so_state & SS_NOFDREF) { - db_printf("%sSS_FDREF", comma ? ", " : ""); + db_printf("%sSS_NOFDREF", comma ? ", " : ""); comma = 1; } if (so_state & SS_ISCONNECTED) { From dchagin at freebsd.org Mon Feb 9 05:37:37 2009 From: dchagin at freebsd.org (Chagin Dmitry) Date: Mon Feb 9 05:37:49 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <20090209130910.C93725@maildrop.int.zabbadoz.net> References: <200902091142.n19BgNnb059032@svn.freebsd.org> <20090209124141.GA2071@dchagin.static.corbina.ru> <20090209130910.C93725@maildrop.int.zabbadoz.net> Message-ID: <20090209133730.GA34589@dchagin.static.corbina.ru> On Mon, Feb 09, 2009 at 01:10:30PM +0000, Bjoern A. Zeeb wrote: > On Mon, 9 Feb 2009, Chagin Dmitry wrote: > > Hi, > > > What would you say about this? (I do not have SCTP option in the kernel config) > > > > linking kernel.debug > > alias_sctp.o(.text+0x1744): In function `TxAbortErrorM': > > /work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `update_crc32' > > alias_sctp.o(.text+0x174b):/work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined reference to `sctp_finalize_crc32' > > *** Error code 1 > > This is unrelated to this commit. > I know. I think that this is not better than the previous COMMIT. > This is a problem with piso's libalias commit; you have to remove that > option from your kernel config as well if you remove SCTP. > > /bz > why? linking kernel.debug ip_fw_nat.o(.text+0xbc): In function `ifaddr_change': /work/pub/head/sys/netinet/ip_fw_nat.c:103: undefined reference to `LibAliasSetAddress' ip_fw_nat.o(.text+0x545): In function `del_redir_spool_cfg': /work/pub/head/sys/netinet/ip_fw_nat.c:162: undefined reference to `LibAliasRedirectDelete' ip_fw_nat.o(.text+0x75b): In function `ipfw_nat_del': /work/pub/head/sys/netinet/ip_fw_nat.c:500: undefined reference to `LibAliasUninit' ip_fw_nat.o(.text+0x922): In function `ipfw_nat_cfg': /work/pub/head/sys/netinet/ip_fw_nat.c:464: undefined reference to `LibAliasSetMode' ip_fw_nat.o(.text+0x92f):/work/pub/head/sys/netinet/ip_fw_nat.c:465: undefined reference to `LibAliasSetAddress' ip_fw_nat.o(.text+0xab4):/work/pub/head/sys/netinet/ip_fw_nat.c:234: undefined reference to `LibAliasAddServer' ip_fw_nat.o(.text+0xbc4):/work/pub/head/sys/netinet/ip_fw_nat.c:198: undefined reference to `LibAliasRedirectAddr' ip_fw_nat.o(.text+0xbf0):/work/pub/head/sys/netinet/ip_fw_nat.c:218: undefined reference to `LibAliasRedirectProto' ip_fw_nat.o(.text+0xc6d):/work/pub/head/sys/netinet/ip_fw_nat.c:207: undefined reference to `LibAliasRedirectPort' ip_fw_nat.o(.text+0xcff):/work/pub/head/sys/netinet/ip_fw_nat.c:437: undefined reference to `LibAliasInit' ip_fw_nat.o(.text+0xeea): In function `ipfw_nat_modevent': -- Have fun! chd From p.pisati at oltrelinux.com Mon Feb 9 05:56:04 2009 From: p.pisati at oltrelinux.com (Paolo Pisati) Date: Mon Feb 9 05:56:21 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <20090209133730.GA34589@dchagin.static.corbina.ru> References: <200902091142.n19BgNnb059032@svn.freebsd.org> <20090209124141.GA2071@dchagin.static.corbina.ru> <20090209130910.C93725@maildrop.int.zabbadoz.net> <20090209133730.GA34589@dchagin.static.corbina.ru> Message-ID: <4990334C.9040100@oltrelinux.com> Chagin Dmitry wrote: > > linking kernel.debug > ip_fw_nat.o(.text+0xbc): In function `ifaddr_change': > /work/pub/head/sys/netinet/ip_fw_nat.c:103: undefined reference to `LibAliasSetAddress' > ip_fw_nat.o(.text+0x545): In function `del_redir_spool_cfg': > /work/pub/head/sys/netinet/ip_fw_nat.c:162: undefined reference to `LibAliasRedirectDelete' > ip_fw_nat.o(.text+0x75b): In function `ipfw_nat_del': > /work/pub/head/sys/netinet/ip_fw_nat.c:500: undefined reference to `LibAliasUninit' > ip_fw_nat.o(.text+0x922): In function `ipfw_nat_cfg': > /work/pub/head/sys/netinet/ip_fw_nat.c:464: undefined reference to `LibAliasSetMode' > ip_fw_nat.o(.text+0x92f):/work/pub/head/sys/netinet/ip_fw_nat.c:465: undefined reference to `LibAliasSetAddress' > ip_fw_nat.o(.text+0xab4):/work/pub/head/sys/netinet/ip_fw_nat.c:234: undefined reference to `LibAliasAddServer' > ip_fw_nat.o(.text+0xbc4):/work/pub/head/sys/netinet/ip_fw_nat.c:198: undefined reference to `LibAliasRedirectAddr' > ip_fw_nat.o(.text+0xbf0):/work/pub/head/sys/netinet/ip_fw_nat.c:218: undefined reference to `LibAliasRedirectProto' > ip_fw_nat.o(.text+0xc6d):/work/pub/head/sys/netinet/ip_fw_nat.c:207: undefined reference to `LibAliasRedirectPort' > ip_fw_nat.o(.text+0xcff):/work/pub/head/sys/netinet/ip_fw_nat.c:437: undefined reference to `LibAliasInit' > ip_fw_nat.o(.text+0xeea): In function `ipfw_nat_modevent': > if you want IPFIREWALL_NAT, you need LIBALIAS. -- bye, P. From p.pisati at oltrelinux.com Mon Feb 9 05:56:05 2009 From: p.pisati at oltrelinux.com (Paolo Pisati) Date: Mon Feb 9 05:56:21 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <20090209130910.C93725@maildrop.int.zabbadoz.net> References: <200902091142.n19BgNnb059032@svn.freebsd.org> <20090209124141.GA2071@dchagin.static.corbina.ru> <20090209130910.C93725@maildrop.int.zabbadoz.net> Message-ID: <499031B6.3030600@oltrelinux.com> Bjoern A. Zeeb wrote: > > This is unrelated to this commit. > > This is a problem with piso's libalias commit; you have to remove that > option from your kernel config as well if you remove SCTP. or in other words IPFIREWALL_NAT now requires SCTP. In case this dependence is felt like an impossible burden for someone, i'll do the usual pointer dance. -- bye, P. From scottl at samsco.org Mon Feb 9 06:31:46 2009 From: scottl at samsco.org (Scott Long) Date: Mon Feb 9 06:31:52 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> <20090208.170515.1031215309.imp@bsdimp.com> <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> <498F8015.8000704@samsco.org> <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> Message-ID: <49903E4A.8000408@samsco.org> Marcel Moolenaar wrote: > > On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > >> Busdma allows you to request bouncing for realignment. > > How exactly? > By specifying an alignment greater than 1 in the tag. Scott From jhb at freebsd.org Mon Feb 9 06:39:40 2009 From: jhb at freebsd.org (John Baldwin) Date: Mon Feb 9 06:39:52 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <498F8015.8000704@samsco.org> <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> Message-ID: <200902090923.45887.jhb@freebsd.org> On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: > > On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > > > Busdma allows you to request bouncing for realignment. > > How exactly? The 'align' parameter to bus_dma_tag_create(). If your hardware needs buffers to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer where 'addr % 4 != 0', then the buffer is bounced. Since by default the new buffer starts on a page boundary, it satifies the 'addr % 4'. -- John Baldwin From stas at FreeBSD.org Mon Feb 9 07:53:18 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Mon Feb 9 07:54:54 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <200902082254.n18MsxVt037307@svn.freebsd.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> Message-ID: <20090209185326.7f92c449.stas@FreeBSD.org> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 8 Feb 2009 22:54:58 +0000 (UTC) Warner Losh mentioned: > Universe builds with these changes. I don't have a huge-memory > machine to test these changes with, but will be happy to work with > folks that do and hps if this changes turns out not to be sufficient. > I can confirm that this fixes EHCI for me (well, I haven't tested this patch yet, but old version from hps did). - -- Stanislav Sedov ST4096-RIPE -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAkmQUXsACgkQK/VZk+smlYF08ACfepUrJwHC3yWbkbE+9UejQAK9 wPsAn3CTxKlN8N+AiN2CBz8H+XMW2BOf =OQrg -----END PGP SIGNATURE----- !DSPAM:49905168967001927946153! From ed at FreeBSD.org Mon Feb 9 07:55:22 2009 From: ed at FreeBSD.org (Ed Schouten) Date: Mon Feb 9 07:55:39 2009 Subject: svn commit: r188391 - in head/sys/dev/syscons: . teken Message-ID: <200902091555.n19FtMQC064375@svn.freebsd.org> Author: ed Date: Mon Feb 9 15:55:21 2009 New Revision: 188391 URL: http://svn.freebsd.org/changeset/base/188391 Log: Properly implement GIO_ATTR and CONS_GETINFO. It seems I didn't implement these two ioctl()'s properly, which meant vidcontrol couldn't properly obtain certain terminal parameters. Modified: head/sys/dev/syscons/scterm-teken.c head/sys/dev/syscons/teken/teken.c head/sys/dev/syscons/teken/teken.h Modified: head/sys/dev/syscons/scterm-teken.c ============================================================================== --- head/sys/dev/syscons/scterm-teken.c Mon Feb 9 13:29:01 2009 (r188390) +++ head/sys/dev/syscons/scterm-teken.c Mon Feb 9 15:55:21 2009 (r188391) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include static void scteken_revattr(unsigned char, teken_attr_t *); +static unsigned int scteken_attr(const teken_attr_t *); static sc_term_init_t scteken_init; static sc_term_term_t scteken_term; @@ -165,21 +166,25 @@ static int scteken_ioctl(scr_stat *scp, struct tty *tp, u_long cmd, caddr_t data, struct thread *td) { + teken_stat *ts = scp->ts; vid_info_t *vi; + unsigned int attr; switch (cmd) { case GIO_ATTR: /* get current attributes */ - *(int*)data = SC_NORM_ATTR; + *(int*)data = + scteken_attr(teken_get_curattr(&ts->ts_teken)); return (0); case CONS_GETINFO: /* get current (virtual) console info */ - /* XXX: INCORRECT! */ vi = (vid_info_t *)data; if (vi->size != sizeof(struct vid_info)) return EINVAL; - vi->mv_norm.fore = SC_NORM_ATTR & 0x0f; - vi->mv_norm.back = (SC_NORM_ATTR >> 4) & 0x0f; - vi->mv_rev.fore = SC_NORM_ATTR & 0x0f; - vi->mv_rev.back = (SC_NORM_ATTR >> 4) & 0x0f; + + attr = scteken_attr(teken_get_defattr(&ts->ts_teken)); + vi->mv_norm.fore = attr & 0x0f; + vi->mv_norm.back = (attr >> 4) & 0x0f; + vi->mv_rev.fore = vi->mv_norm.back; + vi->mv_rev.back = vi->mv_norm.fore; /* * The other fields are filled by the upper routine. XXX */ @@ -280,7 +285,7 @@ scteken_revattr(unsigned char color, tek } } -static inline unsigned int +static unsigned int scteken_attr(const teken_attr_t *a) { unsigned int attr = 0; @@ -300,7 +305,7 @@ scteken_attr(const teken_attr_t *a) attr |= FG_BLINK; #endif /* FG_BLINK */ - return (attr << 8); + return (attr); } static void @@ -337,7 +342,7 @@ scteken_putchar(void *arg, const teken_p } else #endif /* TEKEN_UTF8 */ { - attr = scteken_attr(a); + attr = scteken_attr(a) << 8; ch = c; } @@ -373,7 +378,7 @@ scteken_fill(void *arg, const teken_rect } else #endif /* TEKEN_UTF8 */ { - attr = scteken_attr(a); + attr = scteken_attr(a) << 8; ch = c; } Modified: head/sys/dev/syscons/teken/teken.c ============================================================================== --- head/sys/dev/syscons/teken/teken.c Mon Feb 9 13:29:01 2009 (r188390) +++ head/sys/dev/syscons/teken/teken.c Mon Feb 9 15:55:21 2009 (r188391) @@ -329,6 +329,20 @@ teken_set_cursor(teken_t *t, const teken t->t_cursor = *p; } +const teken_attr_t * +teken_get_curattr(teken_t *t) +{ + + return (&t->t_curattr); +} + +const teken_attr_t * +teken_get_defattr(teken_t *t) +{ + + return (&t->t_defattr); +} + void teken_set_defattr(teken_t *t, const teken_attr_t *a) { Modified: head/sys/dev/syscons/teken/teken.h ============================================================================== --- head/sys/dev/syscons/teken/teken.h Mon Feb 9 13:29:01 2009 (r188390) +++ head/sys/dev/syscons/teken/teken.h Mon Feb 9 15:55:21 2009 (r188391) @@ -170,7 +170,9 @@ void teken_init(teken_t *, const teken_f /* Deliver character input. */ void teken_input(teken_t *, const void *, size_t); -/* Set teken attributes. */ +/* Get/set teken attributes. */ +const teken_attr_t *teken_get_curattr(teken_t *); +const teken_attr_t *teken_get_defattr(teken_t *); void teken_set_cursor(teken_t *, const teken_pos_t *); void teken_set_defattr(teken_t *, const teken_attr_t *); void teken_set_winsize(teken_t *, const teken_pos_t *); From rrs at lakerest.net Mon Feb 9 08:03:42 2009 From: rrs at lakerest.net (Randall Stewart) Date: Mon Feb 9 08:03:59 2009 Subject: svn commit: r188388 - head/sys/netinet In-Reply-To: <20090209124141.GA2071@dchagin.static.corbina.ru> References: <200902091142.n19BgNnb059032@svn.freebsd.org> <20090209124141.GA2071@dchagin.static.corbina.ru> Message-ID: <32F47187-B1D5-4EE3-A1ED-0FE4CD5998AC@lakerest.net> Hmm.. My guess is it has to do with the NAT stuff that Paolo is working on. Basically the ipfw/nat is becoming SCTP aware and I believe we made the sctp_crc32c routines public so that he could access them. Paolo: maybe you need to include and then do some sort of #ifdef SCTP #endif Around the csum calls int crc32?? R On Feb 9, 2009, at 7:41 AM, Chagin Dmitry wrote: > On Mon, Feb 09, 2009 at 11:42:23AM +0000, Randall Stewart wrote: >> Author: rrs >> Date: Mon Feb 9 11:42:23 2009 >> New Revision: 188388 >> URL: http://svn.freebsd.org/changeset/base/188388 >> >> Log: >> Fix minor spacing problem found by s9indent from last >> commit. >> >> Modified: >> head/sys/netinet/sctp_crc32.c >> >> Modified: head/sys/netinet/sctp_crc32.c >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- head/sys/netinet/sctp_crc32.c Mon Feb 9 11:41:54 2009 (r188387) >> +++ head/sys/netinet/sctp_crc32.c Mon Feb 9 11:42:23 2009 (r188388) >> @@ -729,10 +729,11 @@ sctp_finalize_crc32(uint32_t crc32c) >> #endif >> return (crc32c); >> } >> + >> #else >> uint32_t >> -update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int >> length) { >> - >> +update_crc32(uint32_t crc32c, unsigned char *buffer, unsigned int >> length) >> +{ >> return (0); >> } >> >> @@ -741,6 +742,7 @@ sctp_finalize_crc32(uint32_t crc32c) >> { >> return (0); >> } >> + >> #endif /* !defined(SCTP_WITH_NO_CSUM) */ >> >> #if defined(SCTP_WITH_NO_CSUM) > > > What would you say about this? (I do not have SCTP option in the > kernel config) > > linking kernel.debug > alias_sctp.o(.text+0x1744): In function `TxAbortErrorM': > /work/pub/head/sys/netinet/libalias/alias_sctp.c:946: undefined > reference to `update_crc32' > alias_sctp.o(.text+0x174b):/work/pub/head/sys/netinet/libalias/ > alias_sctp.c:946: undefined reference to `sctp_finalize_crc32' > *** Error code 1 > > Stop in /tank/obj/work/pub/head/sys/YOY. > *** Error code 1 > > > -- > Have fun! > chd > ------------------------------ Randall Stewart 803-317-4952 (cell) 803-345-0391(direct) From fjoe at FreeBSD.org Mon Feb 9 08:53:38 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Mon Feb 9 08:53:50 2009 Subject: svn commit: r188392 - head/sys/pci Message-ID: <200902091653.n19GrbIB065499@svn.freebsd.org> Author: fjoe Date: Mon Feb 9 16:53:37 2009 New Revision: 188392 URL: http://svn.freebsd.org/changeset/base/188392 Log: Destroy TX tag outside of loop scope. Found with: Coverity Prevent(tm) CID: 3886 Modified: head/sys/pci/if_rl.c Modified: head/sys/pci/if_rl.c ============================================================================== --- head/sys/pci/if_rl.c Mon Feb 9 15:55:21 2009 (r188391) +++ head/sys/pci/if_rl.c Mon Feb 9 16:53:37 2009 (r188392) @@ -1151,9 +1151,9 @@ rl_dma_free(struct rl_softc *sc) sc->rl_cdata.rl_tx_dmamap[i]); sc->rl_cdata.rl_tx_dmamap[i] = NULL; } + } bus_dma_tag_destroy(sc->rl_cdata.rl_tx_tag); sc->rl_cdata.rl_tx_tag = NULL; - } } if (sc->rl_parent_tag != NULL) { From fjoe at FreeBSD.org Mon Feb 9 08:57:09 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Mon Feb 9 08:57:16 2009 Subject: svn commit: r188393 - head/sys/dev/firewire Message-ID: <200902091657.n19Gv7sY065623@svn.freebsd.org> Author: fjoe Date: Mon Feb 9 16:57:07 2009 New Revision: 188393 URL: http://svn.freebsd.org/changeset/base/188393 Log: Remove unused variable. Found with: Coverity Prevent(tm) CID: 3693 Modified: head/sys/dev/firewire/sbp.c Modified: head/sys/dev/firewire/sbp.c ============================================================================== --- head/sys/dev/firewire/sbp.c Mon Feb 9 16:53:37 2009 (r188392) +++ head/sys/dev/firewire/sbp.c Mon Feb 9 16:57:07 2009 (r188393) @@ -330,12 +330,11 @@ static char *orb_status1_serial_bus_erro static void sbp_identify(driver_t *driver, device_t parent) { - device_t child; SBP_DEBUG(0) printf("sbp_identify\n"); END_DEBUG - child = BUS_ADD_CHILD(parent, 0, "sbp", device_get_unit(parent)); + BUS_ADD_CHILD(parent, 0, "sbp", device_get_unit(parent)); } /* From fjoe at FreeBSD.org Mon Feb 9 08:58:21 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Mon Feb 9 08:58:27 2009 Subject: svn commit: r188394 - head/sys/dev/firewire Message-ID: <200902091658.n19GwIOk065678@svn.freebsd.org> Author: fjoe Date: Mon Feb 9 16:58:18 2009 New Revision: 188394 URL: http://svn.freebsd.org/changeset/base/188394 Log: Do not self-initialize a variable. Found with: Coverity Prevent(tm) CID: 3864, 3865 Modified: head/sys/dev/firewire/if_fwe.c head/sys/dev/firewire/if_fwip.c Modified: head/sys/dev/firewire/if_fwe.c ============================================================================== --- head/sys/dev/firewire/if_fwe.c Mon Feb 9 16:57:07 2009 (r188393) +++ head/sys/dev/firewire/if_fwe.c Mon Feb 9 16:58:18 2009 (r188394) @@ -445,7 +445,7 @@ fwe_ioctl(struct ifnet *ifp, u_long cmd, #ifdef DEVICE_POLLING { struct ifreq *ifr = (struct ifreq *) data; - struct firewire_comm *fc = fc = fwe->fd.fc; + struct firewire_comm *fc = fwe->fd.fc; if (ifr->ifr_reqcap & IFCAP_POLLING && !(ifp->if_capenable & IFCAP_POLLING)) { Modified: head/sys/dev/firewire/if_fwip.c ============================================================================== --- head/sys/dev/firewire/if_fwip.c Mon Feb 9 16:57:07 2009 (r188393) +++ head/sys/dev/firewire/if_fwip.c Mon Feb 9 16:58:18 2009 (r188394) @@ -427,7 +427,7 @@ fwip_ioctl(struct ifnet *ifp, u_long cmd #ifdef DEVICE_POLLING { struct ifreq *ifr = (struct ifreq *) data; - struct firewire_comm *fc = fc = fwip->fd.fc; + struct firewire_comm *fc = fwip->fd.fc; if (ifr->ifr_reqcap & IFCAP_POLLING && !(ifp->if_capenable & IFCAP_POLLING)) { From gary.jennejohn at freenet.de Mon Feb 9 09:02:35 2009 From: gary.jennejohn at freenet.de (Gary Jennejohn) Date: Mon Feb 9 09:02:46 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <200902082254.n18MsxVt037307@svn.freebsd.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> Message-ID: <20090209180230.66841d6e@ernst.jennejohn.org> On Sun, 8 Feb 2009 22:54:58 +0000 (UTC) Warner Losh wrote: > Author: imp > Date: Sun Feb 8 22:54:58 2009 > New Revision: 188350 > URL: http://svn.freebsd.org/changeset/base/188350 > > Log: > When bouncing pages, allow a new option to preserve the intra-page > offset. This is needed for the ehci hardware buffer rings that assume > this behavior. > [big snip] This fixes things for me with AMD64 and 6GB of RAM. Thanks! --- Gary Jennejohn From fjoe at FreeBSD.org Mon Feb 9 09:02:54 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Mon Feb 9 09:03:01 2009 Subject: svn commit: r188395 - head/sys/cam Message-ID: <200902091702.n19H2sdt065875@svn.freebsd.org> Author: fjoe Date: Mon Feb 9 17:02:54 2009 New Revision: 188395 URL: http://svn.freebsd.org/changeset/base/188395 Log: cam_periph_alloc: fix "invalid periph name" error condition Found with: Coverity Prevent(tm) CID: 130 Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Mon Feb 9 16:58:18 2009 (r188394) +++ head/sys/cam/cam_periph.c Mon Feb 9 17:02:54 2009 (r188395) @@ -171,7 +171,7 @@ cam_periph_alloc(periph_ctor_t *periph_c break; } xpt_unlock_buses(); - if (p_drv == NULL) { + if (*p_drv == NULL) { printf("cam_periph_alloc: invalid periph name '%s'\n", name); return (CAM_REQ_INVALID); } From fjoe at FreeBSD.org Mon Feb 9 09:07:30 2009 From: fjoe at FreeBSD.org (Max Khon) Date: Mon Feb 9 09:07:39 2009 Subject: svn commit: r188396 - head/sys/dev/de Message-ID: <200902091707.n19H7T64066041@svn.freebsd.org> Author: fjoe Date: Mon Feb 9 17:07:29 2009 New Revision: 188396 URL: http://svn.freebsd.org/changeset/base/188396 Log: tulip_busdma_cleanup: pass correct vaddr (2nd arg) to bus_dmamem_free() Found with: Coverity Prevent(tm) CID: 1998 Modified: head/sys/dev/de/if_de.c Modified: head/sys/dev/de/if_de.c ============================================================================== --- head/sys/dev/de/if_de.c Mon Feb 9 17:02:54 2009 (r188395) +++ head/sys/dev/de/if_de.c Mon Feb 9 17:07:29 2009 (r188396) @@ -4561,7 +4561,7 @@ tulip_busdma_cleanup(tulip_softc_t * con sc->tulip_setup_dma_addr = 0; } if (sc->tulip_setupbuf != NULL) { - bus_dmamem_free(sc->tulip_setup_tag, sc->tulip_setupdata, + bus_dmamem_free(sc->tulip_setup_tag, sc->tulip_setupbuf, sc->tulip_setup_map); sc->tulip_setup_map = NULL; sc->tulip_setupbuf = NULL; From gary.jennejohn at freenet.de Mon Feb 9 09:11:00 2009 From: gary.jennejohn at freenet.de (Gary Jennejohn) Date: Mon Feb 9 09:11:06 2009 Subject: svn commit: r188381 - head/sys/dev/re In-Reply-To: <200902090459.n194xDa3045928@svn.freebsd.org> References: <200902090459.n194xDa3045928@svn.freebsd.org> Message-ID: <20090209181056.40db0ba2@ernst.jennejohn.org> On Mon, 9 Feb 2009 04:59:13 +0000 (UTC) Pyun YongHyeon wrote: > Author: yongari > Date: Mon Feb 9 04:59:13 2009 > New Revision: 188381 > URL: http://svn.freebsd.org/changeset/base/188381 > > Log: > Reclaim transmitted frames in re_tick(). This is for PCIe > controllers that lose Tx completion interrupts under certain > conditions. With this change it's safe to use MSI on PCIe > controllers so enable MSI on these controllers. > > Modified: > head/sys/dev/re/if_re.c > This does not work with my re(4). When I allow MSI it never transmits. I noticed this while booting when the sendmail startup hung. A test with ping(8) showed that there was no output (or maybe no input, hard to tell with ping). Here dmesg output when it fails: re0: port 0xde00-0xdeff mem 0xfdaff000-0xfdafffff,0xfdae0000-0xfdaeffff irq 18 at device 0.0 on pci2 re0: Using 2 MSI messages re0: Chip rev. 0x3c000000 re0: MAC rev. 0x00400000 re0: Ethernet address: 00:1f:d0:8f:5a:43 re0: [FILTER] re0: [FILTER] re0: link state changed to UP Here dmesg output when it succeeds: re0: port 0xde00-0xdeff mem 0xfdaff000-0xfdafffff,0xfdae0000-0xfdaeffff irq 18 at device 0.0 on pci2 re0: turning off MSI enable bit. re0: Chip rev. 0x3c000000 re0: MAC rev. 0x00400000 re0: Ethernet address: 00:1f:d0:8f:5a:43 re0: [FILTER] re0: link state changed to UP And here pciconf output: re0@pci0:2:0:0: class=0x020000 card=0xe0001458 chip=0x816810ec rev=0x02 hdr=0x00 vendor = 'Realtek Semiconductor' device = 'RTL8168/8111 PCI-E Gigabit Ethernet NIC' class = network subclass = ethernet --- Gary Jennejohn From rrs at FreeBSD.org Mon Feb 9 09:37:17 2009 From: rrs at FreeBSD.org (Randall Stewart) Date: Mon Feb 9 09:37:29 2009 Subject: svn commit: r188398 - head/sys/netinet Message-ID: <200902091737.n19HbH8i066666@svn.freebsd.org> Author: rrs Date: Mon Feb 9 17:37:17 2009 New Revision: 188398 URL: http://svn.freebsd.org/changeset/base/188398 Log: Add padding to then end of the xsctp_xxx structures to allow future changes to be able to maintain ABI compatibility Modified: head/sys/netinet/sctp_uio.h Modified: head/sys/netinet/sctp_uio.h ============================================================================== --- head/sys/netinet/sctp_uio.h Mon Feb 9 17:14:49 2009 (r188397) +++ head/sys/netinet/sctp_uio.h Mon Feb 9 17:37:17 2009 (r188398) @@ -987,6 +987,7 @@ struct xsctp_inpcb { uint16_t local_port; uint16_t qlen; uint16_t maxqlen; + uint32_t extra_padding[8]; /* future */ }; struct xsctp_tcb { @@ -1017,12 +1018,14 @@ struct xsctp_tcb { struct sctp_timeval start_time; /* sctpAssocEntry 16 */ struct sctp_timeval discontinuity_time; /* sctpAssocEntry 17 */ sctp_assoc_t assoc_id; /* sctpAssocEntry 1 */ + uint32_t extra_padding[8]; /* future */ }; struct xsctp_laddr { union sctp_sockstore address; /* sctpAssocLocalAddrEntry 1/2 */ uint32_t last; struct sctp_timeval start_time; /* sctpAssocLocalAddrEntry 3 */ + uint32_t extra_padding[8]; /* future */ }; struct xsctp_raddr { @@ -1039,6 +1042,7 @@ struct xsctp_raddr { uint8_t confirmed; /* */ uint8_t heartbeat_enabled; /* sctpAssocLocalRemEntry 4 */ struct sctp_timeval start_time; /* sctpAssocLocalRemEntry 8 */ + uint32_t extra_padding[8]; /* future */ }; #define SCTP_MAX_LOGGING_SIZE 30000 From xcllnt at mac.com Mon Feb 9 09:48:59 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Mon Feb 9 09:49:11 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <49903E4A.8000408@samsco.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <9E40268E-A2E2-4CAA-AAFE-EB2491175CEE@mac.com> <20090208.170515.1031215309.imp@bsdimp.com> <34EFBA0C-FB99-42DB-BF5C-A889348AD393@mac.com> <498F8015.8000704@samsco.org> <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> <49903E4A.8000408@samsco.org> Message-ID: <859425A6-0F8F-4DE5-9229-4119A1009AD2@mac.com> On Feb 9, 2009, at 6:31 AM, Scott Long wrote: > Marcel Moolenaar wrote: >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: >>> Busdma allows you to request bouncing for realignment. >> How exactly? > > By specifying an alignment greater than 1 in the tag. This does not guarantee bounce buffering and without bounce buffering you don't have realignment. -- Marcel Moolenaar xcllnt@mac.com From xcllnt at mac.com Mon Feb 9 09:51:54 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Mon Feb 9 09:52:05 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <200902090923.45887.jhb@freebsd.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <498F8015.8000704@samsco.org> <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> <200902090923.45887.jhb@freebsd.org> Message-ID: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: >> >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: >> >>> Busdma allows you to request bouncing for realignment. >> >> How exactly? > > The 'align' parameter to bus_dma_tag_create(). If your hardware > needs buffers > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer > where 'addr % 4 != 0', then the buffer is bounced. Since by default > the new > buffer starts on a page boundary, it satifies the 'addr % 4'. But according to the man page, bounce buffering may not be implemented or not be applicable to a platform. It seems to me that you cannot depend on this side-effect in a generic driver. Are you guys talking only in terms of i386 or is this generally applicable? -- Marcel Moolenaar xcllnt@mac.com From cognet at FreeBSD.org Mon Feb 9 10:03:33 2009 From: cognet at FreeBSD.org (Olivier Houchard) Date: Mon Feb 9 10:03:45 2009 Subject: svn commit: r188403 - in head/sys: amd64/amd64 arm/arm i386/i386 Message-ID: <200902091803.n19I3W4T067382@svn.freebsd.org> Author: cognet Date: Mon Feb 9 18:03:31 2009 New Revision: 188403 URL: http://svn.freebsd.org/changeset/base/188403 Log: The bounce zone sees its page number increased if multiple dma maps use it in the same dma tag. However, it can happen multiple dma tags share the same bounce zone too, so add a per-bounce zone map counter, and check it instead of the dma tag map counter, to know if we have to alloc more pages. Reported by: miwi Reviewed by: scottl Modified: head/sys/amd64/amd64/busdma_machdep.c head/sys/arm/arm/busdma_machdep.c head/sys/i386/i386/busdma_machdep.c Modified: head/sys/amd64/amd64/busdma_machdep.c ============================================================================== --- head/sys/amd64/amd64/busdma_machdep.c Mon Feb 9 18:01:54 2009 (r188402) +++ head/sys/amd64/amd64/busdma_machdep.c Mon Feb 9 18:03:31 2009 (r188403) @@ -93,6 +93,7 @@ struct bounce_zone { int active_bpages; int total_bounced; int total_deferred; + int map_count; bus_size_t alignment; bus_size_t boundary; bus_addr_t lowaddr; @@ -418,7 +419,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in else maxpages = MIN(MAX_BPAGES, Maxmem -atop(dmat->lowaddr)); if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 - || (dmat->map_count > 0 && bz->total_bpages < maxpages)) { + || (bz->map_count > 0 && bz->total_bpages < maxpages)) { int pages; pages = MAX(atop(dmat->maxsize), 1); @@ -434,6 +435,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in error = 0; } } + bz->map_count++; } else { *mapp = NULL; } @@ -457,6 +459,8 @@ bus_dmamap_destroy(bus_dma_tag_t dmat, b __func__, dmat, EBUSY); return (EBUSY); } + if (dmat->bounce_zone) + dmat->bounce_zone->map_count--; free(map, M_DEVBUF); } dmat->map_count--; @@ -989,6 +993,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat) bz->lowaddr = dmat->lowaddr; bz->alignment = dmat->alignment; bz->boundary = dmat->boundary; + bz->map_count = 0; snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount); busdma_zonecount++; snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr); Modified: head/sys/arm/arm/busdma_machdep.c ============================================================================== --- head/sys/arm/arm/busdma_machdep.c Mon Feb 9 18:01:54 2009 (r188402) +++ head/sys/arm/arm/busdma_machdep.c Mon Feb 9 18:03:31 2009 (r188403) @@ -112,6 +112,7 @@ struct bounce_zone { int active_bpages; int total_bounced; int total_deferred; + int map_count; bus_size_t alignment; bus_size_t boundary; bus_addr_t lowaddr; @@ -523,7 +524,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in */ maxpages = MAX_BPAGES; if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 - || (dmat->map_count > 0 && bz->total_bpages < maxpages)) { + || (bz->map_count > 0 && bz->total_bpages < maxpages)) { int pages; pages = MAX(atop(dmat->maxsize), 1); @@ -539,6 +540,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in error = 0; } } + bz->map_count++; } CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", __func__, dmat, dmat->flags, error); @@ -560,6 +562,8 @@ bus_dmamap_destroy(bus_dma_tag_t dmat, b __func__, dmat, EBUSY); return (EBUSY); } + if (dmat->bounce_zone) + dmat->bounce_zone->map_count--; dmat->map_count--; CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat); return (0); @@ -1277,6 +1281,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat) bz->lowaddr = dmat->lowaddr; bz->alignment = dmat->alignment; bz->boundary = dmat->boundary; + bz->map_count = 0; snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount); busdma_zonecount++; snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr); Modified: head/sys/i386/i386/busdma_machdep.c ============================================================================== --- head/sys/i386/i386/busdma_machdep.c Mon Feb 9 18:01:54 2009 (r188402) +++ head/sys/i386/i386/busdma_machdep.c Mon Feb 9 18:03:31 2009 (r188403) @@ -98,6 +98,7 @@ struct bounce_zone { int active_bpages; int total_bounced; int total_deferred; + int map_count; bus_size_t alignment; bus_size_t boundary; bus_addr_t lowaddr; @@ -431,7 +432,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in else maxpages = MIN(MAX_BPAGES, Maxmem -atop(dmat->lowaddr)); if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 - || (dmat->map_count > 0 && bz->total_bpages < maxpages)) { + || (bz->map_count > 0 && bz->total_bpages < maxpages)) { int pages; pages = MAX(atop(dmat->maxsize), 1); @@ -447,6 +448,7 @@ bus_dmamap_create(bus_dma_tag_t dmat, in error = 0; } } + bz->map_count++; } else { *mapp = NULL; } @@ -470,6 +472,8 @@ bus_dmamap_destroy(bus_dma_tag_t dmat, b __func__, dmat, EBUSY); return (EBUSY); } + if (dmat->bounce_zone) + dmat->bounce_zone->map_count--; free(map, M_DEVBUF); } dmat->map_count--; @@ -1007,6 +1011,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat) bz->lowaddr = dmat->lowaddr; bz->alignment = dmat->alignment; bz->boundary = dmat->boundary; + bz->map_count = 0; snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount); busdma_zonecount++; snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr); From rwatson at FreeBSD.org Mon Feb 9 10:19:59 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Mon Feb 9 10:20:10 2009 Subject: svn commit: r188404 - head/sys/kern Message-ID: <200902091819.n19IJwJX067749@svn.freebsd.org> Author: rwatson Date: Mon Feb 9 18:19:58 2009 New Revision: 188404 URL: http://svn.freebsd.org/changeset/base/188404 Log: Remove extra 'comma = 0' in socket state printing code, which otherwise could lead to an extra comma in output. Submitted by: Christoph Mallon Modified: head/sys/kern/uipc_debug.c Modified: head/sys/kern/uipc_debug.c ============================================================================== --- head/sys/kern/uipc_debug.c Mon Feb 9 18:03:31 2009 (r188403) +++ head/sys/kern/uipc_debug.c Mon Feb 9 18:19:58 2009 (r188404) @@ -172,7 +172,6 @@ db_print_sostate(short so_state) db_printf("%sSS_ISCONFIRMING", comma ? ", " : ""); comma = 1; } - comma = 0; if (so_state & SS_PROTOREF) { db_printf("%sSS_PROTOREF", comma ? ", " : ""); comma = 1; From imp at bsdimp.com Mon Feb 9 10:33:31 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Mon Feb 9 10:33:43 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> References: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> Message-ID: <20090209.113053.65361811.imp@bsdimp.com> In message: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> Marcel Moolenaar writes: : : On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: : : > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: : >> : >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: : >> : >>> Busdma allows you to request bouncing for realignment. : >> : >> How exactly? : > : > The 'align' parameter to bus_dma_tag_create(). If your hardware : > needs buffers : > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer : > where 'addr % 4 != 0', then the buffer is bounced. Since by default : > the new : > buffer starts on a page boundary, it satifies the 'addr % 4'. : : But according to the man page, bounce buffering may not : be implemented or not be applicable to a platform. It : seems to me that you cannot depend on this side-effect : in a generic driver. Are you guys talking only in terms : of i386 or is this generally applicable? There's no bounce buffering on MIPS right now, for example... There likely should be, but it isn't there now. Warner From jhb at freebsd.org Mon Feb 9 10:43:44 2009 From: jhb at freebsd.org (John Baldwin) Date: Mon Feb 9 10:43:55 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> Message-ID: <200902091342.16078.jhb@freebsd.org> On Monday 09 February 2009 12:51:28 pm Marcel Moolenaar wrote: > > On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: > > > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: > >> > >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > >> > >>> Busdma allows you to request bouncing for realignment. > >> > >> How exactly? > > > > The 'align' parameter to bus_dma_tag_create(). If your hardware > > needs buffers > > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer > > where 'addr % 4 != 0', then the buffer is bounced. Since by default > > the new > > buffer starts on a page boundary, it satifies the 'addr % 4'. > > But according to the man page, bounce buffering may not > be implemented or not be applicable to a platform. It > seems to me that you cannot depend on this side-effect > in a generic driver. Are you guys talking only in terms > of i386 or is this generally applicable? All of the platforms that do bounce buffering will honor this. If a given platform doesn't support bounce buffering then I imagine it will fail misaligned requests with an error. It would probably make it easier to support bounce buffering on more platforms if some of the support code for managing bounce zones could be moved into a subr_busdma.c or the like since much of it is copy and pasted. -- John Baldwin From scottl at samsco.org Mon Feb 9 10:51:37 2009 From: scottl at samsco.org (Scott Long) Date: Mon Feb 9 10:51:49 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <20090209.113053.65361811.imp@bsdimp.com> References: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <20090209.113053.65361811.imp@bsdimp.com> Message-ID: <49907B32.8080307@samsco.org> M. Warner Losh wrote: > In message: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> > Marcel Moolenaar writes: > : > : On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: > : > : > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: > : >> > : >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > : >> > : >>> Busdma allows you to request bouncing for realignment. > : >> > : >> How exactly? > : > > : > The 'align' parameter to bus_dma_tag_create(). If your hardware > : > needs buffers > : > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer > : > where 'addr % 4 != 0', then the buffer is bounced. Since by default > : > the new > : > buffer starts on a page boundary, it satifies the 'addr % 4'. > : > : But according to the man page, bounce buffering may not > : be implemented or not be applicable to a platform. It > : seems to me that you cannot depend on this side-effect > : in a generic driver. Are you guys talking only in terms > : of i386 or is this generally applicable? > > There's no bounce buffering on MIPS right now, for example... There > likely should be, but it isn't there now. > > Warner So yes, it's only available really on amd64 and i386 at the moment. No reason why it can't be available elsewhere, and I'm working on factoring all of the bounce logic out into an MD file so it can be made available. For architectures that use an IOMMU, there's probably no reason why re-alignment can't use the IOMMU instead of bouncing. Scott From imp at bsdimp.com Mon Feb 9 11:00:45 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Mon Feb 9 11:00:56 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <49907B32.8080307@samsco.org> References: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <20090209.113053.65361811.imp@bsdimp.com> <49907B32.8080307@samsco.org> Message-ID: <20090209.115932.1098202471.imp@bsdimp.com> In message: <49907B32.8080307@samsco.org> Scott Long writes: : M. Warner Losh wrote: : > In message: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> : > Marcel Moolenaar writes: : > : : > : On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: : > : : > : > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: : > : >> : > : >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: : > : >> : > : >>> Busdma allows you to request bouncing for realignment. : > : >> : > : >> How exactly? : > : > : > : > The 'align' parameter to bus_dma_tag_create(). If your hardware : > : > needs buffers : > : > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer : > : > where 'addr % 4 != 0', then the buffer is bounced. Since by default : > : > the new : > : > buffer starts on a page boundary, it satifies the 'addr % 4'. : > : : > : But according to the man page, bounce buffering may not : > : be implemented or not be applicable to a platform. It : > : seems to me that you cannot depend on this side-effect : > : in a generic driver. Are you guys talking only in terms : > : of i386 or is this generally applicable? : > : > There's no bounce buffering on MIPS right now, for example... There : > likely should be, but it isn't there now. : > : > Warner : : So yes, it's only available really on amd64 and i386 at the moment. No : reason why it can't be available elsewhere, and I'm working on factoring : all of the bounce logic out into an MD file so it can be made available. : For architectures that use an IOMMU, there's probably no reason why : re-alignment can't use the IOMMU instead of bouncing. arm also does bounce buffering, but not for memory address space reasons. Warner From sam at freebsd.org Mon Feb 9 11:01:03 2009 From: sam at freebsd.org (Sam Leffler) Date: Mon Feb 9 11:01:09 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <49907B32.8080307@samsco.org> References: <94616FBD-4638-4C51-990C-06A943B1BA2A@mac.com> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <20090209.113053.65361811.imp@bsdimp.com> <49907B32.8080307@samsco.org> Message-ID: <49907D66.9010405@freebsd.org> Scott Long wrote: > M. Warner Losh wrote: >> In message: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> >> Marcel Moolenaar writes: >> : : On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: >> : : > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: >> : >> >> : >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: >> : >> >> : >>> Busdma allows you to request bouncing for realignment. >> : >> >> : >> How exactly? >> : > >> : > The 'align' parameter to bus_dma_tag_create(). If your hardware >> : > needs buffers >> : > to be aligned on a 4-byte boundary and you bus_dmamap_load() a >> buffer >> : > where 'addr % 4 != 0', then the buffer is bounced. Since by >> default : > the new >> : > buffer starts on a page boundary, it satifies the 'addr % 4'. >> : : But according to the man page, bounce buffering may not >> : be implemented or not be applicable to a platform. It >> : seems to me that you cannot depend on this side-effect >> : in a generic driver. Are you guys talking only in terms >> : of i386 or is this generally applicable? >> >> There's no bounce buffering on MIPS right now, for example... There >> likely should be, but it isn't there now. >> >> Warner > > So yes, it's only available really on amd64 and i386 at the moment. > No reason why it can't be available elsewhere, and I'm working on > factoring > all of the bounce logic out into an MD file so it can be made available. > For architectures that use an IOMMU, there's probably no reason why > re-alignment can't use the IOMMU instead of bouncing. ARM does bounce buffers. Looks like it'll bounce for mis-aligned data. Sam From sam at freebsd.org Mon Feb 9 11:10:43 2009 From: sam at freebsd.org (Sam Leffler) Date: Mon Feb 9 11:10:52 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <20090209.115932.1098202471.imp@bsdimp.com> References: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <20090209.113053.65361811.imp@bsdimp.com> <49907B32.8080307@samsco.org> <20090209.115932.1098202471.imp@bsdimp.com> Message-ID: <49907FB0.9050901@freebsd.org> M. Warner Losh wrote: > In message: <49907B32.8080307@samsco.org> > Scott Long writes: > : M. Warner Losh wrote: > : > In message: <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> > : > Marcel Moolenaar writes: > : > : > : > : On Feb 9, 2009, at 6:23 AM, John Baldwin wrote: > : > : > : > : > On Monday 09 February 2009 12:37:53 am Marcel Moolenaar wrote: > : > : >> > : > : >> On Feb 8, 2009, at 5:00 PM, Scott Long wrote: > : > : >> > : > : >>> Busdma allows you to request bouncing for realignment. > : > : >> > : > : >> How exactly? > : > : > > : > : > The 'align' parameter to bus_dma_tag_create(). If your hardware > : > : > needs buffers > : > : > to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer > : > : > where 'addr % 4 != 0', then the buffer is bounced. Since by default > : > : > the new > : > : > buffer starts on a page boundary, it satifies the 'addr % 4'. > : > : > : > : But according to the man page, bounce buffering may not > : > : be implemented or not be applicable to a platform. It > : > : seems to me that you cannot depend on this side-effect > : > : in a generic driver. Are you guys talking only in terms > : > : of i386 or is this generally applicable? > : > > : > There's no bounce buffering on MIPS right now, for example... There > : > likely should be, but it isn't there now. > : > > : > Warner > : > : So yes, it's only available really on amd64 and i386 at the moment. No > : reason why it can't be available elsewhere, and I'm working on factoring > : all of the bounce logic out into an MD file so it can be made available. > : For architectures that use an IOMMU, there's probably no reason why > : re-alignment can't use the IOMMU instead of bouncing. > > arm also does bounce buffering, but not for memory address space reasons. > Not sure what you mean my "address space reasons" but it bounces for PCI dma above 64M on ixp4xx. Sam From xcllnt at mac.com Mon Feb 9 11:18:36 2009 From: xcllnt at mac.com (Marcel Moolenaar) Date: Mon Feb 9 11:18:42 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <200902091342.16078.jhb@freebsd.org> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <200902091342.16078.jhb@freebsd.org> Message-ID: <0AA26479-B36A-4412-BF2B-7D4C573BC266@mac.com> On Feb 9, 2009, at 10:42 AM, John Baldwin wrote: >>> The 'align' parameter to bus_dma_tag_create(). If your hardware >>> needs buffers >>> to be aligned on a 4-byte boundary and you bus_dmamap_load() a >>> buffer >>> where 'addr % 4 != 0', then the buffer is bounced. Since by default >>> the new >>> buffer starts on a page boundary, it satifies the 'addr % 4'. >> >> But according to the man page, bounce buffering may not >> be implemented or not be applicable to a platform. It >> seems to me that you cannot depend on this side-effect >> in a generic driver. Are you guys talking only in terms >> of i386 or is this generally applicable? > > All of the platforms that do bounce buffering will honor this. If a > given > platform doesn't support bounce buffering then I imagine it will fail > misaligned requests with an error. It would probably make it easier > to > support bounce buffering on more platforms if some of the support > code for > managing bounce zones could be moved into a subr_busdma.c or the > like since > much of it is copy and pasted. Very much agreed with the unification in subr_busdma.c. If the shared implementation then grows a IOMMU interface, then platforms with a IOMMU can avoid bounce buffering when possible (i.e. no re-alignment is needed or enough free IOMMU mappings exist to avoid the bounce buffering). -- Marcel Moolenaar xcllnt@mac.com From scottl at samsco.org Mon Feb 9 11:20:10 2009 From: scottl at samsco.org (Scott Long) Date: Mon Feb 9 11:20:17 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <0AA26479-B36A-4412-BF2B-7D4C573BC266@mac.com> References: <200902082254.n18MsxVt037307@svn.freebsd.org> <200902090923.45887.jhb@freebsd.org> <2EA5FEEB-E676-4D1B-9700-399C783F4590@mac.com> <200902091342.16078.jhb@freebsd.org> <0AA26479-B36A-4412-BF2B-7D4C573BC266@mac.com> Message-ID: <499081E3.9050009@samsco.org> Marcel Moolenaar wrote: > > On Feb 9, 2009, at 10:42 AM, John Baldwin wrote: > >>>> The 'align' parameter to bus_dma_tag_create(). If your hardware >>>> needs buffers >>>> to be aligned on a 4-byte boundary and you bus_dmamap_load() a buffer >>>> where 'addr % 4 != 0', then the buffer is bounced. Since by default >>>> the new >>>> buffer starts on a page boundary, it satifies the 'addr % 4'. >>> >>> But according to the man page, bounce buffering may not >>> be implemented or not be applicable to a platform. It >>> seems to me that you cannot depend on this side-effect >>> in a generic driver. Are you guys talking only in terms >>> of i386 or is this generally applicable? >> >> All of the platforms that do bounce buffering will honor this. If a >> given >> platform doesn't support bounce buffering then I imagine it will fail >> misaligned requests with an error. It would probably make it easier to >> support bounce buffering on more platforms if some of the support code >> for >> managing bounce zones could be moved into a subr_busdma.c or the like >> since >> much of it is copy and pasted. > > Very much agreed with the unification in subr_busdma.c. > > If the shared implementation then grows a IOMMU interface, > then platforms with a IOMMU can avoid bounce buffering > when possible (i.e. no re-alignment is needed or enough > free IOMMU mappings exist to avoid the bounce buffering). > Yes, this work in progress. Scott From imp at bsdimp.com Mon Feb 9 11:24:38 2009 From: imp at bsdimp.com (M. Warner Losh) Date: Mon Feb 9 11:24:49 2009 Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys In-Reply-To: <49907FB0.9050901@freebsd.org> References: <49907B32.8080307@samsco.org> <20090209.115932.1098202471.imp@bsdimp.com> <49907FB0.9050901@freebsd.org> Message-ID: <20090209.122220.-1691636592.imp@bsdimp.com> In message: <49907FB0.9050901@freebsd.org> Sam Leffler writes: : M. Warner Losh wrote: : > arm also does bounce buffering, but not for memory address space reasons. : > : : Not sure what you mean my "address space reasons" but it bounces for PCI : dma above 64M on ixp4xx. That's exactly what I mean. Warner From lulf at FreeBSD.org Mon Feb 9 12:13:58 2009 From: lulf at FreeBSD.org (Ulf Lilleengen) Date: Mon Feb 9 12:14:10 2009 Subject: svn commit: r188405 - head/contrib/csup Message-ID: <200902092013.n19KDuAF070009@svn.freebsd.org> Author: lulf Date: Mon Feb 9 20:13:55 2009 New Revision: 188405 URL: http://svn.freebsd.org/changeset/base/188405 Log: - Fix an issue where file attributes were not installed correctly during a Touch and SetAttrs operation. - SetAttrs and Touch were incorrectly switched. Modified: head/contrib/csup/updater.c Modified: head/contrib/csup/updater.c ============================================================================== --- head/contrib/csup/updater.c Mon Feb 9 18:19:58 2009 (r188404) +++ head/contrib/csup/updater.c Mon Feb 9 20:13:55 2009 (r188405) @@ -1656,10 +1656,12 @@ updater_rcsedit(struct updater *up, stru if (rf == NULL) { fattr_maskout(oldfattr, ~FA_MODTIME); - if (fattr_equal(oldfattr, sr->sr_serverattr) == 0) + if (fattr_equal(oldfattr, sr->sr_serverattr)) lprintf(1, " SetAttrs %s", fup->coname); else lprintf(1, " Touch %s", fup->coname); + /* Install new attributes. */ + fattr_install(sr->sr_serverattr, fup->destpath, NULL); if (fup->attic) lprintf(1, " -> Attic"); lprintf(1, "\n"); From jhb at FreeBSD.org Mon Feb 9 12:42:52 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Feb 9 12:43:03 2009 Subject: svn commit: r188406 - head/sys/fs/udf Message-ID: <200902092042.n19KgpbY070604@svn.freebsd.org> Author: jhb Date: Mon Feb 9 20:42:51 2009 New Revision: 188406 URL: http://svn.freebsd.org/changeset/base/188406 Log: Use the same style as the rest of the file for the optional data string after each path component rather than a GCC-ism. Modified: head/sys/fs/udf/ecma167-udf.h Modified: head/sys/fs/udf/ecma167-udf.h ============================================================================== --- head/sys/fs/udf/ecma167-udf.h Mon Feb 9 20:13:55 2009 (r188405) +++ head/sys/fs/udf/ecma167-udf.h Mon Feb 9 20:42:51 2009 (r188406) @@ -359,7 +359,7 @@ struct path_component { uint8_t type; uint8_t length; uint16_t version; - uint8_t identifier[0]; + uint8_t identifier[1]; } __packed; #define UDF_PATH_ROOT 2 #define UDF_PATH_DOTDOT 3 From jhb at FreeBSD.org Mon Feb 9 12:50:24 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Feb 9 12:50:37 2009 Subject: svn commit: r188407 - head/sys/fs/udf Message-ID: <200902092050.n19KoN3X070776@svn.freebsd.org> Author: jhb Date: Mon Feb 9 20:50:23 2009 New Revision: 188407 URL: http://svn.freebsd.org/changeset/base/188407 Log: Mark udf(4) MPSAFE and add support for shared vnode locks during pathname lookups: - Honor the caller's locking flags in udf_root() and udf_vget(). - Set VV_ROOT for the root vnode in udf_vget() instead of only doing it in udf_root(). - Honor the requested locking flags during pathname lookups in udf_lookup(). - Release the buffer holding the directory data before looking up the vnode for a given file to avoid a LOR between the "udf" vnode locks and "bufwait". - Use vn_vget_ino() to handle ".." lookups. - Special case "." lookups instead of calling udf_vget(). We have to do extra checking for the vnode lock for "." lookups. Modified: head/sys/fs/udf/udf_vfsops.c head/sys/fs/udf/udf_vnops.c Modified: head/sys/fs/udf/udf_vfsops.c ============================================================================== --- head/sys/fs/udf/udf_vfsops.c Mon Feb 9 20:42:51 2009 (r188406) +++ head/sys/fs/udf/udf_vfsops.c Mon Feb 9 20:50:23 2009 (r188407) @@ -344,6 +344,7 @@ udf_mountfs(struct vnode *devvp, struct mp->mnt_stat.f_fsid.val[1] = mp->mnt_vfc->vfc_typenum; MNT_ILOCK(mp); mp->mnt_flag |= MNT_LOCAL; + mp->mnt_kern_flag |= MNTK_MPSAFE | MNTK_LOOKUP_SHARED; MNT_IUNLOCK(mp); udfmp->im_mountp = mp; udfmp->im_dev = devvp->v_rdev; @@ -546,22 +547,13 @@ static int udf_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) { struct udf_mnt *udfmp; - struct vnode *vp; ino_t id; - int error; udfmp = VFSTOUDFFS(mp); id = udf_getid(&udfmp->root_icb); - error = udf_vget(mp, id, LK_EXCLUSIVE, vpp); - if (error) - return error; - - vp = *vpp; - vp->v_vflag |= VV_ROOT; - - return (0); + return (udf_vget(mp, id, flags, vpp)); } static int @@ -597,6 +589,22 @@ udf_vget(struct mount *mp, ino_t ino, in if (error || *vpp != NULL) return (error); + /* + * We must promote to an exclusive lock for vnode creation. This + * can happen if lookup is passed LOCKSHARED. + */ + if ((flags & LK_TYPE_MASK) == LK_SHARED) { + flags &= ~LK_TYPE_MASK; + flags |= LK_EXCLUSIVE; + } + + /* + * We do not lock vnode creation as it is believed to be too + * expensive for such rare case as simultaneous creation of vnode + * for same ino by different processes. We just allow them to race + * and check later to decide who wins. Let the race begin! + */ + td = curthread; udfmp = VFSTOUDFFS(mp); @@ -689,6 +697,13 @@ udf_vget(struct mount *mp, ino_t ino, in vp->v_type = VLNK; break; } + + if (vp->v_type != VFIFO) + VN_LOCK_ASHARE(vp); + + if (ino == udf_getid(&udfmp->root_icb)) + vp->v_vflag |= VV_ROOT; + *vpp = vp; return (0); Modified: head/sys/fs/udf/udf_vnops.c ============================================================================== --- head/sys/fs/udf/udf_vnops.c Mon Feb 9 20:42:51 2009 (r188406) +++ head/sys/fs/udf/udf_vnops.c Mon Feb 9 20:50:23 2009 (r188407) @@ -1068,13 +1068,14 @@ udf_lookup(struct vop_cachedlookup_args long namelen; ino_t id = 0; int offset, error = 0; - int numdirpasses, fsize; + int fsize, lkflags, ltype, numdirpasses; dvp = a->a_dvp; node = VTON(dvp); udfmp = node->udfmp; nameiop = a->a_cnp->cn_nameiop; flags = a->a_cnp->cn_flags; + lkflags = a->a_cnp->cn_lkflags; nameptr = a->a_cnp->cn_nameptr; namelen = a->a_cnp->cn_namelen; fsize = le64toh(node->fentry->inf_len); @@ -1135,20 +1136,35 @@ lookloop: /* Did we have a match? */ if (id) { - if (flags & ISDOTDOT) - VOP_UNLOCK(dvp, 0); - error = udf_vget(udfmp->im_mountp, id, LK_EXCLUSIVE, &tdp); - if (flags & ISDOTDOT) - vn_lock(dvp, LK_EXCLUSIVE|LK_RETRY); - if (!error) { + /* + * Remember where this entry was if it's the final + * component. + */ + if ((flags & ISLASTCN) && nameiop == LOOKUP) + node->diroff = ds->offset + ds->off; + if (numdirpasses == 2) + nchstats.ncs_pass2++; + udf_closedir(ds); + + if (flags & ISDOTDOT) { + error = vn_vget_ino(dvp, id, lkflags, &tdp); + } else if (node->hash_id == id) { + VREF(dvp); /* we want ourself, ie "." */ /* - * Remember where this entry was if it's the final - * component. + * When we lookup "." we still can be asked to lock it + * differently. */ - if ((flags & ISLASTCN) && nameiop == LOOKUP) - node->diroff = ds->offset + ds->off; - if (numdirpasses == 2) - nchstats.ncs_pass2++; + ltype = lkflags & LK_TYPE_MASK; + if (ltype != VOP_ISLOCKED(dvp)) { + if (ltype == LK_EXCLUSIVE) + vn_lock(dvp, LK_UPGRADE | LK_RETRY); + else /* if (ltype == LK_SHARED) */ + vn_lock(dvp, LK_DOWNGRADE | LK_RETRY); + } + tdp = dvp; + } else + error = udf_vget(udfmp->im_mountp, id, lkflags, &tdp); + if (!error) { *vpp = tdp; /* Put this entry in the cache */ if (flags & MAKEENTRY) @@ -1162,6 +1178,7 @@ lookloop: udf_closedir(ds); goto lookloop; } + udf_closedir(ds); /* Enter name into cache as non-existant */ if (flags & MAKEENTRY) @@ -1175,7 +1192,6 @@ lookloop: } } - udf_closedir(ds); return (error); } From lulf at FreeBSD.org Mon Feb 9 13:34:09 2009 From: lulf at FreeBSD.org (Ulf Lilleengen) Date: Mon Feb 9 13:34:14 2009 Subject: svn commit: r188408 - head/lib/libdisk Message-ID: <200902092134.n19LY6Lw071752@svn.freebsd.org> Author: lulf Date: Mon Feb 9 21:34:06 2009 New Revision: 188408 URL: http://svn.freebsd.org/changeset/base/188408 Log: - Sanitize disk parameters retrieved from GEOM, as they are not guaranteed to have sane values. It caused sysinstall to crash when installing on certain SD cards. Discussed with: marcel Modified: head/lib/libdisk/open_disk.c Modified: head/lib/libdisk/open_disk.c ============================================================================== --- head/lib/libdisk/open_disk.c Mon Feb 9 20:50:23 2009 (r188407) +++ head/lib/libdisk/open_disk.c Mon Feb 9 21:34:06 2009 (r188408) @@ -127,6 +127,9 @@ Int_Open_Disk(const char *name, char *co name, a, b, line); } + /* Sanitize the parameters. */ + Sanitize_Bios_Geom(d); + /* * Calculate the number of cylinders this disk must have. If we have * an obvious insanity, we set the number of cylinders to zero. From thompsa at FreeBSD.org Mon Feb 9 13:47:41 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Mon Feb 9 13:47:48 2009 Subject: svn commit: r188409 - head/sys/dev/usb2/controller Message-ID: <200902092147.n19LldCV072041@svn.freebsd.org> Author: thompsa Date: Mon Feb 9 21:47:39 2009 New Revision: 188409 URL: http://svn.freebsd.org/changeset/base/188409 Log: MFp4 //depot/projects/usb; 157069,157296,157375,157384,157430 - Change "usb2_pause_mtx" so that it takes the timeout value in ticks - USB controller: EHCI High Speed Interrupt endpoint fix. - Fix OHCI and EHCI counting bug when multiple TD's are involved in a short USB transfer and a short packet happens on the non-last TD in the USB transfer frame. - USB process naming cleanup. Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb2/controller/at91dci.c head/sys/dev/usb2/controller/at91dci_atmelarm.c head/sys/dev/usb2/controller/atmegadci.c head/sys/dev/usb2/controller/ehci2.c head/sys/dev/usb2/controller/ehci2.h head/sys/dev/usb2/controller/ehci2_pci.c head/sys/dev/usb2/controller/musb2_otg.c head/sys/dev/usb2/controller/ohci2.c head/sys/dev/usb2/controller/uhci2.c head/sys/dev/usb2/controller/usb2_controller.c head/sys/dev/usb2/controller/uss820dci.c Modified: head/sys/dev/usb2/controller/at91dci.c ============================================================================== --- head/sys/dev/usb2/controller/at91dci.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/at91dci.c Mon Feb 9 21:47:39 2009 (r188409) @@ -275,7 +275,7 @@ at91dci_wakeup_peer(struct usb2_xfer *xf DELAY(8000); } else { /* Wait for reset to complete. */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); } AT91_UDP_WRITE_4(sc, AT91_UDP_GSTATE, 0); @@ -1395,7 +1395,7 @@ at91dci_init(struct at91dci_softc *sc) (sc->sc_clocks_on) (sc->sc_clocks_arg); } /* wait a little for things to stabilise */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); /* disable and clear all interrupts */ Modified: head/sys/dev/usb2/controller/at91dci_atmelarm.c ============================================================================== --- head/sys/dev/usb2/controller/at91dci_atmelarm.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/at91dci_atmelarm.c Mon Feb 9 21:47:39 2009 (r188409) @@ -168,7 +168,7 @@ at91_udp_attach(device_t dev) at91_udp_pull_down(sc); /* wait 10ms for pulldown to stabilise */ - usb2_pause_mtx(NULL, 10); + usb2_pause_mtx(NULL, hz / 100); sc->sc_iclk = at91_pmc_clock_ref("udc_clk"); sc->sc_fclk = at91_pmc_clock_ref("udpck"); Modified: head/sys/dev/usb2/controller/atmegadci.c ============================================================================== --- head/sys/dev/usb2/controller/atmegadci.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/atmegadci.c Mon Feb 9 21:47:39 2009 (r188409) @@ -221,7 +221,7 @@ atmegadci_wakeup_peer(struct usb2_xfer * DELAY(8000); } else { /* Wait for reset to complete. */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); } /* hardware should have cleared RMWKUP bit */ @@ -1253,7 +1253,7 @@ atmegadci_init(struct atmegadci_softc *s (sc->sc_clocks_on) (&sc->sc_bus); /* wait a little for things to stabilise */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); /* enable interrupts */ ATMEGA_WRITE_1(sc, ATMEGA_UDIEN, Modified: head/sys/dev/usb2/controller/ehci2.c ============================================================================== --- head/sys/dev/usb2/controller/ehci2.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/ehci2.c Mon Feb 9 21:47:39 2009 (r188409) @@ -177,7 +177,7 @@ ehci_hc_reset(ehci_softc_t *sc) EOWRITE4(sc, EHCI_USBCMD, 0); /* Halt controller */ for (n = 0; n != 100; n++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); hcr = EOREAD4(sc, EHCI_USBSTS); if (hcr & EHCI_STS_HCH) { hcr = 0; @@ -193,7 +193,7 @@ ehci_hc_reset(ehci_softc_t *sc) EOWRITE4(sc, EHCI_USBCMD, EHCI_CMD_HCRESET); for (n = 0; n != 100; n++) { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); hcr = EOREAD4(sc, EHCI_USBCMD); if (!(hcr & EHCI_CMD_HCRESET)) { if (sc->sc_flags & EHCI_SCFLG_SETMODE) @@ -478,7 +478,7 @@ ehci_init(ehci_softc_t *sc) EOWRITE4(sc, EHCI_CONFIGFLAG, EHCI_CONF_CF); for (i = 0; i < 100; i++) { - usb2_pause_mtx(NULL, 1); + usb2_pause_mtx(NULL, hz / 1000); hcr = EOREAD4(sc, EHCI_USBSTS) & EHCI_STS_HCH; if (!hcr) { break; @@ -511,11 +511,12 @@ ehci_detach(ehci_softc_t *sc) if (ehci_hc_reset(sc)) { DPRINTF("reset failed!\n"); } - /* XXX let stray task complete */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50); USB_BUS_UNLOCK(&sc->sc_bus); + /* XXX let stray task complete */ + usb2_pause_mtx(NULL, hz / 20); + usb2_callout_drain(&sc->sc_tmo_pcd); } @@ -549,7 +550,7 @@ ehci_suspend(ehci_softc_t *sc) if (hcr == 0) { break; } - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); } if (hcr != 0) { @@ -563,7 +564,7 @@ ehci_suspend(ehci_softc_t *sc) if (hcr == EHCI_STS_HCH) { break; } - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); } if (hcr != EHCI_STS_HCH) { @@ -607,7 +608,7 @@ ehci_resume(ehci_softc_t *sc) if (hcr) { usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_RESUME_WAIT); + USB_MS_TO_TICKS(USB_RESUME_WAIT)); for (i = 1; i <= sc->sc_noport; i++) { cmd = EOREAD4(sc, EHCI_PORTSC(i)); @@ -625,16 +626,17 @@ ehci_resume(ehci_softc_t *sc) if (hcr != EHCI_STS_HCH) { break; } - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); } if (hcr == EHCI_STS_HCH) { device_printf(sc->sc_bus.bdev, "config timeout\n"); } - usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_RESUME_WAIT); USB_BUS_UNLOCK(&sc->sc_bus); + usb2_pause_mtx(NULL, + USB_MS_TO_TICKS(USB_RESUME_WAIT)); + /* catch any lost interrupts */ ehci_do_poll(&sc->sc_bus); } @@ -1140,6 +1142,9 @@ ehci_non_isoc_done_sub(struct usb2_xfer td = xfer->td_transfer_cache; td_alt_next = td->alt_next; + if (xfer->aframes != xfer->nframes) { + xfer->frlengths[xfer->aframes] = 0; + } while (1) { usb2_pc_cpu_invalidate(td->page_cache); @@ -1148,8 +1153,8 @@ ehci_non_isoc_done_sub(struct usb2_xfer len = EHCI_QTD_GET_BYTES(status); /* - * Verify the status length and subtract - * the remainder from "frlengths[]": + * Verify the status length and + * add the length to "frlengths[]": */ if (len > td->len) { /* should not happen */ @@ -1157,7 +1162,7 @@ ehci_non_isoc_done_sub(struct usb2_xfer "0x%04x/0x%04x bytes\n", len, td->len); status |= EHCI_QTD_HALTED; } else if (xfer->aframes != xfer->nframes) { - xfer->frlengths[xfer->aframes] -= len; + xfer->frlengths[xfer->aframes] += td->len - len; } /* Check for last transfer */ if (((void *)td) == xfer->td_transfer_last) { @@ -3214,9 +3219,9 @@ ehci_root_ctrl_done(struct usb2_xfer *xf /* wait 20ms for resume sequence to complete */ if (use_polling) { /* polling */ - DELAY(20 * 1000); + DELAY(20000); } else { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); } EOWRITE4(sc, port, v & ~(EHCI_PS_SUSP | @@ -3225,9 +3230,9 @@ ehci_root_ctrl_done(struct usb2_xfer *xf /* settle time */ if (use_polling) { /* polling */ - DELAY(4 * 1000); + DELAY(4000); } else { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 4); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 250); } break; case UHF_PORT_POWER: @@ -3383,7 +3388,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xf } else { /* Wait for reset to complete. */ usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_PORT_ROOT_RESET_DELAY); + USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY)); } /* Terminate reset sequence. */ @@ -3396,7 +3401,7 @@ ehci_root_ctrl_done(struct usb2_xfer *xf } else { /* Wait for HC to complete reset. */ usb2_pause_mtx(&sc->sc_bus.bus_mtx, - EHCI_PORT_RESET_COMPLETE); + USB_MS_TO_TICKS(EHCI_PORT_RESET_COMPLETE)); } v = EOREAD4(sc, port); Modified: head/sys/dev/usb2/controller/ehci2.h ============================================================================== --- head/sys/dev/usb2/controller/ehci2.h Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/ehci2.h Mon Feb 9 21:47:39 2009 (r188409) @@ -468,7 +468,6 @@ typedef struct ehci_softc { struct ehci_sitd *sc_isoc_fs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]; struct ehci_itd *sc_isoc_hs_p_last[EHCI_VIRTUAL_FRAMELIST_COUNT]; void *sc_intr_hdl; - device_t sc_dev; bus_size_t sc_io_size; bus_space_tag_t sc_io_tag; bus_space_handle_t sc_io_hdl; Modified: head/sys/dev/usb2/controller/ehci2_pci.c ============================================================================== --- head/sys/dev/usb2/controller/ehci2_pci.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/ehci2_pci.c Mon Feb 9 21:47:39 2009 (r188409) @@ -237,7 +237,6 @@ ehci_pci_attach(device_t self) USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) { return (ENOMEM); } - sc->sc_dev = self; pci_enable_busmaster(self); @@ -456,7 +455,7 @@ ehci_pci_takecontroller(device_t self) "timed out waiting for BIOS\n"); break; } - usb2_pause_mtx(NULL, 10); /* wait 10ms */ + usb2_pause_mtx(NULL, hz / 100); /* wait 10ms */ } } } Modified: head/sys/dev/usb2/controller/musb2_otg.c ============================================================================== --- head/sys/dev/usb2/controller/musb2_otg.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/musb2_otg.c Mon Feb 9 21:47:39 2009 (r188409) @@ -223,7 +223,7 @@ musbotg_wakeup_peer(struct usb2_xfer *xf DELAY(8000); } else { /* Wait for reset to complete. */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 8); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 125); } temp = MUSB2_READ_1(sc, MUSB2_REG_POWER); @@ -1708,7 +1708,7 @@ musbotg_init(struct musbotg_softc *sc) (sc->sc_clocks_on) (sc->sc_clocks_arg); } /* wait a little for things to stabilise */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); /* disable all interrupts */ @@ -1721,7 +1721,7 @@ musbotg_init(struct musbotg_softc *sc) musbotg_pull_common(sc, 0); /* wait a little bit (10ms) */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); /* disable double packet buffering */ MUSB2_WRITE_2(sc, MUSB2_REG_RXDBDIS, 0xFFFF); Modified: head/sys/dev/usb2/controller/ohci2.c ============================================================================== --- head/sys/dev/usb2/controller/ohci2.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/ohci2.c Mon Feb 9 21:47:39 2009 (r188409) @@ -168,7 +168,7 @@ ohci_controller_init(ohci_softc_t *sc) DPRINTF("SMM active, request owner change\n"); OWRITE4(sc, OHCI_COMMAND_STATUS, OHCI_OCR); for (i = 0; (i < 100) && (ctl & OHCI_IR); i++) { - usb2_pause_mtx(NULL, 1); + usb2_pause_mtx(NULL, hz / 1000); ctl = OREAD4(sc, OHCI_CONTROL); } if (ctl & OHCI_IR) { @@ -181,7 +181,8 @@ ohci_controller_init(ohci_softc_t *sc) DPRINTF("cold started\n"); reset: /* controller was cold started */ - usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY); + usb2_pause_mtx(NULL, + USB_MS_TO_TICKS(USB_BUS_RESET_DELAY)); } /* @@ -191,7 +192,8 @@ reset: DPRINTF("%s: resetting\n", device_get_nameunit(sc->sc_bus.bdev)); OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); - usb2_pause_mtx(NULL, USB_BUS_RESET_DELAY); + usb2_pause_mtx(NULL, + USB_MS_TO_TICKS(USB_BUS_RESET_DELAY)); /* we now own the host controller and the bus has been reset */ ival = OHCI_GET_IVAL(OREAD4(sc, OHCI_FM_INTERVAL)); @@ -253,7 +255,8 @@ reset: desca = OREAD4(sc, OHCI_RH_DESCRIPTOR_A); OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca | OHCI_NOCP); OWRITE4(sc, OHCI_RH_STATUS, OHCI_LPSC); /* Enable port power */ - usb2_pause_mtx(NULL, OHCI_ENABLE_POWER_DELAY); + usb2_pause_mtx(NULL, + USB_MS_TO_TICKS(OHCI_ENABLE_POWER_DELAY)); OWRITE4(sc, OHCI_RH_DESCRIPTOR_A, desca); /* @@ -262,7 +265,8 @@ reset: */ sc->sc_noport = 0; for (i = 0; (i < 10) && (sc->sc_noport == 0); i++) { - usb2_pause_mtx(NULL, OHCI_READ_DESC_DELAY); + usb2_pause_mtx(NULL, + USB_MS_TO_TICKS(OHCI_READ_DESC_DELAY)); sc->sc_noport = OHCI_GET_NDP(OREAD4(sc, OHCI_RH_DESCRIPTOR_A)); } @@ -417,11 +421,11 @@ ohci_detach(struct ohci_softc *sc) OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET); - /* XXX let stray task complete */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 50); - USB_BUS_UNLOCK(&sc->sc_bus); + /* XXX let stray task complete */ + usb2_pause_mtx(NULL, hz / 20); + usb2_callout_drain(&sc->sc_tmo_rhsc); } @@ -455,7 +459,7 @@ ohci_suspend(ohci_softc_t *sc) OWRITE4(sc, OHCI_CONTROL, ctl); usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_RESUME_WAIT); + USB_MS_TO_TICKS(USB_RESUME_WAIT)); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -485,10 +489,12 @@ ohci_resume(ohci_softc_t *sc) ctl = OREAD4(sc, OHCI_CONTROL); ctl |= OHCI_HCFS_RESUME; OWRITE4(sc, OHCI_CONTROL, ctl); - usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_DELAY); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, + USB_MS_TO_TICKS(USB_RESUME_DELAY)); ctl = (ctl & ~OHCI_HCFS_MASK) | OHCI_HCFS_OPERATIONAL; OWRITE4(sc, OHCI_CONTROL, ctl); - usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_RECOVERY); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, + USB_MS_TO_TICKS(USB_RESUME_RECOVERY)); sc->sc_control = sc->sc_intre = 0; USB_BUS_UNLOCK(&sc->sc_bus); @@ -827,6 +833,9 @@ ohci_non_isoc_done_sub(struct usb2_xfer td_alt_next = td->alt_next; td_flags = 0; + if (xfer->aframes != xfer->nframes) { + xfer->frlengths[xfer->aframes] = 0; + } while (1) { usb2_pc_cpu_invalidate(td->page_cache); @@ -850,10 +859,15 @@ ohci_non_isoc_done_sub(struct usb2_xfer cc = OHCI_CC_STALL; } else if (xfer->aframes != xfer->nframes) { /* - * subtract remaining length from - * "frlengths[]" + * Sum up total transfer length + * in "frlengths[]": */ - xfer->frlengths[xfer->aframes] -= temp; + xfer->frlengths[xfer->aframes] += td->len - temp; + } + } else { + if (xfer->aframes != xfer->nframes) { + /* transfer was complete */ + xfer->frlengths[xfer->aframes] += td->len; } } /* Check for last transfer */ @@ -2401,7 +2415,7 @@ ohci_root_ctrl_done(struct usb2_xfer *xf DELAY(USB_PORT_ROOT_RESET_DELAY * 1000); } else { usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_PORT_ROOT_RESET_DELAY); + USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY)); } if ((OREAD4(sc, port) & UPS_RESET) == 0) { Modified: head/sys/dev/usb2/controller/uhci2.c ============================================================================== --- head/sys/dev/usb2/controller/uhci2.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/uhci2.c Mon Feb 9 21:47:39 2009 (r188409) @@ -271,7 +271,7 @@ uhci_reset(uhci_softc_t *sc) /* wait */ usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_BUS_RESET_DELAY); + USB_MS_TO_TICKS(USB_BUS_RESET_DELAY)); /* terminate all transfers */ @@ -283,7 +283,7 @@ uhci_reset(uhci_softc_t *sc) while (n--) { /* wait one millisecond */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); if (!(UREAD2(sc, UHCI_CMD) & UHCI_CMD_HCRESET)) { goto done_1; @@ -299,7 +299,7 @@ done_1: while (n--) { /* wait one millisecond */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); /* check if HC is stopped */ if (UREAD2(sc, UHCI_STS) & UHCI_STS_HCH) { @@ -345,7 +345,7 @@ uhci_start(uhci_softc_t *sc) while (n--) { /* wait one millisecond */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 1); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 1000); /* check that controller has started */ @@ -636,7 +636,8 @@ uhci_suspend(uhci_softc_t *sc) UHCICMD(sc, UHCI_CMD_EGSM); - usb2_pause_mtx(&sc->sc_bus.bus_mtx, USB_RESUME_WAIT); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, + USB_MS_TO_TICKS(USB_RESUME_WAIT)); USB_BUS_UNLOCK(&sc->sc_bus); } @@ -655,7 +656,7 @@ uhci_resume(uhci_softc_t *sc) UHCICMD(sc, UHCI_CMD_FGR); usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_RESUME_DELAY); + USB_MS_TO_TICKS(USB_RESUME_DELAY)); /* and start traffic again */ @@ -2408,7 +2409,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_ if (use_polling) { DELAY(10000); } else { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); } } @@ -2420,7 +2421,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_ DELAY(USB_PORT_ROOT_RESET_DELAY * 1000); } else { usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_PORT_ROOT_RESET_DELAY); + USB_MS_TO_TICKS(USB_PORT_ROOT_RESET_DELAY)); } DPRINTFN(4, "uhci port %d reset, status0 = 0x%04x\n", @@ -2453,7 +2454,7 @@ uhci_portreset(uhci_softc_t *sc, uint16_ DELAY(USB_PORT_RESET_DELAY * 1000); } else { usb2_pause_mtx(&sc->sc_bus.bus_mtx, - USB_PORT_RESET_DELAY); + USB_MS_TO_TICKS(USB_PORT_RESET_DELAY)); } x = UREAD2(sc, port); @@ -2780,9 +2781,9 @@ uhci_root_ctrl_done(struct usb2_xfer *xf /* wait 20ms for resume sequence to complete */ if (use_polling) { /* polling */ - DELAY(20 * 1000); + DELAY(20000); } else { - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 20); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 50); } /* clear suspend and resume detect */ @@ -2790,7 +2791,7 @@ uhci_root_ctrl_done(struct usb2_xfer *xf UHCI_PORTSC_SUSP)); /* wait a little bit */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 2); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 500); sc->sc_isresumed |= (1 << index); Modified: head/sys/dev/usb2/controller/usb2_controller.c ============================================================================== --- head/sys/dev/usb2/controller/usb2_controller.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/usb2_controller.c Mon Feb 9 21:47:39 2009 (r188409) @@ -168,16 +168,16 @@ usb2_detach(device_t dev) /* Get rid of USB callback processes */ - usb2_proc_unsetup(&bus->giant_callback_proc); - usb2_proc_unsetup(&bus->non_giant_callback_proc); + usb2_proc_free(&bus->giant_callback_proc); + usb2_proc_free(&bus->non_giant_callback_proc); /* Get rid of USB roothub process */ - usb2_proc_unsetup(&bus->roothub_proc); + usb2_proc_free(&bus->roothub_proc); /* Get rid of USB explore process */ - usb2_proc_unsetup(&bus->explore_proc); + usb2_proc_free(&bus->explore_proc); return (0); } @@ -375,6 +375,8 @@ usb2_bus_attach(struct usb2_proc_msg *pm static void usb2_attach_sub(device_t dev, struct usb2_bus *bus) { + const char *pname = device_get_nameunit(dev); + /* Initialise USB process messages */ bus->explore_msg[0].hdr.pm_callback = &usb2_bus_explore; bus->explore_msg[0].bus = bus; @@ -398,20 +400,20 @@ usb2_attach_sub(device_t dev, struct usb /* Create USB explore, roothub and callback processes */ - if (usb2_proc_setup(&bus->giant_callback_proc, - &bus->bus_mtx, USB_PRI_MED)) { + if (usb2_proc_create(&bus->giant_callback_proc, + &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB Giant " "callback process failed.\n"); - } else if (usb2_proc_setup(&bus->non_giant_callback_proc, - &bus->bus_mtx, USB_PRI_HIGH)) { + } else if (usb2_proc_create(&bus->non_giant_callback_proc, + &bus->bus_mtx, pname, USB_PRI_HIGH)) { printf("WARNING: Creation of USB non-Giant " "callback process failed.\n"); - } else if (usb2_proc_setup(&bus->roothub_proc, - &bus->bus_mtx, USB_PRI_HIGH)) { + } else if (usb2_proc_create(&bus->roothub_proc, + &bus->bus_mtx, pname, USB_PRI_HIGH)) { printf("WARNING: Creation of USB roothub " "process failed.\n"); - } else if (usb2_proc_setup(&bus->explore_proc, - &bus->bus_mtx, USB_PRI_MED)) { + } else if (usb2_proc_create(&bus->explore_proc, + &bus->bus_mtx, pname, USB_PRI_MED)) { printf("WARNING: Creation of USB explore " "process failed.\n"); } else { Modified: head/sys/dev/usb2/controller/uss820dci.c ============================================================================== --- head/sys/dev/usb2/controller/uss820dci.c Mon Feb 9 21:34:06 2009 (r188408) +++ head/sys/dev/usb2/controller/uss820dci.c Mon Feb 9 21:47:39 2009 (r188409) @@ -1335,7 +1335,7 @@ uss820dci_init(struct uss820dci_softc *s uss820dci_pull_down(sc); /* wait 10ms for pulldown to stabilise */ - usb2_pause_mtx(&sc->sc_bus.bus_mtx, 10); + usb2_pause_mtx(&sc->sc_bus.bus_mtx, hz / 100); /* check hardware revision */ temp = USS820_READ_1(sc, USS820_REV); From thompsa at FreeBSD.org Mon Feb 9 13:50:05 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Mon Feb 9 13:50:20 2009 Subject: svn commit: r188410 - head/sys/dev/usb2/controller Message-ID: <200902092150.n19Lo4bK072147@svn.freebsd.org> Author: thompsa Date: Mon Feb 9 21:50:04 2009 New Revision: 188410 URL: http://svn.freebsd.org/changeset/base/188410 Log: MFp4 //depot/projects/usb - Bring in ehci2_ixp4xx.c and ehci2_mbus.c from dev/usb. Submitted by: Hans Petter Selasky Added: head/sys/dev/usb2/controller/ehci2_ixp4xx.c (contents, props changed) head/sys/dev/usb2/controller/ehci2_mbus.c (contents, props changed) Added: head/sys/dev/usb2/controller/ehci2_ixp4xx.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb2/controller/ehci2_ixp4xx.c Mon Feb 9 21:50:04 2009 (r188410) @@ -0,0 +1,349 @@ +/*- + * Copyright (c) 2008 Sam Leffler. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * IXP435 attachment driver for the USB Enhanced Host Controller. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_bus.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#define EHCI_VENDORID_IXP4XX 0x42fa05 +#define EHCI_HC_DEVSTR "IXP4XX Integrated USB 2.0 controller" + +struct ixp_ehci_softc { + ehci_softc_t base; /* storage for EHCI code */ + bus_space_tag_t iot; + bus_space_handle_t ioh; + struct bus_space tag; /* tag for private bus space ops */ +}; + +static device_attach_t ehci_ixp_attach; +static device_detach_t ehci_ixp_detach; +static device_shutdown_t ehci_ixp_shutdown; +static device_suspend_t ehci_ixp_suspend; +static device_resume_t ehci_ixp_resume; + +static uint8_t ehci_bs_r_1(void *, bus_space_handle_t, bus_size_t); +static void ehci_bs_w_1(void *, bus_space_handle_t, bus_size_t, u_int8_t); +static uint16_t ehci_bs_r_2(void *, bus_space_handle_t, bus_size_t); +static void ehci_bs_w_2(void *, bus_space_handle_t, bus_size_t, uint16_t); +static uint32_t ehci_bs_r_4(void *, bus_space_handle_t, bus_size_t); +static void ehci_bs_w_4(void *, bus_space_handle_t, bus_size_t, uint32_t); + +static int +ehci_ixp_suspend(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + int err; + + err = bus_generic_suspend(self); + if (err) + return (err); + ehci_suspend(sc); + return (0); +} + +static int +ehci_ixp_resume(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + + ehci_resume(sc); + + bus_generic_resume(self); + + return (0); +} + +static int +ehci_ixp_shutdown(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + int err; + + err = bus_generic_shutdown(self); + if (err) + return (err); + ehci_shutdown(sc); + + return (0); +} + +static int +ehci_ixp_probe(device_t self) +{ + + device_set_desc(self, EHCI_HC_DEVSTR); + + return (BUS_PROBE_DEFAULT); +} + +static int +ehci_ixp_attach(device_t self) +{ + struct ixp_ehci_softc *isc = device_get_softc(self); + ehci_softc_t *sc = &isc->base; + int err; + int rid; + + /* initialise some bus fields */ + sc->sc_bus.parent = self; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = EHCI_MAX_DEVICES; + + /* get all DMA memory */ + if (usb2_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) { + return (ENOMEM); + } + + sc->sc_bus.usbrev = USB_REV_2_0; + + /* NB: hints fix the memory location and irq */ + + rid = 0; + sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (!sc->sc_io_res) { + device_printf(self, "Could not map memory\n"); + goto error; + } + + /* + * Craft special resource for bus space ops that handle + * byte-alignment of non-word addresses. Also, since + * we're already intercepting bus space ops we handle + * the register window offset that could otherwise be + * done with bus_space_subregion. + */ + isc->iot = rman_get_bustag(sc->sc_io_res); + isc->tag.bs_cookie = isc->iot; + /* read single */ + isc->tag.bs_r_1 = ehci_bs_r_1, + isc->tag.bs_r_2 = ehci_bs_r_2, + isc->tag.bs_r_4 = ehci_bs_r_4, + /* write (single) */ + isc->tag.bs_w_1 = ehci_bs_w_1, + isc->tag.bs_w_2 = ehci_bs_w_2, + isc->tag.bs_w_4 = ehci_bs_w_4, + + sc->sc_io_tag = &isc->tag; + sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = IXP435_USB1_SIZE - 0x100; + + rid = 0; + sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, + RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + device_printf(self, "Could not allocate irq\n"); + goto error; + } + sc->sc_bus.bdev = device_add_child(self, "usbus", -1); + if (!sc->sc_bus.bdev) { + device_printf(self, "Could not add USB device\n"); + goto error; + } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR); + + sprintf(sc->sc_vendor, "Intel"); + + + err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + NULL, (void *)(void *)ehci_interrupt, sc, &sc->sc_intr_hdl); + if (err) { + device_printf(self, "Could not setup irq, %d\n", err); + sc->sc_intr_hdl = NULL; + goto error; + } + + /* + * Arrange to force Host mode, select big-endian byte alignment, + * and arrange to not terminate reset operations (the adapter + * will ignore it if we do but might as well save a reg write). + * Also, the controller has an embedded Transaction Translator + * which means port speed must be read from the Port Status + * register following a port enable. + */ + sc->sc_flags |= EHCI_SCFLG_TT + | EHCI_SCFLG_SETMODE + | EHCI_SCFLG_BIGEDESC + | EHCI_SCFLG_BIGEMMIO + | EHCI_SCFLG_NORESTERM + ; + + err = ehci_init(sc); + if (!err) { + err = device_probe_and_attach(sc->sc_bus.bdev); + } + if (err) { + device_printf(self, "USB init failed err=%d\n", err); + goto error; + } + return (0); + +error: + ehci_ixp_detach(self); + return (ENXIO); +} + +static int +ehci_ixp_detach(device_t self) +{ + struct ixp_ehci_softc *isc = device_get_softc(self); + ehci_softc_t *sc = &isc->base; + device_t bdev; + int err; + + if (sc->sc_bus.bdev) { + bdev = sc->sc_bus.bdev; + device_detach(bdev); + device_delete_child(self, bdev); + } + /* during module unload there are lots of children leftover */ + device_delete_all_children(self); + + /* + * disable interrupts that might have been switched on in ehci_init + */ + if (sc->sc_io_res) { + EWRITE4(sc, EHCI_USBINTR, 0); + } + + if (sc->sc_irq_res && sc->sc_intr_hdl) { + /* + * only call ehci_detach() after ehci_init() + */ + ehci_detach(sc); + + err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl); + + if (err) + /* XXX or should we panic? */ + device_printf(self, "Could not tear down irq, %d\n", + err); + sc->sc_intr_hdl = NULL; + } + + if (sc->sc_irq_res) { + bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); + sc->sc_irq_res = NULL; + } + if (sc->sc_io_res) { + bus_release_resource(self, SYS_RES_MEMORY, 0, + sc->sc_io_res); + sc->sc_io_res = NULL; + } + usb2_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc); + + return (0); +} + +/* + * Bus space accessors for PIO operations. + */ + +static uint8_t +ehci_bs_r_1(void *t, bus_space_handle_t h, bus_size_t o) +{ + return bus_space_read_1((bus_space_tag_t) t, h, + 0x100 + (o &~ 3) + (3 - (o & 3))); +} + +static void +ehci_bs_w_1(void *t, bus_space_handle_t h, bus_size_t o, u_int8_t v) +{ + panic("%s", __func__); +} + +static uint16_t +ehci_bs_r_2(void *t, bus_space_handle_t h, bus_size_t o) +{ + return bus_space_read_2((bus_space_tag_t) t, h, + 0x100 + (o &~ 3) + (2 - (o & 3))); +} + +static void +ehci_bs_w_2(void *t, bus_space_handle_t h, bus_size_t o, uint16_t v) +{ + panic("%s", __func__); +} + +static uint32_t +ehci_bs_r_4(void *t, bus_space_handle_t h, bus_size_t o) +{ + return bus_space_read_4((bus_space_tag_t) t, h, 0x100 + o); +} + +static void +ehci_bs_w_4(void *t, bus_space_handle_t h, bus_size_t o, uint32_t v) +{ + bus_space_write_4((bus_space_tag_t) t, h, 0x100 + o, v); +} + +static device_method_t ehci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ehci_ixp_probe), + DEVMETHOD(device_attach, ehci_ixp_attach), + DEVMETHOD(device_detach, ehci_ixp_detach), + DEVMETHOD(device_suspend, ehci_ixp_suspend), + DEVMETHOD(device_resume, ehci_ixp_resume), + DEVMETHOD(device_shutdown, ehci_ixp_shutdown), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + + {0, 0} +}; + +static driver_t ehci_driver = { + "ehci", + ehci_methods, + sizeof(struct ixp_ehci_softc), +}; + +static devclass_t ehci_devclass; + +DRIVER_MODULE(ehci, ixp, ehci_driver, ehci_devclass, 0, 0); +MODULE_DEPEND(ehci, usb2_controller, 1, 1, 1); +MODULE_DEPEND(ehci, usb2_core, 1, 1, 1); Added: head/sys/dev/usb2/controller/ehci2_mbus.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb2/controller/ehci2_mbus.c Mon Feb 9 21:50:04 2009 (r188410) @@ -0,0 +1,365 @@ +/*- + * Copyright (C) 2008 MARVELL INTERNATIONAL LTD. + * All rights reserved. + * + * Developed by Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of MARVELL nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * MBus attachment driver for the USB Enhanced Host Controller. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_bus.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#define EHCI_VENDORID_MRVL 0x1286 +#define EHCI_HC_DEVSTR "Marvell Integrated USB 2.0 controller" + +static device_attach_t ehci_mbus_attach; +static device_detach_t ehci_mbus_detach; +static device_shutdown_t ehci_mbus_shutdown; +static device_suspend_t ehci_mbus_suspend; +static device_resume_t ehci_mbus_resume; + +static int err_intr(void *arg); + +static struct resource *irq_err; +static void *ih_err; + +#define USB_BRIDGE_INTR_CAUSE 0x210 +#define USB_BRIDGE_INTR_MASK 0x214 + +#define MV_USB_ADDR_DECODE_ERR (1 << 0) +#define MV_USB_HOST_UNDERFLOW (1 << 1) +#define MV_USB_HOST_OVERFLOW (1 << 2) +#define MV_USB_DEVICE_UNDERFLOW (1 << 3) + +static int +ehci_mbus_suspend(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + int err; + + err = bus_generic_suspend(self); + if (err) + return (err); + ehci_suspend(sc); + return (0); +} + +static int +ehci_mbus_resume(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + + ehci_resume(sc); + + bus_generic_resume(self); + + return (0); +} + +static int +ehci_mbus_shutdown(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + int err; + + err = bus_generic_shutdown(self); + if (err) + return (err); + ehci_shutdown(sc); + + return (0); +} + +static int +ehci_mbus_probe(device_t self) +{ + + device_set_desc(self, EHCI_HC_DEVSTR); + + return (BUS_PROBE_DEFAULT); +} + +static int +ehci_mbus_attach(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + bus_space_handle_t bsh; + int err; + int rid; + + /* initialise some bus fields */ + sc->sc_bus.parent = self; + sc->sc_bus.devices = sc->sc_devices; + sc->sc_bus.devices_max = EHCI_MAX_DEVICES; + + /* get all DMA memory */ + if (usb2_bus_mem_alloc_all(&sc->sc_bus, + USB_GET_DMA_TAG(self), &ehci_iterate_hw_softc)) { + return (ENOMEM); + } + + sc->sc_bus.usbrev = USB_REV_2_0; + + rid = 0; + sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (!sc->sc_io_res) { + device_printf(self, "Could not map memory\n"); + goto error; + } + sc->sc_io_tag = rman_get_bustag(sc->sc_io_res); + bsh = rman_get_bushandle(sc->sc_io_res); + sc->sc_io_size = MV_USB_SIZE - MV_USB_HOST_OFST; + + /* + * Marvell EHCI host controller registers start at certain offset within + * the whole USB registers range, so create a subregion for the host + * mode configuration purposes. + */ + if (bus_space_subregion(sc->sc_io_tag, bsh, MV_USB_HOST_OFST, + sc->sc_io_size, &sc->sc_io_hdl) != 0) + panic("%s: unable to subregion USB host registers", + device_get_name(self)); + + rid = 0; + irq_err = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (irq_err == NULL) { + device_printf(self, "Could not allocate error irq\n"); + ehci_mbus_detach(self); + return (ENXIO); + } + + /* + * Notice: Marvell EHCI controller has TWO interrupt lines, so make sure to + * use the correct rid for the main one (controller interrupt) -- + * refer to obio_devices[] for the right resource number to use here. + */ + rid = 1; + sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE); + if (sc->sc_irq_res == NULL) { + device_printf(self, "Could not allocate irq\n"); + goto error; + } + + sc->sc_bus.bdev = device_add_child(self, "usbus", -1); + if (!sc->sc_bus.bdev) { + device_printf(self, "Could not add USB device\n"); + goto error; + } + device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus); + device_set_desc(sc->sc_bus.bdev, EHCI_HC_DEVSTR); + + sprintf(sc->sc_vendor, "Marvell"); + + err = bus_setup_intr(self, irq_err, INTR_FAST | INTR_TYPE_BIO, + err_intr, NULL, sc, &ih_err); + if (err) { + device_printf(self, "Could not setup error irq, %d\n", err); + ih_err = NULL; + goto error; + } + + EWRITE4(sc, USB_BRIDGE_INTR_MASK, MV_USB_ADDR_DECODE_ERR | + MV_USB_HOST_UNDERFLOW | MV_USB_HOST_OVERFLOW | + MV_USB_DEVICE_UNDERFLOW); + + err = bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE, + NULL, (void *)(void *)ehci_interrupt, sc, &sc->sc_intr_hdl); + if (err) { + device_printf(self, "Could not setup irq, %d\n", err); + sc->sc_intr_hdl = NULL; + goto error; + } + + /* + * Workaround for Marvell integrated EHCI controller: reset of + * the EHCI core clears the USBMODE register, which sets the core in + * an undefined state (neither host nor agent), so it needs to be set + * again for proper operation. + * + * Refer to errata document MV-S500832-00D.pdf (p. 5.24 GL USB-2) for + * details. + */ + sc->sc_flags |= EHCI_SCFLG_SETMODE; + if (bootverbose) + device_printf(self, "5.24 GL USB-2 workaround enabled\n"); + + /* XXX all MV chips need it? */ + sc->sc_flags |= EHCI_SCFLG_FORCESPEED | EHCI_SCFLG_NORESTERM; + + err = ehci_init(sc); + if (!err) { + err = device_probe_and_attach(sc->sc_bus.bdev); + } + if (err) { + device_printf(self, "USB init failed err=%d\n", err); + goto error; + } + return (0); + +error: + ehci_mbus_detach(self); + return (ENXIO); +} + +static int +ehci_mbus_detach(device_t self) +{ + ehci_softc_t *sc = device_get_softc(self); + device_t bdev; + int err; + + if (sc->sc_bus.bdev) { + bdev = sc->sc_bus.bdev; + device_detach(bdev); + device_delete_child(self, bdev); + } + /* during module unload there are lots of children leftover */ + device_delete_all_children(self); + + /* + * disable interrupts that might have been switched on in ehci_init + */ + if (sc->sc_io_res) { + EWRITE4(sc, EHCI_USBINTR, 0); + EWRITE4(sc, USB_BRIDGE_INTR_MASK, 0); + } + if (sc->sc_irq_res && sc->sc_intr_hdl) { + /* + * only call ehci_detach() after ehci_init() + */ + ehci_detach(sc); + + err = bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intr_hdl); + + if (err) + /* XXX or should we panic? */ + device_printf(self, "Could not tear down irq, %d\n", + err); + sc->sc_intr_hdl = NULL; + } + if (irq_err && ih_err) { + err = bus_teardown_intr(self, irq_err, ih_err); + + if (err) + device_printf(self, "Could not tear down irq, %d\n", + err); + ih_err = NULL; + } + if (irq_err) { + bus_release_resource(self, SYS_RES_IRQ, 0, irq_err); + irq_err = NULL; + } + if (sc->sc_irq_res) { + bus_release_resource(self, SYS_RES_IRQ, 1, sc->sc_irq_res); + sc->sc_irq_res = NULL; + } + if (sc->sc_io_res) { + bus_release_resource(self, SYS_RES_MEMORY, 0, + sc->sc_io_res); + sc->sc_io_res = NULL; + } + usb2_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc); + + return (0); +} + +static int +err_intr(void *arg) +{ + ehci_softc_t *sc = arg; + unsigned int cause; + + cause = EREAD4(sc, USB_BRIDGE_INTR_CAUSE); + if (cause) { + printf("IRQ ERR: cause: 0x%08x\n", cause); + if (cause & MV_USB_ADDR_DECODE_ERR) + printf("IRQ ERR: Address decoding error\n"); + if (cause & MV_USB_HOST_UNDERFLOW) + printf("IRQ ERR: USB Host Underflow\n"); + if (cause & MV_USB_HOST_OVERFLOW) + printf("IRQ ERR: USB Host Overflow\n"); + if (cause & MV_USB_DEVICE_UNDERFLOW) + printf("IRQ ERR: USB Device Underflow\n"); + if (cause & ~(MV_USB_ADDR_DECODE_ERR | MV_USB_HOST_UNDERFLOW | + MV_USB_HOST_OVERFLOW | MV_USB_DEVICE_UNDERFLOW)) + printf("IRQ ERR: Unknown error\n"); + + EWRITE4(sc, USB_BRIDGE_INTR_CAUSE, 0); + } + return (FILTER_HANDLED); +} + +static device_method_t ehci_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ehci_mbus_probe), + DEVMETHOD(device_attach, ehci_mbus_attach), + DEVMETHOD(device_detach, ehci_mbus_detach), + DEVMETHOD(device_suspend, ehci_mbus_suspend), + DEVMETHOD(device_resume, ehci_mbus_resume), + DEVMETHOD(device_shutdown, ehci_mbus_shutdown), + + /* Bus interface */ + DEVMETHOD(bus_print_child, bus_generic_print_child), + + {0, 0} +}; + +static driver_t ehci_driver = { + "ehci", + ehci_methods, + sizeof(ehci_softc_t), +}; + +static devclass_t ehci_devclass; + +DRIVER_MODULE(ehci, mbus, ehci_driver, ehci_devclass, 0, 0); +MODULE_DEPEND(ehci, usb2_controller, 1, 1, 1); +MODULE_DEPEND(ehci, usb2_core, 1, 1, 1); From thompsa at FreeBSD.org Mon Feb 9 13:56:34 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Mon Feb 9 13:56:47 2009 Subject: svn commit: r188411 - head/sys/dev/usb2/core Message-ID: <200902092156.n19LuXc5072322@svn.freebsd.org> Author: thompsa Date: Mon Feb 9 21:56:33 2009 New Revision: 188411 URL: http://svn.freebsd.org/changeset/base/188411 Log: MFp4 //depot/projects/usb; 157069, 157429, 157430 - Change "usb2_pause_mtx" so that it takes the timeout value in ticks - Factor out USB ethernet and USB serial driver specific control request. - USB process naming cleanup. Submitted by: Hans Petter Selasky Modified: head/sys/dev/usb2/core/usb2_core.h head/sys/dev/usb2/core/usb2_device.c head/sys/dev/usb2/core/usb2_hub.c head/sys/dev/usb2/core/usb2_msctest.c head/sys/dev/usb2/core/usb2_process.c head/sys/dev/usb2/core/usb2_process.h head/sys/dev/usb2/core/usb2_request.c head/sys/dev/usb2/core/usb2_request.h head/sys/dev/usb2/core/usb2_transfer.c head/sys/dev/usb2/core/usb2_util.c head/sys/dev/usb2/core/usb2_util.h Modified: head/sys/dev/usb2/core/usb2_core.h ============================================================================== --- head/sys/dev/usb2/core/usb2_core.h Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_core.h Mon Feb 9 21:56:33 2009 (r188411) @@ -434,6 +434,7 @@ uint8_t usb2_clear_stall_callback(struct uint8_t usb2_get_interface_altindex(struct usb2_interface *iface); usb2_error_t usb2_set_alt_interface_index(struct usb2_device *udev, uint8_t iface_index, uint8_t alt_index); +uint8_t usb2_get_mode(struct usb2_device *udev); uint8_t usb2_get_speed(struct usb2_device *udev); uint32_t usb2_get_isoc_fps(struct usb2_device *udev); usb2_error_t usb2_transfer_setup(struct usb2_device *udev, Modified: head/sys/dev/usb2/core/usb2_device.c ============================================================================== --- head/sys/dev/usb2/core/usb2_device.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_device.c Mon Feb 9 21:56:33 2009 (r188411) @@ -1401,7 +1401,8 @@ usb2_alloc_device(device_t parent_dev, s "(ignored)\n", udev->address); } /* allow device time to set new address */ - usb2_pause_mtx(&Giant, USB_SET_ADDRESS_SETTLE); + usb2_pause_mtx(&Giant, + USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE)); } else { /* We are not self powered */ udev->flags.self_powered = 0; @@ -1951,6 +1952,20 @@ usb2_check_strings(struct usb2_device *u } } +/* + * Returns: + * See: USB_MODE_XXX + */ +uint8_t +usb2_get_mode(struct usb2_device *udev) +{ + return (udev->flags.usb2_mode); +} + +/* + * Returns: + * See: USB_SPEED_XXX + */ uint8_t usb2_get_speed(struct usb2_device *udev) { Modified: head/sys/dev/usb2/core/usb2_hub.c ============================================================================== --- head/sys/dev/usb2/core/usb2_hub.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_hub.c Mon Feb 9 21:56:33 2009 (r188411) @@ -335,7 +335,8 @@ repeat: /* wait for maximum device power up time */ - usb2_pause_mtx(&Giant, USB_PORT_POWERUP_DELAY); + usb2_pause_mtx(&Giant, + USB_MS_TO_TICKS(USB_PORT_POWERUP_DELAY)); /* reset port, which implies enabling it */ @@ -736,7 +737,7 @@ uhub_attach(device_t dev) goto error; } /* wait with power off for a while */ - usb2_pause_mtx(&Giant, USB_POWER_DOWN_TIME); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_POWER_DOWN_TIME)); /* * To have the best chance of success we do things in the exact same @@ -794,7 +795,7 @@ uhub_attach(device_t dev) portno); /* wait for stable power */ - usb2_pause_mtx(&Giant, pwrdly); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(pwrdly)); } device_printf(dev, "%d port%s with %d " @@ -1666,7 +1667,7 @@ usb2_dev_resume_peer(struct usb2_device return; } /* resume settle time */ - usb2_pause_mtx(&Giant, USB_PORT_RESUME_DELAY); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(USB_PORT_RESUME_DELAY)); if (bus->methods->device_resume != NULL) { /* resume USB device on the USB controller */ @@ -1802,7 +1803,7 @@ repeat: /* do DMA delay */ temp = usb2_get_dma_delay(udev->bus); - usb2_pause_mtx(&Giant, temp); + usb2_pause_mtx(&Giant, USB_MS_TO_TICKS(temp)); } /* suspend current port */ Modified: head/sys/dev/usb2/core/usb2_msctest.c ============================================================================== --- head/sys/dev/usb2/core/usb2_msctest.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_msctest.c Mon Feb 9 21:56:33 2009 (r188411) @@ -562,7 +562,7 @@ repeat_inquiry: goto done; } } else if ((err != 2) && --timeout) { - usb2_pause_mtx(&sc->mtx, USB_MS_HZ); + usb2_pause_mtx(&sc->mtx, hz); goto repeat_inquiry; } err = USB_ERR_INVAL; Modified: head/sys/dev/usb2/core/usb2_process.c ============================================================================== --- head/sys/dev/usb2/core/usb2_process.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_process.c Mon Feb 9 21:56:33 2009 (r188411) @@ -164,7 +164,7 @@ usb2_process(void *arg) } /*------------------------------------------------------------------------* - * usb2_proc_setup + * usb2_proc_create * * This function will create a process using the given "prio" that can * execute callbacks. The mutex pointed to by "p_mtx" will be applied @@ -176,8 +176,9 @@ usb2_process(void *arg) * 0: success * Else: failure *------------------------------------------------------------------------*/ -uint8_t -usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, uint8_t prio) +int +usb2_proc_create(struct usb2_process *up, struct mtx *p_mtx, + const char *pmesg, uint8_t prio) { up->up_mtx = p_mtx; up->up_prio = prio; @@ -188,7 +189,7 @@ usb2_proc_setup(struct usb2_process *up, usb2_cv_init(&up->up_drain, "dmsg"); if (USB_THREAD_CREATE(&usb2_process, up, - &up->up_ptr, "usbproc")) { + &up->up_ptr, pmesg)) { DPRINTFN(0, "Unable to create USB process."); up->up_ptr = NULL; goto error; @@ -196,12 +197,12 @@ usb2_proc_setup(struct usb2_process *up, return (0); error: - usb2_proc_unsetup(up); - return (1); + usb2_proc_free(up); + return (ENOMEM); } /*------------------------------------------------------------------------* - * usb2_proc_unsetup + * usb2_proc_free * * NOTE: If the structure pointed to by "up" is all zero, this * function does nothing. @@ -210,7 +211,7 @@ error: * removed nor called. *------------------------------------------------------------------------*/ void -usb2_proc_unsetup(struct usb2_process *up) +usb2_proc_free(struct usb2_process *up) { if (!(up->up_mtx)) { /* not initialised */ Modified: head/sys/dev/usb2/core/usb2_process.h ============================================================================== --- head/sys/dev/usb2/core/usb2_process.h Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_process.h Mon Feb 9 21:56:33 2009 (r188411) @@ -79,12 +79,12 @@ struct usb2_process { uint8_t usb2_proc_cwait(struct usb2_process *up, int timeout); uint8_t usb2_proc_is_gone(struct usb2_process *up); -uint8_t usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, - uint8_t prio); +int usb2_proc_create(struct usb2_process *up, struct mtx *p_mtx, + const char *pmesg, uint8_t prio); void usb2_proc_csignal(struct usb2_process *up); void usb2_proc_drain(struct usb2_process *up); void usb2_proc_mwait(struct usb2_process *up, void *pm0, void *pm1); -void usb2_proc_unsetup(struct usb2_process *up); +void usb2_proc_free(struct usb2_process *up); void *usb2_proc_msignal(struct usb2_process *up, void *pm0, void *pm1); #endif /* _USB2_PROCESS_H_ */ Modified: head/sys/dev/usb2/core/usb2_request.c ============================================================================== --- head/sys/dev/usb2/core/usb2_request.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_request.c Mon Feb 9 21:56:33 2009 (r188411) @@ -371,7 +371,7 @@ usb2_do_request_flags(struct usb2_device if (temp > 0) { usb2_pause_mtx( xfer->xroot->xfer_mtx, - temp); + USB_MS_TO_TICKS(temp)); } #endif xfer->flags.manual_status = 0; @@ -477,6 +477,49 @@ done: } /*------------------------------------------------------------------------* + * usb2_do_request_proc - factored out code + * + * This function is factored out code. It does basically the same like + * usb2_do_request_flags, except it will check the status of the + * passed process argument before doing the USB request. If the + * process is draining the USB_ERR_IOERROR code will be returned. It + * is assumed that the mutex associated with the process is locked + * when calling this function. + *------------------------------------------------------------------------*/ +usb2_error_t +usb2_do_request_proc(struct usb2_device *udev, struct usb2_process *pproc, + struct usb2_device_request *req, void *data, uint32_t flags, + uint16_t *actlen, uint32_t timeout) +{ + usb2_error_t err; + uint16_t len; + + /* get request data length */ + len = UGETW(req->wLength); + + /* check if the device is being detached */ + if (usb2_proc_is_gone(pproc)) { + err = USB_ERR_IOERROR; + goto done; + } + + /* forward the USB request */ + err = usb2_do_request_flags(udev, pproc->up_mtx, + req, data, flags, actlen, timeout); + +done: + /* on failure we zero the data */ + /* on short packet we zero the unused data */ + if ((len != 0) && (req->bmRequestType & UE_DIR_IN)) { + if (err) + memset(data, 0, len); + else if (actlen && *actlen != len) + memset(((uint8_t *)data) + *actlen, 0, len - *actlen); + } + return (err); +} + +/*------------------------------------------------------------------------* * usb2_req_reset_port * * This function will instruct an USB HUB to perform a reset sequence @@ -520,11 +563,11 @@ usb2_req_reset_port(struct usb2_device * while (1) { #if USB_DEBUG /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, pr_poll_delay); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_poll_delay)); n += pr_poll_delay; #else /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, USB_PORT_RESET_DELAY); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_DELAY)); n += USB_PORT_RESET_DELAY; #endif err = usb2_req_get_port_status(udev, mtx, &ps, port); @@ -559,10 +602,10 @@ usb2_req_reset_port(struct usb2_device * } #if USB_DEBUG /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, pr_recovery_delay); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(pr_recovery_delay)); #else /* wait for the device to recover from reset */ - usb2_pause_mtx(mtx, USB_PORT_RESET_RECOVERY); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_PORT_RESET_RECOVERY)); #endif done: @@ -624,7 +667,7 @@ usb2_req_get_desc(struct usb2_device *ud } retries--; - usb2_pause_mtx(mtx, 200); + usb2_pause_mtx(mtx, hz / 5); continue; } @@ -1369,7 +1412,7 @@ retry: udev->address = old_addr; /* allow device time to set new address */ - usb2_pause_mtx(mtx, USB_SET_ADDRESS_SETTLE); + usb2_pause_mtx(mtx, USB_MS_TO_TICKS(USB_SET_ADDRESS_SETTLE)); /* get the device descriptor */ err = usb2_req_get_desc(udev, mtx, &udev->ddesc, @@ -1389,7 +1432,7 @@ retry: done: if (err && do_retry) { /* give the USB firmware some time to load */ - usb2_pause_mtx(mtx, 500); + usb2_pause_mtx(mtx, hz / 2); /* no more retries after this retry */ do_retry = 0; /* try again */ Modified: head/sys/dev/usb2/core/usb2_request.h ============================================================================== --- head/sys/dev/usb2/core/usb2_request.h Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_request.h Mon Feb 9 21:56:33 2009 (r188411) @@ -27,9 +27,14 @@ #ifndef _USB2_REQUEST_H_ #define _USB2_REQUEST_H_ +struct usb2_process; + usb2_error_t usb2_do_request_flags(struct usb2_device *udev, struct mtx *mtx, struct usb2_device_request *req, void *data, uint32_t flags, uint16_t *actlen, uint32_t timeout); +usb2_error_t usb2_do_request_proc(struct usb2_device *udev, struct usb2_process *pproc, + struct usb2_device_request *req, void *data, uint32_t flags, + uint16_t *actlen, uint32_t timeout); usb2_error_t usb2_req_clear_hub_feature(struct usb2_device *udev, struct mtx *mtx, uint16_t sel); usb2_error_t usb2_req_clear_port_feature(struct usb2_device *udev, Modified: head/sys/dev/usb2/core/usb2_transfer.c ============================================================================== --- head/sys/dev/usb2/core/usb2_transfer.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_transfer.c Mon Feb 9 21:56:33 2009 (r188411) @@ -1066,7 +1066,8 @@ usb2_transfer_unsetup_sub(struct usb2_xf if (needs_delay) { temp = usb2_get_dma_delay(info->bus); - usb2_pause_mtx(&info->bus->bus_mtx, temp); + usb2_pause_mtx(&info->bus->bus_mtx, + USB_MS_TO_TICKS(temp)); } /* make sure that our done messages are not queued anywhere */ Modified: head/sys/dev/usb2/core/usb2_util.c ============================================================================== --- head/sys/dev/usb2/core/usb2_util.c Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_util.c Mon Feb 9 21:56:33 2009 (r188411) @@ -124,36 +124,37 @@ device_set_usb2_desc(device_t dev) /*------------------------------------------------------------------------* * usb2_pause_mtx - factored out code * - * This function will delay the code by the passed number of - * milliseconds. The passed mutex "mtx" will be dropped while waiting, - * if "mtx" is not NULL. The number of milliseconds per second is 1024 - * for sake of optimisation. + * This function will delay the code by the passed number of system + * ticks. The passed mutex "mtx" will be dropped while waiting, if + * "mtx" is not NULL. *------------------------------------------------------------------------*/ void -usb2_pause_mtx(struct mtx *mtx, uint32_t ms) +usb2_pause_mtx(struct mtx *mtx, int _ticks) { + if (mtx != NULL) + mtx_unlock(mtx); + if (cold) { - ms = (ms + 1) * 1024; - DELAY(ms); + /* convert to milliseconds */ + _ticks = (_ticks * 1000) / hz; + /* convert to microseconds, rounded up */ + _ticks = (_ticks + 1) * 1000; + DELAY(_ticks); } else { - ms = USB_MS_TO_TICKS(ms); /* * Add one to the number of ticks so that we don't return * too early! */ - ms++; - - if (mtx != NULL) - mtx_unlock(mtx); + _ticks++; - if (pause("USBWAIT", ms)) { + if (pause("USBWAIT", _ticks)) { /* ignore */ } - if (mtx != NULL) - mtx_lock(mtx); } + if (mtx != NULL) + mtx_lock(mtx); } /*------------------------------------------------------------------------* Modified: head/sys/dev/usb2/core/usb2_util.h ============================================================================== --- head/sys/dev/usb2/core/usb2_util.h Mon Feb 9 21:50:04 2009 (r188410) +++ head/sys/dev/usb2/core/usb2_util.h Mon Feb 9 21:56:33 2009 (r188411) @@ -31,7 +31,7 @@ int device_delete_all_children(device_t uint32_t usb2_get_devid(device_t dev); uint8_t usb2_make_str_desc(void *ptr, uint16_t max_len, const char *s); void device_set_usb2_desc(device_t dev); -void usb2_pause_mtx(struct mtx *mtx, uint32_t ms); +void usb2_pause_mtx(struct mtx *mtx, int _ticks); void usb2_printBCD(char *p, uint16_t p_len, uint16_t bcd); void usb2_trim_spaces(char *p); From thompsa at FreeBSD.org Mon Feb 9 14:02:38 2009 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Mon Feb 9 14:02:52 2009 Subject: svn commit: r188412 - in head/sys/dev/usb2: ethernet include template Message-ID: <200902092202.n19M2c5p072509@svn.freebsd.org> Author: thompsa Date: Mon Feb 9 22:02:38 2009 New Revision: 188412 URL: http://svn.freebsd.org/changeset/base/188412 Log: MFp4 //depot/projects/usb; 157100 1. Move most of the ifnet logic into the usb2_ethernet module, this includes, - make all usb ethernet interfaces named ue%d - handle all threading in usb2_ethernet - provide default ioctl handler - handle mbuf rx - provide locked callbacks for init,start,stop,etc 2. Cleanup CDC-Ethernet driver. Submitted by: Hans Petter Selasky Obtained from: svn.freebsd.org/base/user/thompsa/usb [1] Modified: head/sys/dev/usb2/ethernet/if_aue2.c head/sys/dev/usb2/ethernet/if_auereg.h head/sys/dev/usb2/ethernet/if_axe2.c head/sys/dev/usb2/ethernet/if_axereg.h head/sys/dev/usb2/ethernet/if_cdce2.c head/sys/dev/usb2/ethernet/if_cdcereg.h head/sys/dev/usb2/ethernet/if_cue2.c head/sys/dev/usb2/ethernet/if_cuereg.h head/sys/dev/usb2/ethernet/if_kue2.c head/sys/dev/usb2/ethernet/if_kuereg.h head/sys/dev/usb2/ethernet/if_rue2.c head/sys/dev/usb2/ethernet/if_ruereg.h head/sys/dev/usb2/ethernet/if_udav2.c head/sys/dev/usb2/ethernet/if_udavreg.h head/sys/dev/usb2/ethernet/usb2_ethernet.c head/sys/dev/usb2/ethernet/usb2_ethernet.h head/sys/dev/usb2/include/usb2_cdc.h head/sys/dev/usb2/template/usb2_template_cdce.c Modified: head/sys/dev/usb2/ethernet/if_aue2.c ============================================================================== --- head/sys/dev/usb2/ethernet/if_aue2.c Mon Feb 9 21:56:33 2009 (r188411) +++ head/sys/dev/usb2/ethernet/if_aue2.c Mon Feb 9 22:02:38 2009 (r188412) @@ -2,6 +2,9 @@ * Copyright (c) 1997, 1998, 1999, 2000 * Bill Paul . All rights reserved. * + * Copyright (c) 2006 + * Alfred Perlstein . All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -40,6 +43,9 @@ __FBSDID("$FreeBSD$"); * Written by Bill Paul * Electrical Engineering Department * Columbia University, New York City + * + * SMP locking by Alfred Perlstein . + * RED Inc. */ /* @@ -58,13 +64,8 @@ __FBSDID("$FreeBSD$"); * the controller uses an external PHY chip, it's possible that board * designers might simply choose a 10Mbps PHY. * - * Registers are accessed using usb2_do_request(). Packet transfers are - * done using usb2_transfer() and friends. - */ - -/* - * NOTE: all function names beginning like "aue_cfg_" can only - * be called from within the config thread function ! + * Registers are accessed using usb2_ether_do_request(). Packet + * transfers are done using usb2_transfer() and friends. */ #include @@ -72,15 +73,11 @@ __FBSDID("$FreeBSD$"); #include #include -#define usb2_config_td_cc usb2_ether_cc -#define usb2_config_td_softc aue_softc - #define USB_DEBUG_VAR aue_debug #include #include #include -#include #include #include #include @@ -89,11 +86,6 @@ __FBSDID("$FreeBSD$"); #include #include -MODULE_DEPEND(aue, usb2_ethernet, 1, 1, 1); -MODULE_DEPEND(aue, usb2_core, 1, 1, 1); -MODULE_DEPEND(aue, ether, 1, 1, 1); -MODULE_DEPEND(aue, miibus, 1, 1, 1); - #if USB_DEBUG static int aue_debug = 0; @@ -106,74 +98,74 @@ SYSCTL_INT(_hw_usb2_aue, OID_AUTO, debug * Various supported device vendors/products. */ static const struct usb2_device_id aue_devs[] = { - {USB_VPI(USB_VENDOR_3COM, USB_PRODUCT_3COM_3C460B, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA, 0)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10, 0)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1, AUE_FLAG_PNA | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4, AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5, AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9, AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC, 0)}, - {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_2, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_3, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_4, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS, AUE_FLAG_PNA | AUE_FLAG_DUAL_PHY)}, - {USB_VPI(USB_VENDOR_AEI, USB_PRODUCT_AEI_FASTETHERNET, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ALLIEDTELESYN, USB_PRODUCT_ALLIEDTELESYN_ATUSB100, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC110T, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100, 0)}, - {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100, 0)}, - {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100, AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX, 0)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3, AUE_FLAG_LSYS | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4, AUE_FLAG_LSYS | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA, AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_ELCON, USB_PRODUCT_ELCON_PLAN, AUE_FLAG_PNA | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSB20, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0, 0)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2, 0)}, - {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET, 0)}, - {USB_VPI(USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNBR402W, 0)}, - {USB_VPI(USB_VENDOR_HAWKING, USB_PRODUCT_HAWKING_UF100, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_HP, USB_PRODUCT_HP_HN210E, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX, 0)}, - {USB_VPI(USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX, 0)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1, AUE_FLAG_LSYS | AUE_FLAG_PNA)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1, AUE_FLAG_LSYS | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T, AUE_FLAG_LSYS)}, - {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1, 0)}, - {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5, 0)}, - {USB_VPI(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN110, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA101, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_SIIG2, USB_PRODUCT_SIIG2_USBTOETHER, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB, 0)}, - {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2206USB, AUE_FLAG_PII)}, - {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100, 0)}, - {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB110, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_3COM, USB_PRODUCT_3COM_3C460B, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_DSB650TX_PNA, 0)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_UFE1000, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX10, 0)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX1, AUE_FLAG_PNA | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX2, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX4, AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX5, AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX6, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX7, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX8, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ABOCOM, USB_PRODUCT_ABOCOM_XX9, AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_SS1001, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ACCTON, USB_PRODUCT_ACCTON_USB320_EC, 0)}, + {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_2, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_3, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII_4, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUSII, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ADMTEK, USB_PRODUCT_ADMTEK_PEGASUS, AUE_FLAG_PNA | AUE_FLAG_DUAL_PHY)}, + {USB_VPI(USB_VENDOR_AEI, USB_PRODUCT_AEI_FASTETHERNET, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ALLIEDTELESYN, USB_PRODUCT_ALLIEDTELESYN_ATUSB100, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ATEN, USB_PRODUCT_ATEN_UC110T, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_BELKIN, USB_PRODUCT_BELKIN_USB2LAN, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USB100, 0)}, + {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBE100, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBEL100, 0)}, + {USB_VPI(USB_VENDOR_BILLIONTON, USB_PRODUCT_BILLIONTON_USBLP100, AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TXS, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB_TX, 0)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX1, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX3, AUE_FLAG_LSYS | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX4, AUE_FLAG_LSYS | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX_PNA, AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650TX, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_ELCON, USB_PRODUCT_ELCON_PLAN, AUE_FLAG_PNA | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSB20, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBLTX, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX0, 0)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX1, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX2, 0)}, + {USB_VPI(USB_VENDOR_ELECOM, USB_PRODUCT_ELECOM_LDUSBTX3, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_ELSA, USB_PRODUCT_ELSA_USB2ETHERNET, 0)}, + {USB_VPI(USB_VENDOR_GIGABYTE, USB_PRODUCT_GIGABYTE_GNBR402W, 0)}, + {USB_VPI(USB_VENDOR_HAWKING, USB_PRODUCT_HAWKING_UF100, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_HP, USB_PRODUCT_HP_HN210E, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTXS, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_IODATA, USB_PRODUCT_IODATA_USBETTX, 0)}, + {USB_VPI(USB_VENDOR_KINGSTON, USB_PRODUCT_KINGSTON_KNU101TX, 0)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100H1, AUE_FLAG_LSYS | AUE_FLAG_PNA)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB100TX, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TA, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX1, AUE_FLAG_LSYS | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10TX2, AUE_FLAG_LSYS | AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_LINKSYS, USB_PRODUCT_LINKSYS_USB10T, AUE_FLAG_LSYS)}, + {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUA2TX5, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX1, 0)}, + {USB_VPI(USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUATX5, 0)}, + {USB_VPI(USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_MN110, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA101, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_SIEMENS, USB_PRODUCT_SIEMENS_SPEEDSTREAM, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_SIIG2, USB_PRODUCT_SIIG2_USBTOETHER, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_SMARTBRIDGES, USB_PRODUCT_SMARTBRIDGES_SMARTNIC, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2202USB, 0)}, + {USB_VPI(USB_VENDOR_SMC, USB_PRODUCT_SMC_2206USB, AUE_FLAG_PII)}, + {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB100, 0)}, + {USB_VPI(USB_VENDOR_SOHOWARE, USB_PRODUCT_SOHOWARE_NUB110, AUE_FLAG_PII)}, }; /* prototypes */ @@ -182,48 +174,34 @@ static device_probe_t aue_probe; static device_attach_t aue_attach; static device_detach_t aue_detach; static device_shutdown_t aue_shutdown; +static miibus_readreg_t aue_miibus_readreg; +static miibus_writereg_t aue_miibus_writereg; +static miibus_statchg_t aue_miibus_statchg; -static usb2_callback_t aue_intr_clear_stall_callback; static usb2_callback_t aue_intr_callback; -static usb2_callback_t aue_bulk_read_clear_stall_callback; static usb2_callback_t aue_bulk_read_callback; -static usb2_callback_t aue_bulk_write_clear_stall_callback; static usb2_callback_t aue_bulk_write_callback; -static void aue_cfg_do_request(struct aue_softc *, - struct usb2_device_request *, void *); -static uint8_t aue_cfg_csr_read_1(struct aue_softc *, uint16_t); -static uint16_t aue_cfg_csr_read_2(struct aue_softc *, uint16_t); -static void aue_cfg_csr_write_1(struct aue_softc *, uint16_t, uint8_t); -static void aue_cfg_csr_write_2(struct aue_softc *, uint16_t, uint16_t); -static void aue_cfg_eeprom_getword(struct aue_softc *, uint8_t, uint8_t *); -static void aue_cfg_read_eeprom(struct aue_softc *, uint8_t *, uint16_t, +static usb2_ether_fn_t aue_attach_post; +static usb2_ether_fn_t aue_init; +static usb2_ether_fn_t aue_stop; +static usb2_ether_fn_t aue_start; +static usb2_ether_fn_t aue_tick; +static usb2_ether_fn_t aue_setmulti; +static usb2_ether_fn_t aue_setpromisc; + +static uint8_t aue_csr_read_1(struct aue_softc *, uint16_t); +static uint16_t aue_csr_read_2(struct aue_softc *, uint16_t); +static void aue_csr_write_1(struct aue_softc *, uint16_t, uint8_t); +static void aue_csr_write_2(struct aue_softc *, uint16_t, uint16_t); +static void aue_eeprom_getword(struct aue_softc *, int, uint16_t *); +static void aue_read_eeprom(struct aue_softc *, uint8_t *, uint16_t, uint16_t); +static void aue_reset(struct aue_softc *); +static void aue_reset_pegasus_II(struct aue_softc *); -static miibus_readreg_t aue_cfg_miibus_readreg; -static miibus_writereg_t aue_cfg_miibus_writereg; -static miibus_statchg_t aue_cfg_miibus_statchg; - -static usb2_config_td_command_t aue_cfg_setmulti; -static usb2_config_td_command_t aue_cfg_first_time_setup; -static usb2_config_td_command_t aue_config_copy; -static usb2_config_td_command_t aue_cfg_tick; -static usb2_config_td_command_t aue_cfg_pre_init; -static usb2_config_td_command_t aue_cfg_init; -static usb2_config_td_command_t aue_cfg_promisc_upd; -static usb2_config_td_command_t aue_cfg_ifmedia_upd; -static usb2_config_td_command_t aue_cfg_pre_stop; -static usb2_config_td_command_t aue_cfg_stop; - -static void aue_cfg_reset_pegasus_II(struct aue_softc *); -static void aue_cfg_reset(struct aue_softc *); -static void aue_start_cb(struct ifnet *); -static void aue_init_cb(void *); -static void aue_start_transfers(struct aue_softc *); -static int aue_ifmedia_upd_cb(struct ifnet *); -static void aue_ifmedia_sts_cb(struct ifnet *, struct ifmediareq *); -static int aue_ioctl_cb(struct ifnet *, u_long, caddr_t); -static void aue_watchdog(void *); +static int aue_ifmedia_upd(struct ifnet *); +static void aue_ifmedia_sts(struct ifnet *, struct ifmediareq *); static const struct usb2_config aue_config[AUE_N_TRANSFER] = { @@ -233,7 +211,7 @@ static const struct usb2_config aue_conf .direction = UE_DIR_OUT, .mh.bufsize = (MCLBYTES + 2), .mh.flags = {.pipe_bof = 1,.force_short_xfer = 1,}, - .mh.callback = &aue_bulk_write_callback, + .mh.callback = aue_bulk_write_callback, .mh.timeout = 10000, /* 10 seconds */ }, @@ -243,29 +221,7 @@ static const struct usb2_config aue_conf .direction = UE_DIR_IN, .mh.bufsize = (MCLBYTES + 4 + ETHER_CRC_LEN), .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, - .mh.callback = &aue_bulk_read_callback, - }, - - [AUE_BULK_CS_WR] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = &aue_bulk_write_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ - }, - - [AUE_BULK_CS_RD] = { - .type = UE_CONTROL, - .endpoint = 0x00, /* Control pipe */ - .direction = UE_DIR_ANY, - .mh.bufsize = sizeof(struct usb2_device_request), - .mh.flags = {}, - .mh.callback = &aue_bulk_read_clear_stall_callback, - .mh.timeout = 1000, /* 1 second */ - .mh.interval = 50, /* 50ms */ + .mh.callback = aue_bulk_read_callback, }, [AUE_INTR_DT_RD] = { @@ -274,18 +230,7 @@ static const struct usb2_config aue_conf .direction = UE_DIR_IN, .mh.flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, .mh.bufsize = 0, /* use wMaxPacketSize */ - .mh.callback = &aue_intr_callb