From owner-freebsd-stable@freebsd.org Sat Nov 21 19:12:03 2015 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6A511A333BE for ; Sat, 21 Nov 2015 19:12:03 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C5611346 for ; Sat, 21 Nov 2015 19:12:03 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from slw by zxy.spb.ru with local (Exim 4.86 (FreeBSD)) (envelope-from ) id 1a0DZg-0000VJ-8Z; Sat, 21 Nov 2015 22:11:52 +0300 Date: Sat, 21 Nov 2015 22:11:52 +0300 From: Slawa Olhovchenkov To: Luigi Rizzo Cc: Stable Stable Subject: Re: NETMAP and off-by-one? Message-ID: <20151121191152.GV31314@zxy.spb.ru> References: <20151113213039.GK48728@zxy.spb.ru> <20151114084658.GZ31314@zxy.spb.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151114084658.GZ31314@zxy.spb.ru> User-Agent: Mutt/1.5.24 (2015-08-30) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2015 19:12:03 -0000 On Sat, Nov 14, 2015 at 11:46:58AM +0300, Slawa Olhovchenkov wrote: > On Fri, Nov 13, 2015 at 03:40:04PM -0800, Luigi Rizzo wrote: > > > On Fri, Nov 13, 2015 at 1:30 PM, Slawa Olhovchenkov wrote: > > > I am see strange things: like NETMAP stop transmit after `head` and `cur` > > > touch `tail`. > > > > > > But: > > > > > > /* > > > * check if space is available in the ring. > > > */ > > > static inline int > > > nm_ring_empty(struct netmap_ring *ring) > > > { > > > return (ring->cur == ring->tail); > > > } > > > > > > i.e. if cur == (tail-1) mod ring_size -- space is available in the > > > ring and I can put packet in output buffer. > > > > The design requires to leave at least one empty slot in the buffer. > > The name of the function is correct, the comment is probably not, > > unless a bug has creeped in recently the code was very careful > > in not using the free slot that separates the two regions. > > Please, do some clarification, in case for transmit patch: > > - can I put in txring in case cur == (tail-1) mod ring_size? > - can I use poll with only `events |= POLLIN` for transmiting? > > in case for receive patch: > > - can I detect input overflow? I am asks this questions becaus in may case don't see automatic txsync on poll: device open as np->nr_ringid = NETMAP_DO_RX_POLL; np->nr_flags = NR_REG_ALL_NIC; rc = ioctl(balancer.inside.fd, NIOCREGIF, np); poll do as pollfd[1].fd = thr->inside.fd; pollfd[1].events |= POLLIN; poll(pollfd, nfd, 1000); and I don't see output sysncing w/o pollfd[1].events |= POLLIN | POLLOUT; Only one round packet outputs I see and no slot updates.