- Timestamp:
- 11/29/12 13:20:08 (9 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
- 2627439
- Parents:
- 1935565
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_linux.c
r17dc71c rf240823 272 272 /* Calculate frame size */ 273 273 req->tp_frame_size = pagesize; 274 do{274 while(req->tp_frame_size < mtu && req->tp_frame_size < LIBTRACE_PACKET_BUFSIZE){ 275 275 req->tp_frame_size <<= 1; 276 } while(req->tp_frame_size < mtu && req->tp_frame_size < LIBTRACE_PACKET_BUFSIZE);276 } 277 277 if(req->tp_frame_size > LIBTRACE_PACKET_BUFSIZE) 278 278 req->tp_frame_size >>= 1; … … 282 282 do{ 283 283 req->tp_block_size >>= 1; 284 } while((CONF_RING_FRAMES * req->tp_frame_size) < req->tp_block_size);284 } while((CONF_RING_FRAMES * req->tp_frame_size) <= req->tp_block_size); 285 285 req->tp_block_size <<= 1; 286 286 … … 295 295 (req->tp_block_size / req->tp_frame_size); 296 296 297 printf("MaxO 0x%x BS 0x%x BN 0x%x FS 0x%x FN 0x%x\n",297 /*printf("MaxO 0x%x BS 0x%x BN 0x%x FS 0x%x FN 0x%x\n", 298 298 max_order, 299 299 req->tp_block_size, 300 300 req->tp_block_nr, 301 301 req->tp_frame_size, 302 req->tp_frame_nr); 302 req->tp_frame_nr);*/ 303 303 304 304 /* In case we have some silly values*/ … … 933 933 static int linuxring_get_framing_length(const libtrace_packet_t *packet); 934 934 935 static int linuxring_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 936 937 struct tpacket2_hdr *header; 938 struct pollfd pollset; 939 int ret; 940 935 /* Release a frame back to the kernel or free() if it's a malloc'd buffer 936 */ 937 inline static void ring_release_frame(libtrace_t *libtrace, libtrace_packet_t *packet ){ 941 938 /* Free the old packet */ 939 if(packet->buffer == NULL) 940 return; 941 942 942 if(packet->buf_control == TRACE_CTRL_PACKET){ 943 943 free(packet->buffer); 944 packet->buffer = NULL; 944 945 } 945 946 if(packet->buf_control == TRACE_CTRL_EXTERNAL) { … … 955 956 } 956 957 } 958 } 959 960 static int linuxring_read_packet(libtrace_t *libtrace, libtrace_packet_t *packet) { 961 962 struct tpacket2_hdr *header; 963 struct pollfd pollset; 964 int ret; 965 966 ring_release_frame(libtrace, packet); 957 967 958 968 packet->buf_control = TRACE_CTRL_EXTERNAL; … … 968 978 */ 969 979 while (!(header->tp_status & TP_STATUS_USER)) { 980 printf("I shouldn't run if event handler\n"); 970 981 pollset.fd = FORMAT(libtrace->format_data)->fd; 971 982 pollset.events = POLLIN; … … 994 1005 linuxring_get_capture_length(packet); 995 1006 1007 } 1008 1009 /* Non-blocking read */ 1010 static libtrace_eventobj_t linuxring_event(libtrace_t *libtrace, libtrace_packet_t *packet) { 1011 struct tpacket2_hdr *header; 1012 libtrace_eventobj_t event = {0,0,0.0,0}; 1013 1014 /* We must free the old packet, otherwise select() will instantly return 1015 */ 1016 ring_release_frame(libtrace, packet); 1017 1018 /* Fetch the current frame */ 1019 header = GET_CURRENT_BUFFER(libtrace); 1020 if(header->tp_status & TP_STATUS_USER){ 1021 /* We have a frame waiting */ 1022 event.size = linuxring_read_packet(libtrace, packet); 1023 event.type = TRACE_EVENT_PACKET; 1024 } else { 1025 /* Ok we don't have a packet waiting */ 1026 event.type = TRACE_EVENT_IOWAIT; 1027 event.fd = FORMAT(libtrace->format_data)->fd; 1028 } 1029 1030 return event; 996 1031 } 997 1032 … … 1468 1503 linuxnative_get_captured_packets,/* get_captured_packets */ 1469 1504 linuxnative_get_fd, /* get_fd */ 1470 trace_event_device, /* trace_event */1505 linuxring_event, /* trace_event */ 1471 1506 linuxring_help, /* help */ 1472 1507 NULL
Note: See TracChangeset
for help on using the changeset viewer.