diff --git a/.azure-pipelines/azure-pipelines-build.yml b/.azure-pipelines/azure-pipelines-build.yml index e0a0400f850f..961e72a3e564 100644 --- a/.azure-pipelines/azure-pipelines-build.yml +++ b/.azure-pipelines/azure-pipelines-build.yml @@ -128,7 +128,7 @@ jobs: make $BUILD_OPTIONS ENABLE_ASAN=y target/docker-sonic-vs.gz mv target/docker-sonic-vs.gz target/docker-sonic-vs-asan.gz fi - if [ $(K8S_OPTIONS) == 'INCLUDE_KUBERNETES_MASTER=y' ]; then + if [ "$(K8S_OPTIONS)" == 'INCLUDE_KUBERNETES_MASTER=y' ]; then make $BUILD_OPTIONS $(K8S_OPTIONS) target/sonic-vs.img.gz mv target/sonic-vs.img.gz target/sonic-vs-k8s.img.gz fi diff --git a/.gitmodules b/.gitmodules index b91c3e8aaa67..6715fa4ec6f6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -115,3 +115,6 @@ [submodule "src/sonic-dash-api/sonic-dash-api"] path = src/sonic-dash-api/sonic-dash-api url = https://github.com/sonic-net/sonic-dash-api.git +[submodule "platform/marvell-arm64/mrvl-prestera"] + path = platform/marvell-arm64/mrvl-prestera + url = https://github.com/Marvell-switching/mrvl-prestera.git diff --git a/Makefile.cache b/Makefile.cache index f12f866db9af..137cf9c7bb2d 100644 --- a/Makefile.cache +++ b/Makefile.cache @@ -357,6 +357,22 @@ define SAVE_CACHE $(if $(call CHECK_WCACHE_ENABLED,$(1)), $(call SAVE_INTO_CACHE,$(1),$(2))) endef +RFS_DEP_FILES := $(wildcard \ + $(addprefix scripts/, build_debian_base_system.sh prepare_debian_image_buildinfo.sh build_mirror_config.sh) \ + $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL)) \ + $(shell git ls-files files/initramfs-tools) \ + $(shell git ls-files files/image_config) \ + $(shell git ls-files files/apparmor) \ + $(shell git ls-files files/apt) \ + $(shell git ls-files files/sshd) \ + $(shell git ls-files files/dhcp) \ + src/sonic-build-hooks/buildinfo/trusted.gpg.d \ + platform/$(CONFIGURED_PLATFORM)/modules \ + files/docker/docker.service.conf \ + files/build_templates/default_users.json.j2 \ + files/build_scripts/generate_asic_config_checksum.py \ + files/scripts/core_cleanup.py \ + build_debian.sh onie-image.conf) # Set the target path for each target. @@ -384,11 +400,17 @@ $(foreach pkg, $(SONIC_INSTALL_PKGS), \ $(eval $(pkg)_DST_PATH := $(if $($(pkg)_DST_PATH), $($(pkg)_DST_PATH), $(FSROOT_PATH))) \ $(eval $(FSROOT_PATH)/$(pkg)_TARGET := $(pkg)) ) +$(foreach pkg, $(SONIC_RFS_TARGETS), \ + $(eval $(pkg)_DST_PATH := $(if $($(pkg)_DST_PATH), $($(pkg)_DST_PATH), $(TARGET_PATH))) \ + $(eval $(pkg)_CACHE_MODE := GIT_CONTENT_SHA) \ + $(eval $(pkg)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST)) \ + $(eval $(pkg)_DEP_FILES := $(SONIC_COMMON_BASE_FILES_LIST) $(RFS_DEP_FILES)) \ + $(eval $(TARGET_PATH)/$(pkg)_TARGET := $(pkg)) ) # define the DEP files(.dep and .smdep) and SHA files (.sha and smsha) for each target $(foreach pkg, $(SONIC_MAKE_DEBS) $(SONIC_DPKG_DEBS) $(SONIC_ONLINE_DEBS) $(SONIC_COPY_DEBS) \ $(SONIC_MAKE_FILES) $(SONIC_PYTHON_STDEB_DEBS) $(SONIC_PYTHON_WHEELS) \ - $(SONIC_DOCKER_IMAGES) $(SONIC_DOCKER_DBG_IMAGES) $(SONIC_INSTALL_PKGS), \ + $(SONIC_DOCKER_IMAGES) $(SONIC_DOCKER_DBG_IMAGES) $(SONIC_INSTALL_PKGS) $(SONIC_RFS_TARGETS), \ $(eval $(pkg)_MOD_SRC_PATH:=$(if $($(pkg)_SRC_PATH),$($(pkg)_SRC_PATH),$($(pkg)_PATH))) \ $(eval $(pkg)_BASE_PATH:=$(if $($(pkg)_BASE_PATH),$($(pkg)_BASE_PATH),$(CURDIR))) \ $(eval $(pkg)_DEP_FLAGS_FILE:=$($(pkg)_DST_PATH)/$(pkg).flags) \ @@ -489,6 +511,7 @@ $(eval $(call FLAGS_DEP_RULES, $(SONIC_PYTHON_STDEB_DEBS), $(PYTHON_DEBS_PATH),f $(eval $(call FLAGS_DEP_RULES, $(SONIC_PYTHON_WHEELS), $(PYTHON_WHEELS_PATH),flags)) $(eval $(call FLAGS_DEP_RULES, $(SONIC_DOCKER_IMAGES) $(SONIC_DOCKER_DBG_IMAGES), $(TARGET_PATH),flags)) $(eval $(call FLAGS_DEP_RULES, $(SONIC_INSTALL_PKGS), $(FSROOT_PATH),flags)) +$(eval $(call FLAGS_DEP_RULES, $(SONIC_RFS_TARGETS), $(TARGET_PATH),flags)) @@ -585,6 +608,7 @@ $(eval $(call SHA_DEP_RULES, $(SONIC_PYTHON_STDEB_DEBS), $(PYTHON_DEBS_PATH),dep $(eval $(call SHA_DEP_RULES, $(SONIC_PYTHON_WHEELS), $(PYTHON_WHEELS_PATH),dep)) $(eval $(call SHA_DEP_RULES, $(SONIC_DOCKER_IMAGES) $(SONIC_DOCKER_DBG_IMAGES), $(TARGET_PATH),dep)) $(eval $(call SHA_DEP_RULES, $(SONIC_INSTALL_PKGS), $(FSROOT_PATH),dep)) +$(eval $(call SHA_DEP_RULES, $(SONIC_RFS_TARGETS), $(TARGET_PATH),dep)) @@ -618,6 +642,7 @@ SONIC_CACHE_CLEAN_TARGETS = $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \ $(SONIC_DOCKER_IMAGES) \ $(SONIC_DOCKER_DBG_IMAGES) \ $(SONIC_SIMPLE_DOCKER_IMAGES) \ + $(SONIC_RFS_TARGETS) \ $(SONIC_INSTALLERS))) $(SONIC_CACHE_CLEAN_TARGETS) :: $(TARGET_PATH)/%-clean : .platform @rm -f $($*_DEP_FLAGS_FILE) $($*_MOD_HASH_FILE) $($*_SMOD_HASH_FILE) \ diff --git a/Makefile.work b/Makefile.work index 0fde2e38938b..e98503a132f8 100644 --- a/Makefile.work +++ b/Makefile.work @@ -203,6 +203,7 @@ $(shell \ SONIC_VERSION_CACHE_SOURCE=$(SONIC_VERSION_CACHE_SOURCE) \ DBGOPT='$(DBGOPT)' \ MIRROR_SNAPSHOT=$(MIRROR_SNAPSHOT) \ + PIP_HTTP_TIMEOUT=$(PIP_HTTP_TIMEOUT) \ scripts/generate_buildinfo_config.sh) # Generate the slave Dockerfile, and prepare build info for it @@ -570,6 +571,7 @@ SONIC_BUILD_INSTRUCTION := $(MAKE) \ SONIC_VERSION_CONTROL_COMPONENTS=$(SONIC_VERSION_CONTROL_COMPONENTS) \ ONIE_IMAGE_PART_SIZE=$(ONIE_IMAGE_PART_SIZE) \ SONIC_OS_VERSION=$(SONIC_OS_VERSION) \ + PIP_HTTP_TIMEOUT=$(PIP_HTTP_TIMEOUT) \ $(SONIC_OVERRIDE_BUILD_VARS) .PHONY: sonic-slave-build sonic-slave-bash init reset @@ -592,6 +594,7 @@ export MIRROR_URLS export MIRROR_SECURITY_URLS export MIRROR_SNAPSHOT export SONIC_VERSION_CONTROL_COMPONENTS +export PIP_HTTP_TIMEOUT %:: | sonic-build-hooks ifneq ($(filter y, $(MULTIARCH_QEMU_ENVIRON) $(CROSS_BUILD_ENVIRON)),) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ec0e05110659..7de4dbff3951 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -239,6 +239,21 @@ stages: COMMON_EXTRA_PARAMS: "--neighbor_type=sonic " VM_TYPE: vsonic + - job: dpu_elastictest + displayName: "kvmtest-dpu by Elastictest" + timeoutInMinutes: 240 + continueOnError: false + pool: ubuntu-20.04 + steps: + - template: .azure-pipelines/run-test-elastictest-template.yml@sonic-mgmt + parameters: + TOPOLOGY: dpu + MIN_WORKER: $(T0_SONIC_INSTANCE_NUM) + MAX_WORKER: $(T0_SONIC_INSTANCE_NUM) + KVM_IMAGE_BRANCH: "master" + MGMT_BRANCH: "master" + + # - job: wan_elastictest # displayName: "kvmtest-wan by Elastictest" # pool: ubuntu-20.04 diff --git a/build_debian.sh b/build_debian.sh index 91abddd634e8..055daba9e66b 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -59,23 +59,30 @@ TRUSTED_GPG_DIR=$BUILD_TOOL_PATH/trusted.gpg.d exit 1 } +if [ "$IMAGE_TYPE" = "aboot" ]; then + TARGET_BOOTLOADER="aboot" +fi + +## Check if not a last stage of RFS build +if [[ $RFS_SPLIT_LAST_STAGE != y ]]; then + ## Prepare the file system directory if [[ -d $FILESYSTEM_ROOT ]]; then sudo rm -rf $FILESYSTEM_ROOT || die "Failed to clean chroot directory" fi mkdir -p $FILESYSTEM_ROOT mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR -mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/grub touch $FILESYSTEM_ROOT/$PLATFORM_DIR/firsttime +bootloader_packages="" +if [ "$TARGET_BOOTLOADER" != "aboot" ]; then + mkdir -p $FILESYSTEM_ROOT/$PLATFORM_DIR/grub + bootloader_packages="grub2-common" +fi + ## ensure proc is mounted sudo mount proc /proc -t proc || true -## make / as a mountpoint in chroot env, needed by dockerd -pushd $FILESYSTEM_ROOT -sudo mount --bind . . -popd - ## Build the host debian base system echo '[INFO] Build host debian base system...' TARGET_PATH=$TARGET_PATH scripts/build_debian_base_system.sh $CONFIGURED_ARCH $IMAGE_DISTRO $FILESYSTEM_ROOT @@ -367,7 +374,7 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in gdisk \ sysfsutils \ squashfs-tools \ - grub2-common \ + $bootloader_packages \ screen \ hping3 \ tcptraceroute \ @@ -576,24 +583,11 @@ if [ -f files/image_config/ntp/ntp-systemd-wrapper ]; then sudo cp ./files/image_config/ntp/ntp-systemd-wrapper $FILESYSTEM_ROOT/usr/lib/ntp/ fi -## Version file +## Version file part 1 sudo mkdir -p $FILESYSTEM_ROOT/etc/sonic if [ -f files/image_config/sonic_release ]; then sudo cp files/image_config/sonic_release $FILESYSTEM_ROOT/etc/sonic/ fi -export build_version="${SONIC_IMAGE_VERSION}" -export debian_version="$(cat $FILESYSTEM_ROOT/etc/debian_version)" -export kernel_version="${kversion}" -export asic_type="${sonic_asic_platform}" -export asic_subtype="${TARGET_MACHINE}" -export commit_id="$(git rev-parse --short HEAD)" -export branch="$(git rev-parse --abbrev-ref HEAD)" -export release="$(if [ -f $FILESYSTEM_ROOT/etc/sonic/sonic_release ]; then cat $FILESYSTEM_ROOT/etc/sonic/sonic_release; fi)" -export build_date="$(date -u)" -export build_number="${BUILD_NUMBER:-0}" -export built_by="$USER@$BUILD_HOSTNAME" -export sonic_os_version="${SONIC_OS_VERSION}" -j2 files/build_templates/sonic_version.yml.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/sonic_version.yml # Default users info export password_expire="$( [[ "$CHANGE_DEFAULT_PASSWORD" == "y" ]] && echo true || echo false )" @@ -615,6 +609,60 @@ if [[ ! -f './asic_config_checksum' ]]; then fi sudo cp ./asic_config_checksum $FILESYSTEM_ROOT/etc/sonic/asic_config_checksum +## Check if not a last stage of RFS build +fi + +if [[ $RFS_SPLIT_FIRST_STAGE == y ]]; then + echo '[INFO] Finished with RFS first stage' + echo '[INFO] Umount all' + + ## Display all process details access /proc + sudo LANG=C chroot $FILESYSTEM_ROOT fuser -vm /proc + ## Kill the processes + sudo LANG=C chroot $FILESYSTEM_ROOT fuser -km /proc || true + ## Wait fuser fully kill the processes + sudo timeout 15s bash -c 'until LANG=C chroot $0 umount /proc; do sleep 1; done' $FILESYSTEM_ROOT || true + + sudo rm -f $TARGET_PATH/$RFS_SQUASHFS_NAME + sudo mksquashfs $FILESYSTEM_ROOT $TARGET_PATH/$RFS_SQUASHFS_NAME -Xcompression-level 1 + + exit 0 +fi + +if [[ $RFS_SPLIT_LAST_STAGE == y ]]; then + echo '[INFO] RFS build: second stage' + + ## ensure proc is mounted + sudo mount proc /proc -t proc || true + + sudo fuser -vm $FILESYSTEM_ROOT || true + sudo rm -rf $FILESYSTEM_ROOT + sudo unsquashfs -d $FILESYSTEM_ROOT $TARGET_PATH/$RFS_SQUASHFS_NAME + + ## make / as a mountpoint in chroot env, needed by dockerd + pushd $FILESYSTEM_ROOT + sudo mount --bind . . + popd + + trap_push 'sudo LANG=C chroot $FILESYSTEM_ROOT umount /proc || true' + sudo LANG=C chroot $FILESYSTEM_ROOT mount proc /proc -t proc +fi + +## Version file part 2 +export build_version="${SONIC_IMAGE_VERSION}" +export debian_version="$(cat $FILESYSTEM_ROOT/etc/debian_version)" +export kernel_version="${kversion}" +export asic_type="${sonic_asic_platform}" +export asic_subtype="${TARGET_MACHINE}" +export commit_id="$(git rev-parse --short HEAD)" +export branch="$(git rev-parse --abbrev-ref HEAD)" +export release="$(if [ -f $FILESYSTEM_ROOT/etc/sonic/sonic_release ]; then cat $FILESYSTEM_ROOT/etc/sonic/sonic_release; fi)" +export build_date="$(date -u)" +export build_number="${BUILD_NUMBER:-0}" +export built_by="$USER@$BUILD_HOSTNAME" +export sonic_os_version="${SONIC_OS_VERSION}" +j2 files/build_templates/sonic_version.yml.j2 | sudo tee $FILESYSTEM_ROOT/etc/sonic/sonic_version.yml + if [ -f sonic_debian_extension.sh ]; then ./sonic_debian_extension.sh $FILESYSTEM_ROOT $PLATFORM_DIR $IMAGE_DISTRO fi @@ -786,6 +834,17 @@ sudo mkdir -p $FILESYSTEM_ROOT/var/lib/docker sudo rm -f $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/original sudo cp files/image_config/resolv-config/resolv.conf.head $FILESYSTEM_ROOT/etc/resolvconf/resolv.conf.d/head +## Optimize filesystem size +if [ "$BUILD_REDUCE_IMAGE_SIZE" = "y" ]; then + sudo scripts/build-optimize-fs-size.py "$FILESYSTEM_ROOT" \ + --image-type "$IMAGE_TYPE" \ + --hardlinks var/lib/docker \ + --hardlinks usr/share/sonic/device \ + --remove-docs \ + --remove-mans \ + --remove-licenses +fi + sudo mksquashfs $FILESYSTEM_ROOT $FILESYSTEM_SQUASHFS -comp zstd -b 1M -e boot -e var/lib/docker -e $PLATFORM_DIR ## Reduce /boot permission diff --git a/device/arista/x86_64-arista_7260cx3_64/pcie.yaml b/device/arista/x86_64-arista_7260cx3_64/pcie.yaml index 24955eee42f4..9e25832a0880 100644 --- a/device/arista/x86_64-arista_7260cx3_64/pcie.yaml +++ b/device/arista/x86_64-arista_7260cx3_64/pcie.yaml @@ -100,12 +100,6 @@ id: 8c24 name: 'Signal processing controller: Intel Corporation 8 Series Chipset Family Thermal Management Controller (rev 05)' -- bus: '01' - dev: '00' - fn: '0' - id: '1682' - name: 'Ethernet controller: Broadcom Limited NetXtreme BCM57762 Gigabit Ethernet - PCIe (rev 20)' - bus: '02' dev: '00' fn: '0' diff --git a/device/dell/x86_64-dell_s6100_c2538-r0/installer.conf b/device/dell/x86_64-dell_s6100_c2538-r0/installer.conf index 6ce0ab077f03..e87b44df6147 100644 --- a/device/dell/x86_64-dell_s6100_c2538-r0/installer.conf +++ b/device/dell/x86_64-dell_s6100_c2538-r0/installer.conf @@ -1,3 +1,3 @@ CONSOLE_PORT=0x2f8 CONSOLE_DEV=1 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich,wdat_wdt acpi_no_watchdog=1 nos-config-part=/dev/sda12 logs_inram=on i2c-i801.disable_features=0x10" \ No newline at end of file +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich,wdat_wdt acpi_no_watchdog=1 nos-config-part=/dev/sda12 i2c-i801.disable_features=0x10" diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai.profile index 68e245a2ce1b..3b09459755f0 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-C28D8/sai.profile @@ -1,3 +1,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700_8x50g_28x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile index 4cfa685a0ab2..c1810655051c 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D40C8S8/sai.profile @@ -1,3 +1,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700_8x100g_40x50g_8x10g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D44C10/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D44C10/sai.profile index f25a70d39743..e6f3c2f0cf58 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D44C10/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D44C10/sai.profile @@ -1,3 +1,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700_44x50g_10x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai.profile index ce9e96ee4fa3..daf2235f0adc 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700-D48C8/sai.profile @@ -1,3 +1,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700_48x50g_8x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile deleted file mode 120000 index 5d2c55d8bb44..000000000000 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile +++ /dev/null @@ -1 +0,0 @@ -../ACS-MSN2700/sai.profile \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile new file mode 100644 index 000000000000..fcd0120d8342 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/Mellanox-SN2700/sai.profile @@ -0,0 +1,4 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_2700.xml +SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps +SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn2700-r0/installer.conf b/device/mellanox/x86_64-mlnx_msn2700-r0/installer.conf index eb12e734bb90..c9c9493a5404 100644 --- a/device/mellanox/x86_64-mlnx_msn2700-r0/installer.conf +++ b/device/mellanox/x86_64-mlnx_msn2700-r0/installer.conf @@ -1 +1 @@ -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=lax acpi=noirq logs_inram=on" +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="acpi_enforce_resources=lax acpi=noirq" diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/sai.profile index 5fe089467374..7b27b5a2b96f 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-C64/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai.profile index 5a8b32f589b8..92fb9921fdf5 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D100C12S2/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800_2x10g_100x50g_12x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai.profile index a2c98b0402c8..90534ae58a43 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D112C8/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800_112x50g_8x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai.profile index 56d838caad12..f00701cde546 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D24C52/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800_24x50g_52x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai.profile index 1e4875e52a2d..e90f26e77358 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C49S1/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800_1x10g_28x50g_49x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai.profile b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai.profile index be194b72c731..3b36aff3126a 100644 --- a/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn3800-r0/Mellanox-SN3800-D28C50/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_3800_28x50g_52x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/sai.profile b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/sai.profile index 6dfcaf49bf66..8bf256a6ac45 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-C64/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4600C.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/sai.profile b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/sai.profile index 4987094a5454..ac24ca45fdf1 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D100C12S2/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4600c_100x50g_12x100g_2x10g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai.profile b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai.profile index 21d8fe5a9239..6c8656b90a79 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D112C8/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4600c_112x50g_8x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai.profile b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai.profile index 1970e7030832..f8174ebe6892 100644 --- a/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn4600c-r0/Mellanox-SN4600C-D48C40/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4600c_48x50g_40x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/README.md b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/README.md new file mode 100644 index 000000000000..9d80f238ae58 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/README.md @@ -0,0 +1 @@ +This SKU is dedicated to Virtual Smart Switch diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers.json.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers.json.j2 new file mode 120000 index 000000000000..add8bf8bb7c2 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_objects.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_objects.j2 new file mode 120000 index 000000000000..33b6704f9902 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_objects.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_defaults_objects.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t0.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t0.j2 new file mode 120000 index 000000000000..38216fb84301 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t0.j2 @@ -0,0 +1 @@ +../ACS-MSN4700/buffers_defaults_t0.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t1.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t1.j2 new file mode 120000 index 000000000000..c09ab38502d4 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_defaults_t1.j2 @@ -0,0 +1 @@ +../ACS-MSN4700/buffers_defaults_t1.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_dynamic.json.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_dynamic.json.j2 new file mode 120000 index 000000000000..8c4117c66214 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/buffers_dynamic.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/buffers_dynamic.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/hwsku.json b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/hwsku.json new file mode 100644 index 000000000000..17290e850318 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/hwsku.json @@ -0,0 +1,100 @@ +{ + "interfaces": { + "Ethernet0": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet8": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet16": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet24": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet32": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet40": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet48": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet56": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet64": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet72": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet80": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet88": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet96": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet104": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet112": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet120": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet128": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet136": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet144": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet152": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet160": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet168": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet176": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet184": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet192": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet200": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet208": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet216": { + "default_brkout_mode": "1x400G[200G,100G,50G,40G,25G,10G,1G]" + }, + "Ethernet224": { + "default_brkout_mode": "1x200G" + }, + "Ethernet232": { + "default_brkout_mode": "1x200G" + }, + "Ethernet240": { + "default_brkout_mode": "1x200G" + }, + "Ethernet248": { + "default_brkout_mode": "1x200G" + } + } +} diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/pg_profile_lookup.ini b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/pg_profile_lookup.ini new file mode 120000 index 000000000000..7813e1697844 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/pg_profile_lookup.ini @@ -0,0 +1 @@ +../ACS-MSN4700/pg_profile_lookup.ini \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/port_config.ini b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/port_config.ini new file mode 100644 index 000000000000..bdc1dc6766f9 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/port_config.ini @@ -0,0 +1,49 @@ +## +## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. +## Apache-2.0 +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +# name lanes alias index speed +Ethernet0 0,1,2,3,4,5,6,7 etp1 1 400000 +Ethernet8 8,9,10,11,12,13,14,15 etp2 2 400000 +Ethernet16 16,17,18,19,20,21,22,23 etp3 3 400000 +Ethernet24 24,25,26,27,28,29,30,31 etp4 4 400000 +Ethernet32 32,33,34,35,36,37,38,39 etp5 5 400000 +Ethernet40 40,41,42,43,44,45,46,47 etp6 6 400000 +Ethernet48 48,49,50,51,52,53,54,55 etp7 7 400000 +Ethernet56 56,57,58,59,60,61,62,63 etp8 8 400000 +Ethernet64 64,65,66,67,68,69,70,71 etp9 9 400000 +Ethernet72 72,73,74,75,76,77,78,79 etp10 10 400000 +Ethernet80 80,81,82,83,84,85,86,87 etp11 11 400000 +Ethernet88 88,89,90,91,92,93,94,95 etp12 12 400000 +Ethernet96 96,97,98,99,100,101,102,103 etp13 13 400000 +Ethernet104 104,105,106,107,108,109,110,111 etp14 14 400000 +Ethernet112 112,113,114,115,116,117,118,119 etp15 15 400000 +Ethernet120 120,121,122,123,124,125,126,127 etp16 16 400000 +Ethernet128 128,129,130,131,132,133,134,135 etp17 17 400000 +Ethernet136 136,137,138,139,140,141,142,143 etp18 18 400000 +Ethernet144 144,145,146,147,148,149,150,151 etp19 19 400000 +Ethernet152 152,153,154,155,156,157,158,159 etp20 20 400000 +Ethernet160 160,161,162,163,164,165,166,167 etp21 21 400000 +Ethernet168 168,169,170,171,172,173,174,175 etp22 22 400000 +Ethernet176 176,177,178,179,180,181,182,183 etp23 23 400000 +Ethernet184 184,185,186,187,188,189,190,191 etp24 24 400000 +Ethernet192 192,193,194,195,196,197,198,199 etp25 25 400000 +Ethernet200 200,201,202,203,204,205,206,207 etp26 26 400000 +Ethernet208 208,209,210,211,212,213,214,215 etp27 27 400000 +Ethernet216 216,217,218,219,220,221,222,223 etp28 28 400000 +Ethernet224 224,225,226,227,228,229,230,231 etp29 29 200000 +Ethernet232 232,233,234,235,236,237,238,239 etp30 30 200000 +Ethernet240 240,241,242,243,244,245,246,247 etp31 31 200000 +Ethernet248 248,249,250,251,252,253,254,255 etp32 32 200000 diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/qos.json.j2 b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/qos.json.j2 new file mode 120000 index 000000000000..eccf286dc879 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/qos.json.j2 @@ -0,0 +1 @@ +../../x86_64-mlnx_msn2700-r0/ACS-MSN2700/qos.json.j2 \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai.profile b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai.profile new file mode 100644 index 000000000000..fddba40b2233 --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai.profile @@ -0,0 +1,4 @@ +SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4700.xml +SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps +SAI_DUMP_STORE_AMOUNT=10 +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai_4700.xml b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai_4700.xml new file mode 120000 index 000000000000..5c30521c1c7b --- /dev/null +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O28/sai_4700.xml @@ -0,0 +1 @@ +../ACS-MSN4700/sai_4700.xml \ No newline at end of file diff --git a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O8C48/sai.profile b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O8C48/sai.profile index 4fab1773b390..42f665d760b0 100644 --- a/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O8C48/sai.profile +++ b/device/mellanox/x86_64-mlnx_msn4700-r0/Mellanox-SN4700-O8C48/sai.profile @@ -2,3 +2,4 @@ SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/sai_4700_8x400g_48x100g.xml SAI_DUMP_STORE_PATH=/var/log/mellanox/sdk-dumps SAI_DUMP_STORE_AMOUNT=10 SAI_DUMP_MFT_CFG_PATH=/etc/sonic/mft/fwtrace_cfg +SAI_DEFAULT_SWITCHING_MODE_STORE_FORWARD=1 diff --git a/device/nokia/arm64-nokia_ixs7215_52xb-r0/installer.conf b/device/nokia/arm64-nokia_ixs7215_52xb-r0/installer.conf index b138f294e1ea..3d02aab20dc1 100644 --- a/device/nokia/arm64-nokia_ixs7215_52xb-r0/installer.conf +++ b/device/nokia/arm64-nokia_ixs7215_52xb-r0/installer.conf @@ -1 +1,2 @@ VAR_LOG_SIZE=4096 +ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="default_hugepagesz=32M hugepages=4 loglevel=4" diff --git a/device/nokia/armhf-nokia_ixs7215_52x-r0/installer.conf b/device/nokia/armhf-nokia_ixs7215_52x-r0/installer.conf index 36696d270385..b138f294e1ea 100644 --- a/device/nokia/armhf-nokia_ixs7215_52x-r0/installer.conf +++ b/device/nokia/armhf-nokia_ixs7215_52x-r0/installer.conf @@ -1,2 +1 @@ VAR_LOG_SIZE=4096 -ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="logs_inram=on" diff --git a/dockers/docker-dhcp-server/Dockerfile.j2 b/dockers/docker-dhcp-server/Dockerfile.j2 index af999e74a473..9257ee38c7cd 100755 --- a/dockers/docker-dhcp-server/Dockerfile.j2 +++ b/dockers/docker-dhcp-server/Dockerfile.j2 @@ -3,6 +3,7 @@ FROM docker-config-engine-bullseye-{{DOCKER_USERNAME}}:{{DOCKER_USERTAG}} ARG docker_container_name ARG image_version +RUN [ -f /etc/rsyslog.conf ] && sed -ri "s/%syslogtag%/$docker_container_name#%syslogtag%/;" /etc/rsyslog.conf ## Make apt-get non-interactive ENV DEBIAN_FRONTEND=noninteractive @@ -13,6 +14,7 @@ ENV IMAGE_VERSION=$image_version RUN apt-get update && \ apt-get install -f -y \ tcpdump \ + python3-dev \ # For kea build environment automake \ libtool \ @@ -47,7 +49,9 @@ RUN echo "/usr/local/lib/kea/hooks" > /etc/ld.so.conf.d/kea.conf && \ RUN cd /usr/local/sbin && rm -f kea-admin kea-ctrl-agent kea-dhcp-ddns kea-dhcp6 keactrl # Remove hook lib we don't need RUN cd /usr/local/lib/kea/hooks && rm -f libdhcp_bootp.so libdhcp_flex_option.so libdhcp_stat_cmds.so -# RUN pip3 install psutil +RUN pip3 install psutil +# TODO issue on remote rsyslog server in non-host container +RUN rm -f /etc/supervisor/conf.d/containercfgd.conf {% if docker_dhcp_server_debs.strip() -%} # Copy locally-built Debian package dependencies @@ -57,12 +61,21 @@ RUN cd /usr/local/lib/kea/hooks && rm -f libdhcp_bootp.so libdhcp_flex_option.so {{ install_debian_packages(docker_dhcp_server_debs.split(' ')) }} {%- endif %} +{% if docker_dhcp_server_whls.strip() %} +# Copy locally-built Python wheel dependencies +{{ copy_files("python-wheels/", docker_dhcp_server_whls.split(' '), "/python-wheels/") }} + +# Install locally-built Python wheel dependencies +{{ install_python_wheels(docker_dhcp_server_whls.split(' ')) }} +{% endif %} + # Remove build stuff we don't need RUN apt-get remove -y devscripts \ automake \ libtool \ pkg-config \ build-essential \ + python3-dev \ ccache RUN apt-get clean -y && \ @@ -70,10 +83,14 @@ RUN apt-get clean -y && \ apt-get autoremove -y && \ rm -rf /debs -COPY ["docker_init.sh", "/usr/bin/"] +COPY ["docker_init.sh", "start.sh", "/usr/bin/"] COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] +COPY ["port-name-alias-map.txt.j2", "rsyslog/rsyslog.conf.j2", "kea-dhcp4.conf.j2", "/usr/share/sonic/templates/"] COPY ["critical_processes", "/etc/supervisor/"] +COPY ["lease_update.sh", "/etc/kea/"] +COPY ["kea-dhcp4-init.conf", "/etc/kea/kea-dhcp4.conf"] COPY ["cli", "/cli/"] +COPY ["rsyslog/default.conf", "/etc/rsyslog.d"] ENTRYPOINT ["/usr/bin/docker_init.sh"] diff --git a/dockers/docker-dhcp-server/critical_processes b/dockers/docker-dhcp-server/critical_processes index e69de29bb2d1..cff4ef95a931 100644 --- a/dockers/docker-dhcp-server/critical_processes +++ b/dockers/docker-dhcp-server/critical_processes @@ -0,0 +1 @@ +group:dhcp-server-ipv4 diff --git a/dockers/docker-dhcp-server/docker_init.sh b/dockers/docker-dhcp-server/docker_init.sh index 5f5d39721339..21ff37059aab 100755 --- a/dockers/docker-dhcp-server/docker_init.sh +++ b/dockers/docker-dhcp-server/docker_init.sh @@ -1,5 +1,21 @@ #!/usr/bin/env bash + +# Generate supervisord config file +mkdir -p /etc/supervisor/conf.d/ +# Generate kea folder +mkdir -p /etc/kea/ +udp_server_ip=$(ip -j -4 addr list lo scope host | jq -r -M '.[0].addr_info[0].local') +hostname=$(hostname) +# Generate the following files from templates: +# port-to-alias name map +sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 \ + -a "{\"udp_server_ip\": \"$udp_server_ip\", \"hostname\": \"$hostname\"}" \ + > /etc/rsyslog.conf +sonic-cfggen -d -t /usr/share/sonic/templates/port-name-alias-map.txt.j2,/tmp/port-name-alias-map.txt + +# Make the script that waits for all interfaces to come up executable +chmod +x /etc/kea/lease_update.sh /usr/bin/start.sh # The docker container should start this script as PID 1, so now that supervisord is # properly configured, we exec /usr/local/bin/supervisord so that it runs as PID 1 for the # duration of the container's lifetime diff --git a/dockers/docker-dhcp-server/kea-dhcp4-init.conf b/dockers/docker-dhcp-server/kea-dhcp4-init.conf new file mode 100644 index 000000000000..63733d3ef821 --- /dev/null +++ b/dockers/docker-dhcp-server/kea-dhcp4-init.conf @@ -0,0 +1,40 @@ +{ + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "/etc/kea/lease_update.sh", + "sync": false + } + } + ], + "interfaces-config": { + "interfaces": ["eth0"] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": true, + "name": "/tmp/kea-lease.csv", + "lfc-interval": 3600 + }, + "subnet4": [], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/tmp/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ] + } +} diff --git a/dockers/docker-dhcp-server/kea-dhcp4.conf.j2 b/dockers/docker-dhcp-server/kea-dhcp4.conf.j2 new file mode 100644 index 000000000000..27fd1a1d1f90 --- /dev/null +++ b/dockers/docker-dhcp-server/kea-dhcp4.conf.j2 @@ -0,0 +1,87 @@ +{%- set default_lease_time = 900 -%} +{ + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "{{ lease_update_script_path }}", + "sync": false + } + } + ], + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": true, + "name": "{{ lease_path }}", + "lfc-interval": 3600 + }, + "subnet4": [ +{%- set add_subnet_preceding_comma = { 'flag': False } %} +{%- for subnet_info in subnets %} + {%- if add_subnet_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_subnet_preceding_comma.update({'flag': True}) %} + { + "subnet": "{{ subnet_info["subnet"] }}", + "pools": [ + {%- set add_pool_preceding_comma = { 'flag': False } %} + {%- for pool in subnet_info["pools"] %} + {%- if add_pool_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_pool_preceding_comma.update({'flag': True}) %} + { + "pool": "{{ pool["range"] }}", + "client-class": "{{ pool["client_class"] }}" + } + {%- endfor%} + ], + "option-data": [ + { + "name": "routers", + "data": "{{ subnet_info["gateway"] if "gateway" in subnet_info else subnet_info["server_id"] }}" + }, + { + "name": "dhcp-server-identifier", + "data": "{{ subnet_info["server_id"] }}" + } + ], + "valid-lifetime": {{ subnet_info["lease_time"] if "lease_time" in subnet_info else default_lease_time }}, + "reservations": [] + } +{%- endfor %} + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/var/log/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ]{%- if client_classes -%}, + "client-classes": [ + {%- set add_preceding_comma = { 'flag': False } %} + {%- for class in client_classes %} + {%- if add_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_preceding_comma.update({'flag': True}) %} + { + "name": "{{ class["name"] }}", + "test": "{{ class["condition"] }}" + } + {%- endfor %} + ] + {%- endif %} + } +} diff --git a/dockers/docker-dhcp-server/lease_update.sh b/dockers/docker-dhcp-server/lease_update.sh new file mode 100644 index 000000000000..9fdb8f4f3e29 --- /dev/null +++ b/dockers/docker-dhcp-server/lease_update.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# This script would run once kea-dhcp4 lease change (defined in kea-dhcp4.conf), +# it is to find running process dhcpservd.py, and send SIGUSR1 signal to this +# process to inform it to update lease table in state_db (defined in dhcpservd.py) + +pid=`ps aux | grep 'dhcpservd' | grep -nv 'grep' | awk '{print $2}'` +if [ -z "$pid" ]; then + logger -p daemon.error Cannot find running dhcpservd.py. +else + # Send SIGUSR1 signal to dhcpservd.py + kill -s 10 ${pid} +fi diff --git a/dockers/docker-dhcp-server/port-name-alias-map.txt.j2 b/dockers/docker-dhcp-server/port-name-alias-map.txt.j2 new file mode 100644 index 000000000000..b2290a9ffbf2 --- /dev/null +++ b/dockers/docker-dhcp-server/port-name-alias-map.txt.j2 @@ -0,0 +1,5 @@ +{# Generate port name-alias map for isc-dhcp-relay to parse. Each line contains one #} +{# name-alias pair of the form " " #} +{% for port, config in PORT.items() %} + {{- port }} {% if "alias" in config %}{{ config["alias"] }}{% else %}{{ port }}{% endif %} {{- "\n" -}} +{% endfor -%} diff --git a/dockers/docker-dhcp-server/rsyslog/default.conf b/dockers/docker-dhcp-server/rsyslog/default.conf new file mode 100644 index 000000000000..77609410c57a --- /dev/null +++ b/dockers/docker-dhcp-server/rsyslog/default.conf @@ -0,0 +1,27 @@ +# +# First some standard log files. Log by facility. +# + +# Log all facilities to /var/log/syslog except cron, auth +# and authpriv. They are noisy - log them to their own files +*.*;cron,auth,authpriv.none -/var/log/syslog +auth,authpriv.* /var/log/auth.log +cron.* /var/log/cron.log + +# +# Emergencies are sent to everybody logged in. +# +*.emerg :omusrmsg:* + +# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, +# you must invoke `xconsole' with the `-file' option: +# +# $ xconsole -file /dev/xconsole [...] +# +# NOTE: adjust the list below, or you'll go crazy if you have a reasonably +# busy site.. +# +#daemon.*;mail.*;\ +# news.err;\ +# *.=debug;*.=info;\ +# *.=notice;*.=warn |/dev/xconsole diff --git a/dockers/docker-dhcp-server/rsyslog/rsyslog.conf.j2 b/dockers/docker-dhcp-server/rsyslog/rsyslog.conf.j2 new file mode 100644 index 000000000000..664a6a5fb9bd --- /dev/null +++ b/dockers/docker-dhcp-server/rsyslog/rsyslog.conf.j2 @@ -0,0 +1,96 @@ +############################################################################### +# Managed by Ansible +# file: ansible/roles/acs/templates/rsyslog.conf.j2 +############################################################################### +# +# /etc/rsyslog.conf Configuration file for rsyslog. +# +# For more information see +# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html + + +################# +#### MODULES #### +################# + +$ModLoad imuxsock # provides support for local system logging + +{% set gconf = (SYSLOG_CONFIG | d({})).get('GLOBAL', {}) -%} +{% set rate_limit_interval = gconf.get('rate_limit_interval') %} +{% set rate_limit_burst = gconf.get('rate_limit_burst') %} + +{% if rate_limit_interval is not none %} +$SystemLogRateLimitInterval {{ rate_limit_interval }} +{% endif %} +{% if rate_limit_burst is not none %} +$SystemLogRateLimitBurst {{ rate_limit_burst }} +{% endif %} + +$ModLoad imklog # provides kernel logging support +#$ModLoad immark # provides --MARK-- message capability + +# provides UDP syslog reception +$ModLoad imudp +$UDPServerAddress {{udp_server_ip}} #bind to localhost before udp server run +$UDPServerRun 514 + +# provides TCP syslog reception +#$ModLoad imtcp +#$InputTCPServerRun 514 + + +########################### +#### GLOBAL DIRECTIVES #### +########################### +{% set format = gconf.get('format', 'standard') -%} +{% set fw_name = gconf.get('welf_firewall_name', hostname) -%} +# +# Use traditional timestamp format. +# To enable high precision timestamps, comment out the following line. +# +#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +# Define a custom template +$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% dhcp_server#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" +$ActionFileDefaultTemplate SONiCFileFormat + +template(name="WelfRemoteFormat" type="string" string="%TIMESTAMP% id=firewall time=\"%timereported\ +:::date-year%-%timereported:::date-month%-%timereported:::date-day% %timereported:::date-hour%:%timereported:::date-minute%:%timereported\ +:::date-second%\" fw=\"{{ fw_name }}\" pri=%syslogpriority% msg=\"%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\"\n") + +# +# Set the default permissions for all log files. +# +$FileOwner root +$FileGroup adm +$FileCreateMode 0640 +$DirCreateMode 0755 +$Umask 0022 + +# +# Where to place spool and state files +# +$WorkDirectory /var/spool/rsyslog + +# +# Include all config files in /etc/rsyslog.d/ +# +$IncludeConfig /etc/rsyslog.d/*.conf + +# +# Suppress duplicate messages and report "message repeated n times" +# +$RepeatedMsgReduction on + +############### +#### RULES #### +############### + +# +# Remote syslog logging +# + +# The omfwd plug-in provides the core functionality of traditional message +# forwarding via UDP and plain TCP. It is a built-in module that does not need +# to be loaded. +# TODO rsyslog issue in bridge mode container, don't update to remote server for now diff --git a/dockers/docker-dhcp-server/start.sh b/dockers/docker-dhcp-server/start.sh new file mode 100755 index 000000000000..46b8eb503a4a --- /dev/null +++ b/dockers/docker-dhcp-server/start.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ "${RUNTIME_OWNER}" == "" ]; then + RUNTIME_OWNER="kube" +fi + +# This script is to basicly check for if this starting-container can be allowed +# to run based on current state, and owner & version of this starting container. +# If allowed, update feature info in state_db and then processes in supervisord.conf +# after this process can start up. +CTR_SCRIPT="/usr/share/sonic/scripts/container_startup.py" +if test -f ${CTR_SCRIPT} +then + ${CTR_SCRIPT} -f dhcp_server -o ${RUNTIME_OWNER} -v ${IMAGE_VERSION} +fi + +TZ=$(cat /etc/timezone) +rm -rf /etc/localtime +ln -sf /usr/share/zoneinfo/$TZ /etc/localtime diff --git a/dockers/docker-dhcp-server/supervisord.conf b/dockers/docker-dhcp-server/supervisord.conf index b4ee4f477d32..ea958b9e7cfd 100644 --- a/dockers/docker-dhcp-server/supervisord.conf +++ b/dockers/docker-dhcp-server/supervisord.conf @@ -13,7 +13,7 @@ events=PROCESS_STATE buffer_size=1024 [eventlistener:supervisor-proc-exit-listener] -command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_server +command=/usr/bin/supervisor-proc-exit-listener --container-name dhcp_server --use-unix-socket-path events=PROCESS_STATE_EXITED,PROCESS_STATE_RUNNING autostart=true autorestart=unexpected @@ -38,3 +38,26 @@ stdout_logfile=syslog stderr_logfile=syslog dependent_startup=true dependent_startup_wait_for=rsyslogd:running + +[group:dhcp-server-ipv4] +programs=dhcpservd,kea-dhcp4 + +[program:dhcpservd] +command=/usr/local/bin/dhcpservd +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited + +[program:kea-dhcp4] +command=/usr/local/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf +priority=3 +autostart=false +autorestart=false +stdout_logfile=syslog +stderr_logfile=syslog +dependent_startup=true +dependent_startup_wait_for=start:exited diff --git a/dockers/docker-fpm-frr/docker_init.sh b/dockers/docker-fpm-frr/docker_init.sh index 5e25739b219e..0ed274ec703f 100755 --- a/dockers/docker-fpm-frr/docker_init.sh +++ b/dockers/docker-fpm-frr/docker_init.sh @@ -46,7 +46,8 @@ write_default_zebra_config() FILE_NAME=${1} grep -q '^no fpm use-next-hop-groups' $FILE_NAME || { - sed -i '1i no fpm use-next-hop-groups\nfpm address 127.0.0.1' $FILE_NAME + echo "no fpm use-next-hop-groups" >> $FILE_NAME + echo "fpm address 127.0.0.1" >> $FILE_NAME } } diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 index b12f8e8c84a3..d2d2be87e7f3 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/internal/peer-group.conf.j2 @@ -15,6 +15,7 @@ neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out neighbor INTERNAL_PEER_V4 send-community + neighbor INTERNAL_PEER_V4 ttl-security hops 1 exit-address-family {% if CONFIG_DB__DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} neighbor INTERNAL_PEER_V6 update-source Loopback4096 @@ -28,6 +29,7 @@ neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out neighbor INTERNAL_PEER_V6 send-community + neighbor INTERNAL_PEER_V6 ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/internal/peer-group.conf.j2 diff --git a/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 b/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 index 802aa15ca60f..44552c055db8 100644 --- a/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 +++ b/dockers/docker-fpm-frr/frr/bgpd/templates/voq_chassis/peer-group.conf.j2 @@ -13,6 +13,7 @@ neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V4_PEER in neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V4_PEER out neighbor VOQ_CHASSIS_V4_PEER send-community + neighbor VOQ_CHASSIS_V4_PEER ttl-security hops 1 exit-address-family address-family ipv6 {% if CONFIG_DB__DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} @@ -24,6 +25,7 @@ neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out neighbor VOQ_CHASSIS_V6_PEER send-community + neighbor VOQ_CHASSIS_V6_PEER ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/dockers/docker-orchagent/orchagent.sh b/dockers/docker-orchagent/orchagent.sh index 45571944db30..f407e266ca2a 100755 --- a/dockers/docker-orchagent/orchagent.sh +++ b/dockers/docker-orchagent/orchagent.sh @@ -69,4 +69,10 @@ else ORCHAGENT_ARGS+="-m $MAC_ADDRESS" fi +# Enable ZMQ for SmartSwitch +LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget localhost "subtype"` +if [[ x"${LOCALHOST_SUBTYPE}" == x"SmartSwitch" ]]; then + ORCHAGENT_ARGS+=" -q tcp://127.0.0.1:8100" +fi + exec /usr/bin/orchagent ${ORCHAGENT_ARGS} diff --git a/dockers/docker-sonic-mgmt/0001-Fix-getattr-AttributeError-in-multi-thread-scenario.patch b/dockers/docker-sonic-mgmt/0001-Fix-getattr-AttributeError-in-multi-thread-scenario.patch new file mode 100644 index 000000000000..b7f49c4e884f --- /dev/null +++ b/dockers/docker-sonic-mgmt/0001-Fix-getattr-AttributeError-in-multi-thread-scenario.patch @@ -0,0 +1,46 @@ +From e323263795a0af4c9c61992bd7a3347d8928db39 Mon Sep 17 00:00:00 2001 +From: Xin Wang +Date: Thu, 14 Sep 2023 16:52:54 +0800 +Subject: [PATCH] Fix getattr AttributeError in multi-thread scenario + +When multi-thread is used, the plugin loader may raise AttributeError +while getting "ActionModule" from an action plugin. + +The reason is that cache is used while loading module. Before a module +is fully loaded, it is already put into the sys.modules cache. When another +thread tries to load the same module, it would load an incompletely loaded +module from the sys.modules cache. Then while getting "ActionModule" +attribute from this module, exception AttributeError could be raised. + +Signed-off-by: Xin Wang +--- + lib/ansible/plugins/loader.py | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py +index 74bdeb5719..251531b62e 100644 +--- a/lib/ansible/plugins/loader.py ++++ b/lib/ansible/plugins/loader.py +@@ -801,15 +801,14 @@ class PluginLoader: + warnings.simplefilter("ignore", RuntimeWarning) + spec = importlib.util.spec_from_file_location(to_native(full_name), to_native(path)) + module = importlib.util.module_from_spec(spec) +- +- # mimic import machinery; make the module-being-loaded available in sys.modules during import +- # and remove if there's a failure... +- sys.modules[full_name] = module +- + try: + spec.loader.exec_module(module) ++ # mimic import machinery; make the module-being-loaded available in sys.modules during import ++ # and remove if there's a failure... ++ sys.modules[full_name] = module + except Exception: +- del sys.modules[full_name] ++ if full_name in sys.modules: ++ del sys.modules[full_name] + raise + + return module +-- +2.25.1 diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2 index 39002f6d1ed1..e4f3e07d63f6 100755 --- a/dockers/docker-sonic-mgmt/Dockerfile.j2 +++ b/dockers/docker-sonic-mgmt/Dockerfile.j2 @@ -38,10 +38,10 @@ RUN apt-get update && apt-get install -y apt-transport-https \ telnet \ vim -RUN pip3 install --upgrade pip setuptools wheel -RUN pip3 install aiohttp \ +RUN python3 -m pip install --upgrade pip setuptools wheel +RUN python3 -m pip install aiohttp \ allure-pytest==2.8.22 \ - ansible==2.9.27 \ + ansible==6.7.0 \ azure-storage-blob==12.9.0 \ azure-kusto-data \ azure-kusto-ingest \ @@ -49,7 +49,7 @@ RUN pip3 install aiohttp \ celery[redis]==5.2.7 \ cffi \ contextlib2==0.6.0.post1 \ - cryptography==3.3.2 \ + cryptography==41.0.2 \ ctypesgen \ dpkt \ dpugen==0.1.1 \ @@ -60,7 +60,7 @@ RUN pip3 install aiohttp \ ixload \ ixnetwork-restpy==1.0.64 \ ixnetwork-open-traffic-generator==0.0.79 \ - jinja2==2.10.1 \ + jinja2==3.1.2 \ jsonpatch \ lxml \ markupsafe==2.0.1 \ @@ -71,7 +71,7 @@ RUN pip3 install aiohttp \ netaddr \ netmiko==2.4.2 \ pandas \ - paramiko==2.7.1 \ + paramiko==2.9.5 \ passlib \ pexpect \ prettytable \ @@ -84,12 +84,12 @@ RUN pip3 install aiohttp \ pyro4 \ pysnmp==4.4.12 \ pysubnettree \ - pytest-ansible \ + pytest-ansible==4.0.0 \ pytest-html \ pytest-repeat \ pytest-xdist==1.28.0 \ python-dateutil \ - pytest==7.1.3 \ + pytest==7.4.0 \ PyYAML \ redis \ requests \ @@ -99,7 +99,7 @@ RUN pip3 install aiohttp \ scapy==2.4.5 \ setuptools-rust \ six \ - snappi[ixnetwork,convergence]==0.7.44 \ + snappi[ixnetwork,convergence]==0.11.16 \ tabulate \ textfsm==1.1.2 \ thrift==0.11.0 \ @@ -115,21 +115,15 @@ RUN pip3 install aiohttp \ && cd ../.. \ && rm -fr nanomsg-1.2 \ && rm -f 1.2.tar.gz \ - && pip3 install nnpy - -RUN curl -fsSL http://archive.ubuntu.com/ubuntu/pool/universe/s/scapy/python-scapy_2.3.3-3_all.deb \ - --output python-scapy_2.3.3-3_all.deb \ - && dpkg -i python-scapy_2.3.3-3_all.deb \ - && rm -f python-scapy_2.3.3-3_all.deb + && python3 -m pip install nnpy RUN curl -fsSL https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py \ && python2 get-pip.py \ - && rm -f get-pip.py \ - && ln -sf `which pip2` /usr/bin/pip + && rm -f get-pip.py -RUN pip install --upgrade pip setuptools wheel -RUN pip install allure-pytest==2.8.22 \ - ansible==2.8.12 \ +RUN python2 -m pip install --upgrade pip setuptools wheel +RUN python2 -m pip install allure-pytest==2.8.22 \ + ansible==2.8.20 \ azure-storage-blob==12.9.0 \ celery[redis]==4.4.7 \ cffi==1.12.0 \ @@ -156,11 +150,13 @@ RUN pip install allure-pytest==2.8.22 \ netmiko==2.4.2 \ nnpy \ pandas \ - paramiko==2.7.1 \ + paramiko==2.7.2 \ passlib \ pexpect \ prettytable \ + protobuf==3.15.0 \ psutil \ + ptf \ pyaml==21.10.1 \ pyasn1==0.1.9 \ pycryptodome==3.9.8 \ @@ -181,19 +177,14 @@ RUN pip install allure-pytest==2.8.22 \ retry \ rpyc \ scandir \ + scapy==2.4.5 \ six \ - snappi[ixnetwork,convergence]==0.7.44 \ + snappi[ixnetwork,convergence]==0.11.16 \ statistics \ tabulate \ textfsm==1.1.3 \ thrift==0.11.0 \ - virtualenv \ - && git clone https://github.com/p4lang/scapy-vxlan.git \ - && cd scapy-vxlan \ - && python setup.py install \ - && cd .. \ - && rm -fr scapy-vxlan \ - && pip install scapy==2.4.5 --upgrade --ignore-installed + virtualenv # Install docker-ce-cli RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \ @@ -209,16 +200,9 @@ RUN mkdir -p /etc/apt/keyrings \ && apt-get update && apt-get install -y azure-cli ## Copy and install sonic-mgmt docker dependencies -COPY \ -{% for deb in docker_sonic_mgmt_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor -%} -debs/ +COPY debs/sonic-device-data_*.deb debs/ -RUN dpkg -i \ -{% for deb in docker_sonic_mgmt_debs.split(' ') -%} -debs/{{ deb }}{{' '}} -{%- endfor %} +RUN dpkg -i debs/sonic-device-data_*.deb # Install protobuf 3.21.12 which is from https://deb.debian.org/debian/pool/main/p/protobuf/protobuf_3.21.12-3.dsc RUN mkdir -p /tmp/protobuf \ @@ -293,7 +277,7 @@ RUN python3 -m pip install aiohttp \ celery[redis]==5.2.7 \ cffi \ contextlib2==0.6.0.post1 \ - cryptography==3.3.2 \ + cryptography==41.0.2 \ ctypesgen \ dpkt \ dpugen==0.1.1 \ @@ -316,7 +300,7 @@ RUN python3 -m pip install aiohttp \ netmiko==2.4.2 \ nnpy \ pandas \ - paramiko==2.7.1 \ + paramiko==2.7.2 \ passlib \ pexpect \ prettytable \ @@ -344,7 +328,7 @@ RUN python3 -m pip install aiohttp \ scapy==2.4.5 \ setuptools-rust \ six \ - snappi[ixnetwork,convergence]==0.7.44 \ + snappi[ixnetwork,convergence]==0.11.16 \ sshconf==0.2.5 \ tabulate \ textfsm==1.1.2 \ @@ -356,8 +340,14 @@ ENV PATH="$BACKUP_OF_PATH" USER root WORKDIR /azp -COPY ./start.sh . -RUN chmod +x start.sh +COPY start.sh \ + 0001-Fix-getattr-AttributeError-in-multi-thread-scenario.patch \ + ./ +RUN chmod +x start.sh \ + && ln -sf /usr/bin/python3 /usr/bin/python \ + && ln -sf `which pip3` /usr/bin/pip \ + && ln -sf `which pip3` /usr/local/sbin/pip \ + && patch -u -b /usr/local/lib/python3.8/dist-packages/ansible/plugins/loader.py -i /azp/0001-Fix-getattr-AttributeError-in-multi-thread-scenario.patch USER $user WORKDIR /var/$user diff --git a/dockers/docker-sonic-telemetry/telemetry.sh b/dockers/docker-sonic-telemetry/telemetry.sh index 6e5de142baf8..e44a2282b85c 100755 --- a/dockers/docker-sonic-telemetry/telemetry.sh +++ b/dockers/docker-sonic-telemetry/telemetry.sh @@ -70,6 +70,12 @@ else TELEMETRY_ARGS+=" -v=2" fi +# Enable ZMQ for SmartSwitch +LOCALHOST_SUBTYPE=`sonic-db-cli CONFIG_DB hget localhost "subtype"` +if [[ x"${LOCALHOST_SUBTYPE}" == x"SmartSwitch" ]]; then + TELEMETRY_ARGS+=" -zmq_address=tcp://127.0.0.1:8100" +fi + # Server will handle threshold connections consecutively THRESHOLD_CONNECTIONS=$(echo $GNMI | jq -r '.threshold') if [[ $THRESHOLD_CONNECTIONS =~ ^[0-9]+$ ]]; then diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index c5c6a60aa26e..143e869e58f4 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -615,6 +615,14 @@ write_platform_specific_cmdline() { aboot_machine=arista_7280cr3mk_32p4 flash_size=7382 fi + + # disable cpu c-state other than C1 + local cpuvendor="$(sed -nr 's/vendor_id[\t ]*: (.*)/\1/p' /proc/cpuinfo | head -n 1)" + cmdline_add processor.max_cstate=1 + if [ "$cpuvendor" = "GenuineIntel" ]; then + cmdline_add intel_idle.max_cstate=0 + fi + if in_array "$platform" "rook" "magpie" "woodpecker" "sprucefish"; then cmdline_add tsc=reliable cmdline_add pcie_ports=native @@ -625,7 +633,6 @@ write_platform_specific_cmdline() { if in_array "$platform" "rook" "sprucefish"; then cmdline_add iommu=on cmdline_add intel_iommu=on - cmdline_add intel_idle.max_cstate=0 read_system_eeprom fi if in_array "$platform" "rook"; then @@ -643,7 +650,6 @@ write_platform_specific_cmdline() { read_system_eeprom fi if in_array "$platform" "lorikeet" "hedgehog"; then - cmdline_add processor.max_cstate=1 cmdline_add reassign_prefmem read_system_eeprom fi diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 0b173d3eedb4..f8e5d8b4b5ad 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -47,10 +47,10 @@ function updateSyslogConf() {%- if docker_container_name == "database" %} python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE {%- else %} - sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\", \"platform\": \"$PLATFORM\" }" > $TMP_FILE if [ $? -ne 0 ]; then echo "Error: Execute sonic-cfggen -d failed. Execute without '-d'." - sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\", \"platform\": \"$PLATFORM\" }" > $TMP_FILE fi {%- endif %} docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf diff --git a/files/build_templates/snmp.service.j2 b/files/build_templates/snmp.service.j2 index c6e92ef59813..503d54eed3fd 100644 --- a/files/build_templates/snmp.service.j2 +++ b/files/build_templates/snmp.service.j2 @@ -10,6 +10,7 @@ StartLimitIntervalSec=1200 StartLimitBurst=3 [Service] +ExecStartPre=/bin/bash -c 'end=$((SECONDS+20));while [ $SECONDS -lt $end ];do if /usr/bin/pgrep intfmgrd >/dev/null;then break;else sleep 1;fi;done' ExecStartPre=/usr/local/bin/{{docker_container_name}}.sh start ExecStart=/usr/local/bin/{{docker_container_name}}.sh wait ExecStop=/usr/local/bin/{{docker_container_name}}.sh stop diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 7225bf0fd09d..848911433c94 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -300,7 +300,7 @@ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/libnss-radius_*.deb || \ sudo sed -i -e '/^passwd/s/ radius//' $FILESYSTEM_ROOT/etc/nsswitch.conf # Install a custom version of kdump-tools (and its dependencies via 'apt-get -y install -f') -if [[ $TARGET_BOOTLOADER == grub ]]; then +if [ "$TARGET_BOOTLOADER" != uboot ]; then sudo DEBIAN_FRONTEND=noninteractive dpkg --root=$FILESYSTEM_ROOT -i $debs_path/kdump-tools_*.deb || \ sudo LANG=C DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true chroot $FILESYSTEM_ROOT apt-get -q --no-install-suggests --no-install-recommends install cat $IMAGE_CONFIGS/kdump/kdump-tools | sudo tee -a $FILESYSTEM_ROOT/etc/default/kdump-tools > /dev/null @@ -359,7 +359,7 @@ sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/restart_service sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y install smartmontools=7.2-1 # Install custom-built openssh sshd -sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/openssh-server_${OPENSSH_VERSION}_*.deb +sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/openssh-server_${OPENSSH_VERSION}_*.deb $debs_path/openssh-client_${OPENSSH_VERSION}_*.deb $debs_path/openssh-sftp-server_${OPENSSH_VERSION}_*.deb {% if sonic_asic_platform == 'broadcom' %} # Install custom-built flashrom diff --git a/files/image_config/copp/copp_cfg.j2 b/files/image_config/copp/copp_cfg.j2 index 46d921b82765..08366e57f647 100755 --- a/files/image_config/copp/copp_cfg.j2 +++ b/files/image_config/copp/copp_cfg.j2 @@ -11,7 +11,12 @@ "queue4_group1": { "trap_action":"trap", "trap_priority":"4", - "queue": "4" + "queue": "4", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"6000", + "cbs":"6000", + "red_action":"drop" }, "queue4_group2": { "trap_action":"copy", @@ -26,7 +31,12 @@ "queue4_group3": { "trap_action":"trap", "trap_priority":"4", - "queue": "4" + "queue": "4", + "meter_type":"packets", + "mode":"sr_tcm", + "cir":"300", + "cbs":"300", + "red_action":"drop" }, "queue1_group1": { "trap_action":"trap", @@ -97,7 +107,7 @@ }, "macsec": { "trap_ids": "eapol", - "trap_group": "queue4_group3" + "trap_group": "queue4_group1" }, "nat": { "trap_ids": "src_nat_miss,dest_nat_miss", diff --git a/files/image_config/rsyslog/rsyslog-container.conf.j2 b/files/image_config/rsyslog/rsyslog-container.conf.j2 index a6419eba846a..bb786eacd4ec 100644 --- a/files/image_config/rsyslog/rsyslog-container.conf.j2 +++ b/files/image_config/rsyslog/rsyslog-container.conf.j2 @@ -52,7 +52,18 @@ $SystemLogRateLimitBurst 20000 ########################### #### GLOBAL DIRECTIVES #### ########################### +{% if container_name == 'pmon' %} +{% if platform == 'x86_64-mlnx_msn2700-r0' or platform == 'x86_64-mlnx_msn2700a1-r0' %} +# This rsyslog configuration is intended to resolve the following error message that only appears on the MSN2700 platform: +# "ERR pmon#sensord: Error getting sensor data: dps460/#10: Can't read" +# This error is because of firmware issue with some type of PSU, we are not able to upgrade the FW online. +# Since there is no functional impact, this error log can be ignored safely. + +if $programname contains "sensord" and $msg contains "Error getting sensor data: dps460/#" then stop + +{% endif %} +{% endif %} # Set remote syslog server template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% {{container_name}}#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%") *.* action(type="omfwd" target="{{target_ip}}" port="514" protocol="udp" Template="ForwardFormatInContainer") diff --git a/platform/broadcom/one-aboot.mk b/platform/broadcom/one-aboot.mk index d8e502ea9828..b3dd74b5978b 100644 --- a/platform/broadcom/one-aboot.mk +++ b/platform/broadcom/one-aboot.mk @@ -4,7 +4,9 @@ SONIC_ONE_ABOOT_IMAGE = sonic-aboot-broadcom.swi $(SONIC_ONE_ABOOT_IMAGE)_MACHINE = broadcom $(SONIC_ONE_ABOOT_IMAGE)_DEPENDENT_MACHINE = broadcom-dnx $(SONIC_ONE_ABOOT_IMAGE)_IMAGE_TYPE = aboot +ifeq ($(INCLUDE_GBSYNCD), y) $(SONIC_ONE_ABOOT_IMAGE)_INSTALLS += $(PHY_CREDO) +endif $(SONIC_ONE_ABOOT_IMAGE)_INSTALLS += $(FLASHROM) $(SONIC_ONE_ABOOT_IMAGE)_INSTALLS += $(SYSTEMD_SONIC_GENERATOR) $(SONIC_ONE_ABOOT_IMAGE)_LAZY_BUILD_INSTALLS = $(BRCM_OPENNSL_KERNEL) $(BRCM_DNX_OPENNSL_KERNEL) diff --git a/platform/broadcom/rules.dep b/platform/broadcom/rules.dep index 075636a8dedd..47f7f849ed2f 100644 --- a/platform/broadcom/rules.dep +++ b/platform/broadcom/rules.dep @@ -29,5 +29,7 @@ include $(PLATFORM_PATH)/one-aboot.dep include $(PLATFORM_PATH)/libsaithrift-dev.dep include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.dep include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.dep +ifeq ($(INCLUDE_GBSYNCD), y) include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.dep include $(PLATFORM_PATH)/../components/docker-gbsyncd-broncos.dep +endif diff --git a/platform/broadcom/rules.mk b/platform/broadcom/rules.mk index edc4eb57945d..46700df119b1 100755 --- a/platform/broadcom/rules.mk +++ b/platform/broadcom/rules.mk @@ -30,8 +30,10 @@ include $(PLATFORM_PATH)/one-aboot.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/docker-syncd-brcm-dnx.mk include $(PLATFORM_PATH)/docker-syncd-brcm-dnx-rpc.mk +ifeq ($(INCLUDE_GBSYNCD), y) include $(PLATFORM_PATH)/../components/docker-gbsyncd-credo.mk include $(PLATFORM_PATH)/../components/docker-gbsyncd-broncos.mk +endif BCMCMD = bcmcmd $(BCMCMD)_URL = "https://sonicstorage.blob.core.windows.net/packages/20190307/bcmcmd?sv=2015-04-05&sr=b&sig=sUdbU7oVbh5exbXXHVL5TDFBTWDDBASHeJ8Cp0B0TIc%3D&se=2038-05-06T22%3A34%3A19Z&sp=r" diff --git a/platform/broadcom/sai-modules.mk b/platform/broadcom/sai-modules.mk index 5aa7792064cb..dce19b6227c6 100644 --- a/platform/broadcom/sai-modules.mk +++ b/platform/broadcom/sai-modules.mk @@ -1,6 +1,6 @@ # Broadcom SAI modules -BRCM_OPENNSL_KERNEL_VERSION = 7.1.0.0 +BRCM_OPENNSL_KERNEL_VERSION = 8.4.0.2 BRCM_OPENNSL_KERNEL = opennsl-modules_$(BRCM_OPENNSL_KERNEL_VERSION)_amd64.deb $(BRCM_OPENNSL_KERNEL)_SRC_PATH = $(PLATFORM_PATH)/saibcm-modules diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index f39cdb0f413e..3b534eb2783d 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,4 +1,4 @@ -LIBSAIBCM_XGS_VERSION = 8.4.0.2 +LIBSAIBCM_XGS_VERSION = 8.4.21.0 LIBSAIBCM_DNX_VERSION = 7.1.111.1 LIBSAIBCM_XGS_BRANCH_NAME = SAI_8.4.0_GA LIBSAIBCM_DNX_BRANCH_NAME = REL_7.0_SAI_1.11 diff --git a/platform/broadcom/saibcm-modules/debian/changelog b/platform/broadcom/saibcm-modules/debian/changelog index daa78471c6b2..9233f775a806 100644 --- a/platform/broadcom/saibcm-modules/debian/changelog +++ b/platform/broadcom/saibcm-modules/debian/changelog @@ -1,3 +1,9 @@ +opennsl (8.4.0.2) unstable; urgency=medium + + * Update to Broadcom SAI 8.4.0.2 + + -- Ziting Guo Tue, Sep 5 02:25:03 2023 +0000 + opennsl (7.1.0.0) unstable; urgency=medium * Update to Broadcom SAI 7.1.0.0. diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install index 7d9d7b192cda..1bd3f6d744ff 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules.install @@ -3,6 +3,6 @@ systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/5.10.0 systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/5.10.0-23-2-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/5.10.0-23-2-amd64/extra systemd/opennsl-modules.service lib/systemd/system -sdklt/linux/bde/linux_ngbde.ko lib/modules/5.10.0-23-2-amd64/extra -sdklt/linux/knet/linux_ngknet.ko lib/modules/5.10.0-23-2-amd64/extra -sdklt/linux/knetcb/linux_ngknetcb.ko lib/modules/5.10.0-23-2-amd64/extra +sdklt/build/bde/linux_ngbde.ko lib/modules/5.10.0-23-2-amd64/extra +sdklt/build/knet/linux_ngknet.ko lib/modules/5.10.0-23-2-amd64/extra +sdklt/build/knetcb/linux_ngknetcb.ko lib/modules/5.10.0-23-2-amd64/extra diff --git a/platform/broadcom/saibcm-modules/include/ibde.h b/platform/broadcom/saibcm-modules/include/ibde.h index d71d487f03e5..12f507ea6fd2 100644 --- a/platform/broadcom/saibcm-modules/include/ibde.h +++ b/platform/broadcom/saibcm-modules/include/ibde.h @@ -88,6 +88,7 @@ typedef struct ibde_s { #define BDE_AXI_DEV_TYPE SAL_AXI_DEV_TYPE /* AXI device */ #define BDE_EMMI_DEV_TYPE SAL_EMMI_DEV_TYPE /* EMMI device */ #define BDE_COMPOSITE_DEV_TYPE SAL_COMPOSITE_DEV_TYPE /* Composite device, composed of sub-devices with buses */ +#define BDE_SUB_DEV_TYPE SAL_SUB_DEV_TYPE /* A sub-device (with a bus) of a composite device */ #define BDE_USER_DEV_TYPE SAL_USER_DEV_TYPE /* The user implements his own method of access to the device */ #define BDE_DEV_BUS_ALT SAL_DEV_BUS_ALT /* Alternate Access */ #define BDE_DEV_BUS_MSI SAL_DEV_BUS_MSI /* Message-signaled interrupts */ @@ -186,6 +187,23 @@ typedef struct ibde_s { uint64 (*read64)(int d, uint32 addr); void (*write64)(int d, uint32 addr, uint64 data); + /* + * Probe for new devices. + * + * This function will normally be called implicitly by the BDE + * initialization function, but it may be called at a later time + * by the application to detect removed or added devices. + * + * Existing devices are not affected by this operation. + * + * If a device has been hot-swapped, then it will be assigned the + * same resources as before the hot-swap. + * + * Return value: + * 0: Device probe completed successfully. + * -1: An error happened during device probe. + */ + int (*probe)(void); } ibde_t; diff --git a/platform/broadcom/saibcm-modules/include/kcom.h b/platform/broadcom/saibcm-modules/include/kcom.h index 4771033c6b04..341ddd0f70d2 100644 --- a/platform/broadcom/saibcm-modules/include/kcom.h +++ b/platform/broadcom/saibcm-modules/include/kcom.h @@ -72,6 +72,7 @@ #define KCOM_M_DBGPKT_GET 42 /* Get debug packet function info */ #define KCOM_M_WB_CLEANUP 51 /* Clean up for warmbooting */ #define KCOM_M_CLOCK_CMD 52 /* Clock Commands */ +#define KCOM_M_PCIE_LINK_STATUS 53 /* PCIe link status */ #define KCOM_VERSION 13 /* Protocol version */ @@ -367,6 +368,7 @@ typedef struct kcom_msg_version_s { #define KSYNC_M_HW_TS_DISABLE 3 #define KSYNC_M_MTP_TS_UPDATE_ENABLE 4 #define KSYNC_M_MTP_TS_UPDATE_DISABLE 5 +#define KSYNC_M_DNX_JR2DEVS_SYS_CONFIG 6 typedef struct kcom_clock_info_s { uint8 cmd; @@ -432,6 +434,7 @@ typedef struct kcom_msg_hw_init_s { uint32 udh_size; uint32 oamp_punted; uint8 no_skip_udh_check; + uint8 oam_dm_tod_exist; uint8 system_headers_mode; uint8 udh_enable; /* @@ -481,6 +484,18 @@ typedef struct kcom_msg_wb_cleanup_s { uint32 flags; } kcom_msg_wb_cleanup_t; +/* PCIE Link status */ +#define PCIE_LINK_STATUS_UP 0x0 +#define PCIE_LINK_STATUS_DOWN 0x1 + +/* + * Update PCIe link status. + */ +typedef struct kcom_msg_pcie_link_status_s { + kcom_msg_hdr_t hdr; + int pcie_link_status; +} kcom_msg_pcie_link_status_t; + /* * Create new system network interface. The network interface will * be associated with the specified switch unit number. @@ -606,6 +621,7 @@ typedef union kcom_msg_s { kcom_msg_dbg_pkt_get_t dbg_pkt_get; kcom_msg_wb_cleanup_t wb_cleanup; kcom_msg_clock_cmd_t clock_cmd; + kcom_msg_pcie_link_status_t pcie_link_status; } kcom_msg_t; /* diff --git a/platform/broadcom/saibcm-modules/include/soc/devids.h b/platform/broadcom/saibcm-modules/include/soc/devids.h index 8a67d385d930..edbdef32b285 100644 --- a/platform/broadcom/saibcm-modules/include/soc/devids.h +++ b/platform/broadcom/saibcm-modules/include/soc/devids.h @@ -25,7 +25,7 @@ * https://www.broadcom.com/products/ethernet-connectivity/software/opennsa */ /* - * Copyright: (c) 2021 Broadcom. + * Copyright: (c) 2022 Broadcom. * All Rights Reserved. */ @@ -1386,10 +1386,6 @@ #define BCM56768_A0_REV_ID 1 #define BCM56768_B0_REV_ID 0x11 -#define BCM56068_DEVICE_ID 0xb068 -#define BCM56068_A0_REV_ID 1 -#define BCM56068_B0_REV_ID 0x11 - #define BCM56068_DEVICE_ID 0xb068 #define BCM56068_A0_REV_ID 1 #define BCM56068_B0_REV_ID 0x11 @@ -1532,6 +1528,9 @@ #define BCM53549_DEVICE_ID 0x8549 #define BCM53549_A0_REV_ID 1 +#define BCM53642_DEVICE_ID 0x8642 +#define BCM53642_A0_REV_ID 1 + #define BCM5665_DEVICE_ID 0x5665 #define BCM5665_A0_REV_ID 1 #define BCM5665_B0_REV_ID 0x11 @@ -1549,8 +1548,6 @@ #define BROADCOM_PHYID_HIGH 0x0040 -#define GEDI_DEVICE_ID 0xa100 -#define GEDI_REV_ID 0x0001 #define ARAD_DEVICE_ID 0x8650 #define ARAD_A0_REV_ID 0x0000 #define ARAD_B0_REV_ID 0x0011 @@ -1580,6 +1577,7 @@ #define BCM88956_A1_REV_ID 0x0002 #define DNXC_A0_REV_ID 0x0001 #define DNXC_A1_REV_ID 0x0002 +#define DNXC_A2_REV_ID 0x0003 #define DNXC_B0_REV_ID 0x0011 #define DNXC_B1_REV_ID 0x0012 #define DNXC_DEVID_FAMILY_MASK 0xfff0 @@ -1601,6 +1599,42 @@ #define BCM8879D_DEVICE_ID 0x879D #define BCM8879E_DEVICE_ID 0x879E #define BCM8879F_DEVICE_ID 0x879F +#ifdef BCM_DNXF3_SUPPORT +#define BCM88910_DEVICE_ID 0x8910 +#define BCM88910_A0_REV_ID DNXC_A0_REV_ID +#define BCM88911_DEVICE_ID 0x8911 +#define BCM88912_DEVICE_ID 0x8912 +#define BCM88913_DEVICE_ID 0x8913 +#define BCM88914_DEVICE_ID 0x8914 +#define BCM88915_DEVICE_ID 0x8915 +#define BCM88916_DEVICE_ID 0x8916 +#define BCM88917_DEVICE_ID 0x8917 +#define BCM88918_DEVICE_ID 0x8918 +#define BCM88919_DEVICE_ID 0x8919 +#define BCM8891A_DEVICE_ID 0x891A +#define BCM8891B_DEVICE_ID 0x891B +#define BCM8891C_DEVICE_ID 0x891C +#define BCM8891D_DEVICE_ID 0x891D +#define BCM8891E_DEVICE_ID 0x891E +#define BCM8891F_DEVICE_ID 0x891F +#define BCM88920_DEVICE_ID 0x8920 +#define BCM88920_A0_REV_ID DNXC_A0_REV_ID +#define BCM88921_DEVICE_ID 0x8921 +#define BCM88922_DEVICE_ID 0x8922 +#define BCM88923_DEVICE_ID 0x8923 +#define BCM88924_DEVICE_ID 0x8924 +#define BCM88925_DEVICE_ID 0x8925 +#define BCM88926_DEVICE_ID 0x8926 +#define BCM88927_DEVICE_ID 0x8927 +#define BCM88928_DEVICE_ID 0x8928 +#define BCM88929_DEVICE_ID 0x8929 +#define BCM8892A_DEVICE_ID 0x892A +#define BCM8892B_DEVICE_ID 0x892B +#define BCM8892C_DEVICE_ID 0x892C +#define BCM8892D_DEVICE_ID 0x892D +#define BCM8892E_DEVICE_ID 0x892E +#define BCM8892F_DEVICE_ID 0x892F +#endif #define ARADPLUS_DEVICE_ID 0x8660 #define ARADPLUS_A0_REV_ID 0x0001 #define BCM88660_DEVICE_ID ARADPLUS_DEVICE_ID @@ -1806,9 +1840,11 @@ #define J2P_DEVICE_ID 0x8850 #define J2P_A0_REV_ID DNXC_A0_REV_ID #define J2P_A1_REV_ID DNXC_A1_REV_ID +#define J2P_A2_REV_ID DNXC_A2_REV_ID #define BCM88850_DEVICE_ID J2P_DEVICE_ID #define BCM88850_A0_REV_ID J2P_A0_REV_ID #define BCM88850_A1_REV_ID J2P_A1_REV_ID +#define BCM88850_A2_REV_ID J2P_A2_REV_ID #define BCM88851_DEVICE_ID 0x8851 #define BCM88852_DEVICE_ID 0x8852 #define BCM88853_DEVICE_ID 0x8853 @@ -1842,6 +1878,10 @@ #define BCM8884E_DEVICE_ID 0x884E #define BCM8884F_DEVICE_ID 0x884F +#define J2X_DEVICE_ID 0x8830 +#define J2X_A0_REV_ID DNXC_A0_REV_ID +#define BCM88830_DEVICE_ID J2X_DEVICE_ID +#define BCM88830_A0_REV_ID J2X_A0_REV_ID #define BCM88831_DEVICE_ID 0x8831 #define BCM88832_DEVICE_ID 0x8832 #define BCM88833_DEVICE_ID 0x8833 @@ -1858,6 +1898,16 @@ #define BCM8883E_DEVICE_ID 0x883E #define BCM8883F_DEVICE_ID 0x883F +#ifdef BCM_DNX3_SUPPORT +#define JERICHO3_DEVICE_ID 0x8860 +#define JERICHO3_A0_REV_ID DNXC_A0_REV_ID +#define BCM88860_DEVICE_ID JERICHO3_DEVICE_ID +#define BCM88860_A0_REV_ID JERICHO3_A0_REV_ID +#define Q4_DEVICE_ID 0x8870 +#define Q4_A0_REV_ID DNXC_A0_REV_ID +#define BCM88870_DEVICE_ID Q4_DEVICE_ID +#define BCM88870_A0_REV_ID Q4_A0_REV_ID +#endif #define Q2A_DEVICE_ID 0x8480 #define Q2A_A0_REV_ID DNXC_A0_REV_ID @@ -1996,15 +2046,11 @@ #define BCM88952_A0_REV_ID 0x0001 #define BCM88952_A1_REV_ID 0x0002 -#define PCP_PCI_VENDOR_ID 0x1172 -#define PCP_PCI_DEVICE_ID 0x4 - -#define ACP_PCI_VENDOR_ID 0x10ee -#define ACP_PCI_DEVICE_ID 0x7011 -#define ACP_PCI_REV_ID 0x0001 - #define PLX9056_DEVICE_ID 0x9056 +#define BCM56890_DEVICE_ID 0xb890 +#define BCM56890_A0_REV_ID 0x0001 + #define BCM56880_DEVICE_ID 0xb880 #define BCM56880_A0_REV_ID 0x0001 #define BCM56880_B0_REV_ID 0x0011 @@ -2044,9 +2090,8 @@ #define BCM56991_B0_REV_ID 0x0011 #define BCM56992_DEVICE_ID 0xb992 #define BCM56992_B0_REV_ID 0x0011 - -#define BCM56995_DEVICE_ID 0xb995 -#define BCM56995_A0_REV_ID 0x0001 +#define BCM56993_DEVICE_ID 0xb993 +#define BCM56993_B0_REV_ID 0x0011 #define BCM56996_DEVICE_ID 0xb996 #define BCM56996_A0_REV_ID 0x0001 @@ -2064,5 +2109,25 @@ #define BCM56998_DEVICE_ID 0xb998 #define BCM56998_A0_REV_ID 0x0001 -#endif +#define BCM56999_DEVICE_ID 0xb999 +#define BCM56999_A0_REV_ID 0x0001 +#define BCM56999_B0_REV_ID 0x0011 +#define BCM56995_DEVICE_ID 0xb995 +#define BCM56995_A0_REV_ID 0x0001 +#define BCM56995_B0_REV_ID 0x0011 + +#define BCM78900_DEVICE_ID 0xf900 +#define BCM78900_B0_REV_ID 0x0011 + +#define BCM56080_DEVICE_ID 0xb080 +#define BCM56080_A0_REV_ID 0x0001 +#define BCM56081_DEVICE_ID 0xb081 +#define BCM56081_A0_REV_ID 0x0001 +#define BCM56082_DEVICE_ID 0xb082 +#define BCM56082_A0_REV_ID 0x0001 +#define BCM56083_DEVICE_ID 0xb083 +#define BCM56083_A0_REV_ID 0x0001 +#define BCM56084_DEVICE_ID 0xb084 +#define BCM56084_A0_REV_ID 0x0001 +#endif diff --git a/platform/broadcom/saibcm-modules/make/Make.config b/platform/broadcom/saibcm-modules/make/Make.config index 01869634e295..9a881329e669 100644 --- a/platform/broadcom/saibcm-modules/make/Make.config +++ b/platform/broadcom/saibcm-modules/make/Make.config @@ -119,14 +119,12 @@ else # ifeq "$(HOSTTYPE)" "Windows2000PC" ifndef SDKBUILD SDKBUILD :=build endif - ifdef SDK_OUTDIR BLDROOT = ${SDK_OUTDIR}/${SDKBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${target}${all_suffix}${bldroot_suffix} export DEST_DIR := ${SDK_OUTDIR}/${SDKBUILD}$(if ${BLDCONFIG},/${BLDCONFIG})$(DEST_DIR_SUFFIX) else BLDROOT = ${SDK}/${SDKBUILD}/$(if ${BLDCONFIG},${BLDCONFIG}/)${target}${all_suffix}${bldroot_suffix} endif - endif # ifeq "$(HOSTTYPE)" "Windows2000PC" # This is needed because we cannot include Make.vxworks before Make.config diff --git a/platform/broadcom/saibcm-modules/make/Make.kernlib b/platform/broadcom/saibcm-modules/make/Make.kernlib index 94801acd4a69..56752beca3b6 100644 --- a/platform/broadcom/saibcm-modules/make/Make.kernlib +++ b/platform/broadcom/saibcm-modules/make/Make.kernlib @@ -36,17 +36,6 @@ targetlibsoname = ${lib}.so.${SHAREDLIBVER} targetlibrealname = ${targetlibsoname} targetlibso = ${LIBDIR}/${targetlibrealname} -ifeq ($(TOOLS),Borland) - -LIBSUFFIX=lib - -${LIBDIR}/%.lib: ${BORLAND_BOBJS} - $(RM) $@ - $(FOREACH) -subdir "$(LIBDIR)" \ - "tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))" - -else # !Borland - LIBSUFFIX=a ${LIBDIR}/%.a: ${BOBJS} @@ -60,7 +49,6 @@ ifeq ($(targetbase),unix) $(CC) -shared -Wl,-soname,${targetlibsoname} -o ${targetlibso} ${BOBJS} -lc endif endif # LINUX_MAKE_SHARED_LIB # -endif # !Borland targetlib = ${LIBDIR}/${lib}.${LIBSUFFIX} diff --git a/platform/broadcom/saibcm-modules/make/Make.lib b/platform/broadcom/saibcm-modules/make/Make.lib index ac81cc134f6d..a4f19aad9321 100644 --- a/platform/broadcom/saibcm-modules/make/Make.lib +++ b/platform/broadcom/saibcm-modules/make/Make.lib @@ -43,17 +43,6 @@ ifeq ($(FAST),1) endif endif -ifeq ($(TOOLS),Borland) - -LIBSUFFIX=lib - -${LIBDIR}/%.lib: ${BORLAND_BOBJS} - $(RM) $@ - $(FOREACH) -subdir "$(LIBDIR)" \ - "tlib $@ $(foreach obj, $(BORLAND_LOBJS), +-$(obj))" - -else # !Borland - ifeq ($(LINUX_MAKE_SHARED_LIB),1) LIBSUFFIX=so.${SHAREDLIBVER} else @@ -76,8 +65,6 @@ else $(AR) ${ARFLAGS} $@ $(sort ${BOBJS}) endif -endif # !Borland - install:: all @@ -89,3 +76,7 @@ endif $Q$(RM) ${targetlib} distclean:: clean + +ifeq ($(DNX_FAST_MODE),1) +-include $(SDK)/tools/dnx/make/lib.mk +endif diff --git a/platform/broadcom/saibcm-modules/make/Make.subdirs b/platform/broadcom/saibcm-modules/make/Make.subdirs index 374d817d212d..4016cb83202d 100644 --- a/platform/broadcom/saibcm-modules/make/Make.subdirs +++ b/platform/broadcom/saibcm-modules/make/Make.subdirs @@ -38,18 +38,18 @@ ifdef QUIET endif ${subdirs}:: - $Q$(MAKE) -C $@ kernel_version=$(kernel_version) LINUX_MAKE_SHARED_LIB=${LINUX_MAKE_SHARED_LIB} SHAREDLIBVER=${SHAREDLIBVER} + $Q$(MAKE) -C $@ kernel_version=$(kernel_version) LINUX_MAKE_SHARED_LIB=${LINUX_MAKE_SHARED_LIB} SHAREDLIBVER=${SHAREDLIBVER} ${CLEAN_SUBDIRS} -ifeq "$(HOSTTYPE)" "Windows2000PC" clean clean_d install distclean:: ifdef QUIET @$(ECHO) Subdirectory $@ for ${subdirs} endif - $Q$(FOREACH) "$(subdirs)" "${MAKE} -C ## $@" -else -clean clean_d install distclean:: -ifdef QUIET - @$(ECHO) Subdirectory $@ for ${subdirs} -endif - @(for name in $(subdirs); do $(MAKE) -C $$name $@; done) + $(MAKE) clean_subdirs CLEAN_SUBDIRS=$@ + +clean_subdirs: ${subdirs} + +.PHONY: clean_subdirs + +ifeq ($(DNX_FAST_MODE),1) +-include $(SDK)/tools/dnx/make/subdirs.mk endif diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-gts b/platform/broadcom/saibcm-modules/make/Makefile.linux-gts index 609b49c2094a..293feaf979d6 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-gts +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-gts @@ -45,7 +45,7 @@ #endif # some basic path variables for tools and kernel source, etc # -XLR_TOOLS_BASE = /projects/ntsw-tools/linux/xlr-54 +XLR_TOOLS_BASE ?= /projects/ntsw-tools/linux/xlr-510 TOOLCHAIN_DIR = $(XLR_TOOLS_BASE)/buildroot/host/usr KERNDIR = $(XLR_TOOLS_BASE)/kernel/linux # Target machine for EDK-Host defconfig @@ -112,6 +112,9 @@ ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f1 -d.` \== 10)" "1" CFLAGS += -Wno-error=uninitialized CFLAGS += -Wno-error=format-overflow CFLAGS += -fcommon +ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f2 -d.` \== 2)" "1" + CFLAGS += -Wno-zero-length-bounds +endif endif endif # Compiler-specific CFLAGS @@ -200,5 +203,3 @@ ifneq ($(targetplat),user) BCM_CFLAGS = -Wall include ${SDK}/make/Makefile.linux-kernel-2_6 endif - - diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 index bfb6cd48dda8..ac7915be93ee 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc_64 @@ -93,7 +93,6 @@ ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f1 -d.` \>= 9)" "1" CFLAGS += -Wno-address-of-packed-member endif ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f1 -d.` \== 10)" "1" - #There might be a bug in GCC10 that cannot detect initialization correctly. CFLAGS += -Wno-error=uninitialized CFLAGS += -Wno-error=format-overflow CFLAGS += -fcommon diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel index ccb0c30d2acc..34663445b8a3 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel @@ -112,12 +112,3 @@ endif ifdef DEBUG_PEDANTIC DEBUG_PEDANTIC = FALSE endif - -# -# DEPEND is used as a command to generate the list of dependencies. -# The format of the output must be -# "file.o : file.c a/b/c.h d/e/f.h ...", -# if it is on multiple lines, each line must end in a backslash. -# The output MUST be on standard out. -# -DEPEND = ${CC} -M $(CFLAGS) $< diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 index 431bf808f044..c0e8f084e9f0 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 @@ -153,12 +153,3 @@ endif ifdef DEBUG_PEDANTIC DEBUG_PEDANTIC = FALSE endif - -# -# DEPEND is used as a command to generate the list of dependencies. -# The format of the output must be -# "file.o : file.c a/b/c.h d/e/f.h ...", -# if it is on multiple lines, each line must end in a backslash. -# The output MUST be on standard out. -# -DEPEND = ${CC} -M $(CFLAGS) $< diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 index 528522ec4bd3..a454ea16bad8 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 @@ -148,12 +148,3 @@ endif ifdef DEBUG_PEDANTIC DEBUG_PEDANTIC = FALSE endif - -# -# DEPEND is used as a command to generate the list of dependencies. -# The format of the output must be -# "file.o : file.c a/b/c.h d/e/f.h ...", -# if it is on multiple lines, each line must end in a backslash. -# The output MUST be on standard out. -# -DEPEND = ${CC} -M $(CFLAGS) $< diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 index c02fc0edd89b..6fcb9a9d1590 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 @@ -156,13 +156,3 @@ endif ifdef DEBUG_PEDANTIC DEBUG_PEDANTIC = FALSE endif - -# -# DEPEND is used as a command to generate the list of dependencies. -# The format of the output must be -# "file.o : file.c a/b/c.h d/e/f.h ...", -# if it is on multiple lines, each line must end in a backslash. -# The output MUST be on standard out. -# -DEPEND = ${CC} -M $(CFLAGS) $< - diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule index 46caf00f20b5..d3a41f3824b0 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule @@ -41,22 +41,69 @@ MODULE := $(MOD_NAME).o KMODULE := $(MOD_NAME).ko -PRE_COMPILED_OBJ := obj_$(MOD_NAME).o - obj-m := $(MODULE) -$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ) +SAVE_CFLAGS := ${CFLAGS} -ifeq (,$(CROSS_COMPILE)) +ifeq (1,$(NO_PRECOMPILED_MODULE)) +# { +# +# When compiling the module within the kernel environment, we get plenty of warnings +# of pointer-to-int and the other way round. So, we need to silence them. +# Apart from that, we need a search path on the kernel's 'include' and the various +# SDK 'include' directories. +# It is not clear why they need to be repeated in EXTRA_CFLAGS (probably because +# of the compilation cycle which is done within the SDK environment). +# +ccflags-y := \ + -Wno-pointer-to-int-cast \ + -Wno-int-to-pointer-cast \ + -I$(KERNDIR)/include \ + -I$(SDK)/include \ + -I$(SDK)/systems/bde/linux/include \ + -I$(SDK)/systems/bde/shared/include \ + -I$(SDK)/systems/linux/kernel/modules/include +include $(SDK)/make/Make.config +# +# For compilation of all module files on linux environment, make sure +# all CFLAGS are passed to the module. This was not required when a +# 'precompiled' object was used since it automatically got all these flags. +# +ccflags-y += $(KFLAGS) +ccflags-y += $(CFLAGS) +# +# Reach here if this makefile is invoked +# from systems\bde\linux\kernel (module name: linux-kernel-bde.ko). +# from systems\bde\linux\user\kernel (module name: linux-user.ko) +# from systems/linux/kernel/modules/bcm-knet (module name: linux-bcm-knet) +# from systems/linux/kernel/modules/knet-cb (module name: linux-knet-cb) +$(MOD_NAME)-y := $(MOD_OBJS) +# +# If, for any reason, the definition of CROSS_COMPILE was erased, then +# set it, again. +# +ifeq ($(CROSS_COMPILE),) +CROSS_COMPILE = /tools/bin/ +endif +export CROSS_COMPILE +# } +else +# { +PRE_COMPILED_OBJ := obj_$(MOD_NAME).o +$(MOD_NAME)-y := $(MODULE_SYM) $(PRE_COMPILED_OBJ) +ifeq (,$(CROSS_COMPILE)) export CROSS_COMPILE - endif -SAVE_CFLAGS := ${CFLAGS} - include $(SDK)/make/Make.config +# } +endif +# +# Note that PWD will get two values, in the process of making the module, +# one for the current directory within 'build' and one for the 'base' of the kernel. +# PWD := $(shell pwd) ifneq ($(ARCH),) @@ -67,10 +114,10 @@ endif # Provide an option in case kernel was built in separate directory KERNBLDDIR ?= $(KERNDIR) - +# # Standard SDK include path for building source files that export # kernel symbols. - +# override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/include -I${SDK}/systems/bde/linux/include # # If, for any reason, the definition of LD was erased, then @@ -79,12 +126,27 @@ override EXTRA_CFLAGS = -I${SDK}/include -I${SDK}/systems/linux/kernel/modules/i ifeq ($(LD),) LD = $(CROSS_COMPILE)ld endif - +ifeq (1,$(NO_PRECOMPILED_MODULE)) +# { +$(KMODULE): + rm -f *.o *.ko .*.cmd *.sig *.P + rm -fr .tmp_versions + if [ ! -f $(KERNBLDDIR)/NO_SUPRESS ]; then echo "# suppress warning" > .$(PRE_COMPILED_OBJ).cmd; fi + # + # This make creates the module's object. It, somehow, runs two cycls, one in SDK environment + # and one in the kernel's directory. + # + $(MAKE) -C $(KERNBLDDIR) CROSS_COMPILE=$(CROSS_COMPILE) LD=$(LD) M=$(PWD) modules + if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi + cp -f $(KMODULE) $(LIBDIR) +# } +else +# { # The precopiled object needs a dummy command file to avoid warnings # from the Kbuild scripts (modpost stage). # Kernels before 2.6.17 do not support external module symbols files, # so we create a dummy to prevent build failures. - +# $(KMODULE): rm -f *.o *.ko .*.cmd rm -fr .tmp_versions @@ -94,6 +156,8 @@ $(KMODULE): if [ ! -f Module.symvers ]; then echo "old kernel (pre-2.6.17)" > Module.symvers; fi cp -f $(KMODULE) $(LIBDIR) rm -f $(PRE_COMPILED_OBJ)_shipped +# } +endif EXTRA_CFLAGS = $(CFLAGS) CFLAGS := ${SAVE_CFLAGS} diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr b/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr index 609b49c2094a..293feaf979d6 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-xlr @@ -45,7 +45,7 @@ #endif # some basic path variables for tools and kernel source, etc # -XLR_TOOLS_BASE = /projects/ntsw-tools/linux/xlr-54 +XLR_TOOLS_BASE ?= /projects/ntsw-tools/linux/xlr-510 TOOLCHAIN_DIR = $(XLR_TOOLS_BASE)/buildroot/host/usr KERNDIR = $(XLR_TOOLS_BASE)/kernel/linux # Target machine for EDK-Host defconfig @@ -112,6 +112,9 @@ ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f1 -d.` \== 10)" "1" CFLAGS += -Wno-error=uninitialized CFLAGS += -Wno-error=format-overflow CFLAGS += -fcommon +ifeq "$(shell expr `echo $(CROSS_GCC_VER) | cut -f2 -d.` \== 2)" "1" + CFLAGS += -Wno-zero-length-bounds +endif endif endif # Compiler-specific CFLAGS @@ -200,5 +203,3 @@ ifneq ($(targetplat),user) BCM_CFLAGS = -Wall include ${SDK}/make/Makefile.linux-kernel-2_6 endif - - diff --git a/platform/broadcom/saibcm-modules/sdklt/Makefile b/platform/broadcom/saibcm-modules/sdklt/Makefile index 1ce04c788a32..e0084d260925 100644 --- a/platform/broadcom/saibcm-modules/sdklt/Makefile +++ b/platform/broadcom/saibcm-modules/sdklt/Makefile @@ -1,5 +1,5 @@ # -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -14,6 +14,8 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # +# Makefile for building Linux GPL kernel modules for SDKLT. +# help: @echo '' @@ -26,6 +28,7 @@ help: @echo 'Supported make variables:' @echo 'KDIR - Linux kernel source directory (mandatory)' @echo 'CROSS_COPILE - Cross-compiler prefix (optional)' + @echo 'OUTPUT_DIR - Output directory (build/ by default)' @echo '' @echo 'Examples:' @echo 'make -s KDIR=$$KERNEL/linux kmod' @@ -44,27 +47,42 @@ export CROSS_COMPILE override SDK := $(CURDIR) +ifeq (,$(OUTPUT_DIR)) +OUTPUT_DIR := $(CURDIR)/build +endif + +BDE_BLDDIR := $(OUTPUT_DIR)/bde +KNET_BLDDIR := $(OUTPUT_DIR)/knet +KNETCB_BLDDIR := $(OUTPUT_DIR)/knetcb + +LKM_CFLAGS += -UNGKNET_NETIF_MAX -DNGKNET_NETIF_MAX=1056 -UNGKNET_FILTER_MAX -DNGKNET_FILTER_MAX=1025 +export LKM_CFLAGS + kmod: bde knet knetcb bde: $(MAKE) -C $(SDK)/linux/bde SDK=$(SDK) \ - $(TARGET) - ln -sf $(SDK)/linux/bde/*.ko + LKM_BLDDIR=$(BDE_BLDDIR) $(TARGET) + ln -sf $(BDE_BLDDIR)/*.ko $(OUTPUT_DIR) knet: bde $(MAKE) -C $(SDK)/linux/knet SDK=$(SDK) \ - KBUILD_EXTRA_SYMBOLS=$(SDK)/linux/bde/Module.symvers \ - $(TARGET) - ln -sf $(SDK)/linux/knet/*.ko + KBUILD_EXTRA_SYMBOLS=$(BDE_BLDDIR)/Module.symvers \ + LKM_BLDDIR=$(KNET_BLDDIR) $(TARGET) + ln -sf $(KNET_BLDDIR)/*.ko $(OUTPUT_DIR) knetcb: knet $(MAKE) -C $(SDK)/linux/knetcb SDK=$(SDK) \ - KBUILD_EXTRA_SYMBOLS=$(SDK)/linux/knet/Module.symvers \ - $(TARGET) - ln -sf $(SDK)/linux/knetcb/*.ko + KBUILD_EXTRA_SYMBOLS=$(KNET_BLDDIR)/Module.symvers \ + KBUILD_EXTRA_SYMBOLS+=$(PSAMPLE_SYMVERS) \ + LKM_BLDDIR=$(KNETCB_BLDDIR) $(TARGET) + ln -sf $(KNETCB_BLDDIR)/*.ko $(OUTPUT_DIR) clean: $(MAKE) kmod TARGET=clean - rm -f *.ko + rm -f $(OUTPUT_DIR)/*.ko + +distclean: + rm -rf $(OUTPUT_DIR) -.PHONY: help kmod bde knet knetcb $(PSAMPLE) clean +.PHONY: help kmod bde knet knetcb clean distclean diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56995_a0/bcm56995_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56080_a0/bcm56080_a0_pdma_attach.c similarity index 81% rename from platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56995_a0/bcm56995_a0_pdma_attach.c rename to platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56080_a0/bcm56080_a0_pdma_attach.c index 08419f1d3a1e..7b71dd745ca6 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56995_a0/bcm56995_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56080_a0/bcm56080_a0_pdma_attach.c @@ -1,10 +1,10 @@ -/*! \file bcm56995_a0_pdma_attach.c +/*! \file bcm56080_a0_pdma_attach.c * * Initialize PDMA driver resources. * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -25,13 +25,13 @@ #include int -bcm56995_a0_cnet_pdma_attach(struct pdma_dev *dev) +bcm56080_a0_cnet_pdma_attach(struct pdma_dev *dev) { return bcmcnet_cmicx_pdma_driver_attach(dev); } int -bcm56995_a0_cnet_pdma_detach(struct pdma_dev *dev) +bcm56080_a0_cnet_pdma_detach(struct pdma_dev *dev) { return bcmcnet_cmicx_pdma_driver_detach(dev); } diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c index dfdb504d87c6..4edd614c2a07 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56780_a0/bcm56780_a0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c index 9dc9195cc209..d803f27827a2 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56880_a0/bcm56880_a0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56890_a0/bcm56890_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56890_a0/bcm56890_a0_pdma_attach.c new file mode 100644 index 000000000000..f5297b1bcfcc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56890_a0/bcm56890_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56890_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56890_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56890_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c index 2e02369c958b..4e7626a2b414 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_a0/bcm56990_a0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c index 1acf4b41bffd..95b1b3adb601 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56990_b0/bcm56990_b0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c index 2fca51ce9788..1ec4e3a9f414 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_a0/bcm56996_a0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_b0/bcm56996_b0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_b0/bcm56996_b0_pdma_attach.c index 06e22a8a28a0..c881a7a37266 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_b0/bcm56996_b0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56996_b0/bcm56996_b0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56998_a0/bcm56998_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56998_a0/bcm56998_a0_pdma_attach.c index 1c5e0b2846a5..47b83a495538 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56998_a0/bcm56998_a0_pdma_attach.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56998_a0/bcm56998_a0_pdma_attach.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56999_a0/bcm56999_a0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56999_a0/bcm56999_a0_pdma_attach.c new file mode 100644 index 000000000000..2aee042564f3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm56999_a0/bcm56999_a0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm56999_a0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm56999_a0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_attach(dev); +} + +int +bcm56999_a0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicx_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm78900_b0/bcm78900_b0_pdma_attach.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm78900_b0/bcm78900_b0_pdma_attach.c new file mode 100644 index 000000000000..e09f04d9b44f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/chip/bcm78900_b0/bcm78900_b0_pdma_attach.c @@ -0,0 +1,38 @@ +/*! \file bcm78900_b0_pdma_attach.c + * + * Initialize PDMA driver resources. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include + +int +bcm78900_b0_cnet_pdma_attach(struct pdma_dev *dev) +{ + return bcmcnet_cmicr_pdma_driver_attach(dev); +} + +int +bcm78900_b0_cnet_pdma_detach(struct pdma_dev *dev) +{ + return bcmcnet_cmicr_pdma_driver_detach(dev); +} + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c index e1eac2488497..b887a2b829a7 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_hw.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -59,7 +59,13 @@ cmicd_pdma_intr_enable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) { uint32_t reg = CMICD_IRQ_STAT(cmc); - hw->dev->intr_unmask(hw->dev, cmc, chan, reg, mask); + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_unmask(hw->dev, cmc, chan, 0, 0); + return; + } + + hw->dev->ctrl.grp[cmc].irq_mask |= mask; + hw->dev->intr_unmask(hw->dev, cmc, chan, reg, 0); } /*! @@ -70,7 +76,13 @@ cmicd_pdma_intr_disable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) { uint32_t reg = CMICD_IRQ_STAT(cmc); - hw->dev->intr_mask(hw->dev, cmc, chan, reg, mask); + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_mask(hw->dev, cmc, chan, 0, 0); + return; + } + + hw->dev->ctrl.grp[cmc].irq_mask &= ~mask; + hw->dev->intr_mask(hw->dev, cmc, chan, reg, 0); } /*! @@ -449,61 +461,61 @@ cmicd_pdma_chan_reg_dump(struct pdma_hw *hw, int chan) que = chan % CMICD_PDMA_CMC_CHAN; hw->hdls.reg_rd32(hw, CMICD_PDMA_CTRL(grp, que), &val); - CNET_PR("CMIC_CMC%d_CH%d_DMA_CTRL: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_CH%d_DMA_CTRL: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_DESC(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_DESC%d: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_DESC%d: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_CURR_DESC(grp, que), &val); - CNET_PR("CMIC_CMC%d_CH%d_DMA_CURR_DESC: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_CH%d_DMA_CURR_DESC: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_DESC_HALT(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_RX0(grp, que), &val); - CNET_PR("CMIC_CMC%d_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_RX1(grp, que), &val); - CNET_PR("CMIC_CMC%d_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_MASK0(grp), &val); - CNET_PR("CMIC_CMC%d_PROGRAMMABLE_COS_MASK0: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_PROGRAMMABLE_COS_MASK0: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COS_MASK1(grp), &val); - CNET_PR("CMIC_CMC%d_PROGRAMMABLE_COS_MASK1: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_PROGRAMMABLE_COS_MASK1: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_INTR_COAL(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_RBUF_THRE(grp, que), &val); - CNET_PR("CMIC_CMC%d_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT(grp), &val); - CNET_PR("CMIC_CMC%d_DMA_STAT: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_STAT: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT_HI(grp), &val); - CNET_PR("CMIC_CMC%d_DMA_STAT_HI: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_STAT_HI: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_STAT_CLR(grp), &val); - CNET_PR("CMIC_CMC%d_DMA_STAT_CLR: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_STAT_CLR: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COUNT_RX(grp, que), &val); - CNET_PR("CMIC_CMC%d_PKT_COUNT_CH%d_RXPKT: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_PKT_COUNT_CH%d_RXPKT: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_PDMA_COUNT_TX(grp, que), &val); - CNET_PR("CMIC_CMC%d_PKT_COUNT_CH%d_TXPKT: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_PKT_COUNT_CH%d_TXPKT: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICD_IRQ_STAT(grp), &val); - CNET_PR("CMIC_CMC%d_IRQ_STAT0: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_IRQ_STAT0: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_IRQ_PCI_MASK(grp), &val); - CNET_PR("CMIC_CMC%d_PCIE_IRQ_MASK0: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_PCIE_IRQ_MASK0: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICD_DEV_REV_ID, &val); - CNET_PR("CMIC_DEV_REV_ID: 0x%08x\n", val); + CNET_INFO(hw->unit, "CMIC_DEV_REV_ID: 0x%08x\n", val); hw->hdls.reg_rd32(hw, CMICD_CMICM_REV_ID, &val); - CNET_PR("CMIC_CMICM_REV_ID: 0x%08x\n", val); + CNET_INFO(hw->unit, "CMIC_CMICM_REV_ID: 0x%08x\n", val); return SHR_E_NONE; } diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c index 711a037510dc..e78e3ae26668 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicd/bcmcnet_cmicd_pdma_rxtx.c @@ -38,7 +38,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -70,6 +70,8 @@ cmicd_rx_desc_config(struct cmicd_rx_desc *rd, uint32_t addr, uint32_t len) rd->md.status = 0; rd->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | CMICD_DESC_CTRL_LEN(len); + + MEMORY_BARRIER; } /*! @@ -82,6 +84,8 @@ cmicd_tx_desc_config(struct cmicd_tx_desc *td, uint32_t addr, uint32_t len, uint td->md.status = 0; td->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | CMICD_DESC_CTRL_FLAGS(flags) | CMICD_DESC_CTRL_LEN(len); + + MEMORY_BARRIER; } /*! @@ -94,6 +98,8 @@ cmicd_rx_rldesc_config(struct cmicd_rx_desc *rd, uint32_t addr) rd->md.status = 0; rd->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | CMICD_DESC_CTRL_RELOAD; + + MEMORY_BARRIER; } /*! @@ -106,6 +112,8 @@ cmicd_tx_rldesc_config(struct cmicd_tx_desc *td, uint32_t addr) td->md.status = 0; td->ctrl = CMICD_DESC_CTRL_CNTLD_INTR | CMICD_DESC_CTRL_CHAIN | CMICD_DESC_CTRL_RELOAD; + + MEMORY_BARRIER; } /*! @@ -119,6 +127,8 @@ cmicd_rx_desc_chain(struct cmicd_rx_desc *rd, int chain) } else { rd->ctrl &= ~CMICD_DESC_CTRL_CHAIN; } + + MEMORY_BARRIER; } /*! @@ -132,6 +142,8 @@ cmicd_tx_desc_chain(struct cmicd_tx_desc *td, int chain) } else { td->ctrl &= ~CMICD_DESC_CTRL_CHAIN; } + + MEMORY_BARRIER; } /*! @@ -141,9 +153,7 @@ static inline int cmicd_pdma_rx_ring_unused(struct pdma_rx_queue *rxq) { /* Leave one descriptor unused so as not to halt */ - return rxq->curr > rxq->halt ? - rxq->curr - rxq->halt - 1 : - rxq->nb_desc + rxq->curr - rxq->halt - 1; + return (rxq->nb_desc + rxq->curr - rxq->halt - 1) % rxq->nb_desc; } /*! @@ -153,9 +163,7 @@ static inline int cmicd_pdma_tx_ring_unused(struct pdma_tx_queue *txq) { /* Leave one descriptor unused so as not to halt */ - return txq->dirt > txq->curr ? - txq->dirt - txq->curr - 1 : - txq->nb_desc + txq->dirt - txq->curr - 1; + return (txq->nb_desc + txq->dirt - txq->curr - 1) % txq->nb_desc; } /*! @@ -191,9 +199,9 @@ cmicd_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicd_rx_rldesc_config(&ring[di], rxq->ring_addr); rxq->curr = 0; - rxq->halt = rxq->state & PDMA_RX_BATCH_REFILL ? 0 : rxq->nb_desc; + rxq->halt = rxq->nb_desc - 1; - rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * di; + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * rxq->halt; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); hw->hdls.chan_setup(hw, rxq->chan_id, rxq->ring_addr); @@ -207,7 +215,7 @@ cmicd_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicd_rx_desc_config(&ring[di], 0, 0); } - CNET_PR("RX: Failed to allocate mem\n"); + CNET_ERROR(hw->unit, "RX: Failed to allocate memory\n"); return SHR_E_MEMORY; } @@ -354,26 +362,22 @@ cmicd_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) int unused = cmicd_pdma_rx_ring_unused(rxq); dma_addr_t addr; uint32_t halt; - int retry; int rv; for (halt = rxq->halt; halt < rxq->halt + unused; halt++) { + if (ring[halt % rxq->nb_desc].addr) { + continue; + } pbuf = &rxq->pbuf[halt % rxq->nb_desc]; /* Allocate a new pktbuf */ if (!bm->rx_buf_avail(dev, rxq, pbuf)) { - retry = 5000000; - do { - rv = bm->rx_buf_alloc(dev, rxq, pbuf); - if (SHR_SUCCESS(rv)) { - break; - } + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { rxq->stats.nomems++; - sal_usleep(1); - } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Rx buffer has not been allocated for 5 seconds\n"); rxq->halt = halt % rxq->nb_desc; - return rv; + CNET_ERROR(hw->unit, "Can not alloc RX buffer, %d DCBs not filled\n", + cmicd_pdma_rx_ring_unused(rxq)); + break; } } /* Setup the new descriptor */ @@ -383,10 +387,11 @@ cmicd_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicd_rx_desc_chain(&ring[halt % rxq->nb_desc], 0); } } + rxq->halt = halt % rxq->nb_desc; + /* Move forward */ sal_spinlock_lock(rxq->lock); - rxq->halt = halt % rxq->nb_desc; - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { /* Descriptor cherry pick */ rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * rxq->halt; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); @@ -422,28 +427,33 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg curr = rxq->curr; while (CMICD_DESC_STAT_DONE(ring[curr].md.status)) { - if (dev->mode == DEV_MODE_VNET && rxq->state & PDMA_RX_QUEUE_XOFF) { - break; - } - if (!(rxq->state & PDMA_RX_BATCH_REFILL) && - !(rxq->state & PDMA_RX_QUEUE_XOFF)) { - /* Descriptor cherry pick */ - rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * curr; - hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); - rxq->halt = curr; - } if (done == budget) { break; } + /* Move forward */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + sal_spinlock_unlock(rxq->lock); + } + /* Get the current pktbuf to process */ pbuf = &rxq->pbuf[curr]; stat = ring[curr].md.status; len = CMICD_DESC_STAT_LEN(stat); pkh = bm->rx_buf_get(dev, rxq, pbuf, len); if (!pkh) { + CNET_ERROR(hw->unit, "RX buffer build failed, retry ...\n"); rxq->stats.nomems++; - return SHR_E_MEMORY; + /* Set busy state to retry */ + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; } /* Setup packet header */ @@ -489,24 +499,33 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Setup the new descriptor */ if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { if (!bm->rx_buf_avail(dev, rxq, pbuf)) { - retry = 5000000; - do { + retry = 0; + while (1) { rv = bm->rx_buf_alloc(dev, rxq, pbuf); if (SHR_SUCCESS(rv)) { break; } rxq->stats.nomems++; - sal_usleep(1); - } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Rx buffer has not been allocated for 5 seconds\n"); - return done; + if (dev->mode == DEV_MODE_UNET || dev->mode == DEV_MODE_VNET) { + if (retry++ < 5000000) { + sal_usleep(1); + continue; + } + CNET_ERROR(hw->unit, "Fatal error: can not alloc RX buffer\n"); + } + rxq->state |= PDMA_RX_BATCH_REFILL; + rxq->free_thresh = 1; + cmicd_rx_desc_config(&ring[curr], 0, 0); + CNET_ERROR(hw->unit, "RX buffer alloc failed, try batch refilling later\n"); + break; } } - bm->rx_buf_dma(dev, rxq, pbuf, &addr); - cmicd_rx_desc_config(&ring[curr], addr, rxq->buf_size); - if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { - cmicd_rx_desc_chain(&ring[curr], 0); + if (pbuf->dma) { + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicd_rx_desc_config(&ring[curr], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { + cmicd_rx_desc_chain(&ring[curr], 0); + } } } else { cmicd_rx_desc_config(&ring[curr], 0, 0); @@ -514,7 +533,6 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Notify HNET to process if needed */ if (dev->mode == DEV_MODE_VNET) { - MEMORY_BARRIER; if (ring[(curr + rxq->nb_desc - 1) % rxq->nb_desc].md.status) { dev->xnet_wake(dev); } @@ -523,7 +541,7 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Update the indicators */ if (!(rxq->state & PDMA_RX_BATCH_REFILL) && rxq->halt != curr) { sal_spinlock_lock(rxq->lock); - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { /* Descriptor cherry pick */ rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicd_rx_desc) * curr; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); @@ -539,10 +557,12 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Restart DMA if in chain mode */ if (dev->flags & PDMA_CHAIN_MODE) { - if (curr == 0 && !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + sal_spinlock_lock(rxq->lock); + if (curr == 0 && !(rxq->status & PDMA_RX_QUEUE_XOFF)) { hw->hdls.chan_stop(hw, rxq->chan_id); hw->hdls.chan_start(hw, rxq->chan_id); } + sal_spinlock_unlock(rxq->lock); } } @@ -557,12 +577,10 @@ cmicd_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg if (rxq->state & PDMA_RX_BATCH_REFILL && cmicd_pdma_rx_ring_unused(rxq) >= (int)rxq->free_thresh) { cmicd_pdma_rx_ring_refill(hw, rxq); - } - - /* Notify the other side to process */ - if (dev->mode == DEV_MODE_VNET || dev->mode == DEV_MODE_HNET) { - if (done) { - dev->xnet_wake(dev); + /* If no one filled, return budget and keep polling */ + if (cmicd_pdma_rx_ring_unused(rxq) == (int)(rxq->nb_desc - 1)) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; } } @@ -669,16 +687,24 @@ cmicd_pdma_tx_ring_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budg sal_spinlock_unlock(txq->lock); } + /* Set busy state to avoid HW checking */ + if (done == budget) { + txq->state |= PDMA_TX_QUEUE_BUSY; + } + /* Resume Tx if any */ sal_spinlock_lock(txq->lock); - if (txq->state & PDMA_TX_QUEUE_XOFF && - txq->state & PDMA_TX_QUEUE_ACTIVE && - cmicd_pdma_tx_ring_unused(txq)) { - txq->state &= ~PDMA_TX_QUEUE_XOFF; - sal_spinlock_unlock(txq->lock); + if (txq->status & PDMA_TX_QUEUE_XOFF && cmicd_pdma_tx_ring_unused(txq)) { + txq->status &= ~PDMA_TX_QUEUE_XOFF; + if (dev->suspended) { + sal_spinlock_unlock(txq->lock); + return done; + } if (dev->tx_resume) { dev->tx_resume(dev, txq->queue_id); - } else if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + } + sal_spinlock_unlock(txq->lock); + if (!dev->tx_resume && !(txq->state & PDMA_TX_QUEUE_POLL)) { sal_sem_give(txq->sem); } return done; @@ -698,14 +724,14 @@ cmicd_pdma_rx_ring_dump(struct pdma_hw *hw, struct pdma_rx_queue *rxq) struct cmicd_rx_desc *rd; uint32_t di; - CNET_PR("\nRX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", - rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); - CNET_PR("----------------------------------------------------------------\n"); + CNET_INFO(hw->unit, "RX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", + rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); for (di = 0; di < rxq->nb_desc + 1; di++) { rd = &ring[di]; - CNET_PR("DESC[%03d]: (%p)->%08x %08x ... %08x\n", - di, (void *)(unsigned long)(rxq->ring_addr + di * CMICD_PDMA_DCB_SIZE), - rd->addr, rd->ctrl, rd->md.status); + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x ... %08x\n", + di, (void *)(unsigned long)(rxq->ring_addr + di * CMICD_PDMA_DCB_SIZE), + rd->addr, rd->ctrl, rd->md.status); } return SHR_E_NONE; @@ -721,14 +747,14 @@ cmicd_pdma_tx_ring_dump(struct pdma_hw *hw, struct pdma_tx_queue *txq) struct cmicd_tx_desc *td; uint32_t di; - CNET_PR("\nTX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", - txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); - CNET_PR("----------------------------------------------------------------\n"); + CNET_INFO(hw->unit, "TX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", + txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); for (di = 0; di < txq->nb_desc + 1; di++) { td = &ring[di]; - CNET_PR("DESC[%03d]: (%p)->%08x %08x ... %08x\n", - di, (void *)(unsigned long)(txq->ring_addr + di * CMICD_PDMA_DCB_SIZE), - td->addr, td->ctrl, td->md.status); + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x ... %08x\n", + di, (void *)(unsigned long)(txq->ring_addr + di * CMICD_PDMA_DCB_SIZE), + td->addr, td->ctrl, td->md.status); } return SHR_E_NONE; @@ -771,18 +797,31 @@ cmicd_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, static inline int cmicd_pdma_tx_ring_check(struct pdma_hw *hw, struct pdma_tx_queue *txq) { + struct pdma_dev *dev = hw->dev; + + if (dev->suspended) { + txq->stats.xoffs++; + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); + return SHR_E_BUSY; + } + if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + return SHR_E_BUSY; + } + } + if (cmicd_pdma_tx_ring_unused(txq)) { return SHR_E_NONE; } sal_spinlock_lock(txq->lock); if (!cmicd_pdma_tx_ring_unused(txq)) { - txq->state |= PDMA_TX_QUEUE_XOFF; + txq->status |= PDMA_TX_QUEUE_XOFF; txq->stats.xoffs++; - sal_spinlock_unlock(txq->lock); - if (hw->dev->tx_suspend) { - hw->dev->tx_suspend(hw->dev, txq->queue_id); + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); } + sal_spinlock_unlock(txq->lock); return SHR_E_BUSY; } sal_spinlock_unlock(txq->lock); @@ -818,7 +857,7 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } else { rv = sal_sem_take(txq->sem, BCMCNET_TX_RSRC_WAIT_USEC); if (rv == -1) { - CNET_PR("Timeout waiting for Tx resources\n"); + CNET_ERROR(hw->unit, "Timeout waiting for Tx resources\n"); return SHR_E_TIMEOUT; } } @@ -833,7 +872,7 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } } else { /* Abort Tx if a fatal error happened */ - if (txq->state & PDMA_TX_QUEUE_XOFF) { + if (txq->status & PDMA_TX_QUEUE_XOFF) { sal_sem_give(txq->sem); return SHR_E_RESOURCE; } @@ -848,6 +887,7 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) sal_spinlock_unlock(txq->mutex); return SHR_E_EMPTY; } + txq->state |= PDMA_TX_QUEUE_BUSY; } else { pbuf->adj = 0; pkh = bm->tx_buf_get(dev, txq, pbuf, buf); @@ -858,7 +898,7 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } else { sal_sem_give(txq->sem); } - return SHR_E_NONE; + return SHR_E_RESOURCE; } bm->tx_buf_dma(dev, txq, pbuf, &addr); flags |= pkh->attrs & PDMA_TX_HIGIG_PKT ? CMICD_DESC_TX_HIGIG_PKT : 0; @@ -872,7 +912,6 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) /* Notify HNET to process if needed */ if (dev->mode == DEV_MODE_VNET) { - MEMORY_BARRIER; if (!CMICD_DESC_CTRL_LEN(ring[(curr + txq->nb_desc - 1) % txq->nb_desc].ctrl)) { dev->xnet_wake(dev); } @@ -892,8 +931,8 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } sal_usleep(1); } while (retry--); - if (retry <= 0) { - CNET_PR("Last Tx could not be done in given time\n"); + if (retry < 0) { + CNET_ERROR(hw->unit, "Last Tx could not get done in given time\n"); } } sal_spinlock_lock(txq->lock); @@ -919,7 +958,7 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) /* Clean up ring if in polling mode */ if (txq->state & PDMA_TX_QUEUE_POLL && cmicd_pdma_tx_ring_unused(txq) <= (int)txq->free_thresh) { - cmicd_pdma_tx_ring_clean(hw, txq, txq->nb_desc - txq->free_thresh); + cmicd_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); } /* Suspend Tx if no resource */ @@ -932,15 +971,15 @@ cmicd_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) if (txq->state & PDMA_TX_QUEUE_POLL) { /* In polling mode, must wait till the ring is available */ do { - cmicd_pdma_tx_ring_clean(hw, txq, txq->free_thresh); - if (!(txq->state & PDMA_TX_QUEUE_XOFF) || + cmicd_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); + if (!(txq->status & PDMA_TX_QUEUE_XOFF) || !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { break; } sal_usleep(1); } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Tx ring is full, packets have not been transmitted for 5 seconds\n"); + if (retry < 0) { + CNET_ERROR(hw->unit, "Fatal error: Tx ring is full, packets can not been transmitted\n"); if (!dev->tx_suspend) { sal_sem_give(txq->sem); return SHR_E_RESOURCE; @@ -970,7 +1009,7 @@ static int cmicd_pdma_rx_suspend(struct pdma_hw *hw, struct pdma_rx_queue *rxq) { sal_spinlock_lock(rxq->lock); - rxq->state |= PDMA_RX_QUEUE_XOFF; + rxq->status |= PDMA_RX_QUEUE_XOFF; if (hw->dev->flags & PDMA_CHAIN_MODE) { hw->hdls.chan_stop(hw, rxq->chan_id); } @@ -986,7 +1025,7 @@ static int cmicd_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) { sal_spinlock_lock(rxq->lock); - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { sal_spinlock_unlock(rxq->lock); return SHR_E_NONE; } @@ -1002,7 +1041,7 @@ cmicd_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) rxq->curr = 0; hw->hdls.chan_start(hw, rxq->chan_id); } - rxq->state &= ~PDMA_RX_QUEUE_XOFF; + rxq->status &= ~PDMA_RX_QUEUE_XOFF; sal_spinlock_unlock(rxq->lock); return SHR_E_NONE; diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_hw.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_hw.c new file mode 100644 index 000000000000..99f1d7276cfc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_hw.c @@ -0,0 +1,667 @@ +/*! \file bcmcnet_cmicr_pdma_hw.c + * + * Utility routines for handling BCMCNET hardware (CMICr). + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include + +/*! + * Read 32-bit register + */ +static inline void +cmicr_pdma_reg_read32(struct pdma_hw *hw, uint32_t addr, uint32_t *data) +{ + if (hw->dev->dev_read32) { + hw->dev->dev_read32(hw->dev, addr, data); + } else { + DEV_READ32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Write 32-bit register + */ +static inline void +cmicr_pdma_reg_write32(struct pdma_hw *hw, uint32_t addr, uint32_t data) +{ + if (hw->dev->dev_write32) { + hw->dev->dev_write32(hw->dev, addr, data); + } else { + DEV_WRITE32(&hw->dev->ctrl, addr, data); + } +} + +/*! + * Enable interrupt for a channel + */ +static inline void +cmicr_pdma_intr_enable(struct pdma_hw *hw, int cmc, int chan) +{ + uint32_t reg, val; + + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_unmask(hw->dev, cmc, chan, 0, 0); + return; + } + + if ((cmc == 0) || (cmc == 1 && chan < 8)) { + reg = PAXB_PDMA_IRQ_ENAB_SET0; + } else { + reg = PAXB_PDMA_IRQ_ENAB_SET1; + } + + val = 1 << chan; + if (cmc == 0) { + val <<= CMICR_IRQ_MASK_SHIFT; + } else if (cmc == 1 && chan < 8) { + val <<= CMICR_IRQ_MASK_SHIFT + CMICR_PDMA_CMC_CHAN; + } else { + val >>= CMICR_IRQ_MASK_SHIFT; + } + + hw->dev->intr_unmask(hw->dev, cmc, chan, reg & 0xfff, val); +} + +/*! + * Disable interrupt for a channel + */ +static inline void +cmicr_pdma_intr_disable(struct pdma_hw *hw, int cmc, int chan) +{ + uint32_t reg, val; + + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_mask(hw->dev, cmc, chan, 0, 0); + return; + } + + if ((cmc == 0) || (cmc == 1 && chan < 8)) { + reg = PAXB_PDMA_IRQ_ENAB_CLR0; + } else { + reg = PAXB_PDMA_IRQ_ENAB_CLR1; + } + + val = 1 << chan; + if (cmc == 0) { + val <<= CMICR_IRQ_MASK_SHIFT; + } else if (cmc == 1 && chan < 8) { + val <<= CMICR_IRQ_MASK_SHIFT + CMICR_PDMA_CMC_CHAN; + } else { + val >>= CMICR_IRQ_MASK_SHIFT; + } + + hw->dev->intr_mask(hw->dev, cmc, chan, reg & 0xfff, val); +} + +/*! + * Initialize HW + */ +static int +cmicr_pdma_hw_init(struct pdma_hw *hw) +{ + dev_mode_t mode = DEV_MODE_MAX; + CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_t val_header_size; + + /* Temporarily upgrade work mode to get HW information in VNET mode. */ + if (hw->dev->mode == DEV_MODE_VNET) { + mode = DEV_MODE_VNET; + hw->dev->mode = DEV_MODE_UNET; + } + + hw->info.name = CMICR_DEV_NAME; + hw->info.dev_id = hw->dev->dev_id; + hw->info.num_cmcs = CMICR_PDMA_CMC_MAX; + hw->info.cmc_chans = CMICR_PDMA_CMC_CHAN; + hw->info.num_chans = CMICR_PDMA_CMC_MAX * CMICR_PDMA_CMC_CHAN; + hw->info.rx_dcb_size = CMICR_PDMA_DCB_SIZE; + hw->info.tx_dcb_size = CMICR_PDMA_DCB_SIZE; + hw->hdls.reg_rd32(hw, CMICR_EP_TO_CPU_HEADER_SIZE, + &CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_GET(val_header_size)); + hw->info.rx_ph_size = CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_EP_TO_CPU_HEADER_SIZEf_GET(val_header_size) * 8; + hw->info.tx_ph_size = CMICR_TX_PKT_HDR_SIZE; + + /* Restore work mode to VNET. */ + if (mode == DEV_MODE_VNET) { + hw->dev->mode = DEV_MODE_VNET; + } + + return SHR_E_NONE; +} + +/*! + * Configure HW + */ +static int +cmicr_pdma_hw_config(struct pdma_hw *hw) +{ + struct dev_ctrl *ctrl = &hw->dev->ctrl; + struct pdma_rx_queue *rxq = NULL; + struct pdma_tx_queue *txq = NULL; + uint32_t que_ctrl; + int grp, que; + uint32_t qi; + int ip_if_hdr_endian = 0; + CMIC_CMC_PKTDMA_CTRLr_t pktdma_ctrl; + CMIC_CMC_PKTDMA_INTR_ENABLEr_t pktdma_intr_enable; + CMIC_CMC_PKTDMA_INTR_CLRr_t pktdma_intr_clr; + CMIC_TOP_CONFIGr_t cmic_config; + + CMIC_CMC_PKTDMA_INTR_ENABLEr_CLR(pktdma_intr_enable); + CMIC_CMC_PKTDMA_INTR_ENABLEr_DESC_CONTROLLED_INTR_ENABLEf_SET(pktdma_intr_enable, 1); + + CMIC_CMC_PKTDMA_INTR_CLRr_CLR(pktdma_intr_clr); + CMIC_CMC_PKTDMA_INTR_CLRr_DESC_DONE_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_DESC_CONTROLLED_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_INTR_COALESCING_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_DYN_RCNFG_ERR_CLRf_SET(pktdma_intr_clr, 1); + + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + rxq = (struct pdma_rx_queue *)ctrl->rx_queue[qi]; + grp = rxq->group_id; + que = rxq->chan_id % CMICR_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_CLR(grp, que), + CMIC_CMC_PKTDMA_INTR_CLRr_GET(pktdma_intr_clr)); + CMIC_CMC_PKTDMA_CTRLr_CLR(pktdma_ctrl); + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + CMIC_CMC_PKTDMA_CTRLr_PKTDMA_ENDIANESSf_SET(pktdma_ctrl, 1); + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + CMIC_CMC_PKTDMA_CTRLr_DESC_ENDIANESSf_SET(pktdma_ctrl, 1); + } + if (que_ctrl & PDMA_HDR_BYTE_SWAP) { + CMIC_CMC_PKTDMA_CTRLr_HEADER_ENDIANESSf_SET(pktdma_ctrl, 1); + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + CMIC_CMC_PKTDMA_CTRLr_ENABLE_CONTINUOUS_DMAf_SET(pktdma_ctrl, 1); + } + CMIC_CMC_PKTDMA_CTRLr_CONTIGUOUS_DESCRIPTORSf_SET(pktdma_ctrl, 1); + CMIC_CMC_PKTDMA_CTRLr_DESC_DONE_INTR_MODEf_SET(pktdma_ctrl, 1); + + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_ENAB(grp, que), + CMIC_CMC_PKTDMA_INTR_ENABLEr_GET(pktdma_intr_enable)); + } + + for (qi = 0; qi < ctrl->nb_txq; qi++) { + txq = (struct pdma_tx_queue *)ctrl->tx_queue[qi]; + grp = txq->group_id; + que = txq->chan_id % CMICR_PDMA_CMC_CHAN; + que_ctrl = ctrl->grp[grp].que_ctrl[que]; + + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_CLR(grp, que), + CMIC_CMC_PKTDMA_INTR_CLRr_GET(pktdma_intr_clr)); + CMIC_CMC_PKTDMA_CTRLr_CLR(pktdma_ctrl); + if (que_ctrl & PDMA_PKT_BYTE_SWAP) { + CMIC_CMC_PKTDMA_CTRLr_PKTDMA_ENDIANESSf_SET(pktdma_ctrl, 1); + CMIC_CMC_PKTDMA_CTRLr_HEADER_ENDIANESSf_SET(pktdma_ctrl, 1); + ip_if_hdr_endian = 1; + } + if (que_ctrl & PDMA_OTH_BYTE_SWAP) { + CMIC_CMC_PKTDMA_CTRLr_DESC_ENDIANESSf_SET(pktdma_ctrl, 1); + } + if (que_ctrl & PDMA_HDR_BYTE_SWAP) { + ip_if_hdr_endian = 1; + } + if (!(hw->dev->flags & PDMA_CHAIN_MODE)) { + CMIC_CMC_PKTDMA_CTRLr_ENABLE_CONTINUOUS_DMAf_SET(pktdma_ctrl, 1); + } + CMIC_CMC_PKTDMA_CTRLr_CONTIGUOUS_DESCRIPTORSf_SET(pktdma_ctrl, 1); + CMIC_CMC_PKTDMA_CTRLr_DESC_DONE_INTR_MODEf_SET(pktdma_ctrl, 1); + CMIC_CMC_PKTDMA_CTRLr_DIRECTIONf_SET(pktdma_ctrl, 1); + + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_ENAB(grp, que), + CMIC_CMC_PKTDMA_INTR_ENABLEr_GET(pktdma_intr_enable)); + } + + hw->hdls.reg_rd32(hw, + CMICR_TOP_CONFIG, &CMIC_TOP_CONFIGr_GET(cmic_config)); + CMIC_TOP_CONFIGr_IP_INTERFACE_HEADER_ENDIANESSf_SET(cmic_config, + ip_if_hdr_endian); + hw->hdls.reg_wr32(hw, + CMICR_TOP_CONFIG, CMIC_TOP_CONFIGr_GET(cmic_config)); + + return SHR_E_NONE; +} + +/*! + * Reset HW + */ +static int +cmicr_pdma_hw_reset(struct pdma_hw *hw) +{ + int gi, qi; + + for (gi = 0; gi < hw->dev->num_groups; gi++) { + if (!hw->dev->ctrl.grp[gi].attached) { + continue; + } + for (qi = 0; qi < CMICR_PDMA_CMC_CHAN; qi++) { + if (1 << qi & hw->dev->ctrl.grp[gi].bm_rxq || + 1 << qi & hw->dev->ctrl.grp[gi].bm_txq) { + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(gi, qi), 0); + } + } + } + + return SHR_E_NONE; +} + +/*! + * Start a channel + */ +static int +cmicr_pdma_chan_start(struct pdma_hw *hw, int chan) +{ + CMIC_CMC_PKTDMA_CTRLr_t pktdma_ctrl; + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICR_PDMA_CTRL(grp, que), + &CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_SET(pktdma_ctrl, 1); + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Stop a channel + */ +static int +cmicr_pdma_chan_stop(struct pdma_hw *hw, int chan) +{ + CMIC_CMC_PKTDMA_CTRLr_t pktdma_ctrl; + CMIC_CMC_PKTDMA_INTR_ENABLEr_t pktdma_intr_enable; + CMIC_CMC_PKTDMA_INTR_CLRr_t pktdma_intr_clr; + CMIC_CMC_PKTDMA_STATr_t pktdma_stat; + int grp, que; + int retry = CMICR_HW_RETRY_TIMES; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICR_PDMA_STAT(grp, que), + &CMIC_CMC_PKTDMA_STATr_GET(pktdma_stat)); + + if (CMIC_CMC_PKTDMA_STATr_CHAIN_DONEf_GET(pktdma_stat)) { + hw->hdls.reg_rd32(hw, CMICR_PDMA_CTRL(grp, que), + &CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_SET(pktdma_ctrl, 0); + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + return SHR_E_NONE; + } + + /* if chain done is 0, abort */ + hw->hdls.reg_rd32(hw, CMICR_PDMA_CTRL(grp, que), + &CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_SET(pktdma_ctrl, 1); + CMIC_CMC_PKTDMA_CTRLr_ABORT_DMAf_SET(pktdma_ctrl, 1); + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + + MEMORY_BARRIER; + + do { + hw->hdls.reg_rd32(hw, CMICR_PDMA_STAT(grp, que), + &CMIC_CMC_PKTDMA_STATr_GET(pktdma_stat)); + } while (!CMIC_CMC_PKTDMA_STATr_CHAIN_DONEf_GET(pktdma_stat) && (--retry > 0)); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_CTRL(grp, que), + &CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_SET(pktdma_ctrl, 0); + CMIC_CMC_PKTDMA_CTRLr_ABORT_DMAf_SET(pktdma_ctrl, 0); + hw->hdls.reg_wr32(hw, CMICR_PDMA_CTRL(grp, que), + CMIC_CMC_PKTDMA_CTRLr_GET(pktdma_ctrl)); + + MEMORY_BARRIER; + + CMIC_CMC_PKTDMA_INTR_ENABLEr_CLR(pktdma_intr_enable); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_ENAB(grp, que), + CMIC_CMC_PKTDMA_INTR_ENABLEr_GET(pktdma_intr_enable)); + + MEMORY_BARRIER; + + CMIC_CMC_PKTDMA_INTR_CLRr_CLR(pktdma_intr_clr); + CMIC_CMC_PKTDMA_INTR_CLRr_DESC_DONE_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_DESC_CONTROLLED_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_INTR_COALESCING_INTR_CLRf_SET(pktdma_intr_clr, 1); + CMIC_CMC_PKTDMA_INTR_CLRr_DYN_RCNFG_ERR_CLRf_SET(pktdma_intr_clr, 1); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_CLR(grp, que), + CMIC_CMC_PKTDMA_INTR_CLRr_GET(pktdma_intr_clr)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Setup a channel + */ +static int +cmicr_pdma_chan_setup(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICR_PDMA_DESC_LO(grp, que), addr); + hw->hdls.reg_wr32(hw, CMICR_PDMA_DESC_HI(grp, que), DMA_TO_BUS_HI(addr >> 32)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Set halt point for a channel + */ +static int +cmicr_pdma_chan_goto(struct pdma_hw *hw, int chan, uint64_t addr) +{ + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_wr32(hw, CMICR_PDMA_DESC_HALT_LO(grp, que), addr); + hw->hdls.reg_wr32(hw, CMICR_PDMA_DESC_HALT_HI(grp, que), DMA_TO_BUS_HI(addr >> 32)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Clear a channel + */ +static int +cmicr_pdma_chan_clear(struct pdma_hw *hw, int chan) +{ + CMIC_CMC_PKTDMA_INTR_CLRr_t pktdma_intr_clr; + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + CMIC_CMC_PKTDMA_INTR_CLRr_CLR(pktdma_intr_clr); + CMIC_CMC_PKTDMA_INTR_CLRr_DESC_CONTROLLED_INTR_CLRf_SET(pktdma_intr_clr, 1); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_CLR(grp, que), + CMIC_CMC_PKTDMA_INTR_CLRr_GET(pktdma_intr_clr)); + + MEMORY_BARRIER; + + return SHR_E_NONE; +} + +/*! + * Get interrupt number for a channel + */ +static int +cmicr_pdma_chan_intr_num_get(struct pdma_hw *hw, int chan) +{ + int grp, que; + const int irq_map[CMICR_PDMA_CMC_MAX][CMICR_PDMA_CMC_CHAN] = + {{CMICR_IRQ_CMC0_PKTDMA_CH0_INTR, CMICR_IRQ_CMC0_PKTDMA_CH1_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH2_INTR, CMICR_IRQ_CMC0_PKTDMA_CH3_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH4_INTR, CMICR_IRQ_CMC0_PKTDMA_CH5_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH6_INTR, CMICR_IRQ_CMC0_PKTDMA_CH7_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH8_INTR, CMICR_IRQ_CMC0_PKTDMA_CH9_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH10_INTR, CMICR_IRQ_CMC0_PKTDMA_CH11_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH12_INTR, CMICR_IRQ_CMC0_PKTDMA_CH13_INTR, + CMICR_IRQ_CMC0_PKTDMA_CH14_INTR, CMICR_IRQ_CMC0_PKTDMA_CH15_INTR}, + {CMICR_IRQ_CMC1_PKTDMA_CH0_INTR, CMICR_IRQ_CMC1_PKTDMA_CH1_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH2_INTR, CMICR_IRQ_CMC1_PKTDMA_CH3_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH4_INTR, CMICR_IRQ_CMC1_PKTDMA_CH5_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH6_INTR, CMICR_IRQ_CMC1_PKTDMA_CH7_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH8_INTR, CMICR_IRQ_CMC1_PKTDMA_CH9_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH10_INTR, CMICR_IRQ_CMC1_PKTDMA_CH11_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH12_INTR, CMICR_IRQ_CMC1_PKTDMA_CH13_INTR, + CMICR_IRQ_CMC1_PKTDMA_CH14_INTR, CMICR_IRQ_CMC1_PKTDMA_CH15_INTR}}; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + if (grp < 0 || grp >= CMICR_PDMA_CMC_MAX) { + return -1; + } + + return irq_map[grp][que]; +} + +/*! + * Enable interrupt for a channel + */ +static int +cmicr_pdma_chan_intr_enable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->dev->ctrl.grp[grp].irq_mask |= (1 << que); + cmicr_pdma_intr_enable(hw, grp, que); + + return SHR_E_NONE; +} + +/*! + * Disable interrupt for a channel + */ +static int +cmicr_pdma_chan_intr_disable(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->dev->ctrl.grp[grp].irq_mask &= ~(1 << que); + cmicr_pdma_intr_disable(hw, grp, que); + + return SHR_E_NONE; +} + +/*! + * Query interrupt status for a channel + * + * In group mode (interrupt processing per CMC), need to query each channel's + * interrupt status. + * + */ +static int +cmicr_pdma_chan_intr_query(struct pdma_hw *hw, int chan) +{ + CMIC_CMC_PKTDMA_INTRr_t pktdma_intr; + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICR_PDMA_INTR_STAT(grp, que), + &CMIC_CMC_PKTDMA_INTRr_GET(pktdma_intr)); + + return CMIC_CMC_PKTDMA_INTRr_DESC_CONTROLLED_INTRf_GET(pktdma_intr); +} + +/*! + * Check interrupt validity for a channel + * + * In group mode (interrupt processing per CMC), need to check each channel's + * interrupt validity based on its interrupt mask. + * + */ +static int +cmicr_pdma_chan_intr_check(struct pdma_hw *hw, int chan) +{ + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + if (!(hw->dev->ctrl.grp[grp].irq_mask & (1 << que))) { + return 0; + } + + return cmicr_pdma_chan_intr_query(hw, chan); +} + +/*! + * Coalesce interrupt for a channel + */ +static int +cmicr_pdma_chan_intr_coalesce(struct pdma_hw *hw, int chan, int count, int timer) +{ + CMIC_CMC_PKTDMA_INTR_COALr_t pktdma_intr_col; + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + CMIC_CMC_PKTDMA_INTR_COALr_CLR(pktdma_intr_col); + CMIC_CMC_PKTDMA_INTR_COALr_ENABLEf_SET(pktdma_intr_col, 1); + CMIC_CMC_PKTDMA_INTR_COALr_COUNTf_SET(pktdma_intr_col, count); + CMIC_CMC_PKTDMA_INTR_COALr_TIMERf_SET(pktdma_intr_col, timer); + hw->hdls.reg_wr32(hw, CMICR_PDMA_INTR_COAL(grp, que), + CMIC_CMC_PKTDMA_INTR_COALr_GET(pktdma_intr_col)); + + return SHR_E_NONE; +} + +/*! + * Dump registers for a channel + */ +static int +cmicr_pdma_chan_reg_dump(struct pdma_hw *hw, int chan) +{ + uint32_t val; + int grp, que; + + grp = chan / CMICR_PDMA_CMC_CHAN; + que = chan % CMICR_PDMA_CMC_CHAN; + + hw->hdls.reg_rd32(hw, CMICR_PDMA_CTRL(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CTRL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_DESC_LO(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_DESC_HI(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_CURR_DESC_LO(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CURR_DESC_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_CURR_DESC_HI(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CURR_DESC_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_DESC_HALT_LO(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_LO: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_DESC_HALT_HI(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_HI: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_COS_CTRL_RX0(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_COS_CTRL_RX1(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_INTR_COAL(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_RBUF_THRE(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_STAT(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_STAT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_COUNT_RX(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_COUNT_TX(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_TXPKT: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_COUNT_RX_DROP(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT_DROP: 0x%08x\n", grp, que, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_INTR_ENAB(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_INTR_ENAB: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_INTR_STAT(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_INTR_STAT: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICR_PDMA_INTR_CLR(grp, que), &val); + CNET_INFO(hw->unit, "CMIC_CMC%d_INTR_CLR: 0x%08x\n", grp, val); + + val = hw->dev->ctrl.grp[grp].irq_mask; + CNET_INFO(hw->unit, "CMIC_CMC%d_IRQ_ENAB: 0x%08x\n", grp, val); + + hw->hdls.reg_rd32(hw, CMICR_EP_TO_CPU_HEADER_SIZE, &val); + CNET_INFO(hw->unit, "CMIC_EP_TO_CPU_HEADER_SIZE: 0x%08x\n", val); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicr_pdma_hw_hdls_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->hdls.reg_rd32 = cmicr_pdma_reg_read32; + hw->hdls.reg_wr32 = cmicr_pdma_reg_write32; + hw->hdls.hw_init = cmicr_pdma_hw_init; + hw->hdls.hw_config = cmicr_pdma_hw_config; + hw->hdls.hw_reset = cmicr_pdma_hw_reset; + hw->hdls.chan_start = cmicr_pdma_chan_start; + hw->hdls.chan_stop = cmicr_pdma_chan_stop; + hw->hdls.chan_setup = cmicr_pdma_chan_setup; + hw->hdls.chan_goto = cmicr_pdma_chan_goto; + hw->hdls.chan_clear = cmicr_pdma_chan_clear; + hw->hdls.chan_intr_num_get = cmicr_pdma_chan_intr_num_get; + hw->hdls.chan_intr_enable = cmicr_pdma_chan_intr_enable; + hw->hdls.chan_intr_disable = cmicr_pdma_chan_intr_disable; + hw->hdls.chan_intr_query = cmicr_pdma_chan_intr_query; + hw->hdls.chan_intr_check = cmicr_pdma_chan_intr_check; + hw->hdls.chan_intr_coalesce = cmicr_pdma_chan_intr_coalesce; + hw->hdls.chan_reg_dump = cmicr_pdma_chan_reg_dump; + + return SHR_E_NONE; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_rxtx.c new file mode 100644 index 000000000000..381b9e208446 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicr/bcmcnet_cmicr_pdma_rxtx.c @@ -0,0 +1,1187 @@ +/*! \file bcmcnet_cmicr_pdma_rxtx.c + * + * Utility routines for BCMCNET hardware (CMICr) specific Rx/Tx. + * + * Here are the CMIC specific Rx/Tx routines including DCBs resource allocation + * and clean up, DCBs configuration, Rx buffers allocation, Tx buffers release, + * Rx/Tx packets processing, etc. + * They are shared among all the modes (UNET, KNET, VNET, HNET) and in both of + * user space and kernel space. + * + * The driver uses a ring of DCBs per DMA channel based on Continuous DMA mode. + * The beginning is written to register pointing to the physical address of the + * start of the ring. The ring size is maintained by the driver. A HALT DCB + * physical address is written to DMA register timely to indicate how many DCBs + * can be handled by HW. + * + * When a packet is received, an interrupt is triggered. The handler will go + * through the Rx DCB ring to process the current completed DCB and every + * subsequent DCBs until no one is left. The received packet is processed and + * passed up to the high level SW. After that, a new buffer is allocated and + * the DCB is updated for receiving a new packet. A new HALT DCB is selected + * and its physical address is written to DMA register. + * + * When a packet is transmitted, the driver starts where it left off last time + * in the Tx DCB ring, updates the DCB and writes its physical address to DMA + * register so as to start DMA. Once the transmitting is finished, the handler + * is informed to clean up the buffer based on the work mode. In KNET or HNET + * mode, an interrupt will be triggered. Polling mode is used in CNET or VNET + * mode, the buffers will be cleaned up when the number of dirty DCBs reaches + * a pre-defined threshold. + * + * In VNET and HNET modes, DCB updating between virtual ring and real ring and + * a IOCTL based notification mechanism are involved. The hypervisor in kernel + * emulates the DMA HW behaviors to update DCBs in virtual network and inform + * the handler something happened. Likewise, the hypervisor updates itself real + * DCB ring from the virtual ring to start DMA for transmitting a packet once a + * notification is received from the virtual network. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#include +#include +#include +#include +#include + +#define RX_DCB_CTRL_WORD (2) +#define RX_DCB_STATUS_WORD (3) +#define RX_DCB_STATUS_GET(_rd_) (RX_DCB_GET((_rd_), RX_DCB_STATUS_WORD)) +#define RX_DCB_STATUS_SET(_rd_, _val_) (RX_DCB_SET((_rd_), RX_DCB_STATUS_WORD, (_val_))) +#define RX_DCB_CTRL_SET(_rd_, _val_) (RX_DCB_SET((_rd_), RX_DCB_CTRL_WORD, (_val_))) + +#define TX_DCB_CTRL_WORD (2) +#define TX_DCB_STATUS_WORD (3) +#define TX_DCB_STATUS_GET(_td_) (TX_DCB_GET((_td_), TX_DCB_STATUS_WORD)) +#define TX_DCB_STATUS_SET(_td_, _val_) (TX_DCB_SET((_td_), TX_DCB_STATUS_WORD, (_val_))) +#define TX_DCB_CTRL_SET(_td_, _val_) (TX_DCB_SET((_td_), TX_DCB_CTRL_WORD, (_val_))) + +/*! + * Configure Rx descriptor + */ +static inline void +cmicr_rx_desc_config(volatile RX_DCB_t *rd, uint64_t addr, uint32_t len) +{ + uint32_t remain; + + /* word 0, 1 : addr */ + RX_DCB_ADDR_LOf_SET(*rd, addr); + RX_DCB_ADDR_HIf_SET(*rd, DMA_TO_BUS_HI(addr >> 32)); + + /* word 2: ctrl */ + remain = RX_DCB_DESC_REMAINf_GET(*rd); + RX_DCB_CTRL_SET(*rd, 0); + RX_DCB_DESC_REMAINf_SET(*rd, remain); + RX_DCB_DESC_CTRL_INTRf_SET(*rd, 1); + RX_DCB_CHAINf_SET(*rd, 1); + RX_DCB_BYTE_COUNTf_SET(*rd, len); + + /* word 3: status */ + RX_DCB_STATUS_SET(*rd, 0); + + MEMORY_BARRIER; +} + +/*! + * Configure Tx descriptor + */ +static inline void +cmicr_tx_desc_config(volatile TX_DCB_t *td, uint64_t addr, uint32_t len, uint16_t flags) +{ + uint32_t remain; + + /* word 0,1 : addr */ + TX_DCB_ADDR_LOf_SET(*td, addr); + TX_DCB_ADDR_HIf_SET(*td, DMA_TO_BUS_HI(addr >> 32)); + + /* word 2: ctrl */ + remain = TX_DCB_DESC_REMAINf_GET(*td); + TX_DCB_CTRL_SET(*td, 0); + TX_DCB_DESC_REMAINf_SET(*td, remain); + TX_DCB_DESC_CTRL_INTRf_SET(*td, 1); + TX_DCB_CHAINf_SET(*td, 1); + TX_DCB_BYTE_COUNTf_SET(*td, len); + if (flags & PDMA_TX_HIGIG_PKT) { + TX_DCB_HGf_SET(*td, 1); + } + if (flags & PDMA_TX_PURGE_PKT) { + TX_DCB_PURGEf_SET(*td, 1); + } + + /* word 3: status */ + TX_DCB_STATUS_SET(*td, 0); + + MEMORY_BARRIER; +} + +/*! + * Configure Rx reload descriptor + */ +static inline void +cmicr_rx_rldesc_config(volatile RX_DCB_t *rd, uint64_t addr) +{ + /* word 0,1 : addr */ + RX_DCB_ADDR_LOf_SET(*rd, addr); + RX_DCB_ADDR_HIf_SET(*rd, DMA_TO_BUS_HI(addr >> 32)); + + /* word 2: ctrl */ + RX_DCB_CTRL_SET(*rd, 0); + RX_DCB_DESC_CTRL_INTRf_SET(*rd, 1); + RX_DCB_CHAINf_SET(*rd, 1); + RX_DCB_RELOADf_SET(*rd, 1); + + /* word 3: status */ + RX_DCB_STATUS_SET(*rd, 0); + + MEMORY_BARRIER; +} + +/*! + * Configure Tx reload descriptor + */ +static inline void +cmicr_tx_rldesc_config(volatile TX_DCB_t *td, uint64_t addr) +{ + /* word 0, 1 : addr */ + TX_DCB_ADDR_LOf_SET(*td, addr); + TX_DCB_ADDR_HIf_SET(*td, DMA_TO_BUS_HI(addr >> 32)); + + /* word 2: ctrl */ + TX_DCB_CTRL_SET(*td, 0); + TX_DCB_DESC_CTRL_INTRf_SET(*td, 1); + TX_DCB_CHAINf_SET(*td, 1); + TX_DCB_RELOADf_SET(*td, 1); + + /* word 3: status */ + TX_DCB_STATUS_SET(*td, 0); + + MEMORY_BARRIER; +} + +/*! + * Chain Rx descriptor + */ +static inline void +cmicr_rx_desc_chain(volatile RX_DCB_t *rd, int chain) +{ + if (chain) { + RX_DCB_CHAINf_SET(*rd, 1); + } else { + RX_DCB_CHAINf_SET(*rd, 0); + } + + MEMORY_BARRIER; +} + +/*! + * Chain Tx descriptor + */ +static inline void +cmicr_tx_desc_chain(volatile TX_DCB_t *td, int chain) +{ + if (chain) { + TX_DCB_CHAINf_SET(*td, 1); + } else { + TX_DCB_CHAINf_SET(*td, 0); + } + + MEMORY_BARRIER; +} + +/*! + * Set Rx descriptor remain + */ +static inline void +cmicr_rx_desc_remain(volatile RX_DCB_t *rd, uint32_t rm) +{ + RX_DCB_DESC_REMAINf_SET(*rd, rm); + + MEMORY_BARRIER; +} + +/*! + * Set Tx descriptor remain + */ +static inline void +cmicr_tx_desc_remain(volatile TX_DCB_t *td, uint32_t rm) +{ + TX_DCB_DESC_REMAINf_SET(*td, rm); + + MEMORY_BARRIER; +} + +/*! + * Get unused descriptors in a Rx ring + */ +static inline int +cmicr_pdma_rx_ring_unused(struct pdma_rx_queue *rxq) +{ + /* Leave one descriptor unused so as not to halt */ + return (rxq->nb_desc + rxq->curr - rxq->halt - 1) % rxq->nb_desc; +} + +/*! + * Get unused descriptors in a Tx ring + */ +static inline int +cmicr_pdma_tx_ring_unused(struct pdma_tx_queue *txq) +{ + /* Leave one descriptor unused so as not to halt */ + return (txq->nb_desc + txq->dirt - txq->curr - 1) % txq->nb_desc; +} + +/*! + * Initialize Rx descriptors + */ +static int +cmicr_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + dma_addr_t addr; + uint32_t di, rm; + int rv; + + for (di = 0; di < rxq->nb_desc; di++) { + if (!rxq->pbuf[di].dma) { + /* Allocate pktbuf for ring entry */ + rv = bm->rx_buf_alloc(dev, rxq, &rxq->pbuf[di]); + if (SHR_FAILURE(rv)) { + goto cleanup; + } + } + /* Config receive descriptor ring */ + bm->rx_buf_dma(dev, rxq, &rxq->pbuf[di], &addr); + cmicr_rx_desc_config(&ring[di], addr, rxq->buf_size); + rm = (rxq->nb_desc - di) >= CMICR_DESC_REMAIN_MAX ? + CMICR_DESC_REMAIN_MAX : rxq->nb_desc - di; + cmicr_rx_desc_remain(&ring[di], rm); + if (hw->dev->flags & PDMA_CHAIN_MODE && di == rxq->nb_desc - 1) { + cmicr_rx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicr_rx_rldesc_config(&ring[di], rxq->ring_addr); + + rxq->curr = 0; + rxq->halt = rxq->nb_desc - 1; + + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + hw->hdls.chan_setup(hw, rxq->chan_id, rxq->ring_addr); + + return SHR_E_NONE; + +cleanup: + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicr_rx_desc_config(&ring[di], 0, 0); + } + + CNET_ERROR(hw->unit, "RX: Failed to allocate memory\n"); + + return SHR_E_MEMORY; +} + +/*! + * Cleanup Rx descriptors + */ +static int +cmicr_pdma_rx_desc_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < rxq->nb_desc; di++) { + if (rxq->pbuf[di].dma) { + bm->rx_buf_free(dev, rxq, &rxq->pbuf[di]); + } + cmicr_rx_desc_config(&ring[di], 0, 0); + } + + rxq->curr = 0; + rxq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Initialize Tx descriptors + */ +static int +cmicr_pdma_tx_desc_init(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + uint32_t di, rm; + + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + /* Config transmit descriptor ring */ + cmicr_tx_desc_config(&ring[di], 0, 0, 0); + rm = (txq->nb_desc - di) >= CMICR_DESC_REMAIN_MAX ? + CMICR_DESC_REMAIN_MAX : txq->nb_desc - di; + cmicr_tx_desc_remain(&ring[di], rm); + if (hw->dev->flags & PDMA_CHAIN_MODE) { + cmicr_tx_desc_chain(&ring[di], 0); + } + } + /* Config the last descriptor in the ring as reload descriptor */ + cmicr_tx_rldesc_config(&ring[di], txq->ring_addr); + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + txq->halt_addr = txq->ring_addr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + hw->hdls.chan_setup(hw, txq->chan_id, txq->ring_addr); + + return SHR_E_NONE; +} + +/*! + * Cleanup Tx descriptors + */ +static int +cmicr_pdma_tx_desc_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + uint32_t di; + + /* Go through all the descriptors and free pktbuf */ + for (di = 0; di < txq->nb_desc; di++) { + if (txq->pbuf[di].dma) { + bm->tx_buf_free(dev, txq, &txq->pbuf[di]); + } + cmicr_tx_desc_config(&ring[di], 0, 0, 0); + } + + txq->curr = 0; + txq->dirt = 0; + txq->halt = 0; + + return SHR_E_NONE; +} + +/*! + * Process Rx vring + */ +static int +cmicr_pdma_rx_vring_process(struct pdma_hw *hw, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + struct pdma_rx_queue *vrxq = NULL; + volatile RX_DCB_t *vring = NULL; + struct pkt_hdr *pkh = &pbuf->pkb->pkh; + uint64_t buf_addr; + + vrxq = (struct pdma_rx_queue *)dev->ctrl.vnet_rxq[rxq->queue_id]; + vring = (volatile RX_DCB_t *)vrxq->ring; + if (!vring) { + rxq->stats.dropped++; + return SHR_E_UNAVAIL; + } + + if (RX_DCB_DONEf_GET(vring[vrxq->curr])) { + dev->xnet_wake(dev); + return SHR_E_BUSY; + } + + /* Copy descriptor and packet to vring */ + buf_addr = BUS_TO_DMA_HI(RX_DCB_ADDR_HIf_GET(vring[vrxq->curr])); + buf_addr = buf_addr << 32 | RX_DCB_ADDR_LOf_GET(vring[vrxq->curr]); + sal_memcpy(dev->sys_p2v(dev, buf_addr), &pbuf->pkb->data, + pkh->meta_len + pkh->data_len); + RX_DCB_STATUS_SET(vring[vrxq->curr], RX_DCB_STATUS_GET(ring[rxq->curr])); + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!RX_DCB_STATUS_GET(vring[(vrxq->curr + vrxq->nb_desc - 1) % vrxq->nb_desc])) { + dev->xnet_wake(dev); + } + vrxq->curr = (vrxq->curr + 1) % vrxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Refill Rx ring + */ +static int +cmicr_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + int unused = cmicr_pdma_rx_ring_unused(rxq); + dma_addr_t addr; + uint32_t halt; + int rv; + + for (halt = rxq->halt; halt < rxq->halt + unused; halt++) { + if (RX_DCB_ADDR_LOf_GET(ring[halt % rxq->nb_desc])) { + continue; + } + pbuf = &rxq->pbuf[halt % rxq->nb_desc]; + /* Allocate a new pktbuf */ + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { + rxq->stats.nomems++; + rxq->halt = halt % rxq->nb_desc; + CNET_ERROR(hw->unit, "Can not alloc RX buffer, %d DCBs not filled\n", + cmicr_pdma_rx_ring_unused(rxq)); + break; + } + } + /* Setup the new descriptor */ + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicr_rx_desc_config(&ring[halt % rxq->nb_desc], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && halt % rxq->nb_desc == rxq->nb_desc - 1) { + cmicr_rx_desc_chain(&ring[halt % rxq->nb_desc], 0); + } + } + rxq->halt = halt % rxq->nb_desc; + + /* Move forward */ + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * \brief Clean Rx ring + * + * \param [in] hw HW structure point. + * \param [in] rxq Rx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicr_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + struct pdma_rx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t curr; + int len, done = 0; + int retry; + int rv; + + curr = rxq->curr; + while (RX_DCB_DONEf_GET(ring[curr])) { + if (done == budget) { + break; + } + + /* Move forward */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + sal_spinlock_unlock(rxq->lock); + } + + /* Get the current pktbuf to process */ + pbuf = &rxq->pbuf[curr]; + len = RX_DCB_BYTES_TRANSFERREDf_GET(ring[curr]); + pkh = bm->rx_buf_get(dev, rxq, pbuf, len); + if (!pkh) { + CNET_ERROR(hw->unit, "RX buffer build failed, retry ...\n"); + rxq->stats.nomems++; + /* Set busy state to retry */ + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; + } + + /* Setup packet header */ + pkh->data_len = len - hw->info.rx_ph_size; + pkh->meta_len = hw->info.rx_ph_size; + pkh->queue_id = rxq->queue_id; + + /* Send up the packet */ + rv = dev->pkt_recv(dev, rxq->queue_id, (void *)pbuf->skb); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_HNET && pkh->attrs & PDMA_RX_TO_VNET) { + rv = cmicr_pdma_rx_vring_process(hw, rxq, pbuf); + if (SHR_FAILURE(rv) && rv == SHR_E_BUSY) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return done; + } + } else { + rxq->stats.dropped++; + } + bm->rx_buf_put(dev, rxq, pbuf, len); + } + + /* Count the packets/bytes */ + rxq->stats.packets++; + rxq->stats.bytes += len; + + /* Count the errors if any */ + if (RX_DCB_ERRORf_GET(ring[curr])) { + rxq->stats.errors++; + } + + /* Setup the new descriptor */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + if (!bm->rx_buf_avail(dev, rxq, pbuf)) { + retry = 0; + while (1) { + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_SUCCESS(rv)) { + break; + } + rxq->stats.nomems++; + if (dev->mode == DEV_MODE_UNET || dev->mode == DEV_MODE_VNET) { + if (retry++ < 5000000) { + sal_usleep(1); + continue; + } + CNET_ERROR(hw->unit, "Fatal error: can not alloc RX buffer\n"); + } + rxq->state |= PDMA_RX_BATCH_REFILL; + rxq->free_thresh = 1; + cmicr_rx_desc_config(&ring[curr], 0, 0); + CNET_ERROR(hw->unit, "RX buffer alloc failed, try batch refilling later\n"); + break; + } + } + if (pbuf->dma) { + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicr_rx_desc_config(&ring[curr], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { + cmicr_rx_desc_chain(&ring[curr], 0); + } + } + } else { + cmicr_rx_desc_config(&ring[curr], 0, 0); + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + if (RX_DCB_STATUS_GET(ring[(curr + rxq->nb_desc - 1) % rxq->nb_desc])) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL) && rxq->halt != curr) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + curr = (curr + 1) % rxq->nb_desc; + sal_spinlock_unlock(rxq->lock); + } else { + curr = (curr + 1) % rxq->nb_desc; + } + rxq->curr = curr; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(rxq->lock); + if (curr == 0 && !(rxq->status & PDMA_RX_QUEUE_XOFF)) { + hw->hdls.chan_stop(hw, rxq->chan_id); + hw->hdls.chan_start(hw, rxq->chan_id); + } + sal_spinlock_unlock(rxq->lock); + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (curr == rxq->nb_desc - 1 && done) { + done = budget; + } + } + + /* In batching mode, replenish all the unused descriptors */ + if (rxq->state & PDMA_RX_BATCH_REFILL && + cmicr_pdma_rx_ring_unused(rxq) >= (int)rxq->free_thresh) { + cmicr_pdma_rx_ring_refill(hw, rxq); + /* If no one filled, return budget and keep polling */ + if (cmicr_pdma_rx_ring_unused(rxq) == (int)(rxq->nb_desc - 1)) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; + } + } + + return done; +} + +/*! + * Process Tx vring + */ +static int +cmicr_pdma_tx_vring_process(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + volatile TX_DCB_t *vring = NULL; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (volatile TX_DCB_t *)vtxq->ring; + if (!vring) { + return SHR_E_UNAVAIL; + } + + /* Update vring descriptor */ + TX_DCB_STATUS_SET(vring[vtxq->dirt], TX_DCB_STATUS_GET(ring[txq->dirt])); + pbuf->dma = 0; + + MEMORY_BARRIER; + + /* Notify VNET to process if needed */ + if (!TX_DCB_STATUS_GET(vring[(vtxq->dirt + vtxq->nb_desc - 1) % vtxq->nb_desc])) { + dev->xnet_wake(dev); + } + vtxq->dirt = (vtxq->dirt + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * \brief Clean Tx ring + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] budget Polling budget. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicr_pdma_tx_ring_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budget) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + uint32_t dirt, curr; + int done = 0; + + dirt = txq->dirt; + while (txq->pbuf[dirt].dma) { + if (!TX_DCB_STATUS_GET(ring[dirt])) { + break; + } + if (done == budget) { + break; + } + + if (dev->mode == DEV_MODE_HNET && !txq->pbuf[dirt].skb) { + cmicr_pdma_tx_vring_process(hw, txq, &txq->pbuf[dirt]); + } else { + /* Free the done pktbuf */ + bm->tx_buf_free(dev, txq, &txq->pbuf[dirt]); + } + + cmicr_tx_desc_config(&ring[dirt], 0, 0, 0); + + /* Update the indicators */ + dirt = (dirt + 1) % txq->nb_desc; + txq->dirt = dirt; + done++; + + /* Restart DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + curr = txq->curr; + if (dirt == txq->halt && dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicr_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(TX_DCB_t) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + } + + /* One more poll for chain done in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + sal_spinlock_lock(txq->lock); + if (dirt != txq->halt) { + done = budget; + } + sal_spinlock_unlock(txq->lock); + } + + /* Set busy state to avoid HW checking */ + if (done == budget) { + txq->state |= PDMA_TX_QUEUE_BUSY; + } + + /* Resume Tx if any */ + sal_spinlock_lock(txq->lock); + if (txq->status & PDMA_TX_QUEUE_XOFF && cmicr_pdma_tx_ring_unused(txq)) { + txq->status &= ~PDMA_TX_QUEUE_XOFF; + if (dev->suspended) { + sal_spinlock_unlock(txq->lock); + return done; + } + if (dev->tx_resume) { + dev->tx_resume(dev, txq->queue_id); + } + sal_spinlock_unlock(txq->lock); + if (!dev->tx_resume && !(txq->state & PDMA_TX_QUEUE_POLL)) { + sal_sem_give(txq->sem); + } + return done; + } + sal_spinlock_unlock(txq->lock); + + return done; +} + +/*! + * Dump Rx ring + */ +static int +cmicr_pdma_rx_ring_dump(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + volatile RX_DCB_t *ring = (volatile RX_DCB_t *)rxq->ring; + volatile RX_DCB_t *rd; + uint32_t di; + + CNET_INFO(hw->unit, "RX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", + rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); + for (di = 0; di < rxq->nb_desc + 1; di++) { + rd = &ring[di]; + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(rxq->ring_addr + di * CMICR_PDMA_DCB_SIZE), + RX_DCB_GET(*rd, 0), RX_DCB_GET(*rd, 1), + RX_DCB_GET(*rd, 2), RX_DCB_GET(*rd, 3)); + } + + return SHR_E_NONE; +} + +/*! + * Dump Tx ring + */ +static int +cmicr_pdma_tx_ring_dump(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + volatile TX_DCB_t *td; + uint32_t di; + + CNET_INFO(hw->unit, "TX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", + txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); + for (di = 0; di < txq->nb_desc + 1; di++) { + td = &ring[di]; + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(txq->ring_addr + di * CMICR_PDMA_DCB_SIZE), + TX_DCB_GET(*td, 0), TX_DCB_GET(*td, 1), + TX_DCB_GET(*td, 2), TX_DCB_GET(*td, 3)); + } + + return SHR_E_NONE; +} + +/*! + * Fetch Tx vring + */ +static int +cmicr_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) +{ + struct pdma_dev *dev = hw->dev; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + struct pdma_tx_queue *vtxq = NULL; + volatile TX_DCB_t *vring = NULL; + uint32_t rm; + + vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; + vring = (volatile TX_DCB_t *)vtxq->ring; + if (!vring || !TX_DCB_BYTE_COUNTf_GET(vring[vtxq->curr])) { + return SHR_E_UNAVAIL; + } + + /* Fetch vring descriptor */ + rm = TX_DCB_DESC_REMAINf_GET(ring[txq->curr]); + TX_DCB_SET(ring[txq->curr], 0, TX_DCB_GET(vring[vtxq->curr], 0)); + TX_DCB_SET(ring[txq->curr], 1, TX_DCB_GET(vring[vtxq->curr], 1)); + TX_DCB_SET(ring[txq->curr], 2, TX_DCB_GET(vring[vtxq->curr], 2)); + TX_DCB_SET(ring[txq->curr], 3, TX_DCB_GET(vring[vtxq->curr], 3)); + TX_DCB_DESC_REMAINf_SET(ring[txq->curr], rm); + TX_DCB_BYTE_COUNTf_SET(vring[vtxq->curr], 0); + + MEMORY_BARRIER; + + pbuf->dma = TX_DCB_ADDR_LOf_GET(vring[vtxq->curr]); + pbuf->len = TX_DCB_BYTE_COUNTf_GET(ring[txq->curr]); + vtxq->curr = (vtxq->curr + 1) % vtxq->nb_desc; + + return SHR_E_NONE; +} + +/*! + * Check Tx ring + */ +static inline int +cmicr_pdma_tx_ring_check(struct pdma_hw *hw, struct pdma_tx_queue *txq) +{ + struct pdma_dev *dev = hw->dev; + + if (dev->suspended) { + txq->stats.xoffs++; + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); + return SHR_E_BUSY; + } + if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + return SHR_E_BUSY; + } + } + + if (cmicr_pdma_tx_ring_unused(txq)) { + return SHR_E_NONE; + } + + sal_spinlock_lock(txq->lock); + if (!cmicr_pdma_tx_ring_unused(txq)) { + txq->status |= PDMA_TX_QUEUE_XOFF; + txq->stats.xoffs++; + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); + } + sal_spinlock_unlock(txq->lock); + return SHR_E_BUSY; + } + sal_spinlock_unlock(txq->lock); + + return SHR_E_NONE; +} + +/*! + * \brief Start packet transmission + * + * \param [in] hw HW structure point. + * \param [in] txq Tx queue structure point. + * \param [in] buf Tx packet buffer. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +static int +cmicr_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) +{ + struct pdma_dev *dev = hw->dev; + struct pdma_buf_mngr *bm = (struct pdma_buf_mngr *)dev->ctrl.buf_mngr; + volatile TX_DCB_t *ring = (volatile TX_DCB_t *)txq->ring; + struct pdma_tx_buf *pbuf = NULL; + struct pkt_hdr *pkh = NULL; + dma_addr_t addr; + uint32_t curr; + int retry = 5000000; + int rv; + + if (dev->tx_suspend) { + sal_spinlock_lock(txq->mutex); + } else { + rv = sal_sem_take(txq->sem, BCMCNET_TX_RSRC_WAIT_USEC); + if (rv == -1) { + CNET_ERROR(hw->unit, "Timeout waiting for Tx resources\n"); + return SHR_E_TIMEOUT; + } + } + + /* Check Tx resource */ + if (dev->tx_suspend) { + /* Suspend Tx if no resource */ + rv = cmicr_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return rv; + } + } else { + /* Abort Tx if a fatal error happened */ + if (txq->status & PDMA_TX_QUEUE_XOFF) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + + /* Setup the new descriptor */ + curr = txq->curr; + pbuf = &txq->pbuf[curr]; + if (dev->mode == DEV_MODE_HNET && !buf) { + rv = cmicr_pdma_tx_vring_fetch(hw, txq, pbuf); + if (SHR_FAILURE(rv)) { + sal_spinlock_unlock(txq->mutex); + return SHR_E_EMPTY; + } + txq->state |= PDMA_TX_QUEUE_BUSY; + } else { + pbuf->adj = 1; + pkh = bm->tx_buf_get(dev, txq, pbuf, buf); + if (!pkh) { + txq->stats.dropped++; + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + return SHR_E_RESOURCE; + } + bm->tx_buf_dma(dev, txq, pbuf, &addr); + cmicr_tx_desc_config(&ring[curr], addr, pbuf->len, pkh->attrs); + } + + /* Notify HNET to process if needed */ + if (dev->mode == DEV_MODE_VNET) { + if (!TX_DCB_BYTE_COUNTf_GET(ring[(curr + txq->nb_desc - 1) % txq->nb_desc])) { + dev->xnet_wake(dev); + } + } + + /* Update the indicators */ + curr = (curr + 1) % txq->nb_desc; + txq->curr = curr; + + /* Start DMA if in chain mode */ + if (dev->flags & PDMA_CHAIN_MODE) { + if (txq->state & PDMA_TX_QUEUE_POLL) { + do { + rv = cmicr_pdma_tx_ring_clean(hw, txq, txq->nb_desc - 1); + if (rv != (int)txq->nb_desc - 1) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry < 0) { + CNET_ERROR(hw->unit, "Last Tx could not get done in given time\n"); + } + } + sal_spinlock_lock(txq->lock); + if (txq->dirt == txq->halt && txq->dirt != curr) { + hw->hdls.chan_stop(hw, txq->chan_id); + cmicr_tx_desc_chain(&ring[(curr + txq->nb_desc - 1) % txq->nb_desc], 0); + hw->hdls.chan_setup(hw, txq->chan_id, + txq->ring_addr + sizeof(TX_DCB_t) * txq->halt); + hw->hdls.chan_start(hw, txq->chan_id); + txq->halt = curr; + } + sal_spinlock_unlock(txq->lock); + } + + /* Kick off DMA */ + txq->halt_addr = txq->ring_addr + sizeof(TX_DCB_t) * curr; + hw->hdls.chan_goto(hw, txq->chan_id, txq->halt_addr); + + /* Count the packets/bytes */ + txq->stats.packets++; + txq->stats.bytes += pbuf->len; + + /* Clean up ring if in polling mode */ + if (txq->state & PDMA_TX_QUEUE_POLL && + cmicr_pdma_tx_ring_unused(txq) <= (int)txq->free_thresh) { + cmicr_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); + } + + /* Suspend Tx if no resource */ + rv = cmicr_pdma_tx_ring_check(hw, txq); + if (SHR_FAILURE(rv)) { + if (dev->mode == DEV_MODE_VNET) { + dev->xnet_wake(dev); + } + + if (txq->state & PDMA_TX_QUEUE_POLL) { + /* In polling mode, must wait till the ring is available */ + do { + cmicr_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); + if (!(txq->status & PDMA_TX_QUEUE_XOFF) || + !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { + break; + } + sal_usleep(1); + } while (retry--); + if (retry < 0) { + CNET_ERROR(hw->unit, "Fatal error: Tx ring is full, packets can not been transmitted\n"); + if (!dev->tx_suspend) { + sal_sem_give(txq->sem); + return SHR_E_RESOURCE; + } + } + } else { + /* In interrupt mode, the handle thread will wake up Tx */ + if (!dev->tx_suspend) { + return SHR_E_NONE; + } + } + } + + if (dev->tx_suspend) { + sal_spinlock_unlock(txq->mutex); + } else { + sal_sem_give(txq->sem); + } + + return SHR_E_NONE; +} + +/*! + * Suspend Rx queue + */ +static int +cmicr_pdma_rx_suspend(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + rxq->status |= PDMA_RX_QUEUE_XOFF; + if (hw->dev->flags & PDMA_CHAIN_MODE) { + hw->hdls.chan_stop(hw, rxq->chan_id); + } + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Resume Rx queue + */ +static int +cmicr_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) +{ + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + sal_spinlock_unlock(rxq->lock); + return SHR_E_NONE; + } + if (rxq->state & PDMA_RX_BATCH_REFILL) { + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } else if (rxq->halt == rxq->curr || (rxq->halt == rxq->nb_desc && rxq->curr == 0)) { + rxq->halt = (rxq->curr + 1) % rxq->nb_desc; + rxq->halt_addr = rxq->ring_addr + sizeof(RX_DCB_t) * rxq->halt; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + } + if (hw->dev->flags & PDMA_CHAIN_MODE) { + rxq->curr = 0; + hw->hdls.chan_start(hw, rxq->chan_id); + } + rxq->status &= ~PDMA_RX_QUEUE_XOFF; + sal_spinlock_unlock(rxq->lock); + + return SHR_E_NONE; +} + +/*! + * Initialize function pointers + */ +int +bcmcnet_cmicr_pdma_desc_ops_init(struct pdma_hw *hw) +{ + if (!hw) { + return SHR_E_PARAM; + } + + hw->dops.rx_desc_init = cmicr_pdma_rx_desc_init; + hw->dops.rx_desc_clean = cmicr_pdma_rx_desc_clean; + hw->dops.rx_ring_clean = cmicr_pdma_rx_ring_clean; + hw->dops.rx_ring_dump = cmicr_pdma_rx_ring_dump; + hw->dops.rx_suspend = cmicr_pdma_rx_suspend; + hw->dops.rx_resume = cmicr_pdma_rx_resume; + hw->dops.tx_desc_init = cmicr_pdma_tx_desc_init; + hw->dops.tx_desc_clean = cmicr_pdma_tx_desc_clean; + hw->dops.tx_ring_clean = cmicr_pdma_tx_ring_clean; + hw->dops.tx_ring_dump = cmicr_pdma_tx_ring_dump; + hw->dops.pkt_xmit = cmicr_pdma_pkt_xmit; + + return SHR_E_NONE; +} + +/*! + * Attach device driver + */ +int +bcmcnet_cmicr_pdma_driver_attach(struct pdma_dev *dev) +{ + struct pdma_hw *hw = NULL; + + /* Allocate memory for HW data */ + hw = sal_alloc(sizeof(*hw), "bcmcnetPdmaHw"); + if (!hw) { + return SHR_E_MEMORY; + } + sal_memset(hw, 0, sizeof(*hw)); + hw->unit = dev->unit; + hw->dev = dev; + dev->ctrl.hw = hw; + + bcmcnet_cmicr_pdma_hw_hdls_init(hw); + bcmcnet_cmicr_pdma_desc_ops_init(hw); + + return SHR_E_NONE; +} + +/*! + * Detach device driver + */ +int +bcmcnet_cmicr_pdma_driver_detach(struct pdma_dev *dev) +{ + if (dev->ctrl.hw) { + sal_free(dev->ctrl.hw); + } + dev->ctrl.hw = NULL; + + return SHR_E_NONE; +} diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c index 471e65f70682..f43dc9a3ed65 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_hw.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -59,6 +59,11 @@ cmicx_pdma_intr_enable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) { uint32_t reg, irq_mask; + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_unmask(hw->dev, cmc, chan, 0, 0); + return; + } + hw->dev->ctrl.grp[cmc].irq_mask |= mask; irq_mask = hw->dev->ctrl.grp[cmc].irq_mask; if (cmc == 0) { @@ -85,6 +90,11 @@ cmicx_pdma_intr_disable(struct pdma_hw *hw, int cmc, int chan, uint32_t mask) { uint32_t reg, irq_mask; + if (hw->dev->mode == DEV_MODE_UNET || hw->dev->mode == DEV_MODE_VNET) { + hw->dev->intr_mask(hw->dev, cmc, chan, 0, 0); + return; + } + hw->dev->ctrl.grp[cmc].irq_mask &= ~mask; irq_mask = hw->dev->ctrl.grp[cmc].irq_mask; if (cmc == 0) { @@ -480,61 +490,61 @@ cmicx_pdma_chan_reg_dump(struct pdma_hw *hw, int chan) que = chan % CMICX_PDMA_CMC_CHAN; hw->hdls.reg_rd32(hw, CMICX_PDMA_CTRL(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_CTRL: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CTRL: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_LO(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_LO: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_LO: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HI(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HI: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HI: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_CURR_DESC_LO(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_CURR_DESC_LO: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CURR_DESC_LO: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_CURR_DESC_HI(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_CURR_DESC_HI: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_CURR_DESC_HI: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HALT_LO(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_LO: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_LO: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_DESC_HALT_HI(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_HI: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_DESC_HALT_ADDR_HI: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_COS_CTRL_RX0(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_0: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_COS_CTRL_RX1(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_COS_CTRL_RX_1: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_INTR_COAL(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_INTR_COAL: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_RBUF_THRE(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_RXBUF_THRESHOLD_CONFIG: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_STAT(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_STAT: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_STAT: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_RX(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_TX(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_TXPKT: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_TXPKT: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_COUNT_RX_DROP(grp, que), &val); - CNET_PR("CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT_DROP: 0x%08x\n", grp, que, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_DMA_CH%d_PKT_COUNT_RXPKT_DROP: 0x%08x\n", grp, que, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_IRQ_STAT(grp), &val); - CNET_PR("CMIC_CMC%d_IRQ_STAT: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_IRQ_STAT: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICX_PDMA_IRQ_STAT_CLR(grp), &val); - CNET_PR("CMIC_CMC%d_IRQ_STAT_CLR: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_IRQ_STAT_CLR: 0x%08x\n", grp, val); val = hw->dev->ctrl.grp[grp].irq_mask; - CNET_PR("CMIC_CMC%d_IRQ_ENAB: 0x%08x\n", grp, val); + CNET_INFO(hw->unit, "CMIC_CMC%d_IRQ_ENAB: 0x%08x\n", grp, val); hw->hdls.reg_rd32(hw, CMICX_EP_TO_CPU_HEADER_SIZE, &val); - CNET_PR("CMIC_EP_TO_CPU_HEADER_SIZE: 0x%08x\n", val); + CNET_INFO(hw->unit, "CMIC_EP_TO_CPU_HEADER_SIZE: 0x%08x\n", val); return SHR_E_NONE; } diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c index 9ea7489b5471..0eaf26890e43 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/hmi/cmicx/bcmcnet_cmicx_pdma_rxtx.c @@ -38,7 +38,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -76,6 +76,8 @@ cmicx_rx_desc_config(struct cmicx_rx_desc *rd, uint64_t addr, uint32_t len) ctrl |= CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | CMICX_DESC_CTRL_LEN(len); rd->ctrl = ctrl; + + MEMORY_BARRIER; } /*! @@ -94,6 +96,8 @@ cmicx_tx_desc_config(struct cmicx_tx_desc *td, uint64_t addr, uint32_t len, uint ctrl |= CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | CMICX_DESC_CTRL_FLAGS(flags) | CMICX_DESC_CTRL_LEN(len); td->ctrl = ctrl; + + MEMORY_BARRIER; } /*! @@ -107,6 +111,8 @@ cmicx_rx_rldesc_config(struct cmicx_rx_desc *rd, uint64_t addr) rd->status = 0; rd->ctrl = CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | CMICX_DESC_CTRL_RELOAD; + + MEMORY_BARRIER; } /*! @@ -120,6 +126,8 @@ cmicx_tx_rldesc_config(struct cmicx_tx_desc *td, uint64_t addr) td->status = 0; td->ctrl = CMICX_DESC_CTRL_CNTLD_INTR | CMICX_DESC_CTRL_CHAIN | CMICX_DESC_CTRL_RELOAD; + + MEMORY_BARRIER; } /*! @@ -133,6 +141,8 @@ cmicx_rx_desc_chain(struct cmicx_rx_desc *rd, int chain) } else { rd->ctrl &= ~CMICX_DESC_CTRL_CHAIN; } + + MEMORY_BARRIER; } /*! @@ -146,6 +156,8 @@ cmicx_tx_desc_chain(struct cmicx_tx_desc *td, int chain) } else { td->ctrl &= ~CMICX_DESC_CTRL_CHAIN; } + + MEMORY_BARRIER; } /*! @@ -156,6 +168,8 @@ cmicx_rx_desc_remain(struct cmicx_rx_desc *rd, uint32_t rm) { rd->ctrl &= ~CMICX_DESC_CTRL_REMAIN(0xf); rd->ctrl |= CMICX_DESC_CTRL_REMAIN(rm); + + MEMORY_BARRIER; } /*! @@ -166,6 +180,8 @@ cmicx_tx_desc_remain(struct cmicx_tx_desc *td, uint32_t rm) { td->ctrl &= ~CMICX_DESC_CTRL_REMAIN(0xf); td->ctrl |= CMICX_DESC_CTRL_REMAIN(rm); + + MEMORY_BARRIER; } /*! @@ -175,9 +191,7 @@ static inline int cmicx_pdma_rx_ring_unused(struct pdma_rx_queue *rxq) { /* Leave one descriptor unused so as not to halt */ - return rxq->curr > rxq->halt ? - rxq->curr - rxq->halt - 1 : - rxq->nb_desc + rxq->curr - rxq->halt - 1; + return (rxq->nb_desc + rxq->curr - rxq->halt - 1) % rxq->nb_desc; } /*! @@ -187,9 +201,7 @@ static inline int cmicx_pdma_tx_ring_unused(struct pdma_tx_queue *txq) { /* Leave one descriptor unused so as not to halt */ - return txq->dirt > txq->curr ? - txq->dirt - txq->curr - 1 : - txq->nb_desc + txq->dirt - txq->curr - 1; + return (txq->nb_desc + txq->dirt - txq->curr - 1) % txq->nb_desc; } /*! @@ -227,9 +239,9 @@ cmicx_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicx_rx_rldesc_config(&ring[di], rxq->ring_addr); rxq->curr = 0; - rxq->halt = rxq->state & PDMA_RX_BATCH_REFILL ? 0 : rxq->nb_desc; + rxq->halt = rxq->nb_desc - 1; - rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * di; + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * rxq->halt; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); hw->hdls.chan_setup(hw, rxq->chan_id, rxq->ring_addr); @@ -243,7 +255,7 @@ cmicx_pdma_rx_desc_init(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicx_rx_desc_config(&ring[di], 0, 0); } - CNET_PR("RX: Failed to allocate mem\n"); + CNET_ERROR(hw->unit, "RX: Failed to allocate memory\n"); return SHR_E_MEMORY; } @@ -394,26 +406,22 @@ cmicx_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) int unused = cmicx_pdma_rx_ring_unused(rxq); dma_addr_t addr; uint32_t halt; - int retry; int rv; for (halt = rxq->halt; halt < rxq->halt + unused; halt++) { + if (ring[halt % rxq->nb_desc].addr_lo) { + continue; + } pbuf = &rxq->pbuf[halt % rxq->nb_desc]; /* Allocate a new pktbuf */ if (!bm->rx_buf_avail(dev, rxq, pbuf)) { - retry = 5000000; - do { - rv = bm->rx_buf_alloc(dev, rxq, pbuf); - if (SHR_SUCCESS(rv)) { - break; - } + rv = bm->rx_buf_alloc(dev, rxq, pbuf); + if (SHR_FAILURE(rv)) { rxq->stats.nomems++; - sal_usleep(1); - } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Rx buffer has not been allocated for 5 seconds\n"); rxq->halt = halt % rxq->nb_desc; - return rv; + CNET_ERROR(hw->unit, "Can not alloc RX buffer, %d DCBs not filled\n", + cmicx_pdma_rx_ring_unused(rxq)); + break; } } /* Setup the new descriptor */ @@ -423,10 +431,11 @@ cmicx_pdma_rx_ring_refill(struct pdma_hw *hw, struct pdma_rx_queue *rxq) cmicx_rx_desc_chain(&ring[halt % rxq->nb_desc], 0); } } + rxq->halt = halt % rxq->nb_desc; + /* Move forward */ sal_spinlock_lock(rxq->lock); - rxq->halt = halt % rxq->nb_desc; - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { /* Descriptor cherry pick */ rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * rxq->halt; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); @@ -462,28 +471,33 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg curr = rxq->curr; while (CMICX_DESC_STAT_DONE(ring[curr].status)) { - if (dev->mode == DEV_MODE_VNET && rxq->state & PDMA_RX_QUEUE_XOFF) { - break; - } - if (!(rxq->state & PDMA_RX_BATCH_REFILL) && - !(rxq->state & PDMA_RX_QUEUE_XOFF)) { - /* Descriptor cherry pick */ - rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * curr; - hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); - rxq->halt = curr; - } if (done == budget) { break; } + /* Move forward */ + if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { + sal_spinlock_lock(rxq->lock); + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { + /* Descriptor cherry pick */ + rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * curr; + hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); + rxq->halt = curr; + } + sal_spinlock_unlock(rxq->lock); + } + /* Get the current pktbuf to process */ pbuf = &rxq->pbuf[curr]; stat = ring[curr].status; len = CMICX_DESC_STAT_LEN(stat); pkh = bm->rx_buf_get(dev, rxq, pbuf, len); if (!pkh) { + CNET_ERROR(hw->unit, "RX buffer build failed, retry ...\n"); rxq->stats.nomems++; - return SHR_E_MEMORY; + /* Set busy state to retry */ + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; } /* Setup packet header */ @@ -525,24 +539,33 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Setup the new descriptor */ if (!(rxq->state & PDMA_RX_BATCH_REFILL)) { if (!bm->rx_buf_avail(dev, rxq, pbuf)) { - retry = 5000000; - do { + retry = 0; + while (1) { rv = bm->rx_buf_alloc(dev, rxq, pbuf); if (SHR_SUCCESS(rv)) { break; } rxq->stats.nomems++; - sal_usleep(1); - } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Rx buffer has not been allocated for 5 seconds\n"); - return done; + if (dev->mode == DEV_MODE_UNET || dev->mode == DEV_MODE_VNET) { + if (retry++ < 5000000) { + sal_usleep(1); + continue; + } + CNET_ERROR(hw->unit, "Fatal error: can not alloc RX buffer\n"); + } + rxq->state |= PDMA_RX_BATCH_REFILL; + rxq->free_thresh = 1; + cmicx_rx_desc_config(&ring[curr], 0, 0); + CNET_ERROR(hw->unit, "RX buffer alloc failed, try batch refilling later\n"); + break; } } - bm->rx_buf_dma(dev, rxq, pbuf, &addr); - cmicx_rx_desc_config(&ring[curr], addr, rxq->buf_size); - if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { - cmicx_rx_desc_chain(&ring[curr], 0); + if (pbuf->dma) { + bm->rx_buf_dma(dev, rxq, pbuf, &addr); + cmicx_rx_desc_config(&ring[curr], addr, rxq->buf_size); + if (dev->flags & PDMA_CHAIN_MODE && curr == rxq->nb_desc - 1) { + cmicx_rx_desc_chain(&ring[curr], 0); + } } } else { cmicx_rx_desc_config(&ring[curr], 0, 0); @@ -550,7 +573,6 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Notify HNET to process if needed */ if (dev->mode == DEV_MODE_VNET) { - MEMORY_BARRIER; if (ring[(curr + rxq->nb_desc - 1) % rxq->nb_desc].status) { dev->xnet_wake(dev); } @@ -559,7 +581,7 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Update the indicators */ if (!(rxq->state & PDMA_RX_BATCH_REFILL) && rxq->halt != curr) { sal_spinlock_lock(rxq->lock); - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { /* Descriptor cherry pick */ rxq->halt_addr = rxq->ring_addr + sizeof(struct cmicx_rx_desc) * curr; hw->hdls.chan_goto(hw, rxq->chan_id, rxq->halt_addr); @@ -575,10 +597,12 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg /* Restart DMA if in chain mode */ if (dev->flags & PDMA_CHAIN_MODE) { - if (curr == 0 && !(rxq->state & PDMA_RX_QUEUE_XOFF)) { + sal_spinlock_lock(rxq->lock); + if (curr == 0 && !(rxq->status & PDMA_RX_QUEUE_XOFF)) { hw->hdls.chan_stop(hw, rxq->chan_id); hw->hdls.chan_start(hw, rxq->chan_id); } + sal_spinlock_unlock(rxq->lock); } } @@ -593,12 +617,10 @@ cmicx_pdma_rx_ring_clean(struct pdma_hw *hw, struct pdma_rx_queue *rxq, int budg if (rxq->state & PDMA_RX_BATCH_REFILL && cmicx_pdma_rx_ring_unused(rxq) >= (int)rxq->free_thresh) { cmicx_pdma_rx_ring_refill(hw, rxq); - } - - /* Notify the other side to process */ - if (dev->mode == DEV_MODE_VNET || dev->mode == DEV_MODE_HNET) { - if (done) { - dev->xnet_wake(dev); + /* If no one filled, return budget and keep polling */ + if (cmicx_pdma_rx_ring_unused(rxq) == (int)(rxq->nb_desc - 1)) { + rxq->state |= PDMA_RX_QUEUE_BUSY; + return budget; } } @@ -705,16 +727,24 @@ cmicx_pdma_tx_ring_clean(struct pdma_hw *hw, struct pdma_tx_queue *txq, int budg sal_spinlock_unlock(txq->lock); } + /* Set busy state to avoid HW checking */ + if (done == budget) { + txq->state |= PDMA_TX_QUEUE_BUSY; + } + /* Resume Tx if any */ sal_spinlock_lock(txq->lock); - if (txq->state & PDMA_TX_QUEUE_XOFF && - txq->state & PDMA_TX_QUEUE_ACTIVE && - cmicx_pdma_tx_ring_unused(txq)) { - txq->state &= ~PDMA_TX_QUEUE_XOFF; - sal_spinlock_unlock(txq->lock); + if (txq->status & PDMA_TX_QUEUE_XOFF && cmicx_pdma_tx_ring_unused(txq)) { + txq->status &= ~PDMA_TX_QUEUE_XOFF; + if (dev->suspended) { + sal_spinlock_unlock(txq->lock); + return done; + } if (dev->tx_resume) { dev->tx_resume(dev, txq->queue_id); - } else if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + } + sal_spinlock_unlock(txq->lock); + if (!dev->tx_resume && !(txq->state & PDMA_TX_QUEUE_POLL)) { sal_sem_give(txq->sem); } return done; @@ -734,14 +764,14 @@ cmicx_pdma_rx_ring_dump(struct pdma_hw *hw, struct pdma_rx_queue *rxq) struct cmicx_rx_desc *rd; uint32_t di; - CNET_PR("\nRX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", - rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); - CNET_PR("----------------------------------------------------------------\n"); + CNET_INFO(hw->unit, "RX: queue=%d, chan=%d, curr=%d, halt=%d, halt@%p\n", + rxq->queue_id, rxq->chan_id, rxq->curr, rxq->halt, (void *)&ring[rxq->halt]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); for (di = 0; di < rxq->nb_desc + 1; di++) { rd = &ring[di]; - CNET_PR("DESC[%03d]: (%p)->%08x %08x %08x %08x\n", - di, (void *)(unsigned long)(rxq->ring_addr + di * CMICX_PDMA_DCB_SIZE), - rd->addr_lo, rd->addr_hi, rd->ctrl, rd->status); + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(rxq->ring_addr + di * CMICX_PDMA_DCB_SIZE), + rd->addr_lo, rd->addr_hi, rd->ctrl, rd->status); } return SHR_E_NONE; @@ -757,14 +787,14 @@ cmicx_pdma_tx_ring_dump(struct pdma_hw *hw, struct pdma_tx_queue *txq) struct cmicx_tx_desc *td; uint32_t di; - CNET_PR("\nTX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", - txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); - CNET_PR("----------------------------------------------------------------\n"); + CNET_INFO(hw->unit, "TX: queue=%d, chan=%d, curr=%d, dirt=%d, halt@%p\n", + txq->queue_id, txq->chan_id, txq->curr, txq->dirt, (void *)&ring[txq->curr]); + CNET_INFO(hw->unit, "----------------------------------------------------------------\n"); for (di = 0; di < txq->nb_desc + 1; di++) { td = &ring[di]; - CNET_PR("DESC[%03d]: (%p)->%08x %08x %08x %08x\n", - di, (void *)(unsigned long)(txq->ring_addr + di * CMICX_PDMA_DCB_SIZE), - td->addr_lo, td->addr_hi, td->ctrl, td->status); + CNET_INFO(hw->unit, "DESC[%03d]: (%p)->%08x %08x %08x %08x\n", + di, (void *)(unsigned long)(txq->ring_addr + di * CMICX_PDMA_DCB_SIZE), + td->addr_lo, td->addr_hi, td->ctrl, td->status); } return SHR_E_NONE; @@ -781,6 +811,7 @@ cmicx_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, struct cmicx_tx_desc *ring = (struct cmicx_tx_desc *)txq->ring; struct pdma_tx_queue *vtxq = NULL; struct cmicx_tx_desc *vring = NULL; + uint32_t rm; vtxq = (struct pdma_tx_queue *)dev->ctrl.vnet_txq[txq->queue_id]; vring = (struct cmicx_tx_desc *)vtxq->ring; @@ -789,7 +820,10 @@ cmicx_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, } /* Fetch vring descriptor */ + rm = ring[txq->curr].ctrl & CMICX_DESC_CTRL_REMAIN(0xf); sal_memcpy(&ring[txq->curr], &vring[vtxq->curr], sizeof(struct cmicx_tx_desc)); + ring[txq->curr].ctrl &= ~CMICX_DESC_CTRL_REMAIN(0xf); + ring[txq->curr].ctrl |= rm; vring[vtxq->curr].ctrl &= ~CMICX_DESC_CTRL_LEN(-1); MEMORY_BARRIER; @@ -807,18 +841,31 @@ cmicx_pdma_tx_vring_fetch(struct pdma_hw *hw, struct pdma_tx_queue *txq, static inline int cmicx_pdma_tx_ring_check(struct pdma_hw *hw, struct pdma_tx_queue *txq) { + struct pdma_dev *dev = hw->dev; + + if (dev->suspended) { + txq->stats.xoffs++; + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); + return SHR_E_BUSY; + } + if (!(txq->state & PDMA_TX_QUEUE_POLL)) { + return SHR_E_BUSY; + } + } + if (cmicx_pdma_tx_ring_unused(txq)) { return SHR_E_NONE; } sal_spinlock_lock(txq->lock); if (!cmicx_pdma_tx_ring_unused(txq)) { - txq->state |= PDMA_TX_QUEUE_XOFF; + txq->status |= PDMA_TX_QUEUE_XOFF; txq->stats.xoffs++; - sal_spinlock_unlock(txq->lock); - if (hw->dev->tx_suspend) { - hw->dev->tx_suspend(hw->dev, txq->queue_id); + if (dev->tx_suspend) { + dev->tx_suspend(dev, txq->queue_id); } + sal_spinlock_unlock(txq->lock); return SHR_E_BUSY; } sal_spinlock_unlock(txq->lock); @@ -854,7 +901,7 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } else { rv = sal_sem_take(txq->sem, BCMCNET_TX_RSRC_WAIT_USEC); if (rv == -1) { - CNET_PR("Timeout waiting for Tx resources\n"); + CNET_ERROR(hw->unit, "Timeout waiting for Tx resources\n"); return SHR_E_TIMEOUT; } } @@ -869,7 +916,7 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } } else { /* Abort Tx if a fatal error happened */ - if (txq->state & PDMA_TX_QUEUE_XOFF) { + if (txq->status & PDMA_TX_QUEUE_XOFF) { sal_sem_give(txq->sem); return SHR_E_RESOURCE; } @@ -884,6 +931,7 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) sal_spinlock_unlock(txq->mutex); return SHR_E_EMPTY; } + txq->state |= PDMA_TX_QUEUE_BUSY; } else { pbuf->adj = 1; pkh = bm->tx_buf_get(dev, txq, pbuf, buf); @@ -894,7 +942,7 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } else { sal_sem_give(txq->sem); } - return SHR_E_NONE; + return SHR_E_RESOURCE; } bm->tx_buf_dma(dev, txq, pbuf, &addr); flags |= pkh->attrs & PDMA_TX_HIGIG_PKT ? CMICX_DESC_TX_HIGIG_PKT : 0; @@ -904,7 +952,6 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) /* Notify HNET to process if needed */ if (dev->mode == DEV_MODE_VNET) { - MEMORY_BARRIER; if (!CMICX_DESC_CTRL_LEN(ring[(curr + txq->nb_desc - 1) % txq->nb_desc].ctrl)) { dev->xnet_wake(dev); } @@ -924,8 +971,8 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) } sal_usleep(1); } while (retry--); - if (retry <= 0) { - CNET_PR("Last Tx could not be done in given time\n"); + if (retry < 0) { + CNET_ERROR(hw->unit, "Last Tx could not get done in given time\n"); } } sal_spinlock_lock(txq->lock); @@ -951,7 +998,7 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) /* Clean up ring if in polling mode */ if (txq->state & PDMA_TX_QUEUE_POLL && cmicx_pdma_tx_ring_unused(txq) <= (int)txq->free_thresh) { - cmicx_pdma_tx_ring_clean(hw, txq, txq->nb_desc - txq->free_thresh); + cmicx_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); } /* Suspend Tx if no resource */ @@ -964,15 +1011,15 @@ cmicx_pdma_pkt_xmit(struct pdma_hw *hw, struct pdma_tx_queue *txq, void *buf) if (txq->state & PDMA_TX_QUEUE_POLL) { /* In polling mode, must wait till the ring is available */ do { - cmicx_pdma_tx_ring_clean(hw, txq, txq->free_thresh); - if (!(txq->state & PDMA_TX_QUEUE_XOFF) || + cmicx_pdma_tx_ring_clean(hw, txq, dev->ctrl.budget); + if (!(txq->status & PDMA_TX_QUEUE_XOFF) || !(txq->state & PDMA_TX_QUEUE_ACTIVE)) { break; } sal_usleep(1); } while (retry--); - if (retry <= 0) { - CNET_PR("Fatal error: Tx ring is full, packets have not been transmitted for 5 seconds\n"); + if (retry < 0) { + CNET_ERROR(hw->unit, "Fatal error: Tx ring is full, packets can not been transmitted\n"); if (!dev->tx_suspend) { sal_sem_give(txq->sem); return SHR_E_RESOURCE; @@ -1002,7 +1049,7 @@ static int cmicx_pdma_rx_suspend(struct pdma_hw *hw, struct pdma_rx_queue *rxq) { sal_spinlock_lock(rxq->lock); - rxq->state |= PDMA_RX_QUEUE_XOFF; + rxq->status |= PDMA_RX_QUEUE_XOFF; if (hw->dev->flags & PDMA_CHAIN_MODE) { hw->hdls.chan_stop(hw, rxq->chan_id); } @@ -1018,7 +1065,7 @@ static int cmicx_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) { sal_spinlock_lock(rxq->lock); - if (!(rxq->state & PDMA_RX_QUEUE_XOFF)) { + if (!(rxq->status & PDMA_RX_QUEUE_XOFF)) { sal_spinlock_unlock(rxq->lock); return SHR_E_NONE; } @@ -1034,7 +1081,7 @@ cmicx_pdma_rx_resume(struct pdma_hw *hw, struct pdma_rx_queue *rxq) rxq->curr = 0; hw->hdls.chan_start(hw, rxq->chan_id); } - rxq->state &= ~PDMA_RX_QUEUE_XOFF; + rxq->status &= ~PDMA_RX_QUEUE_XOFF; sal_spinlock_unlock(rxq->lock); return SHR_E_NONE; diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h index 3e6ccd035c0f..1811ca44c33c 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr.h new file mode 100644 index 000000000000..6f74d7fb1895 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr.h @@ -0,0 +1,199 @@ +/*! \file bcmcnet_cmicr.h + * + * CMICr registers and descriptors definitions. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_CMICR_H +#define BCMCNET_CMICR_H + +#include + +/*! + * \name CMICR PDMA HW definitions + */ +/*! \{ */ +/*! CMICR CMC number */ +#define CMICR_PDMA_CMC_MAX 2 +/*! CMICR CMC PDMA channels */ +#define CMICR_PDMA_CMC_CHAN 16 +/*! CMICR PDMA DCB size */ +#define CMICR_PDMA_DCB_SIZE RX_DCB_SIZE +/*! \} */ + +/*! + * \name CMICR PCIe device address definitions + */ +/*! \{ */ +/*! CMICR PCIE offset */ +#define CMICR_PCIE_SO_OFFSET 0x10000000 +/*! Higher DMA address to bus address */ +#define DMA_TO_BUS_HI(dma) ((dma) | CMICR_PCIE_SO_OFFSET) +/*! Higher bus address to DMA address */ +#define BUS_TO_DMA_HI(bus) ((bus) & ~CMICR_PCIE_SO_OFFSET) +/*! \} */ + + +/*! \} */ +/*! + * \name CMICR PDMA register address + */ +/*! \{ */ +/*! Base address */ +#define CMICR_GRP_BASE(g) (0x00000000 + 0x2000 * g) +/*! Control register address */ +#define CMICR_PDMA_CTRL(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_CTRLr_OFFSET + q * 0x80) +/*! Descriptor Address Lower register address */ +#define CMICR_PDMA_DESC_LO(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_ADDR_LOr_OFFSET + q * 0x80) +/*! Descriptor Address Higher register address */ +#define CMICR_PDMA_DESC_HI(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_ADDR_HIr_OFFSET + q * 0x80) +/*! Descriptor Halt Address Lower register address */ +#define CMICR_PDMA_DESC_HALT_LO(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_OFFSET + q * 0x80) +/*! Descriptor Halt Address Higher register address */ +#define CMICR_PDMA_DESC_HALT_HI(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_OFFSET + q * 0x80) +/*! Status register address */ +#define CMICR_PDMA_STAT(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_STATr_OFFSET + q * 0x80) +/*! Interrupt status register address */ +#define CMICR_PDMA_INTR_STAT(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_INTRr_OFFSET + q * 0x80) +/*! Interrupt enable register address */ +#define CMICR_PDMA_INTR_ENAB(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_INTR_ENABLEr_OFFSET + q * 0x80) +/*! Interrupt clear register address */ +#define CMICR_PDMA_INTR_CLR(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_INTR_CLRr_OFFSET + q * 0x80) +/*! COS Control Rx0 register address */ +#define CMICR_PDMA_COS_CTRL_RX0(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_OFFSET + q * 0x80) +/*! COS Control Rx1 register address */ +#define CMICR_PDMA_COS_CTRL_RX1(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_OFFSET + q * 0x80) +/*! Interrupt Coalesce register address */ +#define CMICR_PDMA_INTR_COAL(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_INTR_COALr_OFFSET + q * 0x80) +/*! Current Descriptor Address Lower register address */ +#define CMICR_PDMA_CURR_DESC_LO(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_CURR_DESC_LOr_OFFSET + q * 0x80) +/*! Current Descriptor Address Higher register address */ +#define CMICR_PDMA_CURR_DESC_HI(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_CURR_DESC_HIr_OFFSET + q * 0x80) +/*! Rx Buffer Threshhold register address */ +#define CMICR_PDMA_RBUF_THRE(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_OFFSET + q * 0x80) +/*! Debug Control register address */ +#define CMICR_PDMA_DEBUG_CTRL(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DEBUG_CONTROLr_OFFSET + q * 0x80) +/*! Debug State Machine Status register address */ +#define CMICR_PDMA_DEBUG_SM_STAT(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_OFFSET + q * 0x80) +/*! Debug Status register address */ +#define CMICR_PDMA_DEBUG_STAT(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DEBUG_STATUSr_OFFSET + q * 0x80) +/*! Rx Packet Count register address */ +#define CMICR_PDMA_COUNT_RX(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_OFFSET + q * 0x80) +/*! Tx Packet Count register address */ +#define CMICR_PDMA_COUNT_TX(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_OFFSET + q * 0x80) +/*! Dropped Rx Packet Count register address */ +#define CMICR_PDMA_COUNT_RX_DROP(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_OFFSET + q * 0x80) +/*! Requested Descriptor Count register address */ +#define CMICR_PDMA_DESC_CNT_REQ(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_COUNT_REQr_OFFSET + q * 0x80) +/*! Received Descriptor Count register address */ +#define CMICR_PDMA_DESC_CNT_RX(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_COUNT_RXr_OFFSET + q * 0x80) +/*! Updated Descriptor Count register address */ +#define CMICR_PDMA_DESC_CNT_STAT(g, q) (CMICR_GRP_BASE(g) + CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_OFFSET + q * 0x80) +/*! EP_TO_CPU Header Size register address */ +#define CMICR_EP_TO_CPU_HEADER_SIZE CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_OFFSET +/*! Top config register address */ +#define CMICR_TOP_CONFIG CMIC_TOP_CONFIGr_OFFSET +/*! iProc interrupt enable set register address0 */ +#define PAXB_PDMA_IRQ_ENAB_SET0 PAXB_0_INTC_SET_INTR_ENABLE_REG5r_OFFSET +/*! iProc interrupt enable set register address1 */ +#define PAXB_PDMA_IRQ_ENAB_SET1 PAXB_0_INTC_SET_INTR_ENABLE_REG6r_OFFSET +/*! iProc interrupt enable clear register address0 */ +#define PAXB_PDMA_IRQ_ENAB_CLR0 PAXB_0_INTC_CLEAR_INTR_ENABLE_REG5r_OFFSET +/*! iProc interrupt enable clear register address1 */ +#define PAXB_PDMA_IRQ_ENAB_CLR1 PAXB_0_INTC_CLEAR_INTR_ENABLE_REG6r_OFFSET +/*! \} */ + +/*! + * \name Interrupt status & clear register definitions + */ +/*! \{ */ +/*! Interrupt mask shift */ +#define CMICR_IRQ_MASK_SHIFT 8 +/*! \} */ + +/*! 32-bit register read */ +#define DEV_READ32(_c, _a, _p) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + *(_p) = ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4]; \ + } \ + } while (0) + +/*! 32-bit register write */ +#define DEV_WRITE32(_c, _a, _v) \ + do { \ + if ((_c)->dev->mode != DEV_MODE_VNET) { \ + ((volatile uint32_t *)(_c)->hw_addr)[(_a) / 4] = (_v); \ + } \ + } while (0) + +/*! Tx packet header size */ +#define CMICR_TX_PKT_HDR_SIZE 16 + +/*! HW access retry times */ +#define CMICR_HW_RETRY_TIMES 100000 + +/*! Max remaining descriptors */ +#define CMICR_DESC_REMAIN_MAX 8 + +/*! + * \brief Initialize HW handles. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicr_pdma_hw_hdls_init(struct pdma_hw *hw); + +/*! + * \brief Initialize descriptor operations. + * + * \param [in] hw HW structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicr_pdma_desc_ops_init(struct pdma_hw *hw); + +/*! + * \brief Attach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicr_pdma_driver_attach(struct pdma_dev *dev); + +/*! + * \brief Detach device driver. + * + * \param [in] dev Device structure point. + * + * \retval SHR_E_NONE No errors. + * \retval SHR_E_XXXX Operation failed. + */ +extern int +bcmcnet_cmicr_pdma_driver_detach(struct pdma_dev *dev); + +#endif /* BCMCNET_CMICR_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr_acc.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr_acc.h new file mode 100644 index 000000000000..9bd736d5694d --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicr_acc.h @@ -0,0 +1,791 @@ +/*! \file bcmcnet_cmicr_acc.h + * + * CMICr PDMA registers and descriptors access macros extracted from: + * bcmbd/include/bcmbd/bcmbd_cmicr_acc.h + * bcmbd/include/bcmbd/bcmbd_cmicr_intr.h + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMCNET_CMICR_ACC_H +#define BCMCNET_CMICR_ACC_H + +#define IPROC_IRQ_BASE5 (5 * 32) +#define IPROC_IRQ_BASE6 (6 * 32) +#define CMICR_IRQ_CMC0_PKTDMA_CH0_INTR (IPROC_IRQ_BASE5 + 8) +#define CMICR_IRQ_CMC0_PKTDMA_CH1_INTR (IPROC_IRQ_BASE5 + 9) +#define CMICR_IRQ_CMC0_PKTDMA_CH2_INTR (IPROC_IRQ_BASE5 + 10) +#define CMICR_IRQ_CMC0_PKTDMA_CH3_INTR (IPROC_IRQ_BASE5 + 11) +#define CMICR_IRQ_CMC0_PKTDMA_CH4_INTR (IPROC_IRQ_BASE5 + 12) +#define CMICR_IRQ_CMC0_PKTDMA_CH5_INTR (IPROC_IRQ_BASE5 + 13) +#define CMICR_IRQ_CMC0_PKTDMA_CH6_INTR (IPROC_IRQ_BASE5 + 14) +#define CMICR_IRQ_CMC0_PKTDMA_CH7_INTR (IPROC_IRQ_BASE5 + 15) +#define CMICR_IRQ_CMC0_PKTDMA_CH8_INTR (IPROC_IRQ_BASE5 + 16) +#define CMICR_IRQ_CMC0_PKTDMA_CH9_INTR (IPROC_IRQ_BASE5 + 17) +#define CMICR_IRQ_CMC0_PKTDMA_CH10_INTR (IPROC_IRQ_BASE5 + 18) +#define CMICR_IRQ_CMC0_PKTDMA_CH11_INTR (IPROC_IRQ_BASE5 + 19) +#define CMICR_IRQ_CMC0_PKTDMA_CH12_INTR (IPROC_IRQ_BASE5 + 20) +#define CMICR_IRQ_CMC0_PKTDMA_CH13_INTR (IPROC_IRQ_BASE5 + 21) +#define CMICR_IRQ_CMC0_PKTDMA_CH14_INTR (IPROC_IRQ_BASE5 + 22) +#define CMICR_IRQ_CMC0_PKTDMA_CH15_INTR (IPROC_IRQ_BASE5 + 23) +#define CMICR_IRQ_CMC1_PKTDMA_CH0_INTR (IPROC_IRQ_BASE5 + 24) +#define CMICR_IRQ_CMC1_PKTDMA_CH1_INTR (IPROC_IRQ_BASE5 + 25) +#define CMICR_IRQ_CMC1_PKTDMA_CH2_INTR (IPROC_IRQ_BASE5 + 26) +#define CMICR_IRQ_CMC1_PKTDMA_CH3_INTR (IPROC_IRQ_BASE5 + 27) +#define CMICR_IRQ_CMC1_PKTDMA_CH4_INTR (IPROC_IRQ_BASE5 + 28) +#define CMICR_IRQ_CMC1_PKTDMA_CH5_INTR (IPROC_IRQ_BASE5 + 29) +#define CMICR_IRQ_CMC1_PKTDMA_CH6_INTR (IPROC_IRQ_BASE5 + 30) +#define CMICR_IRQ_CMC1_PKTDMA_CH7_INTR (IPROC_IRQ_BASE5 + 31) +#define CMICR_IRQ_CMC1_PKTDMA_CH8_INTR (IPROC_IRQ_BASE6 + 0) +#define CMICR_IRQ_CMC1_PKTDMA_CH9_INTR (IPROC_IRQ_BASE6 + 1) +#define CMICR_IRQ_CMC1_PKTDMA_CH10_INTR (IPROC_IRQ_BASE6 + 2) +#define CMICR_IRQ_CMC1_PKTDMA_CH11_INTR (IPROC_IRQ_BASE6 + 3) +#define CMICR_IRQ_CMC1_PKTDMA_CH12_INTR (IPROC_IRQ_BASE6 + 4) +#define CMICR_IRQ_CMC1_PKTDMA_CH13_INTR (IPROC_IRQ_BASE6 + 5) +#define CMICR_IRQ_CMC1_PKTDMA_CH14_INTR (IPROC_IRQ_BASE6 + 6) +#define CMICR_IRQ_CMC1_PKTDMA_CH15_INTR (IPROC_IRQ_BASE6 + 7) + +#define PAXB_0_INTC_SET_INTR_ENABLE_REG5r_OFFSET 0x0292d114 +#define PAXB_0_INTC_SET_INTR_ENABLE_REG6r_OFFSET 0x0292d118 +#define PAXB_0_INTC_CLEAR_INTR_ENABLE_REG5r_OFFSET 0x0292d13c +#define PAXB_0_INTC_CLEAR_INTR_ENABLE_REG6r_OFFSET 0x0292d140 + +/* + * This structure should be used to declare and program CMIC_TOP_CONFIG. + * + */ +typedef union CMIC_TOP_CONFIGr_s { + uint32_t v[1]; + uint32_t cmic_top_config[1]; + uint32_t _cmic_top_config; +} CMIC_TOP_CONFIGr_t; + +#define CMIC_TOP_CONFIGr_CLR(r) (r).cmic_top_config[0] = 0 +#define CMIC_TOP_CONFIGr_SET(r,d) (r).cmic_top_config[0] = d +#define CMIC_TOP_CONFIGr_GET(r) (r).cmic_top_config[0] +#define CMIC_TOP_CONFIGr_OFFSET 0x0000000c +#define CMIC_TOP_CONFIGr_IP_2_EP_LOOPBACK_ENABLEf_GET(r) ((((r).cmic_top_config[0]) >> 1) & 0x1) +#define CMIC_TOP_CONFIGr_IP_2_EP_LOOPBACK_ENABLEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_TOP_CONFIGr_CMC0_CLK_ENf_GET(r) ((((r).cmic_top_config[0]) >> 2) & 0x1) +#define CMIC_TOP_CONFIGr_CMC0_CLK_ENf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_TOP_CONFIGr_CMC1_CLK_ENf_GET(r) ((((r).cmic_top_config[0]) >> 3) & 0x1) +#define CMIC_TOP_CONFIGr_CMC1_CLK_ENf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define CMIC_TOP_CONFIGr_COMMON_POOL_CLK_ENf_GET(r) ((((r).cmic_top_config[0]) >> 4) & 0x1) +#define CMIC_TOP_CONFIGr_COMMON_POOL_CLK_ENf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 4)) | ((((uint32_t)f) & 0x1) << 4)) +#define CMIC_TOP_CONFIGr_RPE_CLK_ENf_GET(r) ((((r).cmic_top_config[0]) >> 5) & 0x1) +#define CMIC_TOP_CONFIGr_RPE_CLK_ENf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 5)) | ((((uint32_t)f) & 0x1) << 5)) +#define CMIC_TOP_CONFIGr_IP_INTERFACE_PAYLOAD_ENDIANESSf_GET(r) ((((r).cmic_top_config[0]) >> 6) & 0x1) +#define CMIC_TOP_CONFIGr_IP_INTERFACE_PAYLOAD_ENDIANESSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 6)) | ((((uint32_t)f) & 0x1) << 6)) +#define CMIC_TOP_CONFIGr_IP_INTERFACE_HEADER_ENDIANESSf_GET(r) ((((r).cmic_top_config[0]) >> 7) & 0x1) +#define CMIC_TOP_CONFIGr_IP_INTERFACE_HEADER_ENDIANESSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 7)) | ((((uint32_t)f) & 0x1) << 7)) +#define CMIC_TOP_CONFIGr_EP_INTERFACE_PAYLOAD_ENDIANESSf_GET(r) ((((r).cmic_top_config[0]) >> 8) & 0x1) +#define CMIC_TOP_CONFIGr_EP_INTERFACE_PAYLOAD_ENDIANESSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 8)) | ((((uint32_t)f) & 0x1) << 8)) +#define CMIC_TOP_CONFIGr_EP_INTERFACE_HEADER_ENDIANESSf_GET(r) ((((r).cmic_top_config[0]) >> 9) & 0x1) +#define CMIC_TOP_CONFIGr_EP_INTERFACE_HEADER_ENDIANESSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 9)) | ((((uint32_t)f) & 0x1) << 9)) +#define CMIC_TOP_CONFIGr_CLEAR_ON_READ_ENABLEf_GET(r) ((((r).cmic_top_config[0]) >> 10) & 0x1) +#define CMIC_TOP_CONFIGr_CLEAR_ON_READ_ENABLEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 10)) | ((((uint32_t)f) & 0x1) << 10)) +#define CMIC_TOP_CONFIGr_SATURATE_ENABLEf_GET(r) ((((r).cmic_top_config[0]) >> 11) & 0x1) +#define CMIC_TOP_CONFIGr_SATURATE_ENABLEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 11)) | ((((uint32_t)f) & 0x1) << 11)) +#define CMIC_TOP_CONFIGr_CLEAR_CMC0_COUNTERSf_GET(r) ((((r).cmic_top_config[0]) >> 12) & 0x1) +#define CMIC_TOP_CONFIGr_CLEAR_CMC0_COUNTERSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 12)) | ((((uint32_t)f) & 0x1) << 12)) +#define CMIC_TOP_CONFIGr_CLEAR_CMC1_COUNTERSf_GET(r) ((((r).cmic_top_config[0]) >> 13) & 0x1) +#define CMIC_TOP_CONFIGr_CLEAR_CMC1_COUNTERSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 13)) | ((((uint32_t)f) & 0x1) << 13)) +#define CMIC_TOP_CONFIGr_CLEAR_RPE_COUNTERSf_GET(r) ((((r).cmic_top_config[0]) >> 14) & 0x1) +#define CMIC_TOP_CONFIGr_CLEAR_RPE_COUNTERSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 14)) | ((((uint32_t)f) & 0x1) << 14)) +#define CMIC_TOP_CONFIGr_CLEAR_TOP_COUNTERSf_GET(r) ((((r).cmic_top_config[0]) >> 15) & 0x1) +#define CMIC_TOP_CONFIGr_CLEAR_TOP_COUNTERSf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 15)) | ((((uint32_t)f) & 0x1) << 15)) +#define CMIC_TOP_CONFIGr_RPE_PIPE_MAPf_GET(r) ((((r).cmic_top_config[0]) >> 16) & 0x1) +#define CMIC_TOP_CONFIGr_RPE_PIPE_MAPf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 16)) | ((((uint32_t)f) & 0x1) << 16)) +#define CMIC_TOP_CONFIGr_SBUS_RING_ARB_CUT_THROUGH_MODE_ENABLEf_GET(r) ((((r).cmic_top_config[0]) >> 17) & 0x1) +#define CMIC_TOP_CONFIGr_SBUS_RING_ARB_CUT_THROUGH_MODE_ENABLEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 17)) | ((((uint32_t)f) & 0x1) << 17)) +#define CMIC_TOP_CONFIGr_IP_ARB_QUANTA_SELf_GET(r) ((((r).cmic_top_config[0]) >> 18) & 0x3) +#define CMIC_TOP_CONFIGr_IP_ARB_QUANTA_SELf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x3 << 18)) | ((((uint32_t)f) & 0x3) << 18)) +#define CMIC_TOP_CONFIGr_ENABLE_CMIC_RST_AFTER_SW_IF_PURGEf_GET(r) ((((r).cmic_top_config[0]) >> 20) & 0x1) +#define CMIC_TOP_CONFIGr_ENABLE_CMIC_RST_AFTER_SW_IF_PURGEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 20)) | ((((uint32_t)f) & 0x1) << 20)) +#define CMIC_TOP_CONFIGr_COS_MASK_OVERRIDEf_GET(r) ((((r).cmic_top_config[0]) >> 21) & 0x1) +#define CMIC_TOP_CONFIGr_COS_MASK_OVERRIDEf_SET(r,f) (r).cmic_top_config[0]=(((r).cmic_top_config[0] & ~((uint32_t)0x1 << 21)) | ((((uint32_t)f) & 0x1) << 21)) +#define READ_CMIC_TOP_CONFIGr(u,r) BCMDRD_DEV_READ32(u,CMIC_TOP_CONFIGr_OFFSET,r._cmic_top_config) +#define WRITE_CMIC_TOP_CONFIGr(u,r) BCMDRD_DEV_WRITE32(u,CMIC_TOP_CONFIGr_OFFSET,r._cmic_top_config) + +/* + * This structure should be used to declare and program CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZE. + * + */ +typedef union CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_s { + uint32_t v[1]; + uint32_t cmic_top_status_ep_to_cpu_header_size[1]; + uint32_t _cmic_top_status_ep_to_cpu_header_size; +} CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_t; + +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_CLR(r) (r).cmic_top_status_ep_to_cpu_header_size[0] = 0 +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_SET(r,d) (r).cmic_top_status_ep_to_cpu_header_size[0] = d +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_GET(r) (r).cmic_top_status_ep_to_cpu_header_size[0] +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_OFFSET 0x00000004 +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_EP_TO_CPU_HEADER_SIZEf_GET(r) (((r).cmic_top_status_ep_to_cpu_header_size[0]) & 0xf) +#define CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_EP_TO_CPU_HEADER_SIZEf_SET(r,f) (r).cmic_top_status_ep_to_cpu_header_size[0]=(((r).cmic_top_status_ep_to_cpu_header_size[0] & ~((uint32_t)0xf)) | (((uint32_t)f) & 0xf)) +#define READ_CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr(u,r) BCMDRD_DEV_READ32(u,CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_OFFSET,r._cmic_top_status_ep_to_cpu_header_size) +#define WRITE_CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr(u,r) BCMDRD_DEV_WRITE32(u,CMIC_TOP_STATUS_EP_TO_CPU_HEADER_SIZEr_OFFSET,r._cmic_top_status_ep_to_cpu_header_size) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_COS_CTRL_RX_0. + * + */ +typedef union CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_cos_ctrl_rx_0[1]; + uint32_t _cmic_cmc_pktdma_cos_ctrl_rx_0; +} CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_t; + +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_CLR(r) (r).cmic_cmc_pktdma_cos_ctrl_rx_0[0] = 0 +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_SET(r,d) (r).cmic_cmc_pktdma_cos_ctrl_rx_0[0] = d +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_GET(r) (r).cmic_cmc_pktdma_cos_ctrl_rx_0[0] +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_OFFSET 0x00003124 +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_COS_BMPf_GET(r) ((r).cmic_cmc_pktdma_cos_ctrl_rx_0[0]) +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_COS_BMPf_SET(r,f) (r).cmic_cmc_pktdma_cos_ctrl_rx_0[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_COS_CTRL_RX_0r(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_cos_ctrl_rx_0) +#define WRITE_CMIC_CMC_PKTDMA_COS_CTRL_RX_0r(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_COS_CTRL_RX_0r_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_cos_ctrl_rx_0) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_COS_CTRL_RX_1. + * + */ +typedef union CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_cos_ctrl_rx_1[1]; + uint32_t _cmic_cmc_pktdma_cos_ctrl_rx_1; +} CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_t; + +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_CLR(r) (r).cmic_cmc_pktdma_cos_ctrl_rx_1[0] = 0 +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_SET(r,d) (r).cmic_cmc_pktdma_cos_ctrl_rx_1[0] = d +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_GET(r) (r).cmic_cmc_pktdma_cos_ctrl_rx_1[0] +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_OFFSET 0x00003128 +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_COS_BMPf_GET(r) ((r).cmic_cmc_pktdma_cos_ctrl_rx_1[0]) +#define CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_COS_BMPf_SET(r,f) (r).cmic_cmc_pktdma_cos_ctrl_rx_1[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_COS_CTRL_RX_1r(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_cos_ctrl_rx_1) +#define WRITE_CMIC_CMC_PKTDMA_COS_CTRL_RX_1r(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_COS_CTRL_RX_1r_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_cos_ctrl_rx_1) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_CTRL. + * + */ +typedef union CMIC_CMC_PKTDMA_CTRLr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_ctrl[1]; + uint32_t _cmic_cmc_pktdma_ctrl; +} CMIC_CMC_PKTDMA_CTRLr_t; + +#define CMIC_CMC_PKTDMA_CTRLr_CLR(r) (r).cmic_cmc_pktdma_ctrl[0] = 0 +#define CMIC_CMC_PKTDMA_CTRLr_SET(r,d) (r).cmic_cmc_pktdma_ctrl[0] = d +#define CMIC_CMC_PKTDMA_CTRLr_GET(r) (r).cmic_cmc_pktdma_ctrl[0] +#define CMIC_CMC_PKTDMA_CTRLr_OFFSET 0x00003100 +#define CMIC_CMC_PKTDMA_CTRLr_DIRECTIONf_GET(r) (((r).cmic_cmc_pktdma_ctrl[0]) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DIRECTIONf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1)) | (((uint32_t)f) & 0x1)) +#define CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 1) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DMA_ENf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_CMC_PKTDMA_CTRLr_ABORT_DMAf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 2) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_ABORT_DMAf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_CMC_PKTDMA_CTRLr_PKTDMA_ENDIANESSf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 3) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_PKTDMA_ENDIANESSf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define CMIC_CMC_PKTDMA_CTRLr_DESC_ENDIANESSf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 4) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DESC_ENDIANESSf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 4)) | ((((uint32_t)f) & 0x1) << 4)) +#define CMIC_CMC_PKTDMA_CTRLr_DROP_RX_PKT_ON_CHAIN_ENDf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 5) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DROP_RX_PKT_ON_CHAIN_ENDf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 5)) | ((((uint32_t)f) & 0x1) << 5)) +#define CMIC_CMC_PKTDMA_CTRLr_RLD_STS_UPD_DISf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 6) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_RLD_STS_UPD_DISf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 6)) | ((((uint32_t)f) & 0x1) << 6)) +#define CMIC_CMC_PKTDMA_CTRLr_DESC_DONE_INTR_MODEf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 7) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DESC_DONE_INTR_MODEf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 7)) | ((((uint32_t)f) & 0x1) << 7)) +#define CMIC_CMC_PKTDMA_CTRLr_ENABLE_CONTINUOUS_DMAf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 8) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_ENABLE_CONTINUOUS_DMAf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 8)) | ((((uint32_t)f) & 0x1) << 8)) +#define CMIC_CMC_PKTDMA_CTRLr_CONTIGUOUS_DESCRIPTORSf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 9) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_CONTIGUOUS_DESCRIPTORSf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 9)) | ((((uint32_t)f) & 0x1) << 9)) +#define CMIC_CMC_PKTDMA_CTRLr_HEADER_ENDIANESSf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 12) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_HEADER_ENDIANESSf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 12)) | ((((uint32_t)f) & 0x1) << 12)) +#define CMIC_CMC_PKTDMA_CTRLr_DISABLE_ABORT_ON_ERRORf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 13) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DISABLE_ABORT_ON_ERRORf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 13)) | ((((uint32_t)f) & 0x1) << 13)) +#define CMIC_CMC_PKTDMA_CTRLr_PIPE_MAPf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 14) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_PIPE_MAPf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 14)) | ((((uint32_t)f) & 0x1) << 14)) +#define CMIC_CMC_PKTDMA_CTRLr_DISABLE_DESC_OTDSTD_READf_GET(r) ((((r).cmic_cmc_pktdma_ctrl[0]) >> 15) & 0x1) +#define CMIC_CMC_PKTDMA_CTRLr_DISABLE_DESC_OTDSTD_READf_SET(r,f) (r).cmic_cmc_pktdma_ctrl[0]=(((r).cmic_cmc_pktdma_ctrl[0] & ~((uint32_t)0x1 << 15)) | ((((uint32_t)f) & 0x1) << 15)) +#define READ_CMIC_CMC_PKTDMA_CTRLr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_CTRLr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_ctrl) +#define WRITE_CMIC_CMC_PKTDMA_CTRLr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_CTRLr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_ctrl) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_CURR_DESC_HI. + * + */ +typedef union CMIC_CMC_PKTDMA_CURR_DESC_HIr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_curr_desc_hi[1]; + uint32_t _cmic_cmc_pktdma_curr_desc_hi; +} CMIC_CMC_PKTDMA_CURR_DESC_HIr_t; + +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_CLR(r) (r).cmic_cmc_pktdma_curr_desc_hi[0] = 0 +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_SET(r,d) (r).cmic_cmc_pktdma_curr_desc_hi[0] = d +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_GET(r) (r).cmic_cmc_pktdma_curr_desc_hi[0] +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_OFFSET 0x00003134 +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_curr_desc_hi[0]) +#define CMIC_CMC_PKTDMA_CURR_DESC_HIr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_curr_desc_hi[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_CURR_DESC_HIr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_CURR_DESC_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_curr_desc_hi) +#define WRITE_CMIC_CMC_PKTDMA_CURR_DESC_HIr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_CURR_DESC_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_curr_desc_hi) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_CURR_DESC_LO. + * + */ +typedef union CMIC_CMC_PKTDMA_CURR_DESC_LOr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_curr_desc_lo[1]; + uint32_t _cmic_cmc_pktdma_curr_desc_lo; +} CMIC_CMC_PKTDMA_CURR_DESC_LOr_t; + +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_CLR(r) (r).cmic_cmc_pktdma_curr_desc_lo[0] = 0 +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_SET(r,d) (r).cmic_cmc_pktdma_curr_desc_lo[0] = d +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_GET(r) (r).cmic_cmc_pktdma_curr_desc_lo[0] +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_OFFSET 0x00003130 +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_curr_desc_lo[0]) +#define CMIC_CMC_PKTDMA_CURR_DESC_LOr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_curr_desc_lo[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_CURR_DESC_LOr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_CURR_DESC_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_curr_desc_lo) +#define WRITE_CMIC_CMC_PKTDMA_CURR_DESC_LOr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_CURR_DESC_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_curr_desc_lo) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DEBUG_CONTROL. + * + */ +typedef union CMIC_CMC_PKTDMA_DEBUG_CONTROLr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_debug_control[1]; + uint32_t _cmic_cmc_pktdma_debug_control; +} CMIC_CMC_PKTDMA_DEBUG_CONTROLr_t; + +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_CLR(r) (r).cmic_cmc_pktdma_debug_control[0] = 0 +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_SET(r,d) (r).cmic_cmc_pktdma_debug_control[0] = d +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_GET(r) (r).cmic_cmc_pktdma_debug_control[0] +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_OFFSET 0x0000313c +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_DESC_PENDING_SER_Q_SIZEf_GET(r) (((r).cmic_cmc_pktdma_debug_control[0]) & 0x7) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_DESC_PENDING_SER_Q_SIZEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x7)) | (((uint32_t)f) & 0x7)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_DESC_PENDING_WRITE_Q_SIZEf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 3) & 0x7) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_DESC_PENDING_WRITE_Q_SIZEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x7 << 3)) | ((((uint32_t)f) & 0x7) << 3)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_FLUSH_DESC_Qf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 6) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_FLUSH_DESC_Qf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 6)) | ((((uint32_t)f) & 0x1) << 6)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_OUTSTANDING_CNTf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 7) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_OUTSTANDING_CNTf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 7)) | ((((uint32_t)f) & 0x1) << 7)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_SM_SELECTf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 8) & 0x3) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_SM_SELECTf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x3 << 8)) | ((((uint32_t)f) & 0x3) << 8)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DESC_READ_SM_IDLEf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 10) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DESC_READ_SM_IDLEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 10)) | ((((uint32_t)f) & 0x1) << 10)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_MEM_RDWR_SM_IDLEf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 11) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_MEM_RDWR_SM_IDLEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 11)) | ((((uint32_t)f) & 0x1) << 11)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DESC_STATUS_WR_SM_IDLEf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 12) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DESC_STATUS_WR_SM_IDLEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 12)) | ((((uint32_t)f) & 0x1) << 12)) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DYN_RCNFG_SM_IDLEf_GET(r) ((((r).cmic_cmc_pktdma_debug_control[0]) >> 13) & 0x1) +#define CMIC_CMC_PKTDMA_DEBUG_CONTROLr_RESET_DYN_RCNFG_SM_IDLEf_SET(r,f) (r).cmic_cmc_pktdma_debug_control[0]=(((r).cmic_cmc_pktdma_debug_control[0] & ~((uint32_t)0x1 << 13)) | ((((uint32_t)f) & 0x1) << 13)) +#define READ_CMIC_CMC_PKTDMA_DEBUG_CONTROLr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DEBUG_CONTROLr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_control) +#define WRITE_CMIC_CMC_PKTDMA_DEBUG_CONTROLr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DEBUG_CONTROLr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_control) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DEBUG_SM_STATUS. + * + */ +typedef union CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_debug_sm_status[1]; + uint32_t _cmic_cmc_pktdma_debug_sm_status; +} CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_t; + +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_CLR(r) (r).cmic_cmc_pktdma_debug_sm_status[0] = 0 +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_SET(r,d) (r).cmic_cmc_pktdma_debug_sm_status[0] = d +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_GET(r) (r).cmic_cmc_pktdma_debug_sm_status[0] +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_OFFSET 0x00003140 +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_STATEf_GET(r) ((r).cmic_cmc_pktdma_debug_sm_status[0]) +#define CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_STATEf_SET(r,f) (r).cmic_cmc_pktdma_debug_sm_status[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_sm_status) +#define WRITE_CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DEBUG_SM_STATUSr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_sm_status) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DEBUG_STATUS. + * + */ +typedef union CMIC_CMC_PKTDMA_DEBUG_STATUSr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_debug_status[1]; + uint32_t _cmic_cmc_pktdma_debug_status; +} CMIC_CMC_PKTDMA_DEBUG_STATUSr_t; + +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_CLR(r) (r).cmic_cmc_pktdma_debug_status[0] = 0 +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_SET(r,d) (r).cmic_cmc_pktdma_debug_status[0] = d +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_GET(r) (r).cmic_cmc_pktdma_debug_status[0] +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_OFFSET 0x00003144 +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_PENDING_SER_Q_SIZE_NUM_ENTRIESf_GET(r) (((r).cmic_cmc_pktdma_debug_status[0]) & 0x3f) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_PENDING_SER_Q_SIZE_NUM_ENTRIESf_SET(r,f) (r).cmic_cmc_pktdma_debug_status[0]=(((r).cmic_cmc_pktdma_debug_status[0] & ~((uint32_t)0x3f)) | (((uint32_t)f) & 0x3f)) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_PENDING_WRITE_Q_NUM_ENTRIESf_GET(r) ((((r).cmic_cmc_pktdma_debug_status[0]) >> 6) & 0x7f) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_PENDING_WRITE_Q_NUM_ENTRIESf_SET(r,f) (r).cmic_cmc_pktdma_debug_status[0]=(((r).cmic_cmc_pktdma_debug_status[0] & ~((uint32_t)0x7f << 6)) | ((((uint32_t)f) & 0x7f) << 6)) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_NUM_TXPKTBUF_CELL_USEDf_GET(r) ((((r).cmic_cmc_pktdma_debug_status[0]) >> 13) & 0x7f) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_NUM_TXPKTBUF_CELL_USEDf_SET(r,f) (r).cmic_cmc_pktdma_debug_status[0]=(((r).cmic_cmc_pktdma_debug_status[0] & ~((uint32_t)0x7f << 13)) | ((((uint32_t)f) & 0x7f) << 13)) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_READ_OUTSTD_CNTf_GET(r) ((((r).cmic_cmc_pktdma_debug_status[0]) >> 20) & 0x1f) +#define CMIC_CMC_PKTDMA_DEBUG_STATUSr_DESC_READ_OUTSTD_CNTf_SET(r,f) (r).cmic_cmc_pktdma_debug_status[0]=(((r).cmic_cmc_pktdma_debug_status[0] & ~((uint32_t)0x1f << 20)) | ((((uint32_t)f) & 0x1f) << 20)) +#define READ_CMIC_CMC_PKTDMA_DEBUG_STATUSr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DEBUG_STATUSr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_status) +#define WRITE_CMIC_CMC_PKTDMA_DEBUG_STATUSr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DEBUG_STATUSr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_debug_status) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_ADDR_HI. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_ADDR_HIr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_addr_hi[1]; + uint32_t _cmic_cmc_pktdma_desc_addr_hi; +} CMIC_CMC_PKTDMA_DESC_ADDR_HIr_t; + +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_CLR(r) (r).cmic_cmc_pktdma_desc_addr_hi[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_SET(r,d) (r).cmic_cmc_pktdma_desc_addr_hi[0] = d +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_GET(r) (r).cmic_cmc_pktdma_desc_addr_hi[0] +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_OFFSET 0x00003108 +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_desc_addr_hi[0]) +#define CMIC_CMC_PKTDMA_DESC_ADDR_HIr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_desc_addr_hi[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_ADDR_HIr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_ADDR_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_addr_hi) +#define WRITE_CMIC_CMC_PKTDMA_DESC_ADDR_HIr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_ADDR_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_addr_hi) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_ADDR_LO. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_ADDR_LOr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_addr_lo[1]; + uint32_t _cmic_cmc_pktdma_desc_addr_lo; +} CMIC_CMC_PKTDMA_DESC_ADDR_LOr_t; + +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_CLR(r) (r).cmic_cmc_pktdma_desc_addr_lo[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_SET(r,d) (r).cmic_cmc_pktdma_desc_addr_lo[0] = d +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_GET(r) (r).cmic_cmc_pktdma_desc_addr_lo[0] +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_OFFSET 0x00003104 +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_desc_addr_lo[0]) +#define CMIC_CMC_PKTDMA_DESC_ADDR_LOr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_desc_addr_lo[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_ADDR_LOr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_ADDR_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_addr_lo) +#define WRITE_CMIC_CMC_PKTDMA_DESC_ADDR_LOr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_ADDR_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_addr_lo) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_COUNT_REQ. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_COUNT_REQr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_count_req[1]; + uint32_t _cmic_cmc_pktdma_desc_count_req; +} CMIC_CMC_PKTDMA_DESC_COUNT_REQr_t; + +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_CLR(r) (r).cmic_cmc_pktdma_desc_count_req[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_SET(r,d) (r).cmic_cmc_pktdma_desc_count_req[0] = d +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_GET(r) (r).cmic_cmc_pktdma_desc_count_req[0] +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_OFFSET 0x00003154 +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_desc_count_req[0]) +#define CMIC_CMC_PKTDMA_DESC_COUNT_REQr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_desc_count_req[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_COUNT_REQr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_COUNT_REQr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_req) +#define WRITE_CMIC_CMC_PKTDMA_DESC_COUNT_REQr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_COUNT_REQr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_req) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_COUNT_RX. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_COUNT_RXr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_count_rx[1]; + uint32_t _cmic_cmc_pktdma_desc_count_rx; +} CMIC_CMC_PKTDMA_DESC_COUNT_RXr_t; + +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_CLR(r) (r).cmic_cmc_pktdma_desc_count_rx[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_SET(r,d) (r).cmic_cmc_pktdma_desc_count_rx[0] = d +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_GET(r) (r).cmic_cmc_pktdma_desc_count_rx[0] +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_OFFSET 0x00003158 +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_desc_count_rx[0]) +#define CMIC_CMC_PKTDMA_DESC_COUNT_RXr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_desc_count_rx[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_COUNT_RXr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_COUNT_RXr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_rx) +#define WRITE_CMIC_CMC_PKTDMA_DESC_COUNT_RXr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_COUNT_RXr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_rx) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WR. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_count_status_wr[1]; + uint32_t _cmic_cmc_pktdma_desc_count_status_wr; +} CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_t; + +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_CLR(r) (r).cmic_cmc_pktdma_desc_count_status_wr[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_SET(r,d) (r).cmic_cmc_pktdma_desc_count_status_wr[0] = d +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_GET(r) (r).cmic_cmc_pktdma_desc_count_status_wr[0] +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_OFFSET 0x0000315c +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_desc_count_status_wr[0]) +#define CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_desc_count_status_wr[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_status_wr) +#define WRITE_CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_COUNT_STATUS_WRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_count_status_wr) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HI. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_halt_addr_hi[1]; + uint32_t _cmic_cmc_pktdma_desc_halt_addr_hi; +} CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_t; + +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_CLR(r) (r).cmic_cmc_pktdma_desc_halt_addr_hi[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_SET(r,d) (r).cmic_cmc_pktdma_desc_halt_addr_hi[0] = d +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_GET(r) (r).cmic_cmc_pktdma_desc_halt_addr_hi[0] +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_OFFSET 0x00003110 +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_desc_halt_addr_hi[0]) +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_desc_halt_addr_hi[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_halt_addr_hi) +#define WRITE_CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_HALT_ADDR_HIr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_halt_addr_hi) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LO. + * + */ +typedef union CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_desc_halt_addr_lo[1]; + uint32_t _cmic_cmc_pktdma_desc_halt_addr_lo; +} CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_t; + +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_CLR(r) (r).cmic_cmc_pktdma_desc_halt_addr_lo[0] = 0 +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_SET(r,d) (r).cmic_cmc_pktdma_desc_halt_addr_lo[0] = d +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_GET(r) (r).cmic_cmc_pktdma_desc_halt_addr_lo[0] +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_OFFSET 0x0000310c +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_ADDRf_GET(r) ((r).cmic_cmc_pktdma_desc_halt_addr_lo[0]) +#define CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_ADDRf_SET(r,f) (r).cmic_cmc_pktdma_desc_halt_addr_lo[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_halt_addr_lo) +#define WRITE_CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_DESC_HALT_ADDR_LOr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_desc_halt_addr_lo) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_INTR. + * + */ +typedef union CMIC_CMC_PKTDMA_INTRr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_intr[1]; + uint32_t _cmic_cmc_pktdma_intr; +} CMIC_CMC_PKTDMA_INTRr_t; + +#define CMIC_CMC_PKTDMA_INTRr_CLR(r) (r).cmic_cmc_pktdma_intr[0] = 0 +#define CMIC_CMC_PKTDMA_INTRr_SET(r,d) (r).cmic_cmc_pktdma_intr[0] = d +#define CMIC_CMC_PKTDMA_INTRr_GET(r) (r).cmic_cmc_pktdma_intr[0] +#define CMIC_CMC_PKTDMA_INTRr_OFFSET 0x00003118 +#define CMIC_CMC_PKTDMA_INTRr_CHAIN_DONE_INTRf_GET(r) (((r).cmic_cmc_pktdma_intr[0]) & 0x1) +#define CMIC_CMC_PKTDMA_INTRr_CHAIN_DONE_INTRf_SET(r,f) (r).cmic_cmc_pktdma_intr[0]=(((r).cmic_cmc_pktdma_intr[0] & ~((uint32_t)0x1)) | (((uint32_t)f) & 0x1)) +#define CMIC_CMC_PKTDMA_INTRr_DESC_DONE_INTRf_GET(r) ((((r).cmic_cmc_pktdma_intr[0]) >> 1) & 0x1) +#define CMIC_CMC_PKTDMA_INTRr_DESC_DONE_INTRf_SET(r,f) (r).cmic_cmc_pktdma_intr[0]=(((r).cmic_cmc_pktdma_intr[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_CMC_PKTDMA_INTRr_DESC_CONTROLLED_INTRf_GET(r) ((((r).cmic_cmc_pktdma_intr[0]) >> 2) & 0x1) +#define CMIC_CMC_PKTDMA_INTRr_DESC_CONTROLLED_INTRf_SET(r,f) (r).cmic_cmc_pktdma_intr[0]=(((r).cmic_cmc_pktdma_intr[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_CMC_PKTDMA_INTRr_INTR_COALESCING_INTRf_GET(r) ((((r).cmic_cmc_pktdma_intr[0]) >> 3) & 0x1) +#define CMIC_CMC_PKTDMA_INTRr_INTR_COALESCING_INTRf_SET(r,f) (r).cmic_cmc_pktdma_intr[0]=(((r).cmic_cmc_pktdma_intr[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define READ_CMIC_CMC_PKTDMA_INTRr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_INTRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr) +#define WRITE_CMIC_CMC_PKTDMA_INTRr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_INTRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_INTR_CLR. + * + */ +typedef union CMIC_CMC_PKTDMA_INTR_CLRr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_intr_clr[1]; + uint32_t _cmic_cmc_pktdma_intr_clr; +} CMIC_CMC_PKTDMA_INTR_CLRr_t; + +#define CMIC_CMC_PKTDMA_INTR_CLRr_CLR(r) (r).cmic_cmc_pktdma_intr_clr[0] = 0 +#define CMIC_CMC_PKTDMA_INTR_CLRr_SET(r,d) (r).cmic_cmc_pktdma_intr_clr[0] = d +#define CMIC_CMC_PKTDMA_INTR_CLRr_GET(r) (r).cmic_cmc_pktdma_intr_clr[0] +#define CMIC_CMC_PKTDMA_INTR_CLRr_OFFSET 0x00003120 +#define CMIC_CMC_PKTDMA_INTR_CLRr_DESC_DONE_INTR_CLRf_GET(r) ((((r).cmic_cmc_pktdma_intr_clr[0]) >> 1) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_CLRr_DESC_DONE_INTR_CLRf_SET(r,f) (r).cmic_cmc_pktdma_intr_clr[0]=(((r).cmic_cmc_pktdma_intr_clr[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_CMC_PKTDMA_INTR_CLRr_DESC_CONTROLLED_INTR_CLRf_GET(r) ((((r).cmic_cmc_pktdma_intr_clr[0]) >> 2) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_CLRr_DESC_CONTROLLED_INTR_CLRf_SET(r,f) (r).cmic_cmc_pktdma_intr_clr[0]=(((r).cmic_cmc_pktdma_intr_clr[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_CMC_PKTDMA_INTR_CLRr_INTR_COALESCING_INTR_CLRf_GET(r) ((((r).cmic_cmc_pktdma_intr_clr[0]) >> 3) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_CLRr_INTR_COALESCING_INTR_CLRf_SET(r,f) (r).cmic_cmc_pktdma_intr_clr[0]=(((r).cmic_cmc_pktdma_intr_clr[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define CMIC_CMC_PKTDMA_INTR_CLRr_DYN_RCNFG_ERR_CLRf_GET(r) ((((r).cmic_cmc_pktdma_intr_clr[0]) >> 4) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_CLRr_DYN_RCNFG_ERR_CLRf_SET(r,f) (r).cmic_cmc_pktdma_intr_clr[0]=(((r).cmic_cmc_pktdma_intr_clr[0] & ~((uint32_t)0x1 << 4)) | ((((uint32_t)f) & 0x1) << 4)) +#define READ_CMIC_CMC_PKTDMA_INTR_CLRr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_INTR_CLRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_clr) +#define WRITE_CMIC_CMC_PKTDMA_INTR_CLRr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_INTR_CLRr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_clr) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_INTR_COAL. + * + */ +typedef union CMIC_CMC_PKTDMA_INTR_COALr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_intr_coal[1]; + uint32_t _cmic_cmc_pktdma_intr_coal; +} CMIC_CMC_PKTDMA_INTR_COALr_t; + +#define CMIC_CMC_PKTDMA_INTR_COALr_CLR(r) (r).cmic_cmc_pktdma_intr_coal[0] = 0 +#define CMIC_CMC_PKTDMA_INTR_COALr_SET(r,d) (r).cmic_cmc_pktdma_intr_coal[0] = d +#define CMIC_CMC_PKTDMA_INTR_COALr_GET(r) (r).cmic_cmc_pktdma_intr_coal[0] +#define CMIC_CMC_PKTDMA_INTR_COALr_OFFSET 0x0000312c +#define CMIC_CMC_PKTDMA_INTR_COALr_TIMERf_GET(r) (((r).cmic_cmc_pktdma_intr_coal[0]) & 0xffff) +#define CMIC_CMC_PKTDMA_INTR_COALr_TIMERf_SET(r,f) (r).cmic_cmc_pktdma_intr_coal[0]=(((r).cmic_cmc_pktdma_intr_coal[0] & ~((uint32_t)0xffff)) | (((uint32_t)f) & 0xffff)) +#define CMIC_CMC_PKTDMA_INTR_COALr_COUNTf_GET(r) ((((r).cmic_cmc_pktdma_intr_coal[0]) >> 16) & 0x7fff) +#define CMIC_CMC_PKTDMA_INTR_COALr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_intr_coal[0]=(((r).cmic_cmc_pktdma_intr_coal[0] & ~((uint32_t)0x7fff << 16)) | ((((uint32_t)f) & 0x7fff) << 16)) +#define CMIC_CMC_PKTDMA_INTR_COALr_ENABLEf_GET(r) ((((r).cmic_cmc_pktdma_intr_coal[0]) >> 31) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_COALr_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_intr_coal[0]=(((r).cmic_cmc_pktdma_intr_coal[0] & ~((uint32_t)0x1 << 31)) | ((((uint32_t)f) & 0x1) << 31)) +#define READ_CMIC_CMC_PKTDMA_INTR_COALr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_INTR_COALr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_coal) +#define WRITE_CMIC_CMC_PKTDMA_INTR_COALr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_INTR_COALr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_coal) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_INTR_ENABLE. + * + */ +typedef union CMIC_CMC_PKTDMA_INTR_ENABLEr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_intr_enable[1]; + uint32_t _cmic_cmc_pktdma_intr_enable; +} CMIC_CMC_PKTDMA_INTR_ENABLEr_t; + +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_CLR(r) (r).cmic_cmc_pktdma_intr_enable[0] = 0 +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_SET(r,d) (r).cmic_cmc_pktdma_intr_enable[0] = d +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_GET(r) (r).cmic_cmc_pktdma_intr_enable[0] +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_OFFSET 0x0000311c +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_CHAIN_DONE_INTR_ENABLEf_GET(r) (((r).cmic_cmc_pktdma_intr_enable[0]) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_CHAIN_DONE_INTR_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_intr_enable[0]=(((r).cmic_cmc_pktdma_intr_enable[0] & ~((uint32_t)0x1)) | (((uint32_t)f) & 0x1)) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_DESC_DONE_INTR_ENABLEf_GET(r) ((((r).cmic_cmc_pktdma_intr_enable[0]) >> 1) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_DESC_DONE_INTR_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_intr_enable[0]=(((r).cmic_cmc_pktdma_intr_enable[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_DESC_CONTROLLED_INTR_ENABLEf_GET(r) ((((r).cmic_cmc_pktdma_intr_enable[0]) >> 2) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_DESC_CONTROLLED_INTR_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_intr_enable[0]=(((r).cmic_cmc_pktdma_intr_enable[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_INTR_COALESCING_INTR_ENABLEf_GET(r) ((((r).cmic_cmc_pktdma_intr_enable[0]) >> 3) & 0x1) +#define CMIC_CMC_PKTDMA_INTR_ENABLEr_INTR_COALESCING_INTR_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_intr_enable[0]=(((r).cmic_cmc_pktdma_intr_enable[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define READ_CMIC_CMC_PKTDMA_INTR_ENABLEr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_INTR_ENABLEr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_enable) +#define WRITE_CMIC_CMC_PKTDMA_INTR_ENABLEr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_INTR_ENABLEr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_intr_enable) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT. + * + */ +typedef union CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_pkt_count_rxpkt[1]; + uint32_t _cmic_cmc_pktdma_pkt_count_rxpkt; +} CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_t; + +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_CLR(r) (r).cmic_cmc_pktdma_pkt_count_rxpkt[0] = 0 +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_SET(r,d) (r).cmic_cmc_pktdma_pkt_count_rxpkt[0] = d +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_GET(r) (r).cmic_cmc_pktdma_pkt_count_rxpkt[0] +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_OFFSET 0x00003148 +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_pkt_count_rxpkt[0]) +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_pkt_count_rxpkt[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_rxpkt) +#define WRITE_CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_PKT_COUNT_RXPKTr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_rxpkt) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROP. + * + */ +typedef union CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_pkt_count_rxpkt_drop[1]; + uint32_t _cmic_cmc_pktdma_pkt_count_rxpkt_drop; +} CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_t; + +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_CLR(r) (r).cmic_cmc_pktdma_pkt_count_rxpkt_drop[0] = 0 +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_SET(r,d) (r).cmic_cmc_pktdma_pkt_count_rxpkt_drop[0] = d +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_GET(r) (r).cmic_cmc_pktdma_pkt_count_rxpkt_drop[0] +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_OFFSET 0x00003150 +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_pkt_count_rxpkt_drop[0]) +#define CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_pkt_count_rxpkt_drop[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_rxpkt_drop) +#define WRITE_CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_PKT_COUNT_RXPKT_DROPr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_rxpkt_drop) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_PKT_COUNT_TXPKT. + * + */ +typedef union CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_pkt_count_txpkt[1]; + uint32_t _cmic_cmc_pktdma_pkt_count_txpkt; +} CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_t; + +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_CLR(r) (r).cmic_cmc_pktdma_pkt_count_txpkt[0] = 0 +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_SET(r,d) (r).cmic_cmc_pktdma_pkt_count_txpkt[0] = d +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_GET(r) (r).cmic_cmc_pktdma_pkt_count_txpkt[0] +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_OFFSET 0x0000314c +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_COUNTf_GET(r) ((r).cmic_cmc_pktdma_pkt_count_txpkt[0]) +#define CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_COUNTf_SET(r,f) (r).cmic_cmc_pktdma_pkt_count_txpkt[0]=((uint32_t)f) +#define READ_CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_txpkt) +#define WRITE_CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_PKT_COUNT_TXPKTr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_pkt_count_txpkt) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIG. + * + */ +typedef union CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_rxbuf_threshold_config[1]; + uint32_t _cmic_cmc_pktdma_rxbuf_threshold_config; +} CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_t; + +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_CLR(r) (r).cmic_cmc_pktdma_rxbuf_threshold_config[0] = 0 +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_SET(r,d) (r).cmic_cmc_pktdma_rxbuf_threshold_config[0] = d +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_GET(r) (r).cmic_cmc_pktdma_rxbuf_threshold_config[0] +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_OFFSET 0x00003138 +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_RXBUF_THRESHOLDf_GET(r) (((r).cmic_cmc_pktdma_rxbuf_threshold_config[0]) & 0x1ff) +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_RXBUF_THRESHOLDf_SET(r,f) (r).cmic_cmc_pktdma_rxbuf_threshold_config[0]=(((r).cmic_cmc_pktdma_rxbuf_threshold_config[0] & ~((uint32_t)0x1ff)) | (((uint32_t)f) & 0x1ff)) +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_ENABLEf_GET(r) ((((r).cmic_cmc_pktdma_rxbuf_threshold_config[0]) >> 9) & 0x1) +#define CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_ENABLEf_SET(r,f) (r).cmic_cmc_pktdma_rxbuf_threshold_config[0]=(((r).cmic_cmc_pktdma_rxbuf_threshold_config[0] & ~((uint32_t)0x1 << 9)) | ((((uint32_t)f) & 0x1) << 9)) +#define READ_CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_rxbuf_threshold_config) +#define WRITE_CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_RXBUF_THRESHOLD_CONFIGr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_rxbuf_threshold_config) + +/* + * This structure should be used to declare and program CMIC_CMC_PKTDMA_STAT. + * + */ +typedef union CMIC_CMC_PKTDMA_STATr_s { + uint32_t v[1]; + uint32_t cmic_cmc_pktdma_stat[1]; + uint32_t _cmic_cmc_pktdma_stat; +} CMIC_CMC_PKTDMA_STATr_t; + +#define CMIC_CMC_PKTDMA_STATr_CLR(r) (r).cmic_cmc_pktdma_stat[0] = 0 +#define CMIC_CMC_PKTDMA_STATr_SET(r,d) (r).cmic_cmc_pktdma_stat[0] = d +#define CMIC_CMC_PKTDMA_STATr_GET(r) (r).cmic_cmc_pktdma_stat[0] +#define CMIC_CMC_PKTDMA_STATr_OFFSET 0x00003114 +#define CMIC_CMC_PKTDMA_STATr_CHAIN_DONEf_GET(r) (((r).cmic_cmc_pktdma_stat[0]) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_CHAIN_DONEf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1)) | (((uint32_t)f) & 0x1)) +#define CMIC_CMC_PKTDMA_STATr_DMA_ACTIVEf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 1) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DMA_ACTIVEf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 1)) | ((((uint32_t)f) & 0x1) << 1)) +#define CMIC_CMC_PKTDMA_STATr_STWT_ADDR_DECODE_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 2) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_STWT_ADDR_DECODE_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 2)) | ((((uint32_t)f) & 0x1) << 2)) +#define CMIC_CMC_PKTDMA_STATr_PKTWRRD_ADDR_DECODE_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 3) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_PKTWRRD_ADDR_DECODE_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 3)) | ((((uint32_t)f) & 0x1) << 3)) +#define CMIC_CMC_PKTDMA_STATr_DESCRD_ADDR_DECODE_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 4) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DESCRD_ADDR_DECODE_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 4)) | ((((uint32_t)f) & 0x1) << 4)) +#define CMIC_CMC_PKTDMA_STATr_PKTWR_ECC_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 5) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_PKTWR_ECC_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 5)) | ((((uint32_t)f) & 0x1) << 5)) +#define CMIC_CMC_PKTDMA_STATr_CH_IN_HALTf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 6) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_CH_IN_HALTf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 6)) | ((((uint32_t)f) & 0x1) << 6)) +#define CMIC_CMC_PKTDMA_STATr_RELOAD_UNALIGNED_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 7) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_RELOAD_UNALIGNED_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 7)) | ((((uint32_t)f) & 0x1) << 7)) +#define CMIC_CMC_PKTDMA_STATr_DESC_DONEf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 8) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DESC_DONEf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 8)) | ((((uint32_t)f) & 0x1) << 8)) +#define CMIC_CMC_PKTDMA_STATr_DESC_CONTROLLEDf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 9) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DESC_CONTROLLEDf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 9)) | ((((uint32_t)f) & 0x1) << 9)) +#define CMIC_CMC_PKTDMA_STATr_INTR_COALESCINGf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 10) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_INTR_COALESCINGf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 10)) | ((((uint32_t)f) & 0x1) << 10)) +#define CMIC_CMC_PKTDMA_STATr_DYN_RCNFG_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 11) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DYN_RCNFG_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 11)) | ((((uint32_t)f) & 0x1) << 11)) +#define CMIC_CMC_PKTDMA_STATr_INVALID_AXI_CMD_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 12) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_INVALID_AXI_CMD_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 12)) | ((((uint32_t)f) & 0x1) << 12)) +#define CMIC_CMC_PKTDMA_STATr_DMA_IS_ENf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 13) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DMA_IS_ENf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 13)) | ((((uint32_t)f) & 0x1) << 13)) +#define CMIC_CMC_PKTDMA_STATr_DESC_MEM_ECC_ERRf_GET(r) ((((r).cmic_cmc_pktdma_stat[0]) >> 14) & 0x1) +#define CMIC_CMC_PKTDMA_STATr_DESC_MEM_ECC_ERRf_SET(r,f) (r).cmic_cmc_pktdma_stat[0]=(((r).cmic_cmc_pktdma_stat[0] & ~((uint32_t)0x1 << 14)) | ((((uint32_t)f) & 0x1) << 14)) +#define READ_CMIC_CMC_PKTDMA_STATr(u,_cmc,_ch,r) BCMDRD_DEV_READ32(u,CMIC_CMC_PKTDMA_STATr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_stat) +#define WRITE_CMIC_CMC_PKTDMA_STATr(u,_cmc,_ch,r) BCMDRD_DEV_WRITE32(u,CMIC_CMC_PKTDMA_STATr_OFFSET+(0x80*(_ch))+(0x2000*(_cmc)),r._cmic_cmc_pktdma_stat) + +#define RX_DCB_SIZE 16 +#define TX_DCB_SIZE 16 + +/* + * This structure should be used to declare and program TX_DCB. + * + */ +typedef union TX_DCB_s { + uint32_t v[4]; + uint32_t tx_dcb[4]; + uint32_t _tx_dcb; +} TX_DCB_t; + +#define TX_DCB_CLR(r) sal_memset(&((r).tx_dcb[0]), 0, sizeof(TX_DCB_t)) +#define TX_DCB_SET(r,i,d) (r).tx_dcb[i] = d +#define TX_DCB_GET(r,i) (r).tx_dcb[i] +#define TX_DCB_OFFSET 0x00000000 +#define TX_DCB_BYTES_TRANSFERREDf_GET(r) (((r).tx_dcb[3]) & 0xffff) +#define TX_DCB_BYTES_TRANSFERREDf_SET(r,f) (r).tx_dcb[3]=(((r).tx_dcb[3] & ~((uint32_t)0xffff)) | (((uint32_t)f) & 0xffff)) +#define TX_DCB_DONEf_GET(r) ((((r).tx_dcb[3]) >> 31) & 0x1) +#define TX_DCB_DONEf_SET(r,f) (r).tx_dcb[3]=(((r).tx_dcb[3] & ~((uint32_t)0x1 << 31)) | ((((uint32_t)f) & 0x1) << 31)) +#define TX_DCB_BYTE_COUNTf_GET(r) (((r).tx_dcb[2]) & 0xffff) +#define TX_DCB_BYTE_COUNTf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0xffff)) | (((uint32_t)f) & 0xffff)) +#define TX_DCB_CHAINf_GET(r) ((((r).tx_dcb[2]) >> 16) & 0x1) +#define TX_DCB_CHAINf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 16)) | ((((uint32_t)f) & 0x1) << 16)) +#define TX_DCB_SGf_GET(r) ((((r).tx_dcb[2]) >> 17) & 0x1) +#define TX_DCB_SGf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 17)) | ((((uint32_t)f) & 0x1) << 17)) +#define TX_DCB_RELOADf_GET(r) ((((r).tx_dcb[2]) >> 18) & 0x1) +#define TX_DCB_RELOADf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 18)) | ((((uint32_t)f) & 0x1) << 18)) +#define TX_DCB_HGf_GET(r) ((((r).tx_dcb[2]) >> 19) & 0x1) +#define TX_DCB_HGf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 19)) | ((((uint32_t)f) & 0x1) << 19)) +#define TX_DCB_PURGEf_GET(r) ((((r).tx_dcb[2]) >> 22) & 0x1) +#define TX_DCB_PURGEf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 22)) | ((((uint32_t)f) & 0x1) << 22)) +#define TX_DCB_DESC_DONE_INTRf_GET(r) ((((r).tx_dcb[2]) >> 23) & 0x1) +#define TX_DCB_DESC_DONE_INTRf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 23)) | ((((uint32_t)f) & 0x1) << 23)) +#define TX_DCB_DESC_CTRL_INTRf_GET(r) ((((r).tx_dcb[2]) >> 24) & 0x1) +#define TX_DCB_DESC_CTRL_INTRf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 24)) | ((((uint32_t)f) & 0x1) << 24)) +#define TX_DCB_DESC_REMAINf_GET(r) ((((r).tx_dcb[2]) >> 25) & 0xf) +#define TX_DCB_DESC_REMAINf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0xf << 25)) | ((((uint32_t)f) & 0xf) << 25)) +#define TX_DCB_DESC_STAT_WR_DISABLEf_GET(r) ((((r).tx_dcb[2]) >> 29) & 0x1) +#define TX_DCB_DESC_STAT_WR_DISABLEf_SET(r,f) (r).tx_dcb[2]=(((r).tx_dcb[2] & ~((uint32_t)0x1 << 29)) | ((((uint32_t)f) & 0x1) << 29)) +#define TX_DCB_ADDR_HIf_GET(r) ((r).tx_dcb[1]) +#define TX_DCB_ADDR_HIf_SET(r,f) (r).tx_dcb[1]=((uint32_t)f) +#define TX_DCB_ADDR_LOf_GET(r) ((r).tx_dcb[0]) +#define TX_DCB_ADDR_LOf_SET(r,f) (r).tx_dcb[0]=((uint32_t)f) + +/* + * This structure should be used to declare and program RX_DCB. + * + */ +typedef union RX_DCB_s { + uint32_t v[4]; + uint32_t rx_dcb[4]; + uint32_t _rx_dcb; +} RX_DCB_t; + +#define RX_DCB_CLR(r) sal_memset(&((r).rx_dcb[0]), 0, sizeof(RX_DCB_t)) +#define RX_DCB_SET(r,i,d) (r).rx_dcb[i] = d +#define RX_DCB_GET(r,i) (r).rx_dcb[i] +#define RX_DCB_OFFSET 0x00000000 +#define RX_DCB_BYTES_TRANSFERREDf_GET(r) (((r).rx_dcb[3]) & 0xffff) +#define RX_DCB_BYTES_TRANSFERREDf_SET(r,f) (r).rx_dcb[3]=(((r).rx_dcb[3] & ~((uint32_t)0xffff)) | (((uint32_t)f) & 0xffff)) +#define RX_DCB_END_BITf_GET(r) ((((r).rx_dcb[3]) >> 16) & 0x1) +#define RX_DCB_END_BITf_SET(r,f) (r).rx_dcb[3]=(((r).rx_dcb[3] & ~((uint32_t)0x1 << 16)) | ((((uint32_t)f) & 0x1) << 16)) +#define RX_DCB_START_BITf_GET(r) ((((r).rx_dcb[3]) >> 17) & 0x1) +#define RX_DCB_START_BITf_SET(r,f) (r).rx_dcb[3]=(((r).rx_dcb[3] & ~((uint32_t)0x1 << 17)) | ((((uint32_t)f) & 0x1) << 17)) +#define RX_DCB_ERRORf_GET(r) ((((r).rx_dcb[3]) >> 18) & 0x1) +#define RX_DCB_ERRORf_SET(r,f) (r).rx_dcb[3]=(((r).rx_dcb[3] & ~((uint32_t)0x1 << 18)) | ((((uint32_t)f) & 0x1) << 18)) +#define RX_DCB_DONEf_GET(r) ((((r).rx_dcb[3]) >> 31) & 0x1) +#define RX_DCB_DONEf_SET(r,f) (r).rx_dcb[3]=(((r).rx_dcb[3] & ~((uint32_t)0x1 << 31)) | ((((uint32_t)f) & 0x1) << 31)) +#define RX_DCB_BYTE_COUNTf_GET(r) (((r).rx_dcb[2]) & 0xffff) +#define RX_DCB_BYTE_COUNTf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0xffff)) | (((uint32_t)f) & 0xffff)) +#define RX_DCB_CHAINf_GET(r) ((((r).rx_dcb[2]) >> 16) & 0x1) +#define RX_DCB_CHAINf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 16)) | ((((uint32_t)f) & 0x1) << 16)) +#define RX_DCB_SGf_GET(r) ((((r).rx_dcb[2]) >> 17) & 0x1) +#define RX_DCB_SGf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 17)) | ((((uint32_t)f) & 0x1) << 17)) +#define RX_DCB_RELOADf_GET(r) ((((r).rx_dcb[2]) >> 18) & 0x1) +#define RX_DCB_RELOADf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 18)) | ((((uint32_t)f) & 0x1) << 18)) +#define RX_DCB_DESC_DONE_INTRf_GET(r) ((((r).rx_dcb[2]) >> 23) & 0x1) +#define RX_DCB_DESC_DONE_INTRf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 23)) | ((((uint32_t)f) & 0x1) << 23)) +#define RX_DCB_DESC_CTRL_INTRf_GET(r) ((((r).rx_dcb[2]) >> 24) & 0x1) +#define RX_DCB_DESC_CTRL_INTRf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 24)) | ((((uint32_t)f) & 0x1) << 24)) +#define RX_DCB_DESC_REMAINf_GET(r) ((((r).rx_dcb[2]) >> 25) & 0xf) +#define RX_DCB_DESC_REMAINf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0xf << 25)) | ((((uint32_t)f) & 0xf) << 25)) +#define RX_DCB_DESC_STAT_WR_DISABLEf_GET(r) ((((r).rx_dcb[2]) >> 29) & 0x1) +#define RX_DCB_DESC_STAT_WR_DISABLEf_SET(r,f) (r).rx_dcb[2]=(((r).rx_dcb[2] & ~((uint32_t)0x1 << 29)) | ((((uint32_t)f) & 0x1) << 29)) +#define RX_DCB_ADDR_HIf_GET(r) ((r).rx_dcb[1]) +#define RX_DCB_ADDR_HIf_SET(r,f) (r).rx_dcb[1]=((uint32_t)f) +#define RX_DCB_ADDR_LOf_GET(r) ((r).rx_dcb[0]) +#define RX_DCB_ADDR_LOf_SET(r,f) (r).rx_dcb[0]=((uint32_t)f) + +#endif /* BCMCNET_CMICR_ACC_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h index 9d5369784776..75d61c7a38bf 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h index e421afd0f35a..82341cac7b7a 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -125,7 +125,7 @@ struct intr_handle { void *priv; /*! Interrupt number */ - int intr_num; + int inum; /*! Interrupt flags */ uint32_t intr_flags; @@ -190,7 +190,7 @@ struct queue_group { uint32_t irq_mask; /*! Indicating the group is attached */ - int attached; + bool attached; }; /*! @@ -721,6 +721,20 @@ typedef int (*pdma_rx_f)(struct pdma_dev *dev, int queue, void *buf); */ typedef int (*pdma_tx_f)(struct pdma_dev *dev, int queue, void *buf); +/*! + * Network device detach. + * + * \param [in] dev Pointer to device structure. + */ +typedef void (*sys_ndev_detach_f)(struct pdma_dev *dev); + +/*! + * Network device attach. + * + * \param [in] dev Pointer to device structure. + */ +typedef void (*sys_ndev_attach_f)(struct pdma_dev *dev); + /*! * Suspend Tx queue. * @@ -842,6 +856,12 @@ struct pdma_dev { /*! Packet transmission */ pdma_tx_f pkt_xmit; + /*! Network device detach */ + sys_ndev_detach_f ndev_detach; + + /*! Network device attach */ + sys_ndev_attach_f ndev_attach; + /*! Tx suspend */ sys_tx_suspend_f tx_suspend; @@ -902,13 +922,13 @@ struct pdma_dev { dev_mode_t mode; /*! Device is started */ - int started; + bool started; /*! Device is started but suspended */ - int suspended; + bool suspended; /*! Device is initialized and HMI driver is attached */ - int attached; + bool attached; }; /*! diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h index aa1d47876b95..2a316531f1e0 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h index f3602e07c098..6a4495a84bb8 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h index 197378108c35..cd3eb1afe933 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -148,13 +148,19 @@ struct pdma_rx_queue { #define PDMA_RX_QUEUE_ACTIVE (1 << 2) /*! Queue is busy */ #define PDMA_RX_QUEUE_BUSY (1 << 3) + /*! Queue in batch refilling mode */ +#define PDMA_RX_BATCH_REFILL (1 << 4) + + /*! Queue status */ + uint32_t status; /*! Queue is suspended */ -#define PDMA_RX_QUEUE_XOFF (1 << 4) - /*! Queue is batch refilled */ -#define PDMA_RX_BATCH_REFILL (1 << 5) +#define PDMA_RX_QUEUE_XOFF (1 << 0) /*! DMA buffer mode */ - enum buf_mode mode; + enum buf_mode buf_mode; + + /*! Page order in PDMA_BUF_MODE_PAGE mode */ + uint32_t page_order; }; /*! @@ -248,13 +254,16 @@ struct pdma_tx_queue { #define PDMA_TX_QUEUE_ACTIVE (1 << 2) /*! Queue is setup */ #define PDMA_TX_QUEUE_BUSY (1 << 3) + /*! Queue in polling mode */ +#define PDMA_TX_QUEUE_POLL (1 << 4) + + /*! Queue status */ + uint32_t status; /*! Queue is suspended */ -#define PDMA_TX_QUEUE_XOFF (1 << 4) - /*! Queue is poll mode */ -#define PDMA_TX_QUEUE_POLL (1 << 5) +#define PDMA_TX_QUEUE_XOFF (1 << 0) /*! DMA buffer mode */ - enum buf_mode mode; + enum buf_mode buf_mode; }; /*! diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h index 8992634097c5..67b0c3578d83 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -118,8 +118,14 @@ typedef struct bcmcnet_dev_info { /*! Number of Rx descriptors per queue */ uint32_t nb_rx_desc[NUM_Q_MAX]; + /*! State of Rx queues */ + uint32_t rxq_state[NUM_Q_MAX]; + /*! Number of Tx descriptors per queue */ uint32_t nb_tx_desc[NUM_Q_MAX]; + + /*! State of Tx queues */ + uint32_t txq_state[NUM_Q_MAX]; } bcmcnet_dev_info_t; /*! diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c index fec920a935c1..4a1125548b03 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_core.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -37,7 +37,7 @@ bcmcnet_pdma_dev_init(struct pdma_dev *dev) return rv; } - dev->attached = 1; + dev->attached = true; return SHR_E_NONE; } @@ -55,7 +55,7 @@ bcmcnet_pdma_dev_cleanup(struct pdma_dev *dev) dev->ops->dev_close(dev); dev->ops = NULL; - dev->attached = 0; + dev->attached = false; return SHR_E_NONE; } @@ -83,6 +83,8 @@ bcmcnet_pdma_dev_start(struct pdma_dev *dev) return rv; } + dev->started = true; + /* Start all the Rx queues */ for (qi = 0; qi < ctrl->nb_rxq; qi++) { rv = dev->ops->rx_queue_setup(dev, qi); @@ -95,16 +97,16 @@ bcmcnet_pdma_dev_start(struct pdma_dev *dev) /* Start all the Tx queues */ for (qi = 0; qi < ctrl->nb_txq; qi++) { - dev->ops->tx_queue_setup(dev, qi); + rv = dev->ops->tx_queue_setup(dev, qi); + if (SHR_FAILURE(rv)) { + return rv; + } dev->ops->tx_queue_intr_enable(dev, qi); dev->ops->tx_queue_start(dev, qi); - dev->ops->tx_queue_wakeup(dev, qi); } bcmcnet_pdma_dev_info_get(dev); - dev->started = 1; - return SHR_E_NONE; } @@ -127,20 +129,27 @@ bcmcnet_pdma_dev_stop(struct pdma_dev *dev) /* Stop all the Rx queues */ for (qi = 0; qi < ctrl->nb_rxq; qi++) { - dev->ops->rx_queue_intr_disable(dev, qi); dev->ops->rx_queue_stop(dev, qi); dev->ops->rx_queue_release(dev, qi); } /* Stop all the Tx queues */ for (qi = 0; qi < ctrl->nb_txq; qi++) { - dev->ops->tx_queue_intr_disable(dev, qi); dev->ops->tx_queue_stop(dev, qi); - dev->ops->tx_queue_wakeup(dev, qi); dev->ops->tx_queue_release(dev, qi); } - dev->started = 0; + dev->started = false; + + /* Disable all the Rx interrupts */ + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + dev->ops->rx_queue_intr_disable(dev, qi); + } + + /* Disable all the Tx interrupts */ + for (qi = 0; qi < ctrl->nb_txq; qi++) { + dev->ops->tx_queue_intr_disable(dev, qi); + } return SHR_E_NONE; } @@ -159,13 +168,13 @@ bcmcnet_pdma_dev_suspend(struct pdma_dev *dev) return SHR_E_UNAVAIL; } + dev->suspended = true; + rv = dev->ops->dev_suspend(dev); if (SHR_FAILURE(rv)) { return rv; } - dev->suspended = true; - if (dev->flags & PDMA_ABORT) { /* Abort all the Tx queues */ for (qi = 0; qi < ctrl->nb_txq; qi++) { @@ -173,7 +182,7 @@ bcmcnet_pdma_dev_suspend(struct pdma_dev *dev) } /* Abort all the Rx queues */ for (qi = 0; qi < ctrl->nb_rxq; qi++) { - dev->ops->rx_queue_stop(dev, qi);; + dev->ops->rx_queue_stop(dev, qi); } } @@ -194,6 +203,8 @@ bcmcnet_pdma_dev_resume(struct pdma_dev *dev) return SHR_E_UNAVAIL; } + dev->suspended = false; + if (dev->flags & PDMA_ABORT) { /* * H/W configuration of Packet DMA is gone in the FFB apply phase, @@ -215,7 +226,6 @@ bcmcnet_pdma_dev_resume(struct pdma_dev *dev) dev->ops->tx_queue_intr_enable(dev, qi); dev->ops->tx_queue_start(dev, qi); } - dev->flags &= ~PDMA_ABORT; } rv = dev->ops->dev_resume(dev); @@ -223,7 +233,9 @@ bcmcnet_pdma_dev_resume(struct pdma_dev *dev) return rv; } - dev->suspended = false; + if (dev->flags & PDMA_ABORT) { + dev->flags &= ~PDMA_ABORT; + } return rv; } @@ -710,7 +722,7 @@ bcmcnet_group_intr_check(struct pdma_dev *dev, int group) int bcmcnet_rx_queue_poll(struct pdma_dev *dev, int queue, int budget) { - if (dev->started == 0) { + if (!dev->started) { return SHR_E_NONE; } @@ -727,7 +739,7 @@ bcmcnet_rx_queue_poll(struct pdma_dev *dev, int queue, int budget) int bcmcnet_tx_queue_poll(struct pdma_dev *dev, int queue, int budget) { - if (dev->started == 0) { + if (!dev->started) { return SHR_E_NONE; } @@ -744,7 +756,7 @@ bcmcnet_tx_queue_poll(struct pdma_dev *dev, int queue, int budget) int bcmcnet_queue_poll(struct pdma_dev *dev, struct intr_handle *hdl, int budget) { - if (dev->started == 0) { + if (!dev->started) { return SHR_E_NONE; } @@ -761,7 +773,7 @@ bcmcnet_queue_poll(struct pdma_dev *dev, struct intr_handle *hdl, int budget) int bcmcnet_group_poll(struct pdma_dev *dev, int group, int budget) { - if (dev->started == 0) { + if (!dev->started) { return SHR_E_NONE; } diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c index 7b0344e83c30..ab91bdfd0760 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_dev.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -143,7 +143,7 @@ bcn_tx_queues_alloc(struct pdma_dev *dev) txq->group_id = gi; txq->chan_id = qi + gi * dev->grp_queues; txq->ctrl = ctrl; - txq->sem = sal_sem_create("bcmcnetTxMutexSem", SAL_SEM_BINARY, 0); + txq->sem = sal_sem_create("bcmcnetTxMutexSem", SAL_SEM_BINARY, 1); if (!txq->sem) { goto error; } @@ -220,8 +220,8 @@ bcn_rx_queue_group_parse(struct pdma_dev *dev, uint32_t qbm) } rxq->buf_size += dev->rx_ph_size; /* Set mode and state for the queue */ - rxq->mode = bm->rx_buf_mode(dev, rxq); - rxq->state = PDMA_RX_QUEUE_USED; + rxq->buf_mode = bm->rx_buf_mode(dev, rxq); + rxq->state |= PDMA_RX_QUEUE_USED; if (dev->flags & PDMA_RX_BATCHING) { rxq->free_thresh = rxq->nb_desc / 4; rxq->state |= PDMA_RX_BATCH_REFILL; @@ -297,7 +297,7 @@ bcn_tx_queue_group_parse(struct pdma_dev *dev, uint32_t qbm) ctrl->grp[gi].nb_desc[qi] = txq->nb_desc; } /* Set mode and state for the queue */ - txq->state = PDMA_TX_QUEUE_USED; + txq->state |= PDMA_TX_QUEUE_USED; if (dev->flags & PDMA_TX_POLLING) { txq->free_thresh = txq->nb_desc / 4; txq->state |= PDMA_TX_QUEUE_POLL; @@ -364,7 +364,7 @@ bcmcnet_pdma_config(struct pdma_dev *dev, uint32_t bm_rxq, uint32_t bm_txq) } /* Update group metadata */ if (!ctrl->grp[gi].bm_rxq && !ctrl->grp[gi].bm_txq) { - ctrl->grp[gi].attached = 0; + ctrl->grp[gi].attached = false; ctrl->bm_grp &= ~(1 << gi); ctrl->nb_grp--; continue; @@ -398,7 +398,7 @@ bcmcnet_pdma_close(struct pdma_dev *dev) ctrl->nb_grp--; ctrl->grp[gi].irq_mask = 0; ctrl->grp[gi].poll_queues = 0; - ctrl->grp[gi].attached = 0; + ctrl->grp[gi].attached = false; } bcn_rx_queues_free(dev); @@ -420,8 +420,12 @@ bcmcnet_pdma_suspend(struct pdma_dev *dev) bcmcnet_pdma_rx_queue_suspend(dev, qi); } - for (qi = 0; qi < ctrl->nb_txq; qi++) { - bcmcnet_pdma_tx_queue_suspend(dev, qi); + if (dev->ndev_detach) { + dev->ndev_detach(dev); + } else { + for (qi = 0; qi < ctrl->nb_txq; qi++) { + bcmcnet_pdma_tx_queue_suspend(dev, qi); + } } return SHR_E_NONE; @@ -436,12 +440,16 @@ bcmcnet_pdma_resume(struct pdma_dev *dev) struct dev_ctrl *ctrl = &dev->ctrl; uint32_t qi; - for (qi = 0; qi < ctrl->nb_rxq; qi++) { - bcmcnet_pdma_rx_queue_resume(dev, qi); + if (dev->ndev_attach) { + dev->ndev_attach(dev); + } else { + for (qi = 0; qi < ctrl->nb_txq; qi++) { + bcmcnet_pdma_tx_queue_resume(dev, qi); + } } - for (qi = 0; qi < ctrl->nb_txq; qi++) { - bcmcnet_pdma_tx_queue_resume(dev, qi); + for (qi = 0; qi < ctrl->nb_rxq; qi++) { + bcmcnet_pdma_rx_queue_resume(dev, qi); } return SHR_E_NONE; @@ -485,6 +493,7 @@ bcmcnet_pdma_info_get(struct pdma_dev *dev) } dev->info.rx_buf_size[qi] = rxq->buf_size; dev->info.nb_rx_desc[qi] = rxq->nb_desc; + dev->info.rxq_state[qi] = rxq->state; } for (qi = 0; qi < ctrl->nb_txq; qi++) { @@ -493,6 +502,7 @@ bcmcnet_pdma_info_get(struct pdma_dev *dev) continue; } dev->info.nb_tx_desc[qi] = txq->nb_desc; + dev->info.txq_state[qi] = txq->state; } } @@ -681,7 +691,6 @@ bcmcnet_pdma_rx_queue_start(struct pdma_dev *dev, int queue) rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; rxq->state |= PDMA_RX_QUEUE_ACTIVE; - rxq->state &= ~PDMA_RX_QUEUE_XOFF; return hw->hdls.chan_start(hw, rxq->chan_id); } @@ -702,7 +711,6 @@ bcmcnet_pdma_rx_queue_stop(struct pdma_dev *dev, int queue) rxq = (struct pdma_rx_queue *)ctrl->rx_queue[queue]; rxq->state &= ~PDMA_RX_QUEUE_ACTIVE; - rxq->state |= PDMA_RX_QUEUE_XOFF; return hw->hdls.chan_stop(hw, rxq->chan_id); } @@ -723,7 +731,6 @@ bcmcnet_pdma_tx_queue_start(struct pdma_dev *dev, int queue) txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; txq->state |= PDMA_TX_QUEUE_ACTIVE; - txq->state &= ~PDMA_TX_QUEUE_XOFF; return dev->flags & PDMA_CHAIN_MODE ? SHR_E_NONE : hw->hdls.chan_start(hw, txq->chan_id); @@ -745,7 +752,6 @@ bcmcnet_pdma_tx_queue_stop(struct pdma_dev *dev, int queue) txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; txq->state &= ~PDMA_TX_QUEUE_ACTIVE; - txq->state |= PDMA_TX_QUEUE_XOFF; return hw->hdls.chan_stop(hw, txq->chan_id); } @@ -876,7 +882,11 @@ bcmcnet_pdma_tx_queue_intr_disable(struct pdma_dev *dev, int queue) txq = (struct pdma_tx_queue *)ctrl->tx_queue[queue]; - return hw->hdls.chan_intr_disable(hw, txq->chan_id); + if (txq->state & PDMA_TX_QUEUE_POLL) { + return SHR_E_NONE; + } else { + return hw->hdls.chan_intr_disable(hw, txq->chan_id); + } } /*! @@ -1008,8 +1018,8 @@ bcmcnet_pdma_open(struct pdma_dev *dev) hdl->group = gi; hdl->chan = chan; hdl->dev = dev; - hdl->intr_num = hw->hdls.chan_intr_num_get(hw, chan); - if (hdl->intr_num < 0) { + hdl->inum = hw->hdls.chan_intr_num_get(hw, chan); + if (hdl->inum < 0) { return SHR_E_INTERNAL; } } diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c index 41504949876b..6f42236eb08f 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c +++ b/platform/broadcom/saibcm-modules/sdklt/bcmcnet/main/bcmcnet_rxtx.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -212,8 +212,8 @@ bcmcnet_pdma_rx_queue_setup(struct pdma_dev *dev, int queue) } if (dev->mode == DEV_MODE_VNET) { - ctrl->vsync.rx_ring_addr[queue] = rxq->ring_addr; - ctrl->vsync.rx_ring_size[queue] = rxq->nb_desc; + ctrl->vsync.rx_ring_addr[rxq->chan_id] = rxq->ring_addr; + ctrl->vsync.rx_ring_size[rxq->chan_id] = rxq->nb_desc; } rxq->state |= PDMA_RX_QUEUE_SETUP; @@ -273,14 +273,12 @@ bcmcnet_pdma_rx_vqueue_setup(struct pdma_dev *dev, int queue) return SHR_E_NONE; } - if (dev->ctrl.vsync.rx_ring_addr[queue]) { + if (dev->ctrl.vsync.rx_ring_addr[vrxq->chan_id]) { vrxq->curr = 0; - vrxq->nb_desc = dev->ctrl.vsync.rx_ring_size[queue]; - vrxq->ring_addr = dev->ctrl.vsync.rx_ring_addr[queue]; + vrxq->nb_desc = dev->ctrl.vsync.rx_ring_size[vrxq->chan_id]; + vrxq->ring_addr = dev->ctrl.vsync.rx_ring_addr[vrxq->chan_id]; vrxq->ring = dev->sys_p2v(dev, vrxq->ring_addr); vrxq->state |= PDMA_RX_QUEUE_SETUP; - } else { - return SHR_E_UNAVAIL; } return SHR_E_NONE; @@ -331,8 +329,8 @@ bcmcnet_pdma_tx_queue_setup(struct pdma_dev *dev, int queue) } if (dev->mode == DEV_MODE_VNET) { - ctrl->vsync.tx_ring_addr[queue] = txq->ring_addr; - ctrl->vsync.tx_ring_size[queue] = txq->nb_desc; + ctrl->vsync.tx_ring_addr[txq->chan_id] = txq->ring_addr; + ctrl->vsync.tx_ring_size[txq->chan_id] = txq->nb_desc; } txq->state |= PDMA_TX_QUEUE_SETUP; @@ -392,15 +390,13 @@ bcmcnet_pdma_tx_vqueue_setup(struct pdma_dev *dev, int queue) return SHR_E_NONE; } - if (dev->ctrl.vsync.tx_ring_addr[queue]) { + if (dev->ctrl.vsync.tx_ring_addr[vtxq->chan_id]) { vtxq->curr = 0; vtxq->dirt = 0; - vtxq->nb_desc = dev->ctrl.vsync.tx_ring_size[queue]; - vtxq->ring_addr = dev->ctrl.vsync.tx_ring_addr[queue]; + vtxq->nb_desc = dev->ctrl.vsync.tx_ring_size[vtxq->chan_id]; + vtxq->ring_addr = dev->ctrl.vsync.tx_ring_addr[vtxq->chan_id]; vtxq->ring = dev->sys_p2v(dev, vtxq->ring_addr); vtxq->state |= PDMA_TX_QUEUE_SETUP; - } else { - return SHR_E_UNAVAIL; } return SHR_E_NONE; @@ -588,7 +584,8 @@ bcmcnet_pdma_group_poll(struct pdma_dev *dev, int group, int budget) if (hw->hdls.chan_intr_query(hw, rxq->chan_id)) { hw->hdls.chan_clear(hw, rxq->chan_id); grp->poll_queues |= 1 << i; - } else if (rxq->state & PDMA_RX_QUEUE_BUSY) { + } + if (rxq->state & PDMA_RX_QUEUE_BUSY) { rxq->state &= ~PDMA_RX_QUEUE_BUSY; grp->poll_queues |= 1 << i; } @@ -600,6 +597,10 @@ bcmcnet_pdma_group_poll(struct pdma_dev *dev, int group, int budget) hw->hdls.chan_clear(hw, txq->chan_id); grp->poll_queues |= 1 << i; } + if (txq->state & PDMA_TX_QUEUE_BUSY) { + txq->state &= ~PDMA_TX_QUEUE_BUSY; + grp->poll_queues |= 1 << i; + } } } @@ -664,7 +665,9 @@ bcmcnet_pdma_rx_ring_dump(struct pdma_dev *dev, int queue) } if (dev->mode == DEV_MODE_HNET) { rxq = (struct pdma_rx_queue *)ctrl->vnet_rxq[queue]; - hw->dops.rx_ring_dump(hw, rxq); + if (rxq->state & PDMA_RX_QUEUE_SETUP) { + hw->dops.rx_ring_dump(hw, rxq); + } } return SHR_E_NONE; @@ -690,7 +693,9 @@ bcmcnet_pdma_tx_ring_dump(struct pdma_dev *dev, int queue) } if (dev->mode == DEV_MODE_HNET) { txq = (struct pdma_tx_queue *)ctrl->vnet_txq[queue]; - hw->dops.tx_ring_dump(hw, txq); + if (txq->state & PDMA_TX_QUEUE_SETUP) { + hw->dops.tx_ring_dump(hw, txq); + } } return SHR_E_NONE; diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h index 4a2384760820..5ede02035a9c 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd/bcmdrd_devlist.h @@ -4,7 +4,7 @@ * Edits to this file will be lost when it is regenerated. * Tool: INTERNAL/drd/instpkgs.pl * - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -37,6 +37,31 @@ #define BROADCOM_VENDOR_ID 0x14e4 #define BROADCOM_PHYID_MSB 0x0143 +/* BCM56080 */ +#define BCM56080_VENDOR_ID 0x14e4 +#define BCM56080_DEVICE_ID 0xb080 +#define BCM56080_REV_A0 0x01 + +/* BCM56081 */ +#define BCM56081_VENDOR_ID 0x14e4 +#define BCM56081_DEVICE_ID 0xb081 +#define BCM56081_REV_A0 0x01 + +/* BCM56082 */ +#define BCM56082_VENDOR_ID 0x14e4 +#define BCM56082_DEVICE_ID 0xb082 +#define BCM56082_REV_A0 0x01 + +/* BCM56083 */ +#define BCM56083_VENDOR_ID 0x14e4 +#define BCM56083_DEVICE_ID 0xb083 +#define BCM56083_REV_A0 0x01 + +/* BCM56084 */ +#define BCM56084_VENDOR_ID 0x14e4 +#define BCM56084_DEVICE_ID 0xb084 +#define BCM56084_REV_A0 0x01 + /* BCM56780 */ #define BCM56780_VENDOR_ID 0x14e4 #define BCM56780_DEVICE_ID 0xb780 @@ -95,6 +120,31 @@ #define BCM56883_REV_A0 0x01 #define BCM56883_REV_B0 0x11 +/* BCM56890 */ +#define BCM56890_VENDOR_ID 0x14e4 +#define BCM56890_DEVICE_ID 0xb890 +#define BCM56890_REV_A0 0x01 + +/* BCM56891 */ +#define BCM56891_VENDOR_ID 0x14e4 +#define BCM56891_DEVICE_ID 0xb891 +#define BCM56891_REV_A0 0x01 + +/* BCM56892 */ +#define BCM56892_VENDOR_ID 0x14e4 +#define BCM56892_DEVICE_ID 0xb892 +#define BCM56892_REV_A0 0x01 + +/* BCM56895 */ +#define BCM56895_VENDOR_ID 0x14e4 +#define BCM56895_DEVICE_ID 0xb895 +#define BCM56895_REV_A0 0x01 + +/* BCM56896 */ +#define BCM56896_VENDOR_ID 0x14e4 +#define BCM56896_DEVICE_ID 0xb896 +#define BCM56896_REV_A0 0x01 + /* BCM56990 */ #define BCM56990_VENDOR_ID 0x14e4 #define BCM56990_DEVICE_ID 0xb990 @@ -111,10 +161,10 @@ #define BCM56992_DEVICE_ID 0xb992 #define BCM56992_REV_B0 0x11 -/* BCM56995 */ -#define BCM56995_VENDOR_ID 0x14e4 -#define BCM56995_DEVICE_ID 0xb995 -#define BCM56995_REV_A0 0x01 +/* BCM56993 */ +#define BCM56993_VENDOR_ID 0x14e4 +#define BCM56993_DEVICE_ID 0xb993 +#define BCM56993_REV_B0 0x11 /* BCM56996 */ #define BCM56996_VENDOR_ID 0x14e4 @@ -133,6 +183,28 @@ #define BCM56998_DEVICE_ID 0xb998 #define BCM56998_REV_A0 0x01 +/* BCM56995 */ +#define BCM56995_VENDOR_ID 0x14e4 +#define BCM56995_DEVICE_ID 0xb995 +#define BCM56995_REV_A0 0x01 +#define BCM56995_REV_B0 0x11 + +/* BCM56999 */ +#define BCM56999_VENDOR_ID 0x14e4 +#define BCM56999_DEVICE_ID 0xb999 +#define BCM56999_REV_A0 0x01 +#define BCM56999_REV_B0 0x11 + +/* BCM78900 */ +#define BCM78900_VENDOR_ID 0x14e4 +#define BCM78900_DEVICE_ID 0xf900 +#define BCM78900_REV_B0 0x11 + +/* BCM78905 */ +#define BCM78905_VENDOR_ID 0x14e4 +#define BCM78905_DEVICE_ID 0xf905 +#define BCM78905_REV_B0 0x11 + /* * End of Supported Devices and Revisions */ @@ -166,6 +238,54 @@ * Note that this macro will be undefined at the end of this file. */ +#if BCMDRD_CONFIG_INCLUDE_BCM56080_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56080, BCM56080_VENDOR_ID, BCM56080_DEVICE_ID, BCM56080_REV_A0, \ + 0, 0, \ + bcm56080_a0, bcm56080_a0, bcm56080_a0, \ + "Pex1", "BCM56080", \ + "1.6 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56081_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56081, BCM56081_VENDOR_ID, BCM56081_DEVICE_ID, BCM56081_REV_A0, \ + 0, 0, \ + bcm56080_a0, bcm56081_a0, bcm56081_a0, \ + "Pex1", "BCM56080", \ + "1.2 Tbps Line Card w/MACsec", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56082_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56082, BCM56082_VENDOR_ID, BCM56082_DEVICE_ID, BCM56082_REV_A0, \ + 0, 0, \ + bcm56080_a0, bcm56082_a0, bcm56082_a0, \ + "Pex1", "BCM56080", \ + "1.08 Tbps Line Card w/MACsec", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56083_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56083, BCM56083_VENDOR_ID, BCM56083_DEVICE_ID, BCM56083_REV_A0, \ + 0, 0, \ + bcm56080_a0, bcm56083_a0, bcm56083_a0, \ + "Pex1", "BCM56080", \ + "1.2 Tbps Line Card", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56084_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56084, BCM56084_VENDOR_ID, BCM56084_DEVICE_ID, BCM56084_REV_A0, \ + 0, 0, \ + bcm56080_a0, bcm56084_a0, bcm56084_a0, \ + "Pex1", "BCM56080", \ + "1.08 Tbps Line Card", 0, 0) +#endif +#endif + #if BCMDRD_CONFIG_INCLUDE_BCM56780_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) BCMDRD_DEVLIST_ENTRY(BCM56780, BCM56780_VENDOR_ID, BCM56780_DEVICE_ID, BCM56780_REV_A0, \ 0, 0, \ @@ -302,6 +422,54 @@ BCMDRD_DEVLIST_ENTRY(BCM56883, BCM56883_VENDOR_ID, BCM56883_DEVICE_ID, BCM56883_ #endif #endif +#if BCMDRD_CONFIG_INCLUDE_BCM56890_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56890, BCM56890_VENDOR_ID, BCM56890_DEVICE_ID, BCM56890_REV_A0, \ + 0, 0, \ + bcm56890_a0, bcm56890_a0, bcm56890_a0, \ + "Trident4-X11C", "BCM56890", \ + "12.8 Tb/s 256x50G-PAM4 Programmable Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56891_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56891, BCM56891_VENDOR_ID, BCM56891_DEVICE_ID, BCM56891_REV_A0, \ + 0, 0, \ + bcm56890_a0, bcm56891_a0, bcm56891_a0, \ + "Trident4-X11C", "BCM56890", \ + "12.8 Tb/s 256x50G-PAM4 Programmable Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56892_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56892, BCM56892_VENDOR_ID, BCM56892_DEVICE_ID, BCM56892_REV_A0, \ + 0, 0, \ + bcm56890_a0, bcm56892_a0, bcm56892_a0, \ + "Trident4-X11C", "BCM56890", \ + "12.8 Tb/s 256x50G-PAM4 Programmable Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56895_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56895, BCM56895_VENDOR_ID, BCM56895_DEVICE_ID, BCM56895_REV_A0, \ + 0, 0, \ + bcm56890_a0, bcm56895_a0, bcm56895_a0, \ + "Trident4-X11C", "BCM56890", \ + "6.4 Tb/s 128x50G-PAM4 Programmable Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56896_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56896, BCM56896_VENDOR_ID, BCM56896_DEVICE_ID, BCM56896_REV_A0, \ + 0, 0, \ + bcm56890_a0, bcm56896_a0, bcm56896_a0, \ + "Trident4-X11C", "BCM56890", \ + "6.4 Tb/s 256x50G-PAM4 Programmable Switch", 0, 0) +#endif +#endif + #if BCMDRD_CONFIG_INCLUDE_BCM56990_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) BCMDRD_DEVLIST_ENTRY(BCM56990, BCM56990_VENDOR_ID, BCM56990_DEVICE_ID, BCM56990_REV_A0, \ 0, 0, \ @@ -338,12 +506,14 @@ BCMDRD_DEVLIST_ENTRY(BCM56992, BCM56992_VENDOR_ID, BCM56992_DEVICE_ID, BCM56992_ #endif #endif -#if BCMDRD_CONFIG_INCLUDE_BCM56995_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) -BCMDRD_DEVLIST_ENTRY(BCM56995, BCM56995_VENDOR_ID, BCM56995_DEVICE_ID, BCM56995_REV_A0, \ +#if BCMDRD_CONFIG_INCLUDE_BCM56993_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56993, BCM56993_VENDOR_ID, BCM56993_DEVICE_ID, BCM56993_REV_B0, \ 0, 0, \ - bcm56995_a0, bcm56995_a0, bcm56995_a0, \ - "Tomahawk4D", "BCM56995", \ - "25.6 Tbps Multilayer Switch", 0, 0) + bcm56990_b0, bcm56993_b0, bcm56993_b0, \ + "Tomahawk4", "BCM56990", \ + "12.8 Tbps Multilayer Switch", 0, 0) +#endif #endif #if BCMDRD_CONFIG_INCLUDE_BCM56996_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) @@ -390,6 +560,62 @@ BCMDRD_DEVLIST_ENTRY(BCM56998, BCM56998_VENDOR_ID, BCM56998_DEVICE_ID, BCM56998_ "12.8 Tbps Multilayer Switch", 0, 0) #endif +#if BCMDRD_CONFIG_INCLUDE_BCM56995_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56995, BCM56995_VENDOR_ID, BCM56995_DEVICE_ID, BCM56995_REV_A0, \ + 0, 0, \ + bcm56999_a0, bcm56995_a0, bcm56995_a0, \ + "Tomahawk4D", "BCM56999", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56995_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56995, BCM56995_VENDOR_ID, BCM56995_DEVICE_ID, BCM56995_REV_B0, \ + 0, 0, \ + bcm56999_a0, bcm56995_a0, bcm56995_b0, \ + "Tomahawk4D", "BCM56999", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56999_A0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM56999, BCM56999_VENDOR_ID, BCM56999_DEVICE_ID, BCM56999_REV_A0, \ + 0, 0, \ + bcm56999_a0, bcm56999_a0, bcm56999_a0, \ + "Tomahawk4D", "BCM56999", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM56999_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM56999, BCM56999_VENDOR_ID, BCM56999_DEVICE_ID, BCM56999_REV_B0, \ + 0, 0, \ + bcm56999_a0, bcm56999_a0, bcm56999_b0, \ + "Tomahawk4D", "BCM56999", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM78900_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +BCMDRD_DEVLIST_ENTRY(BCM78900, BCM78900_VENDOR_ID, BCM78900_DEVICE_ID, BCM78900_REV_B0, \ + 0, 0, \ + bcm78900_b0, bcm78900_b0, bcm78900_b0, \ + "Tomahawk5", "BCM78900", \ + "51.2 Tbps Multilayer Switch", 0, 0) +#endif + +#if BCMDRD_CONFIG_INCLUDE_BCM78905_B0 == 1 || defined(BCMDRD_DEVLIST_OVERRIDE) +#ifdef BCMDRD_DEVLIST_INCLUDE_ALL +BCMDRD_DEVLIST_ENTRY(BCM78905, BCM78905_VENDOR_ID, BCM78905_DEVICE_ID, BCM78905_REV_B0, \ + 0, 0, \ + bcm78900_b0, bcm78905_b0, bcm78905_b0, \ + "Tomahawk5", "BCM78900", \ + "25.6 Tbps Multilayer Switch", 0, 0) +#endif +#endif + /* End BCMDRD_DEVLIST_ENTRY Macros */ #ifdef BCMDRD_DEVLIST_INCLUDE_ALL diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h index 42b1d5619aee..455f748e9077 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config.h @@ -1,21 +1,4 @@ -/* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. - * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * A copy of the GNU General Public License version 2 (GPLv2) can - * be found in the LICENSES folder.$ - * - * DO NOT EDIT THIS FILE! - * This file will be auto-generated in the near future. +/*! \file bcmdrd_config.h * * This config file defines all compilation-time specifications for * the BCMDRD. @@ -40,13 +23,27 @@ * compilation * d) Make sure the compilation include path includes * 'bcmdrd_custom_config.h' - * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ */ #ifndef BCMDRD_CONFIG_H #define BCMDRD_CONFIG_H - /* * Include system config file if specified: */ @@ -54,48 +51,37 @@ #include #endif - /* * OPTIONAL configuration and feature values. * Defaults are provided for all non-specified values. */ -/* Maximum number of chips supported */ +/*! Maximum number of chips supported. */ #ifndef BCMDRD_CONFIG_MAX_UNITS #define BCMDRD_CONFIG_MAX_UNITS 8 #endif -/* Maximum number of ports per chip supported */ +/*! Maximum number of ports per chip supported. */ #ifndef BCMDRD_CONFIG_MAX_PORTS #define BCMDRD_CONFIG_MAX_PORTS 848 #endif -/* Maximum number of SCHAN polls */ -#ifndef BCMDRD_CONFIG_SCHAN_MAX_POLLS -#define BCMDRD_CONFIG_SCHAN_MAX_POLLS 100000 -#endif - -/* Maximum number of MIIM polls */ -#ifndef BCMDRD_CONFIG_MIIM_MAX_POLLS -#define BCMDRD_CONFIG_MIIM_MAX_POLLS 100000 -#endif - -/* Direct access to memory-mapped registers */ +/*! Direct access to memory-mapped registers. */ #ifndef BCMDRD_CONFIG_MEMMAP_DIRECT #define BCMDRD_CONFIG_MEMMAP_DIRECT 0 #endif -/* - * Include chip symbol tables for the debug shell. +/*! + * \brief Include chip symbol tables. * * No symbolic debugging (register/memory names) will be available * without this defined. * - * You should enable at least these symbols if you can afford the - * space. - * * This define is required to get any symbols at all. * + * Symbols tables are required for normal SDK operation, but may be + * excluded for small footprint base driver applications. + * * If you only wish to include symbols for a subset of chips in the * system (probably for code space reasons), you can define the * following for each chip whose symbols you wish to EXCLUDE: @@ -107,14 +93,17 @@ #define BCMDRD_CONFIG_INCLUDE_CHIP_SYMBOLS 1 #endif -/* - * Include register and memory field information for the debug shell. +/*! + * \brief Include register and memory field information. * * This provides encoding, decoding, and displaying individual field * values for each register and memory. * * Requires more code space than just the chip symbols alone. * + * Symbols field information is required for normal SDK operation, but + * may be excluded for small footprint base driver applications. + * * The per-chip exclusion define * (BCMDRD_CONFIG_EXCLUDE_FIELD_INFO_) also applies. */ @@ -122,8 +111,8 @@ #define BCMDRD_CONFIG_INCLUDE_FIELD_INFO 1 #endif -/* - * Include alternative symbol names for registers and memories. +/*! + * \brief Include alternative symbol names for registers and memories. * * Mainly for internal Broadcom use, so you can safely leave this * option off. @@ -132,6 +121,18 @@ #define BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES 1 #endif +/*! + * \brief Include field size checks for registers and memories. + * + * This option adds compile-time checks for field values exceeding the + * size of the field being assigned. The check in mainly intended for + * internal use, and it may trigger warnings from various memory + * sanity checker tools. + */ +#ifndef BCMDRD_CONFIG_INCLUDE_FIELD_CHECKS +#define BCMDRD_CONFIG_INCLUDE_FIELD_CHECKS 0 +#endif + #endif /* BCMDRD_CONFIG_H */ #ifdef CONFIG_OPTION @@ -144,12 +145,6 @@ CONFIG_OPTION(BCMDRD_CONFIG_MAX_UNITS) #ifdef BCMDRD_CONFIG_MAX_PORTS CONFIG_OPTION(BCMDRD_CONFIG_MAX_PORTS) #endif -#ifdef BCMDRD_CONFIG_SCHAN_MAX_POLLS -CONFIG_OPTION(BCMDRD_CONFIG_SCHAN_MAX_POLLS) -#endif -#ifdef BCMDRD_CONFIG_MIIM_MAX_POLLS -CONFIG_OPTION(BCMDRD_CONFIG_MIIM_MAX_POLLS) -#endif #ifdef BCMDRD_CONFIG_MEMMAP_DIRECT CONFIG_OPTION(BCMDRD_CONFIG_MEMMAP_DIRECT) #endif @@ -162,5 +157,8 @@ CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_FIELD_INFO) #ifdef BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_ALIAS_NAMES) #endif +#ifdef BCMDRD_CONFIG_INCLUDE_FIELD_CHECKS +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_FIELD_CHECKS) +#endif #endif /* CONFIG_OPTION */ #include "bcmdrd_config_chips.h" diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h index 41fb6c64a141..1fa1afd92af0 100644 --- a/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h +++ b/platform/broadcom/saibcm-modules/sdklt/bcmdrd/include/bcmdrd_config_chips.h @@ -4,7 +4,7 @@ * Edits to this file will be lost when it is regenerated. * Tool: INTERNAL/drd/instpkgs.pl * - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -26,17 +26,17 @@ * * (1) #define BCMDRD_CONFIG_INCLUDE_ [1|0] * -- Include or exclude all revisions of the given device - * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780 1 + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56080 1 * * (2) #define BCMDRD_CONFIG_INCLUDE__X [1|0] * -- Include or exclude all versions of the given revision - * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780_Ax 0 - * #define BCMDRD_CONFIG_INCLUde_BCM56780_Bx 1 + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56080_Ax 0 + * #define BCMDRD_CONFIG_INCLUde_BCM56080_Bx 1 * * (3) #define BCMDRD_CONFIG_INCLUDE_ [1|0] * -- Include or exclude an exact device - * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56780_A0 1 - * #define BCMDRD_CONFIG_INCLUDE_BCM56780_A1 0 + * Example: #define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 1 + * #define BCMDRD_CONFIG_INCLUDE_BCM56080_A1 0 * * * The value of BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT is used for any @@ -57,6 +57,135 @@ * Default configuration and dependencies for all chips */ +/* + * BCM56080 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080 +#define BCMDRD_CONFIG_INCLUDE_BCM56080 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56080_Ax BCMDRD_CONFIG_INCLUDE_BCM56080 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 BCMDRD_CONFIG_INCLUDE_BCM56080_Ax +#endif + + +/* + * BCM56081 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56081 +#define BCMDRD_CONFIG_INCLUDE_BCM56081 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56081_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56081_Ax BCMDRD_CONFIG_INCLUDE_BCM56081 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56081_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56081_A0 BCMDRD_CONFIG_INCLUDE_BCM56081_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56081_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56080_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56082 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56082 +#define BCMDRD_CONFIG_INCLUDE_BCM56082 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56082_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56082_Ax BCMDRD_CONFIG_INCLUDE_BCM56082 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56082_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56082_A0 BCMDRD_CONFIG_INCLUDE_BCM56082_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56082_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56080_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56083 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56083 +#define BCMDRD_CONFIG_INCLUDE_BCM56083 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56083_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56083_Ax BCMDRD_CONFIG_INCLUDE_BCM56083 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56083_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56083_A0 BCMDRD_CONFIG_INCLUDE_BCM56083_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56083_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56080_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56084 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56084 +#define BCMDRD_CONFIG_INCLUDE_BCM56084 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56084_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56084_Ax BCMDRD_CONFIG_INCLUDE_BCM56084 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56084_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56084_A0 BCMDRD_CONFIG_INCLUDE_BCM56084_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56084_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56080_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56080_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED 1 +#endif +#endif + + /* * BCM56780 */ @@ -386,6 +515,135 @@ #endif +/* + * BCM56890 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890 +#define BCMDRD_CONFIG_INCLUDE_BCM56890 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56890_Ax BCMDRD_CONFIG_INCLUDE_BCM56890 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 BCMDRD_CONFIG_INCLUDE_BCM56890_Ax +#endif + + +/* + * BCM56891 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56891 +#define BCMDRD_CONFIG_INCLUDE_BCM56891 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56891_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56891_Ax BCMDRD_CONFIG_INCLUDE_BCM56891 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56891_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56891_A0 BCMDRD_CONFIG_INCLUDE_BCM56891_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56891_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56890_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56892 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56892 +#define BCMDRD_CONFIG_INCLUDE_BCM56892 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56892_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56892_Ax BCMDRD_CONFIG_INCLUDE_BCM56892 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56892_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56892_A0 BCMDRD_CONFIG_INCLUDE_BCM56892_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56892_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56890_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56895 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56895 +#define BCMDRD_CONFIG_INCLUDE_BCM56895 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56895_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56895_Ax BCMDRD_CONFIG_INCLUDE_BCM56895 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56895_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56895_A0 BCMDRD_CONFIG_INCLUDE_BCM56895_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56895_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56890_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56896 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56896 +#define BCMDRD_CONFIG_INCLUDE_BCM56896 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56896_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56896_Ax BCMDRD_CONFIG_INCLUDE_BCM56896 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56896_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56896_A0 BCMDRD_CONFIG_INCLUDE_BCM56896_Ax +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56896_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56890_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56890_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED 1 +#endif +#endif + + /* * BCM56990 */ @@ -466,19 +724,30 @@ /* - * BCM56995 + * BCM56993 */ /* Sets the default include state if it was not given */ -#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995 -#define BCMDRD_CONFIG_INCLUDE_BCM56995 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56993 +#define BCMDRD_CONFIG_INCLUDE_BCM56993 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT #endif /* Resolve revision dependencies */ -#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_Ax -#define BCMDRD_CONFIG_INCLUDE_BCM56995_Ax BCMDRD_CONFIG_INCLUDE_BCM56995 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56993_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56993_Bx BCMDRD_CONFIG_INCLUDE_BCM56993 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56993_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56993_B0 BCMDRD_CONFIG_INCLUDE_BCM56993_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56993_B0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56990_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56990_B0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56990_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56990_B0_IMPLIED 1 #endif -#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_A0 -#define BCMDRD_CONFIG_INCLUDE_BCM56995_A0 BCMDRD_CONFIG_INCLUDE_BCM56995_Ax #endif @@ -566,6 +835,126 @@ #endif +/* + * BCM56995 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995 +#define BCMDRD_CONFIG_INCLUDE_BCM56995 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56995_Ax BCMDRD_CONFIG_INCLUDE_BCM56995 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56995_A0 BCMDRD_CONFIG_INCLUDE_BCM56995_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56995_Bx BCMDRD_CONFIG_INCLUDE_BCM56995 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56995_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56995_B0 BCMDRD_CONFIG_INCLUDE_BCM56995_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56995_A0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56999_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0_IMPLIED 1 +#endif +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56995_B0 == 1 +#if BCMDRD_CONFIG_INCLUDE_BCM56999_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM56999 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999 +#define BCMDRD_CONFIG_INCLUDE_BCM56999 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_Ax +#define BCMDRD_CONFIG_INCLUDE_BCM56999_Ax BCMDRD_CONFIG_INCLUDE_BCM56999 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 BCMDRD_CONFIG_INCLUDE_BCM56999_Ax +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM56999_Bx BCMDRD_CONFIG_INCLUDE_BCM56999 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_B0 BCMDRD_CONFIG_INCLUDE_BCM56999_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM56999_B0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM56999_A0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM56999_A0 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM56999_A0_IMPLIED 1 +#endif +#endif + + +/* + * BCM78900 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78900 +#define BCMDRD_CONFIG_INCLUDE_BCM78900 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78900_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM78900_Bx BCMDRD_CONFIG_INCLUDE_BCM78900 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78900_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM78900_B0 BCMDRD_CONFIG_INCLUDE_BCM78900_Bx +#endif + + +/* + * BCM78905 + */ + +/* Sets the default include state if it was not given */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78905 +#define BCMDRD_CONFIG_INCLUDE_BCM78905 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +/* Resolve revision dependencies */ +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78905_Bx +#define BCMDRD_CONFIG_INCLUDE_BCM78905_Bx BCMDRD_CONFIG_INCLUDE_BCM78905 +#endif +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78905_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM78905_B0 BCMDRD_CONFIG_INCLUDE_BCM78905_Bx +#endif +/* Resolve all interchip dependencies */ +#if BCMDRD_CONFIG_INCLUDE_BCM78905_B0 == 1 +#ifndef BCMDRD_CONFIG_INCLUDE_BCM78900_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM78900_B0 BCMDRD_CONFIG_INCLUDE_CHIP_DEFAULT +#endif +#if BCMDRD_CONFIG_INCLUDE_BCM78900_B0 != 1 +#undef BCMDRD_CONFIG_INCLUDE_BCM78900_B0 +#define BCMDRD_CONFIG_INCLUDE_BCM78900_B0 1 +#define BCMDRD_CONFIG_INCLUDE_BCM78900_B0_IMPLIED 1 +#endif +#endif + + #endif /* BCMDRD_CONFIG_CHIPS_H */ /* @@ -573,6 +962,24 @@ */ #ifdef CONFIG_OPTION +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56080) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56080_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56080_A0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56080_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56081) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56081_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56081_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56082) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56082_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56082_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56083) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56083_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56083_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56084) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56084_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56084_A0) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780_Ax) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56780_A0) @@ -618,6 +1025,24 @@ CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_Ax) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_A0) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_Bx) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56883_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56890) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56890_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56890_A0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56890_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56891) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56891_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56891_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56892) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56892_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56892_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56895) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56895_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56895_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56896) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56896_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56896_A0) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_Ax) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56990_A0) @@ -635,12 +1060,9 @@ CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56991_B0) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992_Bx) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56992_B0) -CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995) -CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_Ax) -CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_A0) -#ifdef BCMDRD_CONFIG_INCLUDE_BCM56995_A0_IMPLIED -CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_A0_IMPLIED) -#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56993) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56993_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56993_B0) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996_Ax) CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56996_A0) @@ -663,5 +1085,27 @@ CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56998_A0) #ifdef BCMDRD_CONFIG_INCLUDE_BCM56998_A0_IMPLIED CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56998_A0_IMPLIED) #endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56995_B0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999_Ax) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999_A0) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999_B0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM56999_A0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM56999_A0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78900) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78900_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78900_B0) +#ifdef BCMDRD_CONFIG_INCLUDE_BCM78900_B0_IMPLIED +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78900_B0_IMPLIED) +#endif +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78905) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78905_Bx) +CONFIG_OPTION(BCMDRD_CONFIG_INCLUDE_BCM78905_B0) #undef CONFIG_OPTION #endif /* #ifdef CONFIG_OPTION */ diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/bcmlrd_variant.h b/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/bcmlrd_variant.h new file mode 100644 index 000000000000..2949f6626425 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/bcmlrd_variant.h @@ -0,0 +1,40 @@ +/*! \file bcmlrd_variant.h + * + * \brief BCMLRD Variant interfaces and definitions + * + * BCMLRD_VARIANT_ENTRY macros. + * + * If a list of variant entries is needed, before including this file, + * define BCMLRD_VARIANT_ENTRY as a macro. See bcmltd/include/bcmltd_variant.h + * for the parameters for BCMLRD_VARIANT_ENTRY, which are exactly the same as + * those for BCMLTD_VARIANT_ENTRY. + * + * Note that BCMLTD_VARIANT_ENTRY will be undefined at the end of this file. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMLRD_VARIANT_H +#define BCMLRD_VARIANT_H + +/* The contents between the include guard is deliberately empty. */ + +#endif /* BCMLRD_VARIANT_H */ + +/* This include must be placed outside the include guard. */ +#include diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/chip/bcmlrd_chip_variant.h b/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/chip/bcmlrd_chip_variant.h new file mode 100644 index 000000000000..1d746a2e981b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmlrd/include/bcmlrd/chip/bcmlrd_chip_variant.h @@ -0,0 +1,48 @@ +/*! \file bcmlrd_chip_variant.h + * + * \brief BCMLRD variant definitions + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMLRD_CHIP_VARIANT_H +#define BCMLRD_CHIP_VARIANT_H + +#include + +#endif /* BCMLRD_CHIP_VARIANT_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#ifdef BCMLTD_VARIANT_OVERRIDE +#error "Use BCMLRD_VARIANT_OVERRIDE instead." +#endif +#ifdef BCMLRD_VARIANT_OVERRIDE +#define BCMLTD_VARIANT_OVERRIDE +#endif +#ifdef BCMLRD_VARIANT_ENTRY +#define BCMLTD_VARIANT_ENTRY(...) BCMLRD_VARIANT_ENTRY(__VA_ARGS__) +#include +#ifdef BCMLRD_VARIANT_OVERRIDE +#undef BCMLRD_VARIANT_OVERRIDE +#endif +#undef BCMLRD_VARIANT_ENTRY +#endif /* BCMLRD_VARIANT_ENTRY */ + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/bcmltd_variant.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/bcmltd_variant.h new file mode 100644 index 000000000000..18abbe88055d --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/bcmltd_variant.h @@ -0,0 +1,64 @@ +/*! \file bcmltd_variant.h + * + * \brief BCMLTD Variant initerfaces and definitions + * + * Logical table variant inclusion and exclusion support within the + * BCMLTD can be specified as a combination of the following defines: + * + * #define BCMLTD_CONFIG_INCLUDE__X_ [1|0] + * -- Include or exclude the specified variant + * Example: #define BCMLTD_CONFIG_INCLUDE_BCM56880_UTLTM 1 + * + * The value of BCMLTD_CONFIG_INCLUDE_VARIANT_DEFAULT is used for any + * variants which are left unspecified. Set this value to 1 or 0 to + * include or exclude all variants by default. + * + * BCMLTD_VARIANT_ENTRY macros. + * + * If a list of variant entries is needed, before including this file, + * define BCMLTD_VARIANT_ENTRY as a macro to operate on the following + * parameters: + * + * #define BCMLTD_VARIANT_ENTRY(_bd,_bu,_va,_ve,_vu,_vv,_vo,_vd,_r0,_r1) + * + * _bd: SW Base Driver (lower case) + * _bu: SW Base Driver (upper case) + * _va: Variant name (lower case or empty for BASE) + * _ve: Variant enum symbol (upper case) + * _vu: Variant name (underscore or empty for BASE) + * _vv: Variant numeric value + * _vo: Device relative offset + * _vd: Variant Description + * _r0: Reserved + * _r1: Reserved + * + * Note that BCMLTD_VARIANT_ENTRY will be undefined at the end of this file. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMLTD_VARIANT_H +#define BCMLTD_VARIANT_H + +#include + +#endif /* BCMLTD_VARIANT_H */ + +/* This include must be placed outside the include guard. */ +#include + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_chip_variant.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_chip_variant.h new file mode 100644 index 000000000000..c4a5131ef2d2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_chip_variant.h @@ -0,0 +1,42 @@ +/*! \file bcmltd_chip_variant.h + * + * \brief BCMLTD variant definitions + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMLTD_CHIP_VARIANT_H +#define BCMLTD_CHIP_VARIANT_H + +#include + +#endif /* BCMLTD_CHIP_VARIANT_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#ifdef BCMLTD_VARIANT_ENTRY +#include +#ifdef BCMLTD_VARIANT_OVERRIDE +#undef BCMLTD_VARIANT_OVERRIDE +#endif +#undef BCMLTD_VARIANT_ENTRY + +#endif /* BCMLTD_VARIANT_ENTRY */ + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_variant_defs.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_variant_defs.h new file mode 100644 index 000000000000..2dfe7fe81277 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/chip/bcmltd_variant_defs.h @@ -0,0 +1,28 @@ +/*! \file bcmltd_variant_defs.h + * + * \brief BCMLTD variant definitions + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef BCMLTD_VARIANT_DEFS_H +#define BCMLTD_VARIANT_DEFS_H +#ifndef DOXYGEN_IGNORE_AUTOGEN +#include +#endif /* DOXYGEN_IGNORE_AUTOGEN */ +#endif /* BCMLTD_VARIANT_DEFS_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56080_a0/bcm56080_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56080_a0/bcm56080_a0_ltd_variant_def.h new file mode 100644 index 000000000000..eb0297e5ac7c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56080_a0/bcm56080_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56080_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56080_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56080_A0_BASE 1 +#define BCMLTD_VARIANT_LOCAL_BCM56080_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56080_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/bcm56780_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/bcm56780_a0_ltd_variant_def.h new file mode 100644 index 000000000000..a4a167739bca --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/bcm56780_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56780_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56780_A0_BASE 2 +#define BCMLTD_VARIANT_LOCAL_BCM56780_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56780_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_def.h new file mode 100644 index 000000000000..aa4b1b7dcfcb --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_DEF_H +#define GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56780_A0_CNA_1_2_13 12 +#define BCMLTD_VARIANT_LOCAL_BCM56780_A0_CNA_1_2_13 1 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_def.h new file mode 100644 index 000000000000..c6d9933996dc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_DEF_H +#define GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56780_A0_DNA_2_9_5_0 13 +#define BCMLTD_VARIANT_LOCAL_BCM56780_A0_DNA_2_9_5_0 2 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_def.h new file mode 100644 index 000000000000..607e1369508b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H +#define GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56780_A0_HNA_1_2_10_0 14 +#define BCMLTD_VARIANT_LOCAL_BCM56780_A0_HNA_1_2_10_0 3 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/bcm56880_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/bcm56880_a0_ltd_variant_def.h new file mode 100644 index 000000000000..7b3f82532223 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/bcm56880_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_BASE 3 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_def.h new file mode 100644 index 000000000000..e6efc2937edf --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_CNA_1_2_13 15 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_CNA_1_2_13 1 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_def.h new file mode 100644 index 000000000000..e7af41f9b460 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_DNA_4_11_4_0 16 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_DNA_4_11_4_0 2 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_def.h new file mode 100644 index 000000000000..1694f3a1ab09 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_HNA_1_2_10_0 17 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_HNA_1_2_10_0 3 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_def.h new file mode 100644 index 000000000000..154ab064843e --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTCFG_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_UTCFG_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_UTCFG 18 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTCFG 4 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_UTCFG_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_def.h new file mode 100644 index 000000000000..6a7659d095bb --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTLRD_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_UTLRD_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_UTLRD 19 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTLRD 5 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_UTLRD_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_def.h new file mode 100644 index 000000000000..ce6a7109d385 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTLTM_LTD_VARIANT_DEF_H +#define GEN_BCM56880_A0_UTLTM_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56880_A0_UTLTM 20 +#define BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTLTM 6 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56880_A0_UTLTM_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/bcm56890_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/bcm56890_a0_ltd_variant_def.h new file mode 100644 index 000000000000..067cd3aa6fd8 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/bcm56890_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56890_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56890_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56890_A0_BASE 4 +#define BCMLTD_VARIANT_LOCAL_BCM56890_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56890_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_def.h new file mode 100644 index 000000000000..fcea5c979c8a --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_DEF_H +#define GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56890_A0_DNA_4_0_17_0 21 +#define BCMLTD_VARIANT_LOCAL_BCM56890_A0_DNA_4_0_17_0 1 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_a0/bcm56990_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_a0/bcm56990_a0_ltd_variant_def.h new file mode 100644 index 000000000000..0b136b21dd3c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_a0/bcm56990_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56990_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56990_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56990_A0_BASE 5 +#define BCMLTD_VARIANT_LOCAL_BCM56990_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56990_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_b0/bcm56990_b0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_b0/bcm56990_b0_ltd_variant_def.h new file mode 100644 index 000000000000..72f72fbd1e17 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56990_b0/bcm56990_b0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56990_B0_LTD_VARIANT_DEF_H +#define GEN_BCM56990_B0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56990_B0_BASE 6 +#define BCMLTD_VARIANT_LOCAL_BCM56990_B0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56990_B0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_a0/bcm56996_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_a0/bcm56996_a0_ltd_variant_def.h new file mode 100644 index 000000000000..80ef0b123700 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_a0/bcm56996_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56996_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56996_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56996_A0_BASE 7 +#define BCMLTD_VARIANT_LOCAL_BCM56996_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56996_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_b0/bcm56996_b0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_b0/bcm56996_b0_ltd_variant_def.h new file mode 100644 index 000000000000..2a9e72e913d6 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56996_b0/bcm56996_b0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56996_B0_LTD_VARIANT_DEF_H +#define GEN_BCM56996_B0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56996_B0_BASE 8 +#define BCMLTD_VARIANT_LOCAL_BCM56996_B0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56996_B0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56998_a0/bcm56998_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56998_a0/bcm56998_a0_ltd_variant_def.h new file mode 100644 index 000000000000..a5ec341f379a --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56998_a0/bcm56998_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56998_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56998_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56998_A0_BASE 9 +#define BCMLTD_VARIANT_LOCAL_BCM56998_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56998_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56999_a0/bcm56999_a0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56999_a0/bcm56999_a0_ltd_variant_def.h new file mode 100644 index 000000000000..22ef37f20095 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm56999_a0/bcm56999_a0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56999_A0_LTD_VARIANT_DEF_H +#define GEN_BCM56999_A0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM56999_A0_BASE 10 +#define BCMLTD_VARIANT_LOCAL_BCM56999_A0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM56999_A0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm78900_b0/bcm78900_b0_ltd_variant_def.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm78900_b0/bcm78900_b0_ltd_variant_def.h new file mode 100644 index 000000000000..ed6b18f0827d --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/defs/generated/bcm78900_b0/bcm78900_b0_ltd_variant_def.h @@ -0,0 +1,37 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM78900_B0_LTD_VARIANT_DEF_H +#define GEN_BCM78900_B0_LTD_VARIANT_DEF_H + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#define BCMLTD_VARIANT_BCM78900_B0_BASE 11 +#define BCMLTD_VARIANT_LOCAL_BCM78900_B0_BASE 0 +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + +#endif /* GEN_BCM78900_B0_LTD_VARIANT_DEF_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56080_a0/bcm56080_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56080_a0/bcm56080_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..50616d50963f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56080_a0/bcm56080_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56080_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56080_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56080_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56080_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56080_a0,BCM56080_A0,,BASE,,BCMLTD_VARIANT_BCM56080_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56080_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/bcm56780_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/bcm56780_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..6f6b34efbdb7 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/bcm56780_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56780_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56780_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56780_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56780_a0,BCM56780_A0,,BASE,,BCMLTD_VARIANT_BCM56780_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56780_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_entry.h new file mode 100644 index 000000000000..e80842ef117e --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/cna_1_2_13/bcm56780_a0_cna_1_2_13_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H +#define GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56780_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56780_A0_CNA_1_2_13 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56780_a0,BCM56780_A0,cna_1_2_13,CNA_1_2_13,_,BCMLTD_VARIANT_BCM56780_A0_CNA_1_2_13,BCMLTD_VARIANT_LOCAL_BCM56780_A0_CNA_1_2_13,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_entry.h new file mode 100644 index 000000000000..2e3cd8ef6419 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/dna_2_9_5_0/bcm56780_a0_dna_2_9_5_0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56780_A0_DNA_2_9_5_0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56780_A0_DNA_2_9_5_0 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56780_a0,BCM56780_A0,dna_2_9_5_0,DNA_2_9_5_0,_,BCMLTD_VARIANT_BCM56780_A0_DNA_2_9_5_0,BCMLTD_VARIANT_LOCAL_BCM56780_A0_DNA_2_9_5_0,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_entry.h new file mode 100644 index 000000000000..27d73773bdbc --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56780_a0/hna_1_2_10_0/bcm56780_a0_hna_1_2_10_0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56780_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56780_A0_HNA_1_2_10_0 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56780_a0,BCM56780_A0,hna_1_2_10_0,HNA_1_2_10_0,_,BCMLTD_VARIANT_BCM56780_A0_HNA_1_2_10_0,BCMLTD_VARIANT_LOCAL_BCM56780_A0_HNA_1_2_10_0,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/bcm56880_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/bcm56880_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..08775e092c8c --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/bcm56880_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,,BASE,,BCMLTD_VARIANT_BCM56880_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56880_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_entry.h new file mode 100644 index 000000000000..8fb2a10d8389 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/cna_1_2_13/bcm56880_a0_cna_1_2_13_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_CNA_1_2_13_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_CNA_1_2_13 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,cna_1_2_13,CNA_1_2_13,_,BCMLTD_VARIANT_BCM56880_A0_CNA_1_2_13,BCMLTD_VARIANT_LOCAL_BCM56880_A0_CNA_1_2_13,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_entry.h new file mode 100644 index 000000000000..e677601d1dfe --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/dna_4_11_4_0/bcm56880_a0_dna_4_11_4_0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_DNA_4_11_4_0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_DNA_4_11_4_0 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,dna_4_11_4_0,DNA_4_11_4_0,_,BCMLTD_VARIANT_BCM56880_A0_DNA_4_11_4_0,BCMLTD_VARIANT_LOCAL_BCM56880_A0_DNA_4_11_4_0,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_entry.h new file mode 100644 index 000000000000..c0707c11439a --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/hna_1_2_10_0/bcm56880_a0_hna_1_2_10_0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_HNA_1_2_10_0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_HNA_1_2_10_0 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,hna_1_2_10_0,HNA_1_2_10_0,_,BCMLTD_VARIANT_BCM56880_A0_HNA_1_2_10_0,BCMLTD_VARIANT_LOCAL_BCM56880_A0_HNA_1_2_10_0,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_entry.h new file mode 100644 index 000000000000..db4192647c2b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utcfg/bcm56880_a0_utcfg_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTCFG_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_UTCFG_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_UTCFG_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_UTCFG == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,utcfg,UTCFG,_,BCMLTD_VARIANT_BCM56880_A0_UTCFG,BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTCFG,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_entry.h new file mode 100644 index 000000000000..6ba897bc6800 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utlrd/bcm56880_a0_utlrd_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTLRD_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_UTLRD_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_UTLRD_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_UTLRD == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,utlrd,UTLRD,_,BCMLTD_VARIANT_BCM56880_A0_UTLRD,BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTLRD,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_entry.h new file mode 100644 index 000000000000..6adb5eda219f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56880_a0/utltm/bcm56880_a0_utltm_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56880_A0_UTLTM_LTD_VARIANT_ENTRY_H +#define GEN_BCM56880_A0_UTLTM_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56880_A0_UTLTM_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56880_A0_UTLTM == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56880_a0,BCM56880_A0,utltm,UTLTM,_,BCMLTD_VARIANT_BCM56880_A0_UTLTM,BCMLTD_VARIANT_LOCAL_BCM56880_A0_UTLTM,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/bcm56890_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/bcm56890_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..56deb27eb09f --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/bcm56890_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56890_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56890_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56890_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56890_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56890_a0,BCM56890_A0,,BASE,,BCMLTD_VARIANT_BCM56890_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56890_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_entry.h new file mode 100644 index 000000000000..a139a20a3959 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56890_a0/dna_4_0_17_0/bcm56890_a0_dna_4_0_17_0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56890_A0_DNA_4_0_17_0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56890_A0_DNA_4_0_17_0 == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56890_a0,BCM56890_A0,dna_4_0_17_0,DNA_4_0_17_0,_,BCMLTD_VARIANT_BCM56890_A0_DNA_4_0_17_0,BCMLTD_VARIANT_LOCAL_BCM56890_A0_DNA_4_0_17_0,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_a0/bcm56990_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_a0/bcm56990_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..7e58e4babd30 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_a0/bcm56990_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56990_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56990_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56990_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56990_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56990_a0,BCM56990_A0,,BASE,,BCMLTD_VARIANT_BCM56990_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56990_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_b0/bcm56990_b0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_b0/bcm56990_b0_ltd_variant_entry.h new file mode 100644 index 000000000000..a395052a5853 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56990_b0/bcm56990_b0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56990_B0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56990_B0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56990_B0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56990_B0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56990_b0,BCM56990_B0,,BASE,,BCMLTD_VARIANT_BCM56990_B0_BASE,BCMLTD_VARIANT_LOCAL_BCM56990_B0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_a0/bcm56996_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_a0/bcm56996_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..40abaeff0df0 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_a0/bcm56996_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56996_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56996_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56996_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56996_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56996_a0,BCM56996_A0,,BASE,,BCMLTD_VARIANT_BCM56996_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56996_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_b0/bcm56996_b0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_b0/bcm56996_b0_ltd_variant_entry.h new file mode 100644 index 000000000000..ad387ff5c24b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56996_b0/bcm56996_b0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56996_B0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56996_B0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56996_B0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56996_B0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56996_b0,BCM56996_B0,,BASE,,BCMLTD_VARIANT_BCM56996_B0_BASE,BCMLTD_VARIANT_LOCAL_BCM56996_B0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56998_a0/bcm56998_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56998_a0/bcm56998_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..b5313fb0a589 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56998_a0/bcm56998_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56998_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56998_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56998_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56998_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56998_a0,BCM56998_A0,,BASE,,BCMLTD_VARIANT_BCM56998_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56998_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56999_a0/bcm56999_a0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56999_a0/bcm56999_a0_ltd_variant_entry.h new file mode 100644 index 000000000000..a472cabc74c3 --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm56999_a0/bcm56999_a0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM56999_A0_LTD_VARIANT_ENTRY_H +#define GEN_BCM56999_A0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM56999_A0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM56999_A0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm56999_a0,BCM56999_A0,,BASE,,BCMLTD_VARIANT_BCM56999_A0_BASE,BCMLTD_VARIANT_LOCAL_BCM56999_A0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm78900_b0/bcm78900_b0_ltd_variant_entry.h b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm78900_b0/bcm78900_b0_ltd_variant_entry.h new file mode 100644 index 000000000000..339373fd1afe --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/bcmltd/include/bcmltd/entry/generated/bcm78900_b0/bcm78900_b0_ltd_variant_entry.h @@ -0,0 +1,40 @@ +/******************************************************************************* + * + * DO NOT EDIT THIS FILE! + * This file is auto-generated by fltg from Logical Table mapping files. + * + * Tool: $SDK/tools/fltg/bin/fltg + * + * Edits to this file will be lost when it is regenerated. + * + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + * + ******************************************************************************/ + +#ifndef GEN_BCM78900_B0_LTD_VARIANT_ENTRY_H +#define GEN_BCM78900_B0_LTD_VARIANT_ENTRY_H +#include +#endif /* GEN_BCM78900_B0_LTD_VARIANT_ENTRY_H */ + +#ifndef DOXYGEN_IGNORE_AUTOGEN + +#if BCMLTD_CONFIG_INCLUDE_BCM78900_B0_BASE == 1 || defined(BCMLTD_VARIANT_OVERRIDE) +BCMLTD_VARIANT_ENTRY(bcm78900_b0,BCM78900_B0,,BASE,,BCMLTD_VARIANT_BCM78900_B0_BASE,BCMLTD_VARIANT_LOCAL_BCM78900_B0_BASE,NULL,0,0) +#endif + +#endif /* DOXYGEN_IGNORE_AUTOGEN */ + + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild index 928ecdf49b7c..7b444f5097f4 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Kbuild @@ -2,7 +2,11 @@ # # Linux kernel BDE module. # -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# The NGBDE_CFLAGS variable is intended for configuring non-default +# builds of the NGBDE kernel module, for example, using a different +# default DMA pool size or turning off MSI interrupts. +# +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -20,7 +24,7 @@ obj-m := linux_ngbde.o -ccflags-y := $(LKM_CFLAGS) \ +ccflags-y := $(LKM_CFLAGS) $(NGBDE_CFLAGS) \ -I$(SDK)/linux/include \ -I$(SDK)/linux/bde \ -I$(SDK)/bcmdrd/include diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile index a20346e4b50b..f4401e62dc5e 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/Makefile @@ -1,8 +1,5 @@ -# -*- Makefile -*- # -# Linux kernel BDE module. -# -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -17,6 +14,8 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # +# Linux kernel BDE module. +# include Kbuild @@ -30,4 +29,4 @@ endif .PHONY: distclean -distclean: +distclean:: diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h index ad1f71031cbe..5d3339ad74ef 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -125,6 +125,13 @@ typedef struct ngbde_irq_reg_s { /*! Mask register is of type "write 1 to clear". */ bool mask_w1tc; + /*! + * Indicates that the kmask value is valid. This is mainly to + * distinguish a mask value of zero from the mask value being + * uninitialized, as this matters during a warm boot. + */ + bool kmask_valid; + /*! Mask identifying the register bits owned by the kernel mode driver. */ uint32_t kmask; diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c index 848664af046e..6e15855034c0 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_dma.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -24,34 +24,36 @@ /*! \cond */ static int dma_debug = 0; -module_param(dma_debug, int, 0); +module_param(dma_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(dma_debug, "DMA debug output enable (default 0)."); /*! \endcond */ /*! Default size of of DMA memory pools (in MB). */ +#ifndef DMAPOOL_SIZE_DEFAULT #define DMAPOOL_SIZE_DEFAULT 16 +#endif /*! Default number of DMA memory pools per device. */ #define NUM_DMAPOOL_DEFAULT 1 /*! \cond */ static int dma_size = DMAPOOL_SIZE_DEFAULT; -module_param(dma_size, int, 0); +module_param(dma_size, int, S_IRUSR); MODULE_PARM_DESC(dma_size, "Size of of DMA memory pools in MB (default 16 MB)."); /*! \endcond */ /*! \cond */ -static char *dma_alloc; -module_param(dma_alloc, charp, 0); +static char *dma_alloc = "auto"; +module_param(dma_alloc, charp, S_IRUSR); MODULE_PARM_DESC(dma_alloc, "DMA allocation method auto|kapi|pgmem (default auto)"); /*! \endcond */ /*! \cond */ static int dma_pools = NUM_DMAPOOL_DEFAULT; -module_param(dma_pools, int, 0); +module_param(dma_pools, int, S_IRUSR); MODULE_PARM_DESC(dma_pools, "Number of DMA memory pools to pre-allocate per device (default 1)."); /*! \endcond */ @@ -120,10 +122,12 @@ ngbde_dmamem_pgmem_alloc(ngbde_dmactrl_t *dmactrl, ngbde_dmamem_t *dmamem) dmamem->baddr = dma_map_single(dmamem->dev, dmamem->vaddr, dmamem->size, DMA_BIDIRECTIONAL); if (dma_mapping_error(dmactrl->dev, dmamem->baddr)) { - dmamem->baddr = 0; + ngbde_pgmem_free(dmamem->vaddr); + memset(dmamem, 0, sizeof(*dmamem)); if (dma_debug) { printk("DMA: Failed to map PGMEM memory\n"); } + return; } /* Write small signature for debug purposes */ @@ -223,7 +227,7 @@ ngbde_dmamem_free(ngbde_dmamem_t *dmamem) (int)(dmamem->size / ONE_KB)); } dma_free_coherent(dmamem->dev, dmamem->size, - dmamem->vaddr, dmamem->paddr); + dmamem->vaddr, dmamem->baddr); memset(dmamem, 0, sizeof(*dmamem)); break; case NGBDE_DMA_T_PGMEM: @@ -240,7 +244,7 @@ ngbde_dmamem_free(ngbde_dmamem_t *dmamem) dmamem->size, DMA_BIDIRECTIONAL); } ngbde_pgmem_free(dmamem->vaddr); - memset(dmamem, 0, sizeof(*dmamem)); + memset(dmamem, 0, sizeof(*dmamem)); // nosemgrep break; case NGBDE_DMA_T_NONE: /* Nothing to free */ @@ -298,7 +302,9 @@ ngbde_dma_init(void) /* Check for forced DMA allocation method */ if (dma_alloc) { - if (strcmp(dma_alloc, "kapi") == 0) { + if (strcmp(dma_alloc, "auto") == 0) { + dma_type = NGBDE_DMA_T_AUTO; + } else if (strcmp(dma_alloc, "kapi") == 0) { dma_type = NGBDE_DMA_T_KAPI; } else if (strcmp(dma_alloc, "pgmem") == 0) { dma_type = NGBDE_DMA_T_PGMEM; diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c index 744cf2442fbd..99ced831e015 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iio.c @@ -5,7 +5,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c index bc343a7e223e..5d68fa92abe2 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_intr.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ /*! \cond */ static int intr_debug = 0; -module_param(intr_debug, int, 0); +module_param(intr_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(intr_debug, "Interrupt debug output enable (default 0)."); /*! \endcond */ @@ -476,17 +476,20 @@ ngbde_intr_reg_add(int kdev, unsigned int irq_num, if (ic->irq_active) { /* * If the interrupt is connected, then we only update the - * kernel mask for existing entries. + * kernel mask for existing entries, and only if the kernel + * mask is marked as valid and differs from the existing mask. */ for (idx = 0; idx < ic->num_regs; idx++) { ir = &ic->regs[idx]; if (ir->status_reg == ireg->status_reg && ir->mask_reg == ireg->mask_reg) { - ir->kmask = ireg->kmask; - if (intr_debug) { - printk("INTR: Updating interrupt register " - "0x%08x/0x%08x (0x%08x)\n", - ir->status_reg, ir->mask_reg, ir->kmask); + if (ir->kmask != ireg->kmask && ireg->kmask_valid) { + ir->kmask = ireg->kmask; + if (intr_debug) { + printk("INTR: Updating interrupt register " + "0x%08x/0x%08x (0x%08x)\n", + ir->status_reg, ir->mask_reg, ir->kmask); + } } return 0; } diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c index 4eeeb2438306..f83857f6edcc 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_ioctl.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -156,8 +156,12 @@ ngbde_ioctl(struct file *file, unsigned int cmd, unsigned long arg) irq_num = ioc.op.irq_reg_add.irq_num; ireg.status_reg = ioc.op.irq_reg_add.status_reg; ireg.mask_reg = ioc.op.irq_reg_add.mask_reg; - ireg.kmask = ioc.op.irq_reg_add.kmask; - ireg.status_is_masked = false; + ireg.kmask = 0; + ireg.kmask_valid = false; + if (ioc.op.irq_reg_add.flags & NGBDE_DEV_IRQ_REG_F_KMASK) { + ireg.kmask = ioc.op.irq_reg_add.kmask; + ireg.kmask_valid = true; + } if (ioc.op.irq_reg_add.flags & NGBDE_DEV_IRQ_REG_F_MASKED) { ireg.status_is_masked = true; } diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c index 218fd8262a65..10f221642c3d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_iproc_probe.c @@ -8,7 +8,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -30,7 +30,7 @@ /*! \cond */ static int iproc_debug = 0; -module_param(iproc_debug, int, 0); +module_param(iproc_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(iproc_debug, "IPROC debug output enable (default 0)."); /*! \endcond */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c index 7775100d952b..506231054b7d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_kapi.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c index 697412cf5b97..38a60867b719 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_main.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -30,7 +30,7 @@ MODULE_LICENSE("GPL"); /*! \cond */ static int mmap_debug = 0; -module_param(mmap_debug, int, 0); +module_param(mmap_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(mmap_debug, "MMAP debug output enable (default 0)."); /*! \endcond */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_paxb.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_paxb.c index 7b8cdda58b59..376062d348d5 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_paxb.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_paxb.c @@ -5,7 +5,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c index f444f04fa9f5..f74ccf5a4377 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pci_probe.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -24,14 +24,14 @@ /*! \cond */ static int use_msi = 1; -module_param(use_msi, int, 0); +module_param(use_msi, int, S_IRUSR); MODULE_PARM_DESC(use_msi, "Use MSI interrupts if supported by the kernel (default 1)."); /*! \endcond */ /*! \cond */ static int pci_debug = 0; -module_param(pci_debug, int, 0); +module_param(pci_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(pci_debug, "PCI debug output enable (default 0)."); /*! \endcond */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c index 1283b66e1e19..ec6b369780a8 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pgmem.c @@ -31,7 +31,7 @@ * likely these requests are to succeed. */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -62,14 +62,14 @@ /*! \cond */ static int pgmem_chunk_size = 0; -module_param(pgmem_chunk_size, int, 0); +module_param(pgmem_chunk_size, int, S_IRUSR); MODULE_PARM_DESC(pgmem_chunk_size, "Memory chunk size in KB used by page allocator (default auto)."); /*! \endcond */ /*! \cond */ static int pgmem_debug = 0; -module_param(pgmem_debug, int, 0); +module_param(pgmem_debug, int, S_IRUSR | S_IWUSR); MODULE_PARM_DESC(pgmem_debug, "Enable page memory allocator debug output (default 0)."); /*! \endcond */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c index 13dde9de98e7..cfcc97a94e49 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_pio.c @@ -5,7 +5,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c index 883b5a8ea7d1..6fd02ebd3d4b 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_procfs.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -88,22 +88,13 @@ proc_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_fops = { - owner: THIS_MODULE, - open: proc_open, - read: seq_read, - llseek: seq_lseek, - release: proc_release, +struct proc_ops proc_fops = { + PROC_OWNER(THIS_MODULE) + .proc_open = proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_release, }; -#else -static struct proc_ops proc_fops = { - proc_open: proc_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_release, -}; -#endif int ngbde_procfs_init(void) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c index b8d67382f450..a6fedc2c4a30 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/bde/ngbde_swdev.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h index f35550922fed..4da4ab985e96 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/lkm.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -63,6 +63,21 @@ /* Compatibility Macros */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,5,0) +#define PROC_OWNER(_m) +#else +#define PROC_OWNER(_m) .owner = _m, +#define proc_ops file_operations +#define proc_open open +#define proc_read read +#define proc_write write +#define proc_lseek llseek +#define proc_release release +#define proc_ioctl unlocked_ioctl +#define proc_compat_ioctl compat_ioctl +#define proc_mmap mmap +#endif + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0) #define PROC_CREATE(_entry, _name, _acc, _path, _fops) \ do { \ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h index 84088fb391f7..1a3b94f0ad5d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_ioctl.h @@ -9,7 +9,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -238,6 +238,13 @@ struct ngbde_ioc_intr_ctrl_s { /*! IRQ status register is a bitwise AND of mask and raw status. */ #define NGBDE_DEV_IRQ_REG_F_MASKED (1 << 1) +/*! + * Indicates that the kmask value is valid. This is mainly to + * distinguish a mask value of zero from the mask value being + * uninitialized, as this matters during a warm boot. + */ +#define NGBDE_DEV_IRQ_REG_F_KMASK (1 << 2) + /*! \} */ /*! Add interrupt register information. */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h index 2d908da1f544..98a148711aaa 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngbde_kapi.h @@ -6,7 +6,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngedk_ioctl.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngedk_ioctl.h index 7a4c7b5d24a1..05063d3207b0 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngedk_ioctl.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngedk_ioctl.h @@ -9,7 +9,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -82,6 +82,9 @@ /*! Handle EDK software interrupt. */ #define NGEDK_IOC_SW_INTR _IOW(NGEDK_IOC_MAGIC, 7, __u64) +/*! Handle EDK timer interrupt. */ +#define NGEDK_IOC_TIMER_INTR _IOW(NGEDK_IOC_MAGIC, 8, __u64) + /*! \} */ /*! IOCTL command return code for success. */ @@ -90,6 +93,18 @@ /*! IOCTL command return code for failure. */ #define NGEDK_IOC_FAIL ((__u32)-1) +/*! + * \name EDK IOC flags. + * \anchor NGEDK_IOC_F_xxx + */ + +/*! \{ */ + +/*! Interrupt enable/disable registers are "write 1 to clear". */ +#define NGEDK_IOC_F_W1TC (1 << 0) + +/*! \} */ + /*! Kernel module information. */ struct ngedk_ioc_mod_info_s { @@ -129,14 +144,17 @@ struct ngedk_ioc_intr_s { /*! Timer interrupts status offset */ __u32 timer_intrc_stat_reg; - /*! Timer interrupts enable offset */ - __u32 timer_intrc_enable_reg; + /*! Timer interrupts disable offset */ + __u32 timer_intrc_disable_reg; /*! Timer interrupts mask */ __u32 timer_intrc_mask_val; /*! Bitmap of cores that triggered SW interrupt. */ __u32 sw_intr_cores; + + /*! EDK ioctl flags (\ref NGEDK_IOC_F_xxx). */ + __u32 flags; }; /*! IOCTL operation data. */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h index baef36109a4b..1c6ec921c0aa 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_dev.h @@ -9,7 +9,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -28,7 +28,14 @@ #ifndef NGKNET_DEV_H #define NGKNET_DEV_H -#include +#include + +/*! Maximum number of devices supported */ +#ifdef NGBDE_NUM_SWDEV_MAX +#define NUM_PDMA_DEV_MAX NGBDE_NUM_SWDEV_MAX +#else +#define NUM_PDMA_DEV_MAX 16 +#endif /*! Device name length */ #define NGKNET_DEV_NAME_MAX 16 @@ -284,6 +291,20 @@ typedef struct ngknet_filter_s { uint8_t user_data[NGKNET_FILTER_USER_DATA]; } ngknet_filter_t; +/*! + * \brief Device information. + */ +typedef struct ngknet_dev_info_s { + /*! Device number (from BDE) */ + int dev_no; + + /*! Device type string */ + char type_str[NGKNET_DEV_NAME_MAX]; + + /*! Device variant string */ + char var_str[NGKNET_DEV_NAME_MAX]; +} ngknet_dev_info_t; + /*! * \brief Device configure structure. */ @@ -294,14 +315,14 @@ typedef struct ngknet_dev_cfg_s { /*! Device type string */ char type_str[NGKNET_DEV_NAME_MAX]; - /*! Variant string */ + /*! Device variant string */ char var_str[NGKNET_DEV_NAME_MAX]; /*! Device ID */ uint32_t dev_id; /*! Device mode */ - dev_mode_t mode; + int mode; /*! Number of groups */ uint32_t nb_grp; diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h index 42533787f927..ad1614f8110c 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_ioctl.h @@ -9,7 +9,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_kapi.h b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_kapi.h new file mode 100644 index 000000000000..878a065ba39b --- /dev/null +++ b/platform/broadcom/saibcm-modules/sdklt/linux/include/lkm/ngknet_kapi.h @@ -0,0 +1,379 @@ +/*! \file ngknet_kapi.h + * + * NGKNET kernel API. + * + * This file is intended for use by other kernel modules relying on the KNET. + * + */ +/* + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. + * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the GNU General Public License version 2 (GPLv2) can + * be found in the LICENSES folder.$ + */ + +#ifndef NGKNET_KAPI_H +#define NGKNET_KAPI_H + +#include +#include + +/*! + * \brief NGKNET callback description. + */ +struct ngknet_callback_desc { + /* Device information */ + ngknet_dev_info_t *dinfo; + + /*! Network interface */ + ngknet_netif_t *netif; + + /*! Matched filter */ + ngknet_filter_t *filt; + + /*! Packet meta data */ + uint8_t *pmd; + + /*! Packet meta data length */ + int pmd_len; + + /*! Packet data length */ + int pkt_len; +}; + +/*! SKB callback data */ +#define NGKNET_SKB_CB(_skb) ((struct ngknet_callback_desc *)_skb->cb) + +/*! TX/RX callback init */ +typedef void +(*ngknet_dev_init_cb_f)(ngknet_dev_info_t *dinfo); + +/*! Handle Rx packet */ +typedef struct sk_buff * +(*ngknet_rx_cb_f)(struct net_device *dev, struct sk_buff *skb); + +/*! Handle Tx packet */ +typedef struct sk_buff * +(*ngknet_tx_cb_f)(struct sk_buff *skb); + +#if 0 +/*! Handle Netif callback */ +typedef int +(*ngknet_netif_cb_f)(ngknet_dev_info_t *dinfo, ngknet_netif_t *netif); +#endif +/*! Handle Filter callback */ +typedef struct sk_buff * +(*ngknet_filter_cb_f)(struct sk_buff *skb, ngknet_filter_t **filt); + +/*! PTP Rx/Tx config set */ +typedef int +(*ngknet_ptp_config_set_cb_f)(ngknet_dev_info_t *dinfo, ngknet_netif_t *netif, int *value); + +/*! PTP Rx/Tx HW timestamp get */ +typedef int +(*ngknet_ptp_hwts_get_cb_f)(struct sk_buff *skb, uint64_t *ts); + +/*! PTP Tx meta set */ +typedef int +(*ngknet_ptp_meta_set_cb_f)(struct sk_buff *skb); + +/*! PTP PHC index get */ +typedef int +(*ngknet_ptp_phc_index_get_cb_f)(ngknet_dev_info_t *dinfo, ngknet_netif_t *netif, int *index); + +/*! PTP device control */ +typedef int +(*ngknet_ptp_dev_ctrl_cb_f)(ngknet_dev_info_t *dinfo, int cmd, char *data, int len); + +/*! Netif callback */ +typedef int +(*ngknet_netif_cb_f)(struct net_device *dev); + +/*! + * \brief Register TX/RX callback device initialization callback function. + * + * The device initialization callback allows an external module to + * perform device-specific initialization in preparation for Tx and Rx + * packet processing. + * + * \param [in] dev_init_cb TX/RX callback device initialization callback + * function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_dev_init_cb_register(ngknet_dev_init_cb_f dev_init_cb); + +/*! + * \brief Unegister TX/RX callback device initialization callback function. + * + * The device initialization callback allows an external module to + * perform device-specific initialization in preparation for Tx and Rx + * packet processing. + * + * \param [in] dev_init_cb TX/RX callback device initialization callback + * function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_dev_init_cb_unregister(ngknet_dev_init_cb_f dev_init_cb); + +/*! + * \brief Register Rx callback. + * + * \param [in] rx_cb Rx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_rx_cb_register(ngknet_rx_cb_f rx_cb); + +/*! + * \brief Unregister Rx callback. + * + * \param [in] rx_cb Rx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_rx_cb_unregister(ngknet_rx_cb_f rx_cb); + +/*! + * \brief Register Tx callback. + * + * \param [in] tx_cb Tx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_tx_cb_register(ngknet_tx_cb_f tx_cb); + +/*! + * \brief Unregister Tx callback. + * + * \param [in] tx_cb Tx callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb); + +/*! + * \brief Register callback for network interface creation. + * + * Register a function to be called whenever a virtual network interface + * is created in the KNET kernel module. + * + * \param [in] netif_cb Callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Unregister callback for network interface creation. + * + * \param [in] netif_cb Callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Register callback for network interface destruction. + * + * Register a function to be called whenever a virtual network interface + * is destroyed in the KNET kernel module. + * + * \param [in] netif_cb Callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Unregister callback for network interface destruction. + * + * \param [in] netif_cb Callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb); + +/*! + * \brief Register filter callback. + * + * \param [in] filter_cb Filter callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_filter_cb_register(ngknet_filter_cb_f filter_cb); + +/*! + * \brief Unregister filter callback. + * + * \param [in] filter_cb Filter callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_filter_cb_unregister(ngknet_filter_cb_f filter_cb); + +/*! + * \brief Register PTP Rx config set callback. + * + * \param [in] ptp_rx_config_set_cb Rx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); + +/*! + * \brief Unregister PTP Rx config set callback. + * + * \param [in] ptp_rx_config_set_cb Rx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); + +/*! + * \brief Register PTP Tx config set callback. + * + * \param [in] ptp_tx_config_set_cb Tx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); + +/*! + * \brief Unregister PTP Tx config set callback. + * + * \param [in] ptp_tx_config_set_cb Tx config set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); + +/*! + * \brief Register PTP Rx HW timestamp get callback. + * + * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); + +/*! + * \brief Unregister PTP Rx HW timestamp get callback. + * + * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_rx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); + +/*! + * \brief Register PTP Tx HW timestamp get callback. + * + * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); + +/*! + * \brief Unregister PTP Tx HW timestamp get callback. + * + * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); + +/*! + * \brief Register PTP Tx meta set callback. + * + * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_meta_set_cb_register(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); + +/*! + * \brief Unregister PTP Tx meta set callback. + * + * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_tx_meta_set_cb_unregister(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); + +/*! + * \brief Register PTP PHC index get callback. + * + * \param [in] ptp_phc_index_get_cb PHC index get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_phc_index_get_cb_register(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); + +/*! + * \brief Unregister PTP PHC index get callback. + * + * \param [in] ptp_phc_index_get_cb PHC index get callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_phc_index_get_cb_unregister(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); + +/*! + * \brief Register PTP device control callback. + * + * \param [in] ptp_dev_ctrl_cb Device control callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_dev_ctrl_cb_register(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); + +/*! + * \brief Unregister PTP device control callback. + * + * \param [in] ptp_dev_ctrl_cb Device control callback function. + * + * \retval SHR_E_NONE No errors. + */ +extern int +ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); + +#endif /* NGKNET_KAPI_H */ + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild index 1f543b8e2ccf..a23e587b1d45 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Kbuild @@ -2,7 +2,7 @@ # # Linux KNET module. # -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -20,18 +20,25 @@ obj-m := linux_ngknet.o +ifneq ($(OUTPUT_DIR),) +INCLUDES := -I$(OUTPUT_DIR)/knet/generated/include -I$(OUTPUT_DIR)/knet/generated +endif + ccflags-y := $(KNET_CPPFLAGS) $(LKM_CFLAGS) \ -I$(SDK)/shr/include \ -I$(SDK)/bcmdrd/include \ -I$(SDK)/linux/include \ - -I$(SDK)/linux/knet/include \ - -I$(SDK)/linux/knet + -I$(SDK)/linux/knet/generated/include \ + -I$(SDK)/linux/knet/generated \ + $(INCLUDES) linux_ngknet-y := $(CHIP_OBJS) \ bcmcnet_cmicd_pdma_hw.o \ bcmcnet_cmicd_pdma_rxtx.o \ bcmcnet_cmicx_pdma_hw.o \ bcmcnet_cmicx_pdma_rxtx.o \ + bcmcnet_cmicr_pdma_hw.o \ + bcmcnet_cmicr_pdma_rxtx.o \ bcmcnet_core.o \ bcmcnet_dev.o \ bcmcnet_rxtx.o \ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile index 2142857ad387..f13702ac92fd 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/Makefile @@ -1,8 +1,5 @@ -# -*- Makefile -*- # -# Linux KNET module. -# -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -17,11 +14,17 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # +# Linux KNET module. +# CNETDIR = $(SDK)/bcmcnet KNETDIR = $(SDK)/linux/knet +GENDIR = $(KNETDIR)/generated SRCIDIR = $(CNETDIR)/include/bcmcnet -DSTIDIR = $(KNETDIR)/include/bcmcnet +ifneq ($(OUTPUT_DIR),) +GENDIR = $(OUTPUT_DIR)/knet/generated +endif +DSTIDIR = $(GENDIR)/include/bcmcnet # Change comma-separated list to space-separated list comma = , @@ -54,7 +57,7 @@ endif .PHONY: mklinks rmlinks knet: mklinks - $(MAKE) all + $(MAKE) -C $(GENDIR) all # # Suppress symlink error messages. @@ -77,17 +80,19 @@ mklinks: -ln -s $(SRCIDIR)/bcmcnet_cmicx.h $(DSTIDIR) $(R) -ln -s $(SRCIDIR)/bcmcnet_cmicr.h $(DSTIDIR) $(R) -ln -s $(SRCIDIR)/bcmcnet_cmicr_acc.h $(DSTIDIR) $(R) - -ln -s $(CNETDIR)/chip/*/*attach.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/hmi/cmicd/*.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/hmi/cmicx/*.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/hmi/cmicr/*.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/main/bcmcnet_core.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/main/bcmcnet_dev.c $(KNETDIR) $(R) - -ln -s $(CNETDIR)/main/bcmcnet_rxtx.c $(KNETDIR) $(R) + -ln -s $(CNETDIR)/chip/*/*attach.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/hmi/cmicd/*.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/hmi/cmicx/*.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/hmi/cmicr/*.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_core.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_dev.c $(GENDIR) $(R) + -ln -s $(CNETDIR)/main/bcmcnet_rxtx.c $(GENDIR) $(R) + -ln -s $(KNETDIR)/*.[ch] $(GENDIR) $(R) + -ln -s $(KNETDIR)/Makefile $(GENDIR) $(R) + -ln -s $(KNETDIR)/Kbuild $(GENDIR) $(R) rmlinks: - -rm -f bcm* - -rm -rf include + -rm -rf $(GENDIR) CHIP_SRCS := $(addsuffix _pdma_attach.c,$(KNET_CHIPS)) CHIP_OBJS ?= $(patsubst %.c, %.o, $(CHIP_SRCS)) @@ -105,4 +110,4 @@ endif .PHONY: distclean -distclean: rmlinks +distclean:: rmlinks diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h deleted file mode 120000 index b4bc2b7ffe74..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_buff.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h deleted file mode 120000 index cface69c6365..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicd.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicd.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h deleted file mode 120000 index ee9f52060eae..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_cmicx.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_cmicx.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h deleted file mode 120000 index 83e0769b2b5e..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_core.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_core.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h deleted file mode 120000 index 8a9a6c6f6582..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dep.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h deleted file mode 120000 index 4ba5f9aefbaa..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_dev.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_dev.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h deleted file mode 120000 index e9c65317d643..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_internal.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_internal.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h deleted file mode 120000 index 7bfe68f89882..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_rxtx.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_rxtx.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h deleted file mode 120000 index f2e6649cd0da..000000000000 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/include/bcmcnet/bcmcnet_types.h +++ /dev/null @@ -1 +0,0 @@ -/sonic/platform/broadcom/saibcm-modules/sdklt/bcmcnet/include/bcmcnet/bcmcnet_types.h \ No newline at end of file diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c index 5d92ed016b49..362c6e156e2b 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -30,7 +30,7 @@ * Allocate coherent memory */ static void * -bcmcnet_ring_buf_alloc(struct pdma_dev *dev, uint32_t size, dma_addr_t *dma) +ngknet_ring_buf_alloc(struct pdma_dev *dev, uint32_t size, dma_addr_t *dma) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; @@ -41,7 +41,7 @@ bcmcnet_ring_buf_alloc(struct pdma_dev *dev, uint32_t size, dma_addr_t *dma) * Free coherent memory */ static void -bcmcnet_ring_buf_free(struct pdma_dev *dev, uint32_t size, void *addr, dma_addr_t dma) +ngknet_ring_buf_free(struct pdma_dev *dev, uint32_t size, void *addr, dma_addr_t dma) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; @@ -52,22 +52,23 @@ bcmcnet_ring_buf_free(struct pdma_dev *dev, uint32_t size, void *addr, dma_addr_ * Allocate Rx buffer */ static int -bcmcnet_rx_buf_alloc(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf) +ngknet_rx_buf_alloc(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; dma_addr_t dma; struct page *page; struct sk_buff *skb; - if (rxq->mode == PDMA_BUF_MODE_PAGE) { - page = kal_dev_alloc_page(); + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { + page = kal_dev_alloc_pages(rxq->page_order); if (unlikely(!page)) { return SHR_E_MEMORY; } - dma = dma_map_page(kdev->dev, page, 0, PAGE_SIZE, DMA_FROM_DEVICE); + dma = kal_dma_map_page_attrs(kdev->dev, page, 0, PAGE_SIZE * (1 << rxq->page_order), DMA_FROM_DEVICE, + DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING); if (unlikely(dma_mapping_error(kdev->dev, dma))) { - __free_page(page); + __free_pages(page, rxq->page_order); return SHR_E_MEMORY; } pbuf->dma = dma; @@ -96,10 +97,10 @@ bcmcnet_rx_buf_alloc(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Get Rx buffer DMA address */ static void -bcmcnet_rx_buf_dma(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf, dma_addr_t *addr) +ngknet_rx_buf_dma(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, dma_addr_t *addr) { - if (rxq->mode == PDMA_BUF_MODE_PAGE) { + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { *addr = pbuf->dma + pbuf->page_offset + PDMA_RXB_RESV + pbuf->adj; } else { *addr = pbuf->dma; @@ -110,10 +111,10 @@ bcmcnet_rx_buf_dma(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Check Rx buffer */ static bool -bcmcnet_rx_buf_avail(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf) +ngknet_rx_buf_avail(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) { - if (rxq->mode == PDMA_BUF_MODE_PAGE) { + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { pbuf->skb = NULL; } @@ -124,36 +125,41 @@ bcmcnet_rx_buf_avail(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Get Rx buffer */ static struct pkt_hdr * -bcmcnet_rx_buf_get(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf, int len) +ngknet_rx_buf_get(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; struct sk_buff *skb; + uint32_t pages_size; - if (rxq->mode == PDMA_BUF_MODE_PAGE) { + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { if (pbuf->skb) { return &pbuf->pkb->pkh; } skb = kal_build_skb(page_address(pbuf->page) + pbuf->page_offset, - PDMA_SKB_RESV + pbuf->adj + rxq->buf_size); + PDMA_RXB_SIZE(rxq->buf_size + pbuf->adj)); if (unlikely(!skb)) { return NULL; } skb_reserve(skb, PDMA_RXB_ALIGN); + pages_size = PAGE_SIZE * (1 << rxq->page_order); dma_sync_single_range_for_cpu(kdev->dev, pbuf->dma, pbuf->page_offset, - PDMA_PAGE_BUF_MAX, DMA_FROM_DEVICE); + pages_size >> 1, DMA_FROM_DEVICE); pbuf->skb = skb; pbuf->pkb = (struct pkt_buf *)skb->data; /* Try to reuse this page */ - if (unlikely(page_count(pbuf->page) != 1)) { - dma_unmap_page(kdev->dev, pbuf->dma, PAGE_SIZE, DMA_FROM_DEVICE); + if (unlikely(page_count(pbuf->page) != 1) || + kal_page_is_pfmemalloc(pbuf->page) || + page_to_nid(pbuf->page) != numa_mem_id()) { + kal_dma_unmap_page_attrs(kdev->dev, pbuf->dma, pages_size, DMA_FROM_DEVICE, + DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING); pbuf->dma = 0; } else { - pbuf->page_offset ^= PDMA_PAGE_BUF_MAX; + pbuf->page_offset ^= pages_size >> 1; page_ref_inc(pbuf->page); dma_sync_single_range_for_device(kdev->dev, pbuf->dma, pbuf->page_offset, - PDMA_PAGE_BUF_MAX, DMA_FROM_DEVICE); + pages_size >> 1, DMA_FROM_DEVICE); } } else { if (!pbuf->dma) { @@ -173,19 +179,20 @@ bcmcnet_rx_buf_get(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Put Rx buffer */ static int -bcmcnet_rx_buf_put(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf, int len) +ngknet_rx_buf_put(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf, int len) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; dma_addr_t dma; struct sk_buff *skb; - if (rxq->mode == PDMA_BUF_MODE_PAGE) { + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { dev_kfree_skb_any(pbuf->skb); } else { skb = pbuf->skb; if (pbuf->pkb != (struct pkt_buf *)skb->data) { dev_kfree_skb_any(skb); + pbuf->dma = 0; return SHR_E_NONE; } dma = dma_map_single(kdev->dev, &pbuf->pkb->data + pbuf->adj, @@ -196,7 +203,7 @@ bcmcnet_rx_buf_put(struct pdma_dev *dev, struct pdma_rx_queue *rxq, return SHR_E_MEMORY; } pbuf->dma = dma; - skb_trim(skb, skb->len - (PKT_HDR_SIZE + pbuf->adj + len)); + skb_trim(skb, 0); } return SHR_E_NONE; @@ -206,15 +213,24 @@ bcmcnet_rx_buf_put(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Free Rx buffer */ static void -bcmcnet_rx_buf_free(struct pdma_dev *dev, struct pdma_rx_queue *rxq, - struct pdma_rx_buf *pbuf) +ngknet_rx_buf_free(struct pdma_dev *dev, struct pdma_rx_queue *rxq, + struct pdma_rx_buf *pbuf) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + uint32_t pages_size; - if (rxq->mode == PDMA_BUF_MODE_PAGE) { - dma_unmap_single(kdev->dev, pbuf->dma, PAGE_SIZE, DMA_FROM_DEVICE); - __free_page(pbuf->page); + if (rxq->buf_mode == PDMA_BUF_MODE_PAGE) { + if (!pbuf->page) { + return; + } + pages_size = PAGE_SIZE * (1 << rxq->page_order); + kal_dma_unmap_page_attrs(kdev->dev, pbuf->dma, pages_size, DMA_FROM_DEVICE, + DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING); + __free_pages(pbuf->page, rxq->page_order); } else { + if (!pbuf->skb) { + return; + } dma_unmap_single(kdev->dev, pbuf->dma, rxq->buf_size, DMA_FROM_DEVICE); dev_kfree_skb_any(pbuf->skb); } @@ -231,25 +247,42 @@ bcmcnet_rx_buf_free(struct pdma_dev *dev, struct pdma_rx_queue *rxq, * Get Rx buffer mode */ static enum buf_mode -bcmcnet_rx_buf_mode(struct pdma_dev *dev, struct pdma_rx_queue *rxq) +ngknet_rx_buf_mode(struct pdma_dev *dev, struct pdma_rx_queue *rxq) { - uint32_t len; + uint32_t len, order; + + switch (ngknet_page_buffer_mode_get()) { + case 0: + /* Forced SKB mode */ + return PDMA_BUF_MODE_SKB; + case 1: + /* Forced page mode */ + break; + default: /* -1 */ + /* Select buffer mode based on system capability */ + if (kal_support_paged_skb() == 0) { + return PDMA_BUF_MODE_SKB; + } + break; + } len = dev->rx_ph_size ? rxq->buf_size : rxq->buf_size + PDMA_RXB_META; - if (PDMA_RXB_SIZE(len) <= PDMA_PAGE_BUF_MAX && PAGE_SIZE < 8192 && - kal_support_paged_skb()) { - return PDMA_BUF_MODE_PAGE; + for (order = 0; order < 32; order++) { + if (PDMA_RXB_SIZE(len) * 2 <= PAGE_SIZE * (1 << order)) { + rxq->page_order = order; + break; + } } - return PDMA_BUF_MODE_SKB; + return PDMA_BUF_MODE_PAGE; } /*! * Get Tx buffer */ static struct pkt_hdr * -bcmcnet_tx_buf_get(struct pdma_dev *dev, struct pdma_tx_queue *txq, - struct pdma_tx_buf *pbuf, void *buf) +ngknet_tx_buf_get(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, void *buf) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; struct sk_buff *skb = (struct sk_buff *)buf; @@ -274,8 +307,8 @@ bcmcnet_tx_buf_get(struct pdma_dev *dev, struct pdma_tx_queue *txq, * Get Tx buffer DMA address */ static void -bcmcnet_tx_buf_dma(struct pdma_dev *dev, struct pdma_tx_queue *txq, - struct pdma_tx_buf *pbuf, dma_addr_t *addr) +ngknet_tx_buf_dma(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf, dma_addr_t *addr) { *addr = pbuf->dma; } @@ -284,11 +317,15 @@ bcmcnet_tx_buf_dma(struct pdma_dev *dev, struct pdma_tx_queue *txq, * Free Tx buffer */ static void -bcmcnet_tx_buf_free(struct pdma_dev *dev, struct pdma_tx_queue *txq, - struct pdma_tx_buf *pbuf) +ngknet_tx_buf_free(struct pdma_dev *dev, struct pdma_tx_queue *txq, + struct pdma_tx_buf *pbuf) { struct ngknet_dev *kdev = (struct ngknet_dev *)dev->priv; + if (!pbuf->skb) { + return; + } + dma_unmap_single(kdev->dev, pbuf->dma, pbuf->len, DMA_TO_DEVICE); if (skb_shinfo(pbuf->skb)->tx_flags & SKBTX_IN_PROGRESS) { skb_queue_tail(&kdev->ptp_tx_queue, pbuf->skb); @@ -305,18 +342,18 @@ bcmcnet_tx_buf_free(struct pdma_dev *dev, struct pdma_tx_queue *txq, } static const struct pdma_buf_mngr buf_mngr = { - .ring_buf_alloc = bcmcnet_ring_buf_alloc, - .ring_buf_free = bcmcnet_ring_buf_free, - .rx_buf_alloc = bcmcnet_rx_buf_alloc, - .rx_buf_dma = bcmcnet_rx_buf_dma, - .rx_buf_avail = bcmcnet_rx_buf_avail, - .rx_buf_get = bcmcnet_rx_buf_get, - .rx_buf_put = bcmcnet_rx_buf_put, - .rx_buf_free = bcmcnet_rx_buf_free, - .rx_buf_mode = bcmcnet_rx_buf_mode, - .tx_buf_get = bcmcnet_tx_buf_get, - .tx_buf_dma = bcmcnet_tx_buf_dma, - .tx_buf_free = bcmcnet_tx_buf_free, + .ring_buf_alloc = ngknet_ring_buf_alloc, + .ring_buf_free = ngknet_ring_buf_free, + .rx_buf_alloc = ngknet_rx_buf_alloc, + .rx_buf_dma = ngknet_rx_buf_dma, + .rx_buf_avail = ngknet_rx_buf_avail, + .rx_buf_get = ngknet_rx_buf_get, + .rx_buf_put = ngknet_rx_buf_put, + .rx_buf_free = ngknet_rx_buf_free, + .rx_buf_mode = ngknet_rx_buf_mode, + .tx_buf_get = ngknet_tx_buf_get, + .tx_buf_dma = ngknet_tx_buf_dma, + .tx_buf_free = ngknet_tx_buf_free, }; /*! diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h index 948815c48304..e8d5a69dc4f6 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_buff.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -30,11 +30,9 @@ /*! Rx SKB reserved size */ #define PDMA_SKB_RESV (PDMA_RXB_RESV + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) /*! Rx buffer size */ -#define PDMA_RXB_SIZE(len) (SKB_DATA_ALIGN(len + NET_SKB_PAD) + PDMA_SKB_RESV) +#define PDMA_RXB_SIZE(len) (SKB_DATA_ALIGN(len) + PDMA_SKB_RESV) /*! Rx reserved meta size */ #define PDMA_RXB_META 64 -/*! Max page buffer size */ -#define PDMA_PAGE_BUF_MAX 2048 /*! * \brief Rx buffer. diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c index 8f4ea5aa3f8f..04d1540a270b 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -102,6 +102,50 @@ ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb) return 0; } +int +ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb) +{ + if (callback_ctrl.netif_create_cb != NULL) { + return -1; + } + callback_ctrl.netif_create_cb = netif_cb; + + return 0; +} + +int +ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb) +{ + if (netif_cb == NULL || callback_ctrl.netif_create_cb != netif_cb) { + return -1; + } + callback_ctrl.netif_create_cb = NULL; + + return 0; +} + +int +ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb) +{ + if (callback_ctrl.netif_destroy_cb != NULL) { + return -1; + } + callback_ctrl.netif_destroy_cb = netif_cb; + + return 0; +} + +int +ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb) +{ + if (netif_cb == NULL || callback_ctrl.netif_destroy_cb != netif_cb) { + return -1; + } + callback_ctrl.netif_destroy_cb = NULL; + + return 0; +} + int ngknet_filter_cb_register(ngknet_filter_cb_f filter_cb) { @@ -285,56 +329,16 @@ ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb) return 0; } -int -ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb) -{ - if (callback_ctrl.netif_create_cb != NULL) { - return -1; - } - callback_ctrl.netif_create_cb = netif_cb; - - return 0; -} - -int -ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb) -{ - if (netif_cb == NULL || callback_ctrl.netif_create_cb != netif_cb) { - return -1; - } - callback_ctrl.netif_create_cb = NULL; - - return 0; -} - -int -ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb) -{ - if (callback_ctrl.netif_destroy_cb != NULL) { - return -1; - } - callback_ctrl.netif_destroy_cb = netif_cb; - - return 0; -} - -int -ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb) -{ - if (netif_cb == NULL || callback_ctrl.netif_destroy_cb != netif_cb) { - return -1; - } - callback_ctrl.netif_destroy_cb = NULL; - - return 0; -} - EXPORT_SYMBOL(ngknet_dev_init_cb_register); EXPORT_SYMBOL(ngknet_dev_init_cb_unregister); EXPORT_SYMBOL(ngknet_rx_cb_register); EXPORT_SYMBOL(ngknet_rx_cb_unregister); EXPORT_SYMBOL(ngknet_tx_cb_register); EXPORT_SYMBOL(ngknet_tx_cb_unregister); +EXPORT_SYMBOL(ngknet_netif_create_cb_register); +EXPORT_SYMBOL(ngknet_netif_create_cb_unregister); +EXPORT_SYMBOL(ngknet_netif_destroy_cb_register); +EXPORT_SYMBOL(ngknet_netif_destroy_cb_unregister); EXPORT_SYMBOL(ngknet_filter_cb_register); EXPORT_SYMBOL(ngknet_filter_cb_unregister); EXPORT_SYMBOL(ngknet_ptp_rx_config_set_cb_register); @@ -351,7 +355,4 @@ EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_register); EXPORT_SYMBOL(ngknet_ptp_phc_index_get_cb_unregister); EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_register); EXPORT_SYMBOL(ngknet_ptp_dev_ctrl_cb_unregister); -EXPORT_SYMBOL(ngknet_netif_create_cb_register); -EXPORT_SYMBOL(ngknet_netif_create_cb_unregister); -EXPORT_SYMBOL(ngknet_netif_destroy_cb_register); -EXPORT_SYMBOL(ngknet_netif_destroy_cb_unregister); + diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h index abc78aa1874f..c330c106817f 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_callback.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -23,79 +23,7 @@ #ifndef NGKNET_CALLBACK_H #define NGKNET_CALLBACK_H -#include -#include "ngknet_main.h" - -/*! - * \brief NGKNET callback description. - */ -struct ngknet_callback_desc { - /*! Device number */ - int dev_no; - - /*! Device ID */ - uint32_t dev_id; - - /*! Device type string */ - const char *type_str; - - /*! Network interface private data */ - struct ngknet_private *priv; - - /*! Matched filter */ - struct ngknet_filter_s *filt; - - /*! Packet meta data */ - uint8_t *pmd; - - /*! Packet meta data length */ - int pmd_len; - - /*! Packet data length */ - int pkt_len; -}; - -#define NGKNET_SKB_CB(_skb) ((struct ngknet_callback_desc *)_skb->cb) - -/*! TX/RX callback init */ -typedef void -(*ngknet_dev_init_cb_f)(const struct ngknet_dev *dev); - -/*! Handle Rx packet */ -typedef struct sk_buff * -(*ngknet_rx_cb_f)(struct sk_buff *skb); - -/*! Handle Tx packet */ -typedef struct sk_buff * -(*ngknet_tx_cb_f)(struct sk_buff *skb); - -/*! Handle Filter callback */ -typedef struct sk_buff * -(*ngknet_filter_cb_f)(struct sk_buff *skb, ngknet_filter_t **filt); - -/*! PTP Rx/Tx config set */ -typedef int -(*ngknet_ptp_config_set_cb_f)(struct ngknet_private *priv, int *value); - -/*! PTP Rx/Tx HW timestamp get */ -typedef int -(*ngknet_ptp_hwts_get_cb_f)(struct sk_buff *skb, uint64_t *ts); - -/*! PTP Tx meta set */ -typedef int -(*ngknet_ptp_meta_set_cb_f)(struct sk_buff *skb); - -/*! PTP PHC index get */ -typedef int -(*ngknet_ptp_phc_index_get_cb_f)(struct ngknet_private *priv, int *index); - -/*! PTP device control */ -typedef int -(*ngknet_ptp_dev_ctrl_cb_f)(struct ngknet_dev *dev, int cmd, char *data, int len); - -/*! Netif callback */ -typedef int -(*ngknet_netif_cb_f)(struct net_device *dev); +#include /*! * \brief NGKNET callback control. @@ -110,6 +38,12 @@ struct ngknet_callback_ctrl { /*! Handle Tx packet */ ngknet_tx_cb_f tx_cb; + /*! Handle Netif creation */ + ngknet_netif_cb_f netif_create_cb; + + /*! Handle Netif destruction */ + ngknet_netif_cb_f netif_destroy_cb; + /*! Handle filter callback */ ngknet_filter_cb_f filter_cb; @@ -133,12 +67,6 @@ struct ngknet_callback_ctrl { /*! PTP device control */ ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb; - - /*! Handle Netif create */ - ngknet_netif_cb_f netif_create_cb; - - /*! Handle Netif destroy */ - ngknet_netif_cb_f netif_destroy_cb; }; /*! @@ -151,275 +79,5 @@ struct ngknet_callback_ctrl { extern int ngknet_callback_control_get(struct ngknet_callback_ctrl **cbc); -/*! - * \brief Register TX/RX callback device initialization callback function. - * - * The device initialization callback allows an external module to - * perform device-specific initialization in preparation for Tx and Rx - * packet processing. - * - * \param [in] dev_init_cb TX/RX callback device initialization callback - * function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_dev_init_cb_register(ngknet_dev_init_cb_f dev_init_cb); - -/*! - * \brief Unegister TX/RX callback device initialization callback function. - * - * The device initialization callback allows an external module to - * perform device-specific initialization in preparation for Tx and Rx - * packet processing. - * - * \param [in] dev_init_cb TX/RX callback device initialization callback - * function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_dev_init_cb_unregister(ngknet_dev_init_cb_f dev_init_cb); - -/*! - * \brief Register Rx callback. - * - * \param [in] rx_cb Rx callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_rx_cb_register(ngknet_rx_cb_f rx_cb); - -/*! - * \brief Unregister Rx callback. - * - * \param [in] rx_cb Rx callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_rx_cb_unregister(ngknet_rx_cb_f rx_cb); - -/*! - * \brief Register Tx callback. - * - * \param [in] tx_cb Tx callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_tx_cb_register(ngknet_tx_cb_f tx_cb); - -/*! - * \brief Unregister Tx callback. - * - * \param [in] tx_cb Tx callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_tx_cb_unregister(ngknet_tx_cb_f tx_cb); - -/*! - * \brief Register filter callback. - * - * \param [in] filter_cb Filter callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_filter_cb_register(ngknet_filter_cb_f filter_cb); - -/*! - * \brief Unregister filter callback. - * - * \param [in] filter_cb Filter callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_filter_cb_unregister(ngknet_filter_cb_f filter_cb); - -/*! - * \brief Register PTP Rx config set callback. - * - * \param [in] ptp_rx_config_set_cb Rx config set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_rx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); - -/*! - * \brief Unregister PTP Rx config set callback. - * - * \param [in] ptp_rx_config_set_cb Rx config set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_rx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_rx_config_set_cb); - -/*! - * \brief Register PTP Tx config set callback. - * - * \param [in] ptp_tx_config_set_cb Tx config set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_config_set_cb_register(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); - -/*! - * \brief Unregister PTP Tx config set callback. - * - * \param [in] ptp_tx_config_set_cb Tx config set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_config_set_cb_unregister(ngknet_ptp_config_set_cb_f ptp_tx_config_set_cb); - -/*! - * \brief Register PTP Rx HW timestamp get callback. - * - * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_rx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); - -/*! - * \brief Unregister PTP Rx HW timestamp get callback. - * - * \param [in] ptp_rx_hwts_get_cb Rx HW timestamp get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_rx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_rx_hwts_get_cb); - -/*! - * \brief Register PTP Tx HW timestamp get callback. - * - * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_hwts_get_cb_register(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); - -/*! - * \brief Unregister PTP Tx HW timestamp get callback. - * - * \param [in] ptp_tx_hwts_get_cb Tx HW timestamp get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_hwts_get_cb_unregister(ngknet_ptp_hwts_get_cb_f ptp_tx_hwts_get_cb); - -/*! - * \brief Register PTP Tx meta set callback. - * - * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_meta_set_cb_register(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); - -/*! - * \brief Unregister PTP Tx meta set callback. - * - * \param [in] ptp_tx_meta_set_cb Tx meta set callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_tx_meta_set_cb_unregister(ngknet_ptp_meta_set_cb_f ptp_tx_meta_set_cb); - -/*! - * \brief Register PTP PHC index get callback. - * - * \param [in] ptp_phc_index_get_cb PHC index get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_phc_index_get_cb_register(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); - -/*! - * \brief Unregister PTP PHC index get callback. - * - * \param [in] ptp_phc_index_get_cb PHC index get callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_phc_index_get_cb_unregister(ngknet_ptp_phc_index_get_cb_f ptp_phc_index_get_cb); - -/*! - * \brief Register PTP device control callback. - * - * \param [in] ptp_dev_ctrl_cb Device control callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_dev_ctrl_cb_register(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); - -/*! - * \brief Unregister PTP device control callback. - * - * \param [in] ptp_dev_ctrl_cb Device control callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_ptp_dev_ctrl_cb_unregister(ngknet_ptp_dev_ctrl_cb_f ptp_dev_ctrl_cb); - -/*! - * \brief Register Netif Create callback. - * - * \param [netif_cb] netif_cb create callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_netif_create_cb_register(ngknet_netif_cb_f netif_cb); - -/*! - * \brief Unregister Netif Create callback. - * - * \param [netif_cb] netif_cb destroy callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_netif_create_cb_unregister(ngknet_netif_cb_f netif_cb); - -/*! - * \brief Register Netif Destroy callback. - * - * \param [netif_cb] netif_cb destroy callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_netif_destroy_cb_register(ngknet_netif_cb_f netif_cb); - -/*! - * \brief Unregister Netif Destroy callback. - * - * \param [netif_cb] netif_cb destroy callback function. - * - * \retval SHR_E_NONE No errors. - */ -extern int -ngknet_netif_destroy_cb_unregister(ngknet_netif_cb_f netif_cb); - #endif /* NGKNET_CALLBACK_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h index 4590a7a6f402..6292494bc92d 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_dep.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -29,8 +29,9 @@ /*! Memorry barrier */ #define MEMORY_BARRIER smp_mb() -/*! CNET print uitility */ -#define CNET_PR(fmt, args...) printk(fmt, ##args) +/*! CNET log macros */ +#define CNET_INFO(unit, fmt, args...) printk(KERN_INFO fmt, ##args) +#define CNET_ERROR(unit, fmt, args...) printk(KERN_ERR fmt, ##args) struct pdma_dev; diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c index 2124cd16f6fd..3bf2dbfdc5ef 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -263,7 +263,7 @@ ngknet_rx_pkt_filter(struct ngknet_dev *dev, struct sk_buff *skb, struct net_dev unsigned long flags; int wsize; int chan_id; - int rv, idx, match = 0, match_cb = 0; + int rv, idx, match = 0,match_cb = 0; rv = bcmcnet_pdma_dev_queue_to_chan(&dev->pdma_dev, pkb->pkh.queue_id, PDMA_Q_RX, &chan_id); @@ -330,9 +330,7 @@ ngknet_rx_pkt_filter(struct ngknet_dev *dev, struct sk_buff *skb, struct net_dev spin_unlock_irqrestore(&dev->lock, flags); return SHR_E_UNAVAIL; } - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->type_str = dev->type_str; + cbd->dinfo = &dev->dev_info; cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pmd_len = pkh->meta_len; cbd->pkt_len = pkh->data_len; @@ -393,7 +391,6 @@ ngknet_rx_pkt_filter(struct ngknet_dev *dev, struct sk_buff *skb, struct net_dev if (dev->cbc->rx_cb) { NGKNET_SKB_CB(skb)->filt = filt; - /* Add callback filter if matched */ if (priv) { priv->filt_cb = match_cb? filt_cb : NULL; @@ -444,7 +441,7 @@ ngknet_rl_process(timer_context_t data) dev = &rc->devs[idx]; if (rc->dev_active[idx] && rc->dev_paused[idx]) { bcmcnet_pdma_dev_rx_resume(&dev->pdma_dev); - rl_ctrl.dev_paused[dev->dev_no] = 0; + rl_ctrl.dev_paused[dev->dev_info.dev_no] = 0; } } spin_unlock_irqrestore(&rc->lock, flags); @@ -481,7 +478,7 @@ ngknet_rx_rate_limit_start(struct ngknet_dev *dev) unsigned long flags; spin_lock_irqsave(&rl_ctrl.lock, flags); - rl_ctrl.dev_active[dev->dev_no] = 1; + rl_ctrl.dev_active[dev->dev_info.dev_no] = 1; spin_unlock_irqrestore(&rl_ctrl.lock, flags); if (!rl_ctrl.started) { @@ -497,7 +494,7 @@ ngknet_rx_rate_limit_stop(struct ngknet_dev *dev) unsigned long flags; spin_lock_irqsave(&rl_ctrl.lock, flags); - rl_ctrl.dev_active[dev->dev_no] = 0; + rl_ctrl.dev_active[dev->dev_info.dev_no] = 0; spin_unlock_irqrestore(&rl_ctrl.lock, flags); } @@ -515,12 +512,13 @@ ngknet_rx_rate_limit(struct ngknet_dev *dev, int limit) spin_lock_irqsave(&rl_ctrl.lock, flags); if ((++rl_ctrl.rx_pkts + rl_ctrl.rx_overruns > limit / rl_ctrl.rx_ticks) && - !rl_ctrl.dev_paused[dev->dev_no] && rl_ctrl.dev_active[dev->dev_no]) { - rl_ctrl.dev_paused[dev->dev_no] = 1; + !rl_ctrl.dev_paused[dev->dev_info.dev_no] && + rl_ctrl.dev_active[dev->dev_info.dev_no]) { + rl_ctrl.dev_paused[dev->dev_info.dev_no] = 1; rl_ctrl.rx_overruns = 0; bcmcnet_pdma_dev_rx_suspend(&dev->pdma_dev); } - if (rl_ctrl.dev_paused[dev->dev_no]) { + if (rl_ctrl.dev_paused[dev->dev_info.dev_no]) { rl_ctrl.rx_overruns++; } spin_unlock_irqrestore(&rl_ctrl.lock, flags); diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h index f9ef71f118d9..1dbeb8094a88 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_extra.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c index 0f1ec3348c71..56d3f2371b47 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -39,19 +39,7 @@ unsigned long sal_time_usecs(void) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) - struct timeval tv; - - kal_time_val_get(&tv); - - return tv.tv_sec * 1000000 + tv.tv_usec; -#else - struct timespec64 tv; - - kal_time_val_get(&tv); - - return tv.tv_sec * 1000000 + tv.tv_nsec / 1000; -#endif + return (unsigned long)kal_time_usecs(); } void diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h index faed6d1f8db8..14475167d7e8 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_linux.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -34,6 +34,13 @@ #define MODULE_PARAM(n, t, p) module_param(n, t, p) + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) +#define NGKNET_ETHTOOL_LINK_SETTINGS 1 +#else +#define NGKNET_ETHTOOL_LINK_SETTINGS 0 +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) #define kal_vlan_hwaccel_put_tag(skb, proto, tci) \ __vlan_hwaccel_put_tag(skb, tci) @@ -44,42 +51,22 @@ __vlan_hwaccel_put_tag(skb, htons(proto), tci) #endif /* KERNEL_VERSION(3,10,0) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) -static inline int -kal_support_paged_skb(void) -{ - return false; -} -#else -static inline int -kal_support_paged_skb(void) -{ - return true; -} -#endif /* KERNEL_VERSION(3,6,0) */ - -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) -static inline struct page * -kal_dev_alloc_page(void) -{ - return NULL; -} -#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,19,0) static inline struct page * -kal_dev_alloc_page(void) +kal_dev_alloc_pages(unsigned int order) { return alloc_pages(GFP_ATOMIC | __GFP_ZERO | __GFP_COLD | - __GFP_COMP | __GFP_MEMALLOC, 0); + __GFP_COMP | __GFP_MEMALLOC, order); } #else static inline struct page * -kal_dev_alloc_page(void) +kal_dev_alloc_pages(unsigned int order) { - return dev_alloc_page(); + return dev_alloc_pages(order); } -#endif /* KERNEL_VERSION(3,6,0) */ +#endif /* KERNEL_VERSION(3,19,0) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) static inline struct sk_buff * kal_build_skb(void *data, unsigned int frag_size) { @@ -91,7 +78,21 @@ kal_build_skb(void *data, unsigned int frag_size) { return build_skb(data, frag_size); } -#endif /* KERNEL_VERSION(3,6,0) */ +#endif /* KERNEL_VERSION(3,5,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,2,0) +static inline bool +kal_page_is_pfmemalloc(struct page *page) +{ + return false; +} +#else +static inline bool +kal_page_is_pfmemalloc(struct page *page) +{ + return page_is_pfmemalloc(page); +} +#endif /* KERNEL_VERSION(4,2,0) */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4,7,0) static inline void @@ -107,26 +108,53 @@ kal_netif_trans_update(struct net_device *dev) } #endif /* KERNEL_VERSION(4,7,0) */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) -static inline void -kal_time_val_get(struct timeval *tv) +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0) +static inline dma_addr_t +kal_dma_map_page_attrs(struct device *dev, struct page *page, + size_t offset, size_t size, enum dma_data_direction dir, + unsigned long attrs) { - do_gettimeofday(tv); + return dma_map_page(dev, page, offset, size, dir); } -#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) static inline void -kal_time_val_get(struct timeval *tv) +kal_dma_unmap_page_attrs(struct device *dev, dma_addr_t addr, + size_t size, enum dma_data_direction dir, + unsigned long attrs) { - struct timespec64 ts; - ktime_get_real_ts64(&ts); - tv->tv_sec = ts.tv_sec; - tv->tv_usec = ts.tv_nsec / 1000; + dma_unmap_page(dev, addr, size, dir); } #else +static inline dma_addr_t +kal_dma_map_page_attrs(struct device *dev, struct page *page, + size_t offset, size_t size, enum dma_data_direction dir, + unsigned long attrs) +{ + return dma_map_page_attrs(dev, page, offset, size, dir, attrs); +} static inline void -kal_time_val_get(struct timespec64 *tv) +kal_dma_unmap_page_attrs(struct device *dev, dma_addr_t addr, + size_t size, enum dma_data_direction dir, + unsigned long attrs) +{ + dma_unmap_page_attrs(dev, addr, size, dir, attrs); +} +#endif /* KERNEL_VERSION(4,10,0) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0) +static inline s64 +kal_time_usecs(void) { - ktime_get_real_ts64(tv); + struct timeval tv; + do_gettimeofday(&tv); + return tv.tv_sec * 1000000 + tv.tv_usec; +} +#else +static inline s64 +kal_time_usecs(void) +{ + struct timespec64 ts; + ktime_get_real_ts64(&ts); + return ts.tv_sec * 1000000 + ts.tv_nsec / 1000; } #endif /* KERNEL_VERSION(3,17,0) */ @@ -158,6 +186,16 @@ kal_copy_to_user(void __user *to, const void *from, return copy_to_user(to, from, len); } +static inline int +kal_support_paged_skb(void) +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0) + return 1; +#else + return 0; +#endif +} + /*! * System abstraction */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c index cc40fd76d224..abf1746bc435 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -156,6 +155,13 @@ MODULE_PARM_DESC(rx_batching, "Rx batching mode (default 0 in single fill mode)"); /*! \endcond */ +/*! \cond */ +static int page_buffer_mode = -1; +MODULE_PARAM(page_buffer_mode, int, 0); +MODULE_PARM_DESC(rx_batching, +"Page buffer mode (default -1 do not override, 0 forced disable, 1 forced enable)"); +/*! \endcond */ + typedef int (*drv_ops_attach)(struct pdma_dev *dev); struct bcmcnet_drv_ops { @@ -234,11 +240,7 @@ ngknet_pkt_dump(uint8_t *data, int len) static void ngknet_pkt_stats(struct pdma_dev *pdev, int dir) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) - static struct timeval tv0[2], tv1[2]; -#else - static struct timespec64 tv0[2], tv1[2]; -#endif + s64 ts0[2], ts1[2]; static uint32_t pkts[2] = {0}, prts[2] = {0}; static uint64_t intrs = 0; uint32_t iv_time; @@ -257,18 +259,12 @@ ngknet_pkt_stats(struct pdma_dev *pdev, int dir) } if (pkts[dir] == 0) { - kal_time_val_get(&tv0[dir]); + ts0[dir] = kal_time_usecs(); intrs = pdev->stats.intrs; } if (++pkts[dir] >= boudary) { - kal_time_val_get(&tv1[dir]); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) - iv_time = (tv1[dir].tv_sec - tv0[dir].tv_sec) * 1000000 + - (tv1[dir].tv_usec - tv0[dir].tv_usec); -#else - iv_time = (tv1[dir].tv_sec - tv0[dir].tv_sec) * 1000000 + - (tv1[dir].tv_nsec - tv0[dir].tv_nsec) / 1000; -#endif + ts1[dir] = kal_time_usecs(); + iv_time = ts1[dir] - ts0[dir]; pps = boudary * 1000 / (iv_time / 1000); prts[dir]++; /* pdev->stats.intrs is reset and re-count from 0. */ @@ -360,7 +356,7 @@ ngknet_rx_frame_process(struct net_device *ndev, struct sk_buff **oskb) skb_trim(skb, skb->len - ETH_FCS_LEN); pkh->data_len -= ETH_FCS_LEN; - if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + if (priv->netif.flags & NGKNET_NETIF_F_RCPU_ENCAP) { /* Set up RCPU header */ memcpy(skb->data, skb->data + PKT_HDR_SIZE + meta_len, 2 * ETH_ALEN); if (*(uint32_t *)&dev->rcpu_ctrl.dst_mac[0] != 0 || @@ -390,11 +386,9 @@ ngknet_rx_frame_process(struct net_device *ndev, struct sk_buff **oskb) /* Optional callback handle */ if (dev->cbc->rx_cb) { struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->type_str = dev->type_str; - cbd->priv = priv; - if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + cbd->dinfo = &dev->dev_info; + cbd->netif = &priv->netif; + if (priv->netif.flags & NGKNET_NETIF_F_RCPU_ENCAP) { cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pkt_len = ntohs(rch->data_len); } else { @@ -402,12 +396,12 @@ ngknet_rx_frame_process(struct net_device *ndev, struct sk_buff **oskb) cbd->pkt_len = pkh->data_len; } cbd->pmd_len = meta_len; - skb = dev->cbc->rx_cb(skb); + skb = dev->cbc->rx_cb(ndev, skb); if (!skb) { *oskb = NULL; return SHR_E_UNAVAIL; } - if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + if (priv->netif.flags & NGKNET_NETIF_F_RCPU_ENCAP) { rch = (struct ngknet_rcpu_hdr *)skb->data; rch->data_len = htons(skb->len - PKT_HDR_SIZE - meta_len); } @@ -450,7 +444,8 @@ ngknet_netif_recv(struct net_device *ndev, struct sk_buff *skb) } } - DBG_VERB(("Rx packet sent up to ndev%d (%d bytes).\n", priv->id, skb->len)); + DBG_VERB(("Rx packet sent up to ndev%d (%d bytes).\n", + priv->netif.id, skb->len)); if (debug & DBG_LVL_PDMP) { ngknet_pkt_dump(skb->data, skb->len); } @@ -464,14 +459,8 @@ ngknet_netif_recv(struct net_device *ndev, struct sk_buff *skb) } } - if (!(priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) && - ndev->features & NETIF_F_HW_VLAN_CTAG_RX && - pkh->attrs & PDMA_RX_STRIP_TAG) { - kal_vlan_hwaccel_put_tag(skb, ETH_P_8021Q, priv->vlan); - } - proto = eth_type_trans(skb, ndev); - if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + if (priv->netif.flags & NGKNET_NETIF_F_RCPU_ENCAP) { skb->protocol = htons(dev->rcpu_ctrl.eth_type); } else if (!(pkh->attrs & PDMA_RX_SET_PROTO) || !skb->protocol) { skb->protocol = proto; @@ -492,14 +481,14 @@ ngknet_netif_recv(struct net_device *ndev, struct sk_buff *skb) napi = (struct napi_struct *)pdev->ctrl.grp[gi].intr_hdl[qi].priv; } - /* FIXME: File CSP on KASAN warning on use-after-free in ngknet_netif_recv */ - skb_len = skb->len; + /* FIXME: File CSP on KASAN warning on use-after-free in ngknet_netif_recv */ + skb_len = skb->len; napi_gro_receive(napi, skb); - /* Update accounting */ priv->stats.rx_packets++; priv->stats.rx_bytes += skb_len; + /* Rate limit */ if (rx_rate_limit >= 0) { if (!ngknet_rx_rate_limit_started()) { @@ -547,9 +536,8 @@ ngknet_frame_recv(struct pdma_dev *pdev, int queue, void *buf) /* Populate header, checksum status, VLAN, and protocol */ priv = netdev_priv(ndev); - if (netif_carrier_ok(ndev)) { - ngknet_netif_recv(ndev, skb); - } else { + if (!netif_carrier_ok(ndev) || + SHR_FAILURE(ngknet_netif_recv(ndev, skb))) { priv->stats.rx_dropped++; rv = SHR_E_UNAVAIL; } @@ -564,9 +552,8 @@ ngknet_frame_recv(struct pdma_dev *pdev, int queue, void *buf) /* Handle mirrored packet */ if (mndev && mskb) { priv = netdev_priv(mndev); - if (netif_carrier_ok(mndev)) { - ngknet_netif_recv(mndev, mskb); - } else { + if (!netif_carrier_ok(mndev) || + SHR_FAILURE(ngknet_netif_recv(mndev, mskb))) { priv->stats.rx_dropped++; dev_kfree_skb_any(mskb); } @@ -638,7 +625,7 @@ ngknet_ptp_tx_config(struct net_device *ndev, struct sk_buff *skb) struct ngknet_dev *dev = priv->bkn_dev; int rv; - if (priv->type == NGKNET_NETIF_T_PORT) { + if (priv->netif.type == NGKNET_NETIF_T_PORT) { rv = ngknet_ptp_tx_meta_set(ndev, skb); if (SHR_FAILURE(rv)) { return rv; @@ -683,7 +670,7 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) uint16_t tpid; /* Set up packet header */ - if (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP) { + if (priv->netif.flags & NGKNET_NETIF_F_RCPU_ENCAP) { /* RCPU encapsulation packet */ data_len = pkh->attrs & PDMA_TX_HDR_COOKED ? pkh->data_len - ETH_FCS_LEN : ntohs(rch->data_len); @@ -728,8 +715,8 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) return SHR_E_NONE; } meta_len = 0; - if (priv->type == NGKNET_NETIF_T_PORT) { - meta_len = priv->meta_len; + if (priv->netif.type == NGKNET_NETIF_T_PORT) { + meta_len = priv->netif.meta_len; if (!meta_len) { printk("Tx abort: no metadata\n"); return SHR_E_UNAVAIL; @@ -752,12 +739,15 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) pkh->data_len = skb->len - PKT_HDR_SIZE - meta_len + ETH_FCS_LEN; pkh->meta_len = meta_len; pkh->attrs = 0; - if (priv->type == NGKNET_NETIF_T_PORT) { + if (priv->netif.type == NGKNET_NETIF_T_PORT) { /* Send to physical port using netif metadata */ - if (priv->meta_off) { - memmove(skb->data + PKT_HDR_SIZE, skb->data + PKT_HDR_SIZE + meta_len, priv->meta_off); + if (priv->netif.meta_off) { + memmove(skb->data + PKT_HDR_SIZE, + skb->data + PKT_HDR_SIZE + meta_len, + priv->netif.meta_off); } - memcpy(skb->data + PKT_HDR_SIZE + priv->meta_off, priv->meta_data, priv->meta_len); + memcpy(skb->data + PKT_HDR_SIZE + priv->netif.meta_off, + priv->netif.meta_data, priv->netif.meta_len); pkh->attrs |= PDMA_TX_HIGIG_PKT; } pkh->pkt_sig = dev->rcpu_ctrl.pkt_sig; @@ -771,7 +761,9 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) tag_len = (tpid == ETH_P_8021Q || tpid == ETH_P_8021AD) ? VLAN_HLEN : 0; /* Need to add VLAN tag if packet is untagged */ - if (!tag_len && (!(pkh->attrs & PDMA_TX_HIGIG_PKT) || priv->flags & NGKNET_NETIF_F_ADD_TAG)) { + if (tag_len == 0 && (priv->netif.vlan & 0xfff) != 0 && + (!(pkh->attrs & PDMA_TX_HIGIG_PKT) || + priv->netif.flags & NGKNET_NETIF_F_ADD_TAG)) { copy_len = PKT_HDR_SIZE + pkh->meta_len + 2 * ETH_ALEN; if (skb_header_cloned(skb) || skb_headroom(skb) < VLAN_HLEN) { nskb = skb_copy_expand(skb, VLAN_HLEN, 0, GFP_ATOMIC); @@ -787,8 +779,8 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) data = skb->data + PKT_HDR_SIZE + pkh->meta_len; data[12] = 0x81; data[13] = 0x00; - data[14] = priv->vlan >> 8 & 0xf; - data[15] = priv->vlan & 0xff; + data[14] = priv->netif.vlan >> 8 & 0xf; + data[15] = priv->netif.vlan & 0xff; pkh->data_len += VLAN_HLEN; tag_len = VLAN_HLEN; } @@ -796,10 +788,8 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) /* Optional callback handle */ if (dev->cbc->tx_cb) { struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->type_str = dev->type_str; - cbd->priv = priv; + cbd->dinfo = &dev->dev_info; + cbd->netif = &priv->netif; cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pmd_len = pkh->meta_len; cbd->pkt_len = skb->len - PKT_HDR_SIZE - pkh->meta_len; @@ -818,7 +808,8 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) pad_len = ETH_ZLEN + ETH_FCS_LEN + tag_len; if (pkh->data_len < pad_len && !(pkh->attrs & PDMA_TX_NO_PAD)) { pkh->data_len = pad_len; - if (skb_padto(skb, PKT_HDR_SIZE + pkh->meta_len + pkh->data_len)) { + if (skb_padto(skb, + PKT_HDR_SIZE + pkh->meta_len + pkh->data_len - ETH_FCS_LEN)) { if (!nskb) { *oskb = NULL; } @@ -832,6 +823,52 @@ ngknet_tx_frame_process(struct net_device *ndev, struct sk_buff **oskb) return SHR_E_NONE; } +/*! + * Network device detach callback + */ +static void +ngknet_ndev_detach(struct pdma_dev *pdev) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + int vdi; + + netif_tx_lock(dev->net_dev); + netif_device_detach(dev->net_dev); + netif_tx_unlock(dev->net_dev); + + for (vdi = 1; vdi <= NUM_VDEV_MAX; vdi++) { + if (!dev->vdev[vdi]) { + continue; + } + netif_tx_lock(dev->vdev[vdi]); + netif_device_detach(dev->vdev[vdi]); + netif_tx_unlock(dev->vdev[vdi]); + } +} + +/*! + * Network device attach callback + */ +static void +ngknet_ndev_attach(struct pdma_dev *pdev) +{ + struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; + int vdi; + + netif_tx_lock(dev->net_dev); + netif_device_attach(dev->net_dev); + netif_tx_unlock(dev->net_dev); + + for (vdi = 1; vdi <= NUM_VDEV_MAX; vdi++) { + if (!dev->vdev[vdi]) { + continue; + } + netif_tx_lock(dev->vdev[vdi]); + netif_device_attach(dev->vdev[vdi]); + netif_tx_unlock(dev->vdev[vdi]); + } +} + /*! * Suspend Tx queue callback */ @@ -1005,7 +1042,7 @@ ngknet_isr(void *isr_data) } if (iv) { - DBG_IRQ(("Got interrupt on device %d.\n", dev->dev_no)); + DBG_IRQ(("Got interrupt on device %d.\n", dev->dev_info.dev_no)); pdev->stats.intrs++; return IRQ_HANDLED; } else { @@ -1057,8 +1094,8 @@ static int ngknet_dev_hnet_wait(struct pdma_dev *pdev) { struct ngknet_dev *dev = (struct ngknet_dev *)pdev->priv; - int qi; - int rv; + uint32_t bmp; + int budget, qi; while (!kthread_should_stop()) { wait_event_interruptible(dev->hnet_wq, @@ -1068,12 +1105,22 @@ ngknet_dev_hnet_wait(struct pdma_dev *pdev) continue; } atomic_set(&dev->hnet_active, 0); - for (qi = 0; qi < pdev->ctrl.nb_txq; qi++) { - do { - rv = pdev->pkt_xmit(pdev, qi, 0); - } while (rv == SHR_E_NONE); - } + schedule_work(&dev->hnet_work); + + do { + bmp = 0x0; + for (qi = 0; qi < pdev->ctrl.nb_txq; qi++) { + bmp |= 1 << qi; + budget = pdev->ctrl.budget; + while (budget--) { + if (SHR_FAILURE(pdev->pkt_xmit(pdev, qi, 0))) { + bmp &= ~(1 << qi); + break; + } + } + } + } while (bmp); } return 0; @@ -1150,14 +1197,14 @@ ngknet_enet_open(struct net_device *ndev) return -EPERM; } - if (priv->id <= 0) { + if (priv->netif.id <= 0) { /* Register interrupt handler */ - ngbde_kapi_intr_connect(dev->dev_no, 0, ngknet_isr, dev); + ngbde_kapi_intr_connect(dev->dev_info.dev_no, 0, ngknet_isr, dev); /* Start PDMA device */ rv = bcmcnet_pdma_dev_start(pdev); if (SHR_FAILURE(rv)) { - ngbde_kapi_intr_disconnect(dev->dev_no, 0); + ngbde_kapi_intr_disconnect(dev->dev_info.dev_no, 0); return -EPERM; } @@ -1169,12 +1216,12 @@ ngknet_enet_open(struct net_device *ndev) /* Notify the stack of the actual queue counts. */ rv = netif_set_real_num_rx_queues(dev->net_dev, pdev->ctrl.nb_rxq); if (rv < 0) { - ngbde_kapi_intr_disconnect(dev->dev_no, 0); + ngbde_kapi_intr_disconnect(dev->dev_info.dev_no, 0); return rv; } rv = netif_set_real_num_tx_queues(dev->net_dev, pdev->ctrl.nb_txq); if (rv < 0) { - ngbde_kapi_intr_disconnect(dev->dev_no, 0); + ngbde_kapi_intr_disconnect(dev->dev_info.dev_no, 0); return rv; } @@ -1229,15 +1276,12 @@ ngknet_enet_stop(struct net_device *ndev) netif_tx_stop_all_queues(ndev); - if (priv->id <= 0) { + if (priv->netif.id <= 0) { /* Stop rate limit */ if (rx_rate_limit >= 0) { ngknet_rx_rate_limit_stop(dev); } - /* Suspend PDMA device */ - bcmcnet_pdma_dev_suspend(pdev); - for (gi = 0; gi < pdev->num_groups; gi++) { if (!pdev->ctrl.grp[gi].attached) { continue; @@ -1259,7 +1303,7 @@ ngknet_enet_stop(struct net_device *ndev) bcmcnet_pdma_dev_stop(pdev); /* Unregister interrupt handler */ - ngbde_kapi_intr_disconnect(dev->dev_no, 0); + ngbde_kapi_intr_disconnect(dev->dev_info.dev_no, 0); } return 0; @@ -1279,13 +1323,13 @@ ngknet_start_xmit(struct sk_buff *skb, struct net_device *ndev) int queue; int rv; - DBG_VERB(("Tx packet from ndev%d (%d bytes).\n", priv->id, skb->len)); + DBG_VERB(("Tx packet from ndev%d (%d bytes).\n", priv->netif.id, skb->len)); if (debug & DBG_LVL_PDMP) { ngknet_pkt_dump(skb->data, skb->len); } /* Do not transmit on base device */ - if (priv->id <= 0) { + if (priv->netif.id <= 0) { priv->stats.tx_dropped++; dev_kfree_skb_any(skb); return NETDEV_TX_OK; @@ -1424,7 +1468,7 @@ ngknet_do_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd) return -EFAULT; } - if (priv->type != NGKNET_NETIF_T_PORT) { + if (priv->netif.type != NGKNET_NETIF_T_PORT) { return -ENOSYS; } @@ -1520,7 +1564,7 @@ static const struct net_device_ops ngknet_netdev_ops = { }; static void -ngknet_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) +ngknet_get_drvinfo(struct net_device *ndev, struct ethtool_drvinfo *drvinfo) { strlcpy(drvinfo->driver, "linux_ngknet", sizeof(drvinfo->driver)); snprintf(drvinfo->version, sizeof(drvinfo->version), "%d", NGKNET_IOC_VERSION); @@ -1551,11 +1595,41 @@ ngknet_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info) } #endif +#if NGKNET_ETHTOOL_LINK_SETTINGS +static int +ngknet_get_link_ksettings(struct net_device *ndev, + struct ethtool_link_ksettings *cmd) +{ + struct ngknet_private *priv = netdev_priv(ndev); + + cmd->base.speed = priv->link_settings.speed; + cmd->base.duplex = priv->link_settings.duplex; + + return 0; +} + +static int +ngknet_set_link_ksettings(struct net_device *ndev, + const struct ethtool_link_ksettings *cmd) +{ + struct ngknet_private *priv = netdev_priv(ndev); + + priv->link_settings.speed = cmd->base.speed; + priv->link_settings.duplex = cmd->base.speed ? DUPLEX_FULL : 0; + + return 0; +} +#endif + static const struct ethtool_ops ngknet_ethtool_ops = { .get_drvinfo = ngknet_get_drvinfo, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) .get_ts_info = ngknet_get_ts_info, #endif +#if NGKNET_ETHTOOL_LINK_SETTINGS + .get_link_ksettings = ngknet_get_link_ksettings, + .set_link_ksettings = ngknet_set_link_ksettings, +#endif }; /*! @@ -1608,6 +1682,12 @@ ngknet_ndev_init(ngknet_netif_t *netif, struct net_device **nd) ndev->mtu = default_mtu ? default_mtu : rx_buffer_size; } + /* MTU range: 32 - 9198 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) + ndev->min_mtu = PKT_HDR_SIZE; /* Min 50-byte length of packet with RCPU-encap */ + ndev->max_mtu = rx_buffer_size - (ETH_HLEN + ETH_FCS_LEN); +#endif + ndev->netdev_ops = &ngknet_netdev_ops; ndev->ethtool_ops = &ngknet_ethtool_ops; @@ -1625,9 +1705,9 @@ ngknet_ndev_init(ngknet_netif_t *netif, struct net_device **nd) memcpy(ndev->dev_addr, ma, ETH_ALEN); /* Initialize the device features */ - ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | + ndev->hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_TX; - ndev->features |= NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_RX; + ndev->features = ndev->hw_features | NETIF_F_HIGHDMA; /* Register the kernel network device */ rv = register_netdev(ndev); @@ -1675,7 +1755,7 @@ ngknet_pdev_init(struct ngknet_dev *dev) int rv; /* Initialize PDMA control structure */ - pdev->unit = dev->dev_no; + pdev->unit = dev->dev_info.dev_no; pdev->priv = dev; pdev->ctrl.dev = pdev; pdev->ctrl.hw_addr = dev->base_addr; @@ -1685,6 +1765,8 @@ ngknet_pdev_init(struct ngknet_dev *dev) pdev->dev_read32 = ngknet_dev_read32; pdev->dev_write32 = ngknet_dev_write32; pdev->pkt_recv = ngknet_frame_recv; + pdev->ndev_detach = ngknet_ndev_detach; + pdev->ndev_attach = ngknet_ndev_attach; pdev->tx_suspend = ngknet_tx_suspend; pdev->tx_resume = ngknet_tx_resume; pdev->intr_unmask = ngknet_intr_enable; @@ -1741,10 +1823,9 @@ ngknet_dev_info_get(int dn) return SHR_E_ACCESS; } - dev->dev_no = dn; - strlcpy(dev->type_str, - drv_ops[dev->pdma_dev.dev_type]->drv_desc, - sizeof(dev->type_str)); + dev->dev_info.dev_no = dn; + strlcpy(dev->dev_info.type_str, drv_ops[dev->pdma_dev.dev_type]->drv_desc, + sizeof(dev->dev_info.type_str)); return SHR_E_NONE; } @@ -1813,25 +1894,15 @@ ngknet_dev_probe(int dn, ngknet_netif_t *netif) priv = netdev_priv(ndev); priv->net_dev = ndev; priv->bkn_dev = dev; - priv->id = 0; - priv->type = netif->type; - if (priv->type == NGKNET_NETIF_T_PORT) { - priv->meta_off = netif->meta_off; - priv->meta_len = netif->meta_len; - memcpy(priv->meta_data, netif->meta_data, priv->meta_len); - } - priv->flags = netif->flags; - priv->vlan = netif->vlan; - priv->chan = netif->chan; - memcpy(priv->user_data, netif->user_data, sizeof(priv->user_data)); - - netif->id = priv->id; + + netif->id = 0; memcpy(netif->macaddr, ndev->dev_addr, ETH_ALEN); netif->mtu = ndev->mtu; memcpy(netif->name, ndev->name, sizeof(netif->name) - 1); + memcpy(&priv->netif, netif, sizeof(priv->netif)); - if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { - dev->bdev[priv->chan] = ndev; + if (priv->netif.flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->netif.chan] = ndev; } /* Register for napi */ @@ -1868,7 +1939,7 @@ ngknet_dev_probe(int dn, ngknet_netif_t *netif) return SHR_E_INTERNAL; } cpumask_clear(&mask); - cpumask_set_cpu(1, &mask); + cpumask_set_cpu(num_online_cpus() / 2, &mask); set_cpus_allowed_ptr(dev->hnet_task, &mask); INIT_WORK(&dev->hnet_work, ngknet_dev_hnet_schedule); } @@ -2006,7 +2077,8 @@ ngknet_netif_create(struct ngknet_dev *dev, ngknet_netif_t *netif) if (netif->name[0] == '\0') { /* Reserve 6 vacancies for base&vitual device number, i.e. nameAB_XYZ */ if (strlen(base_dev_name) < IFNAMSIZ - 6) { - snprintf(netif->name, IFNAMSIZ, "%s%d%s", base_dev_name, dev->dev_no, "_"); + snprintf(netif->name, IFNAMSIZ, "%s%d%s", + base_dev_name, dev->dev_info.dev_no, "_"); strncat(netif->name, "%d", 3); } else { DBG_WARN(("Too long network device name: %s.\n", base_dev_name)); @@ -2048,36 +2120,27 @@ ngknet_netif_create(struct ngknet_dev *dev, ngknet_netif_t *netif) priv = netdev_priv(ndev); priv->net_dev = ndev; priv->bkn_dev = dev; - priv->id = id; - priv->type = netif->type; - if (priv->type == NGKNET_NETIF_T_PORT) { - priv->meta_off = netif->meta_off; - priv->meta_len = netif->meta_len; - memcpy(priv->meta_data, netif->meta_data, priv->meta_len); - } - priv->flags = netif->flags; - priv->vlan = netif->vlan; - priv->chan = netif->chan; - memcpy(priv->user_data, netif->user_data, sizeof(priv->user_data)); - - netif->id = priv->id; + + netif->id = id; memcpy(netif->macaddr, ndev->dev_addr, ETH_ALEN); netif->mtu = ndev->mtu; memcpy(netif->name, ndev->name, sizeof(netif->name) - 1); + memcpy(&priv->netif, netif, sizeof(priv->netif)); - if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { - dev->bdev[priv->chan] = ndev; + if (priv->netif.flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->netif.chan] = ndev; } /* Optional netif create callback handle */ if (dev->cbc->netif_create_cb) { - rv = dev->cbc->netif_create_cb(ndev); - if (rv) { - DBG_WARN(("Netif create callback failed with rv %d for '%s'\n", rv, ndev->name)); + if (dev->cbc->netif_create_cb(ndev)) { + DBG_WARN(("Network interface callback (create) failed for '%s'\n", + ndev->name)); } } - DBG_VERB(("Created virtual network device %s (%d).\n", ndev->name, priv->id)); + DBG_VERB(("Created virtual network device %s (%d).\n", + ndev->name, priv->netif.id)); return SHR_E_NONE; } @@ -2116,8 +2179,8 @@ ngknet_netif_destroy(struct ngknet_dev *dev, int id) set_current_state(TASK_RUNNING); } - if (priv->flags & NGKNET_NETIF_F_BIND_CHAN) { - dev->bdev[priv->chan] = NULL; + if (priv->netif.flags & NGKNET_NETIF_F_BIND_CHAN) { + dev->bdev[priv->netif.chan] = NULL; } dev->vdev[id] = NULL; @@ -2135,12 +2198,14 @@ ngknet_netif_destroy(struct ngknet_dev *dev, int id) /* Optional netif destroy callback handle */ if (dev->cbc->netif_destroy_cb) { - int rv = dev->cbc->netif_destroy_cb(ndev); - if (rv) { - DBG_WARN(("Netif destroy callback failed with rv %d for '%s'\n", rv, ndev->name)); + if (dev->cbc->netif_destroy_cb(ndev)) { + DBG_WARN(("Network interface callback (destroy) failed for '%s'\n", + ndev->name)); } } - DBG_VERB(("Removing virtual network device %s (%d).\n", ndev->name, priv->id)); + + DBG_VERB(("Removing virtual network device %s (%d).\n", + ndev->name, priv->netif.id)); netif_carrier_off(ndev); unregister_netdev(ndev); @@ -2170,18 +2235,7 @@ ngknet_netif_get(struct ngknet_dev *dev, int id, ngknet_netif_t *netif) } priv = netdev_priv(ndev); - netif->id = priv->id; - netif->type = priv->type; - netif->flags = priv->flags; - netif->vlan = priv->vlan; - memcpy(netif->macaddr, priv->net_dev->dev_addr, ETH_ALEN); - netif->mtu = priv->net_dev->mtu; - netif->chan = priv->chan; - memcpy(netif->name, priv->net_dev->name, sizeof(netif->name) - 1); - netif->meta_off = priv->meta_off; - netif->meta_len = priv->meta_len; - memcpy(netif->meta_data, priv->meta_data, netif->meta_len); - memcpy(netif->user_data, priv->user_data, sizeof(netif->user_data)); + memcpy(netif, &priv->netif, sizeof(*netif)); num = (long)dev->vdev[0]; for (id++; id < num + 1; id++) { @@ -2193,7 +2247,8 @@ ngknet_netif_get(struct ngknet_dev *dev, int id, ngknet_netif_t *netif) spin_unlock_irqrestore(&dev->lock, flags); - DBG_VERB(("Got virtual network device %s (%d).\n", ndev->name, priv->id)); + DBG_VERB(("Got virtual network device %s (%d).\n", + ndev->name, priv->netif.id)); return SHR_E_NONE; } @@ -2232,6 +2287,12 @@ ngknet_rx_rate_limit_set(int rate_limit) rx_rate_limit = rate_limit; } +int +ngknet_page_buffer_mode_get(void) +{ + return page_buffer_mode; +} + /*! * Generic module functions */ @@ -2344,7 +2405,8 @@ ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } if (!strcasecmp(dev_cfg->type_str, drv_ops[dt]->drv_desc)) { pdev->dev_type = dt; - strlcpy(dev->var_str, dev_cfg->var_str, sizeof(dev->var_str)); + strlcpy(dev->dev_info.var_str, dev_cfg->var_str, + sizeof(dev->dev_info.var_str)); break; } } @@ -2357,7 +2419,7 @@ ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg) for (gi = 0; gi < NUM_GRP_MAX; gi++) { if (1 << gi & dev_cfg->bm_grp) { pdev->ctrl.nb_grp++; - pdev->ctrl.grp[gi].attached = 1; + pdev->ctrl.grp[gi].attached = true; pdev->num_groups = gi + 1; } } @@ -2372,7 +2434,7 @@ ngknet_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } if (dev->cbc->dev_init_cb) { - dev->cbc->dev_init_cb(dev); + dev->cbc->dev_init_cb(&dev->dev_info); } if (kal_copy_to_user((void *)(unsigned long)ioc.op.data.buf, dev_cfg, diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h index 71ea0fb84fdf..e31d4bb257ab 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_main.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -23,18 +23,12 @@ #ifndef NGKNET_MAIN_H #define NGKNET_MAIN_H +#include #include #include #include #include -/*! Maximum number of PDMA devices supported */ -#ifdef NGBDE_NUM_SWDEV_MAX -#define NUM_PDMA_DEV_MAX NGBDE_NUM_SWDEV_MAX -#else -#define NUM_PDMA_DEV_MAX 16 -#endif - /*! * Debug levels */ @@ -68,11 +62,8 @@ * Device description */ struct ngknet_dev { - /*! Device type string */ - char type_str[NGKNET_DEV_NAME_MAX]; - - /*! Device type string */ - char var_str[NGKNET_DEV_NAME_MAX]; + /* Device information */ + ngknet_dev_info_t dev_info; /*! Base address for PCI register access */ volatile void *base_addr; @@ -89,9 +80,6 @@ struct ngknet_dev { /*! PDMA device */ struct pdma_dev pdma_dev; - /*! Device number (from BDE) */ - int dev_no; - /*! Virtual network devices, 0 is reserved for valid number of devices. */ struct net_device *vdev[NUM_VDEV_MAX + 1]; @@ -159,32 +147,8 @@ struct ngknet_private { /*! NGKNET device */ struct ngknet_dev *bkn_dev; - /*! Network interface ID */ - int id; - - /*! Network interface type */ - int type; - - /*! Network interface flags */ - uint32_t flags; - - /*! Network interface vlan */ - uint32_t vlan; - - /*! Network interface bound to */ - uint32_t chan; - - /*! Metadata offset from Ethernet header */ - uint32_t meta_off; - - /*! Metadata length */ - uint32_t meta_len; - - /*! Metadata used to send packets to physical port */ - uint8_t meta_data[NGKNET_NETIF_META_MAX]; - - /*! User data gotten back through callbacks */ - uint8_t user_data[NGKNET_NETIF_USER_DATA]; + /*! Network interface */ + ngknet_netif_t netif; /*! Users of this network interface */ int users; @@ -198,7 +162,11 @@ struct ngknet_private { /*! HW timestamp Tx type */ int hwts_tx_type; - /*! Matched callback filter */ +#if NGKNET_ETHTOOL_LINK_SETTINGS + /* Link settings */ + struct ethtool_link_settings link_settings; +#endif + /*! Matched callback filter */ struct ngknet_filter_s *filt_cb; }; @@ -283,5 +251,13 @@ ngknet_rx_rate_limit_get(void); extern void ngknet_rx_rate_limit_set(int rate_limit); +/*! + * \brief Get page buffer mode. + * + * \retval Current page buffer mode. + */ +extern int +ngknet_page_buffer_mode_get(void); + #endif /* NGKNET_MAIN_H */ diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c index 60b59c0761d6..ad3aefe83b32 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -88,24 +88,14 @@ proc_debug_level_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_debug_level_fops = { - owner: THIS_MODULE, - open: proc_debug_level_open, - read: seq_read, - write: proc_debug_level_write, - llseek: seq_lseek, - release: proc_debug_level_release, -}; -#else static struct proc_ops proc_debug_level_fops = { - proc_open: proc_debug_level_open, - proc_read: seq_read, - proc_write: proc_debug_level_write, - proc_lseek: seq_lseek, - proc_release: proc_debug_level_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_debug_level_open, + .proc_read = seq_read, + .proc_write = proc_debug_level_write, + .proc_lseek = seq_lseek, + .proc_release = proc_debug_level_release, }; -#endif static int proc_device_info_show(struct seq_file *m, void *v) @@ -151,9 +141,15 @@ proc_device_info_show(struct seq_file *m, void *v) for (qi = 0; qi < info->nb_rx_queues; qi++) { seq_printf(m, "nb_rx_desc[%d]: %d\n", qi, info->nb_rx_desc[qi]); } + for (qi = 0; qi < info->nb_rx_queues; qi++) { + seq_printf(m, "rxq_state[%d]: 0x%x\n", qi, info->rxq_state[qi]); + } for (qi = 0; qi < info->nb_tx_queues; qi++) { seq_printf(m, "nb_tx_desc[%d]: %d\n", qi, info->nb_tx_desc[qi]); } + for (qi = 0; qi < info->nb_tx_queues; qi++) { + seq_printf(m, "txq_state[%d]: 0x%x\n", qi, info->txq_state[qi]); + } } if (!ai) { @@ -178,22 +174,13 @@ proc_device_info_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_device_info_fops = { - owner: THIS_MODULE, - open: proc_device_info_open, - read: seq_read, - llseek: seq_lseek, - release: proc_device_info_release, -}; -#else static struct proc_ops proc_device_info_fops = { - proc_open: proc_device_info_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_device_info_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_device_info_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_device_info_release, }; -#endif static int proc_filter_info_show(struct seq_file *m, void *v) @@ -269,22 +256,13 @@ proc_filter_info_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_filter_info_fops = { - owner: THIS_MODULE, - open: proc_filter_info_open, - read: seq_read, - llseek: seq_lseek, - release: proc_filter_info_release, -}; -#else static struct proc_ops proc_filter_info_fops = { - proc_open: proc_filter_info_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_filter_info_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_filter_info_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_filter_info_release, }; -#endif static int proc_netif_info_show(struct seq_file *m, void *v) @@ -370,22 +348,13 @@ proc_netif_info_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_netif_info_fops = { - owner: THIS_MODULE, - open: proc_netif_info_open, - read: seq_read, - llseek: seq_lseek, - release: proc_netif_info_release, -}; -#else static struct proc_ops proc_netif_info_fops = { - proc_open: proc_netif_info_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_netif_info_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_netif_info_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_netif_info_release, }; -#endif static int proc_pkt_stats_show(struct seq_file *m, void *v) @@ -455,22 +424,13 @@ proc_pkt_stats_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_pkt_stats_fops = { - owner: THIS_MODULE, - open: proc_pkt_stats_open, - read: seq_read, - llseek: seq_lseek, - release: proc_pkt_stats_release, -}; -#else static struct proc_ops proc_pkt_stats_fops = { - proc_open: proc_pkt_stats_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_pkt_stats_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_pkt_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_pkt_stats_release, }; -#endif static int proc_rate_limit_show(struct seq_file *m, void *v) @@ -510,24 +470,14 @@ proc_rate_limit_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_rate_limit_fops = { - owner: THIS_MODULE, - open: proc_rate_limit_open, - read: seq_read, - write: proc_rate_limit_write, - llseek: seq_lseek, - release: proc_rate_limit_release, -}; -#else static struct proc_ops proc_rate_limit_fops = { - proc_open: proc_rate_limit_open, - proc_read: seq_read, - proc_write: proc_rate_limit_write, - proc_lseek: seq_lseek, - proc_release: proc_rate_limit_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_rate_limit_open, + .proc_read = seq_read, + .proc_write = proc_rate_limit_write, + .proc_lseek = seq_lseek, + .proc_release = proc_rate_limit_release, }; -#endif static int proc_reg_status_show(struct seq_file *m, void *v) @@ -571,22 +521,13 @@ proc_reg_status_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_reg_status_fops = { - owner: THIS_MODULE, - open: proc_reg_status_open, - read: seq_read, - llseek: seq_lseek, - release: proc_reg_status_release, -}; -#else static struct proc_ops proc_reg_status_fops = { - proc_open: proc_reg_status_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_reg_status_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_reg_status_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_reg_status_release, }; -#endif static int proc_ring_status_show(struct seq_file *m, void *v) @@ -634,22 +575,13 @@ proc_ring_status_release(struct inode *inode, struct file *file) return single_release(inode, file); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) -static struct file_operations proc_ring_status_fops = { - owner: THIS_MODULE, - open: proc_ring_status_open, - read: seq_read, - llseek: seq_lseek, - release: proc_ring_status_release, -}; -#else static struct proc_ops proc_ring_status_fops = { - proc_open: proc_ring_status_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_release: proc_ring_status_release, + PROC_OWNER(THIS_MODULE) + .proc_open = proc_ring_status_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = proc_ring_status_release, }; -#endif int ngknet_procfs_init(void) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h index 99e1ce93c48d..f6df80fe7064 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_procfs.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c index 75e22bc43f17..eaec51a9800f 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.c @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or @@ -36,11 +36,10 @@ ngknet_ptp_rx_config_set(struct net_device *ndev, int *filter) /* * The expected Rx filter value is passed to the callback. The callback * should pass back the actual filter value by the paramter . - * The callback can use priv->user_data to get other private parameters - * such as phys_port, dev_type, etc, which should be introduced when the - * netif is created. + * The callback can use netif->user_data to get other private parameters + * like phys_port which should be introduced when the netif is created. */ - return dev->cbc->ptp_rx_config_set_cb(priv, filter); + return dev->cbc->ptp_rx_config_set_cb(&dev->dev_info, &priv->netif, filter); } int @@ -56,11 +55,10 @@ ngknet_ptp_tx_config_set(struct net_device *ndev, int type) /* * The Tx type value is passed to the callback by the parameter . * The callback should do the configuration according to the type. - * The callback can use priv->user_data to get other private parameters - * such as phys_port, dev_type, etc, which should be introduced when the - * netif is created. + * The callback can use netif->user_data to get other private parameters + * like phys_port which should be introduced when the netif is created. */ - return dev->cbc->ptp_tx_config_set_cb(priv, &type); + return dev->cbc->ptp_tx_config_set_cb(&dev->dev_info, &priv->netif, &type); } int @@ -75,9 +73,8 @@ ngknet_ptp_rx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *t return SHR_E_UNAVAIL; } - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->priv = priv; + cbd->dinfo = &dev->dev_info; + cbd->netif = &priv->netif; cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pmd_len = pkh->meta_len; cbd->pkt_len = pkh->data_len; @@ -87,7 +84,8 @@ ngknet_ptp_rx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *t * by the parameter . * Some parameters have been consolidated to SKB as above. They can be * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are - * in NGKNET_SKB_CB(skb)->priv->user_data[]. + * in NGKNET_SKB_CB(skb)->dinfo or NGKNET_SKB_CB(skb)->netif->user_data + * such as dev_type, phys_port and so on. */ return dev->cbc->ptp_rx_hwts_get_cb(skb, ts); } @@ -104,9 +102,8 @@ ngknet_ptp_tx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *t return SHR_E_UNAVAIL; } - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->priv = priv; + cbd->dinfo = &dev->dev_info; + cbd->netif = &priv->netif; cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pmd_len = pkh->meta_len; cbd->pkt_len = pkh->data_len; @@ -120,8 +117,8 @@ ngknet_ptp_tx_hwts_get(struct net_device *ndev, struct sk_buff *skb, uint64_t *t * been tranmitted out from port. * Some parameters have been consolidated to SKB as above. They can be * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are - * in NGKNET_SKB_CB(skb)->priv->user_data[] such as phys_port, dev_type, - * and so on. + * in NGKNET_SKB_CB(skb)->dinfo or NGKNET_SKB_CB(skb)->netif->user_data + * such as dev_type, phys_port and so on. */ return dev->cbc->ptp_tx_hwts_get_cb(skb, ts); } @@ -138,9 +135,8 @@ ngknet_ptp_tx_meta_set(struct net_device *ndev, struct sk_buff *skb) return SHR_E_UNAVAIL; } - cbd->dev_no = dev->dev_no; - cbd->dev_id = dev->pdma_dev.dev_id; - cbd->priv = priv; + cbd->dinfo = &dev->dev_info; + cbd->netif = &priv->netif; cbd->pmd = skb->data + PKT_HDR_SIZE; cbd->pmd_len = pkh->meta_len; cbd->pkt_len = pkh->data_len; @@ -150,8 +146,8 @@ ngknet_ptp_tx_meta_set(struct net_device *ndev, struct sk_buff *skb) * for HW timestamping according to the corresponding switch device. * Some parameters have been consolidated to SKB as above. They can be * achieved by NGKNET_SKB_CB(skb). Specially more private paramters are - * in NGKNET_SKB_CB(skb)->priv->user_data[] such as phys_port, dev_type, - * and so on. + * in NGKNET_SKB_CB(skb)->dinfo or NGKNET_SKB_CB(skb)->netif->user_data + * such as dev_type, phys_port and so on. */ return dev->cbc->ptp_tx_meta_set_cb(skb); } @@ -168,11 +164,10 @@ ngknet_ptp_phc_index_get(struct net_device *ndev, int *index) /* * The callback should return the HPC index by the parameter . - * priv->user_data[] can be used to get other private parameters such as - * phys_port, dev_type, etc, which should be introduced when the netif is - * created. + * netif->user_data can be used to get other private parameters such as + * phys_port which should be introduced when the netif is created. */ - return dev->cbc->ptp_phc_index_get_cb(priv, index); + return dev->cbc->ptp_phc_index_get_cb(&dev->dev_info, &priv->netif, index); } int @@ -183,12 +178,12 @@ ngknet_ptp_dev_ctrl(struct ngknet_dev *dev, int cmd, char *data, int len) } /* - * The callback is IOCTL dispatcher for PTP driver/module. + * The callback is IOCTL dispatcher for PTP kernel driver/module. * The parameter is the command defined by the user. The parameter * and are used for interactions between the user application * and the driver for PTP device start/stop, enable/disable, set/get, and * so on. */ - return dev->cbc->ptp_dev_ctrl_cb(dev, cmd, data, len); + return dev->cbc->ptp_dev_ctrl_cb(&dev->dev_info, cmd, data, len); } diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h index e881c77b5273..c365a8d8d0e7 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knet/ngknet_ptp.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild index e14e25669cff..0469855c7dfd 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Kbuild @@ -2,7 +2,7 @@ # # Linux KNET Callback module. # -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -17,23 +17,32 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # -ifneq ($(CONFIG_PSAMPLE),) + +ifeq ($(BUILD_PSAMPLE),1) +PSAMPLE_CFLAGS=-DPSAMPLE_SUPPORT PSAMPLE_CB_OBJS=psample-cb.o endif +ifneq ($(OUTPUT_DIR),) +INCLUDES := -I$(OUTPUT_DIR)/knet/generated/include -I$(OUTPUT_DIR)/knet/generated +endif obj-m := linux_ngknetcb.o ccflags-y := $(KNETCB_CPPFLAGS) $(LKM_CFLAGS) \ - $(SDK_PMD_KFLAGS) \ - -I$(SDK)/shr/include \ - -I$(SDK)/bcmdrd/include \ - -I$(SDK)/bcmltd/include \ - -I$(SDK)/bcmlrd/include \ - -I$(SDK)/linux/include \ - -I$(SDK)/linux/knet/include \ - -I$(SDK)/linux/knetcb \ - -I$(SDK)/linux/knet \ - $(PSAMPLE_CFLAGS) + $(SDK_PMD_KFLAGS) \ + -I$(SDK)/shr/include \ + -I$(SDK)/bcmdrd/include \ + -I$(SDK)/bcmltd/include \ + -I$(SDK)/bcmlrd/include \ + -I$(SDK)/bcmcnet/include \ + -I$(SDK)/linux/include \ + -I$(SDK)/linux/knetcb \ + -I$(SDK)/linux/knet \ + -I$(SDK)/linux/knet/generated/include \ + -I$(SDK)/linux/knet/generated \ + $(INCLUDES) \ + $(PSAMPLE_CFLAGS) \ -linux_ngknetcb-y := $(SDK_PMD_KOBJS) ngknetcb_main.o \ - $(PSAMPLE_CB_OBJS) +linux_ngknetcb-y := $(SDK_PMD_KOBJS) \ + ngknetcb_main.o \ + $(PSAMPLE_CB_OBJS) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile index 4698183db035..b23af7ed4e86 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/Makefile @@ -1,8 +1,5 @@ -# -*- Makefile -*- # -# Linux KNET Callback module. -# -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or @@ -17,6 +14,8 @@ # A copy of the GNU General Public License version 2 (GPLv2) can # be found in the LICENSES folder.$ # +# Linux KNET Callback module. +# ifdef KPMD @@ -32,7 +31,7 @@ knetcb: mklinks # SDK make helper for stand-alone PMD kernel module include $(SDK)/make/kpmd.mk -distclean: rmlinks +distclean:: rmlinks endif #KPMD @@ -48,4 +47,4 @@ endif .PHONY: distclean -distclean: +distclean:: diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c index af2a0c9aef3d..0cfe939ac5fc 100644 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/ngknetcb_main.c @@ -3,14 +3,14 @@ * NGKNET Callback module entry. */ /* - * $Copyright: (c) 2019 Broadcom. + * $Copyright: (c) 2022 Broadcom. * Broadcom Proprietary and Confidential. All rights reserved.$ */ #include #include #include "psample-cb.h" - +#include "bcmcnet/bcmcnet_core.h" /*! \cond */ MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("NGKNET Callback Module"); @@ -19,7 +19,7 @@ MODULE_LICENSE("GPL"); /*! \cond */ int debug = 0; -MODULE_PARAM(debug, int, 0); +module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (default 0)"); /*! \endcond */ @@ -64,6 +64,42 @@ strip_vlan_tag(struct sk_buff *skb) } } +static uint32_t +dev_id_get(char* dev_type) +{ + uint32_t dev_id = 0xb880; + + if (0 == strcmp(dev_type, "bcm56880_a0")) + { + dev_id = 0xb880; + } + else if (0 == strcmp(dev_type, "bcm56780_a0")) + { + dev_id = 0xb780; + } + else if ((0 == strcmp(dev_type, "bcm56990_a0")) || + (0 == strcmp(dev_type, "bcm56990_b0"))) + { + dev_id = 0xb990; + } + else if ((0 == strcmp(dev_type, "bcm56996_a0")) || + (0 == strcmp(dev_type, "bcm56996_b0"))) + { + dev_id = 0xb996; + } + else if ((0== strcmp(dev_type, "bcm56995_a0")) || + (0== strcmp(dev_type, "bcm56999_a0"))) + { + dev_id = 0xb999; + } + else if ((0== strcmp(dev_type, "bcm56993_b0")) || + (0== strcmp(dev_type, "bcm56998_a0"))) + { + dev_id = 0xb993; + } + return dev_id; +} + /* * The function get_tag_status() returns the tag status. * 0 = Untagged @@ -73,7 +109,7 @@ strip_vlan_tag(struct sk_buff *skb) * -1 = Unsupported type */ static int -get_tag_status(uint32_t dev_type, uint32_t variant, void *meta) +get_tag_status(char* dev_type, char* dev_var, void *meta) { uint32_t *valptr; uint32_t fd_index; @@ -81,15 +117,24 @@ get_tag_status(uint32_t dev_type, uint32_t variant, void *meta) int tag_status = -1; uint32_t match_id_minbit = 1; uint32_t outer_tag_match = 0x10; - - if ((dev_type == 0xb880) || (dev_type == 0xb780)) + uint32_t dev_id = 0xb880; + + dev_id = dev_id_get(dev_type); +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + printk("dev_type %s dev_var %s\n", dev_type, dev_var); + } +#endif + + if ((0xb880 == dev_id ) || (0xb780 == dev_id)) { /* Field BCM_PKTIO_RXPMD_MATCH_ID_LO has tag status in RX PMD */ fd_index = 2; valptr = (uint32_t *)meta; - match_id_minbit = (dev_type == 0xb780) ? 2 : 1; + match_id_minbit = (dev_id == 0xb780) ? 2 : 1; outer_l2_hdr = (valptr[fd_index] >> match_id_minbit & 0xFF); - outer_tag_match = ((dev_type == 0xb780 && variant == 1) ? 0x8 : 0x10); + outer_tag_match = (((dev_id == 0xb780) && + ((strncmp(dev_var, "DNA_", 4)) == 0)) ? 0x8 : 0x10); if (outer_l2_hdr & 0x1) { #ifdef KNET_CB_DEBUG if (debug & 0x1) { @@ -131,7 +176,8 @@ get_tag_status(uint32_t dev_type, uint32_t variant, void *meta) } } } - else if ((dev_type == 0xb990)|| (dev_type == 0xb996)) + else if ((dev_id == 0xb990)|| (dev_id == 0xb996) || + (dev_id == 0xb999)|| (dev_id == 0xb993)) { fd_index = 9; valptr = (uint32_t *)meta; @@ -165,7 +211,7 @@ get_tag_status(uint32_t dev_type, uint32_t variant, void *meta) } #ifdef KNET_CB_DEBUG if (debug & 0x1) { - printk("%s; Device Type: %d; tag status: %d\n", __func__, dev_type, tag_status); + printk("%s; Device Type: %s; tag status: %d\n", __func__, dev_type, tag_status); } #endif return tag_status; @@ -218,11 +264,10 @@ static struct sk_buff * strip_tag_rx_cb(struct sk_buff *skb) { const struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); - const struct ngknet_private *priv = cbd->priv; int rcpu_mode = 0; int tag_status; - rcpu_mode = (priv->flags & NGKNET_NETIF_F_RCPU_ENCAP)? 1 : 0; + rcpu_mode = (cbd->netif->flags & NGKNET_NETIF_F_RCPU_ENCAP)? 1 : 0; #ifdef KNET_CB_DEBUG if (debug & 0x1) { @@ -230,8 +275,8 @@ strip_tag_rx_cb(struct sk_buff *skb) "\n%4u --------------------------------------------------------------------------------\n", rx_count); printk(KERN_INFO - "RX KNET callback: dev_no=%1d; dev_id=0x%04X; type_str=%4s; RCPU: %3s \n", - cbd->dev_no, cbd->dev_id, cbd->type_str, rcpu_mode ? "yes" : "no"); + "RX KNET callback: dev_no=%1d; dev_id=:%6s; type_str=%4s; RCPU: %3s \n", + cbd->dinfo->dev_no, cbd->dinfo->var_str, cbd->dinfo->type_str, rcpu_mode ? "yes" : "no"); printk(KERN_INFO " pkt_len=%4d; pmd_len=%2d; SKB len: %4d\n", cbd->pkt_len, cbd->pmd_len, skb->len); if (cbd->filt) { @@ -240,8 +285,8 @@ strip_tag_rx_cb(struct sk_buff *skb) } printk(KERN_INFO "Before SKB (%d bytes):\n", skb->len); dump_buffer(skb->data, skb->len); - printk("rx_cb for dev %d: id 0x%x, %s\n", cbd->dev_no, cbd->dev_id, cbd->type_str); - printk("netif user data: 0x%08x\n", *(uint32_t *)cbd->priv->user_data); + printk("rx_cb for dev %d: id %s, %s\n", cbd->dinfo->dev_no, cbd->dinfo->var_str, cbd->dinfo->type_str); + printk("netif user data: 0x%08x\n", *(uint32_t *)cbd->netif->user_data); show_pmd(cbd->pmd, cbd->pmd_len); if (rcpu_mode) { const int RCPU_header_len = PKT_HDR_SIZE + cbd->pmd_len; @@ -259,7 +304,9 @@ strip_tag_rx_cb(struct sk_buff *skb) if ((!rcpu_mode) && (cbd->filt)) { if (FILTER_TAG_ORIGINAL == cbd->filt->user_data[0]) { - tag_status = get_tag_status(cbd->dev_id, cbd->filt->user_data[1],(void *)cbd->pmd); + tag_status = get_tag_status(cbd->dinfo->type_str, + cbd->dinfo->var_str, + (void *)cbd->pmd); if (tag_status < 0) { strip_stats.skipped++; goto _strip_tag_rx_cb_exit; @@ -295,7 +342,7 @@ strip_tag_tx_cb(struct sk_buff *skb) struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); if (debug & 0x1) { - printk("tx_cb for dev %d: %s\n", cbd->dev_no, cbd->type_str); + printk("tx_cb for dev %d: %s\n", cbd->dinfo->dev_no, cbd->dinfo->type_str); } show_pmd(cbd->pmd, cbd->pmd_len); show_mac(cbd->pmd + cbd->pmd_len); @@ -304,11 +351,11 @@ strip_tag_tx_cb(struct sk_buff *skb) } static struct sk_buff * -ngknet_rx_cb(struct sk_buff *skb) +ngknet_rx_cb(struct net_device *dev, struct sk_buff *skb) { skb = strip_tag_rx_cb(skb); -#if IS_ENABLED(CONFIG_PSAMPLE) - skb = psample_rx_cb(skb); +#ifdef PSAMPLE_SUPPORT + skb = psample_rx_cb(dev, skb); #endif return skb; } @@ -324,7 +371,7 @@ static int ngknet_netif_create_cb(struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT retv = psample_netif_create_cb(dev); #endif return retv; @@ -334,7 +381,7 @@ static int ngknet_netif_destroy_cb(struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT retv = psample_netif_destroy_cb(dev); #endif return retv; @@ -387,7 +434,7 @@ ngknetcb_mmap(struct file *filp, struct vm_area_struct *vma) } static struct file_operations ngknetcb_fops = { - .owner = THIS_MODULE, + PROC_OWNER(THIS_MODULE) .open = ngknetcb_open, .read = seq_read, .write = ngknetcb_write, @@ -398,7 +445,9 @@ static struct file_operations ngknetcb_fops = { .mmap = ngknetcb_mmap, }; +/* Added this for PROC_CREATE */ static struct proc_ops ngknetcb_proc_ops = { + PROC_OWNER(THIS_MODULE) .proc_open = ngknetcb_open, .proc_read = seq_read, .proc_write = ngknetcb_write, @@ -431,7 +480,7 @@ ngknetcb_init_module(void) ngknet_rx_cb_register(ngknet_rx_cb); ngknet_tx_cb_register(ngknet_tx_cb); -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT psample_init(); #endif @@ -446,7 +495,7 @@ ngknetcb_exit_module(void) ngknet_netif_create_cb_unregister(ngknet_netif_create_cb); ngknet_netif_destroy_cb_unregister(ngknet_netif_destroy_cb); -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT psample_cleanup(); #endif diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c old mode 100644 new mode 100755 index 142357134ff1..bdd116434611 --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.c @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 Broadcom + * Copyright 2017-2022 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -44,6 +44,7 @@ #include #include #include "psample-cb.h" +#include "ngknet_main.h" #define PSAMPLE_CB_DBG #ifdef PSAMPLE_CB_DBG @@ -64,16 +65,24 @@ extern int debug; #define PSAMPLE_RATE_DFLT 1 #define PSAMPLE_SIZE_DFLT 128 static int psample_size = PSAMPLE_SIZE_DFLT; -MODULE_PARAM(psample_size, int, 0); +module_param(psample_size, int, 0); MODULE_PARM_DESC(psample_size, "psample pkt size (default 128 bytes)"); #define PSAMPLE_QLEN_DFLT 1024 static int psample_qlen = PSAMPLE_QLEN_DFLT; -MODULE_PARAM(psample_qlen, int, 0); +module_param(psample_qlen, int, 0); MODULE_PARM_DESC(psample_qlen, "psample queue length (default 1024 buffers)"); +#if !IS_ENABLED(CONFIG_PSAMPLE) +inline struct +psample_group *psample_group_get(struct net *net, u32 group_num) +{ + return NULL; +} +#endif + /* driver proc entry root */ static struct proc_dir_entry *psample_proc_root = NULL; static struct proc_dir_entry *knet_cb_proc_root = NULL; @@ -152,6 +161,8 @@ psample_netif_lookup_by_ifindex(int ifindex) return (NULL); } +static psample_netif_t* +psample_netif_lookup_by_port(int port) __attribute__ ((unused)); static psample_netif_t* psample_netif_lookup_by_port(int port) { @@ -172,50 +183,6 @@ psample_netif_lookup_by_port(int port) return (NULL); } -static int -psample_meta_sample_reason(uint8_t *pkt, void *pkt_meta) -{ - uint32_t *metadata = (uint32_t*)pkt_meta; - uint32_t reason = 0; - uint32_t reason_hi = 0; - uint32_t sample_rx_reason_mask = 0; - - if (metadata) { - /* Sample Pkt reason code (bcmRxReasonSampleSource) */ - switch(g_psample_info.dcb_type) { - case 36: /* TD3 */ - case 38: /* TH3 */ - reason_hi = *(metadata + 4); - reason = *(metadata + 5); - sample_rx_reason_mask = (1 << 3); - break; - case 32: /* TH1/TH2 */ - case 26: /* TD2 */ - case 23: /* HX4 */ - reason_hi = *(metadata + 2); - reason = *(metadata + 3); - sample_rx_reason_mask = (1 << 5); - break; - default: - break; - } - } - PSAMPLE_CB_DBG_PRINT("%s: DCB%d sample_rx_reason_mask: 0x%08x, reason: 0x%08x, reason_hi: 0x%08x\n", - __func__, g_psample_info.dcb_type, sample_rx_reason_mask, reason, reason_hi); - - /* Check if only sample reason code is set. - * If only sample reason code, then consume pkt. - * If other reason codes exist, then pkt should be - * passed through to Linux network stack. - */ - if ((reason & ~sample_rx_reason_mask) || reason_hi) { - return 0; /* multiple reasons set, pass through */ - } - - /* only sample rx reason set, consume pkt */ - return (PSAMPLE_PKT_HANDLED); -} - static int psample_meta_get(struct sk_buff *skb, psample_meta_t *sflow_meta) { @@ -224,18 +191,18 @@ psample_meta_get(struct sk_buff *skb, psample_meta_t *sflow_meta) int sample_size = PSAMPLE_SIZE_DFLT; psample_netif_t *psample_netif = NULL; const struct ngknet_callback_desc *cbd = NGKNET_SKB_CB(skb); - const struct ngknet_private *netif = cbd->priv; + ngknet_netif_t *netif = cbd->netif; memset(sflow_meta, 0, sizeof(psample_meta_t)); /* find src port */ - if ((psample_netif = psample_netif_lookup_by_ifindex(netif->net_dev->ifindex))) { + if ((psample_netif = psample_netif_lookup_by_ifindex(netif->id))) { src_ifindex = psample_netif->dev->ifindex; sample_rate = psample_netif->sample_rate; sample_size = psample_netif->sample_size; } else { g_psample_stats.pkts_d_meta_srcport++; PSAMPLE_CB_DBG_PRINT("%s: could not find psample netif for src dev %s (ifidx %d)\n", - __func__, netif->net_dev->name, netif->net_dev->ifindex); + __func__, netif->name, netif->id); } sflow_meta->src_ifindex = src_ifindex; @@ -251,7 +218,6 @@ psample_task(struct work_struct *work) unsigned long flags; struct list_head *list_ptr, *list_next; psample_pkt_t *pkt; - struct psample_metadata md = {0}; spin_lock_irqsave(&psample_work->lock, flags); list_for_each_safe(list_ptr, list_next, &psample_work->pkt_list) { @@ -263,18 +229,32 @@ psample_task(struct work_struct *work) /* send to psample */ if (pkt) { +#if ((IS_ENABLED(CONFIG_PSAMPLE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,13,0)) || \ + (defined PSAMPLE_MD_EXTENDED_ATTR && PSAMPLE_MD_EXTENDED_ATTR)) + struct psample_metadata md = {0}; + md.trunc_size = pkt->meta.trunc_size; + md.in_ifindex = pkt->meta.src_ifindex; + md.out_ifindex = pkt->meta.dst_ifindex; +#endif PSAMPLE_CB_DBG_PRINT("%s: group 0x%x, trunc_size %d, src_ifdx 0x%x, dst_ifdx 0x%x, sample_rate %d\n", __func__, pkt->group->group_num, pkt->meta.trunc_size, pkt->meta.src_ifindex, pkt->meta.dst_ifindex, pkt->meta.sample_rate); - md.trunc_size = pkt->meta.trunc_size; - md.in_ifindex = pkt->meta.src_ifindex; - md.out_ifindex = pkt->meta.dst_ifindex; +#if ((IS_ENABLED(CONFIG_PSAMPLE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,13,0)) || \ + (defined PSAMPLE_MD_EXTENDED_ATTR && PSAMPLE_MD_EXTENDED_ATTR)) psample_sample_packet(pkt->group, - pkt->skb, + pkt->skb, pkt->meta.sample_rate, &md); +#else + psample_sample_packet(pkt->group, + pkt->skb, + pkt->meta.trunc_size, + pkt->meta.src_ifindex, + pkt->meta.dst_ifindex, + pkt->meta.sample_rate); +#endif g_psample_stats.pkts_f_psample_mod++; dev_kfree_skb_any(pkt->skb); @@ -286,7 +266,7 @@ psample_task(struct work_struct *work) } struct sk_buff* -psample_rx_cb(struct sk_buff *skb) +psample_rx_cb(struct net_device *dev, struct sk_buff *skb) { struct psample_group *group; psample_meta_t meta; @@ -302,7 +282,7 @@ psample_rx_cb(struct sk_buff *skb) return (NULL); } cbd = NGKNET_SKB_CB(skb); - netif = cbd->priv; + netif = netdev_priv(dev); filt_src = cbd->filt; filt = netif->filt_cb; @@ -429,13 +409,6 @@ psample_rx_cb(struct sk_buff *skb) } PSAMPLE_FILTER_CB_PKT_HANDLED: - /* if sample reason only, consume pkt. else pass through */ - rv = psample_meta_sample_reason(skb->data, cbd->pmd); - if (PSAMPLE_PKT_HANDLED == rv) { - g_psample_stats.pkts_f_handled++; - dev_kfree_skb_any(skb); - return NULL; - } g_psample_stats.pkts_f_pass_through++; return skb; } @@ -464,22 +437,22 @@ psample_netif_create_cb(struct net_device *dev) spin_lock_irqsave(&g_psample_info.lock, flags); psample_netif->dev = dev; - psample_netif->id = netif->id; + psample_netif->id = netif->netif.id; /*Application has encoded the port in netif user data 0 & 1 */ - if (netif->type == NGKNET_NETIF_T_PORT) + if (netif->netif.type == NGKNET_NETIF_T_PORT) { - psample_netif->port = netif->user_data[0]; - psample_netif->port |= netif->user_data[1] << 8; + psample_netif->port = netif->netif.user_data[0]; + psample_netif->port |= netif->netif.user_data[1] << 8; } - psample_netif->vlan = netif->vlan; + psample_netif->vlan = netif->netif.vlan; psample_netif->sample_rate = PSAMPLE_RATE_DFLT; psample_netif->sample_size = PSAMPLE_SIZE_DFLT; - + printk("\r\n Type %d vlan %d", netif->netif.type, psample_netif->vlan); /* insert netif sorted by ID similar to bkn_knet_netif_create() */ found = 0; list_for_each(list, &g_psample_info.netif_list) { lpsample_netif = (psample_netif_t*)list; - if (netif->id < lpsample_netif->id) { + if (netif->netif.id < lpsample_netif->id) { found = 1; g_psample_info.netif_count++; break; @@ -519,7 +492,7 @@ psample_netif_destroy_cb(struct net_device *dev) list_for_each(list, &g_psample_info.netif_list) { psample_netif = (psample_netif_t*)list; - if (netif->id == psample_netif->id) { + if (netif->netif.id == psample_netif->id) { found = 1; list_del(&psample_netif->list); PSAMPLE_CB_DBG_PRINT("%s: removing psample netif '%s'\n", __func__, dev->name); @@ -532,7 +505,6 @@ psample_netif_destroy_cb(struct net_device *dev) spin_unlock_irqrestore(&g_psample_info.lock, flags); if (!found) { - printk("%s: netif ID %d not found!\n", __func__, netif->id); return (-1); } return (0); @@ -631,11 +603,12 @@ psample_proc_rate_write(struct file *file, const char *buf, } struct proc_ops psample_proc_rate_file_ops = { - proc_open: psample_proc_rate_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_rate_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_rate_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_rate_write, + .proc_release = single_release, }; /* @@ -729,11 +702,12 @@ psample_proc_size_write(struct file *file, const char *buf, } struct proc_ops psample_proc_size_file_ops = { - proc_open: psample_proc_size_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_size_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_size_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_size_write, + .proc_release = single_release, }; /* @@ -769,11 +743,12 @@ psample_proc_map_open(struct inode * inode, struct file * file) } struct proc_ops psample_proc_map_file_ops = { - proc_open: psample_proc_map_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: NULL, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_map_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = NULL, + .proc_release = single_release, }; /* @@ -834,11 +809,12 @@ psample_proc_debug_write(struct file *file, const char *buf, } struct proc_ops psample_proc_debug_file_ops = { - proc_open: psample_proc_debug_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_debug_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_debug_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_debug_write, + .proc_release = single_release, }; static int @@ -895,11 +871,12 @@ psample_proc_stats_write(struct file *file, const char *buf, return count; } struct proc_ops psample_proc_stats_file_ops = { - proc_open: psample_proc_stats_open, - proc_read: seq_read, - proc_lseek: seq_lseek, - proc_write: psample_proc_stats_write, - proc_release: single_release, + PROC_OWNER(THIS_MODULE) + .proc_open = psample_proc_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = psample_proc_stats_write, + .proc_release = single_release, }; int psample_cleanup(void) diff --git a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h old mode 100644 new mode 100755 index e2922a36bca4..d89c5f4178bb --- a/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h +++ b/platform/broadcom/saibcm-modules/sdklt/linux/knetcb/psample-cb.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 Broadcom + * Copyright 2022 Broadcom * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2, as @@ -24,6 +24,7 @@ #include #include +//#define PSAMPLE_SUPPORT 1 // TODO: MLI@BRCM - Add this as part of conditional in Makefile #define PSAMPLE_CB_NAME "psample" extern int @@ -33,14 +34,14 @@ extern int psample_cleanup(void); extern struct sk_buff* -psample_rx_cb(struct sk_buff *skb); +psample_rx_cb(struct net_device *dev, struct sk_buff *skb); /* psample data per interface */ typedef struct { struct list_head list; struct net_device *dev; uint16_t id; - uint8_t port; + uint16_t port; uint16_t vlan; uint16_t qnum; uint32_t sample_rate; diff --git a/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk b/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk index 803154e54c68..f565514a1123 100644 --- a/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk +++ b/platform/broadcom/saibcm-modules/sdklt/make/lkm.mk @@ -1,5 +1,5 @@ # -# $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. +# $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. # The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. # # This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h b/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h index a51dc11392b2..702e6317f5f0 100644 --- a/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h +++ b/platform/broadcom/saibcm-modules/sdklt/shr/include/shr/shr_error.h @@ -4,7 +4,7 @@ * */ /* - * $Copyright: Copyright 2018-2021 Broadcom. All rights reserved. + * $Copyright: Copyright 2018-2022 Broadcom. All rights reserved. * The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries. * * This program is free software; you can redistribute it and/or diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h index c4d31579bfdf..fa8849eb2bf7 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux-bde.h @@ -270,6 +270,9 @@ extern int lkbde_cpu_read(int d, uint32 addr, uint32 *buf); extern int lkbde_cpu_pci_register(int d); #endif +extern int lkbde_intr_cb_register(int d, + int (*intr_pending)(void*), + void *intr_pending_data); /* * This flag must be OR'ed onto the device number when calling * interrupt_connect/disconnect and irq_mask_set functions from diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile index bc7b6fef5f15..1c3e94815c4e 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile @@ -42,8 +42,6 @@ include $(SDK)/make/Make.config LIBS = $(LIBDIR)/libkern.a -BDE = linux-kernel-bde.o - # need to add vpath sources VPATH = ../shared @@ -58,8 +56,14 @@ CFLAGS += -I../../shared/include LHDRS += mpool.h LOBJS = $(addsuffix .o, $(basename $(LSRCS))) BOBJS = $(addprefix $(BLDDIR)/,$(LOBJS)) +# +# For 'NO_PRECOMPILED_MODULE', the first kernel compilation is done +# in systems/bde/linux/kernel (and not in systems/bde/linux/kernel/kernel_module, +# which is not even created). +# All the definitions above are for the first cycle of module compilation +# +PWD := $(shell pwd) -ifneq ($(kernel_version),2_4) KERNEL_MODULE_DIR = kernel_module THIS_MOD_NAME := linux-kernel-bde @@ -67,23 +71,63 @@ MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko build: $(KMODULE) -else -MODULE = $(LIBDIR)/linux-kernel-bde.o -build: module -endif +ifeq (1,$(NO_PRECOMPILED_MODULE)) +# { +# +# These are the objects which need to be compiled, in the kernel, to +# created the module object file. +# +SRCS_COMPOSING = linux_shbde.c linux_dma.c ../shared/mpool.o $(THIS_MOD_NAME).c ../../shared/shbde_pci.o ../../shared/shbde_iproc.o ../../shared/shbde_mdio.o ../../../linux/kernel/modules/shared/gmodule.o +OBJECTS_COMPOSING = "linux_shbde.o linux_dma.o mpool.o $(THIS_MOD_NAME)-file.o shbde_pci.o shbde_iproc.o shbde_mdio.o gmodule.o" -module: $(MODULE) +module: $(KMODULE) +# +# Note that for NO_PRECOMPILED_MODULE, the subdirectory 'systems/bde/linux/kernel/kernel_module' +# is not created and all action is done in systems/bde/linux/kernel +# +$(KMODULE): $(SRCS_COMPOSING) + rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) + rm -f $(BLDDIR)/*.c + rm -f $(BLDDIR)/*.o + rm -f $(BLDDIR)/*.ko + cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/Makefile + # + # Here we copy all source files, which are required for the + # compilation of the module, into one directory. It seems that + # specifying path for 'remote' files is not acceptable for + # the module-creation mechanism in the kernel. + # + cp ./*.c $(BLDDIR)/ + cp ./*.h $(BLDDIR)/ + cp ../shared/*.c $(BLDDIR)/ + cp ../../shared/*.c $(BLDDIR)/ + cp ../../../linux/kernel/modules/shared/*.c $(BLDDIR)/ + # + # We change here the name of the 'base' file since, it seems, the module-creation + # mechanism does not add symbols when the name of one of the files is the same as + # the name of the module itself. + # + mv $(BLDDIR)/$(THIS_MOD_NAME).c $(BLDDIR)/$(THIS_MOD_NAME)-file.c + MOD_OBJS=$(OBJECTS_COMPOSING) MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR) $(THIS_MOD_NAME).ko LOC_BLDDIR=$(BLDDIR) LOC_SRCDIR=$(PWD) +# } +else +# { +module: $(MODULE) +# +# This is for the compilation of the 'precompiled' object. We keep it +# here for compatibility. +# $(MODULE): $(BLDDIR)/.tree $(BOBJS) kernel_libs mkdir -p $(@D) $(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@ -ifneq ($(kernel_version),2_4) $(KMODULE): $(MODULE) rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR) cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko +# } endif kernel_libs: @@ -100,6 +144,4 @@ clean:: distclean:: -ifneq ($(kernel_version),2_4) .PHONY: build kernel_libs -endif diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c index be5b6282396d..0fc8b63437b7 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux-kernel-bde.c @@ -37,10 +37,14 @@ /* * Prevent gcc from using a compiler builtin memcpy even if using -fno-builtin or * -fno-builtin-memcpy. - * Use __memcpy kernel function in x86 Linux instead. + * Use __inline_memcpy or __memcpy kernel function in x86 Linux instead. */ #undef MEMCPY +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0)) +#define MEMCPY __inline_memcpy +#else #define MEMCPY __memcpy +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(5.0.0)) */ #endif /* (defined(__GNUC__) && (__GNUC__ >= 8)) */ #endif /* CONFIG_X86_64 */ @@ -166,6 +170,20 @@ MODULE_PARM_DESC(spifreq, #endif + +/* Periodic timer to prevent stuck interrupt */ +static int isrtickms = 1000; +LKM_MOD_PARAM(isrtickms, "i", int, (S_IRUGO | S_IWUSR)); +MODULE_PARM_DESC(isrtickms, +"Periodic ISR tick in milliseconds."); + +/* Debug purpose to simulate stuck interrupts */ +static int dma_lock = 0; +LKM_MOD_PARAM(dma_lock, "i", int, (S_IRUGO | S_IWUSR)); +MODULE_PARM_DESC(dma_lock, +"Simulation of stuck interrupts."); + +/* Compatibility */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) #define _ISR_RET irqreturn_t #else @@ -300,7 +318,7 @@ typedef struct bde_ctrl_s { /* Secondary mapped base address */ sal_vaddr_t alt_base_addr; - + /* BDE device description */ ibde_dev_t bde_dev; @@ -330,6 +348,18 @@ typedef struct bde_ctrl_s { /* inst_id */ uint32 inst_id; /* The instance ID of the instance controlling the device */ + + /* + * Callback function from user BDE to determine if there are pending interrupts + * currently. + */ + int (*intr_pending)(void *); + void *intr_pending_data; + uint32 interrupts; /* Current number of interrupts */ + uint32 prev_interrupts; /* Number of interrupts in previous ISR tick */ + uint32 stuck_interrupts; /* Number of stuck interrupts detected */ + uint32 no_intr_isr_ticks; /* Number of ISR ticks without interrupt occurred */ + struct timer_list isr_tick; /* Timer tick to prevent stuck interrupt */ } bde_ctrl_t; static bde_ctrl_t _devices[LINUX_BDE_MAX_DEVICES]; @@ -416,7 +446,7 @@ static void *cpu_address = NULL; #define BCM53000PCIE_DEFAULT_STATUS 0x00100146 /* 16bit wide register. offset 14, 14*2 = 0x1c */ -#define BCM53000PCIE_SPROM_OFFSET 0x1c +#define BCM53000PCIE_SPROM_OFFSET 0x1c /* bit 15:13 spromData.MaxPayloadSize. 1: 256 bytes */ #define BCM53000PCIE_SPROM_MAX_PAYLOAD_MASK 0xe000 #define BCM53000PCIE_SPROM_MAX_PAYLOAD_256B (1 << 13) @@ -604,15 +634,16 @@ _eb_device_create(resource_size_t paddr, int irq, int rd_hw, int wr_hw) static int sand_device_create(void) { +#ifndef __DUNE_LINUX_BCM_CPU_PCIE__ bde_ctrl_t* ctrl; - ctrl = _devices; /* FIX_ME: on petra, take first device */ + ctrl = _devices; /* on petra, take first device */ + -#ifndef __DUNE_LINUX_BCM_CPU_PCIE__ ctrl->dev_type |= BDE_PCI_DEV_TYPE | BDE_SWITCH_DEV_TYPE; ctrl->pci_device = NULL; /* No PCI bus */ - /* Map in the device */ /* FIX_ME: not realy map anything */ + /* Map in the device */ /* not realy map anything */ ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(0x40000000, 0x100000); ctrl->iowin[0].addr = 0x40000000; ctrl->iowin[0].size = 0x100000; @@ -632,15 +663,6 @@ sand_device_create(void) cpu_address = ioremap(0xe0000000, 0x100000); #endif - if (ctrl->bde_dev.device == PCP_PCI_DEVICE_ID) { - ctrl->bde_dev.device = GEDI_DEVICE_ID; - ctrl->bde_dev.rev = GEDI_REV_ID; - } - - if (ctrl->bde_dev.device == ACP_PCI_DEVICE_ID) { - ctrl->dev_type |= BDE_PCI_DEV_TYPE | BDE_SWITCH_DEV_TYPE; - } - #ifndef __DUNE_LINUX_BCM_CPU_PCIE__ _bde_add_device(); #endif @@ -1263,13 +1285,13 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56844_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56845_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56846_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM56847_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56847_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56549_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56053_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56838_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56831_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM56835_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM56849_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56835_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56849_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56742_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56743_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56744_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1358,7 +1380,7 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56853_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56854_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56855_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { BROADCOM_VENDOR_ID, BCM56834_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56834_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56750_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56830_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM55440_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1450,7 +1472,7 @@ static const struct pci_device_id _id_table[] = { { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9656, PCI_ANY_ID, PCI_ANY_ID }, { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9056, PCI_ANY_ID, PCI_ANY_ID }, { BCM53000_VENDOR_ID, BCM53000PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, -#ifdef BCM_PETRA_SUPPORT +#ifdef BCM_PETRA_SUPPORT { BROADCOM_VENDOR_ID, BCM88350_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88351_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88450_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1458,8 +1480,6 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM88550_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88551_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88552_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { PCP_PCI_VENDOR_ID, PCP_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, - { ACP_PCI_VENDOR_ID, ACP_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88660_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88670_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88671_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1653,6 +1673,7 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8884D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8884E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8884F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88830_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88831_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88832_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88833_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1668,6 +1689,10 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8883D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8883E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8883F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, +#ifdef BCM_DNX3_SUPPORT + { BROADCOM_VENDOR_ID, BCM88860_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88870_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, +#endif #endif /* BCM_DNX_SUPPORT */ #ifdef BCM_DFE_SUPPORT { BROADCOM_VENDOR_ID, BCM88770_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1702,6 +1727,40 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM8879C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8879D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8879F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, +#ifdef BCM_DNXF3_SUPPORT + { BROADCOM_VENDOR_ID, BCM88910_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88911_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88912_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88913_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88914_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88915_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88916_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88917_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88918_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88919_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8891F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88920_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88921_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88922_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88923_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88924_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88925_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88926_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88927_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88928_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88929_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892C_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892D_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8892F_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, +#endif #endif { BROADCOM_VENDOR_ID, BCM56860_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56861_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1725,6 +1784,7 @@ static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56575_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56175_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56176_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM53642_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56370_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56371_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56372_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1778,7 +1838,7 @@ pci_do_bus_find(struct pci_bus* bus, int rc, int vendor, int device) func = dev->devfn & 0x7; if (dev->vendor == vendor && dev->device == device && rc == func) { if (debug >= 1) { - gprintk("pci_do_bus_find: dev->vendor = 0x%x, dev->device = 0x%x on rc(%d)\n", + gprintk("pci_do_bus_find: dev->vendor = 0x%x, dev->device = 0x%x on rc(%d)\n", dev->vendor, dev->device, rc); } return sub_bus; @@ -1948,9 +2008,9 @@ p2p_bridge(void) uint32 tmp, maxpayld, device_bmp=0, mask; unsigned long addr; uint16 tmp16, tmp161; - int i, bus0 = -1, bus1 = -1, port; + int i, bus0 = -1, bus1 = -1, port; struct pci_dev *pcie0, *pcie1; - + pcie0 = dev; bus0 = dev->bus->number; if ((pcie1 = PCI_FIND_DEV(BCM53000_VENDOR_ID, BCM53000PCIE_DEVICE_ID, pcie0)) != NULL) { @@ -1969,7 +2029,7 @@ p2p_bridge(void) device_bmp |= 1 << 1; } } - } + } /* configure the PCIE cap: Max payload size: 256, Max Read * Request size: 256, disabling relax ordering. @@ -1979,8 +2039,8 @@ p2p_bridge(void) i = 0; while(device_bmp) { if (device_bmp & (1 << i)){ - port = i ; - pci_read_config_dword(BCM53000PCIE_DEV(port), + port = i ; + pci_read_config_dword(BCM53000PCIE_DEV(port), BCM53000PCIE_DEV_CAP_REG, &tmp); maxpayld = (tmp & BCM53000PCIE_MAX_PAYLOAD_MASK); if (debug >= 1) { @@ -1991,44 +2051,44 @@ p2p_bridge(void) if (maxpayld != BCM53000PCIE_CAP_MAX_PAYLOAD_256B) { addr = BCM53000PCIE_BASE(port); addr |= (BCM53000PCIE_SROM_SPACE | BCM53000PCIE_SPROM_OFFSET); - tmp16 = *((uint16 *)addr); + tmp16 = *((uint16 *)addr); if (debug >= 1){ gprintk("addr %lx spromData.MaxPayloadSize: 0x%x\n", addr, tmp16); } mask = BCM53000PCIE_SPROM_MAX_PAYLOAD_MASK; if ((tmp16 & mask) != BCM53000PCIE_SPROM_MAX_PAYLOAD_256B) { tmp161 = (tmp16 & ~mask) | BCM53000PCIE_SPROM_MAX_PAYLOAD_256B; - *((uint16 *)addr) = tmp161; + *((uint16 *)addr) = tmp161; if (debug >= 1) { - tmp16 = 0; - tmp16 = *((uint16 *)addr); + tmp16 = 0; + tmp16 = *((uint16 *)addr); gprintk("Enable spromData.MaxPayloadSize to 1 (256 bytes): " "0x%x (%s w/ 0x%x)\n", tmp161, - ((tmp16 & mask) == BCM53000PCIE_SPROM_MAX_PAYLOAD_256B) ? + ((tmp16 & mask) == BCM53000PCIE_SPROM_MAX_PAYLOAD_256B) ? "Success":"Fail", tmp16); } - } - pci_read_config_dword(BCM53000PCIE_DEV(port), - BCM53000PCIE_DEV_CAP_REG, &tmp); + } + pci_read_config_dword(BCM53000PCIE_DEV(port), + BCM53000PCIE_DEV_CAP_REG, &tmp); if (debug >= 1){ - gprintk("DevCap (@%x): now is 0x%x\n\n", - BCM53000PCIE_DEV_CAP_REG, tmp); + gprintk("DevCap (@%x): now is 0x%x\n\n", + BCM53000PCIE_DEV_CAP_REG, tmp); } - } + } addr = BCM53000PCIE_BASE(port); addr |= (BCM53000PCIE_FUNC0_COFIG_SPACE | BCM53000PCIE_DEV_CTRL_REG); - tmp16 = *((uint16 *)addr); + tmp16 = *((uint16 *)addr); if (debug >= 1) { - gprintk("DevControl (@%x): 0x%x\n", BCM53000PCIE_DEV_CTRL_REG, tmp16); + gprintk("DevControl (@%x): 0x%x\n", BCM53000PCIE_DEV_CTRL_REG, tmp16); } - if (!(tmp16 & MAX_PAYLOAD_256B) || !(tmp16 & MAX_READ_REQ_256B)) { - tmp161 = tmp16 | MAX_PAYLOAD_256B | MAX_READ_REQ_256B; - *((uint16 *)addr) = tmp161; + if (!(tmp16 & MAX_PAYLOAD_256B) || !(tmp16 & MAX_READ_REQ_256B)) { + tmp161 = tmp16 | MAX_PAYLOAD_256B | MAX_READ_REQ_256B; + *((uint16 *)addr) = tmp161; if (debug >= 1) { - tmp16 = 0; - tmp16 = *((uint16 *)addr); + tmp16 = 0; + tmp16 = *((uint16 *)addr); gprintk("addr %lx Enable DevControl MaxPayloadSize to 1 (256 bytes): " "0x%x (%s w/ 0x%x)\n", addr, tmp161, (tmp16 & MAX_PAYLOAD_256B) ? "Success":"Fail", @@ -2037,22 +2097,22 @@ p2p_bridge(void) "0x%x (%s w/ 0x%x)\n\n", tmp161, (tmp16 & MAX_READ_REQ_256B) ? "Success":"Fail", tmp16); - } - } + } + } device_bmp &= ~(1 << i); } i++; } } - /* + /* * Configure max payload to 512 on all ports in the PLX8608/PLX8617. - * The device supports 128, 512, and 1024 max payload sizes. + * The device supports 128, 512, and 1024 max payload sizes. */ dev = NULL; while ((dev = PCI_FIND_DEV(PCI_VENDOR_ID_PLX, PCI_ANY_ID, dev)) != NULL) { if ((dev->device == PLX_PEX8608_DEV_ID) || - (dev->device == PLX_PEX8617_DEV_ID)) { + (dev->device == PLX_PEX8617_DEV_ID)) { uint16 ctrl_reg; pci_read_config_word(dev, PLX_PEX86XX_DEV_CTRL_REG, &ctrl_reg); ctrl_reg = (ctrl_reg & ~(7<<5)) | MAX_PAYLOAD_512B; @@ -2072,7 +2132,7 @@ p2p_bridge(void) #define PLX_LAS0_PCIBAR2 2 /* Local Address Space 0 (PCIBAR2) */ #define PLX_LAS1_PCIBAR3 3 /* Local Address Space 1 (PCIBAR3) */ -STATIC int +STATIC int _plx_las_bar_get(struct pci_dev *dev) { void *local_config_addr; @@ -2081,8 +2141,8 @@ _plx_las_bar_get(struct pci_dev *dev) local_config_addr = ioremap(pci_resource_start(dev, PLX_MMAP_PCIBAR0), pci_resource_len(dev, PLX_MMAP_PCIBAR0)); if (local_config_addr) { - uint32 las_remap_reg; - /* + uint32 las_remap_reg; + /* * Make sure LAS0BA or LAS1BA is enabled before returning * BAR that will be used to access the Local Bus */ @@ -2094,7 +2154,7 @@ _plx_las_bar_get(struct pci_dev *dev) if (las_remap_reg & PLX_LAS_EN) { bar = PLX_LAS1_PCIBAR3; } - } + } } iounmap(local_config_addr); return bar; @@ -2117,7 +2177,7 @@ _shbde_log_func(int level, const char *str, int param) * Parameters: * dev - Linux PCI device structure * Returns: - * >= 0 : dev is ever probed + * >= 0 : dev is ever probed * reutrn value is the index point to the _devices[] * -1 : dev is not probed before. */ @@ -2178,16 +2238,16 @@ _pci_msix_table_size(struct pci_dev *dev) if (entries != NULL) { nr_entries = pci_enable_msix(dev, entries, PCI_MSIX_FLAGS_QSIZE); - if (nr_entries < 0) { - nr_entries = 0; - } - pci_disable_msix(dev); - kfree(entries); + pci_disable_msix(dev); + kfree(entries); } } #else nr_entries = pci_msix_vec_count(dev); #endif + if (nr_entries < 0) { + nr_entries = 0; + } #endif return nr_entries; @@ -2325,7 +2385,7 @@ config_pci_intr_type(struct pci_dev *dev, bde_ctrl_t *ctrl, int iproc) /* check for support MSIX vector */ ret = _pci_msix_table_size(ctrl->pci_device); if (ret == 0) { - gprintk("%s: Zero MSIX table size\n", __func__); + gprintk("%s: Zero MSIX table size, using MSI.\n", __func__); ctrl->use_msi = PCI_USE_INT_MSI; } } @@ -2377,7 +2437,7 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) if (debug >= 4) {gprintk("probing: vendor_id=0x%x, device_id=0x%x\n", dev->vendor, dev->device);} if (nodevices == 1) { - return 0; + return 0; } /* Initialize Linux hardware abstraction for shared BDE functions */ @@ -2400,10 +2460,10 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) if ((ctrl->dev_type & mask) == mask) { return 0; } - } + } } #endif /* IPROC_CMICD */ - + /* * Note that a few supported devices have a non-Broadcom PCI vendor ID, * but since none of their associated PCI device IDs collide with the @@ -2720,17 +2780,7 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) ctrl->bde_dev.device = dev->device; paddr = pci_resource_start(dev, baroff); - switch (dev->device) { -#if defined(BCM_PETRA_SUPPORT) && defined(__DUNE_LINUX_BCM_CPU_PCIE__) - case GEDI_DEVICE_ID: - case PCP_PCI_DEVICE_ID: - bar_len = 0x1000000; - break; -#endif - default: - bar_len = pci_resource_len(dev, baroff); - break; - } + bar_len = pci_resource_len(dev, baroff); ctrl->bde_dev.base_address = (sal_vaddr_t)ioremap(paddr, bar_len); ctrl->iowin[0].addr = paddr; @@ -2864,7 +2914,7 @@ _pci_remove(struct pci_dev* dev) bde_ctrl_t *ctrl; if (nodevices == 1) { - return; + return; } #if defined(BCM_DFE_SUPPORT) @@ -3296,6 +3346,7 @@ _pprint(struct seq_file *m) pprintf(m, "Module parameters:\n"); pprintf(m, "\tmaxpayload=%d\n", maxpayload); pprintf(m, "\tusemsi=%d\n", usemsi); + pprintf(m, "\tisrtickms=%d\n", isrtickms); _dma_pprint(m); @@ -3374,6 +3425,10 @@ _pprint(struct seq_file *m) ctrl->inst_id < LINUX_BDE_MAX_DEVICES ? "":"(Illegal)"); } } + pprintf(m, "\t\tinterrupts:prev:stuck %d:%d:%d\n", + ctrl->interrupts, + ctrl->prev_interrupts, + ctrl->stuck_interrupts); } return 0; } @@ -3648,20 +3703,79 @@ _write(int d, uint32_t addr, uint32_t data) } +static void +_run_isrs(bde_ctrl_t *ctrl) +{ + if (ctrl->isr) { + ctrl->isr(ctrl->isr_data); + } + + if (ctrl->isr2) { + ctrl->isr2(ctrl->isr2_data); + } +} + static _ISR_RET _isr(_ISR_PARAMS(irq, dev_id, iregs)) { bde_ctrl_t *ctrl = (bde_ctrl_t *) dev_id; - if (ctrl && ctrl->isr) { - ctrl->isr(ctrl->isr_data); + if (dma_lock) { + return IRQ_HANDLED; } - if (ctrl && ctrl->isr2) { - ctrl->isr2(ctrl->isr2_data); + + if (ctrl) { + _run_isrs(ctrl); + ctrl->interrupts++; } + return IRQ_HANDLED; } +static void +lkbde_isrtick_func(bde_ctrl_t *ctrl) +{ + unsigned long flags; + + spin_lock_irqsave(&ctrl->lock, flags); + + if (ctrl->prev_interrupts == ctrl->interrupts) { + if (ctrl->intr_pending(ctrl->intr_pending_data)) { + if (++ctrl->no_intr_isr_ticks >= 2) { + /* Run interrupt handlers if there are pending interrupts. */ + spin_unlock_irqrestore(&ctrl->lock, flags); + _run_isrs(ctrl); + spin_lock_irqsave(&ctrl->lock, flags); + ctrl->stuck_interrupts++; + ctrl->no_intr_isr_ticks = 0; + } + } + } else { + ctrl->no_intr_isr_ticks = 0; + ctrl->prev_interrupts = ctrl->interrupts; + } + + ctrl->isr_tick.expires = jiffies + msecs_to_jiffies(isrtickms); + spin_unlock_irqrestore(&ctrl->lock, flags); + add_timer(&ctrl->isr_tick); +} + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)) +static void +lkbde_isrtick(unsigned long context) +{ + bde_ctrl_t *ctrl = (bde_ctrl_t *)context; + return lkbde_isrtick_func(ctrl); +} +#else +static void +lkbde_isrtick(struct timer_list *t) +{ + bde_ctrl_t *ctrl = from_timer(ctrl, t, isr_tick); + return lkbde_isrtick_func(ctrl); +} +#endif + static int _interrupt_connect(int d, void (*isr)(void *), @@ -3791,6 +3905,20 @@ _interrupt_connect(int d, } } } + + if ((ctrl->use_msi >= PCI_USE_INT_MSI) && ctrl->intr_pending) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)) + init_timer(&ctrl->isr_tick); + ctrl->isr_tick.data = (unsigned long)ctrl; + ctrl->isr_tick.function = lkbde_isrtick; +#else + timer_setup(&ctrl->isr_tick, lkbde_isrtick, 0); +#endif + + ctrl->isr_tick.expires = jiffies + msecs_to_jiffies(isrtickms); + add_timer(&ctrl->isr_tick); + } + return 0; err_disable_msi: @@ -3847,7 +3975,7 @@ _interrupt_disconnect(int d) ctrl->fmask = 0; if (ctrl->isr) { /* Primary handler still active */ - SYNC_IRQ(ctrl->iLine); + SYNC_IRQ(ctrl->iLine); return 0; } } else { @@ -3858,7 +3986,7 @@ _interrupt_disconnect(int d) ctrl->isr_data = NULL; if (ctrl->isr2) { /* Secondary handler still active */ - SYNC_IRQ(ctrl->iLine); + SYNC_IRQ(ctrl->iLine); return 0; } } @@ -3900,6 +4028,9 @@ _interrupt_disconnect(int d) #ifdef CONFIG_PCI_MSI if (ctrl->use_msi >= PCI_USE_INT_MSI) { _msi_disconnect(ctrl); + if (ctrl->intr_pending) { + del_timer_sync(&ctrl->isr_tick); + } } #endif } @@ -3932,7 +4063,7 @@ _iproc_ihost_write(int d, uint32_t addr, uint32_t data) writel(data, mapaddr); iounmap(mapaddr); return 0; -} +} static uint32_t _iproc_read(int d, uint32_t addr) @@ -4083,7 +4214,7 @@ lkbde_cpu_pci_register(int d) gprintk("Cannot enable pci device : vendor_id = %x, device_id = %x\n", ctrl->pci_device->vendor, ctrl->pci_device->device); } - + /* Add PCI_COMMAND_MEMORY and PCI_COMMAND_MASTER */ pci_read_config_word(ctrl->pci_device, PCI_COMMAND, &cmd); if (!(cmd & PCI_COMMAND_MEMORY) || !(cmd & PCI_COMMAND_MASTER)) { @@ -4092,14 +4223,6 @@ lkbde_cpu_pci_register(int d) } switch (ctrl->bde_dev.device) { - case GEDI_DEVICE_ID: - /* Fix bar 0 address */ /* FIXME: write full phy address */ - pci_write_config_byte(ctrl->pci_device, 0x13, 0x60); - - /* Fix Max payload size */ - pci_write_config_byte(ctrl->pci_device, 0x88, 0x2f); - pci_write_config_byte(ctrl->pci_device, 0x89, 0x10); - break; case BCM88770_DEVICE_ID: case BCM88773_DEVICE_ID: case BCM88774_DEVICE_ID: @@ -4110,10 +4233,9 @@ lkbde_cpu_pci_register(int d) case BCM88953_DEVICE_ID: case BCM88954_DEVICE_ID: case BCM88955_DEVICE_ID: - case BCM88956_DEVICE_ID: + case BCM88956_DEVICE_ID: case BCM88772_DEVICE_ID: case BCM88952_DEVICE_ID: - case ACP_PCI_DEVICE_ID: case BCM88670_DEVICE_ID: case BCM88671_DEVICE_ID: @@ -4165,12 +4287,12 @@ lkbde_cpu_pci_register(int d) case BCM88278_DEVICE_ID: case BCM88350_DEVICE_ID: case BCM88351_DEVICE_ID: - case BCM88450_DEVICE_ID: + case BCM88450_DEVICE_ID: case BCM88451_DEVICE_ID: case BCM88550_DEVICE_ID: case BCM88551_DEVICE_ID: case BCM88552_DEVICE_ID: - case BCM88660_DEVICE_ID: + case BCM88660_DEVICE_ID: case BCM88360_DEVICE_ID: case BCM88361_DEVICE_ID: case BCM88363_DEVICE_ID: @@ -4180,7 +4302,7 @@ lkbde_cpu_pci_register(int d) case BCM88561_DEVICE_ID: case BCM88562_DEVICE_ID: case BCM88661_DEVICE_ID: - case BCM88664_DEVICE_ID: + case BCM88664_DEVICE_ID: /* Fix bar 0 address */ /* FIXME: write full phy address */ pci_write_config_byte(ctrl->pci_device, 0x12, 0x10); pci_write_config_byte(ctrl->pci_device, 0x13, 0x60); @@ -4207,9 +4329,17 @@ lkbde_cpu_pci_register(int d) case Q2U_DEVICE_ID: case Q2N_DEVICE_ID: case J2P_DEVICE_ID: + case J2X_DEVICE_ID: +#ifdef BCM_DNX3_SUPPORT + case JERICHO3_DEVICE_ID: + case Q4_DEVICE_ID: +#endif #endif #ifdef BCM_DNXF_SUPPORT case BCM88790_DEVICE_ID: +#ifdef BCM_DNXF3_SUPPORT + case BCM88920_DEVICE_ID: +#endif #endif /* * For DMA transactions - set Max_Payload_Size and @@ -4242,8 +4372,8 @@ lkbde_cpu_pci_register(int d) return 0; } -/* - * Export Low level access function - currently for PCP DMA Kernel module. +/* + * Export Low level access function - currently for PCP DMA Kernel module. */ int lkbde_mem_write(int d, uint32 addr, uint32 *buf) @@ -4253,7 +4383,7 @@ lkbde_mem_write(int d, uint32 addr, uint32 *buf) if (!VALID_DEVICE(d)) return -1; ctrl = &_devices[d]; - + full_addr = (void *)ctrl->bde_dev.base_address + addr; *((uint32_t*)full_addr) = *buf; return 0; @@ -4588,7 +4718,7 @@ lkbde_irq_mask_set(int d, uint32_t addr, uint32_t mask, uint32_t fmask) /* * When a secondary interrupt handler is installed, this function - * is used to avoid activating the user mode interrupt handler + * is used to avoid activating the user mode interrupt handler * thread if all pending interrupts are handled in kernel space. * * The mask returned is the mask of all interrupts, it can be used @@ -4618,7 +4748,7 @@ lkbde_irq_mask_get(int d, uint32_t *mask, uint32_t *fmask) *fmask = ctrl->fmask; *mask = ctrl->imask | ctrl->imask2; - + return 0; } @@ -4651,6 +4781,33 @@ linux_bde_device_bitmap_t* lkbde_get_inst_devs(uint32 inst_id) return &_instance_info[inst_id].devices; } +/* + * Register a callback function to retrieve interrupt pending status from + * the user BDE. + */ +int +lkbde_intr_cb_register(int d, + int (*intr_pending)(void *), + void *intr_pending_data) +{ + bde_ctrl_t *ctrl; + + if (!VALID_DEVICE(d)) { + gprintk("lkbde_intr_cb_register: Invalid device index %d\n", d); + return -1; + } + + if (debug >= 1) { + gprintk("lkbde_intr_cb_register d %d\n", d); + } + + ctrl = _devices + d; + ctrl->intr_pending_data = intr_pending_data; + ctrl->intr_pending = intr_pending; + + return 0; +} + /* * Export functions */ @@ -4675,3 +4832,4 @@ LKM_EXPORT_SYM(lkbde_cpu_pci_register); #endif LKM_EXPORT_SYM(lkbde_is_dev_managed_by_instance); LKM_EXPORT_SYM(lkbde_get_inst_devs); +LKM_EXPORT_SYM(lkbde_intr_cb_register); diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c index be46282e7f8d..bdb8d121b8c3 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_dma.c @@ -285,7 +285,7 @@ static void __iomem *_dma_vbase = NULL; /* CPU physical address of the DMA buffer pool, used for mmap */ static phys_addr_t _cpu_pbase = 0; /* - * DMA buffer poool PCIe bus address, it is either identical to the CPU + * DMA buffer pool PCIe bus address, it is either identical to the CPU * physical address or another address(IOVA) translated by IOMMU. */ static phys_addr_t _dma_pbase = 0; @@ -797,12 +797,9 @@ _mpool_free(void) _use_dma_mapping = 0; } -#ifndef REMAP_DMA_NONCACHED - if (_use_himem) +#ifdef REMAP_DMA_NONCACHED + iounmap(_dma_vbase); #endif - { - iounmap(_dma_vbase); - } switch (dmaalloc) { #if _SIMPLE_MEMORY_ALLOCATION_ @@ -1036,16 +1033,13 @@ void _dma_per_device_init(int dev_index) _dma_pbase = dma_addr; _dma_pool_alloc_state = DMA_POOL_MAPPED; -#ifndef REMAP_DMA_NONCACHED - if (_use_himem) -#endif - { - if (dma_debug >= 2) { - gprintk("remapping DMA buffer pool from physical:0x%lx original kernel_virt:0x%lx\n", - (unsigned long)_dma_pbase, (unsigned long)_dma_vbase); - } - _dma_vbase = ioremap(_dma_pbase, _dma_mem_size); +#ifdef REMAP_DMA_NONCACHED + if (dma_debug >= 2) { + gprintk("remapping DMA buffer pool from physical:0x%lx original kernel_virt:0x%lx\n", + (unsigned long)_dma_pbase, (unsigned long)_dma_vbase); } + _dma_vbase = ioremap(_dma_pbase, _dma_mem_size); +#endif if (dma_debug >= 1) { gprintk("Mapped DMA buffer pool _use_dma_mapping:%d kernel_virt:0x%lx dma_bus:0x%lx physical:0x%lx size:0x%x dmaalloc:%d, dma64_support:%d\n", diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c index 7677aa5d4394..deff8954665b 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.c @@ -185,6 +185,17 @@ be made. /* Defines used to distinguish CMICe from CMICm */ #define CMICE_DEV_REV_ID (0x178 / sizeof(uint32)) +#ifdef BCM_DNX3_SUPPORT +#ifndef NEED_CMICX_GEN2_INTERRUPT +#define NEED_CMICX_GEN2_INTERRUPT +#endif +#endif +#ifdef BCM_DNXF3_SUPPORT +#ifndef NEED_CMICX_GEN2_INTERRUPT +#define NEED_CMICX_GEN2_INTERRUPT +#endif +#endif + static uint32 *ihost_intr_status_base = NULL; static uint32 *ihost_intr_enable_base = NULL; @@ -572,6 +583,34 @@ _cmicx_interrupt_prepare(bde_ctrl_t *ctrl) return ret; } +static int +_cmicx_interrupt_pending(void *data) +{ + int d, ind; + uint32 stat, iena; + bde_ctrl_t *ctrl = (bde_ctrl_t *)data; + + if (ctrl->dev_type & BDE_PCI_DEV_TYPE) { + + d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); + + for (ind = 0; ind < ctrl->intr_regs.intc_intr_nof_regs; ind++) { + IPROC_READ(d, ctrl->intr_regs.intc_intr_status_base + 4 * ind, stat); + IPROC_READ(d, ctrl->intr_regs.intc_intr_enable_base + 4 * ind, iena); + if (debug >= 2) { + gprintk("INTC_INTR_STATUS_REG_%d = 0x%x\n", ind, stat); + gprintk("INTC_INTR_ENABLE_REG_%d = 0x%x\n", ind, iena); + } + if (stat & iena) { + return 1; + } + } + } + + /* No pending interrupts */ + return 0; +} + static void _cmicx_interrupt(bde_ctrl_t *ctrl) { @@ -1187,6 +1226,7 @@ _devices_init(int d) case BCM56575_DEVICE_ID: case BCM56175_DEVICE_ID: case BCM56176_DEVICE_ID: + case BCM53642_DEVICE_ID: ctrl->isr = (isr_f)_cmicx_interrupt; if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { if (!ihost_intr_enable_base) { @@ -1240,6 +1280,7 @@ _devices_init(int d) case Q2U_DEVICE_ID: case Q2N_DEVICE_ID: case J2P_DEVICE_ID: + case J2X_DEVICE_ID: #endif #ifdef BCM_DNXF_SUPPORT case BCM88790_DEVICE_ID: @@ -1248,6 +1289,19 @@ _devices_init(int d) _intr_regs_init(ctrl, 0); break; +#ifdef BCM_DNX3_SUPPORT + case JERICHO3_DEVICE_ID: + case Q4_DEVICE_ID: +#endif +#ifdef BCM_DNXF3_SUPPORT + case BCM88910_DEVICE_ID: + case BCM88920_DEVICE_ID: +#endif +#if defined(BCM_DNX3_SUPPORT) || defined(BCM_DNXF3_SUPPORT) + ctrl->isr = (isr_f)_cmicx_gen2_interrupt; + _intr_regs_init(ctrl, 2); + break; +#endif } #endif /* defined(BCM_DNXF_SUPPORT) || defined(BCM_DNX_SUPPORT) */ @@ -1760,6 +1814,14 @@ _ioctl(unsigned int cmd, unsigned long arg) } if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) { if (_devices[io.dev].isr && !_devices[io.dev].enabled) { + /* PCI/CMICX Devices */ + if ((_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) && + (_devices[io.dev].isr == (isr_f)_cmicx_interrupt)) { + lkbde_intr_cb_register(io.dev, + _cmicx_interrupt_pending, + _devices+io.dev); + } + user_bde->interrupt_connect(io.dev, _devices[io.dev].isr, _devices+io.dev); diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile index 56b83fb0da33..d42798e737db 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/Makefile @@ -35,31 +35,69 @@ include ${SDK}/make/Make.config LIBS = $(LIBDIR)/libkern.a -ifeq ($(kernel_version),2_4) -MODULE = $(LIBDIR)/linux-bcm-knet.o -else KERNEL_MODULE_DIR = kernel_module THIS_MOD_NAME := linux-bcm-knet MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko -build: $(MODULE) $(KMODULE) -endif +# BCM Network Device -KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers +ifeq (1,$(NO_PRECOMPILED_MODULE)) +# { +# +# For 'NO_PRECOMPILED_MODULE', the first kernel compilation is done +# in systems/linux/kernel/modules/bcm-knet (and not in systems/linux/kernel/modules/bcm-knet/kernel_module, +# which is not even created). +# KBUILD_EXTRA_SYMBOLS exports the symbols created on the first module compilation to +# all other module compilations. +# +KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/Module.symvers +export KBUILD_EXTRA_SYMBOLS +# +# These are the objects which need to be compiled, in the kernel, to +# created the module object file. +# +SRCS_COMPOSING = bcm-knet.c ../shared/gmodule.c +OBJECTS_COMPOSING = "bcm-knet.o gmodule.o" +# +# Note that for NO_PRECOMPILED_MODULE, the subdirectory 'systems/linux/kernel/modules/bcm-knet/kernel_module' +# is not created and all action is done in systems/linux/kernel/modules/bcm-knet +# -# BCM Network Device +build: $(KMODULE) + +$(KMODULE): $(SRCS_COMPOSING) + rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) + rm -f $(BLDDIR)/*.c + rm -f $(BLDDIR)/*.o + rm -f $(BLDDIR)/*.ko + cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/Makefile + cp ./*.c $(BLDDIR)/ + cp ../shared/*.c $(BLDDIR)/ + cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/Module.symvers + MOD_OBJS=$(OBJECTS_COMPOSING) MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR) $(THIS_MOD_NAME).ko LOC_BLDDIR=$(BLDDIR) LOC_SRCDIR=$(PWD) +# } +else +# { +KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../../../../bde/linux/kernel/kernel_module/Module.symvers +export KBUILD_EXTRA_SYMBOLS +build: $(MODULE) $(KMODULE) +# +# This is for the compilation of the 'precompiled' object. We keep it +# here for compatibility. +# $(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS) $(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@ -ifneq ($(kernel_version),2_4) + $(KMODULE): $(MODULE) rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR) cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko +# } endif # Make.depend is before clean:: so that Make.depend's clean:: runs first. @@ -70,6 +108,5 @@ clean:: $(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o $(RM) $(BOBJS) $(MODULE) -ifneq ($(kernel_version),2_4) .PHONY: build -endif + diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c old mode 100644 new mode 100755 index b93f1e913fd9..ae4dfb6b773b --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/bcm-knet/bcm-knet.c @@ -604,6 +604,7 @@ typedef struct bkn_switch_info_s { uint32_t udh_size; /* Size of UDH header on legacy devices */ uint32_t oamp_punt; /* OAMP port if nonzero */ uint8_t no_skip_udh_check; /* Indicates UDH won't be skipped */ + uint8_t oam_dm_tod_exist; /* Indicates presence of OAM TOD MSB */ uint8_t system_headers_mode; /* Indicates system header mode */ uint8_t udh_enable; /* Indicates UDH existence */ uint8_t oamp_port_number; /* Indicates number of OAMP system port number */ @@ -627,8 +628,10 @@ typedef struct bkn_switch_info_s { uint32_t poll_channels; /* Channels for polling */ uint32_t unet_channels; /* User network channels */ uint32_t inst_id; /* Instance id of this device */ + uint32_t device_id; /* Device ID, like 0x8675 for Jericho A0, 0x */ int evt_idx; /* Event queue index for this device*/ int basedev_suspended; /* Base device suspended */ + int pcie_link_status; /* This flag is used to indicate PCIE Link status, 0 for up and 1 for down */ struct sk_buff_head tx_ptp_queue; /* Tx PTP skb queue */ struct work_struct tx_ptp_work; /* Tx PTP work */ struct { @@ -964,7 +967,9 @@ typedef struct bkn_priv_s { int phys_port; u32 ptp_stats_tx; u32 ptp_stats_rx; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) struct ethtool_link_settings link_settings; +#endif } bkn_priv_t; typedef struct bkn_filter_s { @@ -1015,7 +1020,6 @@ static knet_hw_tstamp_rx_pre_process_cb_f knet_hw_tstamp_rx_pre_process_cb = NUL static knet_hw_tstamp_ioctl_cmd_cb_f knet_hw_tstamp_ioctl_cmd_cb = NULL; static knet_netif_cb_f knet_netif_create_cb = NULL; static knet_netif_cb_f knet_netif_destroy_cb = NULL; - /* * Thread management */ @@ -1168,18 +1172,45 @@ bkn_sleep(int clicks) /* Maximum packet raw data size for filter validation. */ #define KNET_FILTER_RAW_MAX 256 +static void +dev_read32(bkn_switch_info_t *sinfo, uint32_t address, uint32_t *value) +{ + /* Devices id started with 0x8 is always from DNX devices */ + if ((sinfo->device_id & 0x8000) == 0x8000) { + if (sinfo->pcie_link_status == PCIE_LINK_STATUS_DOWN) { + /* Bypass register access when PCIE Link is down */ + return; + } + } + + DEV_READ32(sinfo, address, value); +} + +static void +dev_write32(bkn_switch_info_t *sinfo, uint32_t address, uint32_t value) +{ + /* Devices id started with 0x8 is always from DNX devices */ + if ((sinfo->device_id & 0x8000) == 0x8000) { + if (sinfo->pcie_link_status == PCIE_LINK_STATUS_DOWN) { + /* Bypass register access when PCIE Link is down */ + return; + } + } + + DEV_WRITE32(sinfo, address, value); +} + /* * Per-channel operations. * These are the basis for the TX/RX functions */ - static inline void xgs_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) { DBG_IRQ(("Clear chain on device %d chan %d\n", sinfo->dev_no, chan)); - DEV_WRITE32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_CLR(chan)); - DEV_WRITE32(sinfo, CMIC_DMA_STATr, DS_CHAIN_DONE_CLR(chan)); + dev_write32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_CLR(chan)); + dev_write32(sinfo, CMIC_DMA_STATr, DS_CHAIN_DONE_CLR(chan)); MEMORY_BARRIER; } @@ -1187,16 +1218,16 @@ xgs_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) static inline void xgs_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) { - uint32_t val; + uint32_t val = 0; DBG_IRQ(("Clear desc on device %d chan %d\n", sinfo->dev_no, chan)); - DEV_WRITE32(sinfo, CMIC_DMA_STATr, DS_DESC_DONE_CLR(chan)); + dev_write32(sinfo, CMIC_DMA_STATr, DS_DESC_DONE_CLR(chan)); MEMORY_BARRIER; /* Flush write buffer */ - DEV_READ32(sinfo, CMIC_DMA_STATr, &val); + dev_read32(sinfo, CMIC_DMA_STATr, &val); MEMORY_BARRIER; } @@ -1213,9 +1244,9 @@ xgs_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) static int xgs_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) { - uint32_t cdc; + uint32_t cdc = 0; - DEV_READ32(sinfo, CMIC_DMA_CTRLr, &cdc); + dev_read32(sinfo, CMIC_DMA_CTRLr, &cdc); cdc &= ~(0x9 << (8 * chan)); if (dir) { @@ -1224,7 +1255,7 @@ xgs_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) cdc |= 0x8 << (8 * chan); } - DEV_WRITE32(sinfo, CMIC_DMA_CTRLr, cdc); + dev_write32(sinfo, CMIC_DMA_CTRLr, cdc); return 0; } @@ -1233,12 +1264,12 @@ static int xgs_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) { /* Write the DCB address to the DESC address for this channel */ - DEV_WRITE32(sinfo, CMIC_DMA_DESC0r + 4 * chan, dcb); + dev_write32(sinfo, CMIC_DMA_DESC0r + 4 * chan, dcb); MEMORY_BARRIER; /* Kick it off */ - DEV_WRITE32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_SET(chan)); + dev_write32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_SET(chan)); MEMORY_BARRIER; @@ -1248,26 +1279,27 @@ xgs_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) static int xgs_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - uint32_t ctrl, dma_stat; + uint32_t ctrl = 0; + uint32_t dma_stat = 0; int p; /* Clear enable */ - DEV_WRITE32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_CLR(chan)); + dev_write32(sinfo, CMIC_DMA_STATr, DS_DMA_EN_CLR(chan)); MEMORY_BARRIER; /* Abort the channel */ - DEV_READ32(sinfo, CMIC_DMA_CTRLr, &ctrl); - DEV_WRITE32(sinfo, CMIC_DMA_CTRLr, ctrl | DC_ABORT_DMA(chan)); + dev_read32(sinfo, CMIC_DMA_CTRLr, &ctrl); + dev_write32(sinfo, CMIC_DMA_CTRLr, ctrl | DC_ABORT_DMA(chan)); MEMORY_BARRIER; /* Poll for abort completion */ for (p = 0; p < polls; p++) { - DEV_READ32(sinfo, CMIC_DMA_STATr, &dma_stat); + dev_read32(sinfo, CMIC_DMA_STATr, &dma_stat); if (!(dma_stat & DS_DMA_ACTIVE(chan))) { /* Restore previous control value */ - DEV_WRITE32(sinfo, CMIC_DMA_CTRLr, ctrl); + dev_write32(sinfo, CMIC_DMA_CTRLr, ctrl); MEMORY_BARRIER; @@ -1285,6 +1317,14 @@ xgs_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) static inline void xgs_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) { + /* Devices id started with 0x8 is always from DNX devices */ + if ((sinfo->device_id & 0x8000) == 0x8000) { + if (sinfo->pcie_link_status == PCIE_LINK_STATUS_DOWN) { + /* Bypass hw access when PCIE Link is down */ + return; + } + } + if (sinfo->napi_poll_mode) { mask = 0; } @@ -1331,12 +1371,12 @@ xgs_irq_mask_disable(bkn_switch_info_t *sinfo, int chan, int update_hw) static inline void xgsm_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) { - uint32_t cdc; + uint32_t cdc = 0; /* Disabing DMA clears chain done */ - DEV_READ32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); + dev_read32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); cdc &= ~(DC_CMC_ENABLE | DC_CMC_ABORT); - DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); + dev_write32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); MEMORY_BARRIER; } @@ -1350,12 +1390,12 @@ xgsm_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) if (CDMA_CH(sinfo, chan)) { val |= DS_CMC_CTRLD_INT_CLR(chan); } - DEV_WRITE32(sinfo, CMICM_DMA_STAT_CLRr, val); + dev_write32(sinfo, CMICM_DMA_STAT_CLRr, val); MEMORY_BARRIER; /* Flush write buffer */ - DEV_READ32(sinfo, CMICM_DMA_STAT_CLRr, &val); + dev_read32(sinfo, CMICM_DMA_STAT_CLRr, &val); MEMORY_BARRIER; } @@ -1372,7 +1412,7 @@ xgsm_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) static inline void xgsm_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) { - DEV_WRITE32(sinfo, CMICM_DMA_HALT_ADDRr + 4 * chan, + dev_write32(sinfo, CMICM_DMA_HALT_ADDRr + 4 * chan, sinfo->halt_addr[chan]); MEMORY_BARRIER; @@ -1381,9 +1421,9 @@ xgsm_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) static int xgsm_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) { - uint32_t cdc; + uint32_t cdc = 0; - DEV_READ32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); + dev_read32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); cdc &= ~DC_CMC_DIRECTION; if (dir) { cdc |= DC_CMC_DIRECTION; @@ -1392,7 +1432,7 @@ xgsm_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) cdc |= DC_CMC_CONTINUOUS | DC_CMC_CTRLD_INT; xgsm_cdma_halt_set(sinfo, chan); } - DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); + dev_write32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); return 0; } @@ -1400,17 +1440,17 @@ xgsm_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) static int xgsm_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) { - uint32_t cdc; + uint32_t cdc = 0; /* Write the DCB address to the DESC address for this channel */ - DEV_WRITE32(sinfo, CMICM_DMA_DESC0r + 4 * chan, dcb); + dev_write32(sinfo, CMICM_DMA_DESC0r + 4 * chan, dcb); MEMORY_BARRIER; /* Kick it off */ - DEV_READ32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); + dev_read32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); cdc |= DC_CMC_ENABLE; - DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); + dev_write32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); MEMORY_BARRIER; @@ -1420,25 +1460,26 @@ xgsm_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) static int xgsm_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - uint32_t ctrl, dma_stat; + uint32_t ctrl = 0; + uint32_t dma_stat = 0; int p; /* Skip abort sequence if channel is not active */ - DEV_READ32(sinfo, CMICM_DMA_STATr, &dma_stat); + dev_read32(sinfo, CMICM_DMA_STATr, &dma_stat); if (!(dma_stat & DS_CMC_DMA_ACTIVE(chan))) { return 0; } /* Abort the channel */ - DEV_READ32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &ctrl); + dev_read32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &ctrl); ctrl |= (DC_CMC_ENABLE | DC_CMC_ABORT); - DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, ctrl); + dev_write32(sinfo, CMICM_DMA_CTRLr + 4 * chan, ctrl); MEMORY_BARRIER; /* Poll for abort completion */ for (p = 0; p < polls; p++) { - DEV_READ32(sinfo, CMICM_DMA_STATr, &dma_stat); + dev_read32(sinfo, CMICM_DMA_STATr, &dma_stat); if (!(dma_stat & DS_CMC_DMA_ACTIVE(chan))) { /* Clear up channel */ xgsm_dma_chan_clear(sinfo, chan); @@ -1456,6 +1497,14 @@ xgsm_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) uint32_t irq_mask_reg = CMICM_IRQ_PCI_MASKr; uint32_t ctrld_mask = 0; + /* Devices id started with 0x8 is always from DNX devices */ + if ((sinfo->device_id & 0x8000) == 0x8000) { + if (sinfo->pcie_link_status == PCIE_LINK_STATUS_DOWN) { + /* Bypass hw access when PCIE Link is down */ + return; + } + } + if (sinfo->napi_poll_mode) { mask = 0; } @@ -1517,20 +1566,21 @@ xgsm_irq_mask_disable(bkn_switch_info_t *sinfo, int chan, int update_hw) static inline void xgsx_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) { - uint32_t ctrl, stat; + uint32_t ctrl = 0; + uint32_t stat = 0; /* Disabing DMA clears chain done */ - DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + dev_read32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); ctrl &= ~(CMICX_DC_CMC_ENABLE | CMICX_DC_CMC_ABORT); - DEV_WRITE32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); + dev_write32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); stat = CMICX_DS_CMC_CHAIN_DONE(chan); - DEV_WRITE32(sinfo, CMICX_IRQ_STAT_CLRr, stat); + dev_write32(sinfo, CMICX_IRQ_STAT_CLRr, stat); MEMORY_BARRIER; /* Flush write buffer */ - DEV_READ32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); + dev_read32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); MEMORY_BARRIER; } @@ -1538,19 +1588,19 @@ xgsx_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) static inline void xgsx_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) { - uint32_t stat; + uint32_t stat = 0; if (CDMA_CH(sinfo, chan)) { stat = CMICX_DS_CMC_CTRLD_INT(chan); } else { stat = CMICX_DS_CMC_DESC_DONE(chan); } - DEV_WRITE32(sinfo, CMICX_IRQ_STAT_CLRr, stat); + dev_write32(sinfo, CMICX_IRQ_STAT_CLRr, stat); MEMORY_BARRIER; /* Flush write buffer */ - DEV_READ32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); + dev_read32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); MEMORY_BARRIER; } @@ -1567,9 +1617,9 @@ xgsx_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) static inline void xgsx_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) { - DEV_WRITE32(sinfo, CMICX_DMA_HALT_LOr + 0x80 * chan, + dev_write32(sinfo, CMICX_DMA_HALT_LOr + 0x80 * chan, sinfo->halt_addr[chan]); - DEV_WRITE32(sinfo, CMICX_DMA_HALT_HIr + 0x80 * chan, + dev_write32(sinfo, CMICX_DMA_HALT_HIr + 0x80 * chan, DMA_TO_BUS_HI(sinfo->halt_addr[chan] >> 32)); MEMORY_BARRIER; @@ -1578,9 +1628,9 @@ xgsx_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) static int xgsx_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) { - uint32_t ctrl; + uint32_t ctrl = 0; - DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + dev_read32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); ctrl &= ~CMICX_DC_CMC_DIRECTION; if (dir) { ctrl |= CMICX_DC_CMC_DIRECTION; @@ -1589,7 +1639,7 @@ xgsx_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) ctrl |= CMICX_DC_CMC_CONTINUOUS | CMICX_DC_CMC_CTRLD_INT; xgsx_cdma_halt_set(sinfo, chan); } - DEV_WRITE32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); + dev_write32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); MEMORY_BARRIER; @@ -1599,18 +1649,18 @@ xgsx_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) static int xgsx_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) { - uint32_t ctrl; + uint32_t ctrl = 0; /* Write the DCB address to the DESC address for this channel */ - DEV_WRITE32(sinfo, CMICX_DMA_DESC_LOr + 0x80 * chan, dcb); - DEV_WRITE32(sinfo, CMICX_DMA_DESC_HIr + 0x80 * chan, DMA_TO_BUS_HI(dcb >> 32)); + dev_write32(sinfo, CMICX_DMA_DESC_LOr + 0x80 * chan, dcb); + dev_write32(sinfo, CMICX_DMA_DESC_HIr + 0x80 * chan, DMA_TO_BUS_HI(dcb >> 32)); MEMORY_BARRIER; /* Kick it off */ - DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + dev_read32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); ctrl |= CMICX_DC_CMC_ENABLE; - DEV_WRITE32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); + dev_write32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); MEMORY_BARRIER; @@ -1620,25 +1670,26 @@ xgsx_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) static int xgsx_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - uint32_t ctrl, stat; + uint32_t ctrl = 0; + uint32_t stat = 0; int p; /* Skip abort sequence if channel is not active */ - DEV_READ32(sinfo, CMICX_DMA_STATr + 0x80 * chan, &stat); + dev_read32(sinfo, CMICX_DMA_STATr + 0x80 * chan, &stat); if (!(stat & CMICX_DS_CMC_DMA_ACTIVE)) { return 0; } /* Abort the channel */ - DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + dev_read32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); ctrl |= CMICX_DC_CMC_ENABLE | CMICX_DC_CMC_ABORT; - DEV_WRITE32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); + dev_write32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); MEMORY_BARRIER; /* Poll for abort completion */ for (p = 0; p < polls; p++) { - DEV_READ32(sinfo, CMICX_DMA_STATr + 0x80 * chan, &stat); + dev_read32(sinfo, CMICX_DMA_STATr + 0x80 * chan, &stat); if (!(stat & CMICX_DS_CMC_DMA_ACTIVE)) { /* Clear up channel */ xgsx_dma_chan_clear(sinfo, chan); @@ -1677,6 +1728,14 @@ xgsx_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) uint32_t irq_mask, irq_fmask, disable_mask; uint32_t fmask = CMICX_TXRX_IRQ_MASK; + /* Devices id started with 0x8 is always from DNX devices */ + if ((sinfo->device_id & 0x8000) == 0x8000) { + if (sinfo->pcie_link_status == PCIE_LINK_STATUS_DOWN) { + /* Bypass hw access when PCIE Link is down */ + return; + } + } + if (sinfo->napi_poll_mode) { mask = 0; } @@ -2309,6 +2368,9 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) return; } + /* Add meta data length */ + resv_size += sinfo->pkt_hdr_size; + while (sinfo->rx[chan].free < MAX_RX_DCBS) { desc = &sinfo->rx[chan].desc[sinfo->rx[chan].cur]; if (desc->skb == NULL) { @@ -2316,6 +2378,7 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) if (skb == NULL) { break; } + /* Reserve buffer space for RCPU encapsulation if needed */ skb_reserve(skb, SKB_DATA_ALIGN(resv_size)); desc->skb = skb; } else { @@ -2993,7 +3056,9 @@ bkn_dpp_packet_parse_otsh( BKN_DPP_OTSH_OAM_SUB_TYPE_NOF_BITS, &oam_sub_type); if ((oam_sub_type == BKN_DPP_OTSH_OAM_SUB_TYPE_DM_1588) || (oam_sub_type == BKN_DPP_OTSH_OAM_SUB_TYPE_DM_NTP)) { - *is_oam_dm_tod_en = TRUE; + if (sinfo->oam_dm_tod_exist) { + *is_oam_dm_tod_en = TRUE; + } /* Down MEP DM trapped packets will not have UDH present (even if configured), except for QAX when custom_feature_oam_dm_tod_msb_add_enable=0 */ if (!sinfo->no_skip_udh_check) { *is_skip_udh = TRUE; @@ -4064,6 +4129,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) bkn_priv_t *mpriv; struct sk_buff *mskb = NULL; uint32_t *rx_cb_meta; + int metalen; if (!sinfo->rx[chan].running) { /* Rx not ready */ @@ -4140,6 +4206,22 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) err_woff = sinfo->pkt_hdr_size / sizeof(uint32_t) - 1; meta[err_woff] = dcb[sinfo->dcb_wsize-1]; } else { + /* Packet sent from R5(KNETSYNC) has EP_TO_CPU_HDR in skb->data + * and not in dcb header. Information within the EP_TO_CPU_HDR + * is considered as metadata to find the KNET filter. + * + * Below WAR implementation is to copy the EP_TO_CPU_HDR from + * sdk->data to dcb header(with EP_TO_CPU as 0's) for further + * packet processing. + */ + if (sinfo->dcb_type == 37 && dcb[5] == 0) { + metalen = (sinfo->dcb_wsize - 3) * sizeof(uint32_t); + meta = (uint32_t *)skb->data; + for (idx = 0; idx < BYTES2WORDS(metalen); idx++) { + dcb[idx + 2] = ntohl(meta[idx]); + } + skip_hdrlen = metalen; + } meta = dcb; err_woff = sinfo->dcb_wsize - 1; } @@ -4460,6 +4542,101 @@ bkn_do_rx(bkn_switch_info_t *sinfo, int chan, int budget) } } +static void +bkn_rx_debug_dump(bkn_switch_info_t *sinfo, int chan) +{ + uint32_t *dcb = NULL; + bkn_dcb_chain_t *dcb_chain = NULL; + struct list_head *curr, *next; + int cnt; + uint32_t irq_stat, dma_stat, dma_ctrl; + + gprintk("Rx%d DCB info (dev_no %d):\n" + " api: %d\n" + " dirty: %d\n" + " cur: %d\n" + " free: %d\n" + " run: %d\n", + chan, sinfo->dev_no, + sinfo->rx[chan].api_active, + sinfo->rx[chan].dirty, + sinfo->rx[chan].cur, + sinfo->rx[chan].free, + sinfo->rx[chan].running); + if (sinfo->rx[chan].use_rx_skb) { + gprintk(" [0x%08lx]--->\n", + (unsigned long)sinfo->rx[chan].desc[0].dcb_dma); + for (cnt = 0; cnt < MAX_RX_DCBS; cnt++) { + dcb = sinfo->rx[chan].desc[cnt].dcb_mem; + if (sinfo->cmic_type == 'x') { + gprintk(" DCB %2d: 0x%08x 0x%08x 0x%08x 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[2], dcb[sinfo->dcb_wsize-1]); + } else { + gprintk(" DCB %2d: 0x%08x 0x%08x ... 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[sinfo->dcb_wsize-1]); + } + } + } else { + curr = &sinfo->rx[chan].api_dcb_list; + dcb_chain = sinfo->rx[chan].api_dcb_chain; + while (dcb_chain) { + gprintk(" [0x%08lx]--->\n", (unsigned long)dcb_chain->dcb_dma); + for (cnt = 0; cnt < dcb_chain->dcb_cnt; cnt++) { + dcb = &dcb_chain->dcb_mem[sinfo->dcb_wsize * cnt]; + if (sinfo->cmic_type == 'x') { + gprintk(" DCB %2d: 0x%08x 0x%08x 0x%08x 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[2], dcb[sinfo->dcb_wsize-1]); + } else { + gprintk(" DCB %2d: 0x%08x 0x%08x ... 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[sinfo->dcb_wsize-1]); + } + } + next = curr->next; + if (next != &sinfo->rx[chan].api_dcb_list) { + dcb_chain = list_entry(next, bkn_dcb_chain_t, list); + curr = next; + } else { + dcb_chain = NULL; + } + } + } + + irq_stat = dma_stat = dma_ctrl = 0; + if (DEV_IS_CMICX(sinfo)) { + dev_read32(sinfo, + CMICX_IRQ_STATr, + &irq_stat); + dev_read32(sinfo, + CMICX_DMA_STATr, + &dma_stat); + dev_read32(sinfo, + CMICX_DMA_CTRLr + 0x80 * (XGS_DMA_RX_CHAN + chan), + &dma_ctrl); + } else if (DEV_IS_CMICM(sinfo)) { + dev_read32(sinfo, + CMICM_IRQ_STATr, + &irq_stat); + dev_read32(sinfo, + CMICM_DMA_STATr, + &dma_stat); + dev_read32(sinfo, + CMICM_DMA_CTRLr + 0x80 * (XGS_DMA_RX_CHAN + chan), + &dma_ctrl); + } else { + dev_read32(sinfo, + CMIC_IRQ_STATr, + &irq_stat); + dev_read32(sinfo, + CMIC_DMA_STATr, + &dma_stat); + dev_read32(sinfo, + CMIC_DMA_CTRLr + 0x80 * (XGS_DMA_RX_CHAN + chan), + &dma_ctrl); + } + gprintk("CMIC irq_stat:0x%08x dma_stat:0x%08x dma_ctrl(RX%d):0x%08x \n", + irq_stat, dma_stat, chan, dma_ctrl); +} + static void bkn_rx_desc_done(bkn_switch_info_t *sinfo, int chan) { @@ -4500,6 +4677,7 @@ bkn_rx_chain_done(bkn_switch_info_t *sinfo, int chan) } if (++maxloop > rx_sync_retry) { gprintk("Fatal error: Incomplete chain\n"); + bkn_rx_debug_dump(sinfo, chan); sinfo->rx[chan].chain_complete = 1; break; } @@ -4585,15 +4763,23 @@ bkn_hw_tstamp_tx_set(bkn_switch_info_t *sinfo, struct sk_buff *skb) hwts = KNET_SKB_CB(skb)->hwts; ts = KNET_SKB_CB(skb)->ts; - - if (hwts == HWTSTAMP_TX_ONESTEP_SYNC) { - if (ts == 0) { - return 1; - } - } else if (hwts == HWTSTAMP_TX_ON) { - if (knet_hw_tstamp_tx_time_get_cb(sinfo->dev_no, port, skb->data + hdrlen, &ts) < 0) { + if (device_is_dnx(sinfo)) { + port = port + 1; + if (knet_hw_tstamp_tx_time_get_cb(sinfo->dev_no, port, skb->data + hdrlen, &ts, hwts) < 0) { + DBG_VERB(("Error in setting tx tstsamp \n")); return -1; } + } else { + if (hwts == HWTSTAMP_TX_ONESTEP_SYNC) { + if (ts == 0) { + return 1; + } + } else if (hwts == HWTSTAMP_TX_ON) { + if (knet_hw_tstamp_tx_time_get_cb(sinfo->dev_no, port, skb->data + hdrlen, &ts, hwts) < 0) { + DBG_VERB(("Error in setting tx tstsamp \n")); + return -1; + } + } } memset(&shhwtstamps, 0, sizeof(shhwtstamps)); @@ -4609,23 +4795,41 @@ bkn_hw_tstamp_tx_work(struct work_struct *work) bkn_switch_info_t *sinfo = container_of(work, bkn_switch_info_t, tx_ptp_work); struct sk_buff *skb; int ret; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + ktime_t tstamp; +#endif while (skb_queue_len(&sinfo->tx_ptp_queue)) { skb = skb_dequeue(&sinfo->tx_ptp_queue); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + tstamp = skb->tstamp; +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,13,0)) + /* + * For Linux versions with simultaneous SW and HW TS support. + * If the driver sends out SW TS included in skb->tstamp, then the + * Kernel will no longer send the HW TS to the application, + * so set the populated skb->tstamp to 0. + */ + skb->tstamp = 0; +#endif + ret = bkn_hw_tstamp_tx_set(sinfo, skb); if (ret < 0) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) ktime_t now; now = ktime_get(); DBG_PTP(("2Step TX Timestamp has not been taken for the current skb (%lld us)\n", - ktime_us_delta(now, skb->tstamp))); + ktime_us_delta(now, tstamp))); } else { ktime_t now; now = ktime_get(); /* Timeout 20 should be same as configured by PTP4L */ - if (ktime_us_delta(now, skb->tstamp) >= 20000) { + if (ktime_us_delta(now, tstamp) >= 20000) { DBG_PTP(("2Step TX Timestamp fetch took long time %lld us\n", - ktime_us_delta(now, skb->tstamp))); + ktime_us_delta(now, tstamp))); } #else DBG_PTP(("2Step TX Timestamp has not been taken for the current skb\n")); @@ -4978,11 +5182,11 @@ xgs_do_dma(bkn_switch_info_t *sinfo, int budget) { int rx_dcbs_done = 0, tx_dcbs_done = 0; int chan_done, budget_chans = 0; - uint32_t dma_stat; + uint32_t dma_stat = 0; int chan; int unet_chans = 0; - DEV_READ32(sinfo, CMIC_DMA_STATr, &dma_stat); + dev_read32(sinfo, CMIC_DMA_STATr, &dma_stat); for (chan = 0; chan < sinfo->rx_chans; chan++) { if (UNET_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { @@ -5042,16 +5246,16 @@ xgsm_do_dma(bkn_switch_info_t *sinfo, int budget) { int rx_dcbs_done = 0, tx_dcbs_done = 0; int chan_done, budget_chans = 0; - uint32_t dma_stat, irq_stat = 0; + uint32_t dma_stat =0, irq_stat = 0; int chan; int unet_chans = 0; /* Get Controlled interrupt states for Continuous DMA mode */ if (sinfo->cdma_channels) { - DEV_READ32(sinfo, CMICM_IRQ_STATr, &irq_stat); + dev_read32(sinfo, CMICM_IRQ_STATr, &irq_stat); } - DEV_READ32(sinfo, CMICM_DMA_STATr, &dma_stat); + dev_read32(sinfo, CMICM_DMA_STATr, &dma_stat); for (chan = 0; chan < sinfo->rx_chans; chan++) { if (UNET_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { @@ -5121,18 +5325,20 @@ xgsx_do_dma(bkn_switch_info_t *sinfo, int budget) { int rx_dcbs_done = 0, tx_dcbs_done = 0; int chan_done, budget_chans = 0; - uint32_t irq_stat, tx_dma_stat, rx_dma_stat[NUM_CMICX_RX_CHAN]; + uint32_t irq_stat = 0; + uint32_t tx_dma_stat = 0; + uint32_t rx_dma_stat[NUM_CMICX_RX_CHAN] = {0}; int chan; int unet_chans = 0; - DEV_READ32(sinfo, CMICX_IRQ_STATr, &irq_stat); - DEV_READ32(sinfo, CMICX_DMA_STATr + 0x80 * XGS_DMA_TX_CHAN, &tx_dma_stat); + dev_read32(sinfo, CMICX_IRQ_STATr, &irq_stat); + dev_read32(sinfo, CMICX_DMA_STATr + 0x80 * XGS_DMA_TX_CHAN, &tx_dma_stat); for (chan = 0; chan < sinfo->rx_chans; chan++) { if (UNET_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { unet_chans++; continue; } - DEV_READ32(sinfo, + dev_read32(sinfo, CMICX_DMA_STATr + 0x80 * (XGS_DMA_RX_CHAN + chan), &rx_dma_stat[chan]); } @@ -5216,10 +5422,10 @@ dev_do_dma(bkn_switch_info_t *sinfo, int budget) static void xgs_isr(bkn_switch_info_t *sinfo) { - uint32_t irq_stat; + uint32_t irq_stat = 0; int rx_dcbs_done; - DEV_READ32(sinfo, CMIC_IRQ_STATr, &irq_stat); + dev_read32(sinfo, CMIC_IRQ_STATr, &irq_stat); if ((irq_stat & sinfo->irq_mask) == 0) { /* Not ours */ return; @@ -5244,10 +5450,10 @@ xgs_isr(bkn_switch_info_t *sinfo) static void xgsm_isr(bkn_switch_info_t *sinfo) { - uint32_t irq_stat; + uint32_t irq_stat = 0; int rx_dcbs_done; - DEV_READ32(sinfo, CMICM_IRQ_STATr, &irq_stat); + dev_read32(sinfo, CMICM_IRQ_STATr, &irq_stat); if ((irq_stat & sinfo->irq_mask) == 0) { /* Not ours */ return; @@ -5278,10 +5484,10 @@ xgsm_isr(bkn_switch_info_t *sinfo) static void xgsx_isr(bkn_switch_info_t *sinfo) { - uint32_t irq_stat; + uint32_t irq_stat = 0; int rx_dcbs_done; - DEV_READ32(sinfo, CMICX_IRQ_STATr, &irq_stat); + dev_read32(sinfo, CMICX_IRQ_STATr, &irq_stat); if ((irq_stat & sinfo->irq_mask) == 0) { /* Not ours */ return; @@ -5293,7 +5499,7 @@ xgsx_isr(bkn_switch_info_t *sinfo) int chan = 0; for (chan = 0; chan < NUM_DMA_CHAN; chan++) { if (irq_stat & CMICX_DS_CMC_CHAIN_DONE(chan)) { - DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + dev_read32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); if (ctrl & CMICX_DC_CMC_ABORT) { DBG_IRQ(("chain %d: chain done for Abort\n", chan)); return; @@ -5696,17 +5902,19 @@ bkn_hw_tstamp_tx_config(bkn_switch_info_t *sinfo, return 0; } - if (!md) { + if (!md && !device_is_dnx(sinfo)) { return -1; } switch (sinfo->dcb_type) { case 28: /* dpp */ + case 39: /* DNX - Q2A, J2C */ break; case 26: case 32: case 33: case 35: + case 37: meta[2] |= md[0]; meta[3] |= md[1]; meta[4] |= md[2]; @@ -5741,7 +5949,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) uint8_t cpu_channel = 0; int headroom, tailroom; - DBG_VERB(("Netif Tx: Len=%d priv->id=%d\n", skb->len, priv->id)); + DBG_VERB(("Netif Tx(%s): Len=%d priv->id=%d\n", dev->name, skb->len, priv->id)); if (priv->id <= 0) { /* Do not transmit on base device */ @@ -5779,8 +5987,12 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) /* Account for extra OAM-TS header. */ if ((bkn_skb_tx_flags(skb) & SKBTX_HW_TSTAMP) && (hdrlen > (BKN_DNX_PTCH_2_SIZE))) { - /* T_LOCAL_PORT intf will use PTCH_2 + ITMH */ - hdrlen += BKN_DPP_OTSH_SIZE_BYTE; + /* T_LOCAL_PORT intf will use Module Hdr + PTCH + ITMH + ASE1588 + TSH */ + if (device_is_dnx(sinfo)) { + hdrlen += (BKN_DNX_FTMH_APP_SPECIFIC_EXT_SIZE + BKN_DNX_TSH_SIZE); + } else { + hdrlen += BKN_DPP_OTSH_SIZE_BYTE; + } } } @@ -5871,7 +6083,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) tailroom = FCS_SZ; new_skb = skb_copy_expand(skb, headroom + skb_headroom(skb), - tailroom + skb_tailroom(skb), + tailroom, GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); @@ -5923,7 +6135,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) tailroom = FCS_SZ; new_skb = skb_copy_expand(skb, headroom + skb_headroom(skb), - tailroom + skb_tailroom(skb), + tailroom, GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); @@ -5960,7 +6172,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) tailroom = FCS_SZ; new_skb = skb_copy_expand(skb, headroom + skb_headroom(skb), - tailroom + skb_tailroom(skb), + tailroom, GFP_ATOMIC); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); @@ -6661,6 +6873,7 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) case 36: case 38: case 40: + case 37: info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_RX_HARDWARE | @@ -6675,6 +6888,21 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) info->phc_index = -1; } break; + case 39: /* dnx - q2a, j2c */ + info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | + SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_RX_HARDWARE | + SOF_TIMESTAMPING_RX_SOFTWARE | + SOF_TIMESTAMPING_SOFTWARE | + SOF_TIMESTAMPING_RAW_HARDWARE; + info->tx_types = 1 << HWTSTAMP_TX_OFF | 1 << HWTSTAMP_TX_ON | 1 << HWTSTAMP_TX_ONESTEP_SYNC; + info->rx_filters = 1 << HWTSTAMP_FILTER_NONE | 1 << HWTSTAMP_FILTER_ALL; + if (knet_hw_tstamp_ptp_clock_index_cb) { + info->phc_index = knet_hw_tstamp_ptp_clock_index_cb(sinfo->dev_no); + } else { + info->phc_index = -1; + } + break; default: info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_RX_SOFTWARE | @@ -6688,29 +6916,27 @@ bkn_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,6,0)) -static int bkn_get_link_ksettings(struct net_device *netdev, - struct ethtool_link_ksettings *cmd) +static int +bkn_get_link_ksettings(struct net_device *netdev, + struct ethtool_link_ksettings *cmd) { bkn_priv_t *priv = netdev_priv(netdev); - /* only speed info now, can enhance later */ - if (priv) { - cmd->base.speed = priv->link_settings.speed; - cmd->base.duplex = priv->link_settings.duplex; - } + cmd->base.speed = priv->link_settings.speed; + cmd->base.duplex = priv->link_settings.duplex; + return 0; } -static int bkn_set_link_ksettings(struct net_device *netdev, - const struct ethtool_link_ksettings *cmd) +static int +bkn_set_link_ksettings(struct net_device *netdev, + const struct ethtool_link_ksettings *cmd) { bkn_priv_t *priv = netdev_priv(netdev); - /* only speed info now, can enhance later */ - if (priv) { - priv->link_settings.speed = cmd->base.speed; - priv->link_settings.duplex = cmd->base.speed? DUPLEX_FULL : 0; - } + priv->link_settings.speed = cmd->base.speed; + priv->link_settings.duplex = cmd->base.speed ? DUPLEX_FULL : 0; + return 0; } #endif @@ -6755,7 +6981,6 @@ bkn_init_ndev(u8 *mac, char *name) dev->mtu = rx_buffer_size; } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) - dev->min_mtu = 68; dev->max_mtu = rx_buffer_size; #endif @@ -6778,11 +7003,9 @@ bkn_init_ndev(u8 *mac, char *name) if (name && *name) { strncpy(dev->name, name, IFNAMSIZ-1); } - #if defined(CONFIG_NET_NS) bkn_dev_net_set(dev, current->nsproxy->net_ns); #endif - /* Register the kernel Ethernet device */ if (register_netdev(dev)) { DBG_WARN(("Error registering Ethernet device.\n")); @@ -6909,11 +7132,11 @@ bkn_proc_link_write(struct file *file, const char *buf, struct proc_ops bkn_proc_link_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_link_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_link_write, - .proc_release = single_release, + .proc_open = bkn_proc_link_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_link_write, + .proc_release = single_release, }; /* @@ -7019,11 +7242,11 @@ bkn_proc_rate_write(struct file *file, const char *buf, struct proc_ops bkn_proc_rate_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_rate_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_rate_write, - .proc_release = single_release, + .proc_open = bkn_proc_rate_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_rate_write, + .proc_release = single_release, }; /* @@ -7269,10 +7492,10 @@ bkn_seq_dma_open(struct inode *inode, struct file *file) static struct proc_ops bkn_seq_dma_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_seq_dma_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_release = seq_release + .proc_open = bkn_seq_dma_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = seq_release }; /* @@ -7359,7 +7582,7 @@ bkn_proc_debug_show(struct seq_file *m, void *v) seq_printf(m, " force_tagged: %d\n", force_tagged); seq_printf(m, " ft_tpid: %d\n", ft_tpid); seq_printf(m, " ft_pri: %d\n", ft_pri); - seq_printf(m, " ft_pri: %d\n", ft_cfi); + seq_printf(m, " ft_cfi: %d\n", ft_cfi); seq_printf(m, " ft_tpid: %d\n", ft_vid); seq_printf(m, "Active IOCTLs:\n"); seq_printf(m, " Command: %d\n", ioctl_cmd); @@ -7392,7 +7615,8 @@ bkn_proc_debug_show(struct seq_file *m, void *v) sinfo->oamp_ports[1], sinfo->oamp_ports[2], sinfo->oamp_ports[3]); - + seq_printf(m, " device_id: 0x%x\n", sinfo->device_id); + seq_printf(m, " pcie_status: %d\n", sinfo->pcie_link_status); unit++; } @@ -7406,11 +7630,11 @@ static int bkn_proc_debug_open(struct inode * inode, struct file * file) struct proc_ops bkn_proc_debug_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_debug_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_debug_write, - .proc_release = single_release, + .proc_open = bkn_proc_debug_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_debug_write, + .proc_release = single_release, }; /* @@ -7424,10 +7648,11 @@ bkn_proc_stats_show(struct seq_file *m, void *v) bkn_switch_info_t *sinfo; bkn_filter_t *filter; int chan; - + unsigned long flags; list_for_each(list, &_sinfo_list) { sinfo = (bkn_switch_info_t *)list; + spin_lock_irqsave(&sinfo->lock, flags); seq_printf(m, "Device stats (unit %d):\n", unit); seq_printf(m, " Interrupts %10u\n", sinfo->interrupts); @@ -7455,6 +7680,7 @@ bkn_proc_stats_show(struct seq_file *m, void *v) } unit++; + spin_unlock_irqrestore(&sinfo->lock, flags); } return 0; } @@ -7535,11 +7761,11 @@ bkn_proc_stats_write(struct file *file, const char *buf, struct proc_ops bkn_proc_stats_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_stats_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_stats_write, - .proc_release = single_release, + .proc_open = bkn_proc_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_stats_write, + .proc_release = single_release, }; @@ -7553,9 +7779,11 @@ bkn_proc_dstats_show(struct seq_file *m, void *v) struct list_head *list; bkn_switch_info_t *sinfo; int chan; + unsigned long flags; list_for_each(list, &_sinfo_list) { sinfo = (bkn_switch_info_t *)list; + spin_lock_irqsave(&sinfo->lock, flags); seq_printf(m, "Device debug stats (unit %d):\n", unit); seq_printf(m, " Tx drop no skb %10u\n", @@ -7609,6 +7837,7 @@ bkn_proc_dstats_show(struct seq_file *m, void *v) chan, sinfo->rx[chan].pkts_d_no_api_buf); } unit++; + spin_unlock_irqrestore(&sinfo->lock, flags); } return 0; } @@ -7712,11 +7941,11 @@ bkn_proc_dstats_write(struct file *file, const char *buf, struct proc_ops bkn_proc_dstats_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_dstats_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_dstats_write, - .proc_release = single_release, + .proc_open = bkn_proc_dstats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_dstats_write, + .proc_release = single_release, }; /* @@ -7820,11 +8049,11 @@ bkn_proc_ptp_stats_write(struct file *file, const char *buf, size_t count, loff_ struct proc_ops bkn_proc_ptp_stats_file_ops = { PROC_OWNER(THIS_MODULE) - .proc_open = bkn_proc_ptp_stats_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = bkn_proc_ptp_stats_write, - .proc_release = single_release, + .proc_open = bkn_proc_ptp_stats_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = bkn_proc_ptp_stats_write, + .proc_release = single_release, }; @@ -8316,6 +8545,7 @@ bkn_knet_hw_init(kcom_msg_hw_init_t *kmsg, int len) sinfo->udh_size = kmsg->udh_size; sinfo->oamp_punt = kmsg->oamp_punted; sinfo->no_skip_udh_check = kmsg->no_skip_udh_check; + sinfo->oam_dm_tod_exist = kmsg->oam_dm_tod_exist; sinfo->system_headers_mode = kmsg->system_headers_mode; sinfo->udh_enable = kmsg->udh_enable; } @@ -8505,7 +8735,7 @@ bkn_knet_netif_create(kcom_msg_netif_create_t *kmsg, int len) priv->port = kmsg->netif.port; priv->phys_port = kmsg->netif.phys_port; priv->qnum = kmsg->netif.qnum; - memset(&(priv->link_settings), 0, sizeof(struct ethtool_link_settings));; + memset(&(priv->link_settings), 0, sizeof(struct ethtool_link_settings)); } else { if (device_is_sand(sinfo) && (priv->type == KCOM_NETIF_T_VLAN)) { /* PTCH.SSPA */ @@ -8581,6 +8811,7 @@ bkn_knet_netif_create(kcom_msg_netif_create_t *kmsg, int len) kmsg->netif.id = priv->id; memcpy(kmsg->netif.macaddr, dev->dev_addr, 6); memcpy(kmsg->netif.name, dev->name, KCOM_NETIF_NAME_MAX - 1); + if (knet_netif_create_cb != NULL) { int retv = knet_netif_create_cb(kmsg->hdr.unit, &(kmsg->netif), dev); if (retv) { @@ -8636,11 +8867,18 @@ bkn_knet_netif_destroy(kcom_msg_netif_destroy_t *kmsg, int len) return sizeof(kcom_msg_hdr_t); } - if (knet_netif_destroy_cb != NULL) { - kcom_netif_t netif; - memset(&netif, 0, sizeof(kcom_netif_t)); - netif.id = priv->id; - knet_netif_destroy_cb(kmsg->hdr.unit, &netif, priv->dev); + if (!device_is_sand(sinfo)) { + if (knet_netif_destroy_cb != NULL) { + int retv; + kcom_netif_t netif; + memset(&netif, 0, sizeof(kcom_netif_t)); + netif.id = priv->id; + retv = knet_netif_destroy_cb(kmsg->hdr.unit, &netif, priv->dev); + if (retv) { + gprintk("warning: knet_netif_destroy_cb() returned %d for netif '%s'\n", + retv, priv->dev? priv->dev->name : "unknown"); + } + } } list_del(&priv->list); @@ -9036,6 +9274,27 @@ bkn_knet_wb_cleanup(kcom_msg_wb_cleanup_t *kmsg, int len) return sizeof(kcom_msg_hdr_t); } +static int +bkn_knet_pcie_link_status_set(kcom_msg_pcie_link_status_t*kmsg, int len) +{ + bkn_switch_info_t *sinfo; + unsigned long flags; + + kmsg->hdr.type = KCOM_MSG_TYPE_RSP; + + sinfo = bkn_sinfo_from_unit(kmsg->hdr.unit); + if (sinfo == NULL) { + kmsg->hdr.status = KCOM_E_PARAM; + return sizeof(kcom_msg_hdr_t); + } + + cfg_api_lock(sinfo, &flags); + sinfo->pcie_link_status = kmsg->pcie_link_status; + cfg_api_unlock(sinfo, &flags); + + return sizeof(kcom_msg_hdr_t); +} + static int bkn_handle_cmd_req(kcom_msg_t *kmsg, int len) { @@ -9141,7 +9400,7 @@ bkn_handle_cmd_req(kcom_msg_t *kmsg, int len) /* Clean up for warmbooting */ len = bkn_knet_wb_cleanup(&kmsg->wb_cleanup, len); break; - case KCOM_M_CLOCK_CMD: + case KCOM_M_CLOCK_CMD: /* PHC clock control*/ if (knet_hw_tstamp_ioctl_cmd_cb) { bkn_switch_info_t *sinfo; @@ -9159,6 +9418,11 @@ bkn_handle_cmd_req(kcom_msg_t *kmsg, int len) len = sizeof(kcom_msg_hdr_t); } break; + case KCOM_M_PCIE_LINK_STATUS: + DBG_CMD(("KCOM_M_PCIE_LINK_STATUS\n")); + /* Set PCIE link status */ + len = bkn_knet_pcie_link_status_set(&kmsg->pcie_link_status, len); + break; default: DBG_WARN(("Unsupported command (type=%d, opcode=%d)\n", kmsg->hdr.type, kmsg->hdr.opcode)); @@ -9401,6 +9665,7 @@ bkn_knet_dev_init(int d) /* Initialize default RCPU signature */ if ((bde_dev = kernel_bde->get_dev(d)) != NULL) { sinfo->rcpu_sig = bde_dev->device & ~0xf; + sinfo->device_id= bde_dev->device & ~0xf; } /* Check for override */ if (rcpu_signature) { diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h index 2f15c83c6b17..003495364853 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/bcm-knet.h @@ -75,7 +75,7 @@ typedef int (*knet_hw_tstamp_enable_cb_f)(int dev_no, int phys_port, int tx_type); typedef int -(*knet_hw_tstamp_tx_time_get_cb_f)(int dev_no, int phys_port, uint8_t *pkt, uint64_t *ts); +(*knet_hw_tstamp_tx_time_get_cb_f)(int dev_no, int phys_port, uint8_t *pkt, uint64_t *ts, int tx_type); typedef int (*knet_hw_tstamp_tx_meta_get_cb_f)(int dev_no, int hwts, int hdrlen, struct sk_buff *skb, uint64_t *ts, uint32_t **md); @@ -182,7 +182,6 @@ bkn_netif_destroy_cb_register(knet_netif_cb_f netif_cb); extern int bkn_netif_destroy_cb_unregister(knet_netif_cb_f netif_cb); - #endif #endif /* __LINUX_BCM_KNET_H__ */ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h index 3d66635977b2..7a749a40a9dd 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/lkm.h @@ -42,7 +42,7 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20) #error Kernel too old #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile index 52b776f82b6c..79223a372d47 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/Makefile @@ -35,31 +35,66 @@ include ${SDK}/make/Make.config LIBS = $(LIBDIR)/libkern.a -ifeq ($(kernel_version),2_4) -MODULE = $(LIBDIR)/linux-knet-cb.o -else KERNEL_MODULE_DIR = kernel_module THIS_MOD_NAME := linux-knet-cb MODULE = $(LIBDIR)/$(THIS_MOD_NAME).o KMODULE = $(LIBDIR)/$(THIS_MOD_NAME).ko -build: $(MODULE) $(KMODULE) -endif +# BCM Network Device -KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../bcm-knet/kernel_module/Module.symvers +ifeq (1,$(NO_PRECOMPILED_MODULE)) +# { +KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../bcm-knet/Module.symvers +export KBUILD_EXTRA_SYMBOLS +# +# These are the objects which need to be compiled, in the kernel, to +# created the module object file. +# +SRCS_COMPOSING = knet-cb.c ../shared/gmodule.c +OBJECTS_COMPOSING = "knet-cb.o gmodule.o" -# BCM Network Device +build: $(KMODULE) +# +# Note that for NO_PRECOMPILED_MODULE, the subdirectory 'systems/linux/kernel/modules/knet-cb/kernel_module' +# is not created and all action is done in systems/linux/kernel/modules/knet-cb +# +$(KMODULE): $(SRCS_COMPOSING) + rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) + rm -f $(BLDDIR)/*.c + rm -f $(BLDDIR)/*.o + rm -f $(BLDDIR)/*.ko + cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/Makefile + cp ./*.c $(BLDDIR)/ + cp ../shared/*.c $(BLDDIR)/ + # + # Wait until bcm-knet compilation is over so that we can copy its resultant + # Module.symvers + # + if [ ! -f ${KBUILD_EXTRA_SYMBOLS} ]; then sleep 5; fi + cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/Module.symvers + MOD_OBJS=$(OBJECTS_COMPOSING) MOD_NAME=$(THIS_MOD_NAME) $(MAKE) -C $(BLDDIR) $(THIS_MOD_NAME).ko LOC_BLDDIR=$(BLDDIR) LOC_SRCDIR=$(PWD) +# } +else +# { +KBUILD_EXTRA_SYMBOLS := ${BLDDIR}/../bcm-knet/kernel_module/Module.symvers +export KBUILD_EXTRA_SYMBOLS +build: $(MODULE) $(KMODULE) +# +# This is for the compilation of the 'precompiled' object. We keep it +# here for compatibility. +# $(MODULE): $(BLDDIR)/.tree $(BOBJS) $(LIBS) $(LD) $(MODULE_LDFLAGS) -r -d $(BOBJS) $(LIBS) -o $@ -ifneq ($(kernel_version),2_4) + $(KMODULE): $(MODULE) rm -fr $(BLDDIR)/$(KERNEL_MODULE_DIR) mkdir $(BLDDIR)/$(KERNEL_MODULE_DIR) cp ${SDK}/make/Makefile.linux-kmodule $(BLDDIR)/$(KERNEL_MODULE_DIR)/Makefile cat ${KBUILD_EXTRA_SYMBOLS} > $(BLDDIR)/$(KERNEL_MODULE_DIR)/Module.symvers MOD_NAME=$(THIS_MOD_NAME) KBUILD_EXTRA_SYMBOLS="${KBUILD_EXTRA_SYMBOLS}" $(MAKE) -C $(BLDDIR)/$(KERNEL_MODULE_DIR) $(THIS_MOD_NAME).ko +# } endif # Make.depend is before clean:: so that Make.depend's clean:: runs first. @@ -70,6 +105,4 @@ clean:: $(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o $(RM) $(BOBJS) $(MODULE) -ifneq ($(kernel_version),2_4) .PHONY: build -endif diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c index b420e30a3729..89428e072f6e 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/knet-cb.c @@ -46,7 +46,7 @@ #include /* Enable sflow sampling using psample */ -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT #include "psample-cb.h" #endif @@ -334,7 +334,7 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t *kf) { /* check for filter callback handler */ -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT if (strncmp(kf->desc, PSAMPLE_CB_NAME, strlen(PSAMPLE_CB_NAME)) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -343,21 +343,21 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, } static int -knet_netif_create_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) +knet_netif_create_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) - retv = psample_netif_create_cb(unit, netif, spa, dev); +#ifdef PSAMPLE_SUPPORT + retv = psample_netif_create_cb(unit, netif, dev); #endif return retv; } static int -knet_netif_destroy_cb(int unit, kcom_netif_t *netif, uint16 spa, struct net_device *dev) +knet_netif_destroy_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) - retv = psample_netif_destroy_cb(unit, netif, spa, dev); +#ifdef PSAMPLE_SUPPORT + retv = psample_netif_destroy_cb(unit, netif, dev); #endif return retv; } @@ -367,7 +367,7 @@ knet_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, int chan, kcom_filter_t *kf) { /* check for filter callback handler */ -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT if (strncmp(kf->desc, PSAMPLE_CB_NAME, KCOM_FILTER_DESC_MAX) == 0) { return psample_filter_cb (pkt, size, dev_no, meta, chan, kf); } @@ -379,7 +379,7 @@ static int knet_netif_create_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT retv = psample_netif_create_cb(unit, netif, dev); #endif return retv; @@ -389,7 +389,7 @@ static int knet_netif_destroy_cb(int unit, kcom_netif_t *netif, struct net_device *dev) { int retv = 0; -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT retv = psample_netif_destroy_cb(unit, netif, dev); #endif return retv; @@ -427,7 +427,7 @@ _cleanup(void) bkn_netif_create_cb_unregister(knet_netif_create_cb); bkn_netif_destroy_cb_unregister(knet_netif_destroy_cb); -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT psample_cleanup(); #endif return 0; @@ -445,7 +445,7 @@ _init(void) bkn_tx_skb_cb_register(strip_tag_tx_cb); } -#if IS_ENABLED(CONFIG_PSAMPLE) +#ifdef PSAMPLE_SUPPORT psample_init(); #endif bkn_filter_cb_register(knet_filter_cb); diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c index 2228eb44d5d3..38c5bee6f848 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.c @@ -98,6 +98,14 @@ LKM_MOD_PARAM(psample_qlen, "i", int, 0); MODULE_PARM_DESC(psample_qlen, "psample queue length (default 1024 buffers)"); +#if !IS_ENABLED(CONFIG_PSAMPLE) +inline struct +psample_group *psample_group_get(struct net *net, u32 group_num) +{ + return NULL; +} +#endif + /* driver proc entry root */ static struct proc_dir_entry *psample_proc_root = NULL; static struct proc_dir_entry *knet_cb_proc_root = NULL; @@ -394,7 +402,6 @@ psample_task(struct work_struct *work) unsigned long flags; struct list_head *list_ptr, *list_next; psample_pkt_t *pkt; - struct psample_metadata md = {0}; spin_lock_irqsave(&psample_work->lock, flags); list_for_each_safe(list_ptr, list_next, &psample_work->pkt_list) { @@ -406,18 +413,32 @@ psample_task(struct work_struct *work) /* send to psample */ if (pkt) { +#if ((IS_ENABLED(CONFIG_PSAMPLE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,13,0)) || \ + (defined PSAMPLE_MD_EXTENDED_ATTR && PSAMPLE_MD_EXTENDED_ATTR)) + struct psample_metadata md = {0}; + md.trunc_size = pkt->meta.trunc_size; + md.in_ifindex = pkt->meta.src_ifindex; + md.out_ifindex = pkt->meta.dst_ifindex; +#endif PSAMPLE_CB_DBG_PRINT("%s: group 0x%x, trunc_size %d, src_ifdx 0x%x, dst_ifdx 0x%x, sample_rate %d\n", __func__, pkt->group->group_num, pkt->meta.trunc_size, pkt->meta.src_ifindex, pkt->meta.dst_ifindex, pkt->meta.sample_rate); - md.trunc_size = pkt->meta.trunc_size; - md.in_ifindex = pkt->meta.src_ifindex; - md.out_ifindex = pkt->meta.dst_ifindex; +#if ((IS_ENABLED(CONFIG_PSAMPLE) && LINUX_VERSION_CODE >= KERNEL_VERSION(5,13,0)) || \ + (defined PSAMPLE_MD_EXTENDED_ATTR && PSAMPLE_MD_EXTENDED_ATTR)) psample_sample_packet(pkt->group, pkt->skb, pkt->meta.sample_rate, &md); +#else + psample_sample_packet(pkt->group, + pkt->skb, + pkt->meta.trunc_size, + pkt->meta.src_ifindex, + pkt->meta.dst_ifindex, + pkt->meta.sample_rate); +#endif g_psample_stats.pkts_f_psample_mod++; dev_kfree_skb_any(pkt->skb); @@ -511,7 +532,7 @@ psample_filter_cb(uint8_t * pkt, int size, int dev_no, void *pkt_meta, /* setup skb to point to pkt */ memcpy(skb->data, pkt, meta.trunc_size); skb_put(skb, meta.trunc_size); - skb->len = size; /* SONIC-55684 */ + skb->len = meta.trunc_size; psample_pkt->skb = skb; spin_lock_irqsave(&g_psample_work.lock, flags); @@ -1016,7 +1037,7 @@ int psample_init(void) struct proc_dir_entry *entry; /* create procfs for psample */ - proc_mkdir(PSAMPLE_PROCFS_PATH, NULL); + knet_cb_proc_root = proc_mkdir(PSAMPLE_PROCFS_PATH, NULL); snprintf(psample_procfs_path, sizeof(psample_procfs_path), "%s/%s", PSAMPLE_PROCFS_PATH, PSAMPLE_CB_NAME); psample_proc_root = proc_mkdir(psample_procfs_path, NULL); diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.h index 8f9398c51692..40408819ef74 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/knet-cb/psample-cb.h @@ -42,7 +42,7 @@ typedef struct { struct list_head list; struct net_device *dev; uint16 id; - uint8 port; + uint16 port; uint16 vlan; uint16 qnum; uint32 sample_rate; diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c index df6e2d6bb681..fd43ee5bd726 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/gmodule.c @@ -141,11 +141,11 @@ static int _gmodule_proc_release(struct inode * inode, struct file * file) { struct proc_ops _gmodule_proc_fops = { PROC_OWNER(THIS_MODULE) - .proc_open = _gmodule_proc_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_write = _gmodule_proc_write, - .proc_release = _gmodule_proc_release, + .proc_open = _gmodule_proc_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_write = _gmodule_proc_write, + .proc_release = _gmodule_proc_release, }; #else int diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c index 9c093e0eacdf..c4a9f9ce309a 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/ksal.c @@ -192,9 +192,9 @@ uint32 sal_time_usecs(void) { #if !defined(SAI_FIXUP) - struct timeval ltv; - do_gettimeofday(<v); - return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec); + struct timeval ltv; + do_gettimeofday(<v); + return (ltv.tv_sec * SECOND_USEC + ltv.tv_usec); #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(4,19,0) /* ktime_to_us and ktime_get_real_ns return 64-bit integets, but this */ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile index a72dba96f6e2..fe1b6fd08cea 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile @@ -144,6 +144,7 @@ endif ifdef BUILD_PSAMPLE ADD_TO_CFLAGS += -DPSAMPLE_SUPPORT endif + ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include COND_KNET_LIBS = libuser.$(libext) endif @@ -204,7 +205,7 @@ clean:: subdirs="shared bcm-knet knet-cb" \ override-target=linux-$(platform) $@ $(RM) $(KERNEL_BDE) $(USER_BDE) - $(RM) $(BCM_KNET) $(KNET_CB) $(PSAMPLE) + $(RM) $(BCM_KNET) $(KNET_CB) $(RM) $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) $(RM) $(KERN_BLDROOT)/linux-user-bde.$(KOBJ) $(RM) $(KERN_BLDROOT)/linux-bcm-knet.$(KOBJ) diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile index d02c97e3f906..921ce62ebaf0 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/gts/Makefile @@ -62,7 +62,7 @@ endif export SDK -override kernel_version=5_4 +override kernel_version=5_10 platform=gts LINUX_MAKE_USER=1 diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile index 377cf43ab68b..a5b0dadf8e6e 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/xlr/Makefile @@ -62,7 +62,7 @@ endif export SDK -override kernel_version=5_4 +override kernel_version=5_10 platform=xlr LINUX_MAKE_USER=1 diff --git a/platform/components/docker-gbsyncd-credo.mk b/platform/components/docker-gbsyncd-credo.mk index 34f7101759eb..2181add0f9c3 100644 --- a/platform/components/docker-gbsyncd-credo.mk +++ b/platform/components/docker-gbsyncd-credo.mk @@ -1,9 +1,9 @@ DOCKER_GBSYNCD_PLATFORM_CODE = credo -LIBSAI_CREDO = libsaicredo_0.8.2_amd64.deb -$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.8.2_amd64.deb?sv=2021-04-10&st=2023-01-31T04%3A24%3A23Z&se=2100-01-31T04%3A24%3A00Z&sr=b&sp=r&sig=RZPbmaIetvDRtwifrVT4s%2FaQxB%2FBTOyCqXtMtoNRjmY%3D" -LIBSAI_CREDO_OWL = libsaicredo-owl_0.8.2_amd64.deb -$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.8.2_amd64.deb?sv=2021-04-10&st=2023-01-31T04%3A25%3A43Z&se=2100-01-31T04%3A25%3A00Z&sr=b&sp=r&sig=%2BdSFujwy0gY%2FiH50Ffi%2FsqZOAHBOFPUcBdR06fHEZkI%3D" +LIBSAI_CREDO = libsaicredo_0.9.3_amd64.deb +$(LIBSAI_CREDO)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo_0.9.3_amd64.deb?sv=2021-04-10&st=2023-10-12T02%3A21%3A05Z&se=2031-10-13T02%3A21%3A00Z&sr=b&sp=r&sig=UXC%2FYKm%2BvHRjGmM3xjnFMQzY%2BMpxhKtMxNHQPdwvtN8%3D" +LIBSAI_CREDO_OWL = libsaicredo-owl_0.9.3_amd64.deb +$(LIBSAI_CREDO_OWL)_URL = "https://sonicstorage.blob.core.windows.net/packages/credosai/libsaicredo-owl_0.9.3_amd64.deb?sv=2021-04-10&st=2023-10-12T02%3A21%3A51Z&se=2031-10-13T02%3A21%3A00Z&sr=b&sp=r&sig=olu3%2Bq5eJYRtXCygJWgKUx%2FdlrlB%2FWE0i9ruftYdB7g%3D" ifneq ($($(LIBSAI_CREDO)_URL),) include $(PLATFORM_PATH)/../template/docker-gbsyncd-base.mk diff --git a/platform/marvell-arm64/mrvl-prestera b/platform/marvell-arm64/mrvl-prestera new file mode 160000 index 000000000000..a5e93cbd8d90 --- /dev/null +++ b/platform/marvell-arm64/mrvl-prestera @@ -0,0 +1 @@ +Subproject commit a5e93cbd8d90c767891e9ad56447b1047cfa558a diff --git a/platform/marvell-arm64/prestera.mk b/platform/marvell-arm64/mrvl-prestera.mk similarity index 54% rename from platform/marvell-arm64/prestera.mk rename to platform/marvell-arm64/mrvl-prestera.mk index fc7debaf5d06..6a3f4df2a543 100644 --- a/platform/marvell-arm64/prestera.mk +++ b/platform/marvell-arm64/mrvl-prestera.mk @@ -1,11 +1,8 @@ -# Marvell Prestera - +# Marvell Prestera platform package export MRVL_PRESTERA_VER = 1.0 export MRVL_PRESTERA = mrvlprestera_$(MRVL_PRESTERA_VER)_$(PLATFORM_ARCH) export MRVL_PRESTERA_DEB = $(MRVL_PRESTERA).deb -export MRVL_PRESTERA_SRC_URL = https://github.com/Marvell-switching/mrvl-prestera.git -export MRVL_PRESTERA_SRC_TAG = MRVL_PRESTERA_DRIVER_1.3 -$(MRVL_PRESTERA_DEB)_SRC_PATH = $(PLATFORM_PATH)/prestera +$(MRVL_PRESTERA_DEB)_SRC_PATH = $(PLATFORM_PATH)/mrvl-prestera $(MRVL_PRESTERA_DEB)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_COMMON) SONIC_DPKG_DEBS += $(MRVL_PRESTERA_DEB) diff --git a/platform/marvell-arm64/platform.conf b/platform/marvell-arm64/platform.conf index a40e16a390d8..9e2a0cd8eeda 100644 --- a/platform/marvell-arm64/platform.conf +++ b/platform/marvell-arm64/platform.conf @@ -48,7 +48,7 @@ else fit_addr=0x8000000 initrd_addr=0x2000000 - fdt_fname="/boot/armada-7020-comexpress.dtb" + fdt_fname="/usr/lib/linux-image-$kernel_version/marvell/armada-7020-comexpress.dtb" FW_ENV_DEFAULT='/dev/mtd1 0x0 0x10000 0x100000' demo_part=1 @@ -194,8 +194,8 @@ prepare_boot_menu() { BORDER='echo "---------------------------------------------------";echo;' fw_setenv ${FW_ARG} print_menu $BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER > /dev/null - fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG ${extra_cmdline_linux} loglevel=4" > /dev/null - fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG loglevel=4" > /dev/null + fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG ${ONIE_PLATFORM_EXTRA_CMDLINE_LINUX}" > /dev/null + fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG ${ONIE_PLATFORM_EXTRA_CMDLINE_LINUX}" > /dev/null sonic_bootargs_old='setenv bootargs root='$demo_dev' rw rootwait rootfstype=ext4 panic=1 console=ttyS0,${baudrate} ${othbootargs} ${mtdparts} ${linuxargs_old}' fw_setenv ${FW_ARG} sonic_bootargs_old $sonic_bootargs_old > /dev/null || true sonic_boot_load_old=$(fw_printenv -n sonic_boot_load || true) diff --git a/platform/marvell-arm64/prestera/debian/changelog b/platform/marvell-arm64/prestera/debian/changelog deleted file mode 100644 index 3e1e97802c2f..000000000000 --- a/platform/marvell-arm64/prestera/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -mrvlprestera (1.0) unstable; urgency=low - - * Prestera switch driver - - -- Marvell Fri, 19 Feb 2021 10:39:18 +0800 diff --git a/platform/marvell-arm64/prestera/debian/compat b/platform/marvell-arm64/prestera/debian/compat deleted file mode 100644 index ec635144f600..000000000000 --- a/platform/marvell-arm64/prestera/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/platform/marvell-arm64/prestera/debian/control b/platform/marvell-arm64/prestera/debian/control deleted file mode 100644 index 33a96b991d24..000000000000 --- a/platform/marvell-arm64/prestera/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: mrvlprestera -Section: unknown -Priority: optional -Maintainer: Marvell -Build-Depends: debhelper (>=9) -Standards-Version: 3.9.6 -Homepage: -#Vcs-Git: git://anonscm.debian.org/collab-maint/mrvlprestera.git -#Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/mrvlprestera.git - -Package: mrvlprestera -Architecture: arm64 -Homepage: -Description: - kernel modules for prestera switch driver diff --git a/platform/marvell-arm64/prestera/debian/mrvlprestera.install.template b/platform/marvell-arm64/prestera/debian/mrvlprestera.install.template deleted file mode 100644 index 5747270e57ea..000000000000 --- a/platform/marvell-arm64/prestera/debian/mrvlprestera.install.template +++ /dev/null @@ -1,3 +0,0 @@ -mrvl-prestera/drivers/generic/cpssEnabler/linuxNoKernelModule/drivers/mvMbusDrv.ko /lib/modules/KVERSION/kernel/extra -mrvl-prestera/drivers/generic/cpssEnabler/linuxNoKernelModule/drivers/mvIntDrv.ko /lib/modules/KVERSION/kernel/extra -mrvl-prestera/platform/arm64/* / diff --git a/platform/marvell-arm64/prestera/debian/rules b/platform/marvell-arm64/prestera/debian/rules deleted file mode 100755 index bf223af19b74..000000000000 --- a/platform/marvell-arm64/prestera/debian/rules +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/make -f - -include /usr/share/dpkg/pkg-info.mk - -PACKAGE_PRE_NAME := mrvlprestera -ifneq ($(CROSS_BUILD_ENVIRON), y) -KVERSION ?= $(shell uname -r) -endif -KERNEL_SRC := /lib/modules/$(KVERSION) -MOD_SRC_DIR:= $(shell pwd) -MODULE_DIR := mrvl-prestera/drivers/generic/cpssEnabler/linuxNoKernelModule/drivers - -%: - dh $@ --with systemd,python2,python3 --buildsystem=pybuild - -clean: - dh_testdir - dh_testroot - dh_clean - -build: - # get sources - rm -rf mrvl-prestera || true - git clone ${MRVL_PRESTERA_SRC_URL} - cd mrvl-prestera && git checkout ${MRVL_PRESTERA_SRC_TAG} && cd .. - sed "s/KVERSION/${KVERSION}/g" /sonic/platform/marvell-arm64/prestera/debian/mrvlprestera.install.template > /sonic/platform/marvell-arm64/prestera/debian/mrvlprestera.install - - make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$(MODULE_DIR)/ - -binary: binary-arch binary-indep - # Nothing to do - -binary-arch: - # Nothing to do - -binary-indep: - dh_testdir - dh_installdirs - - # Resuming debhelper scripts - dh_testroot - dh_install - dh_installchangelogs - dh_installdocs - dh_systemd_enable - dh_installinit - dh_systemd_start - dh_link - dh_fixperms - dh_compress - dh_strip - dh_installdeb - dh_gencontrol - dh_md5sums - dh_builddeb -.PHONY: build binary binary-arch binary-indep clean diff --git a/platform/marvell-arm64/rules.mk b/platform/marvell-arm64/rules.mk index 0e8e18d14cf6..15d5071e1f89 100644 --- a/platform/marvell-arm64/rules.mk +++ b/platform/marvell-arm64/rules.mk @@ -5,7 +5,7 @@ include $(PLATFORM_PATH)/docker-syncd-mrvl-rpc.mk include $(PLATFORM_PATH)/docker-saiserver-mrvl.mk include $(PLATFORM_PATH)/libsaithrift-dev.mk include $(PLATFORM_PATH)/one-image.mk -include $(PLATFORM_PATH)/prestera.mk +include $(PLATFORM_PATH)/mrvl-prestera.mk include $(PLATFORM_PATH)/platform-nokia.mk SONIC_ALL += $(SONIC_ONE_IMAGE) \ diff --git a/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215-init.sh b/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215-init.sh index aaaa47eb92ec..deecbe068232 100644 --- a/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215-init.sh +++ b/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215-init.sh @@ -4,9 +4,9 @@ # Load required kernel-mode drivers load_kernel_drivers() { - echo "Loading Kernel Drivers" - sudo insmod /lib/modules/5.10.0-23-2-arm64/nokia_7215_ixs_a1_cpld.ko - sudo insmod /lib/modules/5.10.0-23-2-arm64/ac5_thermal_sensor.ko + echo "Loading Kernel Drivers" + sudo insmod /lib/modules/5.10.0-23-2-arm64/kernel/extra/nokia_7215_ixs_a1_cpld.ko + sudo insmod /lib/modules/5.10.0-23-2-arm64/kernel/extra/ac5_thermal_sensor.ko } nokia_7215_profile() diff --git a/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215_plt_setup.sh b/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215_plt_setup.sh deleted file mode 100644 index b7a6022e607b..000000000000 --- a/platform/marvell-arm64/sonic-platform-nokia/7215/scripts/nokia-7215_plt_setup.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -fw_uboot_env_cfg() -{ - echo "Setting up U-Boot environment..." - MACH_FILE="/host/machine.conf" - PLATFORM=`sed -n 's/onie_platform=\(.*\)/\1/p' $MACH_FILE` - - FW_ENV_DEFAULT='/dev/mtd0 0x400000 0x10000 0x10000' - - echo $FW_ENV_DEFAULT > /etc/fw_env.config -} - -update_modulelist() -{ - MODULE_FILE="/etc/modules-load.d/marvell.conf" - if grep -Fxq "mvMbusDrv" $MODULE_FILE - then - echo "Module list up to date" - else - echo "mvMbusDrv" >> $MODULE_FILE - modprobe mvMbusDrv - fi - -} - -main() -{ - fw_uboot_env_cfg - update_modulelist -} - -main $@ diff --git a/platform/marvell-arm64/sonic-platform-nokia/debian/rules b/platform/marvell-arm64/sonic-platform-nokia/debian/rules index aa8ba7955152..27015185a1a7 100755 --- a/platform/marvell-arm64/sonic-platform-nokia/debian/rules +++ b/platform/marvell-arm64/sonic-platform-nokia/debian/rules @@ -11,10 +11,13 @@ ifneq ($(CROSS_BUILD_ENVIRON), y) KVERSION ?= $(shell uname -r) endif KERNEL_SRC := /lib/modules/$(KVERSION) +INSTALL_MOD_DIR := kernel/extra/ MOD_SRC_DIR:= $(shell pwd) MODULE_DIRS:= 7215 UTILS_DIR := utils MODULE_DIR:= modules +MRVL_MODULE_DIR:= mrvl-modules +PRESTERA_MODULE_SRC := mrvl-prestera/drivers/generic/cpssEnabler/linuxNoKernelModule/drivers SERVICE_DIR := service PLATFORM_DIR := sonic_platform @@ -28,6 +31,12 @@ clean: build: (for mod in $(MODULE_DIRS); do \ + cd $(MOD_SRC_DIR)/../$(PRESTERA_MODULE_SRC)/; \ + make clean; \ + make modules -C $(KERNEL_SRC)/build M=`pwd` CONFIG_KM_MVMBUS=y CONFIG_KM_MVINT=y || exit 1; \ + mkdir $(MOD_SRC_DIR)/$${mod}/$(MRVL_MODULE_DIR); \ + cp *.ko $(MOD_SRC_DIR)/$${mod}/$(MRVL_MODULE_DIR)/; \ + cd $(MOD_SRC_DIR); \ make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules || exit 1; \ python3 $${mod}/setup.py bdist_wheel -d $(MOD_SRC_DIR)/$${mod}; \ done) @@ -50,6 +59,7 @@ binary-indep: dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} /lib/systemd/system; \ cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \ cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \ + cp $(MOD_SRC_DIR)/$${mod}/$(MRVL_MODULE_DIR)/mvcpss.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \ python3 $${mod}/setup.py install --root=$(MOD_SRC_DIR)/debian/$(PACKAGE_PRE_NAME)-$${mod} --install-layout=deb; \ done) diff --git a/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install b/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install index 8bfbd8efd92d..ec9e8d9f6086 100644 --- a/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install +++ b/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.install @@ -1,4 +1,4 @@ -7215/scripts/nokia-7215_plt_setup.sh usr/local/bin 7215/scripts/nokia-7215-init.sh usr/local/bin 7215/service/nokia-7215init.service etc/systemd/system 7215/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/arm64-nokia_ixs7215_52xb-r0 +../mrvl-prestera/platform/arm64/ac5x/* / diff --git a/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.postinst b/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.postinst index 4cd13f5b0d2c..e48b6feee769 100644 --- a/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.postinst +++ b/platform/marvell-arm64/sonic-platform-nokia/debian/sonic-platform-nokia-7215.postinst @@ -20,8 +20,9 @@ set -e case "$1" in configure) - sh /usr/local/bin/nokia-7215_plt_setup.sh chmod a+x /usr/local/bin/nokia-7215-init.sh + depmod -a + systemctl restart kmod systemctl enable nokia-7215init.service systemctl start nokia-7215init.service diff --git a/platform/marvell-arm64/sonic_fit.its b/platform/marvell-arm64/sonic_fit.its index 63590ffd7fc0..c4be07c76fb2 100644 --- a/platform/marvell-arm64/sonic_fit.its +++ b/platform/marvell-arm64/sonic_fit.its @@ -20,7 +20,7 @@ }; fdt_ac5x { description = "Flattened Device Tree blob for AC5x"; - data = /incbin/("/boot/ac5x.dtb"); + data = /incbin/("/usr/lib/linux-image-5.10.0-23-2-arm64/marvell/ac5-98dx35xx-rd.dtb"); type = "flat_dt"; arch = "arm64"; compression = "none"; diff --git a/platform/marvell-armhf/platform.conf b/platform/marvell-armhf/platform.conf index 7d551b21f4d2..c3b7c0895931 100644 --- a/platform/marvell-armhf/platform.conf +++ b/platform/marvell-armhf/platform.conf @@ -176,7 +176,8 @@ prepare_boot_menu() { fi BORDER='echo "---------------------------------------------------";echo;' fw_setenv ${FW_ARG} print_menu "$BORDER $BOOT1 $BOOT2 $BOOT3 $BORDER" > /dev/null - fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4 ${extra_cmdline_linux} ${ONIE_PLATFORM_EXTRA_CMDLINE_LINUX}" > /dev/null + + fw_setenv ${FW_ARG} linuxargs "net.ifnames=0 loopfstype=squashfs loop=$image_dir/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4 ${extra_cmdline_linux}" > /dev/null fw_setenv ${FW_ARG} linuxargs_old "net.ifnames=0 loopfstype=squashfs loop=$image_dir_old/$FILESYSTEM_SQUASHFS systemd.unified_cgroup_hierarchy=0 varlog_size=$VAR_LOG_SIZE loglevel=4" > /dev/null # Set boot configs diff --git a/platform/marvell/sai.mk b/platform/marvell/sai.mk index 602f922968bd..231bdfc810a7 100644 --- a/platform/marvell/sai.mk +++ b/platform/marvell/sai.mk @@ -1,6 +1,6 @@ # Marvell SAI -export MRVL_SAI_VERSION = 1.8.1-1 +export MRVL_SAI_VERSION = 1.13.0-1 export MRVL_SAI = mrvllibsai_amd64_$(MRVL_SAI_VERSION).deb $(MRVL_SAI)_SRC_PATH = $(PLATFORM_PATH)/sai diff --git a/platform/mellanox/integration-scripts.mk b/platform/mellanox/integration-scripts.mk index ef681e8a73a5..e902a1f06e80 100644 --- a/platform/mellanox/integration-scripts.mk +++ b/platform/mellanox/integration-scripts.mk @@ -25,7 +25,6 @@ TEMP_HW_MGMT_DIR = /tmp/hw_mgmt PTCH_DIR = $(TEMP_HW_MGMT_DIR)/patch_dir/ NON_UP_PTCH_DIR = $(TEMP_HW_MGMT_DIR)/non_up_patch_dir/ PTCH_LIST = $(TEMP_HW_MGMT_DIR)/series -KCFG_LIST = $(TEMP_HW_MGMT_DIR)/kconfig HWMGMT_NONUP_LIST = $(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hwmgmt_nonup_patches HWMGMT_USER_OUTFILE = $(BUILD_WORKDIR)/integrate-mlnx-hw-mgmt_user.out SDK_USER_OUTFILE = $(BUILD_WORKDIR)/integrate-mlnx-sdk_user.out @@ -36,11 +35,33 @@ SLK_COM_MSG := $(shell mktemp -t slk_commit_msg_file_XXXXX.log) SB_HEAD = $(shell git rev-parse --short HEAD) SLK_HEAD = $(shell cd src/sonic-linux-kernel; git rev-parse --short HEAD) +# kconfig related variables +KCFG_BASE_TMPDIR = $(TEMP_HW_MGMT_DIR)/linux_kconfig/ +KCFG_BASE = $(KCFG_BASE_TMPDIR)/amd64.config +KCFG_LIST = $(TEMP_HW_MGMT_DIR)/kconfig_amd64 +KCFG_DOWN_LIST = $(TEMP_HW_MGMT_DIR)/kconfig_downstream_amd64 +KCFG_BASE_ARM = $(KCFG_BASE_TMPDIR)/arm64.config +KCFG_LIST_ARM = $(TEMP_HW_MGMT_DIR)/kconfig_arm64 +KCFG_DOWN_LIST_ARM = $(TEMP_HW_MGMT_DIR)/kconfig_downstream_arm64 + + integrate-mlnx-hw-mgmt: $(FLUSH_LOG) rm -rf $(TEMP_HW_MGMT_DIR) $(TMPFILE_OUT) - mkdir -p $(PTCH_DIR) $(NON_UP_PTCH_DIR) - touch $(PTCH_LIST) $(KCFG_LIST) + mkdir -p $(PTCH_DIR) $(NON_UP_PTCH_DIR) $(KCFG_BASE_TMPDIR) + touch $(PTCH_LIST) $(KCFG_LIST) $(KCFG_DOWN_LIST) $(KCFG_LIST_ARM) $(KCFG_DOWN_LIST_ARM) + + # Fetch the vanilla .config files + pushd $(KCFG_BASE_TMPDIR) $(LOG_SIMPLE) + rm -rf linux/; mkdir linux + # Note: gregkh is the stable linux mirror + git clone --depth 1 --branch v$(KERNEL_VERSION) https://github.com/gregkh/linux.git linux $(LOG_SIMPLE) + + pushd linux + rm -rf .config; make ARCH=x86_64 defconfig; cp -f .config $(KCFG_BASE) $(LOG_SIMPLE) + rm -rf .config; make ARCH=arm64 defconfig; cp -f .config $(KCFG_BASE_ARM) $(LOG_SIMPLE) + popd + popd $(LOG_SIMPLE) # clean up existing untracked files pushd $(BUILD_WORKDIR); git clean -f -- platform/mellanox/ @@ -69,17 +90,32 @@ endif # Pre-processing before runing hw_mgmt script integration-scripts/hwmgmt_kernel_patches.py pre \ - --config_inclusion $(KCFG_LIST) \ + --config_base_amd $(KCFG_BASE) \ + --config_base_arm $(KCFG_BASE_ARM) \ + --config_inc_amd $(KCFG_LIST) \ + --config_inc_arm $(KCFG_LIST_ARM) \ --build_root $(BUILD_WORKDIR) \ --kernel_version $(KERNEL_VERSION) \ - --hw_mgmt_ver ${MLNX_HW_MANAGEMENT_VERSION} $(LOG_SIMPLE) + --hw_mgmt_ver ${MLNX_HW_MANAGEMENT_VERSION} $(LOG_SIMPLE) + $(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hw-mgmt/recipes-kernel/linux/deploy_kernel_patches.py \ + --dst_accepted_folder $(PTCH_DIR) \ + --dst_candidate_folder $(NON_UP_PTCH_DIR) \ + --series_file $(PTCH_LIST) \ + --config_file $(KCFG_LIST_ARM) \ + --config_file_downstream $(KCFG_DOWN_LIST_ARM) \ + --kernel_version $(KERNEL_VERSION) \ + --arch arm64 \ + --os_type sonic $(LOG_SIMPLE) + $(BUILD_WORKDIR)/$($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hw-mgmt/recipes-kernel/linux/deploy_kernel_patches.py \ --dst_accepted_folder $(PTCH_DIR) \ --dst_candidate_folder $(NON_UP_PTCH_DIR) \ --series_file $(PTCH_LIST) \ --config_file $(KCFG_LIST) \ + --config_file_downstream $(KCFG_DOWN_LIST) \ --kernel_version $(KERNEL_VERSION) \ + --arch amd64 \ --os_type sonic $(LOG_SIMPLE) # Post-processing @@ -88,7 +124,12 @@ endif --non_up_patches $(NON_UP_PTCH_DIR) \ --kernel_version $(KERNEL_VERSION) \ --hw_mgmt_ver ${MLNX_HW_MANAGEMENT_VERSION} \ - --config_inclusion $(KCFG_LIST) \ + --config_base_amd $(KCFG_BASE) \ + --config_base_arm $(KCFG_BASE_ARM) \ + --config_inc_amd $(KCFG_LIST) \ + --config_inc_arm $(KCFG_LIST_ARM) \ + --config_inc_down_amd $(KCFG_DOWN_LIST) \ + --config_inc_down_arm $(KCFG_DOWN_LIST_ARM) \ --series $(PTCH_LIST) \ --current_non_up_patches $(HWMGMT_NONUP_LIST) \ --build_root $(BUILD_WORKDIR) \ @@ -121,8 +162,11 @@ endif git add -- $(PLATFORM_PATH)/non-upstream-patches/ git add -- $(PLATFORM_PATH)/hw-management.mk - echo -en '\n###-> Non Upstream series.patch changes <-###\n' >> ${HWMGMT_USER_OUTFILE} - git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/series.patch >> ${HWMGMT_USER_OUTFILE} + echo -en '\n###-> Non Upstream external-changes.patch changes <-###\n' >> ${HWMGMT_USER_OUTFILE} + git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/external-changes.patch >> ${HWMGMT_USER_OUTFILE} + + echo -en '\n###-> Non Upstream kconfig-inclusions.patch changes <-###\n' >> ${HWMGMT_USER_OUTFILE} + git diff --no-color --staged -- $(PLATFORM_PATH)/non-upstream-patches/kconfig-inclusions.patch >> ${HWMGMT_USER_OUTFILE} echo -en '\n###-> Non Upstream patch list file <-###\n' >> ${HWMGMT_USER_OUTFILE} git diff --no-color --staged -- $($(MLNX_HW_MANAGEMENT)_SRC_PATH)/hwmgmt_nonup_patches >> ${HWMGMT_USER_OUTFILE} @@ -142,6 +186,8 @@ endif popd $(LOG_SIMPLE) + rm -rf $(TEMP_HW_MGMT_DIR) + integrate-mlnx-sdk: $(FLUSH_LOG) rm -rf $(MLNX_SDK_VERSION).zip sx_kernel-$(MLNX_SDK_VERSION)-$(MLNX_SDK_ISSU_VERSION).tar.gz diff --git a/platform/mellanox/integration-scripts/helper.py b/platform/mellanox/integration-scripts/helper.py index a8ebbe24cd6d..6c2cb3599834 100644 --- a/platform/mellanox/integration-scripts/helper.py +++ b/platform/mellanox/integration-scripts/helper.py @@ -17,10 +17,12 @@ import os import glob -import re +from collections import OrderedDict MARK_ID = "###->" -MLNX_KFG_MARKER = "mellanox" +MLNX_KFG_MARKER = "mellanox_amd64" +MLNX_NOARCH_MARKER = "mellanox_common" +MLNX_ARM_KFG_SECTION = "mellanox-arm64" SDK_MARKER = "mellanox_sdk" HW_MGMT_MARKER = "mellanox_hw_mgmt" SLK_PATCH_LOC = "src/sonic-linux-kernel/patch/" @@ -29,7 +31,7 @@ SLK_SERIES = SLK_PATCH_LOC + "series" NON_UP_PATCH_DIR = "platform/mellanox/non-upstream-patches/" NON_UP_PATCH_LOC = NON_UP_PATCH_DIR + "patches" -NON_UP_PATCH_DIFF = NON_UP_PATCH_DIR + "series.patch" +NON_UP_DIFF = NON_UP_PATCH_DIR + "external-changes.patch" KCFG_HDR_RE = "\[(.*)\]" KERNEL_BACKPORTS = "kernel_backports" # kconfig_inclusion headers to consider @@ -100,83 +102,35 @@ def find_marker_indices(lines: list, marker=None) -> tuple: return (i_start, i_end) @staticmethod - def read_kconfig_inclusion(path, marker=MLNX_KFG_MARKER): - lines = FileHandler.read_strip(path) - if not marker: - return lines - i_start, i_end = FileHandler.find_marker_indices(lines, marker) - - if i_start < 0 or i_end >= len(lines): - print("-> WARNING No Marker Found") - return [] - - return lines[i_start+1:i_end] - - @staticmethod - def write_lines_marker(path, writable_opts: list, marker=None): - # if marker is none, just write the opts into the file, - # otherwise write the data only b/w the marker - curr_data = FileHandler.read_raw(path) - i_start, i_end = FileHandler.find_marker_indices(curr_data, marker) - newline_writ_opts = [opt + "\n" for opt in writable_opts] - if i_start < 0 or i_end >= len(curr_data): - print("-> WARNING No Marker Found, writing data at the end of file") - curr_data.extend(["\n"]) - curr_data.extend(newline_writ_opts) - else: - curr_data = curr_data[0:i_start+1] + newline_writ_opts + curr_data[i_end:] - - print("-> INFO Written the following opts: \n{}".format("".join(FileHandler.read_raw(path)))) - FileHandler.write_lines(path, curr_data, True) - - @staticmethod - def read_kconfig_parser(path) -> dict: - # kconfig_inclusion output formatted to {"no_parent", "common":[,], "amd64": [,], "arm64": [,]} + def read_kconfig(path) -> dict: + # read the .config file generated during kernel compilation lines = FileHandler.read_strip_minimal(path) - ret = dict({"no_parent":[]}) - curr_hdr = "" + config_data = OrderedDict() for line in lines: - match = re.search(KCFG_HDR_RE, line) - if match: - curr_hdr = match.group(1) - ret[curr_hdr] = [] - elif curr_hdr in ret: - ret[curr_hdr].append(line) - else: - ret["no_parent"].append(line) - return ret - - -class KCFG: + if line.strip().startswith("#"): + continue + tokens = line.strip().split('=') + if len(tokens) == 2: + key = tokens[0].strip() + value = tokens[1].strip() + config_data[key] = value + return config_data @staticmethod - def parse_opt_str(opt: str) -> tuple: - if not opt.startswith("CONFIG"): - print("-> DEBUG: Malformed kconfig opt, {}".format(opt)) - return () - - tmp = opt.split("=") - if len(tmp) != 2: - print("-> DEBUG: Malformed kconfig opt, {}".format(opt)) - return () - - return (tmp[0], tmp[1]) - + def insert_lines(lines: list, start: int, end: int, new_data: list) -> list: + return lines[0:start+1] + new_data + lines[end:] + @staticmethod - def parse_opts_strs(kcfg_sec: list) -> list(tuple()): - opts = [] # list of tuples (CONFIG_*, "m|y|n") - for kcfg in kcfg_sec: - tmp = KCFG.parse_opt_str(kcfg) - if tmp: - opts.append(tmp) - return opts - + def insert_kcfg_data(lines: list, start: int, end: int, new_data: OrderedDict) -> dict: + # inserts data into the lines, escape every lines + new_data_lines = ["{}={}\n".format(cfg, val) for (cfg, val) in new_data.items()] + return FileHandler.insert_lines(lines, start, end, new_data_lines) + @staticmethod - def get_writable_opts(opts): - lines = [] - for opt in opts: - lines.append("{}={}".format(opt[0], opt[1])) - return lines + def insert_kcfg_excl_data(lines: list, start: int, end: int, new_data: OrderedDict) -> dict: + # inserts data into the lines, escape every lines + new_data_lines = ["{}\n".format(cfg) for (cfg, val) in new_data.items()] + return FileHandler.insert_lines(lines, start, end, new_data_lines) class Action(): diff --git a/platform/mellanox/integration-scripts/hwmgmt_helper.py b/platform/mellanox/integration-scripts/hwmgmt_helper.py new file mode 100644 index 000000000000..9dd9cf87a832 --- /dev/null +++ b/platform/mellanox/integration-scripts/hwmgmt_helper.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python +# +# Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. +# Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import os +import io +import sys +import argparse +import shutil +import copy +import difflib +import configparser + +from helper import * + +################################################################################ +#### KConfig Processing #### +################################################################################ + +class KCFGData: + x86_base = OrderedDict() + x86_updated = OrderedDict() + arm_base = OrderedDict() + arm_updated = OrderedDict() + x86_incl = OrderedDict() + arm_incl = OrderedDict() + x86_excl = OrderedDict() + arm_excl = OrderedDict() + x86_down = OrderedDict() + arm_down = OrderedDict() + noarch_incl = OrderedDict() + noarch_excl = OrderedDict() + noarch_down = OrderedDict() + + +class KConfigTask(): + def __init__(self, args): + self.args = args + + + def read_data(self): + KCFGData.x86_base = FileHandler.read_kconfig(self.args.config_base_amd) + KCFGData.x86_updated = FileHandler.read_kconfig(self.args.config_inc_amd) + if os.path.isfile(self.args.config_inc_down_amd): + print(" -> Downstream Config for x86 found..") + KCFGData.x86_down = FileHandler.read_kconfig(self.args.config_inc_down_amd) + + KCFGData.arm_base = FileHandler.read_kconfig(self.args.config_base_arm) + KCFGData.arm_updated = FileHandler.read_kconfig(self.args.config_inc_arm) + if os.path.isfile(self.args.config_inc_down_arm): + print(" -> Downstream Config for arm64 found..") + KCFGData.arm_down = FileHandler.read_kconfig(self.args.config_inc_down_arm) + return + + + def parse_inc_exc(self, base: OrderedDict, updated: OrderedDict): + # parse the updates/deletions in the Kconfig + add, remove = OrderedDict(), copy.deepcopy(base) + for (key, val) in updated.items(): + if val != base.get(key, "empty"): + add[key] = val + # items remaining in remove are the ones to be excluded + if key in remove: + del remove[key] + return add, remove + + + def parse_noarch_inc_exc(self): + # Filter the common inc/excl out from the arch specific inc/excl + x86_incl_base = copy.deepcopy(KCFGData.x86_incl) + for (key, val) in x86_incl_base.items(): + if key in KCFGData.arm_incl and val == KCFGData.arm_incl[key]: + print("-> INFO: NoArch KConfig Inclusion {}:{} found and moving to common marker".format(key, val)) + del KCFGData.arm_incl[key] + del KCFGData.x86_incl[key] + KCFGData.noarch_incl[key] = val + + x86_excl_base = copy.deepcopy(KCFGData.x86_excl) + for (key, val) in x86_excl_base.items(): + if key in KCFGData.arm_excl: + print("-> INFO: NoArch KConfig Exclusion {} found and moving to common marker".format(key)) + del KCFGData.arm_excl[key] + del KCFGData.x86_excl[key] + KCFGData.noarch_excl[key] = val + + if not (KCFGData.x86_down or KCFGData.arm_down): + return + + # Filter the common inc config from the downstream kconfig + x86_down_base = copy.deepcopy(KCFGData.x86_down) + for (key, val) in x86_down_base.items(): + if key in KCFGData.arm_down: + print("-> INFO: NoArch KConfig Downstream Inclusion {} found and moving to common marker".format(key)) + del KCFGData.arm_down[key] + del KCFGData.x86_down[key] + KCFGData.noarch_down[key] = val + + def insert_arm64_section(self, raw_lines: list, arm_data: OrderedDict, is_exclusion=False, section=MLNX_ARM_KFG_SECTION) -> list: + # For arm64, config is not added under markers, but it is added under the section [mellanox-arm64] + # This design decision is taken because of the possibility that there might be conflicting options + # present between two different arm64 platforms + try: + # comment_prefixes needed to also read comments under a section + configParser = configparser.ConfigParser(allow_no_value=True, strict=False, comment_prefixes='////') + configParser.optionxform = str + configParser.read_string("".join(raw_lines)) + if not configParser.has_section(MLNX_ARM_KFG_SECTION): + configParser.add_section(MLNX_ARM_KFG_SECTION) + for (key, val) in arm_data.items(): + if not is_exclusion: + configParser.set(MLNX_ARM_KFG_SECTION, key, val) + else: + configParser.set(MLNX_ARM_KFG_SECTION, key) + str_io = io.StringIO() + configParser.write(str_io, space_around_delimiters=False) + return str_io.getvalue().splitlines(True) + except Exception as e: + print("-> FATAL: Exception {} found while adding opts under arm".format(str(e))) + raise e + return raw_lines + + + def get_kconfig_inc(self) -> list: + kcfg_inc_raw = FileHandler.read_raw(os.path.join(self.args.build_root, SLK_KCONFIG)) + # Insert common config + noarch_start, noarch_end = FileHandler.find_marker_indices(kcfg_inc_raw, MLNX_NOARCH_MARKER) + kcfg_inc_raw = FileHandler.insert_kcfg_data(kcfg_inc_raw, noarch_start, noarch_end, KCFGData.noarch_incl) + # Insert x86 config + x86_start, x86_end = FileHandler.find_marker_indices(kcfg_inc_raw, MLNX_KFG_MARKER) + kcfg_inc_raw = FileHandler.insert_kcfg_data(kcfg_inc_raw, x86_start, x86_end, KCFGData.x86_incl) + # Insert arm config + kcfg_inc_raw = self.insert_arm64_section(kcfg_inc_raw, KCFGData.arm_incl) + print("\n -> INFO: kconfig-inclusion file is generated \n {}".format("".join(kcfg_inc_raw))) + return kcfg_inc_raw + + + def get_downstream_kconfig_inc(self, new_kcfg_upstream) -> list: + kcfg_final = copy.deepcopy(new_kcfg_upstream) + # insert common Kconfig + noarch_start, noarch_end = FileHandler.find_marker_indices(kcfg_final, MLNX_NOARCH_MARKER) + noarch_final = OrderedDict(list(KCFGData.noarch_incl.items()) + list(KCFGData.noarch_down.items())) + kcfg_final = FileHandler.insert_kcfg_data(kcfg_final, noarch_start, noarch_end, noarch_final) + # insert x86 Kconfig + x86_start, x86_end = FileHandler.find_marker_indices(kcfg_final, MLNX_KFG_MARKER) + x86_final = OrderedDict(list(KCFGData.x86_incl.items()) + list(KCFGData.x86_down.items())) + kcfg_final = FileHandler.insert_kcfg_data(kcfg_final, x86_start, x86_end, x86_final) + # insert arm Kconfig + arm_final = OrderedDict(list(KCFGData.arm_incl.items()) + list(KCFGData.arm_down.items())) + kcfg_final = self.insert_arm64_section(kcfg_final, arm_final) + # generate diff + diff = difflib.unified_diff(new_kcfg_upstream, kcfg_final, fromfile='a/patch/kconfig-inclusions', tofile="b/patch/kconfig-inclusions", lineterm="\n") + lines = [] + for line in diff: + lines.append(line) + print("\n -> INFO: kconfig-inclusion.patch file is generated \n{}".format("".join(lines))) + return lines + + + def get_kconfig_excl(self) -> list: + # noarch_excl + kcfg_excl_raw = FileHandler.read_raw(os.path.join(self.args.build_root, SLK_KCONFIG_EXCLUDE)) + # insert common Kconfig + noarch_start, noarch_end = FileHandler.find_marker_indices(kcfg_excl_raw, MLNX_NOARCH_MARKER) + kcfg_excl_raw = FileHandler.insert_kcfg_excl_data(kcfg_excl_raw, noarch_start, noarch_end, KCFGData.noarch_excl) + # insert x86 Kconfig + x86_start, x86_end = FileHandler.find_marker_indices(kcfg_excl_raw, MLNX_KFG_MARKER) + kcfg_excl_raw = FileHandler.insert_kcfg_excl_data(kcfg_excl_raw, x86_start, x86_end, KCFGData.x86_excl) + # insert arm Kconfig + kcfg_excl_raw = self.insert_arm64_section(kcfg_excl_raw, KCFGData.arm_excl, True) + print("\n -> INFO: kconfig-exclusion file is generated \n{}".format("".join(kcfg_excl_raw))) + return kcfg_excl_raw + + + def perform(self): + self.read_data() + KCFGData.x86_incl, KCFGData.x86_excl = self.parse_inc_exc(KCFGData.x86_base, KCFGData.x86_updated) + KCFGData.arm_incl, KCFGData.arm_excl = self.parse_inc_exc(KCFGData.arm_base, KCFGData.arm_updated) + self.parse_noarch_inc_exc() + # Get the updated kconfig-inclusions + kcfg_inc_upstream = self.get_kconfig_inc() + FileHandler.write_lines(os.path.join(self.args.build_root, SLK_KCONFIG), kcfg_inc_upstream, True) + # Get the updated kconfig-exclusions + kcfg_excl_upstream = self.get_kconfig_excl() + FileHandler.write_lines(os.path.join(self.args.build_root, SLK_KCONFIG_EXCLUDE), kcfg_excl_upstream, True) + # return the kconfig-inclusions diff + return self.get_downstream_kconfig_inc(kcfg_inc_upstream) diff --git a/platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py b/platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py index b71e497fbd2c..8db9babb8578 100755 --- a/platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py +++ b/platform/mellanox/integration-scripts/hwmgmt_kernel_patches.py @@ -16,14 +16,7 @@ # limitations under the License. # -import os -import sys -import shutil -import argparse -import copy -import difflib - -from helper import * +from hwmgmt_helper import * COMMIT_TITLE = "Intgerate HW-MGMT {} Changes" @@ -127,8 +120,6 @@ class Data: old_non_up = list() # New series file written by hw_mgmt integration script new_series = list() - # List of new opts written by hw_mgmt integration script - updated_kcfg = list(tuple()) # index of the mlnx_hw_mgmt patches start marker in old_series i_mlnx_start = -1 # index of the mlnx_hw_mgmt patches end marker in old_series @@ -137,15 +128,10 @@ class Data: up_slk_series = list() # SLK series file content updated with non-upstream patches, used to generate diff agg_slk_series = list() - # Diff to be written into the series.patch file - agg_slk_series_diff = list() - # current kcfg opts - current_kcfg = list(tuple()) - # current raw kconfig exclude data - kcfg_exclude = list() # kernel version k_ver = "" + class HwMgmtAction(Action): @staticmethod @@ -162,25 +148,28 @@ def get(args): return action - def check(self): - if not self.args.config_inclusion: - print("-> ERR: config_inclusion is missing") - return False + def return_false(self, str_): + print(str_) + return False + def check(self): + if not self.args.kernel_version: + return self.return_false("-> ERR: Kernel Version is missing") if not self.args.build_root: - print("-> ERR: build_root is missing") - return False - - if not os.path.isfile(self.args.config_inclusion): - print("-> ERR: config_inclusion {} doesn't exist".format(self.args.config_inclusion)) - return False - + return self.return_false("-> ERR: build_root is missing") if not os.path.exists(self.args.build_root): - print("-> ERR: Build Root {} doesn't exist".format(self.args.build_root)) - return False - + return self.return_false("-> ERR: Build Root {} doesn't exist".format(self.args.build_root)) + if not os.path.isfile(self.args.config_base_amd): + return self.return_false("-> ERR: config_base {} doesn't exist".format(self.args.config_base_amd)) + if not os.path.isfile(self.args.config_base_arm): + return self.return_false("-> ERR: config_base_arm {} doesn't exist".format(self.args.config_base_arm)) + if not os.path.isfile(self.args.config_inc_amd): + return self.return_false("-> ERR: config_inclusion {} doesn't exist".format(self.args.config_inc_amd)) + if not os.path.isfile(self.args.config_inc_arm): + return self.return_false("-> ERR: config_inclusion {} doesn't exist".format(self.args.config_inc_arm)) return True + class PreProcess(HwMgmtAction): def __init__(self, args): super().__init__(args) @@ -189,36 +178,28 @@ def check(self): return super(PreProcess, self).check() def perform(self): - """ Move MLNX Kconfig to the loc pointed by config_inclusion """ - kcfg_sec = FileHandler.read_kconfig_inclusion(os.path.join(self.args.build_root, SLK_KCONFIG)) - writable_opts = KCFG.get_writable_opts(KCFG.parse_opts_strs(kcfg_sec)) - FileHandler.write_lines(self.args.config_inclusion, writable_opts) - print("-> OPTS written to temp config_inclusion file: \n{}".format(FileHandler.read_strip(self.args.config_inclusion, True))) + """ Move Base Kconfig to the loc pointed by config_inclusion """ + shutil.copy2(self.args.config_base_amd, self.args.config_inc_amd) + shutil.copy2(self.args.config_base_arm, self.args.config_inc_arm) + print("-> Kconfig amd64/arm64 copied to the relevant directory") + class PostProcess(HwMgmtAction): def __init__(self, args): super().__init__(args) + self.kcfg_handler = KConfigTask(self.args) def check(self): if not super(PostProcess, self).check(): return False - if not (self.args.patches and os.path.exists(self.args.patches)): - print("-> ERR: upstream patch directory is missing ") - return False - + return self.return_false("-> ERR: upstream patch directory is missing ") if not (self.args.non_up_patches and os.path.exists(self.args.non_up_patches)): - print("-> ERR: non upstream patch directory is missing") - return False - + return self.return_false("-> ERR: non upstream patch directory is missing") if not (self.args.series and os.path.isfile(self.args.series)): - print("-> ERR: series file doesn't exist {}".format(self.args.series)) - return False - + return self.return_false("-> ERR: series file doesn't exist {}".format(self.args.series)) if not (self.args.current_non_up_patches and os.path.exists(self.args.current_non_up_patches)): - print("-> ERR: current non_up_patches doesn't exist {}".format(self.args.current_non_up_patches)) - return False - + return self.return_false("-> ERR: current non_up_patches doesn't exist {}".format(self.args.current_non_up_patches)) return True def read_data(self): @@ -227,19 +208,6 @@ def read_data(self): Data.old_series = FileHandler.read_raw(os.path.join(self.args.build_root, SLK_SERIES)) Data.old_non_up = FileHandler.read_strip_minimal(self.args.current_non_up_patches) - # Read the new kcfg - new_cfg = FileHandler.read_kconfig_inclusion(self.args.config_inclusion, None) - Data.updated_kcfg = KCFG.parse_opts_strs(new_cfg) - - # entire current config, [common] + [amd64] - all_kcfg = FileHandler.read_kconfig_parser(os.path.join(self.args.build_root, SLK_KCONFIG)) - Data.current_kcfg = [] - for hdr in HDRS: - Data.current_kcfg.extend(all_kcfg.get(hdr, [])) - Data.current_kcfg = KCFG.parse_opts_strs(Data.current_kcfg) - - Data.kcfg_exclude = FileHandler.read_raw(os.path.join(self.args.build_root, SLK_KCONFIG_EXCLUDE)) - new_up = set(FileHandler.read_dir(self.args.patches, "*.patch")) new_non_up = set(FileHandler.read_dir(self.args.non_up_patches, "*.patch")) @@ -332,58 +300,16 @@ def construct_series_with_non_up(self): FileHandler.write_lines(self.args.current_non_up_patches, lines) print("\n -> POST: series file updated with non-upstream patches \n{}".format("".join(Data.agg_slk_series))) - def write_series_diff(self): + def get_series_diff(self): diff = difflib.unified_diff(Data.up_slk_series, Data.agg_slk_series, fromfile='a/patch/series', tofile="b/patch/series", lineterm="\n") lines = [] for line in diff: lines.append(line) print("\n -> POST: final series.diff \n{}".format("".join(lines))) - FileHandler.write_lines(os.path.join(self.args.build_root, NON_UP_PATCH_DIFF), lines, True) + return lines - def check_kconfig_conflicts(self): - # current config under mellanox marker - old_mlnx_kcfg = FileHandler.read_kconfig_inclusion(os.path.join(self.args.build_root, SLK_KCONFIG)) - old_mlnx_kcfg = KCFG.parse_opts_strs(old_mlnx_kcfg) - - print("-> INFO: [common] + [amd64] Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(Data.current_kcfg)))) - print("-> INFO: current mellanox marker Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(old_mlnx_kcfg)))) - - # Filter the mellanox config from current config - conflict_prone = set(Data.current_kcfg) - for kcfg in old_mlnx_kcfg: - if kcfg in conflict_prone: - conflict_prone.remove(kcfg) - - print("-> INFO: conflict prone Kconfig: \n{}".format("\n".join(KCFG.get_writable_opts(list(conflict_prone))))) - print("-> INFO: updated kconfig for mellanox marker: \n{}".format("\n".join(KCFG.get_writable_opts(Data.updated_kcfg)))) - - # check for conflicts - has_conflict = False - for (cfg, val) in Data.updated_kcfg: - for (cfg_o, val_o) in conflict_prone: - if cfg == cfg_o and val != val_o: - print("-> ERR Conflict seen on the following kconfig: {}, old_opt: {}, new_opt: {}".format(cfg, val_o, val)) - has_conflict = True - return has_conflict - - def handle_exclusions(self): - new_lines = [] - curr_hdr = "" - for line_raw in Data.kcfg_exclude: - line = line_raw.strip() - should_exclude = False - if line: - match = re.search(KCFG_HDR_RE, line) - if match: - curr_hdr = match.group(1) - else: - for (kcfg, _) in Data.updated_kcfg: - if kcfg == line and curr_hdr in HDRS: - should_exclude = True - if not should_exclude: - new_lines.append(line_raw) - FileHandler.write_lines(os.path.join(self.args.build_root, SLK_KCONFIG_EXCLUDE), new_lines, True) - print("-> INFO: updated kconfig-exclusion: \n{}".format("".join(FileHandler.read_raw(os.path.join(self.args.build_root, SLK_KCONFIG_EXCLUDE))))) + def get_merged_diff(self, series_diff: list, kcfg_diff: list) -> list: + return series_diff + ["\n"] + kcfg_diff def list_patches(self): old_up_patches = [] @@ -428,6 +354,7 @@ def create_commit_msg(self, table): title = COMMIT_TITLE.format(self.args.hw_mgmt_ver) changes_slk, changes_sb = {}, {} old_up_patches, old_non_up_patches = self.list_patches() + print(old_up_patches) for patch in table: patch_ = patch.get(PATCH_NAME) id_ = self._fetch_description(patch_, patch.get(COMMIT_ID, "")) @@ -448,18 +375,9 @@ def create_commit_msg(self, table): def perform(self): """ Read the data output from the deploy_kernel_patches.py script and move to appropriate locations """ + # Handle Patches related logic self.read_data() self.find_mlnx_hw_mgmt_markers() - # Find and report conflicts in new kconfig - if self.check_kconfig_conflicts(): - print("-> FATAL Conflicts in kconfig-inclusion detected, exiting...") - sys.exit(1) - else: - # Write the new kcfg to the new file - path = os.path.join(self.args.build_root, SLK_KCONFIG) - FileHandler.write_lines_marker(path, KCFG.get_writable_opts(Data.updated_kcfg), MLNX_KFG_MARKER) - self.handle_exclusions() - # Handle Upstream patches self.rm_old_up_mlnx() self.mv_new_up_mlnx() self.write_final_slk_series() @@ -467,7 +385,11 @@ def perform(self): self.rm_old_non_up_mlnx() self.mv_new_non_up_mlnx() self.construct_series_with_non_up() - self.write_series_diff() + series_diff = self.get_series_diff() + # handle kconfig and get any diff + kcfg_diff = self.kcfg_handler.perform() + final_diff = self.get_merged_diff(series_diff, kcfg_diff) + FileHandler.write_lines(os.path.join(self.args.build_root, NON_UP_DIFF), final_diff, True) path = os.path.join(self.args.build_root, PATCH_TABLE_LOC) patch_table = load_patch_table(path, Data.k_ver) @@ -481,6 +403,8 @@ def perform(self): if self.args.slk_msg: with open(self.args.slk_msg, 'w') as f: f.write(slk_msg) + + def create_parser(): # Create argument parser @@ -492,7 +416,12 @@ def create_parser(): # Optional arguments parser.add_argument("--patches", type=str) parser.add_argument("--non_up_patches", type=str) - parser.add_argument("--config_inclusion", type=str) + parser.add_argument("--config_base_amd", type=str, required=True) + parser.add_argument("--config_base_arm", type=str, required=True) + parser.add_argument("--config_inc_amd", type=str, required=True) + parser.add_argument("--config_inc_arm", type=str, required=True) + parser.add_argument("--config_inc_down_amd", type=str) + parser.add_argument("--config_inc_down_arm", type=str) parser.add_argument("--series", type=str) parser.add_argument("--current_non_up_patches", type=str) parser.add_argument("--build_root", type=str) diff --git a/platform/mellanox/integration-scripts/tests/data/expected_data/series.patch b/platform/mellanox/integration-scripts/tests/data/expected_data/external-changes.patch similarity index 60% rename from platform/mellanox/integration-scripts/tests/data/expected_data/series.patch rename to platform/mellanox/integration-scripts/tests/data/expected_data/external-changes.patch index d0b12995b311..ff69936dce00 100644 --- a/platform/mellanox/integration-scripts/tests/data/expected_data/series.patch +++ b/platform/mellanox/integration-scripts/tests/data/expected_data/external-changes.patch @@ -11,4 +11,22 @@ 0188-i2c-mux-Add-register-map-based-mux-driver.patch ###-> mellanox_hw_mgmt-end - # Cisco patches for 5.10 kernel + +--- a/patch/kconfig-inclusions ++++ b/patch/kconfig-inclusions +@@ -41,4 +41,15 @@ + CONFIG_HWMON=y + CONFIG_OF=y + CONFIG_THERMAL_NETLINK=y ++CONFIG_SENSORS_MP2891=m ++CONFIG_MMC_SDHCI_OF_DWCMSHC=m ++CONFIG_VFIO_PLATFORM=m ++CONFIG_SENSORS_ARM_SCMI=m ++CONFIG_MLXBF_GIGE=m ++CONFIG_I2C_MLXBF=m ++CONFIG_GPIO_MLXBF3=m ++CONFIG_MLXBF_TMFIFO=m ++CONFIG_MLXBF_BOOTCTL=m ++CONFIG_MLXBF_PMC=m ++CONFIG_MLXBF_PTM=m + diff --git a/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-exclusions b/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-exclusions index 809120c0157a..17642ca98d25 100644 --- a/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-exclusions +++ b/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-exclusions @@ -6,12 +6,18 @@ CONFIG_CGROUP_NET_CLASSID CONFIG_NET_CLS_CGROUP CONFIG_NETFILTER_XT_MATCH_CGROUP CONFIG_CGROUP_NET_PRIO +###-> mellanox_common-start +###-> mellanox_common-end [amd64] # Unset X86_PAT according to Broadcom's requirement +CONFIG_SENSORS_UCD9200 CONFIG_X86_PAT CONFIG_MLXSW_PCI CONFIG_THERMAL_STATISTICS +###-> mellanox_amd64-start +CONFIG_I2C_DESIGNWARE_BAYTRAIL +###-> mellanox_amd64-end [arm64] @@ -21,3 +27,6 @@ CONFIG_THERMAL_STATISTICS CONFIG_ARCH_VIRT CONFIG_ARCH_BCM CONFIG_ARCH_EXYNOS + +[mellanox-arm64] + diff --git a/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-inclusions b/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-inclusions index 9ff894f94534..4946ae674969 100644 --- a/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-inclusions +++ b/platform/mellanox/integration-scripts/tests/data/expected_data/kconfig-inclusions @@ -1,11 +1,9 @@ -# Description: Add kconfig options that has to be included in the kernel -# Note: Markers should start with "###->" -# Header should end with .*-start eg: any_description-start -# Footer must end with .*-end eg: any_description-end -# Markers should not be nested - [common] CONFIG_LOG_BUF_SHIFT=20 +###-> mellanox_common-start +CONFIG_THERMAL=y +CONFIG_THERMAL_OF=y +###-> mellanox_common-end [amd64] # For Inventec d7032 @@ -14,19 +12,13 @@ CONFIG_GPIO_ICH=m CONFIG_SENSORS_MAX31790=m # For optoe CONFIG_EEPROM_OPTOE=m - -###-> mellanox-start -CONFIG_SPI_PXA2XX=m -CONFIG_THERMAL_NETLINK=y -CONFIG_SENSORS_XDPE152=m -CONFIG_SENSORS_DRIVETEMP=m -CONFIG_SENSORS_IIO_HWMON=m -CONFIG_SENSORS_LM25066=m -CONFIG_SENSORS_UCD9000=m -CONFIG_SENSORS_UCD9200=m -CONFIG_THERMAL_OF=y -###-> mellanox-end - +###-> mellanox_amd64-start +CONFIG_PINCTRL=y +CONFIG_DW_DMAC_PCI=y +CONFIG_TI_ADS1015=m +CONFIG_I2C_DESIGNWARE_CORE=m +CONFIG_I2C_DESIGNWARE_PCI=m +###-> mellanox_amd64-end # For Cisco 8000 CONFIG_PHYLIB=m CONFIG_GPIOLIB=y @@ -34,7 +26,19 @@ CONFIG_OF_GPIO=y CONFIG_OF=y CONFIG_OF_MDIO=m +[arm64] + [armhf] CONFIG_EEPROM_SFF_8436=m CONFIG_EEPROM_OPTOE=m CONFIG_I2C_MUX_GPIO=m + +[mellanox-arm64] +CONFIG_MELLANOX_PLATFORM=y +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_HWMON=y +CONFIG_OF=y +CONFIG_THERMAL_NETLINK=y + diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig-exclusions b/platform/mellanox/integration-scripts/tests/data/kconfig-exclusions index 3a930bffdc4f..c279869e4df3 100644 --- a/platform/mellanox/integration-scripts/tests/data/kconfig-exclusions +++ b/platform/mellanox/integration-scripts/tests/data/kconfig-exclusions @@ -6,6 +6,8 @@ CONFIG_CGROUP_NET_CLASSID CONFIG_NET_CLS_CGROUP CONFIG_NETFILTER_XT_MATCH_CGROUP CONFIG_CGROUP_NET_PRIO +###-> mellanox_common-start +###-> mellanox_common-end [amd64] # Unset X86_PAT according to Broadcom's requirement @@ -13,6 +15,8 @@ CONFIG_SENSORS_UCD9200 CONFIG_X86_PAT CONFIG_MLXSW_PCI CONFIG_THERMAL_STATISTICS +###-> mellanox_amd64-start +###-> mellanox_amd64-end [arm64] @@ -22,3 +26,5 @@ CONFIG_THERMAL_STATISTICS CONFIG_ARCH_VIRT CONFIG_ARCH_BCM CONFIG_ARCH_EXYNOS + +[mellanox-arm64] \ No newline at end of file diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig-inclusions b/platform/mellanox/integration-scripts/tests/data/kconfig-inclusions index cb828fd25871..bb4eed3e0b6f 100644 --- a/platform/mellanox/integration-scripts/tests/data/kconfig-inclusions +++ b/platform/mellanox/integration-scripts/tests/data/kconfig-inclusions @@ -1,11 +1,7 @@ -# Description: Add kconfig options that has to be included in the kernel -# Note: Markers should start with "###->" -# Header should end with .*-start eg: any_description-start -# Footer must end with .*-end eg: any_description-end -# Markers should not be nested - [common] CONFIG_LOG_BUF_SHIFT=20 +###-> mellanox_common-start +###-> mellanox_common-end [amd64] # For Inventec d7032 @@ -15,13 +11,13 @@ CONFIG_SENSORS_MAX31790=m # For optoe CONFIG_EEPROM_OPTOE=m -###-> mellanox-start +###-> mellanox_amd64-start CONFIG_OF=y CONFIG_THERMAL_OF=y CONFIG_CPU_THERMAL=y CONFIG_PINCTRL_CANNONLAKE=m CONFIG_PINCTRL_DENVERTON=m -###-> mellanox-end +###-> mellanox_amd64-end # For Cisco 8000 CONFIG_PHYLIB=m @@ -30,7 +26,11 @@ CONFIG_OF_GPIO=y CONFIG_OF=y CONFIG_OF_MDIO=m +[arm64] + [armhf] CONFIG_EEPROM_SFF_8436=m CONFIG_EEPROM_OPTOE=m CONFIG_I2C_MUX_GPIO=m + +[mellanox-arm64] diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/arm64.config b/platform/mellanox/integration-scripts/tests/data/kconfig/arm64.config new file mode 100644 index 000000000000..fc22075287ce --- /dev/null +++ b/platform/mellanox/integration-scripts/tests/data/kconfig/arm64.config @@ -0,0 +1,36 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/arm64 5.10.179 Kernel Configuration +# + +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MELLANOX_PLATFORM is not set + +# +# ACPI drivers +# +# CONFIG_SENSORS_ACPI_POWER is not set +CONFIG_THERMAL=n +# CONFIG_THERMAL_NETLINK is not set +# CONFIG_THERMAL_STATISTICS is not set +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=n +# CONFIG_THERMAL_WRITABLE_TRIPS is not set +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_CPU_THERMAL=y + +# +# Sensors +# + +CONFIG_SENSORS_XDPE152=m +CONFIG_SENSORS_DRIVETEMP=m +CONFIG_SENSORS_IIO_HWMON=m +CONFIG_SENSORS_LM25066=m +CONFIG_SENSORS_UCD9000=m +CONFIG_SENSORS_UCD9200=m +CONFIG_FUSE_FS=m + diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm.config b/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm.config new file mode 100644 index 000000000000..e5d0f83f09d3 --- /dev/null +++ b/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm.config @@ -0,0 +1,45 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/arm64 5.10.179 Kernel Configuration +# + +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MELLANOX_PLATFORM is not set + +# +# ACPI drivers +# +# CONFIG_SENSORS_ACPI_POWER is not set +CONFIG_THERMAL=y +# CONFIG_THERMAL_NETLINK is not set +# CONFIG_THERMAL_STATISTICS is not set +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=y +# CONFIG_THERMAL_WRITABLE_TRIPS is not set +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_CPU_THERMAL=y + +# +# Sensors +# + +CONFIG_SENSORS_XDPE152=m +CONFIG_SENSORS_DRIVETEMP=m +CONFIG_SENSORS_IIO_HWMON=m +CONFIG_SENSORS_LM25066=m +CONFIG_SENSORS_UCD9000=m +CONFIG_SENSORS_UCD9200=m +CONFIG_FUSE_FS=m + +# New hw-mgmt 7.0020.5048 arm64 kernel config flags + +CONFIG_MELLANOX_PLATFORM=y +CONFIG_THERMAL_WRITABLE_TRIPS=y +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_HWMON=y +CONFIG_OF=y +CONFIG_THERMAL_NETLINK=y diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm_down.config b/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm_down.config new file mode 100644 index 000000000000..ab2fd4c41d74 --- /dev/null +++ b/platform/mellanox/integration-scripts/tests/data/kconfig/new_arm_down.config @@ -0,0 +1,14 @@ +# New hw-mgmt 7.0020.5048 kernel downstream config flags + +CONFIG_SENSORS_MP2891=m +CONFIG_MMC_SDHCI_OF_DWCMSHC=m +CONFIG_VFIO_PLATFORM=m +CONFIG_SENSORS_ARM_SCMI=m +CONFIG_MLXBF_GIGE=m +CONFIG_I2C_MLXBF=m +CONFIG_GPIO_MLXBF3=m +CONFIG_MLXBF_TMFIFO=m +CONFIG_MLXBF_BOOTCTL=m +CONFIG_MLXBF_PMC=m +CONFIG_MLXBF_PTM=m + diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/new_x86.config b/platform/mellanox/integration-scripts/tests/data/kconfig/new_x86.config new file mode 100644 index 000000000000..ed3b88a2e8cb --- /dev/null +++ b/platform/mellanox/integration-scripts/tests/data/kconfig/new_x86.config @@ -0,0 +1,41 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86_c64 5.10.179 Kernel Configuration +# + +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MELLANOX_PLATFORM is not set + +# +# ACPI drivers +# +CONFIG_THERMAL=y +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=y +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_CPU_THERMAL=y + +# +# Sensors +# +CONFIG_SENSORS_XDPE152=m +CONFIG_SENSORS_DRIVETEMP=m +CONFIG_SENSORS_IIO_HWMON=m +CONFIG_SENSORS_LM25066=m +CONFIG_SENSORS_UCD9000=m +CONFIG_SENSORS_UCD9200=m + +CONFIG_I2C_MUX_PCA954x=m +CONFIG_I2C_DESIGNWARE_PLATFORM=m + +# New hw-mgmt 7.0020.5048 kernel config flags + +CONFIG_PINCTRL=y +CONFIG_DW_DMAC_PCI=y +CONFIG_TI_ADS1015=m +CONFIG_I2C_DESIGNWARE_CORE=m +CONFIG_I2C_DESIGNWARE_PCI=m + diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/new_x86_down.config b/platform/mellanox/integration-scripts/tests/data/kconfig/new_x86_down.config new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/platform/mellanox/integration-scripts/tests/data/kconfig/x86.config b/platform/mellanox/integration-scripts/tests/data/kconfig/x86.config new file mode 100644 index 000000000000..2e7748121646 --- /dev/null +++ b/platform/mellanox/integration-scripts/tests/data/kconfig/x86.config @@ -0,0 +1,34 @@ +# +# Automatically generated file; DO NOT EDIT. +# Linux/x86_c64 5.10.179 Kernel Configuration +# + +CONFIG_NET_VENDOR_MELLANOX=y +# CONFIG_MELLANOX_PLATFORM is not set + +# +# ACPI drivers +# +CONFIG_THERMAL=n +CONFIG_THERMAL_EMERGENCY_POWEROFF_DELAY_MS=0 +CONFIG_THERMAL_HWMON=y +CONFIG_THERMAL_OF=n +CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_STEP_WISE=y +CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y +CONFIG_CPU_THERMAL=y + +# +# Sensors +# +CONFIG_SENSORS_XDPE152=m +CONFIG_SENSORS_DRIVETEMP=m +CONFIG_SENSORS_IIO_HWMON=m +CONFIG_SENSORS_LM25066=m +CONFIG_SENSORS_UCD9000=m +CONFIG_SENSORS_UCD9200=m + +CONFIG_I2C_MUX_PCA954x=m +CONFIG_I2C_DESIGNWARE_PLATFORM=m +CONFIG_I2C_DESIGNWARE_BAYTRAIL=y + diff --git a/platform/mellanox/integration-scripts/tests/data/new_kconfig b/platform/mellanox/integration-scripts/tests/data/new_kconfig deleted file mode 100644 index ba54e9876b89..000000000000 --- a/platform/mellanox/integration-scripts/tests/data/new_kconfig +++ /dev/null @@ -1,12 +0,0 @@ - -# New hw-mgmt 7.0020.5048 kernel config flags - -CONFIG_SPI_PXA2XX=m -CONFIG_THERMAL_NETLINK=y -CONFIG_SENSORS_XDPE152=m -CONFIG_SENSORS_DRIVETEMP=m -CONFIG_SENSORS_IIO_HWMON=m -CONFIG_SENSORS_LM25066=m -CONFIG_SENSORS_UCD9000=m -CONFIG_SENSORS_UCD9200=m -CONFIG_THERMAL_OF=y diff --git a/platform/mellanox/integration-scripts/tests/test_filehandler.py b/platform/mellanox/integration-scripts/tests/test_filehandler.py index f113e1c214cd..a4146306c5f1 100644 --- a/platform/mellanox/integration-scripts/tests/test_filehandler.py +++ b/platform/mellanox/integration-scripts/tests/test_filehandler.py @@ -46,11 +46,11 @@ [amd64] CONFIG_SENSORS_DPS1900=m -###-> mellanox-start +###-> mellanox_amd64-start CONFIG_OF=y CONFIG_THERMAL_OF=y CONFIG_DW_DMAC_PCI=y -###-> mellanox-end +###-> mellanox_amd64-end [armhf] CONFIG_EEPROM_SFF_8436=m @@ -58,17 +58,6 @@ CONFIG_I2C_MUX_GPIO=y """ -UPDATED_MLNX_KCFG = """\ -CONFIG_OF=y -CONFIG_THERMAL_OF=y -CONFIG_DW_DMAC_PCI=y -CONFIG_I2C_I801=m -CONFIG_PINCTRL=y -CONFIG_PINCTRL_INTEL=m -CONFIG_I2C_MUX_PCA954x=m -CONFIG_SPI_PXA2XX=m -""" - FINAL_MOCK_SLK_KCFG = """\ CONFIG_RANDOM=rrr @@ -78,7 +67,7 @@ [amd64] CONFIG_SENSORS_DPS1900=m -###-> mellanox-start +###-> mellanox_amd64-start CONFIG_OF=y CONFIG_THERMAL_OF=y CONFIG_DW_DMAC_PCI=y @@ -87,7 +76,7 @@ CONFIG_PINCTRL_INTEL=m CONFIG_I2C_MUX_PCA954x=m CONFIG_SPI_PXA2XX=m -###-> mellanox-end +###-> mellanox_amd64-end [armhf] CONFIG_EEPROM_SFF_8436=m @@ -95,6 +84,44 @@ CONFIG_I2C_MUX_GPIO=y """ +MOCK_SLK_EXCL = """\ +[common] +CONFIG_CGROUP_NET_CLASSID +CONFIG_NET_CLS_CGROUP +CONFIG_NETFILTER_XT_MATCH_CGROUP +CONFIG_CGROUP_NET_PRIO + +[amd64] +# Unset X86_PAT according to Broadcom's requirement +CONFIG_X86_PAT +CONFIG_MLXSW_PCI +###-> mellanox_amd64-start +###-> mellanox_amd64-end + +[arm64] +CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU +""" + +FINAL_MOCK_SLK_EXCL = """\ +[common] +CONFIG_CGROUP_NET_CLASSID +CONFIG_NET_CLS_CGROUP +CONFIG_NETFILTER_XT_MATCH_CGROUP +CONFIG_CGROUP_NET_PRIO + +[amd64] +# Unset X86_PAT according to Broadcom's requirement +CONFIG_X86_PAT +CONFIG_MLXSW_PCI +###-> mellanox_amd64-start +CONFIG_OF +CONFIG_THERMAL_OF +###-> mellanox_amd64-end + +[arm64] +CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU +""" + LINES_WRITE = [] LINES_READ = [] @@ -137,40 +164,39 @@ def test_find_markers(self): print(i_start, i_end) assert i_start == -1 assert i_end == len(lines) - - @mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock) - def test_read_kconfig_parser(self, mock_read_raw): - global LINES_READ - LINES_READ = MOCK_SLK_KCFG.split("\n") - all_cfg = FileHandler.read_kconfig_parser("") - print(all_cfg) - assert all_cfg['no_parent'] == ['CONFIG_RANDOM=rrr'] - assert all_cfg['common'] == ['CONFIG_LOG_BUF_SHIFT=20'] - assert all_cfg['amd64'] == ['CONFIG_SENSORS_DPS1900=m', 'CONFIG_OF=y', 'CONFIG_THERMAL_OF=y', 'CONFIG_DW_DMAC_PCI=y'] - assert all_cfg['armhf'] == ['CONFIG_EEPROM_SFF_8436=m', 'CONFIG_EEPROM_OPTOE=m', 'CONFIG_I2C_MUX_GPIO=y'] - - @mock.patch('helper.FileHandler.write_lines', side_effect=writer_mock) + @mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock) - def test_write_lines_marker(self, mock_read_raw, mock_write_lines_marker): + def test_insert_kcfg(self, mock_read_raw): global LINES_READ - global LINES_WRITE LINES_READ = MOCK_SLK_KCFG.splitlines(True) - LINES_WRITE = FINAL_MOCK_SLK_KCFG.splitlines(True) - - list_opts = KCFG.parse_opts_strs(UPDATED_MLNX_KCFG.split("\n")) - writable_opts = KCFG.get_writable_opts(list_opts) - - FileHandler.write_lines_marker("", writable_opts, marker="mellanox") + kcfg_inc_raw = FileHandler.read_raw("") + new_opts = OrderedDict({ + "CONFIG_OF" : "y", + "CONFIG_THERMAL_OF" : "y", + "CONFIG_DW_DMAC_PCI" : "y", + "CONFIG_I2C_I801" : "m", + "CONFIG_PINCTRL" : "y", + "CONFIG_PINCTRL_INTEL" : "m", + "CONFIG_I2C_MUX_PCA954x" : "m", + "CONFIG_SPI_PXA2XX" : "m" + }) + x86_start, x86_end = FileHandler.find_marker_indices(kcfg_inc_raw, MLNX_KFG_MARKER) + assert "###-> mellanox_amd64-start" in kcfg_inc_raw[x86_start] + assert "###-> mellanox_amd64-end" in kcfg_inc_raw[x86_end] + final_kcfg = FileHandler.insert_kcfg_data(kcfg_inc_raw, x86_start, x86_end, new_opts) + assert final_kcfg == FINAL_MOCK_SLK_KCFG.splitlines(True) - @mock.patch('helper.FileHandler.write_lines', side_effect=writer_mock) @mock.patch('helper.FileHandler.read_raw', side_effect=read_raw_mock) - def test_read_kconfig_inclusion(self, mock_read_raw, mock_write_lines_marker): + def test_insert_kcfg_excl(self, mock_read_raw): global LINES_READ - LINES_READ = FINAL_MOCK_SLK_KCFG.splitlines(True) - opts = FileHandler.read_kconfig_inclusion("") - - global LINES_WRITE - LINES_WRITE = UPDATED_MLNX_KCFG.splitlines() - writable_opts = KCFG.get_writable_opts(KCFG.parse_opts_strs(opts)) - print(writable_opts) - FileHandler.write_lines("", writable_opts) + LINES_READ = MOCK_SLK_EXCL.splitlines(True) + kcfg_inc_raw = FileHandler.read_raw("") + new_opts = OrderedDict({ + "CONFIG_OF" : "y", + "CONFIG_THERMAL_OF" : "y" + }) + x86_start, x86_end = FileHandler.find_marker_indices(kcfg_inc_raw, MLNX_KFG_MARKER) + assert "###-> mellanox_amd64-start" in kcfg_inc_raw[x86_start] + assert "###-> mellanox_amd64-end" in kcfg_inc_raw[x86_end] + final_kcfg = FileHandler.insert_kcfg_excl_data(kcfg_inc_raw, x86_start, x86_end, new_opts) + assert final_kcfg == FINAL_MOCK_SLK_EXCL.splitlines(True) diff --git a/platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py b/platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py index b480955f12a4..f3ec546a2fae 100644 --- a/platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py +++ b/platform/mellanox/integration-scripts/tests/test_hwmgmtaction.py @@ -20,8 +20,10 @@ from unittest import mock, TestCase from pyfakefs.fake_filesystem_unittest import Patcher sys.path.append('../') +from hwmgmt_helper import * from hwmgmt_kernel_patches import * + NEW_NONUP_LIST = """ \ 0168-TMP-mlxsw-minimal-Ignore-error-reading-SPAD-register.patch 0169-TMP-mlxsw-i2c-Prevent-transaction-execution-for-spec.patch @@ -76,6 +78,7 @@ REL_INPUTS_DIR = "platform/mellanox/integration-scripts/tests/data/" MOCK_INPUTS_DIR = "/sonic/" + REL_INPUTS_DIR MOCK_WRITE_FILE = MOCK_INPUTS_DIR + "test_writer_file.out" +MOCK_KCFG_DIR = MOCK_INPUTS_DIR + "/kconfig" def write_lines_mock(path, lines, raw=False): # Create the dir if it doesn't exist already @@ -90,7 +93,12 @@ def mock_hwmgmt_args(): with mock.patch("sys.argv", ["hwmgmt_kernel_patches.py", "post", "--patches", "/tmp", "--non_up_patches", "/tmp", - "--config_inclusion", MOCK_INPUTS_DIR+"/new_kconfig", + "--config_inc_amd", MOCK_KCFG_DIR+"/new_x86.config", + "--config_inc_arm", MOCK_KCFG_DIR+"/new_arm.config", + "--config_base_amd", MOCK_KCFG_DIR+"/x86.config", + "--config_base_arm", MOCK_KCFG_DIR+"/arm64.config", + "--config_inc_down_amd", MOCK_KCFG_DIR+"/new_x86_down.config", + "--config_inc_down_arm", MOCK_KCFG_DIR+"/new_arm_down.config", "--series", MOCK_INPUTS_DIR+"/new_series", "--current_non_up_patches", MOCK_INPUTS_DIR+"/hwmgmt_nonup_patches", "--kernel_version", "5.10.140", @@ -113,74 +121,56 @@ def check_file_content(path): @mock.patch('helper.SLK_PATCH_LOC', REL_INPUTS_DIR) @mock.patch('helper.SLK_SERIES', REL_INPUTS_DIR+"series") -@mock.patch('helper.SLK_KCONFIG', REL_INPUTS_DIR+"kconfig-inclusion") +@mock.patch('hwmgmt_helper.SLK_KCONFIG', REL_INPUTS_DIR+"kconfig-inclusions") +@mock.patch('hwmgmt_helper.SLK_KCONFIG_EXCLUDE', REL_INPUTS_DIR+"kconfig-exclusions") class TestHwMgmtPostAction(TestCase): def setUp(self): self.action = HwMgmtAction.get(mock_hwmgmt_args()) self.action.read_data() + self.kcfgaction = KConfigTask(mock_hwmgmt_args()) + self.kcfgaction.read_data() # Populate the new_up, new_non_up list Data.new_up = NEW_UP_LIST.splitlines() Data.new_non_up = NEW_NONUP_LIST.splitlines() Data.old_series = FileHandler.read_raw(MOCK_INPUTS_DIR+"/series") - all_kcfg = FileHandler.read_kconfig_parser(MOCK_INPUTS_DIR+"/kconfig-inclusions") - Data.current_kcfg = [] - for hdr in HDRS: - Data.current_kcfg.extend(all_kcfg.get(hdr, [])) - Data.current_kcfg = KCFG.parse_opts_strs(Data.current_kcfg) - Data.kcfg_exclude = FileHandler.read_raw(MOCK_INPUTS_DIR+"/kconfig-exclusions") + + def tearDown(self): + KCFGData.x86_incl.clear() + KCFGData.arm_incl.clear() + KCFGData.x86_excl.clear() + KCFGData.arm_excl.clear() + KCFGData.x86_down.clear() + KCFGData.arm_down.clear() + KCFGData.noarch_incl.clear() + KCFGData.noarch_excl.clear() + KCFGData.noarch_down.clear() def test_find_mlnx_hw_mgmt_markers(self): self.action.find_mlnx_hw_mgmt_markers() print(Data.i_mlnx_start, Data.i_mlnx_end) assert Data.old_series[Data.i_mlnx_start].strip() == "###-> mellanox_hw_mgmt-start" assert Data.old_series[Data.i_mlnx_end].strip() == "###-> mellanox_hw_mgmt-end" - - def test_check_kconfig_conflicts(self): - # Add a line to create conflict - print(Data.current_kcfg) - Data.updated_kcfg.append(["CONFIG_EEPROM_OPTOE", "n"]) - self.action.find_mlnx_hw_mgmt_markers() - assert self.action.check_kconfig_conflicts() == True - - # Add a duplicate option - Data.updated_kcfg.pop(-1) - Data.updated_kcfg.append(["CONFIG_EEPROM_OPTOE", "m"]) - assert self.action.check_kconfig_conflicts() == False - - # Check with no conflicts or duplicates - Data.updated_kcfg.pop(-1) - assert self.action.check_kconfig_conflicts() == False @mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock) def test_write_final_slk_series(self, mock_write_lines): self.action.find_mlnx_hw_mgmt_markers() - assert not self.action.check_kconfig_conflicts() self.action.write_final_slk_series() assert check_file_content(MOCK_INPUTS_DIR+"expected_data/series") - - def test_write_kconfig_inclusion(self): - self.action.find_mlnx_hw_mgmt_markers() - assert not self.action.check_kconfig_conflicts() - print(Data.updated_kcfg) - shutil.copy(MOCK_INPUTS_DIR+"/kconfig-inclusions", MOCK_WRITE_FILE) - FileHandler.write_lines_marker(MOCK_WRITE_FILE, KCFG.get_writable_opts(Data.updated_kcfg), MLNX_KFG_MARKER) - assert check_file_content(MOCK_INPUTS_DIR+"expected_data/kconfig-inclusions") - - @mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock) - def test_handle_exclusions(self, mock_write_lines): - self.action.find_mlnx_hw_mgmt_markers() - self.action.handle_exclusions() - assert check_file_content(MOCK_INPUTS_DIR+"expected_data/kconfig-exclusions") @mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock) - def test_write_series_diff(self, mock_write_lines): + def test_write_final_diff(self, mock_write_lines): self.action.find_mlnx_hw_mgmt_markers() self.action.write_final_slk_series() self.action.construct_series_with_non_up() - self.action.write_series_diff() - assert check_file_content(MOCK_INPUTS_DIR+"expected_data/series.patch") + series_diff = self.action.get_series_diff() + kcfg_diff = self._get_kcfg_incl_diff() + final_diff = self.action.get_merged_diff(series_diff, kcfg_diff) + print("".join(final_diff)) + FileHandler.write_lines(os.path.join(self.action.args.build_root, NON_UP_DIFF), final_diff, True) + assert check_file_content(MOCK_INPUTS_DIR+"expected_data/external-changes.patch") def test_commit_msg(self): + self.action.find_mlnx_hw_mgmt_markers() root_dir = "/sonic/" + PATCH_TABLE_LOC + PATCHWORK_LOC.format("5.10") content = "patchwork_link: https://patchwork.ozlabs.org/project/linux-i2c/patch/20230215195322.21955-1-vadimp@nvidia.com/\n" file = "0188-i2c-mux-Add-register-map-based-mux-driver.patch.txt" @@ -193,3 +183,84 @@ def test_commit_msg(self): assert slk.split() == TEST_SLK_COMMIT.split() assert sb.split() == TEST_SB_COMMIT.split() + def _parse_inc_excl(self): + KCFGData.x86_incl, KCFGData.x86_excl = self.kcfgaction.parse_inc_exc(KCFGData.x86_base, KCFGData.x86_updated) + KCFGData.arm_incl, KCFGData.arm_excl = self.kcfgaction.parse_inc_exc(KCFGData.arm_base, KCFGData.arm_updated) + + def _parse_noarch_inc_excl(self): + self._parse_inc_excl() + self.kcfgaction.parse_noarch_inc_exc() + + def _get_kcfg_incl_raw(self): + self._parse_noarch_inc_excl() + return self.kcfgaction.get_kconfig_inc() + + def _get_kcfg_incl_diff(self): + kcfg_raw = self._get_kcfg_incl_raw() + return self.kcfgaction.get_downstream_kconfig_inc(kcfg_raw) + + def test_parse_inc_excl(self): + self._parse_inc_excl() + test_x86_incl = OrderedDict({ + "CONFIG_THERMAL" : "y", + "CONFIG_THERMAL_OF" : "y", + "CONFIG_PINCTRL" : "y", + "CONFIG_DW_DMAC_PCI" : "y", + "CONFIG_TI_ADS1015" : "m", + "CONFIG_I2C_DESIGNWARE_CORE" : "m", + "CONFIG_I2C_DESIGNWARE_PCI" : "m" + }) + test_arm_incl = OrderedDict({ + "CONFIG_THERMAL" : "y", + "CONFIG_THERMAL_OF" : "y", + "CONFIG_MELLANOX_PLATFORM" : "y", + "CONFIG_THERMAL_WRITABLE_TRIPS" : "y", + "CONFIG_PMBUS" : "m", + "CONFIG_SENSORS_PMBUS" : "m", + "CONFIG_HWMON" : "y", + "CONFIG_OF" : "y", + "CONFIG_THERMAL_NETLINK" : "y" + }) + test_x86_excl = OrderedDict({"CONFIG_I2C_DESIGNWARE_BAYTRAIL" : "y"}) + assert KCFGData.x86_incl == test_x86_incl + assert KCFGData.x86_excl == test_x86_excl + assert KCFGData.arm_incl == test_arm_incl + + def test_parse_inc_excl_noarch(self): + self._parse_noarch_inc_excl() + test_x86_incl = OrderedDict({ + "CONFIG_PINCTRL" : "y", + "CONFIG_DW_DMAC_PCI" : "y", + "CONFIG_TI_ADS1015" : "m", + "CONFIG_I2C_DESIGNWARE_CORE" : "m", + "CONFIG_I2C_DESIGNWARE_PCI" : "m" + }) + test_arm_incl = OrderedDict({ + "CONFIG_MELLANOX_PLATFORM" : "y", + "CONFIG_THERMAL_WRITABLE_TRIPS" : "y", + "CONFIG_PMBUS" : "m", + "CONFIG_SENSORS_PMBUS" : "m", + "CONFIG_HWMON" : "y", + "CONFIG_OF" : "y", + "CONFIG_THERMAL_NETLINK" : "y" + }) + test_noarch_incl = OrderedDict({ + "CONFIG_THERMAL" : "y", + "CONFIG_THERMAL_OF" : "y" + }) + assert KCFGData.x86_incl == test_x86_incl + assert KCFGData.noarch_incl == test_noarch_incl + assert KCFGData.arm_incl == test_arm_incl + + @mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock) + def test_kcfg_incl_file(self, mock_write_lines_mock): + kcfg_raw = self._get_kcfg_incl_raw() + FileHandler.write_lines("", kcfg_raw, True) + assert check_file_content(MOCK_INPUTS_DIR+"expected_data/kconfig-inclusions") + + @mock.patch('helper.FileHandler.write_lines', side_effect=write_lines_mock) + def test_kcfg_excl(self, mock_write_lines_mock): + self._parse_noarch_inc_excl() + kcfg_excl = self.kcfgaction.get_kconfig_excl() + FileHandler.write_lines("", kcfg_excl, True) + assert check_file_content(MOCK_INPUTS_DIR+"expected_data/kconfig-exclusions") diff --git a/platform/mellanox/non-upstream-patches/README.md b/platform/mellanox/non-upstream-patches/README.md index f2f25abfc9ba..8fe02d4cb4a0 100644 --- a/platform/mellanox/non-upstream-patches/README.md +++ b/platform/mellanox/non-upstream-patches/README.md @@ -11,10 +11,10 @@ EXTERNAL_KERNEL_PATCH_LOC/ ├── 0002-mlx5-Implement-get_module_eeprom_by_page.patch.patch ├── 0005-mlx5-Add-support-for-DSFP-module-EEPROM-dumps.patch ├── ............. - ├──── series.patch + ├──── external-changes.patch ``` - 1. It should contain a file named series.patch. This should contain a diff that is applied on the sonic-linux-kernel/patch/series file. The diff should include all the non-upstream patches. + 1. It should contain a file named external-changes.patch. This should contain a diff that is applied on the sonic-linux-kernel/patch/* files. The diff should include all the non-upstream patches. 2. All the patches should be present in the patches folder 3. Developers should make sure patches apply cleanly over the existing patches present in the src/sonic-linux-kernel . diff --git a/platform/mellanox/non-upstream-patches/series.patch b/platform/mellanox/non-upstream-patches/external-changes.patch similarity index 100% rename from platform/mellanox/non-upstream-patches/series.patch rename to platform/mellanox/non-upstream-patches/external-changes.patch diff --git a/rules/config b/rules/config index c3c10e2d5975..ac6a30ba6e33 100644 --- a/rules/config +++ b/rules/config @@ -134,9 +134,6 @@ INCLUDE_ICCPD = n # INCLUDE_SFLOW - build docker-sflow for sFlow support INCLUDE_SFLOW = y -# ENABLE_SFLOW_DROPMON - support of drop packets monitoring feature for sFlow deamon -ENABLE_SFLOW_DROPMON = n - # INCLUDE_MGMT_FRAMEWORK - build docker-sonic-mgmt-framework for CLI and REST server support INCLUDE_MGMT_FRAMEWORK = y @@ -173,6 +170,9 @@ ENABLE_NATIVE_WRITE = y # INCLUDE_MACSEC - build docker-macsec for macsec support INCLUDE_MACSEC = y +# INCLUDE_GBSYNCD - build docker-gbsyncd-* for gearbox support +INCLUDE_GBSYNCD ?= y + # INCLUDE_TEAMD - build docker-teamd for LAG protocol support INCLUDE_TEAMD ?= y @@ -314,3 +314,9 @@ GZ_COMPRESS_PROGRAM ?= gzip # SONIC_OS_VERSION - sonic os version SONIC_OS_VERSION ?= 11 + +# PIP timeout for http connection +PIP_HTTP_TIMEOUT ?= 60 + +# BUILD_REDUCE_IMAGE_SIZE - reduce the image size as much as possbible +BUILD_REDUCE_IMAGE_SIZE = n diff --git a/rules/docker-dhcp-relay.mk b/rules/docker-dhcp-relay.mk index 06dd0f137fb6..701dcc7024e0 100644 --- a/rules/docker-dhcp-relay.mk +++ b/rules/docker-dhcp-relay.mk @@ -45,7 +45,7 @@ endif endif $(DOCKER_DHCP_RELAY)_CONTAINER_NAME = dhcp_relay -$(DOCKER_DHCP_RELAY)_CONTAINER_PRIVILEGED = true +$(DOCKER_DHCP_RELAY)_CONTAINER_PRIVILEGED = false $(DOCKER_DHCP_RELAY)_CONTAINER_VOLUMES += /etc/sonic:/etc/sonic:ro $(DOCKER_DHCP_RELAY)_CONTAINER_VOLUMES += /etc/timezone:/etc/timezone:ro $(DOCKER_DHCP_RELAY)_CONTAINER_TMPFS += /tmp/ diff --git a/rules/docker-dhcp-server.mk b/rules/docker-dhcp-server.mk index af600b81ec40..a65a6a3ca2e8 100644 --- a/rules/docker-dhcp-server.mk +++ b/rules/docker-dhcp-server.mk @@ -13,8 +13,8 @@ $(DOCKER_DHCP_SERVER)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_BULLSEYE)_DB $(DOCKER_DHCP_SERVER)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_BULLSEYE) -$(DOCKER_DHCP_SERVER)_INSTALL_PYTHON_WHEELS = $(SONIC_UTILITIES_PY3) $(DOCKER_DHCP_SERVER)_INSTALL_DEBS = $(PYTHON3_SWSSCOMMON) +$(DOCKER_DHCP_SERVER)_PYTHON_WHEELS += $(SONIC_DHCP_SERVER_PY3) SONIC_DOCKER_IMAGES += $(DOCKER_DHCP_SERVER) SONIC_DOCKER_DBG_IMAGES += $(DOCKER_DHCP_SERVER_DBG) @@ -40,7 +40,7 @@ $(DOCKER_DHCP_SERVER)_PACKAGE_NAME = dhcp-server $(DOCKER_MACSEC)_SERVICE_REQUIRES = updategraph $(DOCKER_MACSEC)_SERVICE_AFTER = swss syncd -$(DOCKER_DHCP_SERVER)_CONTAINER_PRIVILEGED = true +$(DOCKER_DHCP_SERVER)_CONTAINER_PRIVILEGED = false $(DOCKER_DHCP_SERVER)_CONTAINER_VOLUMES += /etc/sonic:/etc/sonic:ro $(DOCKER_DHCP_SERVER)_CONTAINER_TMPFS += /tmp/ $(DOCKER_DHCP_SERVER)_CONTAINER_TMPFS += /var/tmp/ @@ -48,5 +48,6 @@ $(DOCKER_DHCP_SERVER)_CONTAINER_TMPFS += /var/tmp/ $(DOCKER_DHCP_SERVER)_CLI_CONFIG_PLUGIN = /cli/config/plugins/dhcp_server.py $(DOCKER_DHCP_SERVER)_CLI_SHOW_PLUGIN = /cli/show/plugins/show_dhcp_server.py $(DOCKER_DHCP_SERVER)_CLI_CLEAR_PLUGIN = /cli/clear/plugins/clear_dhcp_server.py +$(DOCKER_DHCP_SERVER)_SUPPORT_RATE_LIMIT = false $(DOCKER_DHCP_SERVER)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) diff --git a/rules/docker-macsec.mk b/rules/docker-macsec.mk index 49f80133b9bd..bb85a65b4f89 100644 --- a/rules/docker-macsec.mk +++ b/rules/docker-macsec.mk @@ -38,10 +38,10 @@ endif $(DOCKER_MACSEC)_CONTAINER_NAME = macsec $(DOCKER_MACSEC)_VERSION = 1.0.0 $(DOCKER_MACSEC)_PACKAGE_NAME = macsec -$(DOCKER_MACSEC)_RUN_OPT += --privileged -t -$(DOCKER_MACSEC)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro -$(DOCKER_MACSEC)_RUN_OPT += -v /etc/timezone:/etc/timezone:ro -$(DOCKER_MACSEC)_RUN_OPT += -v /host/warmboot:/var/warmboot +$(DOCKER_MACSEC)_CONTAINER_PRIVILEGED = false +$(DOCKER_MACSEC)_CONTAINER_VOLUMES += /etc/sonic:/etc/sonic:ro +$(DOCKER_MACSEC)_CONTAINER_VOLUMES += /etc/timezone:/etc/timezone:ro +$(DOCKER_MACSEC)_CONTAINER_VOLUMES += /host/warmboot:/var/warmboot $(DOCKER_MACSEC)_SERVICE_REQUIRES = updategraph $(DOCKER_MACSEC)_SERVICE_AFTER = swss syncd diff --git a/rules/docker-sflow.mk b/rules/docker-sflow.mk index 3c7652f84f7e..3acd3c5dc86f 100644 --- a/rules/docker-sflow.mk +++ b/rules/docker-sflow.mk @@ -30,7 +30,7 @@ SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_SFLOW_DBG) endif $(DOCKER_SFLOW)_CONTAINER_NAME = sflow -$(DOCKER_SFLOW)_RUN_OPT += --privileged -t +$(DOCKER_SFLOW)_RUN_OPT += -t $(DOCKER_SFLOW)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro $(DOCKER_SFLOW)_RUN_OPT += -v /etc/timezone:/etc/timezone:ro $(DOCKER_SFLOW)_RUN_OPT += -v /host/warmboot:/var/warmboot diff --git a/rules/functions b/rules/functions index 33f4def2adc8..44a6af3ddcfb 100644 --- a/rules/functions +++ b/rules/functions @@ -143,7 +143,6 @@ SONIC_DBG_DOCKERS += $(2) endef - ############################################################################### ## Utility functions ############################################################################### diff --git a/rules/openssh.mk b/rules/openssh.mk index a5e4b5c4b7b0..5609bf34e49d 100644 --- a/rules/openssh.mk +++ b/rules/openssh.mk @@ -1,6 +1,6 @@ # openssh package -OPENSSH_VERSION = 8.4p1-5+deb11u1 +OPENSSH_VERSION = 8.4p1-5+deb11u2 export OPENSSH_VERSION @@ -9,6 +9,12 @@ $(OPENSSH_SERVER)_SRC_PATH = $(SRC_PATH)/openssh $(OPENSSH_SERVER)_DEPENDS += $(LIBNL3_DEV) $(LIBNL_ROUTE3_DEV) SONIC_MAKE_DEBS += $(OPENSSH_SERVER) +OPENSSH_CLIENT = openssh-client_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(OPENSSH_SERVER),$(OPENSSH_CLIENT))) + +OPENSSH_SFTP_SERVER = openssh-sftp-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb +$(eval $(call add_derived_package,$(OPENSSH_SERVER),$(OPENSSH_SFTP_SERVER))) + # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} # are archived into debug one image to facilitate debugging. # diff --git a/rules/sonic-dhcp-server.dep b/rules/sonic-dhcp-server.dep new file mode 100644 index 000000000000..891fffbe2052 --- /dev/null +++ b/rules/sonic-dhcp-server.dep @@ -0,0 +1,10 @@ +SPATH := $($(SONIC_DHCPSERVD)_SRC_PATH) +DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-dhcp-server.mk rules/sonic-dhcp-server.dep +DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) +SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) + +$(SONIC_DHCPSERVD)_CACHE_MODE := GIT_CONTENT_SHA +$(SONIC_DHCPSERVD)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) +$(SONIC_DHCPSERVD)_DEP_FILES := $(DEP_FILES) +$(SONIC_DHCPSERVD)_SMDEP_FILES := $(SMDEP_FILES) +$(SONIC_DHCPSERVD)_SMDEP_PATHS := $(SPATH) diff --git a/rules/sonic-dhcp-server.mk b/rules/sonic-dhcp-server.mk new file mode 100644 index 000000000000..941127204c3c --- /dev/null +++ b/rules/sonic-dhcp-server.mk @@ -0,0 +1,10 @@ +# sonic-dhcp-server package + +SONIC_DHCP_SERVER_PY3 = sonic_dhcp_server-1.0-py3-none-any.whl +$(SONIC_DHCP_SERVER_PY3)_SRC_PATH = $(SRC_PATH)/sonic-dhcp-server +$(SONIC_DHCP_SERVER_PY3)_DEPENDS += $(SONIC_PY_COMMON_PY3) +$(SONIC_DHCP_SERVER_PY3)_DEBS_DEPENDS = $(LIBSWSSCOMMON) $(PYTHON3_SWSSCOMMON) +$(SONIC_DHCP_SERVER_PY3)_PYTHON_VERSION = 3 +ifeq ($(INCLUDE_DHCP_SERVER), y) +SONIC_PYTHON_WHEELS += $(SONIC_DHCP_SERVER_PY3) +endif diff --git a/rules/sonic-fips.mk b/rules/sonic-fips.mk index 44a157bb1608..ad37f51e1fc8 100644 --- a/rules/sonic-fips.mk +++ b/rules/sonic-fips.mk @@ -1,8 +1,8 @@ # fips packages -FIPS_VERSION = 0.8 -FIPS_OPENSSL_VERSION = 1.1.1n-0+deb11u4+fips -FIPS_OPENSSH_VERSION = 8.4p1-5+deb11u1+fips +FIPS_VERSION = 0.9 +FIPS_OPENSSL_VERSION = 1.1.1n-0+deb11u5+fips +FIPS_OPENSSH_VERSION = 8.4p1-5+deb11u2+fips FIPS_PYTHON_MAIN_VERSION = 3.9 FIPS_PYTHON_VERSION = 3.9.2-1+fips FIPS_GOLANG_MAIN_VERSION = 1.15 diff --git a/scripts/build-optimize-fs-size.py b/scripts/build-optimize-fs-size.py new file mode 100755 index 000000000000..e442b753bf39 --- /dev/null +++ b/scripts/build-optimize-fs-size.py @@ -0,0 +1,253 @@ +#!/usr/bin/env python3 + +import argparse +import hashlib +import os +import shutil +import subprocess +import sys + +from collections import defaultdict +from functools import cached_property + +DRY_RUN = False +def enable_dry_run(enabled): + global DRY_RUN # pylint: disable=global-statement + DRY_RUN = enabled + +class File: + def __init__(self, path): + self.path = path + + def __str__(self): + return self.path + + def rmtree(self): + if DRY_RUN: + print(f'rmtree {self.path}') + return + shutil.rmtree(self.path) + + def hardlink(self, src): + if DRY_RUN: + print(f'hardlink {self.path} {src}') + return + st = self.stats + os.remove(self.path) + os.link(src.path, self.path) + os.chmod(self.path, st.st_mode) + os.chown(self.path, st.st_uid, st.st_gid) + os.utime(self.path, times=(st.st_atime, st.st_mtime)) + + @property + def name(self): + return os.path.basename(self.path) + + @cached_property + def stats(self): + return os.stat(self.path) + + @cached_property + def size(self): + return self.stats.st_size + + @cached_property + def checksum(self): + with open(self.path, 'rb') as f: + return hashlib.md5(f.read()).hexdigest() + +class FileManager: + def __init__(self, path): + self.path = path + self.files = [] + self.folders = [] + self.nindex = defaultdict(list) + self.cindex = defaultdict(list) + + def add_file(self, path): + if not os.path.isfile(path) or os.path.islink(path): + return + f = File(path) + self.files.append(f) + + def load_tree(self): + self.files = [] + self.folders = [] + for root, _, files in os.walk(self.path): + self.folders.append(File(root)) + for f in files: + self.add_file(os.path.join(root, f)) + print(f'loaded {len(self.files)} files and {len(self.folders)} folders') + + def generate_index(self): + print('Computing file hashes') + for f in self.files: + self.nindex[f.name].append(f) + self.cindex[(f.name, f.checksum)].append(f) + + def create_hardlinks(self): + print('Creating hard links') + for files in self.cindex.values(): + if len(files) <= 1: + continue + orig = files[0] + for f in files[1:]: + f.hardlink(orig) + +class FsRoot: + def __init__(self, path): + self.path = path + + def iter_fsroots(self): + yield self.path + dimgpath = os.path.join(self.path, 'var/lib/docker/overlay2') + for layer in os.listdir(dimgpath): + yield os.path.join(dimgpath, layer, 'diff') + + def collect_fsroot_size(self): + cmd = ['du', '-sb', self.path] + p = subprocess.run(cmd, text=True, check=False, + stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + return int(p.stdout.split()[0]) + + def _remove_root_paths(self, relpaths): + for root in self.iter_fsroots(): + for relpath in relpaths: + path = os.path.join(root, relpath) + if os.path.isdir(path): + if DRY_RUN: + print(f'rmtree {path}') + else: + shutil.rmtree(path) + + def remove_docs(self): + self._remove_root_paths([ + 'usr/share/doc', + 'usr/share/doc-base', + 'usr/local/share/doc', + 'usr/local/share/doc-base', + ]) + + def remove_mans(self): + self._remove_root_paths([ + 'usr/share/man', + 'usr/local/share/man', + ]) + + def remove_licenses(self): + self._remove_root_paths([ + 'usr/share/common-licenses', + ]) + + def hardlink_under(self, path): + fm = FileManager(os.path.join(self.path, path)) + fm.load_tree() + fm.generate_index() + fm.create_hardlinks() + + def remove_platforms(self, filter_func): + devpath = os.path.join(self.path, 'usr/share/sonic/device') + for platform in os.listdir(devpath): + if not filter_func(platform): + path = os.path.join(devpath, platform) + if DRY_RUN: + print(f'rmtree platform {path}') + else: + shutil.rmtree(path) + + def remove_modules(self, modules): + modpath = os.path.join(self.path, 'lib/modules') + kversion = os.listdir(modpath)[0] + kmodpath = os.path.join(modpath, kversion) + for module in modules: + path = os.path.join(kmodpath, module) + if os.path.isdir(path): + if DRY_RUN: + print(f'rmtree module {path}') + else: + shutil.rmtree(path) + + def remove_firmwares(self, firmwares): + fwpath = os.path.join(self.path, 'lib/firmware') + for fw in firmwares: + path = os.path.join(fwpath, fw) + if os.path.isdir(path): + if DRY_RUN: + print(f'rmtree firmware {path}') + else: + shutil.rmtree(path) + + + def specialize_aboot_image(self): + fp = lambda p: '-' not in p or 'arista' in p or 'common' in p + self.remove_platforms(fp) + self.remove_modules([ + 'kernel/drivers/gpu', + 'kernel/drivers/infiniband', + ]) + self.remove_firmwares([ + 'amdgpu', + 'i915', + 'mediatek', + 'nvidia', + 'radeon', + ]) + + def specialize_image(self, image_type): + if image_type == 'aboot': + self.specialize_aboot_image() + +def parse_args(args): + parser = argparse.ArgumentParser() + parser.add_argument('fsroot', + help="path to the fsroot build folder") + parser.add_argument('-s', '--stats', action='store_true', + help="show space statistics") + parser.add_argument('--hardlinks', action='append', + help="path where similar files need to be hardlinked") + parser.add_argument('--remove-docs', action='store_true', + help="remove documentation") + parser.add_argument('--remove-licenses', action='store_true', + help="remove license files") + parser.add_argument('--remove-mans', action='store_true', + help="remove manpages") + parser.add_argument('--image-type', default=None, + help="type of image being built") + parser.add_argument('--dry-run', action='store_true', + help="only display what would happen") + return parser.parse_args(args) + +def main(args): + args = parse_args(args) + + enable_dry_run(args.dry_run) + + fs = FsRoot(args.fsroot) + if args.stats: + begin = fs.collect_fsroot_size() + print(f'fsroot size is {begin} bytes') + + if args.remove_docs: + fs.remove_docs() + + if args.remove_mans: + fs.remove_mans() + + if args.remove_licenses: + fs.remove_licenses() + + if args.image_type: + fs.specialize_image(args.image_type) + + for path in args.hardlinks: + fs.hardlink_under(path) + + if args.stats: + end = fs.collect_fsroot_size() + pct = 100 - end / begin * 100 + print(f'fsroot reduced to {end} from {begin} {pct:.2f}') + + return 0 + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/scripts/generate_buildinfo_config.sh b/scripts/generate_buildinfo_config.sh index 87eb612007ba..d0bfb942ec4d 100755 --- a/scripts/generate_buildinfo_config.sh +++ b/scripts/generate_buildinfo_config.sh @@ -12,3 +12,4 @@ echo "export SONIC_VERSION_CACHE=${SONIC_VERSION_CACHE}" >> $BUILDINFO_CONFIG echo "export SONIC_VERSION_CACHE_SOURCE=${SONIC_VERSION_CACHE_SOURCE}" >> $BUILDINFO_CONFIG echo "export DISTRO=${DISTRO}" >> $BUILDINFO_CONFIG echo "export MIRROR_SNAPSHOT=$MIRROR_SNAPSHOT" >> $BUILDINFO_CONFIG +echo "export PIP_HTTP_TIMEOUT=$PIP_HTTP_TIMEOUT" >> $BUILDINFO_CONFIG diff --git a/slave.mk b/slave.mk index 6a51dc6ae9ab..a09adbaa7d26 100644 --- a/slave.mk +++ b/slave.mk @@ -417,7 +417,6 @@ $(info "INCLUDE_SYSTEM_TELEMETRY" : "$(INCLUDE_SYSTEM_TELEMETRY)") $(info "ENABLE_HOST_SERVICE_ON_START" : "$(ENABLE_HOST_SERVICE_ON_START)") $(info "INCLUDE_RESTAPI" : "$(INCLUDE_RESTAPI)") $(info "INCLUDE_SFLOW" : "$(INCLUDE_SFLOW)") -$(info "ENABLE_SFLOW_DROPMON" : "$(ENABLE_SFLOW_DROPMON)") $(info "INCLUDE_NAT" : "$(INCLUDE_NAT)") $(info "INCLUDE_DHCP_RELAY" : "$(INCLUDE_DHCP_RELAY)") $(info "INCLUDE_DHCP_SERVER" : "$(INCLUDE_DHCP_SERVER)") @@ -449,6 +448,34 @@ else $(info SONiC Build System for $(CONFIGURED_PLATFORM):$(CONFIGURED_ARCH)) endif +# Definition of SONIC_RFS_TARGETS +define rfs_get_installer_dependencies +$(call rfs_build_target_name,$(1),$($(1)_MACHINE)) +endef + +define rfs_build_target_name +$(1)__$(2)__rfs.squashfs +endef + +define rfs_define_target +$(eval rfs_target=$(call rfs_build_target_name,$(1),$($(1)_MACHINE))) +$(eval $(rfs_target)_INSTALLER=$(1)) +$(eval $(rfs_target)_MACHINE=$($(1)_MACHINE)) +$(eval SONIC_RFS_TARGETS+=$(rfs_target)) + +$(if $($(1)_DEPENDENT_MACHINE),\ + $(eval dependent_rfs_target=$(call rfs_build_target_name,$(1),$($(1)_DEPENDENT_MACHINE))) + $(eval $(dependent_rfs_target)_INSTALLER=$(1)) + $(eval $(dependent_rfs_target)_MACHINE=$($(1)_DEPENDENT_MACHINE)) + $(eval SONIC_RFS_TARGETS+=$(dependent_rfs_target)) + $(eval $(rfs_target)_DEPENDENT_RFS=$(dependent_rfs_target))) +endef + +$(foreach installer,$(SONIC_INSTALLERS),$(eval $(call rfs_define_target,$(installer)))) +$(foreach installer, $(SONIC_INSTALLERS), $(eval $(installer)_RFS_DEPENDS=$(call rfs_get_installer_dependencies,$(installer)))) + +SONIC_TARGET_LIST += $(addprefix $(TARGET_PATH)/, $(SONIC_RFS_TARGETS)) + # Overwrite the buildinfo in slave container ifeq ($(filter clean,$(MAKECMDGOALS)),) $(shell DBGOPT='$(DBGOPT)' scripts/prepare_slave_container_buildinfo.sh $(SLAVE_DIR) $(CONFIGURED_ARCH) $(BLDENV)) @@ -766,7 +793,7 @@ SONIC_TARGET_LIST += $(addprefix $(DEBS_PATH)/, $(SONIC_DPKG_DEBS)) # we depend on it and move our deb to other targets # Add new dev package: # $(eval $(call add_derived_package,$(ORIGINAL_DEB),derived_deb_file.deb)) -$(addprefix $(DEBS_PATH)/, $(SONIC_DERIVED_DEBS)) : $(DEBS_PATH)/% : .platform $$(addsuffix -install,$$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS))) +$(addprefix $(DEBS_PATH)/, $(SONIC_DERIVED_DEBS)) : $(DEBS_PATH)/% : .platform $$(addprefix $(DEBS_PATH)/,$$($$*_DEPENDS)) $(HEADER) # All noise takes place in main deb recipe, so we are just telling that # we depend on it @@ -1211,6 +1238,62 @@ $(DOCKER_LOAD_TARGETS) : $(TARGET_PATH)/%.gz-load : .platform docker-start $$(TA ## Installers ############################################################################### +$(addprefix $(TARGET_PATH)/, $(SONIC_RFS_TARGETS)) : $(TARGET_PATH)/% : \ + .platform \ + build_debian.sh \ + $(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(INITRAMFS_TOOLS) $(LINUX_KERNEL)) \ + $(addsuffix -install,$(addprefix $(IMAGE_DISTRO_DEBS_PATH)/,$(DEBOOTSTRAP))) \ + $$(addprefix $(TARGET_PATH)/,$$($$*_DEPENDENT_RFS)) \ + $(call dpkg_depend,$(TARGET_PATH)/%.dep) + $(HEADER) + + # $(call LOAD_CACHE,$*,$@) + + # Skip building the target if it is already loaded from cache + if [ -z '$($*_CACHE_LOADED)' ] ; then + + $(eval installer=$($*_INSTALLER)) + $(eval machine=$($*_MACHINE)) + + export debs_path="$(IMAGE_DISTRO_DEBS_PATH)" + export initramfs_tools="$(IMAGE_DISTRO_DEBS_PATH)/$(INITRAMFS_TOOLS)" + export linux_kernel="$(IMAGE_DISTRO_DEBS_PATH)/$(LINUX_KERNEL)" + export kversion="$(KVERSION)" + export image_type="$($(installer)_IMAGE_TYPE)" + export sonicadmin_user="$(USERNAME)" + export sonic_asic_platform="$(patsubst %-$(CONFIGURED_ARCH),%,$(CONFIGURED_PLATFORM))" + export RFS_SPLIT_FIRST_STAGE=y + export RFS_SPLIT_LAST_STAGE=n + + j2 -f env files/initramfs-tools/union-mount.j2 onie-image.conf > files/initramfs-tools/union-mount + j2 -f env files/initramfs-tools/arista-convertfs.j2 onie-image.conf > files/initramfs-tools/arista-convertfs + + RFS_SQUASHFS_NAME=$* \ + USERNAME="$(USERNAME)" \ + PASSWORD="$(PASSWORD)" \ + CHANGE_DEFAULT_PASSWORD="$(CHANGE_DEFAULT_PASSWORD)" \ + TARGET_MACHINE=$(machine) \ + IMAGE_TYPE=$($(installer)_IMAGE_TYPE) \ + TARGET_PATH=$(TARGET_PATH) \ + TRUSTED_GPG_URLS=$(TRUSTED_GPG_URLS) \ + SONIC_ENABLE_SECUREBOOT_SIGNATURE="$(SONIC_ENABLE_SECUREBOOT_SIGNATURE)" \ + SIGNING_KEY="$(SIGNING_KEY)" \ + SIGNING_CERT="$(SIGNING_CERT)" \ + PACKAGE_URL_PREFIX=$(PACKAGE_URL_PREFIX) \ + DBGOPT='$(DBGOPT)' \ + SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \ + MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) \ + CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) \ + MASTER_KUBERNETES_VERSION=$(MASTER_KUBERNETES_VERSION) \ + MASTER_CRI_DOCKERD=$(MASTER_CRI_DOCKERD) \ + ./build_debian.sh $(LOG) + + $(call SAVE_CACHE,$*,$@) + + fi + + $(FOOTER) + # targets for building installers with base image $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ .platform \ @@ -1265,7 +1348,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ $(addprefix $(FILES_PATH)/,$($(SONIC_CTRMGRD)_FILES)) \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_YANG_MGMT_PY3)) \ $(addprefix $(PYTHON_WHEELS_PATH)/,$(SYSTEM_HEALTH)) \ - $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_HOST_SERVICES_PY3)) + $(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_HOST_SERVICES_PY3)) \ + $$(addprefix $(TARGET_PATH)/,$$($$*_RFS_DEPENDS)) + $(HEADER) # Pass initramfs and linux kernel explicitly. They are used for all platforms export debs_path="$(IMAGE_DISTRO_DEBS_PATH)" @@ -1421,6 +1506,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ chmod +x sonic_debian_extension.sh, ) + export RFS_SPLIT_FIRST_STAGE=n + export RFS_SPLIT_LAST_STAGE=y + # Build images for the MACHINE, DEPENDENT_MACHINE defined. $(foreach dep_machine, $($*_MACHINE) $($*_DEPENDENT_MACHINE), \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ @@ -1428,6 +1516,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ scripts/dbg_files.sh + RFS_SQUASHFS_NAME=$*__$(dep_machine)__rfs.squashfs \ DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ DEBUG_SRC_ARCHIVE_FILE="$(DBG_SRC_ARCHIVE_FILE)" \ USERNAME="$(USERNAME)" \ @@ -1447,6 +1536,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ SONIC_VERSION_CACHE=$(SONIC_VERSION_CACHE) \ MULTIARCH_QEMU_ENVIRON=$(MULTIARCH_QEMU_ENVIRON) \ CROSS_BUILD_ENVIRON=$(CROSS_BUILD_ENVIRON) \ + BUILD_REDUCE_IMAGE_SIZE=$(BUILD_REDUCE_IMAGE_SIZE) \ MASTER_KUBERNETES_VERSION=$(MASTER_KUBERNETES_VERSION) \ MASTER_KUBERNETES_CONTAINER_IMAGE_VERSION=$(MASTER_KUBERNETES_CONTAINER_IMAGE_VERSION) \ MASTER_PAUSE_VERSION=$(MASTER_PAUSE_VERSION) \ @@ -1522,7 +1612,9 @@ SONIC_CLEAN_TARGETS += $(addsuffix -clean,$(addprefix $(TARGET_PATH)/, \ $(SONIC_DOCKER_IMAGES) \ $(SONIC_DOCKER_DBG_IMAGES) \ $(SONIC_SIMPLE_DOCKER_IMAGES) \ - $(SONIC_INSTALLERS))) + $(SONIC_INSTALLERS) \ + $(SONIC_RFS_TARGETS))) + $(SONIC_CLEAN_TARGETS) :: $(TARGET_PATH)/%-clean : .platform $(Q)rm -rf $(TARGET_PATH)/$* target/versions/dockers/$(subst .gz,,$*) diff --git a/src/openssh/Makefile b/src/openssh/Makefile index 29df8e76292c..c52a86baf4e2 100644 --- a/src/openssh/Makefile +++ b/src/openssh/Makefile @@ -3,7 +3,11 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = openssh-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb -DERIVED_TARGETS = openssh-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb +DERIVED_TARGETS = openssh-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb \ + openssh-client_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb \ + openssh-client-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb \ + openssh-sftp-server_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb \ + openssh-sftp-server-dbgsym_$(OPENSSH_VERSION)_$(CONFIGURED_ARCH).deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain openssh: https://salsa.debian.org/ssh-team/openssh/-/tree/debian/1%258.4p1-5 diff --git a/src/sflow/hsflowd/Makefile b/src/sflow/hsflowd/Makefile index 35d17783f903..5a9bf6047391 100644 --- a/src/sflow/hsflowd/Makefile +++ b/src/sflow/hsflowd/Makefile @@ -16,11 +16,6 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : stg init stg import -s ../patch/series - if [[ $(ENABLE_SFLOW_DROPMON) == y ]]; then - stg repair - stg import -s ../patch/dropmon/series - fi - mkdir -p debian cp -r DEBIAN_build/* debian chmod u+x debian/rules diff --git a/src/sflow/hsflowd/patch/dropmon/0001-sflow-enabled-drop-monitor-support-for-SONiC.patch b/src/sflow/hsflowd/patch/0003-sflow-enabled-drop-monitor-support-for-SONiC.patch similarity index 100% rename from src/sflow/hsflowd/patch/dropmon/0001-sflow-enabled-drop-monitor-support-for-SONiC.patch rename to src/sflow/hsflowd/patch/0003-sflow-enabled-drop-monitor-support-for-SONiC.patch diff --git a/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch b/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch deleted file mode 100644 index 80a2a20aa8eb..000000000000 --- a/src/sflow/hsflowd/patch/dropmon/0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch +++ /dev/null @@ -1,172 +0,0 @@ -From 6ad3a8ef0339041a800a41dac96370c11b72d814 Mon Sep 17 00:00:00 2001 -From: Vadym Hlushko -Date: Fri, 4 Feb 2022 15:11:48 +0000 -Subject: [PATCH] [dropmon] workaround - created local copy of -TDB: this patch will be removed when we update docker-sflow to bullseye kernel. - -Signed-off-by: Vadym Hlushko ---- - src/Linux/mod_dropmon.c | 2 +- - src/Linux/my_dropmon.h | 132 ++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 133 insertions(+), 1 deletion(-) - create mode 100644 src/Linux/my_dropmon.h - -diff --git a/src/Linux/mod_dropmon.c b/src/Linux/mod_dropmon.c -index 6b8ec6d..a37b157 100644 ---- a/src/Linux/mod_dropmon.c -+++ b/src/Linux/mod_dropmon.c -@@ -7,12 +7,12 @@ extern "C" { - #endif - - #include "hsflowd.h" -+#include "my_dropmon.h" - #include - #include - #include - #include - #include --#include - #include - #include - -diff --git a/src/Linux/my_dropmon.h b/src/Linux/my_dropmon.h -new file mode 100644 -index 0000000..66048cc ---- /dev/null -+++ b/src/Linux/my_dropmon.h -@@ -0,0 +1,132 @@ -+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -+#ifndef __NET_DROPMON_H -+#define __NET_DROPMON_H -+ -+#include -+#include -+ -+struct net_dm_drop_point { -+ __u8 pc[8]; -+ __u32 count; -+}; -+ -+#define is_drop_point_hw(x) do {\ -+ int ____i, ____j;\ -+ for (____i = 0; ____i < 8; i ____i++)\ -+ ____j |= x[____i];\ -+ ____j;\ -+} while (0) -+ -+#define NET_DM_CFG_VERSION 0 -+#define NET_DM_CFG_ALERT_COUNT 1 -+#define NET_DM_CFG_ALERT_DELAY 2 -+#define NET_DM_CFG_MAX 3 -+ -+struct net_dm_config_entry { -+ __u32 type; -+ __u64 data __attribute__((aligned(8))); -+}; -+ -+struct net_dm_config_msg { -+ __u32 entries; -+ struct net_dm_config_entry options[0]; -+}; -+ -+struct net_dm_alert_msg { -+ __u32 entries; -+ struct net_dm_drop_point points[0]; -+}; -+ -+struct net_dm_user_msg { -+ union { -+ struct net_dm_config_msg user; -+ struct net_dm_alert_msg alert; -+ } u; -+}; -+ -+ -+/* These are the netlink message types for this protocol */ -+ -+enum { -+ NET_DM_CMD_UNSPEC = 0, -+ NET_DM_CMD_ALERT, -+ NET_DM_CMD_CONFIG, -+ NET_DM_CMD_START, -+ NET_DM_CMD_STOP, -+ NET_DM_CMD_PACKET_ALERT, -+ NET_DM_CMD_CONFIG_GET, -+ NET_DM_CMD_CONFIG_NEW, -+ NET_DM_CMD_STATS_GET, -+ NET_DM_CMD_STATS_NEW, -+ _NET_DM_CMD_MAX, -+}; -+ -+#define NET_DM_CMD_MAX (_NET_DM_CMD_MAX - 1) -+ -+/* -+ * Our group identifiers -+ */ -+#define NET_DM_GRP_ALERT 1 -+ -+enum net_dm_attr { -+ NET_DM_ATTR_UNSPEC, -+ -+ NET_DM_ATTR_ALERT_MODE, /* u8 */ -+ NET_DM_ATTR_PC, /* u64 */ -+ NET_DM_ATTR_SYMBOL, /* string */ -+ NET_DM_ATTR_IN_PORT, /* nested */ -+ NET_DM_ATTR_TIMESTAMP, /* u64 */ -+ NET_DM_ATTR_PROTO, /* u16 */ -+ NET_DM_ATTR_PAYLOAD, /* binary */ -+ NET_DM_ATTR_PAD, -+ NET_DM_ATTR_TRUNC_LEN, /* u32 */ -+ NET_DM_ATTR_ORIG_LEN, /* u32 */ -+ NET_DM_ATTR_QUEUE_LEN, /* u32 */ -+ NET_DM_ATTR_STATS, /* nested */ -+ NET_DM_ATTR_HW_STATS, /* nested */ -+ NET_DM_ATTR_ORIGIN, /* u16 */ -+ NET_DM_ATTR_HW_TRAP_GROUP_NAME, /* string */ -+ NET_DM_ATTR_HW_TRAP_NAME, /* string */ -+ NET_DM_ATTR_HW_ENTRIES, /* nested */ -+ NET_DM_ATTR_HW_ENTRY, /* nested */ -+ NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */ -+ NET_DM_ATTR_SW_DROPS, /* flag */ -+ NET_DM_ATTR_HW_DROPS, /* flag */ -+ NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */ -+ -+ __NET_DM_ATTR_MAX, -+ NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1 -+}; -+ -+/** -+ * enum net_dm_alert_mode - Alert mode. -+ * @NET_DM_ALERT_MODE_SUMMARY: A summary of recent drops is sent to user space. -+ * @NET_DM_ALERT_MODE_PACKET: Each dropped packet is sent to user space along -+ * with metadata. -+ */ -+enum net_dm_alert_mode { -+ NET_DM_ALERT_MODE_SUMMARY, -+ NET_DM_ALERT_MODE_PACKET, -+}; -+ -+enum { -+ NET_DM_ATTR_PORT_NETDEV_IFINDEX, /* u32 */ -+ NET_DM_ATTR_PORT_NETDEV_NAME, /* string */ -+ -+ __NET_DM_ATTR_PORT_MAX, -+ NET_DM_ATTR_PORT_MAX = __NET_DM_ATTR_PORT_MAX - 1 -+}; -+ -+enum { -+ NET_DM_ATTR_STATS_DROPPED, /* u64 */ -+ -+ __NET_DM_ATTR_STATS_MAX, -+ NET_DM_ATTR_STATS_MAX = __NET_DM_ATTR_STATS_MAX - 1 -+}; -+ -+enum net_dm_origin { -+ NET_DM_ORIGIN_SW, -+ NET_DM_ORIGIN_HW, -+}; -+ -+#endif --- -2.17.1 - diff --git a/src/sflow/hsflowd/patch/dropmon/series b/src/sflow/hsflowd/patch/dropmon/series deleted file mode 100644 index 1a4bb1772ac3..000000000000 --- a/src/sflow/hsflowd/patch/dropmon/series +++ /dev/null @@ -1,2 +0,0 @@ -0001-dropmon-workaround-created-local-copy-of-linux-net_dropmon.patch -0001-sflow-enabled-drop-monitor-support-for-SONiC.patch \ No newline at end of file diff --git a/src/sflow/hsflowd/patch/series b/src/sflow/hsflowd/patch/series index 90f9e47462e5..f6def262debc 100644 --- a/src/sflow/hsflowd/patch/series +++ b/src/sflow/hsflowd/patch/series @@ -1,2 +1,3 @@ 0001-host_sflow_psample.patch 0002-host_sflow_debian.patch +0003-sflow-enabled-drop-monitor-support-for-SONiC.patch diff --git a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_back.conf b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_back.conf index c6acef329eff..da0e6b77339e 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_back.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_back.conf @@ -10,6 +10,7 @@ neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out neighbor INTERNAL_PEER_V4 send-community + neighbor INTERNAL_PEER_V4 ttl-security hops 1 exit-address-family address-family ipv6 neighbor INTERNAL_PEER_V6 route-reflector-client @@ -18,6 +19,7 @@ neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out neighbor INTERNAL_PEER_V6 send-community + neighbor INTERNAL_PEER_V6 ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/internal/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf index e4fb05eeb766..64b30e514d8c 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_chasiss_packet.conf @@ -10,6 +10,7 @@ neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out neighbor INTERNAL_PEER_V4 send-community + neighbor INTERNAL_PEER_V4 ttl-security hops 1 exit-address-family neighbor INTERNAL_PEER_V6 update-source Loopback4096 address-family ipv6 @@ -18,6 +19,7 @@ neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out neighbor INTERNAL_PEER_V6 send-community + neighbor INTERNAL_PEER_V6 ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/internal/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_front.conf b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_front.conf index 7b6ee2667de9..363040eb12f5 100644 --- a/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_front.conf +++ b/src/sonic-bgpcfgd/tests/data/internal/peer-group.conf/result_front.conf @@ -9,6 +9,7 @@ neighbor INTERNAL_PEER_V4 route-map FROM_BGP_INTERNAL_PEER_V4 in neighbor INTERNAL_PEER_V4 route-map TO_BGP_INTERNAL_PEER_V4 out neighbor INTERNAL_PEER_V4 send-community + neighbor INTERNAL_PEER_V4 ttl-security hops 1 exit-address-family address-family ipv6 neighbor INTERNAL_PEER_V6 soft-reconfiguration inbound @@ -16,6 +17,7 @@ neighbor INTERNAL_PEER_V6 route-map FROM_BGP_INTERNAL_PEER_V6 in neighbor INTERNAL_PEER_V6 route-map TO_BGP_INTERNAL_PEER_V6 out neighbor INTERNAL_PEER_V6 send-community + neighbor INTERNAL_PEER_V6 ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/internal/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf index 350ff0eeeb41..3a80739e3cb8 100644 --- a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf +++ b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_all.conf @@ -11,6 +11,7 @@ neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V4_PEER in neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V4_PEER out neighbor VOQ_CHASSIS_V4_PEER send-community + neighbor VOQ_CHASSIS_V4_PEER ttl-security hops 1 exit-address-family address-family ipv6 neighbor VOQ_CHASSIS_V6_PEER allowas-in 1 @@ -20,6 +21,7 @@ neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out neighbor VOQ_CHASSIS_V6_PEER send-community + neighbor VOQ_CHASSIS_V6_PEER ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf index 9818358a771f..450e8a911eb1 100644 --- a/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf +++ b/src/sonic-bgpcfgd/tests/data/voq_chassis/peer-group.conf/result_base.conf @@ -10,6 +10,7 @@ neighbor VOQ_CHASSIS_V4_PEER route-map FROM_VOQ_CHASSIS_V4_PEER in neighbor VOQ_CHASSIS_V4_PEER route-map TO_VOQ_CHASSIS_V4_PEER out neighbor VOQ_CHASSIS_V4_PEER send-community + neighbor VOQ_CHASSIS_V4_PEER ttl-security hops 1 exit-address-family address-family ipv6 neighbor VOQ_CHASSIS_V6_PEER activate @@ -18,6 +19,7 @@ neighbor VOQ_CHASSIS_V6_PEER route-map FROM_VOQ_CHASSIS_V6_PEER in neighbor VOQ_CHASSIS_V6_PEER route-map TO_VOQ_CHASSIS_V6_PEER out neighbor VOQ_CHASSIS_V6_PEER send-community + neighbor VOQ_CHASSIS_V6_PEER ttl-security hops 1 exit-address-family ! ! end of template: bgpd/templates/voq_chassis/peer-group.conf.j2 diff --git a/src/sonic-build-hooks/scripts/buildinfo_base.sh b/src/sonic-build-hooks/scripts/buildinfo_base.sh index 2c85cb665c21..37a84a0c6fa9 100755 --- a/src/sonic-build-hooks/scripts/buildinfo_base.sh +++ b/src/sonic-build-hooks/scripts/buildinfo_base.sh @@ -288,7 +288,7 @@ download_packages() run_pip_command() { - declare -a parameters=("$@") + declare -a parameters=("--default-timeout" "$PIP_HTTP_TIMEOUT" "$@") PIP_CACHE_PATH=${PKG_CACHE_PATH}/pip PKG_CACHE_OPTION="--cache-dir=${PIP_CACHE_PATH}" diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index 4919876bd7a5..cc405e21a76b 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -41,6 +41,11 @@ backend_device_types = ['BackEndToRRouter', 'BackEndLeafRouter'] console_device_types = ['MgmtTsToR'] dhcp_server_enabled_device_types = ['BmcMgmtToRRouter'] +mgmt_device_types = ['BmcMgmtToRRouter', 'MgmtToRRouter', 'MgmtTsToR'] + +# Counters disabled on management devices +mgmt_disabled_counters = ["BUFFER_POOL_WATERMARK", "PFCWD", "PG_DROP", "PG_WATERMARK", "PORT_BUFFER_DROP", "QUEUE", "QUEUE_WATERMARK"] + VLAN_SUB_INTERFACE_SEPARATOR = '.' VLAN_SUB_INTERFACE_VLAN_ID = '10' @@ -2104,6 +2109,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw if current_device and current_device['type'] in dhcp_server_enabled_device_types: results['DEVICE_METADATA']['localhost']['dhcp_server'] = 'enabled' + # Disable unsupported counters on management devices + if current_device and current_device['type'] in mgmt_device_types: + results["FLEX_COUNTER_TABLE"] = {counter: {"FLEX_COUNTER_STATUS": "disable"} for counter in mgmt_disabled_counters} + return results def get_tunnel_entries(tunnel_intfs, tunnel_intfs_qos_remap_config, lo_intfs, tunnel_qos_remap, mux_tunnel_name, peer_switch_ip): diff --git a/src/sonic-config-engine/tests/simple-sample-graph-m0.xml b/src/sonic-config-engine/tests/simple-sample-graph-m0.xml new file mode 100644 index 000000000000..43193b7eb651 --- /dev/null +++ b/src/sonic-config-engine/tests/simple-sample-graph-m0.xml @@ -0,0 +1,914 @@ + + + + + + false + switch-m0 + 10.0.0.56 + ARISTA01M1 + 10.0.0.57 + 1 + 10 + 3 + + + switch-m0 + FC00::71 + ARISTA01M1 + FC00::72 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.64 + ARISTA01MX + 10.0.0.65 + 1 + 10 + 3 + + + switch-m0 + FC00::81 + ARISTA01MX + FC00::82 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.58 + ARISTA02M1 + 10.0.0.59 + 1 + 10 + 3 + + + switch-m0 + FC00::75 + ARISTA02M1 + FC00::76 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.66 + ARISTA02MX + 10.0.0.67 + 1 + 10 + 3 + + + switch-m0 + FC00::85 + ARISTA02MX + FC00::86 + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.60 + ARISTA03M1 + 10.0.0.61 + 1 + 10 + 3 + + + switch-m0 + FC00::79 + ARISTA03M1 + FC00::7A + 1 + 10 + 3 + + + false + switch-m0 + 10.0.0.62 + ARISTA04M1 + 10.0.0.63 + 1 + 10 + 3 + + + switch-m0 + FC00::7D + ARISTA04M1 + FC00::7E + 1 + 10 + 3 + + + + + 65100 + switch-m0 + + +
10.0.0.57
+ + + +
+ +
10.0.0.65
+ + + +
+ +
10.0.0.59
+ + + +
+ +
10.0.0.67
+ + + +
+ +
10.0.0.61
+ + + +
+ +
10.0.0.63
+ + + +
+ + BGPPeer +
10.1.0.32
+ + + + BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21 +
+
+ +
+ + 65200 + ARISTA01M1 + + + + 64001 + ARISTA01MX + + + + 65200 + ARISTA02M1 + + + + 64002 + ARISTA02MX + + + + 65200 + ARISTA03M1 + + + + 65200 + ARISTA04M1 + + +
+
+ + + + + + HostIP + Loopback0 + + 10.1.0.32/32 + + 10.1.0.32/32 + + + HostIP1 + Loopback0 + + FC00:1::32/128 + + FC00:1::32/128 + + + + + HostIP + eth0 + + 10.0.0.100/24 + + 10.0.0.100/24 + + + + + + + switch-m0 + + + PortChannel101 + etp49 + + + + PortChannel103 + etp50 + + + + PortChannel105 + etp51 + + + + PortChannel106 + etp52 + + + + + + ab1 + fortyGigE0/8 + 192.0.0.1;192.0.0.2 + 1000 + 1000 + 192.168.0.0/27 + + + ab4 + fortyGigE0/8 + 192.0.0.1;192.0.0.2 + 1001 + 1001 + 192.168.0.32/27 + + + kk1 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2020 + 2020 + Tagged + 192.168.0.0/28 + + + ab2 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2000 + 2000 + Tagged + 192.168.0.240/27 + + + ab3 + fortyGigE0/12 + 192.0.0.1;192.0.0.2 + 2001 + 2001 + 192.168.0.240/27 + + + + + + PortChannel1 + 10.0.0.56/31 + + + + PortChannel1 + FC00::71/126 + + + + PortChannel1001 + 10.0.0.57/31 + + + + PortChannel1001 + FC00::72/126 + + + + fortyGigE0/0 + 10.0.0.58/31 + + + + fortyGigE0/0 + FC00::75/126 + + + + ab1 + 192.168.0.1/27 + + + + + + PortChannel1 + DataAcl + DataPlane + + + SNMP + SNMP_ACL + SNMP + + + + + + + + + + DeviceInterfaceLink + ARISTA01M1 + Ethernet1 + switch-m0 + etp49 + 10000 + + + DeviceInterfaceLink + ARISTA01MX + Ethernet1 + switch-m0 + etp47 + 1000 + + + DeviceInterfaceLink + ARISTA02M1 + Ethernet1 + switch-m0 + etp50 + 10000 + + + DeviceInterfaceLink + ARISTA02MX + Ethernet1 + switch-m0 + etp48 + 1000 + + + DeviceInterfaceLink + ARISTA03M1 + Ethernet1 + switch-m0 + etp51 + 10000 + + + DeviceInterfaceLink + ARISTA04M1 + Ethernet1 + switch-m0 + etp52 + 10000 + + + DeviceInterfaceLink + switch-m0 + etp1 + Servers0 + eth0 + + + DeviceInterfaceLink + switch-m0 + etp2 + Servers1 + eth0 + + + + + switch-m0 + Nokia-M0-7215 + AAA00PrdStr00 + + + ARISTA04M1 + Arista + + + ARISTA02M1 + Arista + + + ARISTA02MX + Arista + + + ARISTA01MX + Arista + + + ARISTA01M1 + Arista + + + ARISTA03M1 + Arista + + + + + + + + DeviceInterface + + true + 1 + fortyGigE0/0 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + Ethernet1 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + Ethernet2 + + false + 0 + 0 + 10000 + + + DeviceInterface + + true + 1 + fortyGigE0/4 + + false + 0 + 0 + 25000 + + + DeviceInterface + + true + 1 + fortyGigE0/8 + + false + 0 + 0 + 40000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/12 + + false + 0 + 0 + 100000 + Interface description + + + DeviceInterface + + true + 1 + fortyGigE0/16 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/20 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/24 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/28 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/32 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/36 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/40 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/44 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/48 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/52 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/56 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/60 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/64 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/68 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/72 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/76 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/80 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/84 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/88 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/92 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/96 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/100 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/104 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/108 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/112 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/116 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/120 + + false + 0 + 0 + 100000 + + + DeviceInterface + + true + 1 + fortyGigE0/124 + + false + 0 + 0 + 100000 + + + true + 0 + Force10-S6000 + + + DeviceInterface + + 1 + Management1 + false + mgmt1 + 1000 + + + + + + + + switch-m0 + + + DeploymentId + + 1 + + + + + + + switch-m0 + Nokia-M0-7215 +
diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml b/src/sonic-config-engine/tests/simple-sample-graph-mx.xml similarity index 83% rename from src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml rename to src/sonic-config-engine/tests/simple-sample-graph-mx.xml index 6c29fb47e42f..db3410201019 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case-acl-type-bmcdata.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-mx.xml @@ -2,138 +2,91 @@ - - switch-t0 - 10.1.0.32 - BGPMonitor - 10.20.30.40 - 30 - 10 - 3 - false - switch-t0 - 10.0.0.56 - ARISTA01T1 - 10.0.0.57 + switch-mx + 10.0.0.64 + ARISTA01M0 + 10.0.0.65 1 - 180 - 60 + 10 + 3 - switch-t0 - FC00::71 - ARISTA01T1 - FC00::72 + switch-mx + FC00::81 + ARISTA01M0 + FC00::82 1 - 180 - 60 + 10 + 3 false - switch-t0 - 10.0.0.58 - ARISTA02T1 - 10.0.0.59 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 - 1 - 180 - 60 - - - switch-t0 - FC00::75 - ARISTA02T1 - FC00::76 + switch-mx + 10.0.0.66 + ARISTA02M0 + 10.0.0.67 1 - 180 - 60 + 10 + 3 - false - switch-t0 - 10.2.0.20 - CHASSIS_PEER - 10.2.0.21 + switch-mx + FC00::85 + ARISTA02M0 + FC00::86 1 - 180 - 60 - voq + 10 + 3 - 1 - - BGPMonitor - - - BGPPeer -
10.1.0.32
- - - -
-
- -
- - 65100 - switch-t0 + 64001 + switch-mx -
10.0.0.57
+
10.0.0.65
-
10.0.0.59
+
10.0.0.67
- -
10.2.0.21
+ + BGPPeer +
10.1.0.32
+ BGPSLBPassive + 10.255.0.0/25 +
+ + BGPPeer +
10.1.0.32
+ + + + BGPVac + 192.168.0.0/21
- 64600 - ARISTA01T1 - - - - 64600 - ARISTA02T1 - - - - 64600 - ARISTA03T1 - - - - 64600 - ARISTA04T1 + 65100 + ARISTA01M0 65100 - CHASSIS_PEER + ARISTA02M0
@@ -173,13 +126,8 @@ - switch-t0 + switch-mx - - PortChannel1 - fortyGigE0/4 - - @@ -293,54 +241,47 @@ DeviceInterfaceLink + ARISTA01M0 + Ethernet1 + switch-mx + etp47 1000 - ARISTA01T1 - et1 - true - switch-t0 - fortyGigE0/8 - true - - DeviceMgmtLink + + DeviceInterfaceLink + ARISTA02M0 + Ethernet1 + switch-mx + etp48 1000 - switch-t0 - fortyGigE0/16 - true - ChassisMTS1 - mgmt0 - true - - DeviceMgmtLink - 1000 - switch-t0 - Management1 - switch-m0 - Management1 - true + + DeviceInterfaceLink + switch-mx + etp1 + Servers0 + eth0 + + + DeviceInterfaceLink + switch-mx + etp2 + Servers1 + eth0 - - switch-t0 - Force10-S6000 + + switch-mx + Arista-720DT-G48S4 AAA00PrdStr00 - - ARISTA01T1 - Arista - - - ARISTA02T1 - Arista - - - ARISTA03T1 + + ARISTA01M0 Arista - - ARISTA04T1 + + ARISTA02M0 Arista @@ -778,7 +719,7 @@ - switch-t0 + switch-mx DeploymentId @@ -790,6 +731,6 @@ - switch-t0 - Force10-S6000 + switch-mx + Arista-720DT-G48S4 diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index f3b539253b19..60525777d242 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -519,8 +519,8 @@ def test_minigraph_acl_type_bmcdata(self): 'type': 'BMCDATAV6', } # TC1: Minigraph contains acl table type BmcData - sample_graph = os.path.join(self.test_dir,'simple-sample-graph-case-acl-type-bmcdata.xml') - result = minigraph.parse_xml(sample_graph) + sample_mx_graph = os.path.join(self.test_dir,'simple-sample-graph-mx.xml') + result = minigraph.parse_xml(sample_mx_graph) self.assertIn('ACL_TABLE_TYPE', result) self.assertIn('BMCDATA', result['ACL_TABLE_TYPE']) self.assertIn('BMCDATAV6', result['ACL_TABLE_TYPE']) @@ -548,3 +548,22 @@ def test_parse_device_desc_xml_mgmt_interface(self): self.assertEqual(len(mgmt_intf.keys()), 1) self.assertTrue(('eth0', 'FC00:1::32/64') in mgmt_intf.keys()) self.assertTrue(ipaddress.ip_address(u'fc00:1::1') == mgmt_intf[('eth0', 'FC00:1::32/64')]['gwaddr']) + + def test_mgmt_device_disable_counters(self): + expected_mgmt_disabled_counters = ["BUFFER_POOL_WATERMARK", "PFCWD", "PG_DROP", "PG_WATERMARK", "PORT_BUFFER_DROP", "QUEUE", "QUEUE_WATERMARK"] + expected_mgmt_enabled_counters = ["ACL", "PORT", "RIF"] + # TC1: For M0 and Mx minigraph, counters are configured as expected + mgmt_graphs = ['simple-sample-graph-mx.xml', 'simple-sample-graph-m0.xml'] + for graph in mgmt_graphs: + graph_path = os.path.join(self.test_dir, graph) + result = minigraph.parse_xml(graph_path) + self.assertIn('FLEX_COUNTER_TABLE', result) + for counter in expected_mgmt_disabled_counters: + self.assertIn(counter, result['FLEX_COUNTER_TABLE']) + self.assertDictEqual(result['FLEX_COUNTER_TABLE'][counter], {'FLEX_COUNTER_STATUS': 'disable'}) + for counter in expected_mgmt_enabled_counters: + if counter in result['FLEX_COUNTER_TABLE']: + self.assertDictEqual(result['FLEX_COUNTER_TABLE'][counter], {'FLEX_COUNTER_STATUS': 'enable'}) + # TC2: For other minigraph, result should not contain FLEX_COUNTER_TABLE + result = minigraph.parse_xml(self.sample_graph) + self.assertNotIn('FLEX_COUNTER_TABLE', result) diff --git a/src/sonic-dhcp-server/.gitignore b/src/sonic-dhcp-server/.gitignore new file mode 100644 index 000000000000..8f5a21dd7620 --- /dev/null +++ b/src/sonic-dhcp-server/.gitignore @@ -0,0 +1,4 @@ +.eggs/ +build/ +dist/ +sonic_dhcpservd.egg-info/ diff --git a/src/sonic-dhcp-server/dhcp_server/dhcp_cfggen.py b/src/sonic-dhcp-server/dhcp_server/dhcp_cfggen.py new file mode 100755 index 000000000000..4fca71a3834d --- /dev/null +++ b/src/sonic-dhcp-server/dhcp_server/dhcp_cfggen.py @@ -0,0 +1,330 @@ +#!/usr/bin/env python + +import ipaddress +import json +import os +import syslog + +from jinja2 import Environment, FileSystemLoader +from .dhcp_server_utils import merge_intervals + +PORT_MAP_PATH = "/tmp/port-name-alias-map.txt" +UNICODE_TYPE = str +DHCP_SERVER_IPV4 = "DHCP_SERVER_IPV4" +DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS = "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS" +DHCP_SERVER_IPV4_RANGE = "DHCP_SERVER_IPV4_RANGE" +DHCP_SERVER_IPV4_PORT = "DHCP_SERVER_IPV4_PORT" +DHCP_SERVER_IPV4_LEASE = "DHCP_SERVER_IPV4_LEASE" +LEASE_UPDATE_SCRIPT_PATH = "/etc/kea/lease_update.sh" +DEFAULT_LEASE_PATH = "/tmp/kea-lease.csv" +KEA_DHCP4_CONF_TEMPLATE_PATH = "/usr/share/sonic/templates/kea-dhcp4.conf.j2" +# Default lease time of DHCP +DEFAULT_LEASE_TIME = 900 + + +class DhcpServCfgGenerator(object): + port_alias_map = {} + lease_update_script_path = "" + lease_path = "" + + def __init__(self, dhcp_db_connector, lease_path=DEFAULT_LEASE_PATH, port_map_path=PORT_MAP_PATH, + lease_update_script_path=LEASE_UPDATE_SCRIPT_PATH, + kea_conf_template_path=KEA_DHCP4_CONF_TEMPLATE_PATH): + self.db_connector = dhcp_db_connector + self.lease_path = lease_path + self.lease_update_script_path = lease_update_script_path + # Read port alias map file, this file is render after container start, so it would not change any more + self._parse_port_map_alias(port_map_path) + # Get kea config template + self._get_render_template(kea_conf_template_path) + + def generate(self): + """ + Generate dhcp server config + Returns: + config dict + """ + # Generate from running config_db + # Get host name + device_metadata = self.db_connector.get_config_db_table("DEVICE_METADATA") + hostname = self._parse_hostname(device_metadata) + # Get ip information of vlan + vlan_interface = self.db_connector.get_config_db_table("VLAN_INTERFACE") + vlan_member_table = self.db_connector.get_config_db_table("VLAN_MEMBER") + vlan_interfaces, vlan_members = self._parse_vlan(vlan_interface, vlan_member_table) + + dhcp_server_ipv4, customized_options_ipv4, range_ipv4, port_ipv4 = self._get_dhcp_ipv4_tables_from_db() + # Parse range table + ranges = self._parse_range(range_ipv4) + + # TODO Add support for customizing options + + # Parse port table + port_ips = self._parse_port(port_ipv4, vlan_interfaces, vlan_members, ranges) + render_obj = self._construct_obj_for_template(dhcp_server_ipv4, port_ips, hostname) + + return self._render_config(render_obj) + + def _render_config(self, render_obj): + output = self.kea_template.render(render_obj) + return output + + def _parse_vlan(self, vlan_interface, vlan_member): + vlan_interfaces = self._get_vlan_ipv4_interface(vlan_interface.keys()) + vlan_members = vlan_member.keys() + return vlan_interfaces, vlan_members + + def _parse_hostname(self, device_metadata): + localhost_entry = device_metadata.get("localhost", {}) + if localhost_entry is None or "hostname" not in localhost_entry: + syslog.syslog(syslog.LOG_ERR, "Cannot get hostname") + raise Exception("Cannot get hostname") + return localhost_entry["hostname"] + + def _get_render_template(self, kea_conf_template_path): + # Semgrep does not allow to use jinja2 directly, but we do need jinja2 for SONiC + env = Environment(loader=FileSystemLoader(os.path.dirname(kea_conf_template_path))) # nosemgrep + self.kea_template = env.get_template(os.path.basename(kea_conf_template_path)) + + def _parse_port_map_alias(self, port_map_path): + with open(port_map_path, "r") as file: + lines = file.readlines() + for line in lines: + splits = line.strip().split(" ") + if len(splits) != 2: + continue + self.port_alias_map[splits[0]] = splits[1] + + def _construct_obj_for_template(self, dhcp_server_ipv4, port_ips, hostname): + subnets = [] + client_classes = [] + for dhcp_interface_name, dhcp_config in dhcp_server_ipv4.items(): + if "state" not in dhcp_config or dhcp_config["state"] != "enabled": + continue + if dhcp_config["mode"] == "PORT": + if dhcp_interface_name not in port_ips: + syslog.syslog(syslog.LOG_WARNING, "Cannot get DHCP port config for {}" + .format(dhcp_interface_name)) + continue + for dhcp_interface_ip, port_config in port_ips[dhcp_interface_name].items(): + pools = [] + for port_name, ip_ranges in port_config.items(): + ip_range = None + for ip_range in ip_ranges: + client_class = "{}:{}".format(hostname, port_name) + ip_range = { + "range": "{} - {}".format(ip_range[0], ip_range[1]), + "client_class": client_class + } + pools.append(ip_range) + if ip_range is not None: + class_len = len(client_class) + client_classes.append({ + "name": client_class, + "condition": "substring(relay4[1].hex, -{}, {}) == '{}'".format(class_len, class_len, + client_class) + }) + subnet_obj = { + "subnet": str(ipaddress.ip_network(dhcp_interface_ip, strict=False)), + "pools": pools, + "gateway": dhcp_config["gateway"], + "server_id": dhcp_interface_ip.split("/")[0], + "lease_time": dhcp_config["lease_time"] + } + subnets.append(subnet_obj) + render_obj = { + "subnets": subnets, + "client_classes": client_classes, + "lease_update_script_path": self.lease_update_script_path, + "lease_path": self.lease_path + } + return render_obj + + def _get_dhcp_ipv4_tables_from_db(self): + """ + Get DHCP Server IPv4 related table from config_db. + Returns: + Four table objects. + """ + dhcp_server_ipv4 = self.db_connector.get_config_db_table(DHCP_SERVER_IPV4) + customized_options_ipv4 = self.db_connector.get_config_db_table(DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS) + range_ipv4 = self.db_connector.get_config_db_table(DHCP_SERVER_IPV4_RANGE) + port_ipv4 = self.db_connector.get_config_db_table(DHCP_SERVER_IPV4_PORT) + return dhcp_server_ipv4, customized_options_ipv4, range_ipv4, port_ipv4 + + def _get_vlan_ipv4_interface(self, vlan_interface_keys): + """ + Get ipv4 info of vlans + Args: + vlan_interface_keys: Keys of vlan_interfaces, sample: + [ + "Vlan1000|192.168.0.1/21", + "Vlan1000|fc02:1000::1/64" + ] + Returns: + Vlans infomation, sample: + { + 'Vlan1000': [{ + 'network': IPv4Network('192.168.0.0/24'), + 'ip': '192.168.0.1/24' + }] + } + """ + ret = {} + for key in vlan_interface_keys: + splits = key.split("|") + # Skip with no ip address + if len(splits) != 2: + continue + network = ipaddress.ip_network(UNICODE_TYPE(splits[1]), False) + # Skip ipv6 + if network.version != 4: + continue + if splits[0] not in ret: + ret[splits[0]] = [] + ret[splits[0]].append({"network": network, "ip": splits[1]}) + return ret + + def _parse_range(self, range_ipv4): + """ + Parse content in DHCP_SERVER_IPV4_RANGE table to below format: + { + 'range2': [IPv4Address('192.168.0.3'), IPv4Address('192.168.0.6')], + 'range1': [IPv4Address('192.168.0.2'), IPv4Address('192.168.0.5')], + 'range3': [IPv4Address('192.168.0.10'), IPv4Address('192.168.0.10')] + } + Args: + range_ipv4: Table object or dict of range. + """ + ranges = {} + for range in list(range_ipv4.keys()): + curr_range = range_ipv4.get(range, {}).get("range", {}) + if len(curr_range) != 2: + syslog.syslog(syslog.LOG_WARNING, f"Length of {curr_range} != 2") + continue + address_1 = ipaddress.ip_address(curr_range[0]) + address_2 = ipaddress.ip_address(curr_range[1]) + # To make sure order of range is correct + range_start = address_1 if address_1 < address_2 else address_2 + range_end = address_2 if address_1 < address_2 else address_1 + ranges[range] = [range_start, range_end] + + return ranges + + def _match_range_network(self, dhcp_interface, dhcp_interface_name, port, range, port_ips): + """ + Loop the IP of the dhcp interface and find the network that target range is in this network. And to construct + below data to record range - port map + { + 'Vlan1000': { + '192.168.0.1/24': { + 'etp2': [ + [IPv4Address('192.168.0.7'), IPv4Address('192.168.0.7')] + ] + } + } + } + Args: + dhcp_interface: Ip and network information of current DHCP interface, sample: + [{ + 'network': IPv4Network('192.168.0.0/24'), + 'ip': '192.168.0.1/24' + }] + dhcp_interface_name: Name of DHCP interface. + port: Name of DHCP member port. + range: Ip Range, sample: + [IPv4Address('192.168.0.2'), IPv4Address('192.168.0.5')] + """ + for dhcp_interface_ip in dhcp_interface: + if not range[0] in dhcp_interface_ip["network"] or \ + not range[1] in dhcp_interface_ip["network"]: + continue + dhcp_interface_ip_str = dhcp_interface_ip["ip"] + if dhcp_interface_ip_str not in port_ips[dhcp_interface_name]: + port_ips[dhcp_interface_name][dhcp_interface_ip_str] = {} + if port not in port_ips[dhcp_interface_name][dhcp_interface_ip_str]: + port_ips[dhcp_interface_name][dhcp_interface_ip_str][port] = [] + port_ips[dhcp_interface_name][dhcp_interface_ip_str][port].append([range[0], range[1]]) + break + + def _parse_port(self, port_ipv4, vlan_interfaces, vlan_members, ranges): + """ + Parse content in DHCP_SERVER_IPV4_PORT table to below format, which indicate ip ranges assign to interface. + Args: + port_ipv4: Table object. + vlan_interfaces: Vlan information, sample: + { + 'Vlan1000': [{ + 'network': IPv4Network('192.168.0.0/24'), + 'ip': '192.168.0.1/24' + }] + } + vlan_members: List of vlan members + ranges: Dict of ranges + Returns: + Dict of dhcp conf, sample: + { + 'Vlan1000': { + '192.168.0.1/24': { + 'etp2': [ + ['192.168.0.7', '192.168.0.7'] + ], + 'etp3': [ + ['192.168.0.2', '192.168.0.6'], + ['192.168.0.10', '192.168.0.10'] + ] + } + } + } + """ + port_ips = {} + ip_ports = {} + for port_key in list(port_ipv4.keys()): + port_config = port_ipv4.get(port_key, {}) + # Cannot specify both 'ips' and 'ranges' + if "ips" in port_config and len(port_config["ips"]) != 0 and "ranges" in port_config \ + and len(port_config["ranges"]) != 0: + syslog.syslog(syslog.LOG_WARNING, f"Port config for {port_key} contains both ips and ranges, skip") + continue + splits = port_key.split("|") + # Skip port not in correct vlan + if port_key not in vlan_members: + syslog.syslog(syslog.LOG_WARNING, f"Port {splits[1]} is not in {splits[0]}") + continue + # Get dhcp interface name like Vlan1000 + dhcp_interface_name = splits[0] + # Get dhcp member interface name like etp1 + if splits[1] not in self.port_alias_map: + syslog.syslog(syslog.LOG_WARNING, f"Cannot find {splits[1]} in port_alias_map") + continue + port = self.port_alias_map[splits[1]] + if dhcp_interface_name not in port_ips: + port_ips[dhcp_interface_name] = {} + # Get ip information of Vlan + dhcp_interface = vlan_interfaces[dhcp_interface_name] + + for dhcp_interface_ip in dhcp_interface: + ip_ports[str(dhcp_interface_ip["network"])] = dhcp_interface_name + + if "ips" in port_config and len(port_config["ips"]) != 0: + for ip in set(port_config["ips"]): + ip_address = ipaddress.ip_address(ip) + # Loop the IP of the dhcp interface and find the network that target ip is in this network. + self._match_range_network(dhcp_interface, dhcp_interface_name, port, [ip_address, ip_address], + port_ips) + if "ranges" in port_config and len(port_config["ranges"]) != 0: + for range_name in list(port_config["ranges"]): + if range_name not in ranges: + syslog.syslog(syslog.LOG_WARNING, f"Range {range_name} is not in range table, skip") + continue + range = ranges[range_name] + # Loop the IP of the dhcp interface and find the network that target range is in this network. + self._match_range_network(dhcp_interface, dhcp_interface_name, port, range, port_ips) + # Merge ranges to avoid overlap + for dhcp_interface_name, value in port_ips.items(): + for dhcp_interface_ip, port_range in value.items(): + for port_name, ip_range in port_range.items(): + ranges = merge_intervals(ip_range) + ranges = [[str(range[0]), str(range[1])] for range in ranges] + port_ips[dhcp_interface_name][dhcp_interface_ip][port_name] = ranges + return port_ips diff --git a/src/sonic-dhcp-server/dhcp_server/dhcp_lease.py b/src/sonic-dhcp-server/dhcp_server/dhcp_lease.py new file mode 100644 index 000000000000..693a93d2c090 --- /dev/null +++ b/src/sonic-dhcp-server/dhcp_server/dhcp_lease.py @@ -0,0 +1,154 @@ +import ipaddress +import json +import signal +import syslog +import threading +import time +from abc import abstractmethod +from collections import deque +from datetime import datetime + +DHCP_SERVER_IPV4_LEASE = "DHCP_SERVER_IPV4_LEASE" +KEA_LEASE_FILE_PATH = "/tmp/kea-lease.csv" +DEFAULE_LEASE_UPDATE_INTERVAL = 2 # unit: sec + + +class LeaseManager(object): + def __init__(self, db_connector, kea_lease_file=KEA_LEASE_FILE_PATH): + self.lease_handlers = [KeaDhcp4LeaseHandler(db_connector, kea_lease_file)] + + def start(self): + """ + Register lease hanlder + """ + for handler in self.lease_handlers: + handler.register() + + +class LeaseHanlder(object): + def __init__(self, db_connector, lease_update_interval=DEFAULE_LEASE_UPDATE_INTERVAL): + self.db_connector = db_connector + self.lease_update_interval = lease_update_interval + self.last_update_time = None + self.lock = threading.Lock() + + @abstractmethod + def _read(self): + """ + Read lease file to get newest lease information + """ + raise NotImplementedError + + @abstractmethod + def register(self): + """ + Register callback function + """ + raise NotImplementedError + + def update_lease(self): + """ + Update lease table in STATE_DB + """ + last_update_time = self.last_update_time + curr_time = datetime.now() + # If the time since the last update is less than self.lease_update_interval, then wait for a + # self.lease_update_interval + if last_update_time is not None and (curr_time - last_update_time).seconds < self.lease_update_interval: + time.sleep(self.lease_update_interval) + if self.last_update_time != last_update_time: + # Means lease has been updated during sleep, no need to update this lease + return + if not self.lock.acquire(False): + return + new_lease = self._read() + # Store old lease key + old_lease_table = self.db_connector.get_state_db_table(DHCP_SERVER_IPV4_LEASE) + old_lease_key = set(old_lease_table.keys()) + + # 1.1 If start time equal to end time, means lease has been released + # 1.1.1 If current lease table has this old lease, delete it + # 1.1.2 Else skip + # 1.2 Else, means lease valid, save it. + for key, value in new_lease.items(): + if value["lease_start"] == value["lease_end"]: + if key in old_lease_key: + self.db_connector.state_db.delete("{}|{}".format(DHCP_SERVER_IPV4_LEASE, key)) + continue + new_key = "{}|{}".format(DHCP_SERVER_IPV4_LEASE, key) + for k, v in new_lease[key].items(): + self.db_connector.state_db.hset(new_key, k, v) + # Delete old lease not in new lease set + for key in old_lease_key: + if key not in new_lease.keys(): + # Delete entry + self.db_connector.state_db.delete("{}|{}".format(DHCP_SERVER_IPV4_LEASE, key)) + self.last_update_time = datetime.now() + self.lock.release() + + +class KeaDhcp4LeaseHandler(LeaseHanlder): + def __init__(self, db_connector, lease_file=KEA_LEASE_FILE_PATH): + LeaseHanlder.__init__(self, db_connector) + self.lease_file = lease_file + + def register(self): + """ + Register callback function of signal + """ + signal.signal(signal.SIGUSR1, self._update_lease) + + def _read(self): + # Read lease file generated by kea-dhcp4 + try: + with open(self.lease_file, "r", encoding="utf-8") as fb: + dq = deque(fb) + except FileNotFoundError as err: + syslog.syslog(syslog.LOG_ERR, "Cannot find lease file: {}".format(self.lease_file)) + raise err + + fdb_info = self._get_fdb_info() + new_lease = {} + # Get newest lease information of each client + while dq: + last_row = dq.pop() + splits = last_row.split(",") + # Skip header + if splits[0] == "address": + break + ip_str = splits[0] + mac_address = splits[1] + valid_lifetime = splits[3] + lease_end = splits[4] + + if mac_address not in fdb_info: + syslog.syslog(syslog.LOG_WARNING, "Cannot not find {} in fdb table".format(mac_address)) + continue + new_key = "{}|{}".format(fdb_info[mac_address], mac_address) + if new_key in new_lease: + continue + new_lease[new_key] = { + "lease_start": str(int(lease_end) - int(valid_lifetime)), + "lease_end": lease_end, + "ip": ip_str + } + return new_lease + + def _get_fdb_info(self): + """ + Get fdb information, indicate that mac address comes from which dhcp interface. + Returns: + Dict of fdb information, sample: + { + "aa:bb:cc:dd:ee:ff": "Vlan1000" + } + """ + fdb_table = self.db_connector.get_state_db_table("FDB_TABLE") + ret = {} + for key in fdb_table.keys(): + splits = key.split(":", 1) + ret[splits[1]] = splits[0] + return ret + + def _update_lease(self, signum, frame): + self.update_lease() diff --git a/src/sonic-dhcp-server/dhcp_server/dhcp_server_utils.py b/src/sonic-dhcp-server/dhcp_server/dhcp_server_utils.py new file mode 100644 index 000000000000..b045752bc658 --- /dev/null +++ b/src/sonic-dhcp-server/dhcp_server/dhcp_server_utils.py @@ -0,0 +1,99 @@ +from swsscommon import swsscommon + +DEFAULT_REDIS_HOST = "127.0.0.1" +DEFAULT_REDIS_PORT = 6379 + + +class DhcpDbConnector(object): + def __init__(self, redis_host=DEFAULT_REDIS_HOST, redis_port=DEFAULT_REDIS_PORT, redis_sock=None): + if redis_sock is not None: + self.redis_sock = redis_sock + self.config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, redis_sock, 0) + self.state_db = swsscommon.DBConnector(swsscommon.STATE_DB, redis_sock, 0) + else: + self.config_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, redis_host, redis_port, 0) + self.state_db = swsscommon.DBConnector(swsscommon.STATE_DB, redis_host, redis_port, 0) + + def get_config_db_table(self, table_name): + """ + Get table from config_db. + Args: + table_name: Name of table want to get. + Return: + Table objects. + """ + return _parse_table_to_dict(swsscommon.Table(self.config_db, table_name)) + + def get_state_db_table(self, table_name): + """ + Get table from state_db. + Args: + table_name: Name of table want to get. + Return: + Table objects. + """ + return _parse_table_to_dict(swsscommon.Table(self.state_db, table_name)) + + +def get_entry(table, entry_name): + """ + Get dict entry from Table object. + Args: + table: Table object. + entry_name: Name of entry. + Returns: + Dict of entry, sample: + { + "customized_options": "option60,option223", + "gateway": "192.168.0.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + """ + (_, entry) = table.get(entry_name) + return dict(entry) + + +def merge_intervals(intervals): + """ + Merge ip range intervals. + Args: + intervals: Ip ranges, may have overlaps, sample: + [ + [IPv4Address('192.168.0.2'), IPv4Address('192.168.0.5')], + [IPv4Address('192.168.0.3'), IPv4Address('192.168.0.6')], + [IPv4Address('192.168.0.10'), IPv4Address('192.168.0.10')] + ] + Returns: + Merged ip ranges, sample: + [ + [IPv4Address('192.168.0.2'), IPv4Address('192.168.0.6')], + [IPv4Address('192.168.0.10'), IPv4Address('192.168.0.10')] + ] + """ + intervals.sort(key=lambda x: x[0]) + ret = [] + for interval in intervals: + if len(ret) == 0 or interval[0] > ret[-1][-1]: + ret.append(interval) + else: + ret[-1][-1] = max(ret[-1][-1], interval[-1]) + return ret + + +def _parse_table_to_dict(table): + ret = {} + for key in table.getKeys(): + entry = get_entry(table, key) + new_entry = {} + + for field, value in entry.items(): + # if value of this field is list, field end with @, so cannot found by hget + if table.hget(key, field)[0]: + new_entry[field] = value + else: + new_entry[field] = value.split(",") + ret[key] = new_entry + return ret diff --git a/src/sonic-dhcp-server/dhcp_server/dhcpservd.py b/src/sonic-dhcp-server/dhcp_server/dhcpservd.py new file mode 100644 index 000000000000..a82db326c919 --- /dev/null +++ b/src/sonic-dhcp-server/dhcp_server/dhcpservd.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +import psutil +import signal +import time +from .dhcp_cfggen import DhcpServCfgGenerator +from .dhcp_lease import LeaseManager +from .dhcp_server_utils import DhcpDbConnector + +KEA_DHCP4_CONFIG = "/etc/kea/kea-dhcp4.conf" +KEA_DHCP4_PROC_NAME = "kea-dhcp4" +KEA_LEASE_FILE_PATH = "/tmp/kea-lease.csv" +REDIS_SOCK_PATH = "/var/run/redis/redis.sock" + + +class DhcpServd(object): + def __init__(self, dhcp_cfg_generator, db_connector, kea_dhcp4_config_path=KEA_DHCP4_CONFIG): + self.dhcp_cfg_generator = dhcp_cfg_generator + self.db_connector = db_connector + self.kea_dhcp4_config_path = kea_dhcp4_config_path + + def _notify_kea_dhcp4_proc(self): + """ + Send SIGHUP signal to kea-dhcp4 process + """ + for proc in psutil.process_iter(): + if KEA_DHCP4_PROC_NAME in proc.name(): + proc.send_signal(signal.SIGHUP) + break + + def dump_dhcp4_config(self): + """ + Generate kea-dhcp4 config file and dump it to config folder + """ + kea_dhcp4_config = self.dhcp_cfg_generator.generate() + with open(self.kea_dhcp4_config_path, "w") as write_file: + write_file.write(kea_dhcp4_config) + # After refresh kea-config, we need to SIGHUP kea-dhcp4 process to read new config + self._notify_kea_dhcp4_proc() + + def start(self): + self.dump_dhcp4_config() + lease_manager = LeaseManager(self.db_connector, KEA_LEASE_FILE_PATH) + lease_manager.start() + + # TODO Add config db subcribe to re-generate kea-dhcp4 config after config_db change. + + def wait(self): + while True: + time.sleep(5) + + +def main(): + dhcp_db_connector = DhcpDbConnector(redis_sock=REDIS_SOCK_PATH) + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + dhcpservd = DhcpServd(dhcp_cfg_generator, dhcp_db_connector) + dhcpservd.start() + dhcpservd.wait() + + +if __name__ == "__main__": + main() diff --git a/src/sonic-dhcp-server/setup.cfg b/src/sonic-dhcp-server/setup.cfg new file mode 100644 index 000000000000..a9cd7dd6a1a0 --- /dev/null +++ b/src/sonic-dhcp-server/setup.cfg @@ -0,0 +1,20 @@ +[aliases] +test=pytest + +[tool:pytest] +addopts = --durations=5 --cov +testpaths = tests + +[coverage:run] +branch = True +source = dhcp_server + +[coverage:report] +exclude_lines = + main() + if __name__ == .__main__.: +precision = 2 +show_missing = True +skip_covered = True +sort = Cover +fail_under = 80 diff --git a/src/sonic-dhcp-server/setup.py b/src/sonic-dhcp-server/setup.py new file mode 100644 index 000000000000..c81a915cefbc --- /dev/null +++ b/src/sonic-dhcp-server/setup.py @@ -0,0 +1,49 @@ +from setuptools import setup + +dependencies = [ + "psutil", + "coverage" +] + +test_deps = [ + "pytest" +] + +py_modules = [ + "dhcp_server_utils", + "dhcp_cfggen", + "dhcp_lease" +] + +setup( + name="sonic-dhcp-server", + install_requires=dependencies, + description="Module of SONiC built-in dhcp_server", + version="1.0", + url="https://github.com/Azure/sonic-buildimage", + tests_require=test_deps, + author="SONiC Team", + author_email="yaqiangzhu@microsoft.com", + setup_requires=[ + "pytest-runner", + "wheel", + ], + packages=[ + "dhcp_server" + ], + entry_points={ + "console_scripts": [ + "dhcpservd = dhcp_server.dhcpservd:main" + ] + }, + py_modules=py_modules, + classifiers=[ + "Intended Audience :: Developers", + "Operating System :: Linux", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8" + ] +) diff --git a/src/sonic-dhcp-server/tests/common_utils.py b/src/sonic-dhcp-server/tests/common_utils.py new file mode 100644 index 000000000000..a9ebadd3a4e5 --- /dev/null +++ b/src/sonic-dhcp-server/tests/common_utils.py @@ -0,0 +1,12 @@ +import json + +MOCK_CONFIG_DB_PATH = "tests/test_data/mock_config_db.json" + + +class MockConfigDb(object): + def __init__(self, config_db_path=MOCK_CONFIG_DB_PATH): + with open(config_db_path, "r", encoding="utf8") as file: + self.config_db = json.load(file) + + def get_config_db_table(self, table_name): + return self.config_db.get(table_name, {}) diff --git a/src/sonic-dhcp-server/tests/conftest.py b/src/sonic-dhcp-server/tests/conftest.py new file mode 100644 index 000000000000..295cc543b43c --- /dev/null +++ b/src/sonic-dhcp-server/tests/conftest.py @@ -0,0 +1,35 @@ +import pytest +import dhcp_server.dhcp_server_utils as dhcp_server_utils +from unittest.mock import patch, PropertyMock +from dhcp_server.dhcp_cfggen import DhcpServCfgGenerator + + +@pytest.fixture(scope="function") +def mock_swsscommon_dbconnector_init(): + with patch.object(dhcp_server_utils.swsscommon.DBConnector, "__init__", return_value=None) as mock_dbconnector_init: + yield mock_dbconnector_init + + +@pytest.fixture(scope="function") +def mock_swsscommon_table_init(): + with patch.object(dhcp_server_utils.swsscommon.Table, "__init__", return_value=None) as mock_table_init: + yield mock_table_init + + +@pytest.fixture(scope="function") +def mock_get_render_template(): + with patch("dhcp_server.dhcp_cfggen.DhcpServCfgGenerator._get_render_template", return_value=None) as mock_template: + yield mock_template + + +@pytest.fixture +def mock_parse_port_map_alias(scope="function"): + with patch("dhcp_server.dhcp_cfggen.DhcpServCfgGenerator._parse_port_map_alias", return_value=None) as mock_map, \ + patch.object(DhcpServCfgGenerator, "port_alias_map", return_value={"Ethernet24": "etp7", "Ethernet28": "etp8"}, + new_callable=PropertyMock), \ + patch.object(DhcpServCfgGenerator, "lease_update_script_path", return_value="/etc/kea/lease_update.sh", + new_callable=PropertyMock), \ + patch.object(DhcpServCfgGenerator, "lease_path", return_value="/tmp/kea-lease.csv", new_callable=PropertyMock): + yield mock_map + + diff --git a/src/sonic-dhcp-server/tests/kea-dhcp4.conf.j2 b/src/sonic-dhcp-server/tests/kea-dhcp4.conf.j2 new file mode 100644 index 000000000000..27fd1a1d1f90 --- /dev/null +++ b/src/sonic-dhcp-server/tests/kea-dhcp4.conf.j2 @@ -0,0 +1,87 @@ +{%- set default_lease_time = 900 -%} +{ + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "{{ lease_update_script_path }}", + "sync": false + } + } + ], + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": true, + "name": "{{ lease_path }}", + "lfc-interval": 3600 + }, + "subnet4": [ +{%- set add_subnet_preceding_comma = { 'flag': False } %} +{%- for subnet_info in subnets %} + {%- if add_subnet_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_subnet_preceding_comma.update({'flag': True}) %} + { + "subnet": "{{ subnet_info["subnet"] }}", + "pools": [ + {%- set add_pool_preceding_comma = { 'flag': False } %} + {%- for pool in subnet_info["pools"] %} + {%- if add_pool_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_pool_preceding_comma.update({'flag': True}) %} + { + "pool": "{{ pool["range"] }}", + "client-class": "{{ pool["client_class"] }}" + } + {%- endfor%} + ], + "option-data": [ + { + "name": "routers", + "data": "{{ subnet_info["gateway"] if "gateway" in subnet_info else subnet_info["server_id"] }}" + }, + { + "name": "dhcp-server-identifier", + "data": "{{ subnet_info["server_id"] }}" + } + ], + "valid-lifetime": {{ subnet_info["lease_time"] if "lease_time" in subnet_info else default_lease_time }}, + "reservations": [] + } +{%- endfor %} + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/var/log/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ]{%- if client_classes -%}, + "client-classes": [ + {%- set add_preceding_comma = { 'flag': False } %} + {%- for class in client_classes %} + {%- if add_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_preceding_comma.update({'flag': True}) %} + { + "name": "{{ class["name"] }}", + "test": "{{ class["condition"] }}" + } + {%- endfor %} + ] + {%- endif %} + } +} diff --git a/src/sonic-dhcp-server/tests/test_data/kea-dhcp4.conf.j2 b/src/sonic-dhcp-server/tests/test_data/kea-dhcp4.conf.j2 new file mode 100644 index 000000000000..27fd1a1d1f90 --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_data/kea-dhcp4.conf.j2 @@ -0,0 +1,87 @@ +{%- set default_lease_time = 900 -%} +{ + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "{{ lease_update_script_path }}", + "sync": false + } + } + ], + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": true, + "name": "{{ lease_path }}", + "lfc-interval": 3600 + }, + "subnet4": [ +{%- set add_subnet_preceding_comma = { 'flag': False } %} +{%- for subnet_info in subnets %} + {%- if add_subnet_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_subnet_preceding_comma.update({'flag': True}) %} + { + "subnet": "{{ subnet_info["subnet"] }}", + "pools": [ + {%- set add_pool_preceding_comma = { 'flag': False } %} + {%- for pool in subnet_info["pools"] %} + {%- if add_pool_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_pool_preceding_comma.update({'flag': True}) %} + { + "pool": "{{ pool["range"] }}", + "client-class": "{{ pool["client_class"] }}" + } + {%- endfor%} + ], + "option-data": [ + { + "name": "routers", + "data": "{{ subnet_info["gateway"] if "gateway" in subnet_info else subnet_info["server_id"] }}" + }, + { + "name": "dhcp-server-identifier", + "data": "{{ subnet_info["server_id"] }}" + } + ], + "valid-lifetime": {{ subnet_info["lease_time"] if "lease_time" in subnet_info else default_lease_time }}, + "reservations": [] + } +{%- endfor %} + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/var/log/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ]{%- if client_classes -%}, + "client-classes": [ + {%- set add_preceding_comma = { 'flag': False } %} + {%- for class in client_classes %} + {%- if add_preceding_comma.flag -%},{%- endif -%} + {%- set _dummy = add_preceding_comma.update({'flag': True}) %} + { + "name": "{{ class["name"] }}", + "test": "{{ class["condition"] }}" + } + {%- endfor %} + ] + {%- endif %} + } +} diff --git a/src/sonic-dhcp-server/tests/test_data/kea-lease.csv b/src/sonic-dhcp-server/tests/test_data/kea-lease.csv new file mode 100644 index 000000000000..85976d8cb5f9 --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_data/kea-lease.csv @@ -0,0 +1,9 @@ +address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id +192.168.0.2,10:70:fd:b6:13:00,,3600,1694000905,1,0,0,7626dced293e,0,,0 +192.168.0.131,10:70:fd:b6:13:17,,3600,1694000909,1,0,0,7626dced293e,0,,1 +192.168.0.131,10:70:fd:b6:13:17,,0,1693997309,1,0,0,7626dced293e,0,,1 +192.168.0.131,10:70:fd:b6:13:17,,0,1693997309,1,0,0,,2,,1 +192.168.0.131,10:70:fd:b6:13:17,,3600,1694000915,1,0,0,7626dced293e,0,,1 +192.168.0.2,10:70:fd:b6:13:00,,0,1693997305,1,0,0,7626dced293e,0,,0 +193.168.2.2,10:70:fd:b6:13:15,,3600,1693999305,1,0,0,7626dced293e,0,,0 +193.168.2.3,10:70:fd:b6:13:20,,3600,1693999305,1,0,0,7626dced293e,0,,0 \ No newline at end of file diff --git a/src/sonic-dhcp-server/tests/test_data/mock_config_db.json b/src/sonic-dhcp-server/tests/test_data/mock_config_db.json new file mode 100644 index 000000000000..0e6f4387f47c --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_data/mock_config_db.json @@ -0,0 +1,159 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hostname": "sonic-host" + } + }, + "VLAN_INTERFACE": { + "Vlan1000|192.168.0.1/21": { + "NULL": "NULL" + }, + "Vlan1000": { + "NULL": "NULL" + }, + "Vlan1000|fc02:1000::1/64": { + "NULL": "NULL" + }, + "Vlan2000|192.168.1.1/21": { + "NULL": "NULL" + }, + "Vlan2000|192.168.2.1/21": { + "NULL": "NULL" + }, + "Vlan2000": { + "NULL": "NULL" + } + }, + "VLAN_MEMBER": { + "Vlan1000|Ethernet24": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet28": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet40": { + "tagging_mode": "untagged" + } + }, + "DHCP_SERVER_IPV4": { + "Vlan1000": { + "customized_options": [ + "option60", + "option223" + ], + "gateway": "192.168.0.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + }, + "Vlan2000": { + "customized_options": [ + "option60" + ], + "gateway": "192.168.1.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "disabled" + }, + "Vlan3000": { + "customized_options": [ + "option60" + ], + "gateway": "192.168.2.1", + "lease_time": "900", + "mode": "STATIC", + "netmask": "255.255.255.0", + "state": "enabled" + }, + "Vlan4000": { + "customized_options": [ + "option60", + "option223" + ], + "gateway": "192.168.3.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "option223": { + "id": "223", + "type": "text", + "value": "dummy_value" + }, + "option60": { + "id": "60", + "type": "text", + "value": "dummy_value" + } + }, + "DHCP_SERVER_IPV4_RANGE": { + "range3": { + "range": [ + "192.168.0.10", + "192.168.0.10" + ] + }, + "range2": { + "range": [ + "192.168.0.6", + "192.168.0.3" + ] + }, + "range1": { + "range": [ + "192.168.0.2", + "192.168.0.5" + ] + }, + "range4": { + "range": [ + "192.168.0.1" + ] + }, + "range0": { + "range": [ + "192.168.8.2", + "192.168.8.3" + ] + } + }, + "DHCP_SERVER_IPV4_PORT": { + "Vlan1000|Ethernet24": { + "ips": [ + "192.168.0.7" + ] + }, + "Vlan1000|Ethernet28": { + "ranges": [ + "range0", + "range1", + "range2", + "range3", + "range6" + ] + }, + "Vlan1000|Ethernet32": { + "ips": [ + "192.168.0.8" + ], + "ranges": [ + "range0" + ] + }, + "Vlan1000|Ethernet36": { + "ips": [ + "192.168.0.9" + ] + }, + "Vlan1000|Ethernet40": { + "ips": [ + "192.168.0.10" + ] + } + } +} diff --git a/src/sonic-dhcp-server/tests/test_data/mock_config_db_without_port_config.json b/src/sonic-dhcp-server/tests/test_data/mock_config_db_without_port_config.json new file mode 100644 index 000000000000..5adc02679b4e --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_data/mock_config_db_without_port_config.json @@ -0,0 +1,149 @@ +{ + "DEVICE_METADATA": { + "localhost": { + "hostname": "sonic-host" + } + }, + "VLAN_INTERFACE": { + "Vlan1000|192.168.0.1/21": { + "NULL": "NULL" + }, + "Vlan1000": { + "NULL": "NULL" + }, + "Vlan1000|fc02:1000::1/64": { + "NULL": "NULL" + } + }, + "VLAN_MEMBER": { + "Vlan1000|Ethernet68": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet72": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet8": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet80": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet96": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet48": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet32": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet4": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet24": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet40": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet52": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet28": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet44": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet60": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet16": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet12": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet84": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet36": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet64": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet92": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet56": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet20": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet88": { + "tagging_mode": "untagged" + }, + "Vlan1000|Ethernet76": { + "tagging_mode": "untagged" + } + }, + "DHCP_SERVER_IPV4": { + "Vlan1000": { + "customized_options": [ + "option60", + "option223" + ], + "gateway": "192.168.0.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + }, + "Vlan2000": { + "customized_options": [ + "option60" + ], + "gateway": "192.168.0.1", + "lease_time": "900", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "disabled" + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "option223": { + "id": "223", + "type": "text", + "value": "dummy_value" + }, + "option60": { + "id": "60", + "type": "text", + "value": "dummy_value" + } + }, + "DHCP_SERVER_IPV4_RANGE": { + "range3": { + "range": [ + "192.168.0.10", + "192.168.0.10" + ] + }, + "range2": { + "range": [ + "192.168.0.6", + "192.168.0.3" + ] + }, + "range1": { + "range": [ + "192.168.0.2", + "192.168.0.5" + ] + } + }, + "DHCP_SERVER_IPV4_PORT": { + } +} diff --git a/src/sonic-dhcp-server/tests/test_data/port-name-alias-map.txt b/src/sonic-dhcp-server/tests/test_data/port-name-alias-map.txt new file mode 100644 index 000000000000..edebd17db9f7 --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_data/port-name-alias-map.txt @@ -0,0 +1,3 @@ +Ethernet24 etp7 +Ethernet28 etp8 +Ethernet32 \ No newline at end of file diff --git a/src/sonic-dhcp-server/tests/test_dhcp_cfggen.py b/src/sonic-dhcp-server/tests/test_dhcp_cfggen.py new file mode 100644 index 000000000000..25b46f85442b --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_dhcp_cfggen.py @@ -0,0 +1,265 @@ +import copy +import ipaddress +import json +import pytest +from common_utils import MockConfigDb +from dhcp_server.dhcp_server_utils import DhcpDbConnector +from dhcp_server.dhcp_cfggen import DhcpServCfgGenerator +from unittest.mock import patch, MagicMock + +expected_dhcp_config = { + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "/etc/kea/lease_update.sh", + "sync": False + } + } + ], + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": True, + "name": "/tmp/kea-lease.csv", + "lfc-interval": 3600 + }, + "subnet4": [ + { + "subnet": "192.168.0.0/21", + "pools": [ + { + "pool": "192.168.0.2 - 192.168.0.6", + "client-class": "sonic-host:etp8" + }, + { + "pool": "192.168.0.10 - 192.168.0.10", + "client-class": "sonic-host:etp8" + }, + { + "pool": "192.168.0.7 - 192.168.0.7", + "client-class": "sonic-host:etp7" + } + ], + "option-data": [ + { + "name": "routers", + "data": "192.168.0.1" + }, + { + "name": "dhcp-server-identifier", + "data": "192.168.0.1" + } + ], + "valid-lifetime": 900, + "reservations": [] + } + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/var/log/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ], + "client-classes": [ + { + "name": "sonic-host:etp8", + "test": "substring(relay4[1].hex, -15, 15) == 'sonic-host:etp8'" + }, + { + "name": "sonic-host:etp7", + "test": "substring(relay4[1].hex, -15, 15) == 'sonic-host:etp7'" + } + ] + } +} +expected_dhcp_config_without_port_config = { + "Dhcp4": { + "hooks-libraries": [ + { + "library": "/usr/local/lib/kea/hooks/libdhcp_run_script.so", + "parameters": { + "name": "/etc/kea/lease_update.sh", + "sync": False + } + } + ], + "interfaces-config": { + "interfaces": [ + "eth0" + ] + }, + "control-socket": { + "socket-type": "unix", + "socket-name": "/run/kea/kea4-ctrl-socket" + }, + "lease-database": { + "type": "memfile", + "persist": True, + "name": "/tmp/kea-lease.csv", + "lfc-interval": 3600 + }, + "subnet4": [ + ], + "loggers": [ + { + "name": "kea-dhcp4", + "output_options": [ + { + "output": "/var/log/kea-dhcp.log", + "pattern": "%-5p %m\n" + } + ], + "severity": "INFO", + "debuglevel": 0 + } + ] + } +} +expected_parsed_range = { + "range2": [ipaddress.IPv4Address("192.168.0.3"), ipaddress.IPv4Address("192.168.0.6")], + "range3": [ipaddress.IPv4Address("192.168.0.10"), ipaddress.IPv4Address("192.168.0.10")], + "range1": [ipaddress.IPv4Address("192.168.0.2"), ipaddress.IPv4Address("192.168.0.5")], + "range0": [ipaddress.IPv4Address("192.168.8.2"), ipaddress.IPv4Address("192.168.8.3")] +} +expected_vlan_ipv4_interface = { + "Vlan1000": [{ + "ip": "192.168.0.1/21", + "network": ipaddress.ip_network("192.168.0.1/21", strict=False) + }], + "Vlan2000": [ + { + "ip": "192.168.1.1/21", + "network": ipaddress.ip_network("192.168.1.1/21", strict=False) + }, + { + "ip": "192.168.2.1/21", + "network": ipaddress.ip_network("192.168.2.1/21", strict=False) + } + ] +} +expected_parsed_port = { + "Vlan1000": { + "192.168.0.1/21": { + "etp8": [["192.168.0.2", "192.168.0.6"], ["192.168.0.10", "192.168.0.10"]], + "etp7": [["192.168.0.7", "192.168.0.7"]] + } + } +} +tested_parsed_port = { + "Vlan1000": { + "192.168.0.1/21": { + "etp8": [["192.168.0.2", "192.168.0.6"], ["192.168.0.10", "192.168.0.10"]], + "etp7": [["192.168.0.7", "192.168.0.7"]], + "etp9": [] + } + } +} +expected_render_obj = { + "subnets": [{ + "subnet": "192.168.0.0/21", + "pools": [{"range": "192.168.0.2 - 192.168.0.6", "client_class": "sonic-host:etp8"}, + {"range": "192.168.0.10 - 192.168.0.10", "client_class": "sonic-host:etp8"}, + {"range": "192.168.0.7 - 192.168.0.7", "client_class": "sonic-host:etp7"}], + "gateway": "192.168.0.1", "server_id": "192.168.0.1", "lease_time": "900" + }], + "client_classes": [ + {"name": "sonic-host:etp8", "condition": "substring(relay4[1].hex, -15, 15) == 'sonic-host:etp8'"}, + {"name": "sonic-host:etp7", "condition": "substring(relay4[1].hex, -15, 15) == 'sonic-host:etp7'"} + ], + "lease_update_script_path": "/etc/kea/lease_update.sh", + "lease_path": "/tmp/kea-lease.csv" +} + + +def test_parse_port_alias(mock_swsscommon_dbconnector_init, mock_get_render_template): + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector, + port_map_path="tests/test_data/port-name-alias-map.txt") + assert dhcp_cfg_generator.port_alias_map == {'Ethernet24': 'etp7', 'Ethernet28': 'etp8'} + + +@pytest.mark.parametrize("is_success", [True, False]) +def test_parse_hostname(is_success, mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, + mock_get_render_template): + mock_config_db = MockConfigDb(config_db_path="tests/test_data/mock_config_db.json") + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + device_metadata = mock_config_db.config_db.get("DEVICE_METADATA") if is_success else {} + try: + hostname = dhcp_cfg_generator._parse_hostname(device_metadata) + assert hostname == "sonic-host" + except Exception as err: + assert str(err) == "Cannot get hostname" + + +def test_parse_range(mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, mock_get_render_template): + mock_config_db = MockConfigDb(config_db_path="tests/test_data/mock_config_db.json") + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + parse_result = dhcp_cfg_generator._parse_range(mock_config_db.config_db.get("DHCP_SERVER_IPV4_RANGE")) + assert parse_result == expected_parsed_range + + +def test_parse_vlan(mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, mock_get_render_template): + mock_config_db = MockConfigDb(config_db_path="tests/test_data/mock_config_db.json") + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + vlan_interfaces, vlan_members = dhcp_cfg_generator._parse_vlan(mock_config_db.config_db.get("VLAN_INTERFACE"), + mock_config_db.config_db.get("VLAN_MEMBER")) + assert vlan_interfaces == expected_vlan_ipv4_interface + assert list(vlan_members) == ["Vlan1000|Ethernet24", "Vlan1000|Ethernet28", "Vlan1000|Ethernet40"] + + +@pytest.mark.parametrize("test_config_db", ["mock_config_db.json", "mock_config_db_without_port_config.json"]) +def test_parse_port(test_config_db, mock_swsscommon_dbconnector_init, mock_get_render_template, + mock_parse_port_map_alias): + mock_config_db = MockConfigDb(config_db_path="tests/test_data/{}".format(test_config_db)) + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + tested_vlan_interfaces = expected_vlan_ipv4_interface + tested_ranges = expected_parsed_range + ipv4_port = mock_config_db.config_db.get("DHCP_SERVER_IPV4_PORT") + vlan_members = mock_config_db.config_db.get("VLAN_MEMBER").keys() + parse_result = dhcp_cfg_generator._parse_port(ipv4_port, tested_vlan_interfaces, vlan_members, tested_ranges) + assert parse_result == (expected_parsed_port if test_config_db == "mock_config_db.json" else {}) + + +def test_construct_obj_for_template(mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, + mock_get_render_template): + mock_config_db = MockConfigDb(config_db_path="tests/test_data/mock_config_db.json") + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + tested_hostname = "sonic-host" + render_obj = dhcp_cfg_generator._construct_obj_for_template(mock_config_db.config_db.get("DHCP_SERVER_IPV4"), + tested_parsed_port, tested_hostname) + assert render_obj == expected_render_obj + + +@pytest.mark.parametrize("with_port_config", [True, False]) +def test_render_config(mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, with_port_config): + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector, + kea_conf_template_path="tests/test_data/kea-dhcp4.conf.j2") + render_obj = copy.deepcopy(expected_render_obj) + if not with_port_config: + render_obj["client_classes"] = [] + render_obj["subnets"] = [] + config = dhcp_cfg_generator._render_config(render_obj) + assert json.loads(config) == expected_dhcp_config if with_port_config else expected_dhcp_config_without_port_config diff --git a/src/sonic-dhcp-server/tests/test_dhcp_lease.py b/src/sonic-dhcp-server/tests/test_dhcp_lease.py new file mode 100644 index 000000000000..08a93e2c4c2c --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_dhcp_lease.py @@ -0,0 +1,103 @@ +from dhcp_server.dhcp_server_utils import DhcpDbConnector +from dhcp_server.dhcp_lease import KeaDhcp4LeaseHandler, LeaseHanlder +from swsscommon import swsscommon +from unittest.mock import patch, call, MagicMock + +expected_lease = { + "Vlan1000|10:70:fd:b6:13:00": { + "lease_start": "1693997305", + "lease_end": "1693997305", + "ip": "192.168.0.2" + }, + "Vlan1000|10:70:fd:b6:13:17": { + "lease_start": "1693997315", + "lease_end": "1694000915", + "ip": "192.168.0.131" + }, + "Vlan2000|10:70:fd:b6:13:15": { + "lease_start": "1693995705", + "lease_end": "1693999305", + "ip": "193.168.2.2" + } +} +expected_fdb_info = { + "10:70:fd:b6:13:00": "Vlan1000", + "10:70:fd:b6:13:15": "Vlan2000", + "10:70:fd:b6:13:17": "Vlan1000", +} + + +def test_read_kea_lease_with_file_not_found(mock_swsscommon_dbconnector_init): + db_connector = DhcpDbConnector() + kea_lease_handler = KeaDhcp4LeaseHandler(db_connector) + try: + kea_lease_handler._read() + except FileNotFoundError: + pass + + +def test_read_kea_lease(mock_swsscommon_dbconnector_init): + tested_fdb_info = expected_fdb_info + with patch.object(KeaDhcp4LeaseHandler, "_get_fdb_info", return_value=tested_fdb_info): + db_connector = DhcpDbConnector() + kea_lease_handler = KeaDhcp4LeaseHandler(db_connector, lease_file="tests/test_data/kea-lease.csv") + # Verify whether lease information read is as expected + lease = kea_lease_handler._read() + print(lease) + print(expected_lease) + assert lease == expected_lease + + +def test_get_fdb_info(mock_swsscommon_dbconnector_init): + mock_fdb_table = { + "Vlan2000:10:70:fd:b6:13:15": {"port": "Ethernet31", "type": "dynamic"}, + "Vlan1000:10:70:fd:b6:13:00": {"port": "Ethernet32", "type": "dynamic"}, + "Vlan1000:10:70:fd:b6:13:17": {"port": "Ethernet32", "type": "dynamic"} + } + with patch("dhcp_server.dhcp_server_utils.DhcpDbConnector.get_state_db_table", return_value=mock_fdb_table): + db_connector = DhcpDbConnector() + kea_lease_handler = KeaDhcp4LeaseHandler(db_connector, lease_file="tests/test_data/kea-lease.csv") + # Verify whether lease information read is as expected + fdb_info = kea_lease_handler._get_fdb_info() + assert fdb_info == expected_fdb_info + + +def test_update_kea_lease(mock_swsscommon_dbconnector_init, mock_swsscommon_table_init): + tested_lease = expected_lease + with patch.object(swsscommon.Table, "getKeys"), \ + patch.object(swsscommon.DBConnector, "hset") as mock_hset, \ + patch.object(KeaDhcp4LeaseHandler, "_read", MagicMock(return_value=tested_lease)), \ + patch.object(DhcpDbConnector, "get_state_db_table", + return_value={"Vlan1000|aa:bb:cc:dd:ee:ff": {}, "Vlan1000|10:70:fd:b6:13:00": {}}), \ + patch.object(swsscommon.DBConnector, "delete") as mock_delete, \ + patch("time.sleep", return_value=None) as mock_sleep: + db_connector = DhcpDbConnector() + kea_lease_handler = KeaDhcp4LeaseHandler(db_connector) + kea_lease_handler.update_lease() + # Verify that old key was deleted + mock_delete.assert_has_calls([ + call("DHCP_SERVER_IPV4_LEASE|Vlan1000|10:70:fd:b6:13:00"), + call("DHCP_SERVER_IPV4_LEASE|Vlan1000|aa:bb:cc:dd:ee:ff") + ]) + # Verify that lease has been updated, to be noted that lease for "192.168.0.2" didn't been updated because + # lease_start equals to lease_end + mock_hset.assert_has_calls([ + call('DHCP_SERVER_IPV4_LEASE|Vlan1000|10:70:fd:b6:13:17', 'lease_start', '1693997315'), + call('DHCP_SERVER_IPV4_LEASE|Vlan1000|10:70:fd:b6:13:17', 'lease_end', '1694000915'), + call('DHCP_SERVER_IPV4_LEASE|Vlan1000|10:70:fd:b6:13:17', 'ip', '192.168.0.131') + ]) + kea_lease_handler.update_lease() + mock_sleep.assert_called_once_with(2) + + +def test_no_implement(mock_swsscommon_dbconnector_init): + db_connector = DhcpDbConnector() + lease_handler = LeaseHanlder(db_connector) + try: + lease_handler._read() + except NotImplementedError: + pass + try: + lease_handler.register() + except NotImplementedError: + pass diff --git a/src/sonic-dhcp-server/tests/test_dhcp_server_utils.py b/src/sonic-dhcp-server/tests/test_dhcp_server_utils.py new file mode 100644 index 000000000000..7b7857265acb --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_dhcp_server_utils.py @@ -0,0 +1,84 @@ +import dhcp_server.dhcp_server_utils as dhcp_server_utils +import ipaddress +import pytest +from swsscommon import swsscommon +from unittest.mock import patch, call + +interval_test_data = { + "ordered_with_overlap": { + "intervals": [["192.168.0.2", "192.168.0.5"], ["192.168.0.3", "192.168.0.6"], ["192.168.0.10", "192.168.0.10"]], + "expected_res": [["192.168.0.2", "192.168.0.6"], ["192.168.0.10", "192.168.0.10"]] + }, + "not_order_with_overlap": { + "intervals": [["192.168.0.3", "192.168.0.6"], ["192.168.0.2", "192.168.0.5"], ["192.168.0.10", "192.168.0.10"]], + "expected_res": [["192.168.0.2", "192.168.0.6"], ["192.168.0.10", "192.168.0.10"]] + }, + "ordered_without_overlap": { + "intervals": [["192.168.0.2", "192.168.0.5"], ["192.168.0.10", "192.168.0.10"]], + "expected_res": [["192.168.0.2", "192.168.0.5"], ["192.168.0.10", "192.168.0.10"]] + }, + "not_ordered_without_overlap": { + "intervals": [["192.168.0.10", "192.168.0.10"], ["192.168.0.2", "192.168.0.5"]], + "expected_res": [["192.168.0.2", "192.168.0.5"], ["192.168.0.10", "192.168.0.10"]] + }, + "single_interval": { + "intervals": [["192.168.0.10", "192.168.0.10"]], + "expected_res": [["192.168.0.10", "192.168.0.10"]] + } +} + + +def test_construct_without_sock(mock_swsscommon_dbconnector_init): + dhcp_server_utils.DhcpDbConnector() + mock_swsscommon_dbconnector_init.assert_has_calls([ + call(swsscommon.CONFIG_DB, "127.0.0.1", 6379, 0), + call(swsscommon.STATE_DB, "127.0.0.1", 6379, 0) + ]) + + +def test_construct_sock(mock_swsscommon_dbconnector_init): + redis_sock = "/var/run/redis/redis.sock" + dhcp_db_connector = dhcp_server_utils.DhcpDbConnector(redis_sock=redis_sock) + assert dhcp_db_connector.redis_sock == redis_sock + + mock_swsscommon_dbconnector_init.assert_has_calls([ + call(swsscommon.CONFIG_DB, redis_sock, 0), + call(swsscommon.STATE_DB, redis_sock, 0) + ]) + + +def test_get_config_db_table(mock_swsscommon_dbconnector_init, mock_swsscommon_table_init): + dhcp_db_connector = dhcp_server_utils.DhcpDbConnector() + with patch.object(swsscommon.Table, "getKeys", return_value=["key1", "key2"]) as mock_get_keys, \ + patch.object(dhcp_server_utils, "get_entry", return_value={"list": "1,2", "value": "3,4"}), \ + patch.object(swsscommon.Table, "hget", side_effect=mock_hget): + ret = dhcp_db_connector.get_config_db_table("VLAN") + mock_swsscommon_table_init.assert_called_once_with(dhcp_db_connector.config_db, "VLAN") + print(ret) + mock_get_keys.assert_called_once_with() + print(ret) + assert ret == { + "key1": {"list": ["1", "2"], "value": "3,4"}, + "key2": {"list": ["1", "2"], "value": "3,4"} + } + + +@pytest.mark.parametrize("test_type", interval_test_data.keys()) +def test_merge_intervals(test_type): + intervals = convert_ip_address_intervals(interval_test_data[test_type]["intervals"]) + expected_res = convert_ip_address_intervals(interval_test_data[test_type]["expected_res"]) + assert dhcp_server_utils.merge_intervals(intervals) == expected_res + + +def mock_hget(_, field): + if field == "list": + return False, "" + else: + return True, "" + + +def convert_ip_address_intervals(intervals): + ret = [] + for interval in intervals: + ret.append([ipaddress.ip_address(interval[0]), ipaddress.ip_address(interval[1])]) + return ret diff --git a/src/sonic-dhcp-server/tests/test_dhcpservd.py b/src/sonic-dhcp-server/tests/test_dhcpservd.py new file mode 100644 index 000000000000..08e3253a6b94 --- /dev/null +++ b/src/sonic-dhcp-server/tests/test_dhcpservd.py @@ -0,0 +1,60 @@ +import pytest +import psutil +import signal +from dhcp_server.dhcp_server_utils import DhcpDbConnector +from dhcp_server.dhcp_cfggen import DhcpServCfgGenerator +from dhcp_server.dhcpservd import DhcpServd +from unittest.mock import patch, call, MagicMock + + +def test_dump_dhcp4_config(mock_swsscommon_dbconnector_init): + with patch("dhcp_server.dhcp_cfggen.DhcpServCfgGenerator.generate", return_value="dummy_config") as mock_generate, \ + patch("dhcp_server.dhcpservd.DhcpServd._notify_kea_dhcp4_proc", MagicMock()) as mock_notify_kea_dhcp4_proc: + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector, + port_map_path="tests/test_data/port-name-alias-map.txt", + kea_conf_template_path="tests/test_data/kea-dhcp4.conf.j2") + dhcpservd = DhcpServd(dhcp_cfg_generator, dhcp_db_connector, kea_dhcp4_config_path="/tmp/kea-dhcp4.conf") + dhcpservd.dump_dhcp4_config() + # Verfiy whether generate() func of dhcp_cfggen is called + mock_generate.assert_called_once_with() + # Verify whether notify func of dhcpservd is called, which is expected to call after new config generated + mock_notify_kea_dhcp4_proc.assert_called_once_with() + + +@pytest.mark.parametrize("process_list", [["proc1", "proc2", "kea-dhcp4"], ["proc1", "proc2"]]) +def test_notify_kea_dhcp4_proc(process_list, mock_swsscommon_dbconnector_init, mock_get_render_template, + mock_parse_port_map_alias): + proc_list = [MockProc(process_name) for process_name in process_list] + with patch.object(psutil, "process_iter", return_value=proc_list), \ + patch.object(MockProc, "send_signal", MagicMock()) as mock_send_signal: + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + dhcpservd = DhcpServd(dhcp_cfg_generator, dhcp_db_connector) + dhcpservd._notify_kea_dhcp4_proc() + if "kea-dhcp4" in process_list: + mock_send_signal.assert_has_calls([ + call(signal.SIGHUP) + ]) + else: + mock_send_signal.assert_not_called() + + +def test_start(mock_swsscommon_dbconnector_init, mock_parse_port_map_alias, mock_get_render_template): + with patch.object(DhcpServd, "dump_dhcp4_config") as mock_dump: + dhcp_db_connector = DhcpDbConnector() + dhcp_cfg_generator = DhcpServCfgGenerator(dhcp_db_connector) + dhcpservd = DhcpServd(dhcp_cfg_generator, dhcp_db_connector) + dhcpservd.start() + mock_dump.assert_called_once_with() + + +class MockProc(object): + def __init__(self, name): + self.proc_name = name + + def name(self): + return self.proc_name + + def send_signal(self, sig_num): + pass diff --git a/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp b/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp index c660486f749a..6df0a73b0210 100644 --- a/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp +++ b/src/sonic-eventd/rsyslog_plugin/rsyslog_plugin.cpp @@ -5,7 +5,7 @@ #include #include #include "rsyslog_plugin.h" -#include "json.hpp" +#include using json = nlohmann::json; @@ -56,7 +56,7 @@ bool RsyslogPlugin::createRegexList() { } try { regexFile >> jsonList; - } catch (invalid_argument& iaException) { + } catch (nlohmann::detail::parse_error& iaException) { SWSS_LOG_ERROR("Invalid JSON file: %s, throws exception: %s\n", m_regexPath.c_str(), iaException.what()); return false; } @@ -83,7 +83,7 @@ bool RsyslogPlugin::createRegexList() { rs.tag = tag; rs.regexExpression = expression; regexList.push_back(rs); - } catch (domain_error& deException) { + } catch (nlohmann::detail::type_error& deException) { SWSS_LOG_ERROR("Missing required key, throws exception: %s\n", deException.what()); return false; } catch (regex_error& reException) { diff --git a/src/sonic-eventd/rsyslog_plugin/syslog_parser.h b/src/sonic-eventd/rsyslog_plugin/syslog_parser.h index f912cf7e82a7..0d5217a35ac3 100644 --- a/src/sonic-eventd/rsyslog_plugin/syslog_parser.h +++ b/src/sonic-eventd/rsyslog_plugin/syslog_parser.h @@ -11,7 +11,7 @@ extern "C" #include #include #include -#include "json.hpp" +#include #include "events.h" #include "timestamp_formatter.h" diff --git a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp index 4777f7376be7..5ff41d11dd70 100644 --- a/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp +++ b/src/sonic-eventd/rsyslog_plugin_tests/rsyslog_plugin_ut.cpp @@ -9,7 +9,7 @@ extern "C" #include #include #include "gtest/gtest.h" -#include "json.hpp" +#include #include "events.h" #include "../rsyslog_plugin/rsyslog_plugin.h" #include "../rsyslog_plugin/syslog_parser.h" diff --git a/src/sonic-eventd/tools/events_tool.cpp b/src/sonic-eventd/tools/events_tool.cpp index d07f5887a817..8b969b2f80af 100644 --- a/src/sonic-eventd/tools/events_tool.cpp +++ b/src/sonic-eventd/tools/events_tool.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "events.h" #include "events_common.h" diff --git a/src/sonic-gnmi b/src/sonic-gnmi index cbb763111e63..07e0b364375c 160000 --- a/src/sonic-gnmi +++ b/src/sonic-gnmi @@ -1 +1 @@ -Subproject commit cbb763111e6355666c2d7c2dd1a90d5e9ae3935d +Subproject commit 07e0b364375c9b867ae1f5d600d0785f30e3f4d3 diff --git a/src/sonic-linux-kernel b/src/sonic-linux-kernel index ecba611b9510..6508505bea84 160000 --- a/src/sonic-linux-kernel +++ b/src/sonic-linux-kernel @@ -1 +1 @@ -Subproject commit ecba611b95103865207bbedef8fb41cb7fa5e68c +Subproject commit 6508505bea84ed786fa72ff9d7bbb195932c66d9 diff --git a/src/sonic-p4rt/sonic-pins b/src/sonic-p4rt/sonic-pins index 526b4223e6e2..56a7762a3f1e 160000 --- a/src/sonic-p4rt/sonic-pins +++ b/src/sonic-p4rt/sonic-pins @@ -1 +1 @@ -Subproject commit 526b4223e6e27f769363204b481738b834b3e39f +Subproject commit 56a7762a3f1efa6436577d83b9b1110d05387cd9 diff --git a/src/sonic-platform-common b/src/sonic-platform-common index c63abc0d8cca..6d804d6a4f5e 160000 --- a/src/sonic-platform-common +++ b/src/sonic-platform-common @@ -1 +1 @@ -Subproject commit c63abc0d8cca8a3b550e46fd780291269a05e7f3 +Subproject commit 6d804d6a4f5e8c7f9d2096bbbd0bb42552a93a39 diff --git a/src/sonic-restapi b/src/sonic-restapi index a69ba06560eb..ccad4a24b3ea 160000 --- a/src/sonic-restapi +++ b/src/sonic-restapi @@ -1 +1 @@ -Subproject commit a69ba06560eb9d2a9b5ace43e22e9665fa986d33 +Subproject commit ccad4a24b3ea2dd1afd3391f7e99864bd1414976 diff --git a/src/sonic-sairedis b/src/sonic-sairedis index 9263397112a1..15fa9075bba1 160000 --- a/src/sonic-sairedis +++ b/src/sonic-sairedis @@ -1 +1 @@ -Subproject commit 9263397112a16808e026a29bc4940f2bdd0c9058 +Subproject commit 15fa9075bba1b0b5ebc727eae666921b9c46792a diff --git a/src/sonic-snmpagent b/src/sonic-snmpagent index 00d836386a6f..bdaddca5db1a 160000 --- a/src/sonic-snmpagent +++ b/src/sonic-snmpagent @@ -1 +1 @@ -Subproject commit 00d836386a6fdb8de01f7a211f89155f3b927d5d +Subproject commit bdaddca5db1a4b7071c05bdff324257685e889d6 diff --git a/src/sonic-swss b/src/sonic-swss index 45547e66dd50..a9867e67c369 160000 --- a/src/sonic-swss +++ b/src/sonic-swss @@ -1 +1 @@ -Subproject commit 45547e66dd503acae5d5b6bdc2525c1d55cbe114 +Subproject commit a9867e67c36932312ea5696ccf9a65874e71a64b diff --git a/src/sonic-swss-common b/src/sonic-swss-common index b0f148ea6c62..1c185029532e 160000 --- a/src/sonic-swss-common +++ b/src/sonic-swss-common @@ -1 +1 @@ -Subproject commit b0f148ea6c62fbdf781947e28a3de2edf378d35f +Subproject commit 1c185029532e350c32a79ab2f7d7f007ccf58ef8 diff --git a/src/sonic-utilities b/src/sonic-utilities index 7f8779d43349..0ae5d2d28e12 160000 --- a/src/sonic-utilities +++ b/src/sonic-utilities @@ -1 +1 @@ -Subproject commit 7f8779d433492b6a742b26269faaaff74c5fe39b +Subproject commit 0ae5d2d28e12bb4ed94c9cdf77bb1b924fec72d0 diff --git a/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang index 51c69a480fe8..c8c23a650063 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang @@ -83,7 +83,7 @@ module sonic-device_neighbor_metadata { leaf type { description "Network element type"; type string { - pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC|Asic|Supervior|MgmtToRRouter|MgmtLeafRouter|SpineRouter|BackEndToRRouter|BackEndLeafRouter|EPMS|MgmtTsToR|BmcMgmtToRRouter|Server|Bmc|MiniPower|SmartCable|Ixia|not-provisioned"; + pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC|Asic|Supervior|MgmtToRRouter|MgmtLeafRouter|SpineRouter|BackEndToRRouter|BackEndLeafRouter|EPMS|MgmtTsToR|BmcMgmtToRRouter|Server|Bmc|MiniPower|SmartCable|Ixia|EdgeZoneAggregator|not-provisioned"; } } diff --git a/src/sonic-ztp b/src/sonic-ztp index 8768991556cc..739470d666a1 160000 --- a/src/sonic-ztp +++ b/src/sonic-ztp @@ -1 +1 @@ -Subproject commit 8768991556cc6ec408ff42b425e7319a987de120 +Subproject commit 739470d666a1ed4f62dd29af2316eb7d70366ace diff --git a/src/tacacs/bash_tacplus/bash_tacplus.c b/src/tacacs/bash_tacplus/bash_tacplus.c index 82f57c724c7d..6e72e8f0a0cf 100644 --- a/src/tacacs/bash_tacplus/bash_tacplus.c +++ b/src/tacacs/bash_tacplus/bash_tacplus.c @@ -14,8 +14,8 @@ /* Remote user gecos prefix, which been assigned by nss_tacplus */ #define REMOTE_USER_GECOS_PREFIX "remote_user" -/* Default value for _SC_GETPW_R_SIZE_MAX */ -#define DEFAULT_SC_GETPW_R_SIZE_MAX 1024 +/* Default value for getpwent */ +#define DEFAULT_GETPWENT_SIZE_MAX 4096 /* Return value for is_local_user method */ #define IS_LOCAL_USER 0 @@ -31,6 +31,7 @@ /* Output syslog to mock method when build with UT */ #if defined (BASH_PLUGIN_UT) #define syslog mock_syslog +#define getpwent_r mock_getpwent_r #endif /* Tacacs+ log format */ @@ -350,40 +351,39 @@ int is_local_user(char *user) } struct passwd pwd; - struct passwd *pwdresult; - char *buf; - size_t bufsize = sysconf(_SC_GETPW_R_SIZE_MAX); - if (bufsize == -1) { - bufsize = DEFAULT_SC_GETPW_R_SIZE_MAX; - } + struct passwd *ppwd; + char buf[DEFAULT_GETPWENT_SIZE_MAX]; + int pwdresult; + int result = ERROR_CHECK_LOCAL_USER; + setpwent(); + while (1) { + pwdresult = getpwent_r(&pwd, buf, sizeof(buf), &ppwd); + if (pwdresult) { + // no more pw entry + break; + } - buf = malloc(bufsize); - if (buf == NULL) { - output_error("failed to allocate getpwnam_r buffer.\n"); - return ERROR_CHECK_LOCAL_USER; - } + if (strcmp(ppwd->pw_name, user) != 0) { + continue; + } - int s = getpwnam_r(user, &pwd, buf, bufsize, &pwdresult); - int result = IS_LOCAL_USER; - if (pwdresult == NULL) { - if (s == 0) - output_error("get user information user failed, user: %s not found\n", user); + // compare passwd entry, for remote user pw_gecos will start as 'remote_user' + if (strncmp(ppwd->pw_gecos, REMOTE_USER_GECOS_PREFIX, strlen(REMOTE_USER_GECOS_PREFIX)) == 0) { + output_debug("user: %s, UID: %d, GECOS: %s is remote user.\n", user, ppwd->pw_uid, ppwd->pw_gecos); + result = IS_REMOTE_USER; + } else { - output_error("get user information failed, user: %s, errorno: %d\n", user, s); + output_debug("user: %s, UID: %d, GECOS: %s is local user.\n", user, ppwd->pw_uid, ppwd->pw_gecos); + result = IS_LOCAL_USER; } - - result = ERROR_CHECK_LOCAL_USER; - } - else if (strncmp(pwd.pw_gecos, REMOTE_USER_GECOS_PREFIX, strlen(REMOTE_USER_GECOS_PREFIX)) == 0) { - output_debug("user: %s, UID: %d, GECOS: %s is remote user.\n", user, pwd.pw_uid, pwd.pw_gecos); - result = IS_REMOTE_USER; + break; } - else { - output_debug("user: %s, UID: %d, GECOS: %s is local user.\n", user, pwd.pw_uid, pwd.pw_gecos); - result = IS_LOCAL_USER; + endpwent(); + + if (result == ERROR_CHECK_LOCAL_USER) { + output_error("get user information user failed, user: %s not found\n", user); } - free(buf); return result; } @@ -485,4 +485,4 @@ int on_shell_execve (char *user, int shell_level, char *cmd, char **argv) // return 0, so bash will continue run user command and will check user permission with linux permission check. output_debug("start local authorization for command %s with given arguments\n", cmd); return 0; -} \ No newline at end of file +} diff --git a/src/tacacs/bash_tacplus/unittest/mock_helper.c b/src/tacacs/bash_tacplus/unittest/mock_helper.c index 97c99f2cb1d0..d2fc9424fcc3 100644 --- a/src/tacacs/bash_tacplus/unittest/mock_helper.c +++ b/src/tacacs/bash_tacplus/unittest/mock_helper.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -206,4 +207,33 @@ void mock_syslog(int priority, const char *format, ...) va_end (args); debug_printf("MOCK: syslog: %s\n", mock_syslog_message_buffer); +} + +int mock_getpwent_r(struct passwd *restrict pwbuf, + char *buf, size_t buflen, + struct passwd **restrict pwbufp) +{ + static char* test_user = "test_user"; + static char* root_user = "root"; + static char* empty_gecos = ""; + static char* remote_gecos = "remote_user"; + *pwbufp = pwbuf; + switch (test_scenario) + { + case TEST_SCEANRIO_CONNECTION_SEND_SUCCESS_RESULT: + case TEST_SCEANRIO_CONNECTION_SEND_DENINED_RESULT: + case TEST_SCEANRIO_IS_LOCAL_USER_REMOTE: + pwbuf->pw_name = test_user; + pwbuf->pw_gecos = remote_gecos; + pwbuf->pw_uid = 1000; + return 0; + case TEST_SCEANRIO_IS_LOCAL_USER_ROOT: + pwbuf->pw_name = root_user; + pwbuf->pw_gecos = empty_gecos; + pwbuf->pw_uid = 0; + return 0; + case TEST_SCEANRIO_IS_LOCAL_USER_NOT_FOUND: + return 1; + } + return 1; } \ No newline at end of file diff --git a/src/tacacs/bash_tacplus/unittest/mock_helper.h b/src/tacacs/bash_tacplus/unittest/mock_helper.h index 348b7810fc0e..7cc6779c7080 100644 --- a/src/tacacs/bash_tacplus/unittest/mock_helper.h +++ b/src/tacacs/bash_tacplus/unittest/mock_helper.h @@ -24,11 +24,16 @@ /* Mock syslog buffer */ extern char mock_syslog_message_buffer[1024]; -#define TEST_SCEANRIO_CONNECTION_ALL_FAILED 1 -#define TEST_SCEANRIO_CONNECTION_SEND_FAILED_RESULT 2 -#define TEST_SCEANRIO_CONNECTION_SEND_SUCCESS_READ_FAILED 3 -#define TEST_SCEANRIO_CONNECTION_SEND_DENINED_RESULT 4 -#define TEST_SCEANRIO_CONNECTION_SEND_SUCCESS_RESULT 5 +#define TEST_SCEANRIO_CONNECTION_ALL_FAILED 1 +#define TEST_SCEANRIO_CONNECTION_SEND_FAILED_RESULT 2 +#define TEST_SCEANRIO_CONNECTION_SEND_SUCCESS_READ_FAILED 3 +#define TEST_SCEANRIO_CONNECTION_SEND_DENINED_RESULT 4 +#define TEST_SCEANRIO_CONNECTION_SEND_SUCCESS_RESULT 5 +#define TEST_SCEANRIO_LOAD_CHANGED_TACACS_CONFIG 6 +#define TEST_SCEANRIO_IS_LOCAL_USER_UNKNOWN 7 +#define TEST_SCEANRIO_IS_LOCAL_USER_NOT_FOUND 8 +#define TEST_SCEANRIO_IS_LOCAL_USER_ROOT 9 +#define TEST_SCEANRIO_IS_LOCAL_USER_REMOTE 10 /* Set test scenario for test*/ void set_test_scenario(int scenario); diff --git a/src/tacacs/bash_tacplus/unittest/plugin_test.c b/src/tacacs/bash_tacplus/unittest/plugin_test.c index 87df69b7dae5..ab12829cfb4e 100644 --- a/src/tacacs/bash_tacplus/unittest/plugin_test.c +++ b/src/tacacs/bash_tacplus/unittest/plugin_test.c @@ -5,6 +5,10 @@ #include "mock_helper.h" #include +#define IS_LOCAL_USER 0 +#define IS_REMOTE_USER 1 +#define ERROR_CHECK_LOCAL_USER 2 + /* tacacs debug flag */ extern int tacacs_ctrl; @@ -112,6 +116,8 @@ void testcase_authorization_with_host_and_tty_success() { /* Test check_and_load_changed_tacacs_config */ void testcase_check_and_load_changed_tacacs_config() { + set_test_scenario(TEST_SCEANRIO_LOAD_CHANGED_TACACS_CONFIG); + // test connection failed case check_and_load_changed_tacacs_config(); @@ -171,6 +177,43 @@ void testcase_on_shell_execve_failed() { CU_ASSERT_STRING_EQUAL(mock_syslog_message_buffer, "test_command not authorized by TACACS+ with given arguments, not executing\n"); } +/* Test is_local_user unknown user */ +void testcase_is_local_user_unknown() { + set_test_scenario(TEST_SCEANRIO_IS_LOCAL_USER_UNKNOWN); + int result = is_local_user("UNKNOWN"); + + // check unknown user is remote. + CU_ASSERT_EQUAL(result, IS_REMOTE_USER); +} + +/* Test is_local_user not found user */ +void testcase_is_local_user_not_found() { + set_test_scenario(TEST_SCEANRIO_IS_LOCAL_USER_NOT_FOUND); + int result = is_local_user("notexist"); + + // check unknown user is remote. + CU_ASSERT_EQUAL(result, ERROR_CHECK_LOCAL_USER); + CU_ASSERT_STRING_EQUAL(mock_syslog_message_buffer, "get user information user failed, user: notexist not found\n"); +} + +/* Test is_local_user root user */ +void testcase_is_local_user_root() { + set_test_scenario(TEST_SCEANRIO_IS_LOCAL_USER_ROOT); + int result = is_local_user("root"); + + // check unknown user is remote. + CU_ASSERT_EQUAL(result, IS_LOCAL_USER); +} + +/* Test is_local_user remote user */ +void testcase_is_local_user_remote() { + set_test_scenario(TEST_SCEANRIO_IS_LOCAL_USER_REMOTE); + int result = is_local_user("test_user"); + + // check unknown user is remote. + CU_ASSERT_EQUAL(result, IS_REMOTE_USER); +} + int main(void) { if (CUE_SUCCESS != CU_initialize_registry()) { return CU_get_error(); @@ -196,7 +239,11 @@ int main(void) { || !CU_add_test(ste, "Test testcase_check_and_load_changed_tacacs_config()...\n", testcase_check_and_load_changed_tacacs_config) || !CU_add_test(ste, "Test testcase_on_shell_execve_success()...\n", testcase_on_shell_execve_success) || !CU_add_test(ste, "Test testcase_on_shell_execve_denined()...\n", testcase_on_shell_execve_denined) - || !CU_add_test(ste, "Test testcase_on_shell_execve_failed()...\n", testcase_on_shell_execve_failed)) { + || !CU_add_test(ste, "Test testcase_on_shell_execve_failed()...\n", testcase_on_shell_execve_failed) + || !CU_add_test(ste, "Test testcase_is_local_user_unknown()...\n", testcase_is_local_user_unknown) + || !CU_add_test(ste, "Test testcase_is_local_user_not_found()...\n", testcase_is_local_user_not_found) + || !CU_add_test(ste, "Test testcase_is_local_user_root()...\n", testcase_is_local_user_root) + || !CU_add_test(ste, "Test testcase_is_local_user_remote()...\n", testcase_is_local_user_remote)) { CU_cleanup_registry(); return CU_get_error(); }