Ignore:
Timestamp:
02/19/15 13:05:59 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
694823f
Parents:
5ab626a
Message:

Move the ring sizes to the stream structures, it's possible rings could end up different sizes.
Other than that their are many operation related to reading packets which rely upon it and
it seems more natural to include this against the stream.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux_ring.c

    r5ab626a re4f27d1  
    6565#ifdef HAVE_NETPACKET_PACKET_H
    6666/* Get current frame in the ring buffer*/
    67 #define GET_CURRENT_BUFFER(libtrace, stream) \
     67#define GET_CURRENT_BUFFER(stream) \
    6868        ((void *)stream->rx_ring +                              \
    6969         (stream->rxring_offset *                               \
    70           FORMAT_DATA->req.tp_frame_size))
     70          stream->req.tp_frame_size))
    7171#endif
    7272
     
    120120        /* Calculate block size */
    121121        req->tp_block_size = pagesize << max_order;
     122        /* If max order is too high this might become 0 */
     123        if (req->tp_block_size == 0) {
     124                calculate_buffers(req, fd, uri, max_order-1);
     125                return;
     126        }
    122127        do {
    123128                req->tp_block_size >>= 1;
     
    178183         */
    179184        while(1) {
    180                 fprintf(stderr, "max_order=%d\n", *max_order);
    181185                if (*max_order <= 0) {
    182186                        strncpy(error,
     
    202206                } else break;
    203207        }
    204         fprintf(stderr, "max_order=%d\n", *max_order);
    205208
    206209        /* Map the ring buffer into userspace */
     
    260263        if(socket_to_packetmmap(libtrace->uridata, PACKET_RX_RING,
    261264                                stream->fd,
    262                                 &FORMAT_DATA->req,
     265                                &stream->req,
    263266                                &stream->rx_ring,
    264267                                &FORMAT_DATA->max_order,
     
    468471       
    469472        /* Fetch the current frame */
    470         header = GET_CURRENT_BUFFER(libtrace, stream);
     473        header = GET_CURRENT_BUFFER(stream);
    471474        assert((((unsigned long) header) & (pagesize - 1)) == 0);
    472475
     
    534537        /* Move to next buffer */
    535538        stream->rxring_offset++;
    536         stream->rxring_offset %= FORMAT_DATA->req.tp_frame_nr;
     539        stream->rxring_offset %= stream->req.tp_frame_nr;
    537540
    538541        /* We just need to get prepare_packet to set all our packet pointers
     
    575578
    576579        /* Fetch the current frame */
    577         header = GET_CURRENT_BUFFER(libtrace, FORMAT_DATA_FIRST);
     580        header = GET_CURRENT_BUFFER(FORMAT_DATA_FIRST);
    578581        if (header->tp_status & TP_STATUS_USER) {
    579582                /* We have a frame waiting */
Note: See TracChangeset for help on using the changeset viewer.