NETMAP and off-by-one?
Slawa Olhovchenkov
slw at zxy.spb.ru
Sat Nov 21 19:12:03 UTC 2015
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 at 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.
More information about the freebsd-stable
mailing list