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