Changeset 3f58e38


Ignore:
Timestamp:
09/04/14 20:06:40 (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:
6c3b3d7
Parents:
95364aa
Message:

Fixes compling with DPDK 1.6.0r2 and 1.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dpdk.c

    r95364aa r3f58e38  
    5757#include <unistd.h>
    5858#include <endian.h>
     59#include <string.h>
     60
     61/* We can deal with any minor differences by checking the RTE VERSION
     62 * Typically DPDK backports some fixes (typically for building against
     63 * newer kernels) to the older version of DPDK.
     64 *
     65 * These get released with the rX suffix. The following macros where added
     66 * in these new releases.
     67 *
     68 * Below this is a log of version that required changes to the libtrace
     69 * code (that we still attempt to support).
     70 *
     71 * Currently 1.5 to 1.7 is supported.
     72 */
     73#include <rte_version.h>
     74#ifndef RTE_VERSION_NUM
     75#       define RTE_VERSION_NUM(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))
     76#endif
     77#ifndef RTE_VER_PATCH_RELEASE
     78#       define RTE_VER_PATCH_RELEASE 0
     79#endif
     80#ifndef RTE_VERSION
     81#       define RTE_VERSION RTE_VERSION_NUM(RTE_VER_MAJOR,RTE_VER_MINOR, \
     82        RTE_VER_PATCH_LEVEL, RTE_VER_PATCH_RELEASE)
     83#endif
     84
     85/* 1.6.0r2 :
     86 *      rte_eal_pci_set_blacklist() is removed
     87 *      device_list is renamed ot pci_device_list
     88 *
     89 * Replaced by:
     90 *      rte_devargs (we can simply whitelist)
     91 */
     92#if RTE_VERSION <= RTE_VERSION_NUM(1, 6, 0, 1)
     93#       define DPDK_USE_BLACKLIST 1
     94#else
     95#       define DPDK_USE_BLACKLIST 0
     96#endif
     97
     98/*
     99 * 1.7.0 :
     100 *      rte_pmd_init_all is removed
     101 *
     102 * Replaced by:
     103 *      Nothing, no longer needed
     104 */
     105#if RTE_VERSION < RTE_VERSION_NUM(1, 7, 0, 0)
     106#       define DPDK_USE_PMD_INIT 1
     107#else
     108#       define DPDK_USE_PMD_INIT 0
     109#endif
     110
    59111#include <rte_eal.h>
    60112#include <rte_per_lcore.h>
     
    191243    int nb_tx_buf; /* The number of packet buffers in the tx ring */
    192244    struct rte_mempool * pktmbuf_pool; /* Our packet memory pool */
     245#if DPDK_USE_BLACKLIST
    193246    struct rte_pci_addr blacklist[BLACK_LIST_SIZE]; /* Holds our device blacklist */
     247        unsigned int nb_blacklist; /* Number of blacklist items in are valid */
     248#endif
    194249    char mempool_name[MEMPOOL_NAME_LEN]; /* The name of the mempool that we are using */
    195     unsigned int nb_blacklist; /* Number of blacklist items in are valid */
    196250#if HAS_HW_TIMESTAMPS_82580
    197251    /* Timestamping only relevent to RX */
     
    243297 * So blacklist all devices except the one that we wish to use so that
    244298 * the others can still be used as standard ethernet ports.
    245  */
    246 static void blacklist_devices(struct dpdk_format_data_t *format_data, struct rte_pci_addr *whitelist)
     299 *
     300 * @return 0 if successful, otherwise -1 on error.
     301 */
     302#if DPDK_USE_BLACKLIST
     303static int blacklist_devices(struct dpdk_format_data_t *format_data, struct rte_pci_addr *whitelist)
    247304{
    248305        struct rte_pci_device *dev = NULL;
     
    268325
    269326        rte_eal_pci_set_blacklist(format_data->blacklist, format_data->nb_blacklist);
    270 }
     327        return 0;
     328}
     329#else /* DPDK_USE_BLACKLIST */
     330#include <rte_devargs.h>
     331static int blacklist_devices(struct dpdk_format_data_t *format_data UNUSED, struct rte_pci_addr *whitelist)
     332{
     333        char pci_str[20] = {0};
     334        snprintf(pci_str, sizeof(pci_str), PCI_PRI_FMT,
     335                 whitelist->domain,
     336                 whitelist->bus,
     337                 whitelist->devid,
     338                 whitelist->function);
     339        if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, pci_str) < 0) {
     340                return -1;
     341        }
     342        return 0;
     343}
     344#endif
    271345
    272346/**
     
    375449                                        char * err, int errlen) {
    376450    int ret; /* Returned error codes */
    377     struct rte_pci_addr use_addr; /* The only address that we don't blacklist */   
     451    struct rte_pci_addr use_addr; /* The only address that we don't blacklist */
    378452    char cpu_number[10] = {0}; /* The CPU mask we want to bind to */
    379453    char mem_map[20] = {0}; /* The memory name */
     
    394468                "--file-prefix", mem_map, "-m", "256", NULL};
    395469    int argc = sizeof(argv) / sizeof(argv[0]) - 1;
    396    
    397     /* This initialises the Environment Abstraction Layer (EAL)
     470
    398471    /* This initialises the Environment Abstraction Layer (EAL)
    399472     * If we had slave workers these are put into WAITING state
     
    455528    dump_configuration();
    456529#endif
     530
     531#if DPDK_USE_PMD_INIT
    457532    /* This registers all available NICs with Intel DPDK
    458533     * These are not loaded until rte_eal_pci_probe() is called.
     
    463538        return -1;
    464539    }
    465 
    466     /* Black list all ports besides the one that we want to use */
    467     blacklist_devices(format_data, &use_addr);
     540#endif
     541
     542    /* Blacklist all ports besides the one that we want to use */
     543        if ((ret = blacklist_devices(format_data, &use_addr)) < 0) {
     544                snprintf(err, errlen, "Intel DPDK - Whitelisting PCI device failed,"
     545                         " are you sure the address is correct?: %s", strerror(-ret));
     546                return -1;
     547        }
    468548
    469549    /* This loads DPDK drivers against all ports that are not blacklisted */
     
    500580    FORMAT(libtrace)->promisc = -1;
    501581    FORMAT(libtrace)->pktmbuf_pool = NULL;
     582#if DPDK_USE_BLACKLIST
    502583    FORMAT(libtrace)->nb_blacklist = 0;
     584#endif
    503585    FORMAT(libtrace)->paused = DPDK_NEVER_STARTED;
    504586    FORMAT(libtrace)->mempool_name[0] = 0;
     
    533615    FORMAT(libtrace)->promisc = -1;
    534616    FORMAT(libtrace)->pktmbuf_pool = NULL;
     617#if DPDK_USE_BLACKLIST
    535618    FORMAT(libtrace)->nb_blacklist = 0;
     619#endif
    536620    FORMAT(libtrace)->paused = DPDK_NEVER_STARTED;
    537621    FORMAT(libtrace)->mempool_name[0] = 0;
Note: See TracChangeset for help on using the changeset viewer.