Blob Blame History Raw
#!/bin/bash

source configlib.sh

# Generates arch configurations in the current directory based on
# 1. an dpdk.spec file
# 2. an expanded dpdk tree

if (( $# != 2 )); then
    echo "$0: dpdk.spec dpdk_tree" >&2
    exit 1
fi

DPDKSPEC="$1"
DPDKDIR="$2"

# accumulate all arch + name triples
DPDK_CONF_MACH_ARCH=()
for arch in $(grep %define\ machine_arch "$DPDKSPEC" | sed 's@%define machine_arch @@')
do
    DPDK_CONF_MACH_ARCH+=($arch)
done

DPDK_CONF_MACH_TMPL=()
for tmpl in $(grep %define\ machine_tmpl "$DPDKSPEC" | sed 's@%define machine_tmpl @@')
do
    DPDK_CONF_MACH_TMPL+=($tmpl)
done

DPDK_CONF_MACH=()
for mach in $(grep %define\ machine\  "$DPDKSPEC" | sed 's@%define machine @@')
do
    DPDK_CONF_MACH+=($mach)
done

DPDK_TARGETS=()
for ((i=0; i < ${#DPDK_CONF_MACH[@]}; i++));
do
    DPDK_TARGETS+=("${DPDK_CONF_MACH_ARCH[$i]}-${DPDK_CONF_MACH_TMPL[$i]}-linuxapp-gcc")
    echo "DPDK-target: ${DPDK_TARGETS[$i]}"
done

OUTPUT_DIR=$(pwd)
pushd "$DPDKDIR"
for ((i=0; i < ${#DPDK_TARGETS[@]}; i++));
do
    echo "For ${DPDK_TARGETS[$i]}:"

    echo "     a. Generating initial config"
    echo "        make V=1 T=${DPDK_TARGETS[$i]} O=${DPDK_TARGETS[$i]}"
    make V=1 T=${DPDK_TARGETS[$i]} O=${DPDK_TARGETS[$i]} -j8 config
    ORIG_SHA=""
    OUTDIR="${DPDK_TARGETS[$i]}"

    echo "     b. calculating and applying sha"
    calc_sha ORIG_SHA "${OUTDIR}/.config"
    if [ "$ORIG_SHA" == "" ]; then
        echo "ERROR: Unable to get sha for arch ${DPDK_TARGETS[$i]}"
        exit 1
    fi
    echo "# -*- cfg-sha: ${ORIG_SHA}" > ${OUTDIR}/.config.new
    cat "${OUTDIR}/.config" >> "${OUTDIR}/.config.new"
    cp "${OUTDIR}/.config" "${OUTDIR}/.config.orig"
    mv -f "${OUTDIR}/.config.new" "${OUTDIR}/.config"

    echo "     c. setting initial configurations"
    # these are the original setconf values from dpdk.spec
    set_conf "${OUTDIR}" CONFIG_RTE_MACHINE "\\\"${DPDK_CONF_MACH[$i]}\\\""

    # Enable automatic driver loading from this path
    set_conf "${OUTDIR}" CONFIG_RTE_EAL_PMD_PATH '"/usr/lib64/dpdk-pmds"'

    # start by disabling ALL PMDs
    for pmd in $(grep _PMD= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
    do
        set_conf "${OUTDIR}" $pmd n
    done

    # PMDs which have their own naming scheme
    # the default for this was 'n' at one point.  Make sure we keep it
    # as such
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_QAT n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VHOST n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_KNI n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_XENVIRT n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_NULL n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_TAP n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SKELETON_EVENTDEV n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_PCAP n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_BOND n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_AF_PACKET n

    # whitelist of enabled PMDs
    # Soft PMDs to enable
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_RING y
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VHOST y
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VIRTIO_PMD y

    # HW PMDs
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_I40E_PMD y
    case "${DPDK_CONF_MACH_ARCH[i]}" in
    x86_64)
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BNXT_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_ENIC_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX4_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX5_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_NFP_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_QEDE_PMD y
        ;&
    arm64)
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IXGBE_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IGB_PMD y
        ;;
    esac

    # Compile the PMD test application
    set_conf "${OUTDIR}" CONFIG_RTE_TEST_PMD y

    # Enable vhost-numa build, the added deps are ok for us
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VHOST_NUMA y

    # Disable kernel modules
    set_conf "${OUTDIR}" CONFIG_RTE_EAL_IGB_UIO n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_KNI n
    set_conf "${OUTDIR}" CONFIG_RTE_KNI_KMOD n

    # Disable experimental stuff
    set_conf "${OUTDIR}" CONFIG_RTE_NEXT_ABI n

    # Build DPDK as shared library
    set_conf "${OUTDIR}" CONFIG_RTE_BUILD_SHARED_LIB y

    cp "${OUTDIR}/.config" "${OUTPUT_DIR}/${DPDK_TARGETS[$i]}-config"
done
popd >/dev/null

echo -n "For each arch ( "
for ((i=0; i < ${#DPDK_CONF_MACH_ARCH[@]}; i++));
do
    echo -n "${DPDK_CONF_MACH_ARCH[i]} "
done
echo "):"
echo "1. ensure you enable the requisite hw"