Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 May 2009 06:54:53 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r192296 - in user/kmacy/releng_7_2_fcs/sys: dev/cxgb net netinet netinet6 sys
Message-ID:  <200905180654.n4I6srca052889@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Mon May 18 06:54:53 2009
New Revision: 192296
URL: http://svn.freebsd.org/changeset/base/192296

Log:
  merge fixes
  
  191605
  191606
  191607
  191608
  191609
  191610
  191899
  192009
  192011
  192085
  192282

Modified:
  user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c
  user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c
  user/kmacy/releng_7_2_fcs/sys/net/flowtable.c
  user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c
  user/kmacy/releng_7_2_fcs/sys/net/if_ef.c
  user/kmacy/releng_7_2_fcs/sys/netinet/in.c
  user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c
  user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h

Modified: user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/dev/cxgb/cxgb_multiq.c	Mon May 18 06:54:53 2009	(r192296)
@@ -135,29 +135,6 @@ cxgb_pcpu_enqueue_packet_(struct sge_qse
 	return (err);
 }
 
-int
-cxgb_pcpu_enqueue_packet(struct ifnet *ifp, struct mbuf *m)
-{
-	struct port_info *pi = ifp->if_softc;
-	struct sge_qset *qs;
-	int err = 0, qidx;
-#ifdef IFNET_MULTIQUEUE
-	int32_t calc_cookie;
-
-	calc_cookie = m->m_pkthdr.flowid;
-	qidx = cxgb_pcpu_cookie_to_qidx(pi, calc_cookie);
-#else
-	qidx = 0;
-#endif	    
-	qs = &pi->adapter->sge.qs[qidx];
-	if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
-		IFQ_ENQUEUE(qs->txq[0].txq_ifq, m, err);
-	} else {
-		err = cxgb_pcpu_enqueue_packet_(qs, m);
-	}
-	return (err);
-}
-
 static int
 cxgb_dequeue_packet(struct sge_txq *txq, struct mbuf **m_vec)
 {
@@ -166,20 +143,7 @@ cxgb_dequeue_packet(struct sge_txq *txq,
 	int count, size, coalesced;
 	struct adapter *sc;
 
-#ifndef IFNET_MULTIQUEUE
-	struct port_info *pi = txq->port;
-
-	mtx_assert(&txq->lock, MA_OWNED);
-	if (txq->immpkt != NULL)
-		panic("immediate packet set");
-
-	IFQ_DRV_DEQUEUE(&pi->ifp->if_snd, m);
-	if (m == NULL)
-		return (0);
-	
-	m_vec[0] = m;
-	return (1);
-#endif
+#ifdef ALTQ
 	if (ALTQ_IS_ENABLED(txq->txq_ifq)) {
 		IFQ_DRV_DEQUEUE(txq->txq_ifq, m);
 		if (m == NULL)
@@ -188,7 +152,7 @@ cxgb_dequeue_packet(struct sge_txq *txq,
 		m_vec[0] = m;
 		return (1);		
 	}
-	
+#endif
 	mtx_assert(&txq->lock, MA_OWNED);
 	coalesced = count = size = 0;
 	qs = txq_to_qset(txq, TXQ_ETH);
@@ -332,20 +296,14 @@ cxgb_pcpu_start_(struct sge_qset *qs, st
 	}
 
 	stopped = isset(&qs->txq_stopped, TXQ_ETH);
-	flush = ((
-#ifdef IFNET_MULTIQUEUE
-		 !buf_ring_empty(txq->txq_mr)
-#else			     
-		 !IFQ_DRV_IS_EMPTY(&pi->ifp->if_snd)
-#endif
+	flush = ((!drbr_empty(pi->ifp, txq->txq_mr)
 		 && !stopped) || txq->immpkt); 
 	max_desc = tx_flush ? TX_ETH_Q_SIZE : TX_START_MAX_DESC;
 	
 	err = flush ? cxgb_tx(qs, max_desc) : 0;
 
 	if ((tx_flush && flush && err == 0) &&
-	    (!buf_ring_empty(txq->txq_mr)  ||
-		!IFQ_DRV_IS_EMPTY(&pi->ifp->if_snd))) {
+	    !drbr_empty(pi->ifp, txq->txq_mr)) {
 		struct thread *td = curthread;
 
 		if (++i > 1) {
@@ -408,9 +366,6 @@ cxgb_start(struct ifnet *ifp)
 	if (!p->link_config.link_ok)
 		return;
 
-	if (IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-		return;
-
 	cxgb_pcpu_transmit(ifp, NULL);
 }
 

Modified: user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/net/bridgestp.c	Mon May 18 06:54:53 2009	(r192296)
@@ -98,7 +98,6 @@ static void	bstp_decode_bpdu(struct bstp
 		    struct bstp_config_unit *);
 static void	bstp_send_bpdu(struct bstp_state *, struct bstp_port *,
 		    struct bstp_cbpdu *);
-static void	bstp_enqueue(struct ifnet *, struct mbuf *);
 static int	bstp_pdu_flags(struct bstp_port *);
 static void	bstp_received_stp(struct bstp_state *, struct bstp_port *,
 		    struct mbuf **, struct bstp_tbpdu *);
@@ -262,7 +261,7 @@ bstp_transmit_tcn(struct bstp_state *bs,
 	memcpy(mtod(m, caddr_t) + sizeof(*eh), &bpdu, sizeof(bpdu));
 
 	bp->bp_txcount++;
-	bstp_enqueue(ifp, m);
+	ifp->if_transmit(ifp, m);
 }
 
 static void
@@ -391,18 +390,7 @@ bstp_send_bpdu(struct bstp_state *bs, st
 	m->m_len = m->m_pkthdr.len;
 
 	bp->bp_txcount++;
-	bstp_enqueue(ifp, m);
-}
-
-static void
-bstp_enqueue(struct ifnet *dst_ifp, struct mbuf *m)
-{
-	int err = 0;
-
-	IFQ_ENQUEUE(&dst_ifp->if_snd, m, err);
-
-	if ((dst_ifp->if_drv_flags & IFF_DRV_OACTIVE) == 0)
-		(*dst_ifp->if_start)(dst_ifp);
+	ifp->if_transmit(ifp, m);
 }
 
 static int

Modified: user/kmacy/releng_7_2_fcs/sys/net/flowtable.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/net/flowtable.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/net/flowtable.c	Mon May 18 06:54:53 2009	(r192296)
@@ -438,7 +438,6 @@ static void
 flowtable_pcpu_unlock(struct flowtable *table, uint32_t hash)
 {
 
-	mb();
 	critical_exit();
 }
 

Modified: user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/net/if_arcsubr.c	Mon May 18 06:54:53 2009	(r192296)
@@ -237,7 +237,7 @@ arc_output(struct ifnet *ifp, struct mbu
 
 	BPF_MTAP(ifp, m);
 
-	IFQ_HANDOFF(ifp, m, error);
+	error = ifp->if_transmit(ifp, m);
 
 	return (error);
 

Modified: user/kmacy/releng_7_2_fcs/sys/net/if_ef.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/net/if_ef.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/net/if_ef.c	Mon May 18 06:54:53 2009	(r192296)
@@ -222,7 +222,7 @@ ef_start(struct ifnet *ifp)
 		if (m == 0)
 			break;
 		BPF_MTAP(ifp, m);
-		IFQ_HANDOFF(p, m, error);
+		error = p->if_transmit(p, m);
 		if (error) {
 			ifp->if_oerrors++;
 			continue;

Modified: user/kmacy/releng_7_2_fcs/sys/netinet/in.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/netinet/in.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/netinet/in.c	Mon May 18 06:54:53 2009	(r192296)
@@ -45,13 +45,16 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/proc.h>
 #include <sys/sysctl.h>
+#include <sys/syslog.h>
 #include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_var.h>
+#include <net/if_dl.h>
 #include <net/if_llatbl.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_var.h>
@@ -728,6 +731,9 @@ in_ifinit(struct ifnet *ifp, struct in_i
 	INIT_VNET_INET(ifp->if_vnet);
 	register u_long i = ntohl(sin->sin_addr.s_addr);
 	struct sockaddr_in oldaddr;
+	struct rtentry *rt = NULL;
+	struct rt_addrinfo info;
+	static struct sockaddr_dl null_sdl = {sizeof(null_sdl), AF_LINK};
 	int s = splimp(), flags = RTF_UP, error = 0;
 
 	oldaddr = ia->ia_addr;
@@ -816,6 +822,32 @@ in_ifinit(struct ifnet *ifp, struct in_i
 	if ((error = in_addprefix(ia, flags)) != 0)
 		return (error);
 
+	if (ia->ia_addr.sin_addr.s_addr == INADDR_ANY)
+		return (0);
+
+	/*
+	 * add a loopback route to self
+	 */
+	if (!(ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {
+		bzero(&info, sizeof(info));
+		info.rti_ifp = V_loif;
+		info.rti_flags = ia->ia_flags | RTF_HOST | RTF_STATIC;
+		info.rti_info[RTAX_DST] = (struct sockaddr *)&ia->ia_addr;
+		info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl;
+		error = rtrequest1_fib(RTM_ADD, &info, &rt, 0);
+
+		if (error == 0 && rt != NULL) {
+			RT_LOCK(rt);
+			((struct sockaddr_dl *)rt->rt_gateway)->sdl_type  =
+				rt->rt_ifp->if_type;
+			((struct sockaddr_dl *)rt->rt_gateway)->sdl_index =
+				rt->rt_ifp->if_index;
+			RT_REMREF(rt);
+			RT_UNLOCK(rt);
+		} else if (error != 0)
+			log(LOG_INFO, "in_ifinit: insertion failed\n");
+	}
+
 	return (error);
 }
 
@@ -895,10 +927,29 @@ in_scrubprefix(struct in_ifaddr *target)
 	struct in_ifaddr *ia;
 	struct in_addr prefix, mask, p;
 	int error;
+	struct rt_addrinfo info;
+	struct sockaddr_dl null_sdl;
 
 	if ((target->ia_flags & IFA_ROUTE) == 0)
 		return (0);
 
+	if ((target->ia_addr.sin_addr.s_addr != INADDR_ANY) &&
+	    !(target->ia_ifp->if_flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {
+		bzero(&null_sdl, sizeof(null_sdl));
+		null_sdl.sdl_len = sizeof(null_sdl);
+		null_sdl.sdl_family = AF_LINK;
+		null_sdl.sdl_type = V_loif->if_type;
+		null_sdl.sdl_index = V_loif->if_index;
+		bzero(&info, sizeof(info));
+		info.rti_flags = target->ia_flags | RTF_HOST | RTF_STATIC;
+		info.rti_info[RTAX_DST] = (struct sockaddr *)&target->ia_addr;
+		info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&null_sdl;
+		error = rtrequest1_fib(RTM_DELETE, &info, NULL, 0);
+
+		if (error != 0)
+			log(LOG_INFO, "in_scrubprefix: deletion failed\n");
+	}
+
 	if (rtinitflags(target))
 		prefix = target->ia_dstaddr.sin_addr;
 	else {
@@ -1027,7 +1078,6 @@ in_ifdetach(struct ifnet *ifp)
 	in_purgemaddrs(ifp);
 }
 
-#include <sys/syslog.h>
 #include <net/if_dl.h>
 #include <netinet/if_ether.h>
 

Modified: user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/netinet6/in6.c	Mon May 18 06:54:53 2009	(r192296)
@@ -1148,6 +1148,28 @@ in6_purgeaddr(struct ifaddr *ifa)
 	struct ifnet *ifp = ifa->ifa_ifp;
 	struct in6_ifaddr *ia = (struct in6_ifaddr *) ifa;
 	struct in6_multi_mship *imm;
+	struct sockaddr_in6 mltaddr, mltmask;
+	struct rtentry rt0;
+	struct sockaddr_dl gateway;
+	struct sockaddr_in6 mask, addr;
+	int plen, error;
+	struct rtentry *rt;
+	struct ifaddr *ifa0, *nifa;
+
+	/*
+	 * find another IPv6 address as the gateway for the
+	 * link-local and node-local all-nodes multicast
+	 * address routes
+	 */
+	TAILQ_FOREACH_SAFE(ifa0, &ifp->if_addrhead, ifa_link, nifa) {
+		if ((ifa0->ifa_addr->sa_family != AF_INET6) ||
+		    memcmp(&satosin6(ifa0->ifa_addr)->sin6_addr,
+			   &ia->ia_addr.sin6_addr, 
+			   sizeof(struct in6_addr)) == 0)
+			continue;
+		else
+			break;
+	}
 
 	/* stop DAD processing */
 	nd6_dad_stop(ifa);
@@ -1156,7 +1178,25 @@ in6_purgeaddr(struct ifaddr *ifa)
 	lla_lookup(LLTABLE6(ifp), (LLE_DELETE | LLE_IFADDR),
 	    (struct sockaddr *)&ia->ia_addr);
 	IF_AFDATA_UNLOCK(ifp);
-	
+
+	/*
+	 * initialize for rtmsg generation
+	 */
+	bzero(&gateway, sizeof(gateway));
+	gateway.sdl_len = sizeof(gateway);
+	gateway.sdl_family = AF_LINK;
+	gateway.sdl_nlen = 0;
+	gateway.sdl_alen = ifp->if_addrlen;
+	/* */
+	bzero(&rt0, sizeof(rt0));
+	rt0.rt_gateway = (struct sockaddr *)&gateway;
+	memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask));
+	memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr));
+	rt_mask(&rt0) = (struct sockaddr *)&mask;
+	rt_key(&rt0) = (struct sockaddr *)&addr;
+	rt0.rt_flags = RTF_HOST | RTF_STATIC;
+	rt_newaddrmsg(RTM_DELETE, ifa, 0, &rt0);
+
 	/*
 	 * leave from multicast groups we have joined for the interface
 	 */
@@ -1165,6 +1205,139 @@ in6_purgeaddr(struct ifaddr *ifa)
 		in6_leavegroup(imm);
 	}
 
+	/*
+	 * remove the link-local all-nodes address
+	 */
+	bzero(&mltmask, sizeof(mltmask));
+	mltmask.sin6_len = sizeof(struct sockaddr_in6);
+	mltmask.sin6_family = AF_INET6;
+	mltmask.sin6_addr = in6mask32;
+
+	bzero(&mltaddr, sizeof(mltaddr));
+	mltaddr.sin6_len = sizeof(struct sockaddr_in6);
+	mltaddr.sin6_family = AF_INET6;
+	mltaddr.sin6_addr = in6addr_linklocal_allnodes;
+
+	if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) !=
+	    0)
+		goto cleanup; 
+
+	rt = rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL);
+	if (rt != NULL && rt->rt_gateway != NULL &&
+	    (memcmp(&satosin6(rt->rt_gateway)->sin6_addr, 
+		    &ia->ia_addr.sin6_addr,
+		    sizeof(ia->ia_addr.sin6_addr)) == 0)) {
+		/* 
+		 * if no more IPv6 address exists on this interface
+		 * then remove the multicast address route
+		 */
+		if (ifa0 == NULL) {
+			memcpy(&mltaddr.sin6_addr, &satosin6(rt_key(rt))->sin6_addr, 
+			       sizeof(mltaddr.sin6_addr));
+			RTFREE_LOCKED(rt);
+			error = rtrequest(RTM_DELETE, (struct sockaddr *)&mltaddr,
+					  (struct sockaddr *)&ia->ia_addr,
+					  (struct sockaddr *)&mltmask, RTF_UP,
+					  (struct rtentry **)0);
+			if (error)
+				log(LOG_INFO, "in6_purgeaddr: link-local all-nodes"
+				    "multicast address deletion error\n");
+		} else {
+			/*
+			 * replace the gateway of the route
+			 */
+			struct sockaddr_in6 sa;
+
+			bzero(&sa, sizeof(sa));
+			sa.sin6_len = sizeof(struct sockaddr_in6);
+			sa.sin6_family = AF_INET6;
+			memcpy(&sa.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, 
+			       sizeof(sa.sin6_addr));
+			in6_setscope(&sa.sin6_addr, ifa0->ifa_ifp, NULL);
+			memcpy(rt->rt_gateway, &sa, sizeof(sa));
+			RTFREE_LOCKED(rt);
+		}
+	} else {
+		if (rt != NULL)
+			RTFREE_LOCKED(rt);
+	}
+
+	/*
+	 * remove the node-local all-nodes address
+	 */
+	mltaddr.sin6_addr = in6addr_nodelocal_allnodes;
+	if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) !=
+	    0)
+		goto cleanup;
+
+	rt = rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL);
+	if (rt != NULL && rt->rt_gateway != NULL &&
+	    (memcmp(&satosin6(rt->rt_gateway)->sin6_addr, 
+		    &ia->ia_addr.sin6_addr,
+		    sizeof(ia->ia_addr.sin6_addr)) == 0)) {
+		/* 
+		 * if no more IPv6 address exists on this interface
+		 * then remove the multicast address route
+		 */
+		if (ifa0 == NULL) {
+			memcpy(&mltaddr.sin6_addr, &satosin6(rt_key(rt))->sin6_addr, 
+			       sizeof(mltaddr.sin6_addr));
+
+			RTFREE_LOCKED(rt);
+			error = rtrequest(RTM_DELETE, (struct sockaddr *)&mltaddr,
+					  (struct sockaddr *)&ia->ia_addr,
+					  (struct sockaddr *)&mltmask, RTF_UP,
+					  (struct rtentry **)0);
+
+			if (error)
+				log(LOG_INFO, "in6_purgeaddr: node-local all-nodes"
+				    "multicast address deletion error\n");
+		} else {
+			/*
+			 * replace the gateway of the route
+			 */
+			struct sockaddr_in6 sa;
+
+			bzero(&sa, sizeof(sa));
+			sa.sin6_len = sizeof(struct sockaddr_in6);
+			sa.sin6_family = AF_INET6;
+			memcpy(&sa.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, 
+			       sizeof(sa.sin6_addr));
+			in6_setscope(&sa.sin6_addr, ifa0->ifa_ifp, NULL);
+			memcpy(rt->rt_gateway, &sa, sizeof(sa));
+			RTFREE_LOCKED(rt);
+		}
+	} else {
+		if (rt != NULL)
+			RTFREE_LOCKED(rt);
+	}
+
+cleanup:
+
+	plen = in6_mask2len(&ia->ia_prefixmask.sin6_addr, NULL); /* XXX */
+	if ((ia->ia_flags & IFA_ROUTE) && plen == 128) {
+		int error;
+		struct sockaddr *dstaddr;
+
+		/* 
+		 * use the interface address if configuring an
+		 * interface address with a /128 prefix len
+		 */
+		if (ia->ia_dstaddr.sin6_family == AF_INET6)
+			dstaddr = (struct sockaddr *)&ia->ia_dstaddr;
+		else
+			dstaddr = (struct sockaddr *)&ia->ia_addr;
+
+		error = rtrequest(RTM_DELETE,
+		    (struct sockaddr *)dstaddr,
+		    (struct sockaddr *)&ia->ia_addr,
+		    (struct sockaddr *)&ia->ia_prefixmask,
+		    ia->ia_flags | RTF_HOST, NULL);
+		if (error != 0)
+			return;
+		ia->ia_flags &= ~IFA_ROUTE;
+	}
+
 	in6_unlink_ifa(ia, ifp);
 }
 
@@ -1565,6 +1738,9 @@ in6_ifinit(struct ifnet *ifp, struct in6
 	/* Add ownaddr as loopback rtentry, if necessary (ex. on p2p link). */
 	if (newhost) {
 		struct llentry *ln;
+		struct rtentry rt;
+		struct sockaddr_dl gateway;
+		struct sockaddr_in6 mask, addr;
 
 		IF_AFDATA_LOCK(ifp);
 		ia->ia_ifa.ifa_rtrequest = NULL;
@@ -1578,8 +1754,27 @@ in6_ifinit(struct ifnet *ifp, struct in6
 		if (ln != NULL) {
 			ln->la_expire = 0;  /* for IPv6 this means permanent */
 			ln->ln_state = ND6_LLINFO_REACHABLE;
+			/*
+			 * initialize for rtmsg generation
+			 */
+			bzero(&gateway, sizeof(gateway));
+			gateway.sdl_len = sizeof(gateway);
+			gateway.sdl_family = AF_LINK;
+			gateway.sdl_nlen = 0;
+			gateway.sdl_alen = 6;
+			memcpy(gateway.sdl_data, &ln->ll_addr.mac_aligned, sizeof(ln->ll_addr));
+			/* */
 			LLE_WUNLOCK(ln);
 		}
+
+		bzero(&rt, sizeof(rt));
+		rt.rt_gateway = (struct sockaddr *)&gateway;
+		memcpy(&mask, &ia->ia_prefixmask, sizeof(ia->ia_prefixmask));
+		memcpy(&addr, &ia->ia_addr, sizeof(ia->ia_addr));
+		rt_mask(&rt) = (struct sockaddr *)&mask;
+		rt_key(&rt) = (struct sockaddr *)&addr;
+		rt.rt_flags = RTF_UP | RTF_HOST | RTF_STATIC;
+		rt_newaddrmsg(RTM_ADD, &ia->ia_ifa, 0, &rt);
 	}
 
 	return (error);

Modified: user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h	Mon May 18 06:46:34 2009	(r192295)
+++ user/kmacy/releng_7_2_fcs/sys/sys/buf_ring.h	Mon May 18 06:54:53 2009	(r192296)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright (c) 2007,2008 Kip Macy kmacy@freebsd.org
+ * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,10 @@ struct buf_ring {
 	void			*br_ring[0];
 };
 
-
+/*
+ * multi-producer safe lock-free ring buffer enqueue
+ *
+ */
 static __inline int
 buf_ring_enqueue(struct buf_ring *br, void *buf)
 {
@@ -169,8 +172,9 @@ buf_ring_dequeue_mc(struct buf_ring *br)
 }
 
 /*
- * Single-Consumer dequeue for uses where dequeue
- * is protected by a lock
+ * single-consumer dequeue 
+ * use where dequeue is protected by a lock
+ * e.g. a network driver's tx queue lock
  */
 static __inline void *
 buf_ring_dequeue_sc(struct buf_ring *br)
@@ -208,6 +212,11 @@ buf_ring_dequeue_sc(struct buf_ring *br)
 	return (buf);
 }
 
+/*
+ * return a pointer to the first entry in the ring
+ * without modifying it, or NULL if the ring is empty
+ * race-prone if not protected by a lock
+ */
 static __inline void *
 buf_ring_peek(struct buf_ring *br)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905180654.n4I6srca052889>