Changeset 10c47a0
- Timestamp:
- 02/23/15 15:01:00 (6 years ago)
- 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:
- 526d9d0
- Parents:
- 5df059b
- Location:
- lib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_dag25.c
r5df059b r10c47a0 142 142 /* "Global" data that is stored for each DAG input trace */ 143 143 struct dag_format_data_t { 144 /* Data required for regular DUCK reporting */ 145 /* TODO: This doesn't work with the 10X2S card! I don't know how 146 * DUCK stuff works and don't know how to fix it */ 144 /* DAG device */ 145 struct dag_dev_t *device; 146 /* Boolean flag indicating whether the trace is currently attached */ 147 int stream_attached; 148 /* Data stored against each DAG input stream */ 149 libtrace_list_t *per_stream; 150 151 /* Data required for regular DUCK reporting. 152 * We put this on a new cache line otherwise we have a lot of false 153 * sharing caused by updating the last_pkt. 154 * This should only ever be accessed by the first thread stream, 155 * that includes both read and write operations. 156 */ 147 157 struct { 148 158 /* Timestamp of the last DUCK report */ … … 155 165 * DUCK format functions */ 156 166 libtrace_t *dummy_duck; 157 } duck; 158 /* DAG device */ 159 struct dag_dev_t *device; 160 /* Boolean flag indicating whether the trace is currently attached */ 161 int stream_attached; 162 /* Data stored against each DAG input stream */ 163 libtrace_list_t *per_stream; 167 } duck ALIGN_STRUCT(CACHE_LINE_SIZE); 164 168 }; 165 169 … … 914 918 packet->trace = DUCK.dummy_duck; 915 919 DUCK.last_duck = DUCK.last_pkt; 920 packet->error = sizeof(duckinf_t); 916 921 return sizeof(duckinf_t); 917 922 } … … 967 972 /* Converts a buffer containing a recently read DAG packet record into a 968 973 * libtrace packet */ 969 static int dag_prepare_packet_ real(libtrace_t *libtrace,970 971 972 973 974 static int dag_prepare_packet_stream(libtrace_t *libtrace, 975 struct dag_per_stream_t *stream_data, 976 libtrace_packet_t *packet, 977 void *buffer, libtrace_rt_types_t rt_type, 978 uint32_t flags) 974 979 { 975 980 dag_record_t *erfptr; … … 1025 1030 } 1026 1031 1027 packet->error = 1;1028 1029 1032 return 0; 1030 1033 } … … 1034 1037 uint32_t flags) 1035 1038 { 1036 return dag_prepare_packet_ real(libtrace, FORMAT_DATA_FIRST, packet,1039 return dag_prepare_packet_stream(libtrace, FORMAT_DATA_FIRST, packet, 1037 1040 buffer, rt_type, flags); 1038 1041 } … … 1222 1225 int size = 0; 1223 1226 dag_record_t *erfptr = NULL; 1227 struct timeval tv; 1224 1228 int numbytes = 0; 1225 1229 uint32_t flags = 0; … … 1231 1235 maxwait.tv_usec = 250000; 1232 1236 1233 /* Check if we're due for a DUCK report */ 1234 size = dag_get_duckinfo(libtrace, packet); 1235 1236 if (size != 0) 1237 return size; 1237 /* Check if we're due for a DUCK report - only report on the first thread */ 1238 if (stream_data == FORMAT_DATA_FIRST) { 1239 size = dag_get_duckinfo(libtrace, packet); 1240 if (size != 0) 1241 return size; 1242 } 1243 1238 1244 1239 1245 /* Don't let anyone try to free our DAG memory hole! */ … … 1275 1281 packet->trace = libtrace; 1276 1282 /* Prepare the libtrace packet */ 1277 if (dag_prepare_packet_ real(libtrace, stream_data, packet, erfptr,1283 if (dag_prepare_packet_stream(libtrace, stream_data, packet, erfptr, 1278 1284 TRACE_RT_DATA_ERF, flags)) 1279 1285 return -1; 1280 1286 1281 return packet->payload ? htons(erfptr->rlen) : 1282 erf_get_framing_length(packet); 1287 /* Update the DUCK timer - don't re-order this check (false-sharing) */ 1288 if (stream_data == FORMAT_DATA_FIRST && DUCK.duck_freq != 0) { 1289 tv = trace_get_timeval(packet); 1290 DUCK.last_pkt = tv.tv_sec; 1291 } 1292 1293 packet->error = packet->payload ? htons(erfptr->rlen) : 1294 erf_get_framing_length(packet); 1295 1296 return packet->error; 1283 1297 } 1284 1298 … … 1373 1387 break; 1374 1388 } 1375 if (dag_prepare_packet_ real(libtrace, FORMAT_DATA_FIRST, packet,1389 if (dag_prepare_packet_stream(libtrace, FORMAT_DATA_FIRST, packet, 1376 1390 erfptr, TRACE_RT_DATA_ERF, flags)) { 1377 1391 event.type = TRACE_EVENT_TERMINATE; -
lib/format_dpdk.c
r694823f r10c47a0 1824 1824 * @param packets Optional - If not null nb_pkts of libtrace packets which will be prepared 1825 1825 */ 1826 static inline void dpdk_ready_pkts( struct dpdk_format_data_t *format_data, struct dpdk_per_lcore_t *plc,1826 static inline void dpdk_ready_pkts(libtrace_t *libtrace, struct dpdk_per_lcore_t *plc, 1827 1827 struct rte_mbuf **pkts, size_t nb_pkts, libtrace_packet_t **packets) { 1828 struct dpdk_format_data_t *format_data = FORMAT(libtrace); 1828 1829 struct dpdk_addt_hdr *hdr; 1829 1830 size_t i; … … 1865 1866 #endif 1866 1867 1867 assert(RTE_PKTMBUF_HEADROOM >= sizeof(struct dpdk_addt_hdr)); // TODO static compile time assert sometime??1868 ct_assert(RTE_PKTMBUF_HEADROOM >= sizeof(struct dpdk_addt_hdr)); 1868 1869 for (i = 0 ; i < nb_pkts ; ++i) { 1869 1870 … … 1873 1874 1874 1875 #if GET_MAC_CRC_CHECKSUM 1875 <<<<<<< HEAD1876 1876 /* Add back in the CRC sum */ 1877 pkts[i]->pkt.pkt_len+= ETHER_CRC_LEN;1878 pkts[i]->pkt.data_len+= ETHER_CRC_LEN;1877 rte_pktmbuf_pkt_len(pkt) += ETHER_CRC_LEN; 1878 rte_pktmbuf_data_len(pkt) += ETHER_CRC_LEN; 1879 1879 hdr->flags |= INCLUDES_CHECKSUM; 1880 =======1881 /* Add back in the CRC sum */1882 rte_pktmbuf_pkt_len(pkt) += ETHER_CRC_LEN;1883 rte_pktmbuf_data_len(pkt) += ETHER_CRC_LEN;1884 hdr->flags |= INCLUDES_CHECKSUM;1885 >>>>>>> master1886 1880 #endif 1887 1881 … … 1982 1976 packets[i]->buffer = pkts[i]; 1983 1977 packets[i]->header = pkts[i]; 1978 packets[i]->trace = libtrace; 1984 1979 #if HAS_HW_TIMESTAMPS_82580 1985 1980 packets[i]->payload = (char *) pkts[i] + sizeof(struct rte_mbuf) + … … 2042 2037 FORMAT(libtrace)->burst_size = nb_rx; 2043 2038 FORMAT(libtrace)->burst_offset = 1; 2044 dpdk_ready_pkts( FORMAT(libtrace), &FORMAT(libtrace)->per_lcore[0], FORMAT(libtrace)->burst_pkts, nb_rx, NULL);2039 dpdk_ready_pkts(libtrace, &FORMAT(libtrace)->per_lcore[0], FORMAT(libtrace)->burst_pkts, nb_rx, NULL); 2045 2040 packet->buffer = FORMAT(libtrace)->burst_pkts[0]; 2046 2041 dpdk_prepare_packet(libtrace, packet, packet->buffer, packet->type, 0); … … 2090 2085 /* Got some packets - otherwise we keep spining */ 2091 2086 //fprintf(stderr, "Doing P READ PACKET port=%d q=%d\n", (int) FORMAT(libtrace)->port, (int) get_thread_table_num(libtrace)); 2092 dpdk_ready_pkts( FORMAT(libtrace), PERPKT_FORMAT(t), pkts_burst, nb_rx, packets);2087 dpdk_ready_pkts(libtrace, PERPKT_FORMAT(t), pkts_burst, nb_rx, packets); 2093 2088 return nb_rx; 2094 2089 } … … 2212 2207 packet->type = TRACE_RT_DATA_DPDK; 2213 2208 event.type = TRACE_EVENT_PACKET; 2214 dpdk_ready_pkts( FORMAT(trace), &FORMAT(trace)->per_lcore[0], pkts_burst, 1, &packet);2209 dpdk_ready_pkts(trace, &FORMAT(trace)->per_lcore[0], pkts_burst, 1, &packet); 2215 2210 event.size = 1; // TODO should be bytes read, which essentially useless anyway 2216 2211 -
lib/format_linux_int.c
re4f27d1 r10c47a0 300 300 * we just need to get prepare_packet to set all our packet pointers 301 301 * appropriately */ 302 302 packet->trace = libtrace; 303 303 if (linuxnative_prepare_packet(libtrace, packet, packet->buffer, 304 304 packet->type, flags)) -
lib/format_linux_ring.c
re4f27d1 r10c47a0 525 525 526 526 packet->buffer = header; 527 packet->trace = libtrace; 527 528 528 529 /* If a snaplen was configured, automatically truncate the packet to -
lib/libtrace_int.h
r5ab626a r10c47a0 307 307 enum hasher_types hasher_type; 308 308 /** The hasher function - NULL implies they don't care or balance */ 309 fn_hasher hasher; // If valid using a separate thread309 fn_hasher hasher; 310 310 void *hasher_data; 311 311 /** The pread_packet choosen path for the configuration */ -
lib/trace_parallel.c
re8c0a9c r10c47a0 168 168 169 169 /** 170 * True if the trace has dedicated hasher thread otherwise false. 171 * This can be used once the hasher thread has been started. 172 */ 173 static inline int trace_has_dedicated_hasher(libtrace_t * libtrace) 170 * This can be used once the hasher thread has been started and internally after 171 * verfiy_configuration. 172 * 173 * @return true if the trace has dedicated hasher thread otherwise false. 174 */ 175 static inline bool trace_has_dedicated_hasher(libtrace_t * libtrace) 174 176 { 175 177 return libtrace->hasher_thread.type == THREAD_HASHER; … … 260 262 261 263 /** 264 * This is valid once a trace is initialised 265 * 262 266 * @return True if the format supports parallel threads. 263 267 */ … … 1429 1433 } 1430 1434 for (i = 0; i < ret; ++i) { 1431 packets[i]->trace = libtrace; 1435 /* We do not mark the packet against the trace, 1436 * before hand or after. After breaks DAG meta 1437 * packets and before is inefficient */ 1438 //packets[i]->trace = libtrace; 1432 1439 /* TODO IN FORMAT?? Like traditional libtrace */ 1433 1440 if (libtrace->snaplen>0) … … 1497 1504 */ 1498 1505 static void verify_configuration(libtrace_t *libtrace) { 1506 bool require_hasher = false; 1507 1508 /* Might we need a dedicated hasher thread? */ 1509 if (libtrace->hasher && libtrace->hasher_type != HASHER_HARDWARE) { 1510 require_hasher = true; 1511 } 1499 1512 1500 1513 if (libtrace->config.hasher_queue_size <= 0) … … 1526 1539 if (libtrace->combiner.initialise == NULL && libtrace->combiner.publish == NULL) 1527 1540 libtrace->combiner = combiner_unordered; 1541 1542 1543 /* Figure out if we are using a dedicated hasher thread? */ 1544 if (require_hasher && libtrace->config.perpkt_threads > 1) { 1545 libtrace->hasher_thread.type = THREAD_HASHER; 1546 } 1528 1547 } 1529 1548 … … 1630 1649 verify_configuration(libtrace); 1631 1650 1632 /* Try start the format */1633 if (libtrace->perpkt_thread_count > 1 &&1634 1651 /* Try start the format - we prefer parallel over single threaded, as 1652 * these formats should support messages better */ 1653 if (trace_supports_parallel(libtrace) && 1635 1654 !trace_has_dedicated_hasher(libtrace)) { 1636 printf(" This format has direct support for p's\n");1655 printf("Using the parallel trace format\n"); 1637 1656 ret = libtrace->format->pstart_input(libtrace); 1638 1657 libtrace->pread = trace_pread_packet_wrapper; 1639 1658 } else { 1659 printf("Using single threaded interface\n"); 1640 1660 if (libtrace->format->start_input) { 1641 1661 ret = libtrace->format->start_input(libtrace); … … 1644 1664 libtrace->pread = trace_pread_packet_first_in_first_served; 1645 1665 else 1666 /* Use standard read_packet */ 1646 1667 libtrace->pread = NULL; 1647 1668 } … … 1659 1680 * Special Case: If single threaded we don't need a hasher 1660 1681 */ 1661 if (libtrace->perpkt_thread_count > 1 && libtrace->hasher 1662 && libtrace->hasher_type != HASHER_HARDWARE) { 1682 if (trace_has_dedicated_hasher(libtrace)) { 1663 1683 ret = trace_start_thread(libtrace, &libtrace->hasher_thread, 1664 1684 THREAD_HASHER, hasher_entry, -1, … … 1731 1751 goto cleanup_threads; 1732 1752 } 1733 1734 /*trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "trace_pstart "1735 "failed to allocate ocache.");1736 goto cleanup_threads;*/1737 1753 1738 1754 if (libtrace_ocache_init(&libtrace->packet_freelist, … … 1990 2006 } else { 1991 2007 trace->hasher = NULL; 1992 // TODO consider how to handle freeing this1993 2008 trace->hasher_data = NULL; 1994 2009 }
Note: See TracChangeset
for help on using the changeset viewer.