Blob Blame History Raw
#!/bin/bash

source configlib.sh

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

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

OVSSPEC="$1"
DPDKDIR="$2"

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

OVS_DPDK_CONF_MACH_TMPL=()
for tmpl in $(grep %define\ dpdk_mach_tmpl "$OVSSPEC" | sed 's@%define dpdk_mach_tmpl @@')
do
    OVS_DPDK_CONF_MACH_TMPL+=($tmpl)
done

OVS_DPDK_CONF_MACH=()
for mach in $(grep %define\ dpdk_mach\  "$OVSSPEC" | sed 's@%define dpdk_mach @@')
do
    OVS_DPDK_CONF_MACH+=($mach)
done

OVS_DPDK_TARGETS=()
for ((i=0; i < ${#OVS_DPDK_CONF_MACH[@]}; i++));
do
    OVS_DPDK_TARGETS+=("${OVS_DPDK_CONF_MACH_ARCH[$i]}-${OVS_DPDK_CONF_MACH_TMPL[$i]}-linuxapp-gcc")
    echo "DPDK-target: ${OVS_DPDK_TARGETS[$i]}"
done

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

    echo "     a. Generating initial config"
    echo "        make V=1 T=${OVS_DPDK_TARGETS[$i]} O=${OVS_DPDK_TARGETS[$i]}"
    make V=1 T=${OVS_DPDK_TARGETS[$i]} O=${OVS_DPDK_TARGETS[$i]} -j8 config
    ORIG_SHA=""
    OUTDIR="${OVS_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 ${OVS_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 openvswitch.spec
    set_conf "${OUTDIR}" CONFIG_RTE_MACHINE "\\\"${OVS_DPDK_CONF_MACH[$i]}\\\""

    # Disable DPDK libraries not needed
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_TIMER n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CFGFILE n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_JOBSTATS n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_LPM n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_ACL n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_POWER n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_SCHED n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DISTRIBUTOR n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_REORDER n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PORT n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_TABLE n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PIPELINE n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_KNI n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CRYPTODEV n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_SECURITY n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_FLOW_CLASSIFY n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BBDEV n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_COMPRESSDEV n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BPF n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DPAA_MEMPOOL n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DPAA2_MEMPOOL n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CFGFILE n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_EFD n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_FLOW_CLASSIFY n

    # Disable all eventdevs
    for eventdev in $(grep _EVENTDEV= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
    do
        set_conf "${OUTDIR}" $eventdev n
    done

    # Disable all rawdevs
    for rawdev in $(grep _RAWDEV= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
    do
        set_conf "${OUTDIR}" $rawdev n
    done

    # Disable virtio user
    set_conf "${OUTDIR}" CONFIG_RTE_VIRTIO_USER n

    # Enable vhost numa as libnuma dep is ok
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VHOST_NUMA y

    # 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_OCTEONTX_ZIPVF 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_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
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SOFTNIC n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_DPAA_SEC n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_COMMON_DPAAX n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CAAM_JR n
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CAAM_JR_BE 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
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_TAP y
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_FAILSAFE y


    # start by disabling all buses
    for bus in $(grep _BUS= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
    do
        set_conf "${OUTDIR}" $bus n
    done

    # blacklist buses that don't conform to std naming
    # May override VMBUS later in arch specific section
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VMBUS n

    # whitelist buses
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PCI_BUS y
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VDEV_BUS y


    # Disable some other miscellanous items related to test apps
    set_conf "${OUTDIR}" CONFIG_RTE_TEST_BBDEV n
    set_conf "${OUTDIR}" CONFIG_RTE_APP_CRYPTO_PERF n

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

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

    # Arch specific
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_I40E_PMD y
    case "${OVS_DPDK_CONF_MACH_ARCH[i]}" in
    x86_64)
        # Hw PMD
        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
        # Sw PMD
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_NETVSC_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD y
        # Bus
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VMBUS y
        ;&
    arm64)
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IXGBE_PMD y
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IGB_PMD y
        ;;
    esac

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

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