Mark Michelson 9f539b
#!/bin/bash
Mark Michelson 9f539b
Mark Michelson 9f539b
source configlib.sh
Mark Michelson 9f539b
Mark Michelson 9f539b
# Generates arch configurations in the current directory based on
Mark Michelson 9f539b
# 1. an openvswitch.spec file
Mark Michelson 9f539b
# 2. an expanded dpdk tree
Mark Michelson 9f539b
Mark Michelson 9f539b
if (( $# != 2 )); then
Mark Michelson 9f539b
    echo "$0: openvswitch.spec dpdk_tree" >&2
Mark Michelson 9f539b
    exit 1
Mark Michelson 9f539b
fi
Mark Michelson 9f539b
Mark Michelson 9f539b
OVSSPEC="$1"
Mark Michelson 9f539b
DPDKDIR="$2"
Mark Michelson 9f539b
Mark Michelson 9f539b
# accumulate all arch + name triples
Mark Michelson 9f539b
OVS_DPDK_CONF_MACH_ARCH=()
Mark Michelson 9f539b
for arch in $(grep %define\ dpdk_mach_arch "$OVSSPEC" | sed 's@%define dpdk_mach_arch @@')
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    OVS_DPDK_CONF_MACH_ARCH+=($arch)
Mark Michelson 9f539b
done
Mark Michelson 9f539b
Mark Michelson 9f539b
OVS_DPDK_CONF_MACH_TMPL=()
Mark Michelson 9f539b
for tmpl in $(grep %define\ dpdk_mach_tmpl "$OVSSPEC" | sed 's@%define dpdk_mach_tmpl @@')
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    OVS_DPDK_CONF_MACH_TMPL+=($tmpl)
Mark Michelson 9f539b
done
Mark Michelson 9f539b
Mark Michelson 9f539b
OVS_DPDK_CONF_MACH=()
Mark Michelson 9f539b
for mach in $(grep %define\ dpdk_mach\  "$OVSSPEC" | sed 's@%define dpdk_mach @@')
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    OVS_DPDK_CONF_MACH+=($mach)
Mark Michelson 9f539b
done
Mark Michelson 9f539b
Mark Michelson 9f539b
OVS_DPDK_TARGETS=()
Mark Michelson 9f539b
for ((i=0; i < ${#OVS_DPDK_CONF_MACH[@]}; i++));
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    OVS_DPDK_TARGETS+=("${OVS_DPDK_CONF_MACH_ARCH[$i]}-${OVS_DPDK_CONF_MACH_TMPL[$i]}-linuxapp-gcc")
Mark Michelson 9f539b
    echo "DPDK-target: ${OVS_DPDK_TARGETS[$i]}"
Mark Michelson 9f539b
done
Mark Michelson 9f539b
Mark Michelson 9f539b
OUTPUT_DIR=$(pwd)
Mark Michelson 9f539b
pushd "$DPDKDIR"
Mark Michelson 9f539b
for ((i=0; i < ${#OVS_DPDK_TARGETS[@]}; i++));
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    echo "For ${OVS_DPDK_TARGETS[$i]}:"
Mark Michelson 9f539b
Mark Michelson 9f539b
    echo "     a. Generating initial config"
Mark Michelson 9f539b
    echo "        make V=1 T=${OVS_DPDK_TARGETS[$i]} O=${OVS_DPDK_TARGETS[$i]}"
Mark Michelson 9f539b
    make V=1 T=${OVS_DPDK_TARGETS[$i]} O=${OVS_DPDK_TARGETS[$i]} -j8 config
Mark Michelson 9f539b
    ORIG_SHA=""
Mark Michelson 9f539b
    OUTDIR="${OVS_DPDK_TARGETS[$i]}"
Mark Michelson 9f539b
Mark Michelson 9f539b
    echo "     b. calculating and applying sha"
Mark Michelson 9f539b
    calc_sha ORIG_SHA "${OUTDIR}/.config"
Mark Michelson 9f539b
    if [ "$ORIG_SHA" == "" ]; then
Mark Michelson 9f539b
        echo "ERROR: Unable to get sha for arch ${OVS_DPDK_TARGETS[$i]}"
Mark Michelson 9f539b
        exit 1
Mark Michelson 9f539b
    fi
Mark Michelson 9f539b
    echo "# -*- cfg-sha: ${ORIG_SHA}" > ${OUTDIR}/.config.new
Mark Michelson 9f539b
    cat "${OUTDIR}/.config" >> "${OUTDIR}/.config.new"
Mark Michelson 9f539b
    cp "${OUTDIR}/.config" "${OUTDIR}/.config.orig"
Mark Michelson 9f539b
    mv -f "${OUTDIR}/.config.new" "${OUTDIR}/.config"
Mark Michelson 9f539b
Mark Michelson 9f539b
    echo "     c. setting initial configurations"
Mark Michelson 9f539b
    # these are the original setconf values from openvswitch.spec
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_MACHINE "\\\"${OVS_DPDK_CONF_MACH[$i]}\\\""
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable DPDK libraries not needed
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_TIMER n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CFGFILE n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_JOBSTATS n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_LPM n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_ACL n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_POWER n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_SCHED n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DISTRIBUTOR n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_REORDER n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PORT n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_TABLE n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PIPELINE n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_KNI n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CRYPTODEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_SECURITY n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_FLOW_CLASSIFY n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BBDEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_COMPRESSDEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BPF n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_OCTEONTX_MEMPOOL n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DPAA_MEMPOOL n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_DPAA2_MEMPOOL n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_CFGFILE n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_EFD n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_FLOW_CLASSIFY n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable all eventdevs
Mark Michelson 9f539b
    for eventdev in $(grep _EVENTDEV= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
Mark Michelson 9f539b
    do
Mark Michelson 9f539b
        set_conf "${OUTDIR}" $eventdev n
Mark Michelson 9f539b
    done
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable all rawdevs
Mark Michelson 9f539b
    for rawdev in $(grep _RAWDEV= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
Mark Michelson 9f539b
    do
Mark Michelson 9f539b
        set_conf "${OUTDIR}" $rawdev n
Mark Michelson 9f539b
    done
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable virtio user
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_VIRTIO_USER n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Enable vhost numa as libnuma dep is ok
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VHOST_NUMA y
Mark Michelson 9f539b
Mark Michelson 9f539b
    # start by disabling ALL PMDs
Mark Michelson 9f539b
    for pmd in $(grep _PMD= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
Mark Michelson 9f539b
    do
Mark Michelson 9f539b
        set_conf "${OUTDIR}" $pmd n
Mark Michelson 9f539b
    done
Mark Michelson 9f539b
Mark Michelson 9f539b
    # PMDs which have their own naming scheme
Mark Michelson 9f539b
    # the default for this was 'n' at one point.  Make sure we keep it
Mark Michelson 9f539b
    # as such
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_QAT n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_OCTEONTX_SSOVF n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_OCTEONTX_ZIPVF n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VHOST n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_KNI n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_XENVIRT n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_NULL n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CRYPTO_SCHEDULER n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SKELETON_EVENTDEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SW_EVENTDEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_PCAP n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_BOND n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_AF_PACKET n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_SOFTNIC n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_DPAA_SEC n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_COMMON_DPAAX n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CAAM_JR n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_CAAM_JR_BE n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # whitelist of enabled PMDs
Mark Michelson 9f539b
    # Soft PMDs to enable
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_RING y
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_VHOST y
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VIRTIO_PMD y
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_TAP y
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PMD_FAILSAFE y
Mark Michelson 9f539b
Mark Michelson 9f539b
Mark Michelson 9f539b
    # start by disabling all buses
Mark Michelson 9f539b
    for bus in $(grep _BUS= "${OUTDIR}/.config" | sed 's@=\(y\|n\)@@g')
Mark Michelson 9f539b
    do
Mark Michelson 9f539b
        set_conf "${OUTDIR}" $bus n
Mark Michelson 9f539b
    done
Mark Michelson 9f539b
Mark Michelson 9f539b
    # blacklist buses that don't conform to std naming
Mark Michelson 9f539b
    # May override VMBUS later in arch specific section
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VMBUS n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # whitelist buses
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_PCI_BUS y
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VDEV_BUS y
Mark Michelson 9f539b
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable some other miscellanous items related to test apps
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_TEST_BBDEV n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_APP_CRYPTO_PERF n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable kernel modules
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_EAL_IGB_UIO n
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_KNI_KMOD n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Disable experimental stuff
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_NEXT_ABI n
Mark Michelson 9f539b
Mark Michelson 9f539b
    # Arch specific
Mark Michelson 9f539b
    set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_I40E_PMD y
Mark Michelson 9f539b
    case "${OVS_DPDK_CONF_MACH_ARCH[i]}" in
Mark Michelson 9f539b
    x86_64)
Mark Michelson 9f539b
        # Hw PMD
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_BNXT_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_ENIC_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX4_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX4_DLOPEN_DEPS y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX5_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_MLX5_DLOPEN_DEPS y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_NFP_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_QEDE_PMD y
Mark Michelson 9f539b
        # Sw PMD
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_NETVSC_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VDEV_NETVSC_PMD y
Mark Michelson 9f539b
        # Bus
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_VMBUS y
Mark Michelson 9f539b
        ;&
Mark Michelson 9f539b
    arm64)
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IXGBE_PMD y
Mark Michelson 9f539b
        set_conf "${OUTDIR}" CONFIG_RTE_LIBRTE_IGB_PMD y
Mark Michelson 9f539b
        ;;
Mark Michelson 9f539b
    esac
Mark Michelson 9f539b
Mark Michelson 9f539b
    cp "${OUTDIR}/.config" "${OUTPUT_DIR}/${OVS_DPDK_TARGETS[$i]}-config"
Mark Michelson 9f539b
done
Mark Michelson 9f539b
popd >/dev/null
Mark Michelson 9f539b
Mark Michelson 9f539b
printf "For each arch ( "
Mark Michelson 9f539b
for ((i=0; i < ${#OVS_DPDK_CONF_MACH_ARCH[@]}; i++));
Mark Michelson 9f539b
do
Mark Michelson 9f539b
    printf "${OVS_DPDK_CONF_MACH_ARCH[i]} "
Mark Michelson 9f539b
done
Mark Michelson 9f539b
echo "):"
Mark Michelson 9f539b
echo "1. ensure you enable the requisite hw"