Changeset e4f27d1


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.

Location:
lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux_common.c

    r5ab626a re4f27d1  
    221221                close(stream->fd);
    222222        stream->fd = -1;
    223         /* TODO maybe store size against stream XXX */
    224223        if (stream->rx_ring != MAP_FAILED)
    225224                munmap(stream->rx_ring,
    226                        FORMAT_DATA->req.tp_block_size *
    227                        FORMAT_DATA->req.tp_block_nr);
     225                       stream->req.tp_block_size *
     226                       stream->req.tp_block_nr);
    228227        stream->rx_ring = MAP_FAILED;
    229228        FORMAT_DATA->dev_stats.if_name[0] = 0;
     
    422421                   MSG_DONTWAIT) != -1) { count++; }
    423422        free(buf);
    424         fprintf(stderr, "set offset %d", count);
    425423
    426424        /* Mark that the stats are valid and apply an offset */
     
    493491                                 libtrace_thread_t *t,
    494492                                 bool reading) {
    495         fprintf(stderr, "registering thread %d!!\n", t->perpkt_num);
    496493        if (reading) {
    497494                /* XXX TODO remove this oneday make sure hasher thread still works */
  • lib/format_linux_common.h

    r5ab626a re4f27d1  
    216216        /* Flag indicating whether the statistics are current or not */
    217217        int stats_valid;
    218         /* The current ring buffer layout */
    219         struct tpacket_req req;
    220218        /* Used to determine buffer size for the ring buffer */
    221219        uint32_t max_order;
     
    257255        /* Offset within the mapped buffer */
    258256        int rxring_offset;
     257        /* The ring buffer layout */
     258        struct tpacket_req req;
    259259} ALIGN_STRUCT(CACHE_LINE_SIZE);
    260260
    261 #define ZERO_LINUX_STREAM {-1, MAP_FAILED, 0}
     261#define ZERO_LINUX_STREAM {-1, MAP_FAILED, 0, {0}}
    262262
    263263
  • lib/format_linux_int.c

    r5ab626a re4f27d1  
    132132       
    133133}
    134 
    135134
    136135#define LIBTRACE_MIN(a,b) ((a)<(b) ? (a) : (b))
     
    457456        return trace_get_capture_length(packet);
    458457}
    459 
    460 
    461 
    462 
    463458
    464459#ifdef HAVE_NETPACKET_PACKET_H
  • 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.