[PATCH v3 06/10] firmware: Resurrect the ixp4xx microcode package

Christian Marangi ansuelsmth at gmail.com
Fri Oct 20 04:31:06 PDT 2023


On Thu, Oct 12, 2023 at 10:42:21AM +0200, Linus Walleij wrote:
> The firmware package for the IXP4xx microcode was deleted but
> the source files are still in the file cache so we can easily
> resurrect it.
> 
> The firmware either supports ethernet (the most common) or
> WAN (less common), image targets select the firmware they
> want depending on usecase.
> 
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
>  package/firmware/ixp4xx-microcode/Makefile         |  77 +++++++++++
>  .../firmware/ixp4xx-microcode/src/IxNpeMicrocode.h | 148 +++++++++++++++++++++
>  package/firmware/ixp4xx-microcode/src/LICENSE.IPL  |  27 ++++
>  3 files changed, 252 insertions(+)
> 
> diff --git a/package/firmware/ixp4xx-microcode/Makefile b/package/firmware/ixp4xx-microcode/Makefile
> new file mode 100644
> index 000000000000..5ee04a757a2c
> --- /dev/null
> +++ b/package/firmware/ixp4xx-microcode/Makefile
> @@ -0,0 +1,77 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Copyright (C) 2007-2023 OpenWrt.org
> +
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=ixp4xx-microcode
> +PKG_VERSION:=2.4
> +PKG_RELEASE:=1
> +
> +PKG_SOURCE:=IPL_ixp400NpeLibraryWithCrypto-2_4.zip
> +PKG_SOURCE_URL:=http://downloads.openwrt.org/sources

Ehhh we really need to think of a better way for this...

> +PKG_HASH:=1b1170d0657847248589d946048c0aeaa9cd671966fc5bec5933283309485eaa
> +
> +PKG_FLAGS:=nonshared

Missing PKG_LICENSE and PKG_LICENSE_FILES entry? (That I think are
required to redistribute this?)

