Changeset 8efa986 for lib/format_dpdk.c


Ignore:
Timestamp:
12/14/17 11:03:03 (3 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
a6f2d1d
Parents:
b3199cf
Message:

Ensure dpdk snap length is rounded up to next power of 2

Otherwise, we run the risk of the mbufs being too small for our
anticipated packets.

Changed dpdk_get_framing_length and dpdk_get_stats to be accessible
via format_dpdk.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dpdk.c

    rc7e547e r8efa986  
    5555#include <endian.h>
    5656#include <string.h>
     57#include <math.h>
    5758
    5859#if HAVE_LIBNUMA
     
    10591060                        port_conf.rxmode.max_rx_pkt_len = 0;
    10601061                } else {
     1062                        double expn;
     1063
    10611064                        /* Use jumbo frames */
    10621065                        port_conf.rxmode.jumbo_frame = 1;
    10631066                        port_conf.rxmode.max_rx_pkt_len = format_data->snaplen;
     1067
     1068                        /* Use less buffers if we're supporting jumbo frames
     1069                         * otherwise we won't be able to allocate memory.
     1070                         */
     1071                        if (format_data->snaplen > 1500) {
     1072                                format_data->nb_rx_buf /= 2;
     1073                        }
     1074
     1075                        /* snaplen should be rounded up to next power of two
     1076                         * to ensure enough memory is allocated for each
     1077                         * mbuf :(
     1078                         */
     1079                        expn = ceil(log2((double)(format_data->snaplen)));
     1080                        format_data->snaplen = pow(2, (int)expn);
    10641081                }
    10651082
     
    15891606}
    15901607
    1591 static int dpdk_get_framing_length (const libtrace_packet_t *packet) {
     1608int dpdk_get_framing_length (const libtrace_packet_t *packet) {
    15921609        struct dpdk_addt_hdr * hdr = get_addt_hdr(packet);
    15931610        if (hdr->flags & INCLUDES_HW_TIMESTAMP)
     
    19912008}
    19922009
    1993 static void dpdk_get_stats(libtrace_t *trace, libtrace_stat_t *stats) {
     2010void dpdk_get_stats(libtrace_t *trace, libtrace_stat_t *stats) {
    19942011        struct rte_eth_stats dev_stats = {0};
    19952012
Note: See TracChangeset for help on using the changeset viewer.