Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Nov 2015 22:11:52 +0300
From:      Slawa Olhovchenkov <slw@zxy.spb.ru>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        Stable Stable <freebsd-stable@freebsd.org>
Subject:   Re: NETMAP and off-by-one?
Message-ID:  <20151121191152.GV31314@zxy.spb.ru>
In-Reply-To: <20151114084658.GZ31314@zxy.spb.ru>
References:  <20151113213039.GK48728@zxy.spb.ru> <CA%2BhQ2%2BjGrZXd5e_uR_3fBJNUeDo1eGB2hVoWJm4dsOze9KrYFA@mail.gmail.com> <20151114084658.GZ31314@zxy.spb.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <slw@zxy.spb.ru> 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.



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