> +
> +include $(INCLUDE_DIR)/package.mk
> +
> +# Ethernet or WAN support, pick one
> +define Package/ixp4xx-microcode-ethernet
> +  SECTION:=firmware
> +  CATEGORY:=Firmware
> +  TITLE:=IXP4xx ethernet firmware
> +  DEPENDS:=@TARGET_ixp4xx
> +endef
> +define Package/ixp4xx-microcode-wan
> +  SECTION:=firmware
> +  CATEGORY:=Firmware
> +  TITLE:=IXP4xx WAN firmware
> +  DEPENDS:=@TARGET_ixp4xx
> +endef
> +
> +define Package/ixp4xx-microcode-ethernet/description
> + This package contains the microcode needed to use the network engines in
> + IXP4xx CPUs for ethernet on all three NPEs.
> +endef
> +define Package/ixp4xx-microcode-wan/description
> + This package contains the microcode needed to use the network engines in
> + IXP4xx CPUs for ethernet on NPE-A and NPE-B and WAN (HSS) on NPE-C.
> +endef
> +
> +define Build/Prepare
> +	rm -rf $(PKG_BUILD_DIR)
> +	mkdir -p $(PKG_BUILD_DIR)
> +	unzip -d $(PKG_BUILD_DIR)/ $(DL_DIR)/$(PKG_SOURCE)
> +	mv $(PKG_BUILD_DIR)/ixp400_xscale_sw/src/npeDl/IxNpeMicrocode.c $(PKG_BUILD_DIR)/
> +	rm -rf $(PKG_BUILD_DIR)/ixp400_xscale_sw
> +	$(CP) ./src/* $(PKG_BUILD_DIR)/
> +endef
> +
> +define Build/Compile
> +	(cd $(PKG_BUILD_DIR); \
> +		$(HOSTCC) -Wall -I$(STAGING_DIR_HOST)/include IxNpeMicrocode.c -o IxNpeMicrocode; \
> +		./IxNpeMicrocode -be \
> +	)
> +endef
> +
> +define Package/ixp4xx-microcode-ethernet/install
> +	$(INSTALL_DIR) $(1)/lib/firmware
> +	$(INSTALL_DIR) $(1)/usr/share/doc
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A $(1)/lib/firmware/
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-B $(1)/lib/firmware/
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-C $(1)/lib/firmware/
> +	$(INSTALL_DATA) $(PKG_BUILD_DIR)/LICENSE.IPL $(1)/usr/share/doc/
> +endef
> +define Package/ixp4xx-microcode-wan/install
> +	$(INSTALL_DIR) $(1)/lib/firmware
> +	$(INSTALL_DIR) $(1)/usr/share/doc
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-A-HSS $(1)/lib/firmware/
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-B $(1)/lib/firmware/
> +	$(INSTALL_BIN) $(PKG_BUILD_DIR)/NPE-C $(1)/lib/firmware/
> +	$(INSTALL_DATA) $(PKG_BUILD_DIR)/LICENSE.IPL $(1)/usr/share/doc/
> +endef
> +
> +
> +$(eval $(call BuildPackage,ixp4xx-microcode-ethernet))
> +$(eval $(call BuildPackage,ixp4xx-microcode-wan))
> diff --git a/package/firmware/ixp4xx-microcode/src/IxNpeMicrocode.h b/package/firmware/ixp4xx-microcode/src/IxNpeMicrocode.h
> new file mode 100644
> index 000000000000..4a843db104f9
> --- /dev/null
> +++ b/package/firmware/ixp4xx-microcode/src/IxNpeMicrocode.h
> @@ -0,0 +1,148 @@
> +/*
> + * IxNpeMicrocode.h - Headerfile for compiling the Intel microcode C file
> + *
> + * Copyright (C) 2006 Christian Hohnstaedt <chohnstaedt at innominate.com>
> + *
> + * This file is released under the GPLv2
> + *
> + *
> + * compile with
> + *
> + * gcc -Wall IxNpeMicrocode.c -o IxNpeMicrocode
> + *
> + * Executing the resulting binary on your build-host creates the
> + * "NPE-[ABC].xxxxxxxx" files containing the selected microcode
> + *
> + * fetch the IxNpeMicrocode.c from the Intel Access Library.
> + * It will include this header.
> + *
> + * select Images for every NPE from the following
> + * (used C++ comments for easy uncommenting ....)
> + */
> +
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEA_HSS_TSLOT_SWITCH
> +#define IX_NPEDL_NPEIMAGE_NPEA_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ETH_LEARN_FILTER_SPAN_FIREWALL
> +#define IX_NPEDL_NPEIMAGE_NPEA_HSS_2_PORT
> +// #define IX_NPEDL_NPEIMAGE_NPEA_DMA
> +// #define IX_NPEDL_NPEIMAGE_NPEA_ATM_MPHY_12_PORT
> +// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_MPHY_1_PORT
> +// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0_ATM_SPHY_1_PORT
> +// #define IX_NPEDL_NPEIMAGE_NPEA_HSS0
> +// #define IX_NPEDL_NPEIMAGE_NPEA_WEP
> +
> +
> +// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEB_DMA
> +#define IX_NPEDL_NPEIMAGE_NPEB_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
> +// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
> +// #define IX_NPEDL_NPEIMAGE_NPEB_ETH_LEARN_FILTER_SPAN_FIREWALL
> +
> +
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_MASK_FIREWALL_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_VLAN_QOS_HDR_CONV_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_MASK_FIREWALL_VLAN_QOS_EXTMIB
> +// #define IX_NPEDL_NPEIMAGE_NPEC_DMA
> +// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_SPAN
> +// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_ETH_LEARN_FILTER_FIREWALL
> +#define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_ETH
> +// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_AES_CCM_EXTSHA_ETH
> +// #define IX_NPEDL_NPEIMAGE_NPEC_CRYPTO_ETH_LEARN_FILTER_SPAN_FIREWALL
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_SPAN_FIREWALL_VLAN_QOS_HDR_CONV
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL_VLAN_QOS
> +// #define IX_NPEDL_NPEIMAGE_NPEC_ETH_LEARN_FILTER_SPAN_FIREWALL
> +
> +
> +#include <stdio.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <netinet/in.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <errno.h>
> +#include <endian.h>
> +#include <byteswap.h>
> +#include <string.h>
> +
> +#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#define to_le32(x) (x)
> +#define to_be32(x) bswap_32(x)
> +#else
> +#define to_be32(x) (x)
> +#define to_le32(x) bswap_32(x)
> +#endif
> +
> +struct dl_image {
> +	unsigned magic;
> +	unsigned id;
> +	unsigned size;
> +	unsigned data[0];
> +};
> +
> +const unsigned IxNpeMicrocode_array[];
> +
> +int main(int argc, char *argv[])
> +{
> +	struct dl_image *image = (struct dl_image *)IxNpeMicrocode_array;
> +	int imgsiz, i, fd, cnt;
> +	const unsigned *arrayptr = IxNpeMicrocode_array;
> +	const char *names[] = { "IXP425", "IXP465", "unknown" };
> +	int bigendian = 1;
> +
> +	if (argc > 1) {
> +		if (!strcmp(argv[1], "-le"))
> +			bigendian = 0;
> +		else if (!strcmp(argv[1], "-be"))
> +			bigendian = 1;
> +		else {
> +			printf("Usage: %s <-le|-be>\n", argv[0]);
> +			return EXIT_FAILURE;
> +		}
> +	}
> +
> +	for (image = (struct dl_image *)arrayptr, cnt=0;
> +		(image->id != 0xfeedf00d) && (image->magic == 0xfeedf00d);
> +		image = (struct dl_image *)(arrayptr), cnt++)
> +	{
> +		unsigned char field[4];
> +		imgsiz = image->size + 3;
> +		*(unsigned*)field = to_be32(image->id);
> +		char filename[40], slnk[10];
> +
> +		sprintf(filename, "NPE-%c.%08x", (field[0] & 0xf) + 'A',
> +			image->id);
> +		if (image->id == 0x00090000)
> +			sprintf(slnk, "NPE-%c-HSS", (field[0] & 0xf) + 'A');
> +		else
> +			sprintf(slnk, "NPE-%c", (field[0] & 0xf) + 'A');
> +
> +		printf("Writing image: %s.NPE_%c Func: %2x Rev: %02x.%02x "
> +			"Size: %5d to: '%s'\n",
> +			names[field[0] >> 4], (field[0] & 0xf) + 'A',
> +			field[1], field[2], field[3], imgsiz*4, filename);
> +		fd = open(filename, O_CREAT | O_RDWR | O_TRUNC, 0644);
> +		if (fd >= 0) {
> +			for (i=0; i<imgsiz; i++) {
> +				*(unsigned*)field = bigendian ?
> +					to_be32(arrayptr[i]) :
> +					to_le32(arrayptr[i]);
> +				write(fd, field, sizeof(field));
> +			}
> +			close(fd);
> +			unlink(slnk);
> +			symlink(filename, slnk);
> +		} else {
> +			perror(filename);
> +		}
> +		arrayptr += imgsiz;
> +	}
> +	close(fd);
> +	return 0;
> +}
> diff --git a/package/firmware/ixp4xx-microcode/src/LICENSE.IPL b/package/firmware/ixp4xx-microcode/src/LICENSE.IPL
> new file mode 100644
> index 000000000000..dad2566cfcaa
> --- /dev/null
> +++ b/package/firmware/ixp4xx-microcode/src/LICENSE.IPL
> @@ -0,0 +1,27 @@
> +INTEL(R) SOFTWARE LICENSE AGREEMENT
> + 
> +Copyright (c) 2007, Intel Corporation.
> +All rights reserved.
> +
> +Redistribution. Redistribution and use in binary form, without modification, are permitted
> +provided that the following conditions are met:
> +o Redistributions must reproduce the above copyright notice and the following disclaimer in the
> +documentation and/or other materials provided with the distribution. 
> +o Neither the name of Intel Corporation nor the names of its suppliers may be used to endorse
> +or promote products derived from this software without specific prior written permission. 
> +o No reverse engineering, decompilation, or disassembly of this software is permitted.
> +
> +Limited patent license. Intel Corporation grants a world-wide, royalty-free, non-exclusive
> +license under patents it now or hereafter owns or controls to make, have made, use, import,
> +offer to sell and sell (.Utilize.) this software, but solely to the extent that any such patent is
> +necessary to Utilize the software alone. The patent license shall not apply to any combinations
> +which include this software. No hardware per se is licensed hereunder.
> +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
> +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
> +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
> +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
> +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
> +OF SUCH DAMAGE.
> 
> -- 
> 2.34.1
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

-- 
	Ansuel



More information about the openwrt-devel mailing list