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