diff --git a/platform/broadcom/sai.mk b/platform/broadcom/sai.mk index 3df9fb04e10a..3ffb9054c7a4 100644 --- a/platform/broadcom/sai.mk +++ b/platform/broadcom/sai.mk @@ -1,9 +1,9 @@ -BRCM_SAI = libsaibcm_3.1.3.5-12_amd64.deb -$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/libsaibcm_3.1.3.5-12_amd64.deb?sv=2015-04-05&sr=b&sig=6%2Fwcn0EN0krkXMCeOpAgo4N2d%2FgiZJAuU%2FwYhaXNpBE%3D&se=2032-08-07T16%3A57%3A37Z&sp=r" +BRCM_SAI = libsaibcm_3.3.3.1-1_amd64.deb +$(BRCM_SAI)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/3.3/libsaibcm_3.3.3.1-1_amd64.deb?sv=2015-04-05&sr=b&sig=Kp6Pjrvt9DD8fThhSjzDJNuVRYuW6aLwi2bgegM0hd8%3D&se=2032-08-09T02%3A22%3A31Z&sp=r" -BRCM_SAI_DEV = libsaibcm-dev_3.1.3.5-12_amd64.deb +BRCM_SAI_DEV = libsaibcm-dev_3.3.3.1-1_amd64.deb $(eval $(call add_derived_package,$(BRCM_SAI),$(BRCM_SAI_DEV))) -$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/libsaibcm-dev_3.1.3.5-12_amd64.deb?sv=2015-04-05&sr=b&sig=9Tf4Rm0Hftx9IavbLmV6PzsxzejuUzwCRFKNmU2pAkU%3D&se=2032-08-07T16%3A57%3A08Z&sp=r" +$(BRCM_SAI_DEV)_URL = "https://sonicstorage.blob.core.windows.net/packages/bcmsai/3.3/libsaibcm-dev_3.3.3.1-1_amd64.deb?sv=2015-04-05&sr=b&sig=fTWUp3gOcNQNT9sS66CSEyP0JkSlPHNRlsvG4L64I0g%3D&se=2032-08-09T02%3A22%3A08Z&sp=r" SONIC_ONLINE_DEBS += $(BRCM_SAI) $(BRCM_SAI_DEV)_DEPENDS += $(BRCM_SAI) diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.init b/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.init index 7f9f2e24db19..30123b1d98bd 100755 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.init +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.init @@ -12,35 +12,61 @@ # Short-Description: Load OpenNSL kernel modules ### END INIT INFO +function create_devices() +{ + rm -f /dev/linux-knet-cb + rm -f /dev/linux-bcm-knet + rm -f /dev/linux-bcm-bde + rm -f /dev/linux-kernel-bde + + mknod /dev/linux-knet-cb c 121 0 + mknod /dev/linux-bcm-knet c 122 0 + mknod /dev/linux-bcm-bde c 126 0 + mknod /dev/linux-kernel-bde c 127 0 +} + +function load_kernel_modules() +{ + modprobe linux-kernel-bde dmasize=32M maxpayload=128 + modprobe linux-user-bde + modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238 + modprobe linux-knet-cb +} + +function remove_kernel_modules() +{ + rmmod linux-knet-cb + rmmod linux-bcm-knet + rmmod linux-user-bde + rmmod linux-kernel-bde +} + case "$1" in start) - echo -n "Load OpenNSL kernel modules... " + echo -n "Load OpenNSL kernel modules... " - modprobe linux-kernel-bde dmasize=32M maxpayload=128 - modprobe linux-user-bde - modprobe linux-bcm-knet use_rx_skb=1 rx_buffer_size=9238 + create_devices + load_kernel_modules - echo "done." - ;; + echo "done." + ;; stop) - echo -n "Unload OpenNSL kernel modules... " + echo -n "Unload OpenNSL kernel modules... " - rmmod linux-bcm-knet - rmmod linux-user-bde - rmmod linux-kernel-bde + remove_kernel_modules - echo "done." - ;; + echo "done." + ;; force-reload|restart) - echo "Not supported" - ;; + echo "Not supported" + ;; *) - echo "Usage: /etc/init.d/opennsl-modules-4.9.0-7-amd64.init {start|stop}" - exit 1 - ;; + echo "Usage: /etc/init.d/opennsl-modules-4.9.0-7-amd64.init {start|stop}" + exit 1 + ;; esac exit 0 diff --git a/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.install b/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.install index fe6b748c29b8..8eb7db15ba20 100644 --- a/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.install +++ b/platform/broadcom/saibcm-modules/debian/opennsl-modules-4.9.0-7-amd64.install @@ -1,4 +1,5 @@ systems/linux/user/x86-smp_generic_64-2_6/linux-bcm-knet.ko lib/modules/4.9.0-7-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-kernel-bde.ko lib/modules/4.9.0-7-amd64/extra systems/linux/user/x86-smp_generic_64-2_6/linux-user-bde.ko lib/modules/4.9.0-7-amd64/extra +systems/linux/user/x86-smp_generic_64-2_6/linux-knet-cb.ko lib/modules/4.9.0-7-amd64/extra systemd/opennsl-modules-4.9.0-7-amd64.service lib/systemd/system diff --git a/platform/broadcom/saibcm-modules/debian/rules b/platform/broadcom/saibcm-modules/debian/rules index 7560bfad91fa..59862bf1e556 100755 --- a/platform/broadcom/saibcm-modules/debian/rules +++ b/platform/broadcom/saibcm-modules/debian/rules @@ -60,7 +60,7 @@ kdist_config: prep-deb-files kdist_clean: clean dh_testdir dh_clean - SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean + SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean # rm -f driver/*.o driver/*.ko # ### end KERNEL SETUP @@ -78,7 +78,7 @@ build-arch-stamp: dh_testdir # Add here command to compile/build the package. - SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 + SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 touch $@ @@ -103,7 +103,7 @@ clean: rm -f build-arch-stamp build-indep-stamp configure-stamp # Add here commands to clean up after the build process. - SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean + SDK=$(realpath .) LINUX_UAPI_SPLIT=1 DEBIAN_LINUX_HEADER=1 BUILD_KNET_CB=1 KERNDIR=/usr/src/linux-headers-4.9.0-7-amd64 KERNEL_SRC=/usr/src/linux-headers-4.9.0-7-amd64 $(MAKE) -C systems/linux/user/x86-smp_generic_64-2_6 clean dh_clean diff --git a/platform/broadcom/saibcm-modules/include/ibde.h b/platform/broadcom/saibcm-modules/include/ibde.h index c022e0b95aa0..bfc05e330e03 100644 --- a/platform/broadcom/saibcm-modules/include/ibde.h +++ b/platform/broadcom/saibcm-modules/include/ibde.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: ibde.h,v 1.27 Broadcom SDK $ @@ -83,6 +82,7 @@ typedef struct ibde_s { #define BDE_BYTE_SWAP 0x01000000 /* SW byte swap */ #define BDE_NO_IPROC 0x02000000 /* Device uses two BARs, but is not iProc */ +#define BDE_8MB_REG_SPACE 0x10000000 /* 8MB sized CMIC BAR */ #define BDE_256K_REG_SPACE 0x20000000 /* Map 256K (v 64K) */ #define BDE_128K_REG_SPACE 0x40000000 /* Map 128K (v 64K) */ #define BDE_320K_REG_SPACE 0x80000000 /* Map 256K+64K */ diff --git a/platform/broadcom/saibcm-modules/include/kcom.h b/platform/broadcom/saibcm-modules/include/kcom.h index 5755df250fb6..f66e382e4d8f 100644 --- a/platform/broadcom/saibcm-modules/include/kcom.h +++ b/platform/broadcom/saibcm-modules/include/kcom.h @@ -1,26 +1,25 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: kcom.h,v 1.9 Broadcom SDK $ * $Copyright: (c) 2005 Broadcom Corp. * All Rights Reserved.$ * - * File: kcom.h - * Purpose: User/Kernel message definitions + * File: kcom.h + * Purpose: User/Kernel message definitions */ #ifndef _KCOM_H @@ -37,7 +36,6 @@ #define KCOM_MSG_TYPE_RSP 2 /* Command response */ #define KCOM_MSG_TYPE_EVT 3 /* Unsolicited event */ - /* * Message opcodes */ @@ -57,10 +55,11 @@ #define KCOM_M_FILTER_LIST 23 /* Get list of Rx filter IDs */ #define KCOM_M_FILTER_GET 24 /* Get Rx filter info */ #define KCOM_M_DMA_INFO 31 /* Tx/Rx DMA info */ -#define KCOM_M_DBGPKT_SET 41 /* Enbale debug packet function */ -#define KCOM_M_DBGPKT_GET 42 /* Get debug packet function info */ +#define KCOM_M_DBGPKT_SET 41 /* Enbale debug packet function */ +#define KCOM_M_DBGPKT_GET 42 /* Get debug packet function info */ +#define KCOM_M_WB_CLEANUP 51 /* Clean up for warmbooting */ -#define KCOM_VERSION 8 /* Protocol version */ +#define KCOM_VERSION 9 /* Protocol version */ /* * Message status codes @@ -80,7 +79,6 @@ typedef struct kcom_msg_hdr_s { uint16 id; } kcom_msg_hdr_t; - /* * Object types */ @@ -267,44 +265,40 @@ typedef struct kcom_dma_info_s { uint16 chan; uint16 flags; union { - void *p; - uint8 b[8]; - } cookie; - union { - uint32 dcb_start; + uint64 dcb_start; struct { uint32 tx; uint32 rx; } seqno; } data; + union { + void *p; + uint8 b[8]; + } cookie; } kcom_dma_info_t; /* Default channel configuration */ -#define KCOM_DMA_TX_CHAN 0 -#define KCOM_DMA_RX_CHAN 1 +#define KCOM_DMA_TX_CHAN 0 +#define KCOM_DMA_RX_CHAN 1 #define KCOM_ETH_HW_T_RESET 1 #define KCOM_ETH_HW_T_INIT 2 #define KCOM_ETH_HW_T_OTHER 3 -#define KCOM_ETH_HW_C_ALL 0xff - -#define KCOM_ETH_HW_RESET_F_TX (1U << 0) -#define KCOM_ETH_HW_RESET_F_RX (1U << 1) -#define KCOM_ETH_HW_RESET_F_TX_RECLAIM (1U << 2) -#define KCOM_ETH_HW_RESET_F_RX_RECLAIM (1U << 3) - -#define KCOM_ETH_HW_INIT_F_TX (1U << 0) -#define KCOM_ETH_HW_INIT_F_RX (1U << 1) -#define KCOM_ETH_HW_INIT_F_RX_FILL (1U << 2) - - -#define KCOM_ETH_HW_OTHER_F_FIFO_LOOPBACK (1U << 0) -#define KCOM_ETH_HW_OTHER_F_INTERRUPT (1U << 1) +#define KCOM_ETH_HW_C_ALL 0xff +#define KCOM_ETH_HW_RESET_F_TX (1U << 0) +#define KCOM_ETH_HW_RESET_F_RX (1U << 1) +#define KCOM_ETH_HW_RESET_F_TX_RECLAIM (1U << 2) +#define KCOM_ETH_HW_RESET_F_RX_RECLAIM (1U << 3) +#define KCOM_ETH_HW_INIT_F_TX (1U << 0) +#define KCOM_ETH_HW_INIT_F_RX (1U << 1) +#define KCOM_ETH_HW_INIT_F_RX_FILL (1U << 2) +#define KCOM_ETH_HW_OTHER_F_FIFO_LOOPBACK (1U << 0) +#define KCOM_ETH_HW_OTHER_F_INTERRUPT (1U << 1) typedef struct kcom_eth_hw_config_s { uint8 type; @@ -339,7 +333,6 @@ typedef struct kcom_msg_string_s { char val[KCOM_MSG_STRING_MAX]; } kcom_msg_string_t; - /* * Indicate that eth hardware is about to be reset. Active * DMA operations should be aborted and DMA and interrupts @@ -354,7 +347,6 @@ typedef struct kcom_msg_eth_hw_config_s { kcom_eth_hw_config_t config; } kcom_msg_eth_hw_config_t; - /* * Indicate that switch hardware is about to be reset. Active * DMA operations should be aborted and DMA and interrupts @@ -371,8 +363,11 @@ typedef struct kcom_msg_hw_reset_s { */ typedef struct kcom_msg_hw_init_s { kcom_msg_hdr_t hdr; - uint16 dcb_size; - uint16 dcb_type; + uint8 cmic_type; + uint8 dcb_type; + uint8 dcb_size; + uint8 pkt_hdr_size; + uint32 dma_hi; uint32 cdma_channels; } kcom_msg_hw_init_t; @@ -400,6 +395,14 @@ typedef struct kcom_msg_dbg_pkt_get_s { int value; } kcom_msg_dbg_pkt_get_t; +/* + * Clean up warmboot-related resources. + */ +typedef struct kcom_msg_wb_cleanup_s { + kcom_msg_hdr_t hdr; + uint32 flags; +} kcom_msg_wb_cleanup_t; + /* * Create new system network interface. The network interface will * be associated with the specified switch unit number. @@ -458,8 +461,8 @@ typedef struct kcom_msg_filter_destroy_s { * Get list of currently defined packet filters. */ #ifndef KCOM_FILTER_MAX -/* OPENNSL_FIXUP - Increased the filters to 1024 from 128 */ -#define KCOM_FILTER_MAX 1024 +/* SAI_FIXUP - Increased the filters to 1024 from 128 */ +#define KCOM_FILTER_MAX 1024 #endif typedef struct kcom_msg_filter_list_s { @@ -484,11 +487,9 @@ typedef struct kcom_msg_dma_info_s { kcom_dma_info_t dma_info; } kcom_msg_dma_info_t; - /* * All messages (e.g. for generic receive) */ - typedef union kcom_msg_s { kcom_msg_hdr_t hdr; kcom_msg_version_t version; @@ -508,9 +509,9 @@ typedef union kcom_msg_s { kcom_msg_dma_info_t dma_info; kcom_msg_dbg_pkt_set_t dbg_pkt_set; kcom_msg_dbg_pkt_get_t dbg_pkt_get; + kcom_msg_wb_cleanup_t wb_cleanup; } kcom_msg_t; - /* * KCOM communication channel vectors * @@ -538,4 +539,4 @@ typedef struct kcom_chan_s { int (*recv)(void *handle, void *msg, unsigned int bufsz); } kcom_chan_t; -#endif /* _KCOM_H */ +#endif /* _KCOM_H */ diff --git a/platform/broadcom/saibcm-modules/include/sal/core/sync.h b/platform/broadcom/saibcm-modules/include/sal/core/sync.h index edac848b504b..75dd6ce68312 100644 --- a/platform/broadcom/saibcm-modules/include/sal/core/sync.h +++ b/platform/broadcom/saibcm-modules/include/sal/core/sync.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: sync.h,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sal/core/thread.h b/platform/broadcom/saibcm-modules/include/sal/core/thread.h index 1bccb1aaa3ab..b7ecb722489f 100644 --- a/platform/broadcom/saibcm-modules/include/sal/core/thread.h +++ b/platform/broadcom/saibcm-modules/include/sal/core/thread.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: thread.h,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sal/types.h b/platform/broadcom/saibcm-modules/include/sal/types.h index 29e6fc6522a0..b6b40f762939 100644 --- a/platform/broadcom/saibcm-modules/include/sal/types.h +++ b/platform/broadcom/saibcm-modules/include/sal/types.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: types.h,v 1.3 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/sdk_config.h b/platform/broadcom/saibcm-modules/include/sdk_config.h index 5a1bcaddfc40..9d781114bdf3 100644 --- a/platform/broadcom/saibcm-modules/include/sdk_config.h +++ b/platform/broadcom/saibcm-modules/include/sdk_config.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: sdk_config.h,v 1.5 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/soc/cmic.h b/platform/broadcom/saibcm-modules/include/soc/cmic.h index c6cfc25c7595..5bf6130237a2 100644 --- a/platform/broadcom/saibcm-modules/include/soc/cmic.h +++ b/platform/broadcom/saibcm-modules/include/soc/cmic.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: cmic.h,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/include/soc/devids.h b/platform/broadcom/saibcm-modules/include/soc/devids.h index 69fba7777c1a..c1b350f217a5 100644 --- a/platform/broadcom/saibcm-modules/include/soc/devids.h +++ b/platform/broadcom/saibcm-modules/include/soc/devids.h @@ -1,21 +1,20 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* - * Copyright: (c) 2017 Broadcom Corp. + * Copyright: (c) 2018 Broadcom. * All Rights Reserved. */ @@ -1237,6 +1236,9 @@ #define BCM56169_B0_REV_ID 0x11 #define BCM56169_B1_REV_ID 0x12 +#define BCM56980_DEVICE_ID 0xb980 +#define BCM56980_A0_REV_ID 1 + #define BCM56968_DEVICE_ID 0xb968 #define BCM56968_A0_REV_ID 1 #define BCM56968_B0_REV_ID 0x11 @@ -1276,90 +1278,95 @@ #define BCM56560_DEVICE_ID 0xb560 #define BCM56560_A0_REV_ID 1 #define BCM56560_B0_REV_ID 0x11 -#define BCM56560_B1_REV_ID 0x12 #define BCM56561_DEVICE_ID 0xb561 #define BCM56561_A0_REV_ID 1 #define BCM56561_B0_REV_ID 0x11 -#define BCM56561_B1_REV_ID 0x12 #define BCM56562_DEVICE_ID 0xb562 #define BCM56562_A0_REV_ID 1 #define BCM56562_B0_REV_ID 0x11 -#define BCM56562_B1_REV_ID 0x12 + +#define BCM56670_DEVICE_ID 0xb670 +#define BCM56670_A0_REV_ID 1 + +#define BCM56671_DEVICE_ID 0xb671 +#define BCM56671_A0_REV_ID 1 + +#define BCM56672_DEVICE_ID 0xb672 +#define BCM56672_A0_REV_ID 1 + +#define BCM56675_DEVICE_ID 0xb675 +#define BCM56675_A0_REV_ID 1 #define BCM56565_DEVICE_ID 0xb565 #define BCM56565_A0_REV_ID 1 #define BCM56565_B0_REV_ID 0x11 -#define BCM56565_B1_REV_ID 0x12 #define BCM56566_DEVICE_ID 0xb566 #define BCM56566_A0_REV_ID 1 #define BCM56566_B0_REV_ID 0x11 -#define BCM56566_B1_REV_ID 0x12 #define BCM56567_DEVICE_ID 0xb567 #define BCM56567_A0_REV_ID 1 #define BCM56567_B0_REV_ID 0x11 -#define BCM56567_B1_REV_ID 0x12 #define BCM56568_DEVICE_ID 0xb568 #define BCM56568_A0_REV_ID 1 #define BCM56568_B0_REV_ID 0x11 -#define BCM56568_B1_REV_ID 0x12 #define BCM56760_DEVICE_ID 0xb760 #define BCM56760_A0_REV_ID 1 -#define BCM56760_A1_REV_ID 2 #define BCM56760_B0_REV_ID 0x11 -#define BCM56760_B1_REV_ID 0x12 + +#define BCM56761_DEVICE_ID 0xb761 +#define BCM56761_A0_REV_ID 1 +#define BCM56761_B0_REV_ID 0x11 #define BCM56762_DEVICE_ID 0xb762 #define BCM56762_A0_REV_ID 1 #define BCM56762_B0_REV_ID 0x11 -#define BCM56762_B1_REV_ID 0x12 #define BCM56764_DEVICE_ID 0xb764 #define BCM56764_A0_REV_ID 1 #define BCM56764_B0_REV_ID 0x11 -#define BCM56764_B1_REV_ID 0x12 #define BCM56765_DEVICE_ID 0xb765 #define BCM56765_A0_REV_ID 1 #define BCM56765_B0_REV_ID 0x11 -#define BCM56765_B1_REV_ID 0x12 #define BCM56766_DEVICE_ID 0xb766 #define BCM56766_A0_REV_ID 1 #define BCM56766_B0_REV_ID 0x11 -#define BCM56766_B1_REV_ID 0x12 #define BCM56768_DEVICE_ID 0xb768 #define BCM56768_A0_REV_ID 1 #define BCM56768_B0_REV_ID 0x11 -#define BCM56768_B1_REV_ID 0x12 #define BCM56068_DEVICE_ID 0xb068 #define BCM56068_A0_REV_ID 1 #define BCM56068_B0_REV_ID 0x11 -#define BCM56068_B1_REV_ID 0x12 #define BCM56069_DEVICE_ID 0xb069 #define BCM56069_A0_REV_ID 1 #define BCM56069_B0_REV_ID 0x11 -#define BCM56069_B1_REV_ID 0x12 #define BCM56170_DEVICE_ID 0xb170 #define BCM56170_A0_REV_ID 1 +#define BCM56170_B0_REV_ID 0x11 #define BCM56172_DEVICE_ID 0xb172 #define BCM56172_A0_REV_ID 1 +#define BCM56172_B0_REV_ID 0x11 #define BCM56174_DEVICE_ID 0xb174 #define BCM56174_A0_REV_ID 1 +#define BCM56174_B0_REV_ID 0x11 #define BCM53570_DEVICE_ID 0x8570 #define BCM53570_A0_REV_ID 1 +#define BCM53570_B0_REV_ID 0x11 #define BCM53575_DEVICE_ID 0x8575 #define BCM53575_A0_REV_ID 1 +#define BCM53575_B0_REV_ID 0x11 #define BCM56965_DEVICE_ID 0xb965 @@ -1384,13 +1391,24 @@ #define BCM56974_DEVICE_ID 0xb974 #define BCM56974_A0_REV_ID 1 #define BCM56974_B0_REV_ID 0x11 - +#define BCM56975_DEVICE_ID 0xb975 +#define BCM56975_A0_REV_ID 1 +#define BCM56975_B0_REV_ID 0x11 #define BCM56870_DEVICE_ID 0xb870 #define BCM56870_A0_REV_ID 1 #define BCM56873_DEVICE_ID 0xb873 #define BCM56873_A0_REV_ID 1 +#define BCM53540_DEVICE_ID 0x8540 +#define BCM53540_A0_REV_ID 1 +#define BCM53547_DEVICE_ID 0x8547 +#define BCM53547_A0_REV_ID 1 +#define BCM53548_DEVICE_ID 0x8548 +#define BCM53548_A0_REV_ID 1 +#define BCM53549_DEVICE_ID 0x8549 +#define BCM53549_A0_REV_ID 1 + #define BCM5665_DEVICE_ID 0x5665 #define BCM5665_A0_REV_ID 1 #define BCM5665_B0_REV_ID 0x11 @@ -1695,8 +1713,27 @@ #define BCM88955_A1_REV_ID 0x0002 #define BCM88956_DEVICE_ID 0x8956 #define BCM88956_A1_REV_ID 0x0002 +#define DNXC_A0_REV_ID 0x0001 +#define DNXC_A1_REV_ID 0x0002 +#define DNXC_B0_REV_ID 0x0011 #define BCM88790_DEVICE_ID 0x8790 -#define BCM88790_A0_REV_ID 0x0001 +#define BCM88790_A0_REV_ID DNXC_A0_REV_ID +#define BCM88791_DEVICE_ID 0x8791 +#define BCM88792_DEVICE_ID 0x8792 +#define BCM88793_DEVICE_ID 0x8793 +#define BCM88794_DEVICE_ID 0x8794 +#define BCM88795_DEVICE_ID 0x8795 +#define BCM88796_DEVICE_ID 0x8796 +#define BCM88797_DEVICE_ID 0x8797 +#define BCM88798_DEVICE_ID 0x8798 +#define BCM88799_DEVICE_ID 0x8799 +#define BCM8879A_DEVICE_ID 0x879A +#define BCM8879B_DEVICE_ID 0x879B +#define BCM8879C_DEVICE_ID 0x879C +#define BCM8879D_DEVICE_ID 0x879D +#define BCM8879E_DEVICE_ID 0x879E +#define BCM8879F_DEVICE_ID 0x879F +#define BCM_DNXF_DEVID_MASK 0xFFF0 #define ARADPLUS_DEVICE_ID 0x8660 #define ARADPLUS_A0_REV_ID 0x0001 #define BCM88660_DEVICE_ID ARADPLUS_DEVICE_ID @@ -1865,6 +1902,7 @@ #define BCM88272_DEVICE_ID 0x8272 #define BCM88273_DEVICE_ID 0x8273 #define BCM88278_DEVICE_ID 0x8278 +#define BCM88279_DEVICE_ID 0x8279 #define FLAIR_DEVICE_ID 0xF000 #define FLAIR_A0_REV_ID 0x0001 @@ -1922,11 +1960,11 @@ #define BCM88654_DEVICE_ID 0x8654 #define BCM88654_B1_REV_ID ARAD_B1_REV_ID -#define BCM88772_DEVICE_ID 0x8772 -#define BCM88952_DEVICE_ID 0x8952 -#define BCM88772_A1_REV_ID 0x0002 -#define BCM88952_A0_REV_ID 0x0001 -#define BCM88952_A1_REV_ID 0x0002 +#define BCM88772_DEVICE_ID 0x8772 +#define BCM88952_DEVICE_ID 0x8952 +#define BCM88772_A1_REV_ID 0x0002 +#define BCM88952_A0_REV_ID 0x0001 +#define BCM88952_A1_REV_ID 0x0002 #define BCM88752_DEVICE_ID 0x8752 #define BCM88752_A0_REV_ID 0x0000 diff --git a/platform/broadcom/saibcm-modules/make/Make.config b/platform/broadcom/saibcm-modules/make/Make.config index d3f83c24c3f0..b8fa17bda119 100644 --- a/platform/broadcom/saibcm-modules/make/Make.config +++ b/platform/broadcom/saibcm-modules/make/Make.config @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.config,v 1.3 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. @@ -167,6 +166,8 @@ CFLAGS += ${INCFLAGS} CXXFLAGS += ${INCFLAGS} CPPFLAGS += ${INCFLAGS} +CFLAGS += -DSAI_FIXUP -DBCM_PORT_DEFAULT_DISABLE -DBCM_VLAN_NO_DEFAULT_ETHER -DBCM_VLAN_NO_DEFAULT_CPU -DBCM_WARM_BOOT_SUPPORT -DSAL_CONFIG_FILE_DISABLE -DSAL_THREAD_NAME_PRINT_DISABLE -UKCOM_FILTER_MAX -DKCOM_FILTER_MAX=256 -DALPM_ENABLE -DOPENNSL_PHY_ROUTINES -DTH2_CPU_POOL_SETUP -DINCLUDE_L3 -DSAI_ONLY -DPRINT_TO_SYSLOG -D_SHR_PBMP_WIDTH=256 -DINCLUDE_DIAG_SHELL -DSTATIC=static -DLOG_TEST -DLOG_SAI -D_GNU_SOURCE + # # Debug #ifdef control # diff --git a/platform/broadcom/saibcm-modules/make/Make.depend b/platform/broadcom/saibcm-modules/make/Make.depend index 3d8b8c59d938..de7099387666 100644 --- a/platform/broadcom/saibcm-modules/make/Make.depend +++ b/platform/broadcom/saibcm-modules/make/Make.depend @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.depend,v 1.14 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.kernlib b/platform/broadcom/saibcm-modules/make/Make.kernlib index 612b7e3479aa..6ec8a1c8df77 100644 --- a/platform/broadcom/saibcm-modules/make/Make.kernlib +++ b/platform/broadcom/saibcm-modules/make/Make.kernlib @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.kernlib,v 1.7 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.lib b/platform/broadcom/saibcm-modules/make/Make.lib index 992a24e6955c..d67325c5dd2f 100644 --- a/platform/broadcom/saibcm-modules/make/Make.lib +++ b/platform/broadcom/saibcm-modules/make/Make.lib @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.lib,v 1.14 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.linux b/platform/broadcom/saibcm-modules/make/Make.linux index 18a6547bc660..bd86ca351b6e 100644 --- a/platform/broadcom/saibcm-modules/make/Make.linux +++ b/platform/broadcom/saibcm-modules/make/Make.linux @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # # $Id: Make.linux,v 1.18 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/make/Make.local b/platform/broadcom/saibcm-modules/make/Make.local deleted file mode 100644 index be0603fad775..000000000000 --- a/platform/broadcom/saibcm-modules/make/Make.local +++ /dev/null @@ -1,2 +0,0 @@ -#Changing value of this Knet filter -CFGFLAGS += -UKCOM_FILTER_MAX -DKCOM_FILTER_MAX=256 diff --git a/platform/broadcom/saibcm-modules/make/Make.subdirs b/platform/broadcom/saibcm-modules/make/Make.subdirs index 69363da2ffb2..1033e296c0a3 100644 --- a/platform/broadcom/saibcm-modules/make/Make.subdirs +++ b/platform/broadcom/saibcm-modules/make/Make.subdirs @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.subdirs,v 1.8 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Make.tools b/platform/broadcom/saibcm-modules/make/Make.tools index c53d9d4276cc..8ed77727fef2 100644 --- a/platform/broadcom/saibcm-modules/make/Make.tools +++ b/platform/broadcom/saibcm-modules/make/Make.tools @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Make.tools,v 1.2 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-bmw-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-bmw-2_6 new file mode 100644 index 000000000000..6fa170fb75e6 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-bmw-2_6 @@ -0,0 +1,122 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-bmw-2_6,v 1.20 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# Look for custom tools +ifneq (,$(PPC_TOOLS_DIR)) +ifneq (,$(PPC_CROSS_COMPILE)) +override PATH := $(PPC_TOOLS_DIR):$(PATH) +override CROSS_COMPILE := $(PPC_CROSS_COMPILE) +endif +endif + +# Default tools +ifeq (,$(WRS_LINUX_VERSION)) +WRS_LINUX_VERSION=2.0 +endif + +# Default Linux Kernel directory +ifeq (,$(KERNDIR)) + +ifeq (1.4,$(WRS_LINUX_VERSION)) + +KERNDIR := /projects/ntsw-tools/linux/wrslinux_1.4/bcm98245cpci/build/linux-2.6.14-cgl + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE = powerpc-wrs-linux-gnu-603e-glibc_std- +endif + +WRLINUX_BASE=/tools/windriver/linux_ed/1.4/Linux +export WIND_LIC_PROXY = $(WRLINUX_BASE)/setup/x86-linux2/bin +override PATH := $(WRLINUX_BASE)/gnu/3.4.4-wrlinux-1.4/x86-linux2/bin:$(PATH) + +WRS_SYSROOT_PATH := $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/3.4.4/include +else + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE = powerpc-wrs-linux-gnu-ppc_603e-glibc_std- +endif + +KERNDIR:= /projects/ntsw-tools/linux/wrslinux_2.0/bmw/glibc_std/build/linux-2.6.21-standard + +WRLINUX_BASE=/tools/windriver/linux_ed/2.0_GA/Linux + +TOOLCHAIN_EXEC_PREFIX=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2 +TOOLCHAIN_BIN_DIR=$(TOOLCHAIN_EXEC_PREFIX) +WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin + +WRLINUX_GNU_PATH = $(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin + +override PATH := $(TOOLCHAIN_EXEC_PREFIX):$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/powerpc-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH) + +export TOOLCHAIN_EXEC_PREFIX TOOLCHAIN_BIN_DIR WIND_LIC_PROXY + +WRS_SYSROOT_PATH := $(WRLINUX_GNU_PATH)/../lib/gcc/powerpc-wrs-linux-gnu/4.1.2/include + +comma = , +basetarget = $(basename $(notdir $@)) +modname = $(basetarget) + +# Extra variables. +EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") +endif +endif +endif + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE := $(KERNDIR)/include +endif + +CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1 +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) +CFGFLAGS += -DBCM_PLATFORM_STRING=\"BMW_MPC8245/PPC603e\" + +ARCH = ppc +KBUILD_VERBOSE = 1 + +export ARCH KBUILD_VERBOSE + +ifeq (1.4,$(WRS_LINUX_VERSION)) +# From linux/arch/ppc/Makefile + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -fsigned-char -msoft-float -pipe -ffixed-r2 -Wno-uninitialized -mmultiple -mstring +endif + +else +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(WRS_SYSROOT_PATH) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -I$(KERNDIR)/arch/ppc -I$(KERNDIR)/arch/ppc/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -mstring -fomit-frame-pointer -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign +endif + +endif +endif + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel-2_6 +endif diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-gto b/platform/broadcom/saibcm-modules/make/Makefile.linux-gto index ee45fc26a595..cd5e8fbca195 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-gto +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-gto @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-gto-4_4,v 1.42 Broadcom SDK $ # $Copyright: (c) 2015 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6 index 0ca62fc01f51..4caa4902421f 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-gto-2_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-gto-2_6,v 1.42 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. @@ -255,7 +254,13 @@ CFLAGS += -DBCM_PLX9656_LOCAL_BUS -DBDE_LINUX_NON_INTERRUPTIBLE -DSHADOW_SVK endif ifeq (,$(KFLAGS)) -KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/version.h -include $(LINUX_INCLUDE)/generated/autoconf.h -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc/include -I$(KERNDIR)/include/asm-powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -funit-at-a-time -Wa,-me500 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign +#autoconf.h was moved in later kernels +LINUX_AUTOCONF = $(LINUX_INCLUDE)/generated/autoconf.h +ifeq (,$(shell ls $(LINUX_AUTOCONF) 2>/dev/null)) +LINUX_AUTOCONF = $(LINUX_INCLUDE)/linux/autoconf.h +endif + +KFLAGS := -D__KERNEL__ -m32 -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/version.h -include $(LINUX_AUTOCONF) -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc -I$(KERNDIR)/arch/powerpc/include -I$(KERNDIR)/include/asm-powerpc -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -msoft-float -pipe -ffixed-r2 -mmultiple -mno-altivec -funit-at-a-time -Wa,-me500 -fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign endif #Wind river Linux 3.0 needs addtional flags diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc index 272ad93ef842..7c0f9411f5e2 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-iproc Exp $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 index e8a17b184710..723fea6c73cf 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-iproc-3_14 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-iproc-3_6,v 1.1 Broadcom SDK $ # $Copyright: (c) 2007 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-jag-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-jag-2_6 new file mode 100644 index 000000000000..1e89cdab2434 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-jag-2_6 @@ -0,0 +1,166 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-jag-2_6,v 1.20 Broadcom SDK $ +# $Copyright: (c) 2007 Broadcom Corp. +# All Rights Reserved.$ + + +# User must select one platform from below.By default WR_LINUX is selected. . +ifeq (,$(BUILD_PLATFORM)) +#BUILD_PLATFORM=ELDK +BUILD_PLATFORM=WR_LINUX +endif + + +# Specify the KERNEL VERSION you want to use for building SDK. +ifeq (ELDK,$(BUILD_PLATFORM)) +ifeq (,$(KERN_VER)) +KERN_VER=2.6.21.7 +endif +endif + +# Specify the Windriver Linux version here.For example '2.0' as shown below. +ifeq (WR_LINUX,$(BUILD_PLATFORM)) +ifeq (,$(WRS_LINUX_VERSION)) +WRS_LINUX_VERSION=2.0 +endif +endif + +ifeq (WR_LINUX,$(BUILD_PLATFORM)) +ifeq (1.4,$(WRS_LINUX_VERSION)) + +KERNDIR := /projects/ntsw-tools/linux/wrslinux_1.4/broadcom_bcm95836cpci_be/build/linux-2.6.14-small + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu- +endif + +export WIND_LIC_PROXY = /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/setup/x86-linux2/bin + +override PATH := /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/gnu/3.4.4-wrlinux-1.4/x86-linux2/bin:$(PATH) +endif + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +#CROSS_COMPILE = mips-wrs-linux-gnu- + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu-mips_softfp-glibc_std- +endif + +KERNDIR:= /projects/ntsw-tools/linux/wrslinux_2.0/jag/glibc_std/build/linux-2.6.21-standard + +endif + +WRLINUX_BASE=/tools/windriver/linux_ed/2.0_GA/Linux + +TOOLCHAIN_BIN_DIR=$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin +WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin + +WRLINUX_GNU_PATH=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin + +override PATH:=$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH) + +WRS_SYSROOT_PATH := $(WRLINUX_GNU_PATH)/../lib/gcc/mips-wrs-linux-gnu/4.1.2/include + +export TOOLCHAIN_BIN_DIR WIND_LIC_PROXY +endif + +ifeq (ELDK,$(BUILD_PLATFORM)) +ifeq (2.6.21.7, $(KERN_VER)) + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips_4KC- +endif + +override PATH := /tools/eldk/4.1/usr/bin:$(PATH) +KERNDIR ?= /projects/ntsw-tools/linux/eldk/jag-ntswics-eldk/linux-2.6.21.7 +endif +endif + + + +comma = , +basetarget = $(basename $(notdir $@)) +modname = $(basetarget) + +# Extra variables. +EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE := $(KERNDIR)/include +endif + +CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=1 -DSYS_BE_OTHER=0 +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) +CFGFLAGS += -DBCM_PLATFORM_STRING=\"JAG_BCM4704\" + +ARCH = mips +KBUILD_VERBOSE = 1 + +export ARCH KBUILD_VERBOSE + +ifeq (ELDK,$(BUILD_PLATFORM)) +KFLAG_INCLD = /tools/eldk/4.1/usr/lib/gcc/mips-linux/4.0.0/include/ +endif + +ifeq (1.4,$(WRS_LINUX_VERSION)) +# From linux/arch/mips/Makefile + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -Wall -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -g -G 0 -mno-abicalls -fno-pic -pipe -march=mips32 -Wa,-mips32 -Wa,--trap -funit-at-a-time -mlong-calls -Wundef -finline-limit=100000 -mabi=32 +endif + +#-Wdeclaration-after-statement -Wstrict-prototypes +else + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -nostdinc -isystem $(WRS_SYSROOT_PATH) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -I$(KERNDIR)/arch/mips -I$(KERNDIR)/arch/mips -I$(KERNDIR)/arch/mips/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap -Iinclude/asm-mips/mach-bcm947xx -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -mlong-calls +endif + +endif +endif + +ifeq (ELDK,$(BUILD_PLATFORM)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -I$(KERNDIR)/arch/mips -I$(KERNDIR)/arch/mips -I$(KERNDIR)/arch/mips/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap -Iinclude/asm-mips/mach-bcm947xx -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -g -Wdeclaration-after-statement -mlong-calls +endif + +endif + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel-2_6 +endif + +ifneq (,$(findstring TCL,$(FEATURE_LIST))) +LINK_STATIC=0 +export LINK_STATIC +endif + + + + diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel index 2b8c36d6d4b0..7cbf8451f91e 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-kernel,v 1.27 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. 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 52660bc64f18..559f2ae5e5e5 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-2_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. 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 50f32816c686..0d54c4474fc8 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-3_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-kernel-3_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. 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 d662b04334e7..0e8e22e1b32d 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kernel-4_4 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-kernel-2_6,v 1.40 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule index a49919c615b2..3ad11d169c64 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-kmodule @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-kmodule-3_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2006 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx-2_6 new file mode 100644 index 000000000000..785619f31fd4 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx-2_6 @@ -0,0 +1,56 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-nsx-2_6,v 1.9 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# Look for custom tools +ifneq (,$(MIPS_TOOLS_DIR)) +override PATH := $(MIPS_TOOLS_DIR):$(PATH) +endif +ifneq (,$(MIPS_CROSS_COMPILE)) +override CROSS_COMPILE := $(MIPS_CROSS_COMPILE) +endif + +# Default tools +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips2_fp_be- +override PATH := $(PATH):/projects/ntsw-tools/linux/mvista/mvista-4.0/pro/devkit/mips/mips2_fp_be/bin +endif + +# Default Linux Kernel directory +ifeq (,$(KERNDIR)) +KERNDIR := /projects/ntsw-tools/linux/mvista/mvista-4.0-nsx/linux-2.6.10_dev +endif +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE := $(KERNDIR)/include +endif + +CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1 +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) +CFGFLAGS += -DBCM_PLATFORM_STRING=\"NSX_BCM1125\" + +# From linux/arch/mips/Makefile + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -O2 -fomit-frame-pointer -fno-strict-aliasing -G 0 -mno-abicalls -fno-pic -mips64 -mtune=sb1 -Wa,--trap -pipe -mlong-calls +endif + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel-2_6 +endif diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx64 b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx64 new file mode 100644 index 000000000000..c4f71995be52 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx64 @@ -0,0 +1,54 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-nsx64,v 1.9 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# Look for custom tools +ifneq (,$(MIPS_TOOLS_DIR)) +override PATH := $(MIPS_TOOLS_DIR):$(PATH) +endif +ifneq (,$(MIPS_CROSS_COMPILE)) +override CROSS_COMPILE := $(MIPS_CROSS_COMPILE) +endif + +# Default tools +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips64_fp_be- +override PATH := $(PATH):/projects/ntsw-tools/linux/mvista/mips64_be_tools-3.1/bin +endif + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE = /projects/ntsw-tools/linux/headers/mvl-3.1-nsx64/include +endif + +CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1 +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) -Wa,-xgot -mips64 -mabi=64 -fno-strict-aliasing -DPTRS_ARE_64BITS -DLONGS_ARE_64BITS +CFGFLAGS += -DBCM_PLATFORM_STRING=\"NSX_BCM1125\" + +# From linux/arch/mips/Makefile + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -O2 -fomit-frame-pointer -fno-strict-aliasing -G 0 -mno-abicalls -fno-pic -mips64 -mabi=64 -mtune=sb1 -Wa,--trap -pipe -mlong-calls +endif + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel +endif + +MODULE_LDFLAGS += -m elf64btsmip diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx_wrl-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx_wrl-2_6 new file mode 100644 index 000000000000..7b549038fd24 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-nsx_wrl-2_6 @@ -0,0 +1,127 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-nsx_wrl-2_6,v 1.15 Broadcom SDK $ +# $Copyright: (c) 2007 Broadcom Corp. +# All Rights Reserved.$ + +ifeq (,$(WRS_LINUX_VERSION)) +WRS_LINUX_VERSION=2.0 +endif + +# Look for custom tools +ifneq (,$(MIPS_TOOLS_DIR)) +ifneq (,$(MIPS_CROSS_COMPILE)) +override PATH := $(MIPS_TOOLS_DIR):$(PATH) +override CROSS_COMPILE := $(MIPS_CROSS_COMPILE) +endif +endif + +# Default Linux Kernel directory +ifeq (,$(KERNDIR)) + +ifeq (1.4,$(WRS_LINUX_VERSION)) + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu- +endif + +KERNDIR := /projects/ntsw-tools/linux/wrslinux_1.4/broadcom_bcm91125cpci_32_be_glibc_std/build/linux-2.6.14-cgl + +export WIND_LIC_PROXY = /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/setup/x86-linux2/bin +override PATH := /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/gnu/3.4.4-wrlinux-1.4/x86-linux2/bin:$(PATH) +else + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu-mips-glibc_std- +endif + +KERNDIR:= /projects/ntsw-tools/linux/wrslinux_2.0/nsx/glibc_std/build/linux-2.6.21-standard + +WRLINUX_BASE=/tools/windriver/linux_ed/2.0_GA/Linux + +TOOLCHAIN_BIN_DIR=$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin +WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin + +WRLINUX_GNU_PATH=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin +override PATH:=$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH) + +WRS_SYSROOT_PATH := $(WRLINUX_GNU_PATH)/../lib/gcc/mips-wrs-linux-gnu/4.1.2/include + +export TOOLCHAIN_BIN_DIR WIND_LIC_PROXY + +comma = , +basetarget = $(basename $(notdir $@)) +modname = $(basetarget) + +# Extra variables. +EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + +endif +endif +endif + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE := $(KERNDIR)/include +endif + +CFGFLAGS += -DSYS_BE_PIO=1 -DSYS_BE_PACKET=0 -DSYS_BE_OTHER=1 +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) +CFGFLAGS += -DBCM_PLATFORM_STRING=\"NSX_BCM1125\" + +ARCH = mips +KBUILD_VERBOSE = 1 + +export ARCH KBUILD_VERBOSE + +ifeq (1.4,$(WRS_LINUX_VERSION)) +# From Linux Kbuild output + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -Iinclude -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -g -G 0 -mno-abicalls -fno-pic -pipe -finline-limit=100000 -mabi=32 -march=sb1 -Wa,-32 -Wa,-march=sb1 -Wa,-mips64 -Wa,--trap -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL -mlong-calls +#-Wdeclaration-after-statement +endif + +else + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -nostdinc -isystem $(WRS_SYSROOT_PATH) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=sb1 -Wa,--trap -Iinclude/asm-mips/mach-sibyte -Iinclude/asm-mips/mach-generic -DSIBYTE_HDR_FEATURES=SIBYTE_HDR_FMASK_1250_112x_ALL -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -mlong-calls +endif + +endif +endif + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel-2_6 +endif + + +ifneq (,$(findstring TCL,$(FEATURE_LIST))) +LINK_STATIC=0 +export LINK_STATIC +endif + + diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor b/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor new file mode 100644 index 000000000000..80c51e782bea --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor @@ -0,0 +1,53 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-raptor,v 1.6 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# Look for custom tools +ifneq (,$(MIPS_TOOLS_DIR)) +override PATH := $(MIPS_TOOLS_DIR):$(PATH) +endif +ifneq (,$(MIPS_CROSS_COMPILE)) +override CROSS_COMPILE := $(MIPS_CROSS_COMPILE) +endif + +# Default tools +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips_fp_be- +override PATH := $(PATH):/projects/ntsw-tools/linux/mvista/mvista-3.1/pro/devkit/mips/fp_be/bin +endif + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE = /projects/ntsw-tools/linux/headers/mvl-3.1-raptor/include +endif + +CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=1 -DSYS_BE_OTHER=0 -DBCM_ICS +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) +CFGFLAGS += -DBCM_PLATFORM_STRING=\"Raptor_BCM56218\" + + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel +endif + +# From linux/arch/mips/Makefile + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic -pipe -m$(gcc-tune-flag)=r4600 -mips2 -Wa,--trap -mlong-calls +endif diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor-2_6 new file mode 100644 index 000000000000..0bebdf9564c6 --- /dev/null +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-raptor-2_6 @@ -0,0 +1,172 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# $Id: Makefile.linux-raptor-2_6,v 1.21 Broadcom SDK $ +# $Copyright: (c) 2007 Broadcom Corp. +# All Rights Reserved.$ + + +# User must select one platform from below.By default WR_LINUX is selected. . +ifeq (,$(BUILD_PLATFORM)) +#BUILD_PLATFORM=ELDK +BUILD_PLATFORM=WR_LINUX +endif + + +# Specify the KERNEL VERSION you want to use for building SDK. +ifeq (ELDK,$(BUILD_PLATFORM)) +ifeq (,$(KERN_VER)) +KERN_VER=2.6.21.7 +endif +endif + +# Specify the Windriver Linux version here.For example '2.0' as shown below. +ifeq (WR_LINUX,$(BUILD_PLATFORM)) +ifeq (,$(WRS_LINUX_VERSION)) +WRS_LINUX_VERSION=2.0 +endif +endif + + +# Default Linux Kernel directory +ifeq (WR_LINUX,$(BUILD_PLATFORM)) +ifeq (1.4,$(WRS_LINUX_VERSION)) + +KERNDIR ?= /projects/ntsw-tools/linux/wrslinux_1.4/broadcom_bcm95621x_be/build/linux-2.6.14-small + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu- +endif + +export WIND_LIC_PROXY = /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/setup/x86-linux2/bin + +override PATH := /projects/ntsw-tools/wrs/wrs_linux/GPP_LE_1.4_PPR/gnu/3.4.4-wrlinux-1.4/x86-linux2/bin:$(PATH) +endif + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips-wrs-linux-gnu-mips_softfp-glibc_std- +endif + +KERNDIR ?= /projects/ntsw-tools/linux/wrslinux_2.0/ntswics/glibc_std/build/linux-2.6.21-standard +override PATH:=$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH) + +endif + +WRLINUX_BASE=/tools/windriver/linux_ed/2.0_GA/Linux + +TOOLCHAIN_BIN_DIR=$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin +WIND_LIC_PROXY=$(WRLINUX_BASE)/setup/x86-linux2/bin + +WRLINUX_GNU_PATH=$(WRLINUX_BASE)/gnu/4.1-wrlinux-2.0/x86-linux2/bin + +override PATH:=$(KERNDIR)/../../host-cross/bin:$(KERNDIR)/../../host-cross/mips-wrs-linux-gnu/bin:$(WRLINUX_GNU_PATH):$(PATH) + +WRS_SYSROOT_PATH := $(WRLINUX_GNU_PATH)/../lib/gcc/mips-wrs-linux-gnu/4.1.2/include + +export TOOLCHAIN_BIN_DIR WIND_LIC_PROXY + +endif + +ifeq (ELDK,$(BUILD_PLATFORM)) +ifeq (2.6.21.7, $(KERN_VER)) +ifeq (,$(CROSS_COMPILE)) +CROSS_COMPILE := mips_4KC- +endif +override PATH := /tools/eldk/4.1/usr/bin:$(PATH) +KERNDIR ?= /projects/ntsw-tools/linux/eldk/raptor_eldk/linux-2.6.21.7 +endif +endif + + + +comma = , +basetarget = $(basename $(notdir $@)) +modname = $(basetarget) + +# Extra variables. +EXTRA_CFLAGS = -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) + +name-fix = $(subst $(comma),_,$(subst -,_,$1)) +basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" +modname_flags = $(if $(filter 1,$(words $(modname))),\ + -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") + +# Default Linux include directory +ifeq (,$(LINUX_INCLUDE)) +LINUX_INCLUDE := $(KERNDIR)/include +endif + +CFGFLAGS += -DSYS_BE_PIO=0 -DSYS_BE_PACKET=1 -DSYS_BE_OTHER=0 -DBCM_ICS +ENDIAN = BE_HOST=1 +CFGFLAGS += -D$(ENDIAN) -DRAPTOR +CFGFLAGS += -DBCM_PLATFORM_STRING=\"Raptor_BCM56218\" + + +ARCH = mips +KBUILD_VERBOSE = 1 + +export ARCH KBUILD_VERBOSE + + +ifeq (ELDK,$(BUILD_PLATFORM)) +KFLAG_INCLD = /tools/eldk/4.1/usr/lib/gcc/mips-linux/4.0.0/include +endif + + +# From linux/arch/mips/Makefile +ifeq (WR_LINUX,$(BUILD_PLATFORM)) +ifeq (1.4,$(WRS_LINUX_VERSION)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -Wall -Wno-trigraphs -fno-strict-aliasing -fno-common -ffreestanding -O2 -fomit-frame-pointer -g -G 0 -mno-abicalls -fno-pic -pipe -march=mips32 -Wa,-mips32 -Wa,--trap -funit-at-a-time -mlong-calls -Wundef -finline-limit=100000 -mabi=32 +endif + +endif + +ifeq (2.0,$(WRS_LINUX_VERSION)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -nostdinc -isystem $(WRS_SYSROOT_PATH) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -I$(KERNDIR)/arch/mips/mach-bcm56218 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap -Iinclude/asm-mips/mach-bcm56218 -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -g -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -mlong-calls +endif + +endif +endif + +ifeq (ELDK,$(BUILD_PLATFORM)) + +ifeq (,$(KFLAGS)) +KFLAGS := -D__KERNEL__ -nostdinc -isystem $(KFLAG_INCLD) -I$(LINUX_INCLUDE) -include $(LINUX_INCLUDE)/linux/autoconf.h -I$(KERNDIR)/arch/mips/mach-bcm56218 -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -mabi=32 -G 0 -mno-abicalls -fno-pic -pipe -msoft-float -ffreestanding -march=mips32 -Wa,-mips32 -Wa,--trap -Iinclude/asm-mips/mach-bcm56218 -Iinclude/asm-mips/mach-generic -fomit-frame-pointer -g -Wdeclaration-after-statement -mlong-calls +endif + + +endif + + + +ifneq ($(targetplat),user) +include ${SDK}/make/Makefile.linux-kernel-2_6 +endif + +ifneq (,$(findstring TCL,$(FEATURE_LIST))) +LINK_STATIC=0 +export LINK_STATIC +endif + + + + + diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 index 29fb4cddd652..07af2afcc93b 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-common-2_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-x86-common-2_6,v 1.13 Broadcom SDK $ # $Copyright: (c) 2005 Broadcom Corp. @@ -23,7 +22,7 @@ ENDIAN = LE_HOST=1 CFGFLAGS += -D$(ENDIAN) CFGFLAGS += -DBCM_PLATFORM_STRING=\"X86\" ifeq (,$(findstring -DSAL_BDE_DMA_MEM_DEFAULT,$(CFGFLAGS))) -CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=16 +CFGFLAGS += -DSAL_BDE_DMA_MEM_DEFAULT=32 endif # Extra variables. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 index 5e01f2843bae..ab342c12d210 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-generic-common-2_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-x86-generic-common-2_6,v 1.2 Broadcom SDK $ # $Copyright: (c) 2008 Broadcom Corp. diff --git a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 index 2c0242f9841f..bb0bbea536a3 100644 --- a/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 +++ b/platform/broadcom/saibcm-modules/make/Makefile.linux-x86-smp_generic_64-2_6 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # $Id: Makefile.linux-x86-smp_generic_64-2_6,v 1.5 Broadcom SDK $ # $Copyright: (c) 2008 Broadcom Corp. @@ -29,17 +28,19 @@ ifeq (,$(KFLAGS)) KFLAGS := -nostdinc -isystem $(SYSINC) -I$(KERNDIR)/include -I$(KERNDIR)/arch/x86/include -include $(AUTOCONF) -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -fno-stack-protector -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign endif -KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/x86/include/generated -I$(KERNDIR)/arch/x86/include/uapi -I$(KERNDIR)/arch/x86/include/generated/uapi - -ifeq ($(LINUX_MAKE_SHARED_LIB),1) +ifeq ($(LINUX_MAKE_SHARED_LIB), 1) KFLAGS += -fPIC -mcmodel=small else -KFLAGS += -mcmodel=kernel -fno-pie +KFLAGS += -fno-pie -mcmodel=kernel endif +LINUX_UAPI = $(LINUX_INCLUDE)/uapi +KFLAGS += -I$(LINUX_INCLUDE)/uapi -I$(LINUX_INCLUDE)/generated/uapi -I$(KERNDIR)/arch/x86/include/generated -I$(KERNDIR)/arch/x86/include/uapi -I$(KERNDIR)/arch/x86/include/generated/uapi + ifeq (1,$(DEBIAN_LINUX_HEADER)) KERNDIR_COMMON := $(subst amd64,common,$(KERNDIR)) KFLAGS += -I$(KERNDIR_COMMON)/include -I$(KERNDIR_COMMON)/include/uapi -I$(KERNDIR_COMMON)/arch/x86/include -I$(KERNDIR_COMMON)/arch/x86/include/uapi endif include ${SDK}/make/Makefile.linux-x86-common-2_6 + 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 e0c23f73050a..927201bc1fd8 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /*********************************************************************** * @@ -198,6 +197,11 @@ extern void *lkbde_get_dma_dev(int d); */ extern void *lkbde_get_hw_dev(int d); +/* + * Backdoor to retrieve number of switch devices probed. + */ +extern int lkbde_get_num_devices(int type); + /* * Retrive the device state from Kernel BDE. * Used for KNET and User BDE for pci hot swap case. @@ -230,6 +234,12 @@ extern int lkbde_cpu_pci_register(int d); * a secondary device driver. */ #define LKBDE_ISR2_DEV 0x8000 +/* + * This flag should be OR'ed onto the device number when calling + * irq_mask_set functions from a secondary device driver if the + * mask register is iProc register. + */ +#define LKBDE_IPROC_REG 0x4000 #if defined(BCM_PETRA_SUPPORT) || defined(BCM_DFE_SUPPORT) #include diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h index f2621a982cc1..bfbbceb2d8e7 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/linux_dma.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /*********************************************************************** * @@ -59,7 +58,7 @@ #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) #endif -extern void _dma_init(int robo_switch); +extern void _dma_init(int robo_switch, int dev_index); extern int _dma_cleanup(void); extern void _dma_pprint(void); extern uint32_t *_salloc(int d, int size, const char *name); diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h b/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h index 001743d7192a..be4d436f8da9 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/include/mpool.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: mpool.h,v 1.2 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile index 0d126c9a2373..3d504a5665fa 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.18 Broadcom SDK $ 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 105d3d9bd940..e26d35332cc8 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: linux-kernel-bde.c,v 1.414 Broadcom SDK $ @@ -482,7 +481,7 @@ robo_spi_write(void *cookie, uint16_t reg, uint8_t *buf, int len); /* PLX PCI-E Switch */ #define PLX_PEX8608_DEV_ID 0x8608 #define PLX_PEX8617_DEV_ID 0x8617 -#define PLX_PEX86XX_DEV_CTRL_REG 0x70 +#define PLX_PEX86XX_DEV_CTRL_REG 0x70 /* Broadcom BCM58525 */ #define BCM58525_PCI_VENDOR_ID 0x14E4 @@ -541,6 +540,40 @@ _parse_eb_args(char *str, char * format, ...) return 0; } +static void +_bde_add_device(void) +{ + /* + * In order to be backward compatible with the user mode BDE + * (specifically the interrupt IOCTLs) and the CM, switch devices + * *must* come first. If this is not the case (due to the probing + * order), we let the non-switch device(s) drop down to the end of + * the device array. + */ + if (_switch_ndevices > 0) { + bde_ctrl_t tmp_dev; + int i, s = 0; + + while (s < _switch_ndevices) { + if (_devices[s].dev_type & BDE_SWITCH_DEV_TYPE) { + s++; + continue; + } + tmp_dev = _devices[s]; + for (i = s; i < _ndevices - 1; i++) { + _devices[i] = _devices[i+1]; + } + _devices[i] = tmp_dev; + } + } + + /* Initialize device locks and dma */ + if (_ndevices > 0) { + spin_lock_init(&_devices[_ndevices-1].lock); + _dma_init(robo_switch, _ndevices-1); + } +} + static int _eb_device_create(resource_size_t paddr, int irq, int rd_hw, int wr_hw) { @@ -576,6 +609,8 @@ _eb_device_create(resource_size_t paddr, int irq, int rd_hw, int wr_hw) ctrl->isr = NULL; ctrl->isr_data = NULL; + _bde_add_device(); + gprintk("Created EB device at BA=%x IRQ=%d RD16=%d WR16=%d device=0x%x\n", (unsigned int)paddr, irq, rd_hw, wr_hw, ctrl->bde_dev.device); @@ -628,6 +663,10 @@ sand_device_create(void) ctrl->dev_type |= BDE_PCI_DEV_TYPE | BDE_SWITCH_DEV_TYPE; } +#ifndef __DUNE_LINUX_BCM_CPU_PCIE__ + _bde_add_device(); +#endif + return 0; } #endif @@ -721,7 +760,7 @@ iproc_cmicd_probe(struct platform_device *pldev) #endif { /* Assign locally if not available from device node */ - iproc_cmicd_get_irqres(ctrl->bde_dev, &pldev->resource[0]); + iproc_cmicd_get_irqres(ctrl->bde_dev, &pldev->resource[0]); } irqres = iproc_platform_get_resource(pldev, IORESOURCE_IRQ, 0); @@ -735,6 +774,7 @@ iproc_cmicd_probe(struct platform_device *pldev) #endif /* Let's boogie */ + _bde_add_device(); return 0; } @@ -992,6 +1032,7 @@ _ics_bde_create(void) ctrl->isr = NULL; ctrl->isr_data = NULL; + _bde_add_device(); printk("Created ICS device ..%x\n", ctrl->bde_dev.base_address); } @@ -1007,7 +1048,7 @@ extern struct pci_bus *pci_find_bus(int domain, int busnr); * Populated from the include/soc/devids.h file. */ -static struct pci_device_id _id_table[] = { +static const struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM5675_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM5676_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56218X_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1327,6 +1368,7 @@ static struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56971_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56972_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56974_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56975_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56168_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56169_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56560_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1335,8 +1377,13 @@ static struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56565_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56566_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56567_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56670_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56671_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56672_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56675_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56568_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56760_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56761_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56762_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56764_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56765_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1419,6 +1466,7 @@ static struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM88272_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88273_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM88278_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88279_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM8206_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, @@ -1471,6 +1519,20 @@ static struct pci_device_id _id_table[] = { #endif #ifdef BCM_DNXF_SUPPORT { BROADCOM_VENDOR_ID, BCM88790_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88791_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88792_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88793_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88794_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88795_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88796_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88797_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88798_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM88799_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8879A_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM8879B_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { 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 }, #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 }, @@ -1484,10 +1546,17 @@ static struct pci_device_id _id_table[] = { { BROADCOM_VENDOR_ID, BCM56832_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56836_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56870_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM56980_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { BROADCOM_VENDOR_ID, BCM56873_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM53540_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM53547_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM53548_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, + { BROADCOM_VENDOR_ID, BCM53549_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID }, { 0, 0, 0, 0 } };; +MODULE_DEVICE_TABLE(pci, _id_table); + #define pci_bus_b(n) list_entry(n, struct pci_bus, node) #define pci_dev_b(n) list_entry(n, struct pci_dev, bus_list) #define MAX_RC_NUM 4 @@ -2403,18 +2472,15 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) #endif /* BCM_DFE_SUPPORT */ #if defined(BCM_DNXF_SUPPORT) - switch (dev->device) { - case BCM88790_DEVICE_ID: - + /*All Ramon devices from 0x8790 to 0x879F*/ + if ((dev->device & BCM_DNXF_DEVID_MASK) == BCM88790_DEVICE_ID) { /* * For DMA transactions - set Max_Payload_Size and * Max_Read_Request_Size to 128 bytes. */ pci_write_config_byte(dev, 0xb5, 0x0c); pci_write_config_byte(dev, 0xb4, 0x0); - break; - default: - break; + } #endif @@ -2539,24 +2605,6 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) /* Save shared BDE HAL in device structure */ memcpy(&ctrl->shbde, shbde, sizeof(ctrl->shbde)); -#if defined(VENDOR_BROADCOM) -#if defined(BCM_PLX9656_LOCAL_BUS) && defined(SHADOW_SVK) - if (num_plx) { - sal_vaddr_t base_address; - uint32 intr_enable; - - paddr = pci_resource_start(dev, 0); - bar_len = pci_resource_len(dev, 0); - base_address = (sal_vaddr_t)IOREMAP(paddr, bar_len); - - intr_enable = readl((uint32 *)(base_address + 0x68)); - gprintk("PLX Interrupt ENABLE: %x\n", intr_enable); - intr_enable |= 0x00080000; - writel(intr_enable, (uint32 *)(base_address + 0x68)); - gprintk("PLX Interrupt ENABLE: %x\n", intr_enable); - } -#endif -#endif /* * Since the GMAC driver of Robo chips needs access to the @@ -2604,9 +2652,12 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) /* Check if we need 256 KB memory window (default is 64 KB) */ bar_len = pci_resource_len(dev, baroff); - if ((bar_len == 0x40000) || (bar_len == 0x800000)) { + if (bar_len == 0x40000) { ctrl->dev_type |= BDE_256K_REG_SPACE; if (debug >= 1) gprintk("PCI resource len 256K\n"); + } else if (bar_len == 0x800000) { + ctrl->dev_type |= BDE_256K_REG_SPACE | BDE_8MB_REG_SPACE; + if (debug >= 1) gprintk("PCI resource len 8MB\n"); } #if defined (BCM_ROBO_SUPPORT) && !defined(ALTA_ROBO_SPI) @@ -2620,6 +2671,10 @@ _pci_probe(struct pci_dev *dev, const struct pci_device_id *ent) ctrl->dma_dev = &dev->dev; #endif + if (!rescan) { + _bde_add_device(); + } + if (debug >= 2) { gprintk("_pci_probe: configured dev:0x%x rev:0x%x with base_addresses: 0x%lx 0x%lx\n", (unsigned)ctrl->bde_dev.device, (unsigned)ctrl->bde_dev.rev, @@ -2684,17 +2739,17 @@ _pci_remove(struct pci_dev* dev) else #endif { - free_irq(ctrl->iLine, ctrl); + free_irq(ctrl->iLine, ctrl); } } #ifdef CONFIG_PCI_MSI _msi_disconnect(ctrl); #endif - ctrl->isr = NULL; - ctrl->isr_data = NULL; - ctrl->isr2 = NULL; - ctrl->isr2_data = NULL; -} + ctrl->isr = NULL; + ctrl->isr_data = NULL; + ctrl->isr2 = NULL; + ctrl->isr2_data = NULL; + } static struct pci_driver _device_driver = { probe: _pci_probe, @@ -2959,6 +3014,7 @@ probe_robo_switch_iproc_spi(void) ctrl->isr = NULL; ctrl->isr_data = NULL; robo_switch++; + _bde_add_device(); } @@ -3172,6 +3228,7 @@ probe_robo_switch(void) #if defined(KEYSTONE) spi_freq = _spi_id_table[match_idx].spifreq; #endif + _bde_add_device(); } #if defined(KEYSTONE) @@ -3217,6 +3274,8 @@ map_local_bus(uint64_t addr, uint32_t size) ctrl->bde_dev.base_address = (sal_vaddr_t)IOREMAP(addr, size); ctrl->phys_address = addr; + _bde_add_device(); + return(ctrl); } @@ -3368,6 +3427,8 @@ map_local_bus2(bde_ctrl_t *plx_ctrl, uint32_t dev_base, uint32_t size) ctrl->bde_dev.device = dev_rev_id >> 16; ctrl->bde_dev.rev = (dev_rev_id & 0xFF); + _bde_add_device(); + switch (ctrl->bde_dev.device) { case BCM88130_DEVICE_ID: case BME3200_DEVICE_ID: @@ -3590,8 +3651,8 @@ _init(void) #endif { /* Register platform device if no device node in dtb */ - iproc_platform_device_register(&iproc_cmicd_pdev); - } + iproc_platform_device_register(&iproc_cmicd_pdev); + } } #endif /* IPROC_CMICD */ @@ -3629,14 +3690,14 @@ _init(void) } #else if (use_msi > PCI_USE_INT_INTX) { - /* Warn if invalid configuration */ - gprintk("MSI interrupts not supported by kernel\n"); - } + /* Warn if invalid configuration */ + gprintk("MSI interrupts not supported by kernel\n"); + } use_msi = PCI_USE_INT_INTX; #endif /* CONFIG_PCI_MSI */ if (unlikely(debug >= 1)) - gprintk("%s(%d):use_mse = %d\n", __func__, __LINE__, use_msi); + gprintk("%s(%d):use_msi = %d\n", __func__, __LINE__, use_msi); if (spi_devid) { _spi_device_setup(); } else { @@ -3689,41 +3750,6 @@ _init(void) } } - _dma_init(robo_switch); - - /* - * In order to be backward compatible with the user mode BDE - * (specifically the interrupt IOCTLs) and the CM, switch devices - * *must* come first. If this is not the case (due to the probing - * order), we let the non-switch device(s) drop down to the end of - * the device array. - */ - if (_switch_ndevices > 0) { - bde_ctrl_t tmp_dev; - int i, s = 0; - - while (s < _switch_ndevices) { - if (_devices[s].dev_type & BDE_SWITCH_DEV_TYPE) { - s++; - continue; - } - tmp_dev = _devices[s]; - for (i = s; i < _ndevices - 1; i++) { - _devices[i] = _devices[i+1]; - } - _devices[i] = tmp_dev; - } - } - - /* Initialize device locks */ - if (_ndevices > 0) { - int i; - - for (i = 0; i < _ndevices; i++) { - spin_lock_init(&_devices[i].lock); - } - } - return 0; } @@ -4246,8 +4272,7 @@ _interrupt_connect(int d, goto err_disable_msi; if (unlikely(debug >= 1)) - gprintk("%s(%d):device# = %d, \ - irq_flags = %lu, irq = %d\n", + gprintk("%s(%d):device# = %d, irq_flags = %lu, irq = %d\n", __func__, __LINE__, d, irq_flags, ctrl->pci_device ? ctrl->pci_device->irq : ctrl->iLine); } @@ -4261,13 +4286,13 @@ _interrupt_connect(int d, msi_exit: #endif gprintk("could not request IRQ\n"); - ctrl->isr = NULL; - ctrl->isr_data = NULL; - ctrl->isr2 = NULL; - ctrl->isr2_data = NULL; + ctrl->isr = NULL; + ctrl->isr_data = NULL; + ctrl->isr2 = NULL; + ctrl->isr2_data = NULL; - return -1; -} + return -1; + } static int _interrupt_disconnect(int d) @@ -4334,7 +4359,7 @@ _interrupt_disconnect(int d) else #endif { - free_irq(ctrl->iLine, ctrl); + free_irq(ctrl->iLine, ctrl); } #ifdef CONFIG_PCI_MSI if (ctrl->use_msi >= PCI_USE_INT_MSI) { @@ -5082,11 +5107,12 @@ int lkbde_irq_mask_set(int d, uint32_t addr, uint32_t mask, uint32_t fmask) { bde_ctrl_t *ctrl; - int isr2_dev; + int isr2_dev, iproc_reg; unsigned long flags; isr2_dev = d & LKBDE_ISR2_DEV; - d &= ~LKBDE_ISR2_DEV; + iproc_reg = d & LKBDE_IPROC_REG; + d &= ~(LKBDE_ISR2_DEV | LKBDE_IPROC_REG); if (!VALID_DEVICE(d)) { return -1; @@ -5105,7 +5131,12 @@ lkbde_irq_mask_set(int d, uint32_t addr, uint32_t mask, uint32_t fmask) /* This is the primary interrupt handler */ ctrl->imask = mask & ~ctrl->fmask; } - _write(d, addr, ctrl->imask | ctrl->imask2); + + if (iproc_reg) { + _iproc_write(d, addr, ctrl->imask | ctrl->imask2); + } else { + _write(d, addr, ctrl->imask | ctrl->imask2); + } spin_unlock_irqrestore(&ctrl->lock, flags); @@ -5130,13 +5161,13 @@ lkbde_irq_mask_get(int d, uint32_t *mask, uint32_t *fmask) { bde_ctrl_t *ctrl; - d &= ~LKBDE_ISR2_DEV; + d &= ~(LKBDE_ISR2_DEV | LKBDE_IPROC_REG); if (!VALID_DEVICE(d)) { return -1; } - if (mask == NULL) { + if (mask == NULL || fmask == NULL) { return -1; } @@ -5144,10 +5175,15 @@ lkbde_irq_mask_get(int d, uint32_t *mask, uint32_t *fmask) *fmask = ctrl->fmask; *mask = ctrl->imask | ctrl->imask2; - + return 0; } +int +lkbde_get_num_devices(int type) +{ + return _num_devices(type); +} /* * Export functions 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 bd7eab6032e8..32b769784c2e 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: linux_dma.c,v 1.414 Broadcom SDK $ @@ -102,6 +101,10 @@ #define VIRT_TO_PAGE(p) virt_to_page((p)) #endif +#ifndef KMALLOC_MAX_SIZE +#define KMALLOC_MAX_SIZE (1UL << (MAX_ORDER - 1 + PAGE_SHIFT)) +#endif + /* Compatibility */ #ifdef LKM_2_4 #define MEM_MAP_RESERVE mem_map_reserve @@ -149,10 +152,17 @@ LKM_MOD_PARAM(himem, "s", charp, 0); MODULE_PARM_DESC(himem, "Use high memory for DMA (default no)"); +/* Physical high memory address to use for DMA */ +static char *himemaddr = 0; +LKM_MOD_PARAM(himemaddr, "s", charp, 0); +MODULE_PARM_DESC(himemaddr, +"Physical address to use for high memory DMA"); + /* DMA memory allocation */ #define ONE_KB 1024 #define ONE_MB (1024*1024) +#define ONE_GB (1024*1024*1024) /* Default DMA memory size */ #ifdef SAL_BDE_DMA_MEM_DEFAULT @@ -189,10 +199,12 @@ static phys_addr_t _cpu_pbase = 0; */ static phys_addr_t _dma_pbase = 0; static int _use_himem = 0; +static unsigned long _himemaddr = 0; static int _use_dma_mapping = 0; static LIST_HEAD(_dma_seg); -#define DMA_DEV(n) lkbde_get_dma_dev(n) +#define DMA_DEV(n) lkbde_get_dma_dev(n) +#define BDE_NUM_DEVICES(t) lkbde_get_num_devices(t) /* * Function: _find_largest_segment @@ -304,8 +316,7 @@ _alloc_dma_blocks(dma_segment_t *dseg, int blks) return -1; } start = dseg->blk_cnt; - dseg->blk_cnt += blks; - for (i = start; i < dseg->blk_cnt; i++) { + for (i = 0; i < blks; i++) { /* * Note that we cannot use pci_alloc_consistent when we * want to be able to map DMA memory to user space. @@ -317,9 +328,11 @@ _alloc_dma_blocks(dma_segment_t *dseg, int blks) */ addr = __get_free_pages(mem_flags, dseg->blk_order); if (addr) { - dseg->blk_ptr[i] = addr; + dseg->blk_ptr[start + i] = addr; + ++dseg->blk_cnt; } else { - gprintk("DMA allocation failed\n"); + gprintk("DMA allocation failed: allocated %d of %d " + "requested blocks\n", i, blks); return -1; } } @@ -375,6 +388,10 @@ _dma_segment_alloc(size_t size, size_t blk_size) si_meminfo(&si); dseg->blk_cnt_max = (si.totalram << PAGE_SHIFT) / dseg->blk_size; blk_ptr_size = dseg->blk_cnt_max * sizeof(unsigned long); + if (blk_ptr_size > KMALLOC_MAX_SIZE) { + blk_ptr_size = KMALLOC_MAX_SIZE; + dseg->blk_cnt_max = KMALLOC_MAX_SIZE / sizeof(unsigned long); + } /* Allocate an initialize DMA block pool */ dseg->blk_ptr = KMALLOC(blk_ptr_size, GFP_KERNEL); if (dseg->blk_ptr == NULL) { @@ -383,7 +400,15 @@ _dma_segment_alloc(size_t size, size_t blk_size) } memset(dseg->blk_ptr, 0, blk_ptr_size); /* Allocate minimum number of blocks */ - _alloc_dma_blocks(dseg, dseg->req_size / dseg->blk_size); + if (_alloc_dma_blocks(dseg, dseg->req_size / dseg->blk_size) != 0) { + gprintk("Failed to allocate minimum number of DMA blocks\n"); + /* + * _alloc_dma_blocks() returns -1 if it fails to allocate the requested + * number of blocks, but it may still have allocated something. Fall + * through and return dseg filled in with as much memory as we could + * allocate. + */ + } /* Allocate more blocks until we have a complete segment */ do { _find_largest_segment(dseg); @@ -467,6 +492,9 @@ _pgalloc(size_t size) } if (dseg->seg_size < size) { /* If we didn't get the full size then forget it */ + gprintk("_pgalloc() failed to get requested size %zu: " + "only got %lu contiguous across %d blocks\n", + size, dseg->seg_size, dseg->blk_cnt); _dma_segment_free(dseg); return NULL; } @@ -524,8 +552,12 @@ _pgcleanup(void) case ALLOC_TYPE_CHUNK: { struct list_head *pos, *tmp; + int i, ndevices; if (_use_dma_mapping) { - dma_unmap_single(DMA_DEV(0), (dma_addr_t)_dma_pbase, _dma_mem_size, DMA_BIDIRECTIONAL); + ndevices = BDE_NUM_DEVICES(BDE_ALL_DEVICES); + for (i = 0; i < ndevices && DMA_DEV(i); i ++) { + dma_unmap_single(DMA_DEV(i), (dma_addr_t)_dma_pbase, _dma_mem_size, DMA_BIDIRECTIONAL); + } _use_dma_mapping = 0; } list_for_each_safe(pos, tmp, &_dma_seg) { @@ -558,7 +590,7 @@ _pgcleanup(void) static void _alloc_mpool(size_t size) { - unsigned long pbase = 0; + unsigned long pbase = 0; #if defined(__arm__) && !defined(CONFIG_HIGHMEM) if (_use_himem) { @@ -569,7 +601,11 @@ _alloc_mpool(size_t size) if (_use_himem) { /* Use high memory for DMA */ - pbase = virt_to_bus(high_memory); + if (_himemaddr) { + pbase = _himemaddr; + } else { + pbase = virt_to_bus(high_memory); + } if (((pbase + (size - 1)) >> 16) > DMA_BIT_MASK(16)) { gprintk("DMA in high memory at 0x%lx size 0x%lx is beyond the 4GB limit and not supported.\n", pbase, (unsigned long)size); return; @@ -589,14 +625,14 @@ _alloc_mpool(size_t size) { dma_addr_t dma_handle; if (!(_dma_vbase = dma_alloc_coherent(DMA_DEV(0), alloc_size, &dma_handle, GFP_KERNEL)) || !dma_handle) { - gprintk("_alloc_mpool: Kernel failed to allocate the memory pool of size 0x%lx\n", (unsigned long)alloc_size); + gprintk("failed to allocate the memory pool of size 0x%lx\n", (unsigned long)alloc_size); return; } - pbase = dma_handle; + _cpu_pbase = pbase = dma_handle; } if (alloc_size != size) { - gprintk("_alloc_mpool: allocated 0x%lx bytes instead of 0x%lx bytes.\n", + gprintk("allocated 0x%lx bytes instead of 0x%lx bytes.\n", (unsigned long)alloc_size, (unsigned long)size); } size = _dma_mem_size = alloc_size; @@ -606,27 +642,31 @@ _alloc_mpool(size_t size) case ALLOC_TYPE_CHUNK: _dma_vbase = _pgalloc(size); + if (!_dma_vbase) { + gprintk("failed to allocate the memory pool of size 0x%lx\n", (unsigned long)size); + return; + } + _cpu_pbase = virt_to_bus(_dma_vbase); + /* Use dma_map_single to obtain DMA bus address or IOVA if iommu is present. */ if (DMA_DEV(0)) { - /* - * Use dma_map_single to obtain dma bus address or IOVA if iommu is present. - */ pbase = dma_map_single(DMA_DEV(0), _dma_vbase, size, DMA_BIDIRECTIONAL); + if (dma_mapping_error(DMA_DEV(0), pbase)) { + gprintk("Failed to map memory at %p\n", _dma_vbase); + _pgcleanup(); + _dma_vbase = NULL; + _cpu_pbase = 0; + return; + } _use_dma_mapping = 1; } else { - pbase = virt_to_bus(_dma_vbase); + /* Device has not been probed. */ + pbase = _cpu_pbase; } break; default: _dma_vbase = NULL; - pbase = 0; gprintk("DMA memory allocation method dmaalloc=%d is not supported\n", dmaalloc); - } - - _dma_pbase = pbase; - - if (dma_debug >= 1) { - gprintk("_alloc_mpool:%s _dma_vbase:%p pbase:%lx allocated:%lx dmaalloc:%d\n", - DMA_DEV(0)?"dma_dev":"", _dma_vbase, pbase, (unsigned long)size, dmaalloc); + return; } if (((pbase + (size - 1)) >> 16) > DMA_BIT_MASK(16)) { @@ -637,14 +677,15 @@ _alloc_mpool(size_t size) return; } - if (_dma_vbase) { - _cpu_pbase = virt_to_bus(_dma_vbase); - if (dma_debug >= 1) gprintk("_cpu_pbase at %lx\n", (unsigned long)_cpu_pbase); - } + _dma_pbase = pbase; #ifdef REMAP_DMA_NONCACHED _dma_vbase = IOREMAP(_dma_pbase, size); #endif - + if (dma_debug >= 1) { + gprintk("_use_dma_mapping:%d _dma_vbase:%p _dma_pbase:%lx _cpu_pbase:%lx allocated:%lx dmaalloc:%d\n", + _use_dma_mapping, _dma_vbase, (unsigned long)_dma_pbase, + (unsigned long)_cpu_pbase, (unsigned long)size, dmaalloc); + } } } @@ -678,8 +719,20 @@ _dma_cleanup(void) return 0; } -void _dma_init(int robo_switch) +void _dma_init(int robo_switch, int dev_index) { + unsigned long pbase; + + if (dev_index > 0) { + if ((_use_dma_mapping == 1) && DMA_DEV(dev_index) && _dma_vbase) { + pbase = dma_map_single(DMA_DEV(dev_index), _dma_vbase, _dma_mem_size, DMA_BIDIRECTIONAL); + if (dma_mapping_error(DMA_DEV(dev_index), pbase)) { + gprintk("Failed to map memory for device %d at %p\n", dev_index, _dma_vbase); + } + } + return; + } + /* DMA Setup */ if (dmasize) { if ((dmasize[strlen(dmasize)-1] & ~0x20) == 'M') { @@ -706,6 +759,18 @@ void _dma_init(int robo_switch) } } + if (himemaddr && strlen(himemaddr) > 0) { + char suffix = (himemaddr[strlen(himemaddr)-1] & ~0x20); + _himemaddr = simple_strtoul(himemaddr, NULL, 0); + if (suffix == 'M') { + _himemaddr *= ONE_MB; + } else if (suffix == 'G') { + _himemaddr *= ONE_GB; + } else { + gprintk("DMA high memory address must be specified as e.g. himemaddr=8[MG]\n"); + } + } + if (_dma_mem_size) { _alloc_mpool(_dma_mem_size); if (_dma_vbase == NULL) { diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c index 312062b8464c..a2d58858a5a5 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.c @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h index 73d497925ed4..5e8a70119e85 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/kernel/linux_shbde.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c b/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c index 7f7332b3a7a4..7a377cd00787 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/shared/mpool.c @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: mpool.c,v 1.18 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile index ac8b04ac9bcf..424f2fe24bee 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.1 Broadcom SDK $ 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 c237f9429ef7..7fc9fd166bbd 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: linux-user-bde.c,v 1.80 Broadcom SDK $ @@ -64,6 +63,8 @@ MODULE_LICENSE("GPL"); #define CMIC_CMCx_IRQ_STAT6_OFFSET(x) (0x314b4 + (0x1000 * x)) #define CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(x) (0x314b8 + (0x1000 * x)) #define CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(x) (0x314bc + (0x1000 * x)) +#define CMIC_CMCx_UC0_IRQ_MASK5_OFFSET(x) (0x314c0 + (0x1000 * x)) +#define CMIC_CMCx_UC0_IRQ_MASK6_OFFSET(x) (0x314c4 + (0x1000 * x)) #define CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(x) (0x31428 + (0x1000 * x)) #define CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(x) (0x3142c + (0x1000 * x)) @@ -72,16 +73,17 @@ MODULE_LICENSE("GPL"); #define CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(x) (0x31438 + (0x1000 * x)) /* CMICX defines */ -#define INTC_INTR_REG_NUM (8) +#define INTC_INTR_REG_NUM (8) -#define INTC_INTR_ENABLE_REG0 (0x180130f0) -#define INTC_INTR_STATUS_REG0 (0x18013190) -#define INTC_INTR_RAW_STATUS_REG0 (0x18013140) +#define INTC_INTR_ENABLE_REG0 (0x180130f0) +#define INTC_INTR_STATUS_REG0 (0x18013190) +#define INTC_INTR_RAW_STATUS_REG0 (0x18013140) -#define INTC_INTR_ENABLE_BASE (INTC_INTR_ENABLE_REG0) -#define INTC_INTR_STATUS_BASE (INTC_INTR_STATUS_REG0) -#define INTC_INTR_RAW_STATUS_BASE (INTC_INTR_RAW_STATUS_REG0) +#define INTC_INTR_ENABLE_BASE (INTC_INTR_ENABLE_REG0) +#define INTC_INTR_STATUS_BASE (INTC_INTR_STATUS_REG0) +#define INTC_INTR_RAW_STATUS_BASE (INTC_INTR_RAW_STATUS_REG0) +#define INTC_PDMA_INTR_REG_IND 4 #define READ_INTC_INTR(d, reg, v) \ (v = user_bde->iproc_read(d, reg)) @@ -220,18 +222,45 @@ _cmic_interrupt(bde_ctrl_t *ctrl) static void _cmicx_interrupt(bde_ctrl_t *ctrl) { - int d, i; + int d, ind; + uint32 stat, iena, mask, fmask; bde_inst_resource_t *res; d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); res = &_bde_inst_resource[ctrl->inst]; + lkbde_irq_mask_get(d, &mask, &fmask); + + if (fmask) { + READ_INTC_INTR(d, INTC_INTR_STATUS_BASE + 4 * INTC_PDMA_INTR_REG_IND, stat); + READ_INTC_INTR(d, INTC_INTR_ENABLE_BASE + 4 * INTC_PDMA_INTR_REG_IND, iena); + if (stat & iena) { + WRITE_INTC_INTR(d, INTC_INTR_ENABLE_BASE + 4 * INTC_PDMA_INTR_REG_IND, 0); + for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { + if (ind == INTC_PDMA_INTR_REG_IND) { + continue; + } + READ_INTC_INTR(d, INTC_INTR_STATUS_BASE + 4 * ind, stat); + READ_INTC_INTR(d, INTC_INTR_ENABLE_BASE + 4 * ind, iena); + if (stat & iena) { + break; + } + } + if (ind >= INTC_INTR_REG_NUM) { + return; + } + } + } + /* Disable all interrupts.. Re-enable unserviced interrupts later * So as to avoid getting new interrupts until the user level driver * enumerates the interrupts to be serviced */ - for (i = 0 ; i < INTC_INTR_REG_NUM ; i++) { - WRITE_INTC_INTR(d, (INTC_INTR_ENABLE_BASE + 4*i), 0); + for (ind = 0; ind < INTC_INTR_REG_NUM; ind++) { + if (fmask && ind == INTC_PDMA_INTR_REG_IND) { + continue; + } + WRITE_INTC_INTR(d, INTC_INTR_ENABLE_BASE + 4 * ind, 0); } /* Notify */ @@ -327,8 +356,108 @@ _cmicm_interrupt(bde_ctrl_t *ctrl) #endif } +/* some device has cmc0 only */ +static void +_cmicd_cmc0_interrupt(bde_ctrl_t *ctrl) +{ + int d; + int cmc = 0; + uint32 stat, mask = 0, fmask = 0, imask = 0; + bde_inst_resource_t *res; -static void + d = (((uint8 *)ctrl - (uint8 *)_devices) / sizeof (bde_ctrl_t)); + res = &_bde_inst_resource[ctrl->inst]; + lkbde_irq_mask_get(d, &mask, &fmask); + + while (fmask) { + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT0_OFFSET(cmc)); + imask = mask & ~fmask; + if (stat & imask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT1_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT2_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT3_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT4_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT5_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK5_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT6_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK6_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc)); + } + if (stat & mask) { + break; + } + return; + } + + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + lkbde_irq_mask_set(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(cmc), 0, 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK5_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK6_OFFSET(cmc), 0); + } else { + lkbde_irq_mask_set(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(cmc), 0, 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc), 0); + } + atomic_set(&res->intr, 1); +#ifdef BDE_LINUX_NON_INTERRUPTIBLE + wake_up(&res->intr_wq); +#else + wake_up_interruptible(&res->intr_wq); +#endif +} + +static void _cmicd_interrupt(bde_ctrl_t *ctrl) { int d; @@ -347,46 +476,83 @@ _cmicd_interrupt(bde_ctrl_t *ctrl) break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT1_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc)); + } if (stat & mask) { break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT2_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc)); + } if (stat & mask) { break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT3_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc)); + } if (stat & mask) { break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT4_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc)); + } if (stat & mask) { break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT5_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK5_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc)); + } if (stat & mask) { break; } stat = user_bde->read(d, CMIC_CMCx_IRQ_STAT6_OFFSET(cmc)); - mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc)); + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + mask = user_bde->read(d, CMIC_CMCx_UC0_IRQ_MASK6_OFFSET(cmc)); + } else { + mask = user_bde->read(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc)); + } if (stat & mask) { break; } return; } - lkbde_irq_mask_set(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(cmc), 0, 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc), 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc), 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc), 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc), 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc), 0); - user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc), 0); - + if (ctrl->dev_type & BDE_AXI_DEV_TYPE) { + lkbde_irq_mask_set(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(cmc), 0, 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK1_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK2_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK3_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK4_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK5_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK6_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(1), 0); + user_bde->write(d, CMIC_CMCx_UC0_IRQ_MASK0_OFFSET(2), 0); + } else { + lkbde_irq_mask_set(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(cmc), 0, 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK1_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK2_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK3_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK4_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK5_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK6_OFFSET(cmc), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(1), 0); + user_bde->write(d, CMIC_CMCx_PCIE_IRQ_MASK0_OFFSET(2), 0); + } atomic_set(&res->intr, 1); #ifdef BDE_LINUX_NON_INTERRUPTIBLE wake_up(&res->intr_wq); @@ -551,6 +717,7 @@ static struct _intr_mode_s { { (isr_f)_cmic_interrupt, "CMIC/CMICe" }, { (isr_f)_cmicm_interrupt, "CMICm" }, { (isr_f)_cmicd_interrupt, "CMICd" }, + { (isr_f)_cmicd_cmc0_interrupt, "CMICd CMC0" }, { (isr_f)_qe2k_interrupt, "QE2K" }, { (isr_f)_fe2k_interrupt, "FE2K" }, { (isr_f)_fe2kxt_interrupt, "FE2KXT" }, @@ -580,7 +747,9 @@ static void _devices_init(int d) { bde_ctrl_t *ctrl; - uint32 ver; + uint32 ver; + uint16 device_id_mask = 0xFFF0; + uint16 device_id; ctrl = &_devices[d]; /* Initialize our control info */ @@ -616,7 +785,10 @@ _devices_init(int d) case BCM88752_DEVICE_ID: ctrl->isr = (isr_f)_bcm88750_interrupt; break; - /* FIXME: might use _devices[i].dev_type & BDE_AXI_DEV_TYPE*/ + case BCM53540_DEVICE_ID: + case BCM53547_DEVICE_ID: + case BCM53548_DEVICE_ID: + case BCM53549_DEVICE_ID: case BCM88670_DEVICE_ID: case BCM88671_DEVICE_ID: case BCM88671M_DEVICE_ID: @@ -662,29 +834,35 @@ _devices_init(int d) case BCM88474H_DEVICE_ID: case BCM88476_DEVICE_ID: case BCM88477_DEVICE_ID: - case BCM88270_DEVICE_ID: case BCM88272_DEVICE_ID: case BCM88273_DEVICE_ID: case BCM88278_DEVICE_ID: + case BCM88279_DEVICE_ID: case BCM8206_DEVICE_ID: case BCM88950_DEVICE_ID: case BCM88953_DEVICE_ID: case BCM88954_DEVICE_ID: case BCM88955_DEVICE_ID: case BCM88956_DEVICE_ID: - case BCM88790_DEVICE_ID: case BCM88772_DEVICE_ID: case BCM88952_DEVICE_ID: - ctrl->isr = (isr_f)_cmicd_interrupt; + ctrl->isr = (isr_f)_cmicd_cmc0_interrupt; break; default: /* Get CMIC version */ if (user_bde->get_cmic_ver(d, &ver) != 0) { ver = -1; } + device_id = ctrl->devid & device_id_mask; + /* TH/TH+/TH2 should use cmicd interrupt handler */ + if (BCM56960_DEVICE_ID == device_id || + BCM56930_DEVICE_ID == device_id || + BCM56970_DEVICE_ID == device_id) { + ctrl->isr = (isr_f)_cmicd_interrupt; + } /* check if version is CMICX */ - if (ver == 0x04) { + else if (ver == 0x04) { ctrl->isr = (isr_f)_cmicx_interrupt; } else { ctrl->isr = (isr_f)_cmic_interrupt; @@ -698,6 +876,10 @@ _devices_init(int d) } break; } + /*All Ramon devices from 0x8790 to 0x879F*/ + if ((user_bde->get_dev(d)->device & BCM88790_DEVICE_ID) == BCM88790_DEVICE_ID) { + ctrl->isr = (isr_f)_cmicx_interrupt; + } if (_intr_mode_str(ctrl->isr) == NULL) { gprintk("Warning: Unknown interrupt mode\n"); } @@ -1002,7 +1184,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_GET_DEVICE: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } bde_dev = user_bde->get_dev(io.dev); if (bde_dev) { @@ -1019,7 +1201,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_GET_DEVICE_TYPE: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } io.d0 = _devices[io.dev].dev_type; break; @@ -1029,7 +1211,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_PCI_CONFIG_PUT32: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } if (_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) { user_bde->pci_conf_write(io.dev, io.d0, io.d1); @@ -1039,7 +1221,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_PCI_CONFIG_GET32: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } if (_devices[io.dev].dev_type & BDE_PCI_DEV_TYPE) { io.d0 = user_bde->pci_conf_read(io.dev, io.d0); @@ -1068,7 +1250,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_ENABLE_INTERRUPTS: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) { if (_devices[io.dev].isr && !_devices[io.dev].enabled) { @@ -1090,7 +1272,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_DISABLE_INTERRUPTS: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } if (_devices[io.dev].enabled) { user_bde->interrupt_disconnect(io.dev); @@ -1099,7 +1281,7 @@ _ioctl(unsigned int cmd, unsigned long arg) break; case LUBDE_WAIT_FOR_INTERRUPT: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } if (_devices[io.dev].dev_type & BDE_SWITCH_DEV_TYPE) { res = &_bde_inst_resource[_devices[io.dev].inst]; @@ -1200,7 +1382,7 @@ _ioctl(unsigned int cmd, unsigned long arg) #endif case LUBDE_DEV_RESOURCE: if (!VALID_DEVICE(io.dev)) { - return -EINVAL; + return -EINVAL; } bde_dev = user_bde->get_dev(io.dev); if (bde_dev) { @@ -1235,7 +1417,7 @@ _ioctl(unsigned int cmd, unsigned long arg) io.rc = LUBDE_FAIL; break; } - + if (copy_to_user((void *)arg, &io, sizeof(io))) { return -EFAULT; } diff --git a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h index edf5f63bf54a..621973b7a7f5 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/linux/user/kernel/linux-user-bde.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: linux-user-bde.h,v 1.23 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h index 0a9df3a6e419..53003a40ce53 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h index 4841a3167d89..4b614ba53139 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_iproc.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h index b5a2f8b3f31d..5f8fa63533f4 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_mdio.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h index 06aadfae5b31..1f045d7b02c8 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/include/shbde_pci.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c index 2db25df585ae..d1e95725c5f7 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_iproc.c @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ @@ -145,12 +144,14 @@ shbde_iproc_config_init(shbde_iproc_config_t *icfg, icfg->dma_hi_bits = 0x2; break; case 0xb560: /* Apache */ + case 0xb670: /* MO */ case 0xb760: /* Maverick */ icfg->iproc_ver = 0xB; break; case 0xb160: /* Hurricane3 */ - case 0x8440: /* Wolfhound2 */ + case 0x8440: /* Buckhound2 */ case 0x8430: /* Foxhound2 */ + case 0x8540: /* Wolfhound2 */ icfg->iproc_ver = 10; icfg->dma_hi_bits = 0x2; break; @@ -272,17 +273,17 @@ shbde_iproc_paxb_init(shbde_hal_t *shbde, void *iproc_regs, reg = ROFFS(iproc_regs, BAR0_PAXB_PCIE_EP_AXI_CONFIG); iproc32_write(shbde, reg, 0x0); if(icfg->cmic_ver < 4) { /* Non-CMICX */ - reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2); - iproc32_write(shbde, reg, 0x1); - reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2_UPPER); - iproc32_write(shbde, reg, icfg->dma_hi_bits); - - /* Configure MSI interrupt page */ - if (icfg->use_msi) { - reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_FUNC0_MSI_PAGE); - data = iproc32_read(shbde, reg); - iproc32_write(shbde, reg, data | 0x1); - } + reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2); + iproc32_write(shbde, reg, 0x1); + reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_2_UPPER); + iproc32_write(shbde, reg, icfg->dma_hi_bits); + + /* Configure MSI interrupt page */ + if (icfg->use_msi) { + reg = ROFFS(iproc_regs, BAR0_PAXB_OARR_FUNC0_MSI_PAGE); + data = iproc32_read(shbde, reg); + iproc32_write(shbde, reg, data | 0x1); + } } return pci_num; } @@ -318,15 +319,15 @@ shbde_iproc_pci_read(shbde_hal_t *shbde, void *iproc_regs, /* Route the INTC block access through IMAP0_6 */ reg = ROFFS(iproc_regs, 0x6000 + (addr & 0xfff)); } else { - /* Update base address for sub-window 7 */ + /* Update base address for sub-window 7 */ subwin_base |= 1; /* Valid bit */ - reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7); - iproc32_write(shbde, reg, subwin_base); + reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7); + iproc32_write(shbde, reg, subwin_base); /* Read it to make sure the write actually goes through */ subwin_base = iproc32_read(shbde, reg); - /* Read register through sub-window 7 */ - reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff)); + /* Read register through sub-window 7 */ + reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff)); } return iproc32_read(shbde, reg); @@ -364,15 +365,15 @@ shbde_iproc_pci_write(shbde_hal_t *shbde, void *iproc_regs, /* Route the INTC block access through IMAP0_6 */ reg = ROFFS(iproc_regs, 0x6000 + (addr & 0xfff)); } else { - /* Update base address for sub-window 7 */ + /* Update base address for sub-window 7 */ subwin_base |= 1; /* Valid bit */ - reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7); - iproc32_write(shbde, reg, subwin_base); + reg = ROFFS(iproc_regs, BAR0_PAXB_IMAP0_7); + iproc32_write(shbde, reg, subwin_base); /* Read it to make sure the write actually goes through */ subwin_base = iproc32_read(shbde, reg); /* Read register through sub-window 7 */ - reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff)); + reg = ROFFS(iproc_regs, 0x7000 + (addr & 0xfff)); } iproc32_write(shbde, reg, data); diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c index 434312d5608c..ef4a72071b33 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_mdio.c @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c index 22408a84c3e6..5cc46d0d463d 100644 --- a/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c +++ b/platform/broadcom/saibcm-modules/systems/bde/shared/shbde_pci.c @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile index 37f35b2e27a5..84c677758cac 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.10 Broadcom SDK $ 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 5459b399aa4b..ed1a5000e3ca 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 @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.3 Broadcom SDK $ 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 index fe6fd53850cc..801f5d3e406c 100644 --- 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: bcm-knet.c,v 1.90 Broadcom SDK $ @@ -70,6 +69,7 @@ #include #include #include +#include MODULE_AUTHOR("Broadcom Corporation"); @@ -146,12 +146,12 @@ LKM_MOD_PARAM(num_rx_prio, "i", int, 0); MODULE_PARM_DESC(num_rx_prio, "Number of filter priorities per Rx DMA channel"); -static int rx_rate[4] = { 100000, 100000, 100000, 0 }; +static int rx_rate[8] = { 100000, 100000, 100000, 100000, 100000, 100000, 100000, 0 }; LKM_MOD_PARAM_ARRAY(rx_rate, "1-4i", int, NULL, 0); MODULE_PARM_DESC(rx_rate, "Rx rate in packets per second (default 100000)"); -static int rx_burst[4] = { 0, 0, 0, 0 }; +static int rx_burst[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; LKM_MOD_PARAM_ARRAY(rx_burst, "1-4i", int, NULL, 0); MODULE_PARM_DESC(rx_burst, "Rx rate burst maximum in packets (default rx_rate/10)"); @@ -166,16 +166,6 @@ LKM_MOD_PARAM(basedev_suspend, "i", int, 0); MODULE_PARM_DESC(basedev_suspend, "Pause traffic till base device is up (enabled by default in NAPI mode)"); -static int ftmh_lb_key_ext = 0; -LKM_MOD_PARAM(ftmh_lb_key_ext, "i", int, 0); -MODULE_PARM_DESC(ftmh_lb_key_ext, -"FTMH LB-Key Extension header is present (default 0)"); - -static int ftmh_stacking_ext = 0; -LKM_MOD_PARAM(ftmh_stacking_ext, "i", int, 0); -MODULE_PARM_DESC(ftmh_stacking_ext, -"FTMH Stacking Extension header is present (default 0)"); - /* Debug levels */ #define DBG_LVL_VERB 0x1 #define DBG_LVL_DCB 0x2 @@ -295,7 +285,7 @@ MODULE_PARM_DESC(use_proxy, "Use Linux User/Kernel proxy (default 1)"); #define PROXY_SERVICE_CREATE(_s,_q,_f) linux_uk_proxy_service_create(_s,_q,_f) -#define PROXY_SERVICE_DESTROY(_s) linux_uk_proxy_service_destroy(_s); +#define PROXY_SERVICE_DESTROY(_s) linux_uk_proxy_service_destroy(_s); #define PROXY_SEND(_s,_m,_l) linux_uk_proxy_send(_s,_m,_l) #define PROXY_RECV(_s,_m,_l) linux_uk_proxy_recv(_s,_m,_l) @@ -365,20 +355,20 @@ static inline void netif_poll_enable(struct net_device *dev) static struct sk_buff *skb_pad(struct sk_buff *skb, int pad) { struct sk_buff *nskb; - + /* If the skbuff is non linear tailroom is always zero.. */ if(skb_tailroom(skb) >= pad) { memset(skb->data+skb->len, 0, pad); return skb; } - + nskb = skb_copy_expand(skb, skb_headroom(skb), skb_tailroom(skb) + pad, GFP_ATOMIC); kfree_skb(skb); if(nskb) memset(nskb->data+nskb->len, 0, pad); return nskb; -} +} static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) { unsigned int size = skb->len; @@ -388,6 +378,26 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) } #endif /* KERNEL_VERSION(2,4,21) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) +#define bkn_vlan_hwaccel_put_tag(_skb, _proto, _tci) \ + __vlan_hwaccel_put_tag(_skb, _tci) +#else +#define bkn_vlan_hwaccel_put_tag(_skb, _proto, _tci) \ + __vlan_hwaccel_put_tag(_skb, htons(_proto), _tci) +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) +#define bkn_dma_mapping_error(d, a) \ + dma_mapping_error(a) +#define bkn_pci_dma_mapping_error(d, a) \ + pci_dma_mapping_error(a) +#else +#define bkn_dma_mapping_error(d, a) \ + dma_mapping_error(d, a) +#define bkn_pci_dma_mapping_error(d, a) \ + pci_dma_mapping_error(d, a) +#endif + #ifdef LINUX_BDE_DMA_DEVICE_SUPPORT #define DMA_DEV device #define DMA_FROMDEV DMA_FROM_DEVICE @@ -396,6 +406,7 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) #define DMA_UNMAP_SINGLE(d,a,s,r) dma_unmap_single(d,a,s,r) #define DMA_ALLOC_COHERENT(d,s,h) dma_alloc_coherent(d,s,h,GFP_ATOMIC|GFP_DMA32) #define DMA_FREE_COHERENT(d,s,a,h) dma_free_coherent(d,s,a,h) +#define DMA_MAPPING_ERROR(d,a) bkn_dma_mapping_error(d,a) #else #define DMA_DEV pci_dev #define DMA_FROMDEV PCI_DMA_FROMDEVICE @@ -404,6 +415,7 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) #define DMA_UNMAP_SINGLE(d,a,s,r) pci_unmap_single(d,a,s,r) #define DMA_ALLOC_COHERENT(d,s,h) pci_alloc_consistent(d,s,h) #define DMA_FREE_COHERENT(d,s,a,h) pci_free_consistent(d,s,a,h) +#define DMA_MAPPING_ERROR(d,a) bkn_pci_dma_mapping_error(d,a) #endif /* RCPU operations */ @@ -420,6 +432,8 @@ static inline struct sk_buff *skb_padto(struct sk_buff *skb, unsigned int len) #define RCPU_RX_META_SIZE 64 #define RCPU_RX_ENCAP_SIZE (RCPU_HDR_SIZE + RCPU_RX_META_SIZE) +#define PKT_TX_HDR_SIZE 16 + static volatile int module_initialized; static ibde_t *kernel_bde = NULL; @@ -427,9 +441,9 @@ static ibde_t *kernel_bde = NULL; /* Descriptor info */ typedef struct bkn_desc_info_s { uint32_t *dcb_mem; - dma_addr_t dcb_dma; + uint64_t dcb_dma; struct sk_buff *skb; - dma_addr_t skb_dma; + uint64_t skb_dma; uint32_t dma_size; } bkn_desc_info_t; @@ -439,15 +453,16 @@ typedef struct bkn_dcb_chain_s { int dcb_cnt; int dcb_cur; uint32_t *dcb_mem; - dma_addr_t dcb_dma; + uint64_t dcb_dma; } bkn_dcb_chain_t; -#define MAX_TX_DCBS 32 -#define MAX_RX_DCBS 32 +#define MAX_TX_DCBS 64 +#define MAX_RX_DCBS 64 -#define NUM_DMA_CHAN 4 -#define NUM_RX_CHAN 3 -#define API_RX_CHAN 0 +#define NUM_DMA_CHAN 8 +#define NUM_RX_CHAN 7 +#define NUM_CMICX_RX_CHAN 7 +#define NUM_CMICM_RX_CHAN 3 /* Device control info */ typedef struct bkn_switch_info_s { @@ -474,6 +489,9 @@ typedef struct bkn_switch_info_s { int cpu_no; /* Cpu number. 1 for iHost(AXI),0 for others */ int dcb_type; /* DCB type */ int dcb_wsize; /* DCB size (in 32-bit words) */ + int pkt_hdr_size; /* Packet header size */ + int rx_chans; /* Number of Rx channels */ + uint32_t dma_hi; /* DMA higher address */ uint32_t cmic_type; /* CMIC type (CMICe or CMICm) */ uint32_t irq_mask; /* Active IRQs for DMA control */ uint32_t napi_poll_mode; /* NAPI is in polling mode */ @@ -481,11 +499,11 @@ typedef struct bkn_switch_info_s { uint32_t napi_poll_again; /* Used if DCB chain is restarted */ uint32_t tx_yield; /* Tx schedule for Continuous DMA and Non-NAPI mode */ void *dcb_mem; /* Logical pointer to DCB memory */ - dma_addr_t dcb_dma; /* Physical bus address for DCB memory */ + uint64_t dcb_dma; /* Physical bus address for DCB memory */ int dcb_mem_size; /* Total size of allocated DCB memory */ uint32_t dma_events; /* DMA events pending for BCM API */ uint32_t rcpu_sig; /* RCPU signature */ - dma_addr_t halt_addr[NUM_DMA_CHAN]; /* DMA halt address */ + uint64_t halt_addr[NUM_DMA_CHAN]; /* DMA halt address */ uint32_t cdma_channels; /* Active channels for Continuous DMA mode */ uint32_t inst_id; /* Instance id of this device */ int evt_idx; /* Event queue index for this device*/ @@ -518,6 +536,7 @@ typedef struct bkn_switch_info_s { int dirty; /* Index of next Rx DCB to complete */ int running; /* Rx DMA is active */ int api_active; /* BCM Rx API is active */ + int api_wait; /* Wait BCM Rx API resources */ int chain_complete; /* All DCBs in chain processed */ int sync_err; /* Chain done with incomplete DCBs (debug) */ int sync_retry; /* Total retry times for sync error (debug) */ @@ -550,6 +569,8 @@ typedef struct bkn_switch_info_s { #define BKN_DNX_HDR_MAX_SIZE 40 /* FTMH */ +#define BKN_DNX_FTMH_LB_EXT_EN 0x1 +#define BKN_DNX_FTMH_STACKING_EXT_EN 0x2 #define BKN_DNX_FTMH_SIZE_BYTE 9 #define BKN_DNX_FTMH_LB_EXT_SIZE_BYTE 1 #define BKN_DNX_FTMH_STACKING_SIZE_BYTE 2 @@ -676,7 +697,7 @@ static struct proc_dir_entry *bkn_proc_root = NULL; typedef struct bkn_priv_s { struct list_head list; - struct net_device_stats stats; + struct net_device_stats stats; struct net_device *dev; bkn_switch_info_t *sinfo; int id; @@ -916,8 +937,24 @@ static bkn_thread_ctrl_t bkn_evt_ctrl; /* CMICd increased interrupts reserved for kernel handler */ #define CMICD_CTRLD_IRQ_MASK 0x78000000 -#define DEV_HAS_CMICM(_sinfo) ((_sinfo)->cmic_type == 'm') -#define CDMA_CH(_d, _ch) ((_d)->cdma_channels & (1 << (_ch))) +/* CMICx registers */ +#define CMICX_CMC_BASE 0x00000000 +#define CMICX_DMA_CTRLr (CMICX_CMC_BASE + 0x00002100) +#define CMICX_DMA_STATr (CMICX_CMC_BASE + 0x00002114) +#define CMICX_DMA_DESC_HIr (CMICX_CMC_BASE + 0x00002108) +#define CMICX_DMA_DESC_LOr (CMICX_CMC_BASE + 0x00002104) +#define CMICX_DMA_HALT_HIr (CMICX_CMC_BASE + 0x00002110) +#define CMICX_DMA_HALT_LOr (CMICX_CMC_BASE + 0x0000210c) +#define CMICX_IRQ_STATr (CMICX_CMC_BASE + 0x0000106c) +#define CMICX_IRQ_STAT_CLRr (CMICX_CMC_BASE + 0x00001074) +#define CMICX_IRQ_ENABr 0x18013100 + +/* CMICx interrupts reserved for kernel handler */ +#define CMICX_TXRX_IRQ_MASK 0xffffffff + +#define DEV_IS_CMICX(_sinfo) ((_sinfo)->cmic_type == 'x') +#define DEV_IS_CMICM(_sinfo) ((_sinfo)->cmic_type == 'm') +#define CDMA_CH(_d, _ch) ((_d)->cdma_channels & (1 << (_ch))) /* * DMA_STAT: control bits @@ -926,7 +963,6 @@ static bkn_thread_ctrl_t bkn_evt_ctrl; * xxx_TST can be masked against values read from CMIC_DMA_STAT. * Argument required: 0 <= ch <= 3 */ - #define DS_DMA_ACTIVE(ch) (0x00040000 << (ch)) #define DS_DMA_EN_SET(ch) (0x80|(ch)) #define DS_DMA_EN_CLR(ch) (0x00|(ch)) @@ -946,6 +982,14 @@ static bkn_thread_ctrl_t bkn_evt_ctrl; #define DS_CMC_CTRLD_INT_CLR(ch) (0x00000100 << (ch)) #define DS_CMC_DMA_ACTIVE(ch) (0x00000100 << (ch)) +#define CMICX_DS_CMC_DESC_DONE(ch) (0x00000001 << ((ch) * 4)) +#define CMICX_DS_CMC_CHAIN_DONE(ch) (0x00000002 << ((ch) * 4)) +#define CMICX_DS_CMC_CTRLD_INT(ch) (0x00000008 << ((ch) * 4)) +#define CMICX_DS_CMC_DMA_ACTIVE (0x00000002) + +#define DMA_TO_BUS_HI(dma) ((dma) | sinfo->dma_hi) +#define BUS_TO_DMA_HI(bus) ((bus) & ~sinfo->dma_hi) + /* * DMA_CTRL: control bits */ @@ -955,8 +999,14 @@ static bkn_thread_ctrl_t bkn_evt_ctrl; #define DC_CMC_CTRLD_INT (0x00000100) #define DC_CMC_CONTINUOUS (0x00000200) +#define CMICX_DC_CMC_DIRECTION (0x00000001) +#define CMICX_DC_CMC_ENABLE (0x00000002) +#define CMICX_DC_CMC_ABORT (0x00000004) +#define CMICX_DC_CMC_CTRLD_INT (0x00000080) +#define CMICX_DC_CMC_CONTINUOUS (0x00000100) + /* - * Per-channel operations. + * Per-channel operations. * These are the basis for the TX/RX functions */ @@ -968,7 +1018,7 @@ xgs_dma_chain_clear(bkn_switch_info_t *sinfo, int 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; + MEMORY_BARRIER; } static inline void @@ -994,15 +1044,15 @@ xgs_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) xgs_dma_chain_clear(sinfo, chan); xgs_dma_desc_clear(sinfo, chan); - return 0; + return 0; } -static int +static int xgs_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) { - uint32_t cdc; + uint32_t cdc; - DEV_READ32(sinfo, CMIC_DMA_CTRLr, &cdc); + DEV_READ32(sinfo, CMIC_DMA_CTRLr, &cdc); cdc &= ~(0x9 << (8 * chan)); if (dir) { @@ -1011,62 +1061,62 @@ 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; + return 0; } -static int -xgs_dma_chan_start(bkn_switch_info_t *sinfo, int chan, dma_addr_t dcb) +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); - - MEMORY_BARRIER; + + 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; + MEMORY_BARRIER; - return 0; + return 0; } static int xgs_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - uint32_t ctrl, dma_stat; - int p; - + uint32_t ctrl, dma_stat; + 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; - 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; - MEMORY_BARRIER; - /* Poll for abort completion */ for (p = 0; p < polls; p++) { 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); + /* Restore previous control value */ + DEV_WRITE32(sinfo, CMIC_DMA_CTRLr, ctrl); + + MEMORY_BARRIER; - MEMORY_BARRIER; - /* Clear up channel */ - xgs_dma_chan_clear(sinfo, chan); - - return polls; + xgs_dma_chan_clear(sinfo, chan); + + return polls; } } DBG_WARN(("DMA channel %d abort failed\n", chan)); - return -1; + return -1; } static inline void @@ -1125,7 +1175,7 @@ xgsm_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) cdc &= ~(DC_CMC_ENABLE | DC_CMC_ABORT); DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); - MEMORY_BARRIER; + MEMORY_BARRIER; } static inline void @@ -1153,7 +1203,7 @@ xgsm_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) xgsm_dma_chain_clear(sinfo, chan); xgsm_dma_desc_clear(sinfo, chan); - return 0; + return 0; } static inline void @@ -1184,57 +1234,57 @@ xgsm_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) return 0; } -static int -xgsm_dma_chan_start(bkn_switch_info_t *sinfo, int chan, dma_addr_t dcb) +static int +xgsm_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) { uint32_t cdc; /* Write the DCB address to the DESC address for this channel */ DEV_WRITE32(sinfo, CMICM_DMA_DESC0r + 4 * chan, dcb); - - MEMORY_BARRIER; + + MEMORY_BARRIER; /* Kick it off */ DEV_READ32(sinfo, CMICM_DMA_CTRLr + 4 * chan, &cdc); cdc |= DC_CMC_ENABLE; DEV_WRITE32(sinfo, CMICM_DMA_CTRLr + 4 * chan, cdc); - MEMORY_BARRIER; + MEMORY_BARRIER; - return 0; + return 0; } static int xgsm_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - uint32_t ctrl, dma_stat; - int p; - + uint32_t ctrl, dma_stat; + int p; + /* Skip abort sequence if channel is not active */ 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); - - MEMORY_BARRIER; - + + MEMORY_BARRIER; + /* Poll for abort completion */ for (p = 0; p < polls; p++) { 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); - return polls; + xgsm_dma_chan_clear(sinfo, chan); + return polls; } } DBG_WARN(("DMA channel %d abort failed\n", chan)); - return -1; + return -1; } static inline void @@ -1247,7 +1297,7 @@ xgsm_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) mask = 0; } if (sinfo->cpu_no == 1) { - irq_mask_reg = CMICM_IRQ_UC0_MASKr; + irq_mask_reg = CMICM_IRQ_UC0_MASKr; } /* Get the Controlled Interrupts mask for Continuous DMA mode */ @@ -1301,10 +1351,206 @@ 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; + + /* Disabing DMA clears chain done */ + 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); + + stat = CMICX_DS_CMC_CHAIN_DONE(chan); + DEV_WRITE32(sinfo, CMICX_IRQ_STAT_CLRr, stat); + + MEMORY_BARRIER; + + /* Flush write buffer */ + DEV_READ32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); + + MEMORY_BARRIER; +} + +static inline void +xgsx_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) +{ + uint32_t stat; + + 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); + + MEMORY_BARRIER; + + /* Flush write buffer */ + DEV_READ32(sinfo, CMICX_IRQ_STAT_CLRr, &stat); + + MEMORY_BARRIER; +} + +static int +xgsx_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) +{ + xgsx_dma_chain_clear(sinfo, chan); + xgsx_dma_desc_clear(sinfo, chan); + + return 0; +} + +static inline void +xgsx_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) +{ + DEV_WRITE32(sinfo, CMICX_DMA_HALT_LOr + 0x80 * chan, + sinfo->halt_addr[chan]); + DEV_WRITE32(sinfo, CMICX_DMA_HALT_HIr + 0x80 * chan, + DMA_TO_BUS_HI(sinfo->halt_addr[chan] >> 32)); + + MEMORY_BARRIER; +} + +static int +xgsx_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) +{ + uint32_t ctrl; + + DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + ctrl &= ~CMICX_DC_CMC_DIRECTION; + if (dir) { + ctrl |= CMICX_DC_CMC_DIRECTION; + } + if (CDMA_CH(sinfo, chan)) { + 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); + + MEMORY_BARRIER; + + return 0; +} + +static int +xgsx_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) +{ + uint32_t ctrl; + + /* 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)); + + MEMORY_BARRIER; + + /* Kick it off */ + DEV_READ32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, &ctrl); + ctrl |= CMICX_DC_CMC_ENABLE; + DEV_WRITE32(sinfo, CMICX_DMA_CTRLr + 0x80 * chan, ctrl); + + MEMORY_BARRIER; + + return 0; +} + +static int +xgsx_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) +{ + uint32_t ctrl, stat; + int p; + + /* Skip abort sequence if channel is not active */ + 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); + ctrl |= CMICX_DC_CMC_ENABLE | CMICX_DC_CMC_ABORT; + 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); + if (!(stat & CMICX_DS_CMC_DMA_ACTIVE)) { + /* Clear up channel */ + xgsx_dma_chan_clear(sinfo, chan); + return polls; + } + } + + DBG_WARN(("DMA channel %d abort failed\n", chan)); + + return -1; +} + +static inline void +xgsx_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) +{ + if (sinfo->napi_poll_mode) { + mask = 0; + } + + lkbde_irq_mask_set(sinfo->dev_no | LKBDE_ISR2_DEV | LKBDE_IPROC_REG, + CMICX_IRQ_ENABr, mask, CMICX_TXRX_IRQ_MASK); +} + +static inline void +xgsx_irq_mask_enable(bkn_switch_info_t *sinfo, int chan, int update_hw) +{ + uint32_t mask; + + if (CDMA_CH(sinfo, chan)) { + mask = CMICX_DS_CMC_CTRLD_INT(chan); + } else { + if (chan == XGS_DMA_TX_CHAN) { + mask = CMICX_DS_CMC_CHAIN_DONE(chan); + } else { + mask = CMICX_DS_CMC_DESC_DONE(chan) | + CMICX_DS_CMC_CHAIN_DONE(chan); + } + } + + sinfo->irq_mask |= mask; + + if (update_hw) { + xgsx_irq_mask_set(sinfo, sinfo->irq_mask); + } +} + +static inline void +xgsx_irq_mask_disable(bkn_switch_info_t *sinfo, int chan, int update_hw) +{ + uint32_t mask; + + if (CDMA_CH(sinfo, chan)) { + mask = CMICX_DS_CMC_CTRLD_INT(chan); + } else { + if (chan == XGS_DMA_TX_CHAN) { + mask = CMICX_DS_CMC_CHAIN_DONE(chan); + } else { + mask = CMICX_DS_CMC_DESC_DONE(chan) | + CMICX_DS_CMC_CHAIN_DONE(chan); + } + } + + sinfo->irq_mask &= ~mask; + + if (update_hw) { + xgsx_irq_mask_set(sinfo, sinfo->irq_mask); + } +} + static inline void dev_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_dma_chain_clear(sinfo, chan); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_dma_chain_clear(sinfo, chan); } else { xgs_dma_chain_clear(sinfo, chan); @@ -1314,7 +1560,9 @@ dev_dma_chain_clear(bkn_switch_info_t *sinfo, int chan) static inline void dev_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_dma_desc_clear(sinfo, chan); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_dma_desc_clear(sinfo, chan); } else { xgs_dma_desc_clear(sinfo, chan); @@ -1324,51 +1572,67 @@ dev_dma_desc_clear(bkn_switch_info_t *sinfo, int chan) static int dev_dma_chan_clear(bkn_switch_info_t *sinfo, int chan) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + return xgsx_dma_chan_clear(sinfo, chan); + } else if (DEV_IS_CMICM(sinfo)) { return xgsm_dma_chan_clear(sinfo, chan); + } else { + return xgs_dma_chan_clear(sinfo, chan); } - return xgs_dma_chan_clear(sinfo, chan); } static void dev_cdma_halt_set(bkn_switch_info_t *sinfo, int chan) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_cdma_halt_set(sinfo, chan); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_cdma_halt_set(sinfo, chan); } } -static int +static int dev_dma_chan_init(bkn_switch_info_t *sinfo, int chan, int dir) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + return xgsx_dma_chan_init(sinfo, chan, dir); + } else if (DEV_IS_CMICM(sinfo)) { return xgsm_dma_chan_init(sinfo, chan, dir); + } else { + return xgs_dma_chan_init(sinfo, chan, dir); } - return xgs_dma_chan_init(sinfo, chan, dir); } -static int -dev_dma_chan_start(bkn_switch_info_t *sinfo, int chan, dma_addr_t dcb) +static int +dev_dma_chan_start(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + return xgsx_dma_chan_start(sinfo, chan, dcb); + } else if (DEV_IS_CMICM(sinfo)) { return xgsm_dma_chan_start(sinfo, chan, dcb); + } else { + return xgs_dma_chan_start(sinfo, chan, dcb); } - return xgs_dma_chan_start(sinfo, chan, dcb); } static int dev_dma_chan_abort(bkn_switch_info_t *sinfo, int chan, int polls) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + return xgsx_dma_chan_abort(sinfo, chan, polls); + } else if (DEV_IS_CMICM(sinfo)) { return xgsm_dma_chan_abort(sinfo, chan, polls); + } else { + return xgs_dma_chan_abort(sinfo, chan, polls); } - return xgs_dma_chan_abort(sinfo, chan, polls); } static inline void dev_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_irq_mask_set(sinfo, mask); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_irq_mask_set(sinfo, mask); } else { xgs_irq_mask_set(sinfo, mask); @@ -1378,7 +1642,9 @@ dev_irq_mask_set(bkn_switch_info_t *sinfo, uint32_t mask) static inline void dev_irq_mask_enable(bkn_switch_info_t *sinfo, int chan, int update_hw) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_irq_mask_enable(sinfo, chan, update_hw); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_irq_mask_enable(sinfo, chan, update_hw); } else { xgs_irq_mask_enable(sinfo, chan, update_hw); @@ -1388,33 +1654,36 @@ dev_irq_mask_enable(bkn_switch_info_t *sinfo, int chan, int update_hw) static void dev_irq_mask_disable(bkn_switch_info_t *sinfo, int chan, int update_hw) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_irq_mask_disable(sinfo, chan, update_hw); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_irq_mask_disable(sinfo, chan, update_hw); } else { xgs_irq_mask_disable(sinfo, chan, update_hw); } } - static int bkn_alloc_dcbs(bkn_switch_info_t *sinfo) { int dcb_size; int tx_ring_size, rx_ring_size; + dma_addr_t dcb_dma = 0; dcb_size = sinfo->dcb_wsize * sizeof(uint32_t); tx_ring_size = dcb_size * (MAX_TX_DCBS + 1); rx_ring_size = dcb_size * (MAX_RX_DCBS + 1); - sinfo->dcb_mem_size = tx_ring_size + rx_ring_size * NUM_RX_CHAN; + sinfo->dcb_mem_size = tx_ring_size + rx_ring_size * sinfo->rx_chans; sinfo->dcb_mem = DMA_ALLOC_COHERENT(sinfo->dma_dev, sinfo->dcb_mem_size, - &sinfo->dcb_dma); + &dcb_dma); if (sinfo->dcb_mem == NULL) { gprintk("DCB memory allocation (%d bytes) failed.\n", sinfo->dcb_mem_size); return -ENOMEM; } + sinfo->dcb_dma = (uint64_t)dcb_dma; return 0; } @@ -1424,7 +1693,7 @@ bkn_free_dcbs(bkn_switch_info_t *sinfo) { if (sinfo->dcb_mem != NULL) { DMA_FREE_COHERENT(sinfo->dma_dev, sinfo->dcb_mem_size, - sinfo->dcb_mem, sinfo->dcb_dma); + sinfo->dcb_mem, (dma_addr_t)sinfo->dcb_dma); sinfo->dcb_mem = NULL; } } @@ -1484,6 +1753,7 @@ bkn_clean_rx_dcbs(bkn_switch_info_t *sinfo, int chan) } sinfo->rx[chan].running = 0; sinfo->rx[chan].api_active = 0; + sinfo->rx[chan].api_wait = 0; DBG_DCB_RX(("Cleaned Rx%d DCBs (%d %d).\n", chan, sinfo->rx[chan].cur, sinfo->rx[chan].dirty)); } @@ -1495,7 +1765,7 @@ bkn_clean_dcbs(bkn_switch_info_t *sinfo) bkn_clean_tx_dcbs(sinfo); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { bkn_clean_rx_dcbs(sinfo, chan); } } @@ -1505,7 +1775,7 @@ bkn_init_dcbs(bkn_switch_info_t *sinfo) { int dcb_size; uint32_t *dcb_mem; - dma_addr_t dcb_dma; + uint64_t dcb_dma; bkn_desc_info_t *desc; int idx; int chan; @@ -1518,10 +1788,20 @@ bkn_init_dcbs(bkn_switch_info_t *sinfo) for (idx = 0; idx < (MAX_TX_DCBS + 1); idx++) { if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { - dcb_mem[1] |= (1 << 24) | (1 << 16); + if (sinfo->cmic_type == 'x') { + dcb_mem[2] |= 1 << 24 | 1 << 16; + } else { + dcb_mem[1] |= 1 << 24 | 1 << 16; + } if (idx == MAX_TX_DCBS) { - dcb_mem[1] |= 1 << 18; - dcb_mem[0] = sinfo->tx.desc[0].dcb_dma; + if (sinfo->cmic_type == 'x') { + dcb_mem[0] = sinfo->tx.desc[0].dcb_dma; + dcb_mem[1] = DMA_TO_BUS_HI(sinfo->tx.desc[0].dcb_dma >> 32); + dcb_mem[2] |= 1 << 18; + } else { + dcb_mem[0] = sinfo->tx.desc[0].dcb_dma; + dcb_mem[1] |= 1 << 18; + } } } desc = &sinfo->tx.desc[idx]; @@ -1532,17 +1812,29 @@ bkn_init_dcbs(bkn_switch_info_t *sinfo) } sinfo->halt_addr[XGS_DMA_TX_CHAN] = sinfo->tx.desc[0].dcb_dma; sinfo->tx.free = MAX_TX_DCBS; + sinfo->tx.cur = 0; + sinfo->tx.dirty = 0; DBG_DCB_TX(("Tx DCBs @ 0x%08x.\n", (uint32_t)sinfo->tx.desc[0].dcb_dma)); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { for (idx = 0; idx < (MAX_RX_DCBS + 1); idx++) { if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { - dcb_mem[1] |= (1 << 24) | (1 << 16); + if (sinfo->cmic_type == 'x') { + dcb_mem[2] |= 1 << 24 | 1 << 16; + } else { + dcb_mem[1] |= 1 << 24 | 1 << 16; + } if (idx == MAX_RX_DCBS) { - dcb_mem[1] |= 1 << 18; - dcb_mem[0] = sinfo->rx[chan].desc[0].dcb_dma; + if (sinfo->cmic_type == 'x') { + dcb_mem[0] = sinfo->rx[chan].desc[0].dcb_dma; + dcb_mem[1] = DMA_TO_BUS_HI(sinfo->rx[chan].desc[0].dcb_dma >> 32); + dcb_mem[2] |= 1 << 18; + } else { + dcb_mem[0] = sinfo->rx[chan].desc[0].dcb_dma; + dcb_mem[1] |= 1 << 18; + } } } desc = &sinfo->rx[chan].desc[idx]; @@ -1553,6 +1845,8 @@ bkn_init_dcbs(bkn_switch_info_t *sinfo) } sinfo->halt_addr[XGS_DMA_RX_CHAN + chan] = sinfo->rx[chan].desc[MAX_RX_DCBS].dcb_dma; sinfo->rx[chan].free = 0; + sinfo->rx[chan].cur = 0; + sinfo->rx[chan].dirty = 0; DBG_DCB_RX(("Rx%d DCBs @ 0x%08x.\n", chan, (uint32_t)sinfo->rx[chan].desc[0].dcb_dma)); @@ -1563,13 +1857,23 @@ static void bkn_dump_dcb(char *prefix, uint32_t *dcb, int wsize, int txrx) { if (XGS_DMA_TX_CHAN == txrx) { - DBG_DCB_TX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x ... 0x%08x\n", - prefix, dcb[0], dcb[1], dcb[2], dcb[3], dcb[4], dcb[5], - dcb[wsize - 1])); + if (wsize > 4) { + DBG_DCB_TX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x ... 0x%08x\n", + prefix, dcb[0], dcb[1], dcb[2], dcb[3], dcb[4], dcb[5], + dcb[wsize - 1])); + } else { + DBG_DCB_TX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x\n", + prefix, dcb[0], dcb[1], dcb[2], dcb[3])); + } } else { - DBG_DCB_RX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x ... 0x%08x\n", - prefix, dcb[0], dcb[1], dcb[2], dcb[3], dcb[4], dcb[5], - dcb[wsize - 1])); + if (wsize > 4) { + DBG_DCB_RX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x ... 0x%08x\n", + prefix, dcb[0], dcb[1], dcb[2], dcb[3], dcb[4], dcb[5], + dcb[wsize - 1])); + } else { + DBG_DCB_RX(("%s: 0x%08x 0x%08x 0x%08x 0x%08x\n", + prefix, dcb[0], dcb[1], dcb[2], dcb[3])); + } } } @@ -1584,7 +1888,6 @@ bkn_dump_pkt(uint8_t *data, int size, int txrx) !(txrx == XGS_DMA_RX_CHAN && debug & DBG_LVL_PDMP_RX)) { return; } - size =32; for (idx = 0; idx < size; idx++) { if ((idx & 0xf) == 0) { @@ -1621,10 +1924,21 @@ bkn_sinfo_from_unit(int unit) } static void -bkn_api_rx_restart(bkn_switch_info_t *sinfo) +bkn_cdma_goto(bkn_switch_info_t *sinfo, int chan, uint64_t dcb) +{ + if (sinfo->basedev_suspended) { + return; + } + + /* Set the new halt location */ + sinfo->halt_addr[chan] = dcb; + dev_cdma_halt_set(sinfo, chan); +} + +static void +bkn_api_rx_restart(bkn_switch_info_t *sinfo, int chan) { bkn_dcb_chain_t *dcb_chain; - int chan = API_RX_CHAN; int start_dma; if (sinfo->basedev_suspended) { @@ -1645,7 +1959,7 @@ bkn_api_rx_restart(bkn_switch_info_t *sinfo) sinfo->rx[chan].chain_complete = 0; start_dma = 1; if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan) && - sinfo->rx[chan].api_active) { + sinfo->rx[chan].api_wait) { /* HW is running already, so we just move to the next chain */ start_dma = 0; } @@ -1657,8 +1971,8 @@ bkn_api_rx_restart(bkn_switch_info_t *sinfo) (uint32_t)dcb_chain->dcb_dma, dcb_chain->dcb_cnt)); dev_dma_chan_clear(sinfo, XGS_DMA_RX_CHAN + chan); dev_irq_mask_enable(sinfo, XGS_DMA_RX_CHAN + chan, 1); - dev_dma_chan_start(sinfo, XGS_DMA_RX_CHAN + chan, - dcb_chain->dcb_dma); + dev_dma_chan_start(sinfo, XGS_DMA_RX_CHAN + chan, dcb_chain->dcb_dma); + sinfo->rx[chan].api_wait = 1; } list_del(&dcb_chain->list); @@ -1677,7 +1991,7 @@ bkn_api_rx_chain_done(bkn_switch_info_t *sinfo, int chan) kfree(sinfo->rx[chan].api_dcb_chain); sinfo->rx[chan].api_dcb_chain = NULL; } - bkn_api_rx_restart(sinfo); + bkn_api_rx_restart(sinfo, chan); if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan) && sinfo->rx[chan].api_dcb_chain == NULL) { sinfo->rx[chan].api_active = 0; @@ -1692,6 +2006,7 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, uint32_t *dcb; uint32_t dcb_stat; uint8_t *pkt; + uint64_t pkt_dma; int pktlen; int i; bkn_evt_resource_t *evt; @@ -1711,11 +2026,18 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, return -1; } dcb = &dcb_chain->dcb_mem[dcb_chain->dcb_cur * sinfo->dcb_wsize]; - if (dcb[1] < pktlen) { + if ((sinfo->cmic_type == 'x' && (dcb[2] & 0xffff) < pktlen) || + (sinfo->cmic_type != 'x' && (dcb[1] & 0xffff) < pktlen)) { DBG_WARN(("Rx API buffer too small\n")); return -1; } - pkt = (uint8_t *)kernel_bde->p2l(sinfo->dev_no, dcb[0]); + if (sinfo->cmic_type == 'x') { + pkt_dma = BUS_TO_DMA_HI(dcb[1]); + pkt_dma = pkt_dma << 32 | dcb[0]; + } else { + pkt_dma = dcb[0]; + } + pkt = (uint8_t *)kernel_bde->p2l(sinfo->dev_no, (sal_paddr_t)pkt_dma); if (pkt == NULL) { DBG_WARN(("Invalid Rx API buffer\n")); return -1; @@ -1725,8 +2047,10 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, memcpy(pkt, desc->skb->data, pktlen); /* Copy packet metadata and mark as done */ - for (i = SOC_DCB_META_OFFSET; i < sinfo->dcb_wsize; i++) { - dcb[i] = desc->dcb_mem[i]; + if (sinfo->cmic_type != 'x') { + for (i = SOC_DCB_META_OFFSET; i < sinfo->dcb_wsize; i++) { + dcb[i] = desc->dcb_mem[i]; + } } dcb[sinfo->dcb_wsize-1] = dcb_stat | SOC_DCB_KNET_DONE; @@ -1734,9 +2058,10 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { dcb = &dcb_chain->dcb_mem[dcb_chain->dcb_cur * sinfo->dcb_wsize]; - if (dcb[1] & (1 << 18)) { + if ((sinfo->cmic_type == 'x' && dcb[2] & (1 << 18)) || + (sinfo->cmic_type != 'x' && dcb[1] & (1 << 18))) { /* Get the next chain if reload done */ - dcb[sinfo->dcb_wsize - 1] |= (1 << 31) | SOC_DCB_KNET_DONE; + dcb[sinfo->dcb_wsize-1] |= 1 << 31 | SOC_DCB_KNET_DONE; bkn_api_rx_chain_done(sinfo, chan); dcb_chain = sinfo->rx[chan].api_dcb_chain; if (dcb_chain == NULL) { @@ -1744,7 +2069,8 @@ bkn_api_rx_copy_from_skb(bkn_switch_info_t *sinfo, } } } else { - if ((dcb[1] & (1 << 16)) == 0) { + if ((sinfo->cmic_type == 'x' && (dcb[2] & (1 << 16)) == 0) || + (sinfo->cmic_type != 'x' && (dcb[1] & (1 << 16)) == 0)) { bkn_api_rx_chain_done(sinfo, chan); } } @@ -1764,6 +2090,7 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) struct sk_buff *skb; bkn_desc_info_t *desc; uint32_t *dcb; + uint32_t encap_size = sinfo->cmic_type == 'x' ? RCPU_HDR_SIZE : RCPU_RX_ENCAP_SIZE; int prev; if (sinfo->rx[chan].use_rx_skb == 0) { @@ -1780,11 +2107,11 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) while (sinfo->rx[chan].free < MAX_RX_DCBS) { desc = &sinfo->rx[chan].desc[sinfo->rx[chan].cur]; if (desc->skb == NULL) { - skb = dev_alloc_skb(rx_buffer_size + RCPU_RX_ENCAP_SIZE); + skb = dev_alloc_skb(rx_buffer_size + encap_size); if (skb == NULL) { break; } - skb_reserve(skb, RCPU_RX_ENCAP_SIZE); + skb_reserve(skb, encap_size); desc->skb = skb; } else { DBG_DCB_RX(("Refill Rx%d SKB in DCB %d recycled.\n", @@ -1809,21 +2136,44 @@ bkn_rx_refill(bkn_switch_info_t *sinfo, int chan) desc->skb_dma = DMA_MAP_SINGLE(sinfo->dma_dev, skb->data, desc->dma_size, DMA_FROMDEV); + if (DMA_MAPPING_ERROR(sinfo->dma_dev, desc->skb_dma)) { + dev_kfree_skb_any(skb); + desc->skb = NULL; + break; + } DBG_DCB_RX(("Refill Rx%d DCB %d (0x%08x).\n", chan, sinfo->rx[chan].cur, (uint32_t)desc->skb_dma)); dcb = desc->dcb_mem; - memset(dcb, 0, sizeof(uint32_t) * sinfo->dcb_wsize); dcb[0] = desc->skb_dma; - dcb[1] = rx_buffer_size; - if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { - dcb[1] |= (1 << 24) | (1 << 16); + if (sinfo->cmic_type == 'x') { + dcb[2] |= 1 << 24 | 1 << 16; + } else { + dcb[1] |= 1 << 24 | 1 << 16; + } } else { prev = PREV_IDX(sinfo->rx[chan].cur, MAX_RX_DCBS); if (prev < (MAX_RX_DCBS - 1)) { - sinfo->rx[chan].desc[prev].dcb_mem[1] |= (1 << 16); + if (sinfo->cmic_type == 'x') { + sinfo->rx[chan].desc[prev].dcb_mem[2] |= 1 << 16; + } else { + sinfo->rx[chan].desc[prev].dcb_mem[1] |= 1 << 16; + } } } + if (sinfo->cmic_type == 'x') { + dcb[1] = DMA_TO_BUS_HI(desc->skb_dma >> 32); + dcb[2] |= rx_buffer_size; + } else { + dcb[1] |= rx_buffer_size; + } + + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan) && + sinfo->rx[chan].tokens > MAX_RX_DCBS) { + /* DMA run to the new halt location */ + bkn_cdma_goto(sinfo, XGS_DMA_RX_CHAN + chan, desc->dcb_dma); + } + if (++sinfo->rx[chan].cur >= MAX_RX_DCBS) { sinfo->rx[chan].cur = 0; } @@ -1895,7 +2245,7 @@ bkn_dma_init(bkn_switch_info_t *sinfo) bkn_tx_dma_start(sinfo); } - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { dev_dma_chan_init(sinfo, XGS_DMA_RX_CHAN + chan, 0); bkn_rx_refill(sinfo, chan); bkn_rx_restart(sinfo, chan); @@ -1904,18 +2254,6 @@ bkn_dma_init(bkn_switch_info_t *sinfo) return 0; } -static void -bkn_cdma_goto(bkn_switch_info_t *sinfo, int chan, dma_addr_t dcb) -{ - if (sinfo->basedev_suspended) { - return; - } - - /* Set the new halt location */ - sinfo->halt_addr[chan] = dcb; - dev_cdma_halt_set(sinfo, chan); -} - static int bkn_dma_abort_tx(bkn_switch_info_t *sinfo) { @@ -1934,7 +2272,7 @@ bkn_dma_abort_tx(bkn_switch_info_t *sinfo) } while (!list_empty(&sinfo->tx.api_dcb_list)) { dcb_chain = list_entry(sinfo->tx.api_dcb_list.next, - bkn_dcb_chain_t, list); + bkn_dcb_chain_t, list); list_del(&dcb_chain->list); DBG_DCB_TX(("Freeing Tx DCB chain.\n")); kfree(dcb_chain); @@ -1962,7 +2300,7 @@ bkn_dma_abort_rx(bkn_switch_info_t *sinfo, int chan) } while (!list_empty(&sinfo->rx[chan].api_dcb_list)) { dcb_chain = list_entry(sinfo->rx[chan].api_dcb_list.next, - bkn_dcb_chain_t, list); + bkn_dcb_chain_t, list); list_del(&dcb_chain->list); DBG_DCB_RX(("Freeing Rx%d DCB chain.\n", chan)); kfree(dcb_chain); @@ -1979,7 +2317,7 @@ bkn_dma_abort(bkn_switch_info_t *sinfo) bkn_dma_abort_tx(sinfo); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { bkn_dma_abort_rx(sinfo, chan); } @@ -1987,13 +2325,13 @@ bkn_dma_abort(bkn_switch_info_t *sinfo) } static bkn_filter_t * -bkn_match_rx_pkt(bkn_switch_info_t *sinfo, uint32_t *desc, - uint8_t *pkt, int chan, bkn_filter_t *cbf) +bkn_match_rx_pkt(bkn_switch_info_t *sinfo, uint8_t *pkt, int pktlen, + void *meta, int chan, bkn_filter_t *cbf) { struct list_head *list; bkn_filter_t *filter; kcom_filter_t scratch, *kf; - uint8_t *oob = (uint8_t *)desc; + uint8_t *oob = (uint8_t *)meta; int size, wsize; int idx, match; @@ -2010,7 +2348,7 @@ bkn_match_rx_pkt(bkn_switch_info_t *sinfo, uint32_t *desc, size, wsize, kf->data.w[0], kf->mask.w[0])); match = 1; if (match) { - if (kf->priority < (num_rx_prio * NUM_RX_CHAN)) { + if (kf->priority < (num_rx_prio * sinfo->rx_chans)) { if (kf->priority < (num_rx_prio * chan) || kf->priority >= (num_rx_prio * (chan + 1))) { match = 0; @@ -2030,11 +2368,10 @@ bkn_match_rx_pkt(bkn_switch_info_t *sinfo, uint32_t *desc, if (kf->dest_type == KCOM_DEST_T_CB) { /* Check for custom filters */ if (knet_filter_cb != NULL && cbf != NULL) { - size = desc[sinfo->dcb_wsize-1] & SOC_DCB_KNET_COUNT_MASK; memset(cbf, 0, sizeof(*cbf)); memcpy(&cbf->kf, kf, sizeof(cbf->kf)); - if (knet_filter_cb(pkt, size, sinfo->dev_no, - desc, chan, &cbf->kf)) { + if (knet_filter_cb(pkt, pktlen, sinfo->dev_no, + meta, chan, &cbf->kf)) { filter->hits++; return cbf; } @@ -2083,18 +2420,25 @@ bkn_netif_lookup(bkn_switch_info_t *sinfo, int id) } static int -bkn_add_rcpu_encap(bkn_switch_info_t *sinfo, struct sk_buff *skb, uint32_t *dcb) +bkn_add_rcpu_encap(bkn_switch_info_t *sinfo, struct sk_buff *skb, void *meta) { int pktlen = skb->len; - uint32_t *metadata; + uint32_t *dmeta, *smeta, wsize, psize; int idx; /* Add and clear RCPU encapsulation */ - skb_push(skb, RCPU_RX_ENCAP_SIZE); - memset(skb->data, 0, RCPU_RX_ENCAP_SIZE); + if (sinfo->cmic_type == 'x') { + psize = RCPU_HDR_SIZE + sinfo->pkt_hdr_size; + skb_push(skb, psize); + memset(skb->data, 0, RCPU_HDR_SIZE); + } else { + psize = RCPU_RX_ENCAP_SIZE; + skb_push(skb, psize); + memset(skb->data, 0, RCPU_RX_ENCAP_SIZE); + } /* RCPU Header */ - memcpy(skb->data, &skb->data[RCPU_RX_ENCAP_SIZE], 12); + memcpy(skb->data, &skb->data[psize], 12); if (rcpu_dmac != NULL) { memcpy(skb->data, bkn_rcpu_dmac, 6); } @@ -2114,9 +2458,11 @@ bkn_add_rcpu_encap(bkn_switch_info_t *sinfo, struct sk_buff *skb, uint32_t *dcb) skb->data[25] = pktlen & 0xff; /* Meta data */ - metadata = (uint32_t *)&skb->data[RCPU_HDR_SIZE]; - for (idx = 0; idx < sinfo->dcb_wsize - 3; idx++) { - metadata[idx] = htonl(dcb[idx+2]); + dmeta = (uint32_t *)&skb->data[RCPU_HDR_SIZE]; + smeta = sinfo->cmic_type == 'x' ? (uint32_t *)meta : (uint32_t *)meta + 2; + wsize = sinfo->cmic_type == 'x' ? sinfo->pkt_hdr_size / 4 : sinfo->dcb_wsize - 3; + for (idx = 0; idx < wsize; idx++) { + dmeta[idx] = htonl(smeta[idx]); } return 0; @@ -2134,8 +2480,6 @@ bkn_eth_type_update(struct sk_buff *skb, int ethertype) #endif } - - #define BKN_DNX_BIT(x) (1<<(x)) #define BKN_DNX_RBIT(x) (~(1<<(x))) #ifdef __LITTLE_ENDIAN @@ -2143,6 +2487,7 @@ bkn_eth_type_update(struct sk_buff *skb, int ethertype) #else #define BKN_DNX_BYTE_SWAP(x) ((((x) << 24)) | (((x) & 0xff00) << 8) | (((x) & 0xff0000) >> 8) | (((x) >> 24))) #endif + static int device_is_dune(bkn_switch_info_t *sinfo) { @@ -2151,6 +2496,7 @@ device_is_dune(bkn_switch_info_t *sinfo) is_dune = (sinfo->dcb_type == 28) ? 1 : 0; return is_dune; } + static int packet_is_untagged(uint16_t tpid) { @@ -2241,7 +2587,7 @@ bkn_dnx_bitstream_get_field(uint8_t *input_buffer, uint32_t start_bit, uint32_t } static void -bkn_dnx_packet_parse_ftmh(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) +bkn_dnx_packet_parse_ftmh(bkn_switch_info_t *sinfo, uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) { uint32_t header_ptr = 0; uint32_t dsp_ext_exist=0; @@ -2291,7 +2637,7 @@ bkn_dnx_packet_parse_ftmh(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) packet_info->ftmh.pph_type, packet_info->ftmh.src_sys_port, packet_info->ftmh.prio)); /* LB-Key ext */ - if (ftmh_lb_key_ext) + if ((sinfo->pkt_hdr_size & BKN_DNX_FTMH_LB_EXT_EN) == BKN_DNX_FTMH_LB_EXT_EN) { packet_info->ntwrk_header_ptr += BKN_DNX_FTMH_LB_EXT_SIZE_BYTE; DBG_DUNE(("FTMH(%d) FTMH LB-Key Extension is present\n", packet_info->ntwrk_header_ptr)); @@ -2306,10 +2652,11 @@ bkn_dnx_packet_parse_ftmh(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) if (dsp_ext_exist) { packet_info->ntwrk_header_ptr += BKN_DNX_FTMH_DEST_EXT_SIZE_BYTE; - DBG_DUNE(("FTMH(%d) DSP Extension is present\n", packet_info->ntwrk_header_ptr)); + DBG_DUNE(("FTMH(%d) DSP-extension-present 1\n", packet_info->ntwrk_header_ptr)); } + /* stacking ext */ - if (ftmh_stacking_ext) + if ((sinfo->pkt_hdr_size & BKN_DNX_FTMH_STACKING_EXT_EN) == BKN_DNX_FTMH_STACKING_EXT_EN) { packet_info->ntwrk_header_ptr += BKN_DNX_FTMH_STACKING_SIZE_BYTE; DBG_DUNE(("FTMH(%d) FTMH Stacking Extension is present\n", packet_info->ntwrk_header_ptr)); @@ -2318,7 +2665,7 @@ bkn_dnx_packet_parse_ftmh(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) } static void -bkn_dnx_packet_parse_internal(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) +bkn_dnx_packet_parse_internal(bkn_switch_info_t *sinfo, uint8_t hdr_buff[], bkn_dnx_packet_info *packet_info) { uint32_t header_ptr = 0; uint32_t fld_val; @@ -2410,7 +2757,7 @@ bkn_dnx_packet_parse_internal(uint8_t hdr_buff[], bkn_dnx_packet_info *packet_in } static int -bkn_dnx_packet_header_parse(uint8 *buff, uint32_t buff_len, bkn_dnx_packet_info *packet_info) +bkn_dnx_packet_header_parse(bkn_switch_info_t *sinfo, uint8 *buff, uint32_t buff_len, bkn_dnx_packet_info *packet_info) { uint8_t hdr_buff[BKN_DNX_HDR_MAX_SIZE]; uint32_t hdr_size; @@ -2423,7 +2770,7 @@ bkn_dnx_packet_header_parse(uint8 *buff, uint32_t buff_len, bkn_dnx_packet_info memcpy(hdr_buff, buff, hdr_size); /* FTMH */ - bkn_dnx_packet_parse_ftmh(hdr_buff, packet_info); + bkn_dnx_packet_parse_ftmh(sinfo, hdr_buff, packet_info); if (packet_info->ftmh.packet_size != (buff_len + 2)) { DBG_DUNE(("FTMH packet size verfication failed, %d-%d\n", packet_info->ftmh.packet_size, buff_len)); memset(packet_info, 0, sizeof(bkn_dnx_packet_info)); @@ -2448,7 +2795,7 @@ bkn_dnx_packet_header_parse(uint8 *buff, uint32_t buff_len, bkn_dnx_packet_info } if (has_internal) { - bkn_dnx_packet_parse_internal(&hdr_buff[0], packet_info); + bkn_dnx_packet_parse_internal(sinfo, &hdr_buff[0], packet_info); } /* FIXME: */ @@ -2465,15 +2812,16 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) struct sk_buff *skb; bkn_filter_t cbf; bkn_filter_t *filter; - uint32_t *dcb; + uint32_t err_woff; + uint32_t *dcb, *meta; uint8_t *pkt; + uint64_t pkt_dma; + int drop_api; int ethertype; int pktlen; - int drop_api; int idx; - int dcbs_done; + int dcbs_done = 0; bkn_dnx_packet_info packet_info = {0}; - dcbs_done = 0; dcb_chain = sinfo->rx[chan].api_dcb_chain; if (dcb_chain == NULL) { @@ -2493,8 +2841,9 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) if (dcbs_done >= budget) { break; } - if (dcb[1] & (1 << 18)) { - dcb[sinfo->dcb_wsize - 1] |= SOC_DCB_KNET_DONE; + if ((sinfo->cmic_type == 'x' && dcb[2] & (1 << 18)) || + (sinfo->cmic_type != 'x' && dcb[1] & (1 << 18))) { + dcb[sinfo->dcb_wsize-1] |= SOC_DCB_KNET_DONE; bkn_api_rx_chain_done(sinfo, chan); dcb_chain = sinfo->rx[chan].api_dcb_chain; if (dcb_chain == NULL) { @@ -2503,13 +2852,28 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) continue; } } - if ((dcb[1] & (1 << 16)) == 0) { + if ((sinfo->cmic_type == 'x' && (dcb[2] & (1 << 16)) == 0) || + (sinfo->cmic_type != 'x' && (dcb[1] & (1 << 16)) == 0)) { sinfo->rx[chan].chain_complete = 1; } sinfo->rx[chan].pkts++; - pkt = (uint8_t *)kernel_bde->p2l(sinfo->dev_no, dcb[0]); + if (sinfo->cmic_type == 'x') { + pkt_dma = BUS_TO_DMA_HI(dcb[1]); + pkt_dma = pkt_dma << 32 | dcb[0]; + } else { + pkt_dma = dcb[0]; + } + pkt = (uint8_t *)kernel_bde->p2l(sinfo->dev_no, (sal_paddr_t)pkt_dma); + if (sinfo->cmic_type == 'x') { + meta = (uint32_t *)pkt; + err_woff = sinfo->pkt_hdr_size / sizeof(uint32_t) - 1; + meta[err_woff] = dcb[sinfo->dcb_wsize-1]; + } else { + meta = dcb; + err_woff = sinfo->dcb_wsize - 1; + } pktlen = dcb[sinfo->dcb_wsize-1] & SOC_DCB_KNET_COUNT_MASK; - bkn_dump_pkt(pkt, 32, XGS_DMA_RX_CHAN); + bkn_dump_pkt(pkt, pktlen, XGS_DMA_RX_CHAN); if (device_is_dune(sinfo)) { uint16_t tpid = 0; @@ -2517,7 +2881,7 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) int res = -1; memset(&packet_info, 0, sizeof(bkn_dnx_packet_info)); - res = bkn_dnx_packet_header_parse(pkt, (uint32_t)pktlen, &packet_info); + res = bkn_dnx_packet_header_parse(sinfo, pkt, (uint32_t)pktlen, &packet_info); if (res == 0) { if (packet_info.ftmh.action_type == 0x2) { bkn_dnx_bitstream_set_field((uint32_t *)dcb, 192, 32, 0x8); @@ -2552,10 +2916,17 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) } } } - filter = bkn_match_rx_pkt(sinfo, dcb, pkt, chan, &cbf); - if ((dcb[sinfo->dcb_wsize-1] & 0x70000) != 0x30000) { + + if (device_is_dune(sinfo)) { + filter = bkn_match_rx_pkt(sinfo, pkt, pktlen + packet_info.ntwrk_header_ptr, + dcb, chan, &cbf); + } else { + filter = bkn_match_rx_pkt(sinfo, pkt + sinfo->pkt_hdr_size, + pktlen - sinfo->pkt_hdr_size, meta, chan, &cbf); + } + if ((dcb[sinfo->dcb_wsize-1] & 0xf0000) != 0x30000) { /* Fragment or error */ - if (filter && filter->kf.mask.w[sinfo->dcb_wsize-1] == 0) { + if (filter && filter->kf.mask.w[err_woff] == 0) { /* Drop unless DCB status is part of filter */ filter = NULL; } @@ -2578,6 +2949,11 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) break; } + if (sinfo->cmic_type == 'x') { + pkt += sinfo->pkt_hdr_size; + pktlen -= sinfo->pkt_hdr_size; + } + /* Add 2 bytes for IP header alignment (see below) */ skb = dev_alloc_skb(pktlen + RCPU_RX_ENCAP_SIZE + 2); if (skb == NULL) { @@ -2606,6 +2982,18 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) pktlen -= 4; pkt += 4; } + } else { + /* + * Mark packet as VLAN-tagged, otherwise newer + * kernels will strip the tag. + */ + uint16_t tci = (pkt[14] << 8) | pkt[15]; + if (priv->flags & KCOM_NETIF_F_RCPU_ENCAP) { + bkn_vlan_hwaccel_put_tag(skb, ETH_P_8021Q, tci); + } else { + bkn_vlan_hwaccel_put_tag(skb, + ((skb->data[12] << 8) | skb->data[13]), tci); + } } } @@ -2617,14 +3005,14 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) skb_put(skb, pktlen - 4); /* Strip CRC */ } priv->stats.rx_packets++; - priv->stats.rx_bytes += pktlen; + priv->stats.rx_bytes += skb->len; /* Optional SKB updates */ if (knet_rx_cb != NULL) { KNET_SKB_CB(skb)->netif_user_data = priv->cb_user_data; KNET_SKB_CB(skb)->filter_user_data = filter->kf.cb_user_data; KNET_SKB_CB(skb)->dcb_type = sinfo->dcb_type & 0xFFFF; - skb = knet_rx_cb(skb, sinfo->dev_no, dcb); + skb = knet_rx_cb(skb, sinfo->dev_no, meta); if (skb == NULL) { /* Consumed by call-back */ sinfo->rx[chan].pkts_d_callback++; @@ -2633,7 +3021,9 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) } if (priv->flags & KCOM_NETIF_F_RCPU_ENCAP) { - bkn_add_rcpu_encap(sinfo, skb, dcb); + bkn_add_rcpu_encap(sinfo, skb, meta); + DBG_PDMP(("After add RCPU ENCAP\n")); + bkn_dump_pkt(skb->data, pktlen + RCPU_RX_ENCAP_SIZE, XGS_DMA_RX_CHAN); } skb->protocol = eth_type_trans(skb, skb->dev); if (filter->kf.dest_proto) { @@ -2672,6 +3062,9 @@ bkn_do_api_rx(bkn_switch_info_t *sinfo, int chan, int budget) sinfo->rx[chan].pkts_d_unkn_dest++; break; } + } else { + DBG_PKT(("Rx packet dropped.\n")); + sinfo->rx[chan].pkts_d_no_match++; } if (drop_api) { /* If count is zero, the DCB will just be recycled */ @@ -2693,14 +3086,13 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) struct sk_buff *skb; bkn_filter_t cbf; bkn_filter_t *filter; - uint32_t *dcb; + uint32_t err_woff; + uint32_t *dcb, *meta; int ethertype; - int dcbs_done; int pktlen; - bkn_dnx_packet_info packet_info = {0}; int idx; - - dcbs_done = 0; + int dcbs_done = 0; + bkn_dnx_packet_info packet_info = {0}; if (!sinfo->rx[chan].running) { /* Rx not ready */ @@ -2716,11 +3108,8 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) if ((dcb[sinfo->dcb_wsize-1] & (1 << 31)) == 0) { break; } - if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { - /* DMA run to the new halt location */ - bkn_cdma_goto(sinfo, XGS_DMA_RX_CHAN + chan, desc->dcb_dma); - } - if ((dcb[1] & (1 << 16)) == 0) { + if ((sinfo->cmic_type == 'x' && (dcb[2] & (1 << 16)) == 0) || + (sinfo->cmic_type != 'x' && (dcb[1] & (1 << 16)) == 0)) { sinfo->rx[chan].chain_complete = 1; /* Request one extra poll to check for chain done interrupt */ if (sinfo->napi_poll_mode) { @@ -2728,15 +3117,24 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) } } sinfo->rx[chan].pkts++; + skb = desc->skb; + if (sinfo->cmic_type == 'x') { + meta = (uint32_t *)skb->data; + err_woff = sinfo->pkt_hdr_size / sizeof(uint32_t) - 1; + meta[err_woff] = dcb[sinfo->dcb_wsize-1]; + } else { + meta = dcb; + err_woff = sinfo->dcb_wsize - 1; + } pktlen = dcb[sinfo->dcb_wsize-1] & 0xffff; priv = netdev_priv(sinfo->dev); - skb = desc->skb; DBG_DCB_RX(("Rx%d SKB DMA done (%d).\n", chan, sinfo->rx[chan].dirty)); DMA_UNMAP_SINGLE(sinfo->dma_dev, desc->skb_dma, desc->dma_size, DMA_FROMDEV); desc->skb_dma = 0; - bkn_dump_pkt(skb->data, 32, XGS_DMA_RX_CHAN); + bkn_dump_pkt(skb->data, pktlen, XGS_DMA_RX_CHAN); + if (device_is_dune(sinfo)) { uint16_t tpid = 0; uint16_t vid = 0; @@ -2744,7 +3142,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) int res = 0; memset(&packet_info, 0, sizeof(bkn_dnx_packet_info)); - res = bkn_dnx_packet_header_parse(pkt, (uint32_t)pktlen, &packet_info); + res = bkn_dnx_packet_header_parse(sinfo, pkt, (uint32_t)pktlen, &packet_info); if (res == 0) { if (packet_info.ftmh.action_type == 0x2) { bkn_dnx_bitstream_set_field((uint32_t *)dcb, 192, 32, 0x8); @@ -2777,28 +3175,34 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) } } } + if (device_is_dune(sinfo)) { - filter = bkn_match_rx_pkt(sinfo, dcb, (skb->data + packet_info.ntwrk_header_ptr), chan, &cbf); + filter = bkn_match_rx_pkt(sinfo, skb->data + packet_info.ntwrk_header_ptr, + pktlen, dcb, chan, &cbf); } else { - filter = bkn_match_rx_pkt(sinfo, dcb, skb->data, chan, &cbf); + filter = bkn_match_rx_pkt(sinfo, skb->data + sinfo->pkt_hdr_size, + pktlen - sinfo->pkt_hdr_size, meta, chan, &cbf); } - if ((dcb[sinfo->dcb_wsize-1] & 0x70000) == 0x30000) { - DBG_PKT(("Rx packet (%d bytes).\n", pktlen)); - } else { + if ((dcb[sinfo->dcb_wsize-1] & 0xf0000) != 0x30000) { /* Fragment or error */ priv->stats.rx_errors++; - if (filter && filter->kf.mask.w[sinfo->dcb_wsize-1] == 0) { + if (filter && filter->kf.mask.w[err_woff] == 0) { /* Drop unless DCB status is part of filter */ filter = NULL; } } + DBG_PKT(("Rx packet (%d bytes).\n", pktlen)); if (filter) { DBG_FLTR(("Match filter ID %d\n", filter->kf.id)); switch (filter->kf.dest_type) { case KCOM_DEST_T_API: DBG_FLTR(("Send to Rx API\n")); sinfo->rx[chan].pkts_f_api++; - bkn_api_rx_copy_from_skb(sinfo, chan, desc); + if (bkn_api_rx_copy_from_skb(sinfo, chan, desc) < 0) { + /* Suspend SKB Rx due to no API resources */ + sinfo->rx[chan].api_wait = 1; + return dcbs_done; + } break; case KCOM_DEST_T_NETIF: priv = bkn_netif_lookup(sinfo, filter->kf.dest_id); @@ -2812,6 +3216,12 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) priv->id, priv->dev->name)); sinfo->rx[chan].pkts_f_netif++; + if (((filter->kf.mirror_type == KCOM_DEST_T_API) && + (!device_is_dune(sinfo))) || dbg_pkt_enable) { + sinfo->rx[chan].pkts_m_api++; + bkn_api_rx_copy_from_skb(sinfo, chan, desc); + } + if (device_is_dune(sinfo)) { if (filter->kf.mirror_type == KCOM_DEST_T_API) { sinfo->rx[chan].pkts_m_api++; @@ -2827,9 +3237,12 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) skb_put(skb, pktlen - 4); /* Strip CRC */ } + if (sinfo->cmic_type == 'x') { + skb_pull(skb, sinfo->pkt_hdr_size); + } + /* Save for RCPU before stripping tag */ ethertype = (skb->data[16] << 8) | skb->data[17]; - if ((priv->flags & KCOM_NETIF_F_KEEP_RX_TAG) == 0) { if (filter->kf.flags & KCOM_FILTER_F_STRIP_TAG) { /* Strip VLAN tag */ @@ -2840,12 +3253,29 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) ((u32*)skb->data)[2] = ((u32*)skb->data)[1]; ((u32*)skb->data)[1] = ((u32*)skb->data)[0]; skb_pull(skb, 4); - pktlen -= 4; + if (sinfo->cmic_type == 'x') { + for (idx = sinfo->pkt_hdr_size / sizeof(uint32_t); idx; idx--) { + meta[idx] = meta[idx - 1]; + } + meta++; + } + } + } else { + /* + * Mark packet as VLAN-tagged, otherwise newer + * kernels will strip the tag. + */ + uint16_t tci = (skb->data[14] << 8) | skb->data[15]; + if (priv->flags & KCOM_NETIF_F_RCPU_ENCAP) { + bkn_vlan_hwaccel_put_tag(skb, ETH_P_8021Q, tci); + } else { + bkn_vlan_hwaccel_put_tag(skb, + ((skb->data[12] << 8) | skb->data[13]), tci); } } } priv->stats.rx_packets++; - priv->stats.rx_bytes += pktlen; + priv->stats.rx_bytes += skb->len; skb->dev = priv->dev; /* Optional SKB updates */ @@ -2853,25 +3283,20 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) KNET_SKB_CB(skb)->netif_user_data = priv->cb_user_data; KNET_SKB_CB(skb)->filter_user_data = filter->kf.cb_user_data; KNET_SKB_CB(skb)->dcb_type = sinfo->dcb_type & 0xFFFF; - skb = knet_rx_cb(skb, sinfo->dev_no, dcb); + skb = knet_rx_cb(skb, sinfo->dev_no, meta); if (skb == NULL) { /* Consumed by call-back */ sinfo->rx[chan].pkts_d_callback++; priv->stats.rx_dropped++; desc->skb = NULL; - desc->skb_dma = 0; break; } } - if (((filter->kf.mirror_type == KCOM_DEST_T_API) && - (!device_is_dune(sinfo))) || dbg_pkt_enable) { - sinfo->rx[chan].pkts_m_api++; - bkn_api_rx_copy_from_skb(sinfo, chan, desc); - } - if (priv->flags & KCOM_NETIF_F_RCPU_ENCAP) { - bkn_add_rcpu_encap(sinfo, skb, dcb); + bkn_add_rcpu_encap(sinfo, skb, meta); + DBG_PDMP(("After add RCPU ENCAP\n")); + bkn_dump_pkt(skb->data, pktlen + RCPU_RX_ENCAP_SIZE, XGS_DMA_RX_CHAN); } skb->protocol = eth_type_trans(skb, skb->dev); if (filter->kf.dest_proto) { @@ -2881,6 +3306,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) bkn_eth_type_update(skb, ethertype); } DBG_DUNE(("skb protocol 0x%04x\n",skb->protocol)); + if (filter->kf.mirror_type == KCOM_DEST_T_NETIF) { bkn_priv_t *mpriv; struct sk_buff *mskb; @@ -2892,11 +3318,11 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) } else { sinfo->rx[chan].pkts_m_netif++; mpriv->stats.rx_packets++; - mpriv->stats.rx_bytes += pktlen; + mpriv->stats.rx_bytes += mskb->len; skb->dev = mpriv->dev; if (filter->kf.mirror_proto) { skb->protocol = filter->kf.mirror_proto; - } + } /* Unlock while calling up network stack */ spin_unlock(&sinfo->lock); if (use_napi) { @@ -2907,7 +3333,7 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) spin_lock(&sinfo->lock); } } - } + } /* Unlock while calling up network stack */ spin_unlock(&sinfo->lock); @@ -2920,19 +3346,25 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) /* Ensure that we reallocate SKB for this DCB */ desc->skb = NULL; - desc->skb_dma = 0; } else { DBG_FLTR(("Unknown netif %d\n", filter->kf.dest_id)); sinfo->rx[chan].pkts_d_unkn_netif++; } + break; + default: + /* Drop packet */ + DBG_FLTR(("Unknown dest type %d\n", + filter->kf.dest_type)); + sinfo->rx[chan].pkts_d_unkn_dest++; + break; } } else { DBG_PKT(("Rx packet dropped.\n")); sinfo->rx[chan].pkts_d_no_match++; priv->stats.rx_dropped++; } - dcb[sinfo->dcb_wsize-1] = 0; + dcb[sinfo->dcb_wsize-1] &= ~(1 << 31); if (++sinfo->rx[chan].dirty >= MAX_RX_DCBS) { sinfo->rx[chan].dirty = 0; } @@ -2941,9 +3373,6 @@ bkn_do_skb_rx(bkn_switch_info_t *sinfo, int chan, int budget) if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { /* Right now refill for Continuous DMA mode */ bkn_rx_refill(sinfo, chan); - if (sinfo->rx[chan].tokens < MAX_RX_DCBS) { - break; - } } } @@ -2979,6 +3408,10 @@ bkn_rx_desc_done(bkn_switch_info_t *sinfo, int chan) static void bkn_rx_chain_done(bkn_switch_info_t *sinfo, int chan) { + if (sinfo->rx[chan].use_rx_skb && sinfo->rx[chan].api_wait) { + return; + } + DBG_IRQ(("Rx%d chain done\n", chan)); if (sinfo->rx[chan].chain_complete == 0) { @@ -3014,7 +3447,7 @@ bkn_rx_chain_done(bkn_switch_info_t *sinfo, int chan) bkn_api_rx_chain_done(sinfo, chan); } else { bkn_rx_refill(sinfo, chan); - + if (bkn_rx_restart(sinfo, chan) != 0) { /* Presumably out of resources */ sinfo->timer.expires = jiffies + 1; @@ -3091,7 +3524,7 @@ bkn_do_tx(bkn_switch_info_t *sinfo) desc->skb = NULL; desc->skb_dma = 0; } - desc->dcb_mem[sinfo->dcb_wsize-1] = 0; + desc->dcb_mem[sinfo->dcb_wsize-1] &= ~(1 << 31); if (++sinfo->tx.dirty >= MAX_TX_DCBS) { sinfo->tx.dirty = 0; } @@ -3109,7 +3542,7 @@ bkn_tx_cdma_chain_switch(bkn_switch_info_t *sinfo) { bkn_dcb_chain_t *dcb_chain = sinfo->tx.api_dcb_chain; uint32_t *dcb_mem; - dma_addr_t dcb_dma; + uint64_t dcb_dma; int woffset; /* Switch between SKB Tx and API Tx for Continuous DMA mode */ @@ -3122,7 +3555,12 @@ bkn_tx_cdma_chain_switch(bkn_switch_info_t *sinfo) dcb_mem = sinfo->tx.desc[sinfo->tx.cur].dcb_mem; memset(dcb_mem, 0, sinfo->dcb_wsize * sizeof(uint32_t)); dcb_mem[0] = dcb_chain->dcb_dma; - dcb_mem[1] |= (1 << 24) | (1 << 18) | (1 << 16); + if (sinfo->cmic_type == 'x') { + dcb_mem[1] = DMA_TO_BUS_HI(dcb_chain->dcb_dma >> 32); + dcb_mem[2] |= 1 << 24 | 1 << 18 | 1 << 16; + } else { + dcb_mem[1] |= 1 << 24 | 1 << 18 | 1 << 16; + } if (++sinfo->tx.cur >= MAX_TX_DCBS) { sinfo->tx.cur = 0; } @@ -3137,6 +3575,9 @@ bkn_tx_cdma_chain_switch(bkn_switch_info_t *sinfo) woffset = (dcb_chain->dcb_cnt - 1) * sinfo->dcb_wsize; dcb_mem = &dcb_chain->dcb_mem[woffset]; dcb_mem[0] = sinfo->tx.desc[sinfo->tx.dirty].dcb_dma; + if (sinfo->cmic_type == 'x') { + dcb_mem[1] = DMA_TO_BUS_HI(sinfo->tx.desc[sinfo->tx.dirty].dcb_dma >> 32); + } dcb_dma = sinfo->tx.desc[sinfo->tx.cur].dcb_dma; /* DMA run to the new halt location */ bkn_cdma_goto(sinfo, XGS_DMA_TX_CHAN, dcb_dma); @@ -3156,6 +3597,10 @@ static void bkn_api_tx(bkn_switch_info_t *sinfo) { bkn_dcb_chain_t *dcb_chain; + uint64_t pkt_dma; + unsigned char *pktdata; + int pktlen; + int i; /* Assume that driver lock is held */ if (list_empty(&sinfo->tx.api_dcb_list)) { @@ -3166,6 +3611,24 @@ bkn_api_tx(bkn_switch_info_t *sinfo) bkn_dcb_chain_t, list); DBG_DCB_TX(("Start API Tx DMA, first DCB @ 0x%08x (%d DCBs).\n", (uint32_t)dcb_chain->dcb_dma, dcb_chain->dcb_cnt)); + for (i = 0; i < dcb_chain->dcb_cnt && debug & DBG_LVL_PDMP; i++) { + if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN) && i == dcb_chain->dcb_cnt - 1) { + break; + } + if (sinfo->cmic_type == 'x') { + pkt_dma = BUS_TO_DMA_HI(dcb_chain->dcb_mem[sinfo->dcb_wsize * i + 1]); + pkt_dma = pkt_dma << 32 | dcb_chain->dcb_mem[sinfo->dcb_wsize * i]; + } else { + pkt_dma = dcb_chain->dcb_mem[sinfo->dcb_wsize * i]; + } + pktdata = kernel_bde->p2l(sinfo->dev_no, pkt_dma); + if (sinfo->cmic_type == 'x') { + pktlen = dcb_chain->dcb_mem[sinfo->dcb_wsize * i + 2] & 0xffff; + } else { + pktlen = dcb_chain->dcb_mem[sinfo->dcb_wsize * i + 1] & 0xffff; + } + bkn_dump_pkt(pktdata, pktlen, XGS_DMA_TX_CHAN); + } if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { sinfo->tx.api_dcb_chain = dcb_chain; @@ -3178,8 +3641,7 @@ bkn_api_tx(bkn_switch_info_t *sinfo) sinfo->tx.api_active = 1; dev_dma_chan_clear(sinfo, XGS_DMA_TX_CHAN); dev_irq_mask_enable(sinfo, XGS_DMA_TX_CHAN, 1); - dev_dma_chan_start(sinfo, XGS_DMA_TX_CHAN, - dcb_chain->dcb_dma); + dev_dma_chan_start(sinfo, XGS_DMA_TX_CHAN, dcb_chain->dcb_dma); list_del(&dcb_chain->list); kfree(dcb_chain); } @@ -3193,18 +3655,23 @@ bkn_tx_cdma_chain_done(bkn_switch_info_t *sinfo, int done) int dcbs_done = 0; bkn_evt_resource_t *evt; + DBG_IRQ(("Tx CDMA chain done \n")); + evt = &_bkn_evt[sinfo->evt_idx]; + if (sinfo->tx.api_active) { - sinfo->dma_events |= KCOM_DMA_INFO_F_TX_DONE; - evt->evt_wq_put++; - wake_up_interruptible(&evt->evt_wq); /* Drain API Tx chains */ while (sinfo->tx.api_dcb_chain != sinfo->tx.api_dcb_chain_end) { woffset = sinfo->tx.api_dcb_chain->dcb_cnt * sinfo->dcb_wsize - 1; if (!(sinfo->tx.api_dcb_chain->dcb_mem[woffset] & (1 << 31))) { return; } + sinfo->tx.api_dcb_chain->dcb_mem[woffset - sinfo->dcb_wsize] |= SOC_DCB_KNET_DONE; + sinfo->dma_events |= KCOM_DMA_INFO_F_TX_DONE; + evt->evt_wq_put++; + wake_up_interruptible(&evt->evt_wq); kfree(sinfo->tx.api_dcb_chain); + sinfo->tx.api_dcb_chain = NULL; bkn_api_tx(sinfo); if ((++dcbs_done + done) >= MAX_TX_DCBS) { if (sinfo->napi_poll_mode) { @@ -3221,8 +3688,12 @@ bkn_tx_cdma_chain_done(bkn_switch_info_t *sinfo, int done) if (!(sinfo->tx.api_dcb_chain->dcb_mem[woffset] & (1 << 31))) { return; } + sinfo->tx.api_dcb_chain->dcb_mem[woffset] |= SOC_DCB_KNET_DONE; /* Try and park at SKB Tx if API Tx done */ bkn_skb_tx(sinfo); + sinfo->dma_events |= KCOM_DMA_INFO_F_TX_DONE; + evt->evt_wq_put++; + wake_up_interruptible(&evt->evt_wq); kfree(sinfo->tx.api_dcb_chain); sinfo->tx.api_dcb_chain = NULL; sinfo->tx.api_dcb_chain_end = NULL; @@ -3251,16 +3722,16 @@ bkn_tx_chain_done(bkn_switch_info_t *sinfo, int done) int idx, pending; bkn_evt_resource_t *evt; - evt = &_bkn_evt[sinfo->evt_idx]; - - DBG_IRQ(("Tx chain done (%d/%d)\n", sinfo->tx.cur, sinfo->tx.dirty)); - if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { return bkn_tx_cdma_chain_done(sinfo, done); } + DBG_IRQ(("Tx chain done (%d/%d)\n", sinfo->tx.cur, sinfo->tx.dirty)); + dev_irq_mask_disable(sinfo, XGS_DMA_TX_CHAN, 0); + evt = &_bkn_evt[sinfo->evt_idx]; + if (sinfo->tx.api_active) { sinfo->dma_events |= KCOM_DMA_INFO_F_TX_DONE; evt->evt_wq_put++; @@ -3283,7 +3754,11 @@ bkn_tx_chain_done(bkn_switch_info_t *sinfo, int done) pending = MAX_TX_DCBS - sinfo->tx.free; idx = sinfo->tx.dirty; while (--pending && idx < (MAX_TX_DCBS - 1)) { - sinfo->tx.desc[idx++].dcb_mem[1] |= (1 << 16); + if (sinfo->cmic_type == 'x') { + sinfo->tx.desc[idx++].dcb_mem[2] |= 1 << 16; + } else { + sinfo->tx.desc[idx++].dcb_mem[1] |= 1 << 16; + } DBG_DCB_TX(("Chain Tx DCB %d (%d)\n", idx, pending)); } /* Restart DMA from where we stopped */ @@ -3339,7 +3814,7 @@ xgs_do_dma(bkn_switch_info_t *sinfo, int budget) DEV_READ32(sinfo, CMIC_DMA_STATr, &dma_stat); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (dma_stat & DS_DESC_DONE_TST(XGS_DMA_RX_CHAN + chan)) { xgs_dma_desc_clear(sinfo, XGS_DMA_RX_CHAN + chan); rx_dcbs_done += bkn_do_rx(sinfo, chan, budget - rx_dcbs_done); @@ -3375,15 +3850,16 @@ xgsm_do_dma(bkn_switch_info_t *sinfo, int budget) DEV_READ32(sinfo, CMICM_DMA_STATr, &dma_stat); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (dma_stat & (0x10 << (XGS_DMA_RX_CHAN + chan)) || irq_stat & (0x08000000 << (XGS_DMA_RX_CHAN + chan))) { xgsm_dma_desc_clear(sinfo, XGS_DMA_RX_CHAN + chan); rx_dcbs_done += bkn_do_rx(sinfo, chan, budget - rx_dcbs_done); bkn_rx_desc_done(sinfo, chan); - if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { - continue; - } + } + + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { + continue; } if (dma_stat & (0x1 << (XGS_DMA_RX_CHAN + chan))) { @@ -3406,10 +3882,52 @@ xgsm_do_dma(bkn_switch_info_t *sinfo, int budget) return rx_dcbs_done; } +static int +xgsx_do_dma(bkn_switch_info_t *sinfo, int budget) +{ + int rx_dcbs_done = 0, tx_dcbs_done = 0; + uint32_t irq_stat; + int chan; + + DEV_READ32(sinfo, CMICX_IRQ_STATr, &irq_stat); + for (chan = 0; chan < sinfo->rx_chans; chan++) { + if ((irq_stat & CMICX_DS_CMC_CTRLD_INT(XGS_DMA_RX_CHAN + chan)) || + (irq_stat & CMICX_DS_CMC_DESC_DONE(XGS_DMA_RX_CHAN + chan))) { + xgsx_dma_desc_clear(sinfo, XGS_DMA_RX_CHAN + chan); + rx_dcbs_done += bkn_do_rx(sinfo, chan, budget - rx_dcbs_done); + bkn_rx_desc_done(sinfo, chan); + } + + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { + continue; + } + + if (irq_stat & CMICX_DS_CMC_CHAIN_DONE(XGS_DMA_RX_CHAN + chan)) { + xgsx_dma_chain_clear(sinfo, XGS_DMA_RX_CHAN + chan); + bkn_rx_chain_done(sinfo, chan); + } + } + + if ((irq_stat & CMICX_DS_CMC_CTRLD_INT(XGS_DMA_TX_CHAN)) || + (irq_stat & CMICX_DS_CMC_CHAIN_DONE(XGS_DMA_TX_CHAN))) { + if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { + xgsx_dma_desc_clear(sinfo, XGS_DMA_TX_CHAN); + } else { + xgsx_dma_chain_clear(sinfo, XGS_DMA_TX_CHAN); + } + tx_dcbs_done = bkn_do_tx(sinfo); + bkn_tx_chain_done(sinfo, tx_dcbs_done); + } + + return rx_dcbs_done; +} + static int dev_do_dma(bkn_switch_info_t *sinfo, int budget) { - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + return xgsx_do_dma(sinfo, budget); + } else if (DEV_IS_CMICM(sinfo)) { return xgsm_do_dma(sinfo, budget); } else { return xgs_do_dma(sinfo, budget); @@ -3478,6 +3996,40 @@ xgsm_isr(bkn_switch_info_t *sinfo) xgsm_irq_mask_set(sinfo, sinfo->irq_mask); } +static void +xgsx_isr(bkn_switch_info_t *sinfo) +{ + uint32_t irq_stat; + int rx_dcbs_done; + + DEV_READ32(sinfo, CMICX_IRQ_STATr, &irq_stat); + if ((irq_stat & sinfo->irq_mask) == 0) { + /* Not ours */ + return; + } + sinfo->interrupts++; + + DBG_IRQ(("Got interrupt on device %d (0x%08x)\n", + sinfo->dev_no, irq_stat)); + + if (use_napi) { + bkn_schedule_napi_poll(sinfo); + } else { + xgsx_irq_mask_set(sinfo, 0); + do { + rx_dcbs_done = xgsx_do_dma(sinfo, MAX_RX_DCBS); + if (sinfo->cdma_channels) { + if (rx_dcbs_done >= MAX_RX_DCBS || sinfo->tx_yield) { + /* Continuous DMA mode requires to yield timely */ + break; + } + } + } while (rx_dcbs_done); + } + + xgsx_irq_mask_set(sinfo, sinfo->irq_mask); +} + static void bkn_isr(void *isr_data) { @@ -3502,7 +4054,9 @@ bkn_isr(void *isr_data) return; } - if (DEV_HAS_CMICM(sinfo)) { + if (DEV_IS_CMICX(sinfo)) { + xgsx_isr(sinfo); + } else if (DEV_IS_CMICM(sinfo)) { xgsm_isr(sinfo); } else { xgs_isr(sinfo); @@ -3527,22 +4081,21 @@ static void bkn_resume_rx(bkn_switch_info_t *sinfo) { bkn_desc_info_t *desc; - bkn_dcb_chain_t *dcb_chain; - dma_addr_t cur_halt, last_dcb, dcb_dma; + bkn_dcb_chain_t *dcb_chain; + uint64_t cur_halt, last_dcb, dcb_dma; int woffset, chan, cdma_running; /* Resume Rx DMA on all channels */ - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (sinfo->rx[chan].use_rx_skb) { cdma_running = 0; - bkn_api_rx_restart(sinfo); + bkn_api_rx_restart(sinfo, chan); if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { cur_halt = sinfo->halt_addr[XGS_DMA_RX_CHAN + chan]; last_dcb = sinfo->rx[chan].desc[MAX_RX_DCBS].dcb_dma; if (cur_halt != last_dcb) { desc = &sinfo->rx[chan].desc[sinfo->rx[chan].dirty + 1]; - bkn_cdma_goto(sinfo, XGS_DMA_RX_CHAN + chan, - desc->dcb_dma); + bkn_cdma_goto(sinfo, XGS_DMA_RX_CHAN + chan, desc->dcb_dma); cdma_running = 1; } } @@ -3561,7 +4114,7 @@ bkn_resume_rx(bkn_switch_info_t *sinfo) } } if (!cdma_running) { - bkn_api_rx_restart(sinfo); + bkn_api_rx_restart(sinfo, chan); } } } @@ -3617,7 +4170,9 @@ bkn_set_mac_address(struct net_device *dev, void *addr) static int bkn_change_mtu(struct net_device *dev, int new_mtu) { - if (new_mtu < 68 || new_mtu > rx_buffer_size) { + int max_size = new_mtu + ETH_HLEN + VLAN_HLEN + 4; + + if (new_mtu < 68 || max_size > rx_buffer_size) { return -EINVAL; } dev->mtu = new_mtu; @@ -3625,7 +4180,7 @@ bkn_change_mtu(struct net_device *dev, int new_mtu) } #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) -static int +static int bkn_poll(struct net_device *dev, int *budget) { bkn_priv_t *priv = netdev_priv(dev); @@ -3663,7 +4218,7 @@ bkn_poll(struct net_device *dev, int *budget) return poll_again; } #else -static int +static int bkn_poll(struct napi_struct *napi, int budget) { bkn_switch_info_t *sinfo = container_of(napi, bkn_switch_info_t, napi); @@ -3719,9 +4274,9 @@ bkn_stop(struct net_device *dev) return 0; } -/* - * Network Device Statistics. - * Cleared at init time. +/* + * Network Device Statistics. + * Cleared at init time. */ static struct net_device_stats * bkn_get_stats(struct net_device *dev) @@ -3737,19 +4292,15 @@ bkn_set_multicast_list(struct net_device *dev) { } -static int +static int bkn_tx(struct sk_buff *skb, struct net_device *dev) { bkn_priv_t *priv = netdev_priv(dev); bkn_switch_info_t *sinfo = priv->sinfo; - struct sk_buff *new_skb; + struct sk_buff *new_skb = NULL; unsigned char *pktdata; - int pktlen; - int taglen; - int rcpulen; - int metalen; - int sop; - int idx; + int pktlen, hdrlen, taglen, rcpulen, metalen; + int sop, idx; uint16_t tpid; uint32_t *metadata; unsigned long flags; @@ -3775,10 +4326,11 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) if (sinfo->tx.free > 1) { bkn_desc_info_t *desc = &sinfo->tx.desc[sinfo->tx.cur]; - uint32_t *dcb; + uint32_t *dcb, *meta; pktdata = skb->data; pktlen = skb->len + 4; + hdrlen = sinfo->cmic_type == 'x' ? PKT_TX_HDR_SIZE : 0; rcpulen = 0; sop = 0; @@ -3802,7 +4354,6 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) return 0; } if (skb->data[21] & RCPU_F_MODHDR) { - rcpulen += RCPU_TX_META_SIZE; sop = skb->data[RCPU_HDR_SIZE]; switch (sop) { case 0xff: @@ -3818,6 +4369,9 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&sinfo->lock, flags); return 0; } + if (sinfo->cmic_type != 'x') { + rcpulen += RCPU_TX_META_SIZE; + } } /* Skip over RCPU encapsulation */ pktdata = &skb->data[rcpulen]; @@ -3825,6 +4379,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) /* CPU packets require tag */ if (sop == 0) { + hdrlen = 0; tpid = (pktdata[12] << 8) | pktdata[13]; if (tpid != 0x8100) { if (skb_header_cloned(skb)) { @@ -3846,11 +4401,11 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) skb = new_skb; pktdata = skb->data; } else { - /* Add tag to existing buffer */ + /* Add tag to RCPU header space */ DBG_SKB(("Expand into unused RCPU header\n")); - pktdata = &skb->data[rcpulen-4]; + pktdata = &skb->data[rcpulen - 4]; for (idx = 0; idx < 12; idx++) { - pktdata[idx] = pktdata[idx+4]; + pktdata[idx] = pktdata[idx + 4]; } } pktdata[12] = 0x81; @@ -3860,54 +4415,86 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) pktlen += 4; } } - } else if (priv->port < 0 || (priv->flags & KCOM_NETIF_F_ADD_TAG)) { - /* Need to add VLAN tag if packet is untagged */ - tpid = (skb->data[12] << 8) | skb->data[13]; - if (tpid != 0x8100) { - if (skb_header_cloned(skb) || skb_headroom(skb) < 4) { + } else { + if (sinfo->cmic_type == 'x' && priv->port >= 0) { + if (skb_header_cloned(skb) || skb_headroom(skb) < hdrlen + 4 || + ((unsigned long)skb->data % 4)) { /* Current SKB cannot be modified */ DBG_SKB(("Realloc Tx SKB\n")); - new_skb = dev_alloc_skb(pktlen + 4); + new_skb = dev_alloc_skb(pktlen + hdrlen + 4); if (new_skb == NULL) { DBG_WARN(("Tx drop: No SKB memory\n")); priv->stats.tx_dropped++; sinfo->tx.pkts_d_no_skb++; dev_kfree_skb_any(skb); - spin_unlock_irqrestore(&sinfo->lock, flags); - return 0; - } - memcpy(new_skb->data, skb->data, 12); - memcpy(&new_skb->data[16], &skb->data[12], pktlen - 12); - skb_put(new_skb, pktlen + 4); - dev_kfree_skb_any(skb); - skb = new_skb; - } else { - /* Add tag to existing buffer */ - DBG_SKB(("Expand Tx SKB\n")); - skb_push(skb, 4); - for (idx = 0; idx < 12; idx++) { - skb->data[idx] = skb->data[idx+4]; + spin_unlock_irqrestore(&sinfo->lock, flags); + return 0; + } + skb_reserve(new_skb, 4); + memcpy(new_skb->data + hdrlen, skb->data, pktlen); + skb_put(new_skb, pktlen + hdrlen); + dev_kfree_skb_any(skb); + skb = new_skb; + } else { + DBG_SKB(("Expand Tx SKB\n")); + skb_push(skb, hdrlen); + } + memset(skb->data, 0, hdrlen); + pktdata = skb->data; + pktlen += hdrlen; + } else { + hdrlen = 0; + } + + if (priv->port < 0 || (priv->flags & KCOM_NETIF_F_ADD_TAG)) { + /* Need to add VLAN tag if packet is untagged */ + tpid = (skb->data[hdrlen + 12] << 8) | skb->data[hdrlen + 13]; + if (tpid != 0x8100) { + if (skb_header_cloned(skb) || skb_headroom(skb) < 4) { + /* Current SKB cannot be modified */ + DBG_SKB(("Realloc Tx SKB\n")); + new_skb = dev_alloc_skb(pktlen + 4); + if (new_skb == NULL) { + DBG_WARN(("Tx drop: No SKB memory\n")); + priv->stats.tx_dropped++; + sinfo->tx.pkts_d_no_skb++; + dev_kfree_skb_any(skb); + spin_unlock_irqrestore(&sinfo->lock, flags); + return 0; + } + memcpy(new_skb->data, skb->data, hdrlen + 12); + memcpy(&new_skb->data[hdrlen + 16], &skb->data[hdrlen + 12], + pktlen - hdrlen - 12); + skb_put(new_skb, pktlen + 4); + dev_kfree_skb_any(skb); + skb = new_skb; + } else { + /* Add tag to existing buffer */ + DBG_SKB(("Expand Tx SKB\n")); + skb_push(skb, 4); + for (idx = 0; idx < hdrlen + 12; idx++) { + skb->data[idx] = skb->data[idx + 4]; + } } + pktdata = skb->data; + pktdata[hdrlen + 12] = 0x81; + pktdata[hdrlen + 13] = 0x00; + pktdata[hdrlen + 14] = (priv->vlan >> 8) & 0xf; + pktdata[hdrlen + 15] = priv->vlan & 0xff; + pktlen += 4; } - pktdata = skb->data; - pktdata[12] = 0x81; - pktdata[13] = 0x00; - pktdata[14] = (priv->vlan >> 8) & 0xf; - pktdata[15] = priv->vlan & 0xff; - pktlen += 4; } } /* Pad packet if needed */ taglen = 0; - tpid = (pktdata[12] << 8) | pktdata[13]; + tpid = (pktdata[hdrlen + 12] << 8) | pktdata[hdrlen + 13]; if (tpid == 0x8100) { taglen = 4; } - if (pktlen < (64 + taglen)) { - pktlen = (64 + taglen); - /* Pad runt packets accounting for skipped RCPU header if needed */ - if (SKB_PADTO(skb, pktlen + rcpulen) != 0) { + if (pktlen < (64 + taglen + hdrlen)) { + pktlen = (64 + taglen + hdrlen); + if (SKB_PADTO(skb, pktlen) != 0) { DBG_WARN(("Tx drop: skb_padto failed\n")); priv->stats.tx_dropped++; sinfo->tx.pkts_d_pad_fail++; @@ -3915,13 +4502,11 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) spin_unlock_irqrestore(&sinfo->lock, flags); return 0; } - /* skb_padto may update the skb->data pointer */ - pktdata = &skb->data[rcpulen]; DBG_SKB(("Packet padded to %d bytes\n", pktlen)); } if (pktlen > SOC_DCB_KNET_COUNT_MASK) { - DBG_WARN(("Tx drop: size of pkt (%d) is out of range(%d)\n", + DBG_WARN(("Tx drop: size of pkt (%d) is out of range(%d)\n", pktlen, SOC_DCB_KNET_COUNT_MASK)); sinfo->tx.pkts_d_over_limit++; priv->stats.tx_dropped++; @@ -3931,25 +4516,32 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) } dcb = desc->dcb_mem; - memset(dcb, 0, sizeof(uint32_t) * sinfo->dcb_wsize); - dcb[1] = pktlen; + meta = sinfo->cmic_type == 'x' ? (uint32_t *)pktdata : dcb; + memset(dcb, 0, sinfo->dcb_wsize * sizeof(uint32_t)); if (priv->flags & KCOM_NETIF_F_RCPU_ENCAP) { /* If module header SOP is non-zero, use RCPU meta data */ if (sop != 0) { - metalen = (sinfo->dcb_wsize - 3) * sizeof(uint32_t); - if (metalen > RCPU_TX_META_SIZE) { - metalen = RCPU_TX_META_SIZE; - } - metadata = (uint32_t *)&skb->data[RCPU_HDR_SIZE]; - for (idx = 0; idx < BYTES2WORDS(metalen); idx++) { - dcb[idx+2] = ntohl(metadata[idx]); + if (sinfo->cmic_type == 'x') { + dcb[2] |= 1 << 19; + } else { + metalen = (sinfo->dcb_wsize - 3) * sizeof(uint32_t); + if (metalen > RCPU_TX_META_SIZE) { + metalen = RCPU_TX_META_SIZE; + } + metadata = (uint32_t *)&skb->data[RCPU_HDR_SIZE]; + for (idx = 0; idx < BYTES2WORDS(metalen); idx++) { + dcb[idx + 2] = ntohl(metadata[idx]); + } + dcb[1] |= 1 << 19; } - dcb[1] |= (1 << 19); } - bkn_dump_dcb("Tx RCPU", dcb, sinfo->dcb_wsize, XGS_DMA_TX_CHAN); } else if (priv->port >= 0) { /* Send to physical port */ - dcb[1] |= (1 << 19); + if (sinfo->cmic_type == 'x') { + dcb[2] |= 1 << 19; + } else { + dcb[1] |= 1 << 19; + } switch (sinfo->dcb_type) { case 23: case 26: @@ -3963,25 +4555,6 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) dcb[4] = 0x00040000; dcb[4] |= (priv->qnum & 0x3ff) << 8; break; - case 32: - dcb[2] = 0x81000000; - dcb[3] = priv->port; - dcb[4] = 0x4000; - /* according to format of register SOBMH in bcm56960_a0 */ - dcb[4] |= (priv->qnum & 0x3f) << 8; - break; - case 33: - dcb[2] = 0x81000000; - dcb[3] = (priv->port) << 2; - dcb[4] = 0x00100000; - dcb[4] |= (priv->qnum & 0xfff) << 8; - break; - case 35: - dcb[2] = 0x81000000; - dcb[3] = (priv->port) << 4; - dcb[4] = 0x00400000; - dcb[4] |= (priv->qnum & 0x3fff) << 8; - break; case 24: dcb[2] = 0xff000000; dcb[3] = 0x00000100; @@ -4056,6 +4629,48 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) dcb[4] = 0x00100000; dcb[4] |= (priv->qnum & 0xfff) << 8; break; + case 32: + dcb[2] = 0x81000000; + dcb[3] = priv->port; + dcb[4] = 0x00004000; + dcb[4] |= (priv->qnum & 0x3f) << 8; + break; + case 33: + dcb[2] = 0x81000000; + dcb[3] = (priv->port) << 2; + dcb[4] = 0x00100000; + dcb[4] |= (priv->qnum & 0xfff) << 8; + break; + case 35: + dcb[2] = 0x81000000; + dcb[3] = (priv->port) << 4; + dcb[4] = 0x00400000; + dcb[4] |= (priv->qnum & 0x3fff) << 8; + break; + case 36: + if (sinfo->cmic_type == 'x') { + meta[0] = htonl(0x81000000); + meta[1] = htonl(priv->port); + meta[2] = htonl(0x00008000 | (priv->qnum & 0x3f) << 9); + } else { + dcb[2] = 0x81000000; + dcb[3] = priv->port; + dcb[4] = 0x00008000; + dcb[4] |= (priv->qnum & 0x3f) << 9; + } + break; + case 38: + if (sinfo->cmic_type == 'x') { + meta[0] = htonl(0x81000000); + meta[1] = htonl(priv->port); + meta[2] = htonl(0x00004000 | (priv->qnum & 0x3f) << 8); + } else { + dcb[2] = 0x81000000; + dcb[3] = priv->port; + dcb[4] = 0x00004000; + dcb[4] |= (priv->qnum & 0x3f) << 8; + } + break; default: dcb[2] = 0xff000000; dcb[3] = 0x00000100; @@ -4066,7 +4681,9 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) /* Optional SKB updates */ if (knet_tx_cb != NULL) { - skb = knet_tx_cb(skb, sinfo->dev_no, dcb); + KNET_SKB_CB(skb)->netif_user_data = priv->cb_user_data; + KNET_SKB_CB(skb)->dcb_type = sinfo->dcb_type & 0xFFFF; + skb = knet_tx_cb(skb, sinfo->dev_no, meta); if (skb == NULL) { /* Consumed by call-back */ DBG_WARN(("Tx drop: Consumed by call-back\n")); @@ -4081,20 +4698,20 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) if ((skb->len + 4) <= SOC_DCB_KNET_COUNT_MASK) { pktdata = skb->data; pktlen = skb->len + 4; - if (pktlen < (64 + taglen)) { - pktlen = (64 + taglen); - if (SKB_PADTO(skb, pktlen) != 0) { - DBG_WARN(("Tx drop: skb_padto failed\n")); - priv->stats.tx_dropped++; - sinfo->tx.pkts_d_pad_fail++; - dev_kfree_skb_any(skb); - spin_unlock_irqrestore(&sinfo->lock, flags); - return 0; - } - DBG_SKB(("Packet padded to %d bytes after tx callback\n", pktlen)); + if (pktlen < (64 + taglen + hdrlen)) { + pktlen = (64 + taglen + hdrlen); + if (SKB_PADTO(skb, pktlen) != 0) { + DBG_WARN(("Tx drop: skb_padto failed\n")); + priv->stats.tx_dropped++; + sinfo->tx.pkts_d_pad_fail++; + dev_kfree_skb_any(skb); + spin_unlock_irqrestore(&sinfo->lock, flags); + return 0; + } + DBG_SKB(("Packet padded to %d bytes after tx callback\n", pktlen)); } } else { - DBG_WARN(("Tx drop: size of pkt (%d) is out of range(%d)\n", + DBG_WARN(("Tx drop: size of pkt (%d) is out of range(%d)\n", pktlen, SOC_DCB_KNET_COUNT_MASK)); sinfo->tx.pkts_d_over_limit++; priv->stats.tx_dropped++; @@ -4104,23 +4721,41 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) return 0; } } + /* Prepare for DMA */ desc->skb = skb; desc->dma_size = pktlen; desc->skb_dma = DMA_MAP_SINGLE(sinfo->dma_dev, pktdata, desc->dma_size, DMA_TODEV); + if (DMA_MAPPING_ERROR(sinfo->dma_dev, desc->skb_dma)) { + priv->stats.tx_dropped++; + dev_kfree_skb_any(skb); + spin_unlock_irqrestore(&sinfo->lock, flags); + return 0; + } dcb[0] = desc->skb_dma; - dcb[1] &= ~SOC_DCB_KNET_COUNT_MASK; - dcb[1] |= pktlen; + if (sinfo->cmic_type == 'x') { + dcb[1] = DMA_TO_BUS_HI(desc->skb_dma >> 32); + dcb[2] &= ~SOC_DCB_KNET_COUNT_MASK; + dcb[2] |= pktlen; + } else { + dcb[1] &= ~SOC_DCB_KNET_COUNT_MASK; + dcb[1] |= pktlen; + } + bkn_dump_dcb("Tx RCPU", dcb, sinfo->dcb_wsize, XGS_DMA_TX_CHAN); DBG_DCB_TX(("Add Tx DCB @ 0x%08x (%d) [%d free] (%d bytes).\n", (uint32_t)desc->dcb_dma, sinfo->tx.cur, sinfo->tx.free, pktlen)); - bkn_dump_pkt(pktdata, skb->len - rcpulen, XGS_DMA_TX_CHAN); + bkn_dump_pkt(pktdata, pktlen, XGS_DMA_TX_CHAN); if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { - dcb[1] |= (1 << 24) | (1 << 16); + if (sinfo->cmic_type == 'x') { + dcb[2] |= 1 << 24 | 1 << 16; + } else { + dcb[1] |= 1 << 24 | 1 << 16; + } } else { bkn_tx_dma_start(sinfo); } @@ -4138,8 +4773,7 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) priv->stats.tx_packets++; priv->stats.tx_bytes += pktlen; sinfo->tx.pkts++; - } - else { + } else { DBG_WARN(("Tx drop: No DMA resources\n")); priv->stats.tx_dropped++; sinfo->tx.pkts_d_dma_resrc++; @@ -4151,8 +4785,11 @@ bkn_tx(struct sk_buff *skb, struct net_device *dev) bkn_suspend_tx(sinfo); } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(4,6,0)) + dev->trans_start = jiffies; +#else netif_trans_update(dev); - +#endif spin_unlock_irqrestore(&sinfo->lock, flags); return 0; @@ -4171,7 +4808,7 @@ bkn_timer(unsigned long context) sinfo->timer_runs++; restart_timer = 0; - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { /* Restart channel if not running */ if (sinfo->rx[chan].running == 0) { bkn_rx_refill(sinfo, chan); @@ -4197,6 +4834,7 @@ bkn_rx_add_tokens(bkn_switch_info_t *sinfo, int chan) { unsigned long cur_jif, ticks; uint32_t tokens_per_tick; + bkn_desc_info_t *desc; tokens_per_tick = sinfo->rx[chan].rate_max / HZ; cur_jif = jiffies; @@ -4207,10 +4845,19 @@ bkn_rx_add_tokens(bkn_switch_info_t *sinfo, int chan) sinfo->rx[chan].tokens = sinfo->rx[chan].burst_max; } - /* Restart channel if not running */ - if (sinfo->rx[chan].running == 0) { + /* Restart channel if Rx is suppressed */ + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { bkn_rx_refill(sinfo, chan); - bkn_rx_restart(sinfo, chan); + desc = &sinfo->rx[chan].desc[sinfo->rx[chan].dirty]; + if (desc->dcb_dma == sinfo->halt_addr[XGS_DMA_RX_CHAN + chan]) { + desc = &sinfo->rx[chan].desc[MAX_RX_DCBS]; + bkn_cdma_goto(sinfo, XGS_DMA_RX_CHAN + chan, desc->dcb_dma); + } + } else { + if (sinfo->rx[chan].running == 0) { + bkn_rx_refill(sinfo, chan); + bkn_rx_restart(sinfo, chan); + } } } @@ -4229,7 +4876,7 @@ bkn_rxtick(unsigned long context) /* For debug purposes we maintain a rough actual packet rate */ if (++sinfo->rxticks >= sinfo->rxticks_per_sec) { - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { pkt_diff = sinfo->rx[chan].pkts - sinfo->rx[chan].pkts_ref; cur_jif = jiffies; ticks = cur_jif - sinfo->rx[chan].rate_jif; @@ -4241,7 +4888,7 @@ bkn_rxtick(unsigned long context) } /* Update tokens for Rx rate control */ - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (sinfo->rx[chan].tokens < sinfo->rx[chan].burst_max) { bkn_rx_add_tokens(sinfo, chan); } @@ -4316,7 +4963,6 @@ static bkn_switch_info_t * bkn_create_sinfo(int dev_no) { bkn_switch_info_t *sinfo; - uint32_t val; int chan; if ((sinfo = kmalloc(sizeof(*sinfo), GFP_KERNEL)) == NULL) { @@ -4369,15 +5015,6 @@ bkn_create_sinfo(int dev_no) list_add_tail(&sinfo->list, &_sinfo_list); - sinfo->cmic_type = 'e'; - DEV_READ32(sinfo, CMIC_DEV_REV_IDr, &val); - if (val == 0) { - sinfo->cmic_type = 'm'; - DEV_READ32(sinfo, CMICM_DEV_REV_IDr, &val); - } - - DBG_VERB(("Check dev/rev: 0x%08x\n", val)); - return sinfo; } @@ -4462,7 +5099,7 @@ bkn_init_ndev(u8 *mac, char *name) /* * Device Link Control Proc Read Entry */ -static int +static int bkn_proc_link_show(struct seq_file *m, void *v) { struct list_head *slist, *dlist; @@ -4506,9 +5143,9 @@ bkn_proc_link_open(struct inode * inode, struct file * file) * eth4=up * eth4=down */ -static ssize_t +static ssize_t bkn_proc_link_write(struct file *file, const char *buf, - size_t count, loff_t *loff) + size_t count, loff_t *loff) { struct list_head *slist, *dlist; struct net_device *dev; @@ -4519,8 +5156,9 @@ bkn_proc_link_write(struct file *file, const char *buf, char *ptr; char *newline; - if (count >= sizeof(link_str)) { + if (count > sizeof(link_str)) { count = sizeof(link_str) - 1; + link_str[count] = '\0'; } if (copy_from_user(link_str, buf, count)) { return -EFAULT; @@ -4583,8 +5221,9 @@ struct file_operations bkn_proc_link_file_ops = { /* * Device Rate Control Proc Read Entry */ -static int -bkn_proc_rate_show(struct seq_file *m, void *v){ +static int +bkn_proc_rate_show(struct seq_file *m, void *v) +{ int unit = 0; struct list_head *list; bkn_switch_info_t *sinfo; @@ -4594,7 +5233,7 @@ bkn_proc_rate_show(struct seq_file *m, void *v){ sinfo = (bkn_switch_info_t *)list; seq_printf(m, "Rate control (unit %d):\n", unit); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { seq_printf(m, " Rx%d max rate %8u\n", chan, sinfo->rx[chan].rate_max); seq_printf(m, " Rx%d max burst %8u\n", @@ -4611,7 +5250,8 @@ bkn_proc_rate_show(struct seq_file *m, void *v){ } static int -bkn_proc_rate_open(struct inode * inode, struct file * file) { +bkn_proc_rate_open(struct inode * inode, struct file * file) +{ return single_open(file, bkn_proc_rate_show, NULL); } @@ -4629,17 +5269,18 @@ bkn_proc_rate_open(struct inode * inode, struct file * file) { * 0:rx_rate=10000,10000 * 1:rx_rate=10000,5000 */ -static ssize_t +static ssize_t bkn_proc_rate_write(struct file *file, const char *buf, - size_t count, loff_t *loff) + size_t count, loff_t *loff) { bkn_switch_info_t *sinfo; - char rate_str[40]; + char rate_str[80]; char *ptr; int unit, chan; - if (count >= sizeof(rate_str)) { + if (count > sizeof(rate_str)) { count = sizeof(rate_str) - 1; + rate_str[count] = '\0'; } if (copy_from_user(rate_str, buf, count)) { return -EFAULT; @@ -4648,28 +5289,25 @@ bkn_proc_rate_write(struct file *file, const char *buf, unit = simple_strtol(rate_str, NULL, 10); sinfo = bkn_sinfo_from_unit(unit); if (sinfo == NULL) { - gprintk("Warning: unknown unit\n"); + gprintk("Warning: unknown unit: %d\n", unit); return count; } - if ((ptr = strstr(rate_str, "rx_rate=")) != NULL) { ptr += 7; chan = 0; do { ptr++; sinfo->rx[chan].rate_max = simple_strtol(ptr, NULL, 10); - } - while ((ptr = strchr(ptr, ',')) != NULL && ++chan < NUM_RX_CHAN); + } while ((ptr = strchr(ptr, ',')) != NULL && ++chan < sinfo->rx_chans); bkn_rx_rate_config(sinfo); - } else if ((ptr = strstr(rate_str, "rx_burst=")) != NULL) { + } else if ((ptr = strstr(rate_str, "rx_burst=")) != NULL) { ptr += 8; chan = 0; do { ptr++; sinfo->rx[chan].burst_max = simple_strtol(ptr, NULL, 10); - } - while ((ptr = strchr(ptr, ',')) != NULL && ++chan < NUM_RX_CHAN); + } while ((ptr = strchr(ptr, ',')) != NULL && ++chan < sinfo->rx_chans); bkn_rx_rate_config(sinfo); } else { gprintk("Warning: unknown configuration setting\n"); @@ -4705,21 +5343,24 @@ typedef struct { static int bkn_seq_dma_next_pos(bkn_seq_dma_iter_t *iter, loff_t pos) { + bkn_switch_info_t *sinfo; + + sinfo = bkn_sinfo_from_unit(iter->dev_no); while (pos) { if (iter->rx_dma) { - if (++iter->idx >= MAX_RX_DCBS) { + if (++iter->idx >= MAX_RX_DCBS + 1) { iter->idx = -1; - if (++iter->ch_no >= NUM_RX_CHAN) { + if (++iter->ch_no >= sinfo->rx_chans) { iter->rx_dma = 0; iter->ch_no = 0; iter->dev_no++; - if (bkn_sinfo_from_unit(iter->dev_no) == NULL) { + if ((sinfo = bkn_sinfo_from_unit(iter->dev_no)) == NULL) { return -1; } } } } else { - if (++iter->idx >= MAX_TX_DCBS) { + if (++iter->idx >= MAX_TX_DCBS + 1) { iter->idx = -1; iter->rx_dma = 1; } @@ -4747,7 +5388,7 @@ bkn_seq_dma_start(struct seq_file *s, loff_t *pos) } return iter; } - + /* Move to next record */ static void * bkn_seq_dma_next(struct seq_file *s, void *v, loff_t *pos) @@ -4778,7 +5419,10 @@ bkn_seq_dma_show(struct seq_file *s, void *v) bkn_seq_dma_iter_t *iter = (bkn_seq_dma_iter_t *)v; bkn_switch_info_t *sinfo; uint32_t *dcb = NULL; - int chan; + bkn_dcb_chain_t *dcb_chain = NULL; + struct list_head *curr, *next; + unsigned long flags; + int chan, cnt; sinfo = bkn_sinfo_from_unit(iter->dev_no); if (sinfo == NULL) { @@ -4790,6 +5434,31 @@ bkn_seq_dma_show(struct seq_file *s, void *v) if (iter->idx == -2) { seq_printf(s, "Pending events: 0x%x\n", sinfo->dma_events); } else if (iter->idx == -1) { + spin_lock_irqsave(&sinfo->lock, flags); + curr = &sinfo->tx.api_dcb_list; + dcb_chain = sinfo->tx.api_dcb_chain; + while (dcb_chain) { + seq_printf(s, " [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') { + seq_printf(s, " DCB %2d: 0x%08x 0x%08x 0x%08x 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[2], dcb[sinfo->dcb_wsize-1]); + } else { + seq_printf(s, " 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->tx.api_dcb_list) { + dcb_chain = list_entry(next, bkn_dcb_chain_t, list); + curr = next; + } else { + dcb_chain = NULL; + } + } + dcb = NULL; + spin_unlock_irqrestore(&sinfo->lock, flags); seq_printf(s, "Tx DCB info (unit %d):\n" " api: %d\n" @@ -4803,8 +5472,18 @@ bkn_seq_dma_show(struct seq_file *s, void *v) sinfo->tx.cur, sinfo->tx.free, netif_queue_stopped(sinfo->dev) ? "yes" : "no"); + if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { + bkn_desc_info_t *desc = &sinfo->tx.desc[0]; + uint64_t halt = sinfo->halt_addr[XGS_DMA_TX_CHAN]; + seq_printf(s, + " halt: %d\n", + (int)((uint32_t)(halt - desc->dcb_dma) / (sinfo->dcb_wsize * sizeof(uint32_t)))); + } } else { dcb = sinfo->tx.desc[iter->idx].dcb_mem; + if (iter->idx == 0) { + seq_printf(s, " [0x%08lx]--->\n", (unsigned long)sinfo->tx.desc[0].dcb_dma); + } } } else { if (iter->idx == -1) { @@ -4812,23 +5491,66 @@ bkn_seq_dma_show(struct seq_file *s, void *v) seq_printf(s, "Rx%d DCB info (unit %d):\n" " api: %d\n" + " wait: %d\n" " dirty: %d\n" " cur: %d\n" " free: %d\n" " run: %d\n", chan, iter->dev_no, sinfo->rx[chan].api_active, + sinfo->rx[chan].api_wait, sinfo->rx[chan].dirty, sinfo->rx[chan].cur, sinfo->rx[chan].free, sinfo->rx[chan].running); + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan) && sinfo->rx[chan].use_rx_skb) { + bkn_desc_info_t *desc = &sinfo->rx[chan].desc[0]; + uint64_t halt = sinfo->halt_addr[XGS_DMA_RX_CHAN + chan]; + seq_printf(s, + " halt: %d\n", + (int)((uint32_t)(halt - desc->dcb_dma) / (sinfo->dcb_wsize * sizeof(uint32_t)))); + } } else if (sinfo->rx[iter->ch_no].use_rx_skb) { dcb = sinfo->rx[iter->ch_no].desc[iter->idx].dcb_mem; + if (iter->idx == 0) { + seq_printf(s, " [0x%08lx]--->\n", (unsigned long)sinfo->rx[iter->ch_no].desc[0].dcb_dma); + } + } else if (!sinfo->rx[iter->ch_no].use_rx_skb && iter->idx == 0) { + spin_lock_irqsave(&sinfo->lock, flags); + curr = &sinfo->rx[iter->ch_no].api_dcb_list; + dcb_chain = sinfo->rx[iter->ch_no].api_dcb_chain; + while (dcb_chain) { + seq_printf(s, " [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') { + seq_printf(s, " DCB %2d: 0x%08x 0x%08x 0x%08x 0x%08x\n", cnt, + dcb[0], dcb[1], dcb[2], dcb[sinfo->dcb_wsize-1]); + } else { + seq_printf(s, " 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[iter->ch_no].api_dcb_list) { + dcb_chain = list_entry(next, bkn_dcb_chain_t, list); + curr = next; + } else { + dcb_chain = NULL; + } + } + dcb = NULL; + spin_unlock_irqrestore(&sinfo->lock, flags); } } if (dcb) { - seq_printf(s, " DCB %2d: 0x%08x 0x%08x ... 0x%08x\n", iter->idx, - dcb[0], dcb[1], dcb[sinfo->dcb_wsize - 1]); + if (sinfo->cmic_type == 'x') { + seq_printf(s, " DCB %2d: 0x%08x 0x%08x 0x%08x 0x%08x\n", iter->idx, + dcb[0], dcb[1], dcb[2], dcb[sinfo->dcb_wsize-1]); + } else { + seq_printf(s, " DCB %2d: 0x%08x 0x%08x ... 0x%08x\n", iter->idx, + dcb[0], dcb[1], dcb[sinfo->dcb_wsize-1]); + } } return 0; } @@ -4868,15 +5590,16 @@ static struct file_operations bkn_seq_dma_file_ops = { */ static ssize_t bkn_proc_debug_write(struct file *file, const char *buf, - size_t count, loff_t *loff) + size_t count, loff_t *loff) { bkn_switch_info_t *sinfo; char debug_str[40]; char *ptr; int unit; - if (count >= sizeof(debug_str)) { + if (count > sizeof(debug_str)) { count = sizeof(debug_str) - 1; + debug_str[count] = '\0'; } if (copy_from_user(debug_str, buf, count)) { return -EFAULT; @@ -4885,7 +5608,7 @@ bkn_proc_debug_write(struct file *file, const char *buf, unit = simple_strtol(debug_str, NULL, 10); sinfo = bkn_sinfo_from_unit(unit); if (sinfo == NULL) { - gprintk("Warning: unknown unit\n"); + gprintk("Warning: unknown unit: %d\n", unit); return count; } @@ -4902,8 +5625,9 @@ bkn_proc_debug_write(struct file *file, const char *buf, /* * Driver Debug Proc Entry */ -static int -bkn_proc_debug_show(struct seq_file *m, void *v){ +static int +bkn_proc_debug_show(struct seq_file *m, void *v) +{ int unit = 0; struct list_head *list; bkn_switch_info_t *sinfo; @@ -4946,12 +5670,15 @@ bkn_proc_debug_show(struct seq_file *m, void *v){ seq_printf(m, "Device %d:\n", unit); seq_printf(m, " base_addr: 0x%p\n", sinfo->base_addr); seq_printf(m, " dev_no: %d\n", sinfo->dev_no); + seq_printf(m, " cmic_type: %c\n", sinfo->cmic_type); seq_printf(m, " dcb_type: %d\n", sinfo->dcb_type); seq_printf(m, " dcb_wsize: %d\n", sinfo->dcb_wsize); - seq_printf(m, " cmic_type: %c\n", sinfo->cmic_type); + seq_printf(m, " pkt_hdr_size: %d\n", sinfo->pkt_hdr_size); + seq_printf(m, " rx_chans: %d\n", sinfo->rx_chans); + seq_printf(m, " cdma_chans: 0x%x\n", sinfo->cdma_channels); seq_printf(m, " irq_mask: 0x%x\n", sinfo->irq_mask); seq_printf(m, " dma_events: 0x%x\n", sinfo->dma_events); - seq_printf(m, " dcb_dma: 0x%p\n", (void *)sinfo->dcb_dma); + seq_printf(m, " dcb_dma: 0x%p\n", (void *)(sal_paddr_t)sinfo->dcb_dma); seq_printf(m, " dcb_mem_size: 0x%x\n", sinfo->dcb_mem_size); seq_printf(m, " rcpu_sig: 0x%x\n", sinfo->rcpu_sig); seq_printf(m, " napi_poll_mode: %d\n", sinfo->napi_poll_mode); @@ -4964,7 +5691,8 @@ bkn_proc_debug_show(struct seq_file *m, void *v){ return 0; } -static int bkn_proc_debug_open(struct inode * inode, struct file * file) { +static int bkn_proc_debug_open(struct inode * inode, struct file * file) +{ return single_open(file, bkn_proc_debug_show, NULL); } @@ -4980,8 +5708,9 @@ struct file_operations bkn_proc_debug_file_ops = { /* * Device Statistics Proc Entry */ -static int -bkn_proc_stats_show(struct seq_file *m, void *v){ +static int +bkn_proc_stats_show(struct seq_file *m, void *v) +{ int unit = 0; struct list_head *list, *flist; bkn_switch_info_t *sinfo; @@ -4995,17 +5724,16 @@ bkn_proc_stats_show(struct seq_file *m, void *v){ seq_printf(m, "Device stats (unit %d):\n", unit); seq_printf(m, " Interrupts %10u\n", sinfo->interrupts); seq_printf(m, " Tx packets %10u\n", sinfo->tx.pkts); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { - seq_printf(m, " Rx%d packets %10u\n", - chan, sinfo->rx[chan].pkts); + for (chan = 0; chan < sinfo->rx_chans; chan++) { + seq_printf(m, " Rx%d packets %10u\n", chan, sinfo->rx[chan].pkts); } - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (sinfo->interrupts == 0) { /* Avoid divide-by-zero */ seq_printf(m, " Rx%d pkts/intr -\n", chan); } else { seq_printf(m, " Rx%d pkts/intr %8u\n", - chan, sinfo->rx[chan].pkts / sinfo->interrupts); + chan, sinfo->rx[chan].pkts / sinfo->interrupts); } } seq_printf(m, " Timer runs %10u\n", sinfo->timer_runs); @@ -5023,7 +5751,8 @@ bkn_proc_stats_show(struct seq_file *m, void *v){ return 0; } -static int bkn_proc_stats_open(struct inode * inode, struct file * file) { +static int bkn_proc_stats_open(struct inode * inode, struct file * file) +{ return single_open(file, bkn_proc_stats_show, NULL); } @@ -5041,7 +5770,7 @@ static int bkn_proc_stats_open(struct inode * inode, struct file * file) { */ static ssize_t bkn_proc_stats_write(struct file *file, const char *buf, - size_t count, loff_t *loff) + size_t count, loff_t *loff) { bkn_switch_info_t *sinfo; struct list_head *flist; @@ -5052,8 +5781,9 @@ bkn_proc_stats_write(struct file *file, const char *buf, int clear_mask; int chan; - if (count >= sizeof(debug_str)) { + if (count > sizeof(debug_str)) { count = sizeof(debug_str) - 1; + debug_str[count] = '\0'; } if (copy_from_user(debug_str, buf, count)) { return -EFAULT; @@ -5062,7 +5792,7 @@ bkn_proc_stats_write(struct file *file, const char *buf, unit = simple_strtol(debug_str, NULL, 10); sinfo = bkn_sinfo_from_unit(unit); if (sinfo == NULL) { - gprintk("Warning: unknown unit\n"); + gprintk("Warning: unknown unit: %d\n", unit); return count; } @@ -5080,7 +5810,7 @@ bkn_proc_stats_write(struct file *file, const char *buf, if (clear_mask) { sinfo->tx.pkts = 0; - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { sinfo->rx[chan].pkts = 0; } sinfo->interrupts = 0; @@ -5107,8 +5837,9 @@ struct file_operations bkn_proc_stats_file_ops = { /* * Device Debug Statistics Proc Entry */ -static int -bkn_proc_dstats_show(struct seq_file *m, void *v){ +static int +bkn_proc_dstats_show(struct seq_file *m, void *v) +{ int unit = 0; struct list_head *list; bkn_switch_info_t *sinfo; @@ -5138,7 +5869,7 @@ bkn_proc_dstats_show(struct seq_file *m, void *v){ sinfo->tx.pkts_d_over_limit); seq_printf(m, " Tx suspends %10u\n", sinfo->tx.suspends); - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { seq_printf(m, " Rx%d filter to api %10u\n", chan, sinfo->rx[chan].pkts_f_api); seq_printf(m, " Rx%d filter to netif %10u\n", @@ -5173,7 +5904,8 @@ bkn_proc_dstats_show(struct seq_file *m, void *v){ return 0; } -static int bkn_proc_dstats_open(struct inode * inode, struct file * file) { +static int bkn_proc_dstats_open(struct inode * inode, struct file * file) +{ return single_open(file, bkn_proc_dstats_show, NULL); } @@ -5191,7 +5923,7 @@ static int bkn_proc_dstats_open(struct inode * inode, struct file * file) { */ static ssize_t bkn_proc_dstats_write(struct file *file, const char *buf, - size_t count, loff_t *loff) + size_t count, loff_t *loff) { bkn_switch_info_t *sinfo; char debug_str[40]; @@ -5200,8 +5932,9 @@ bkn_proc_dstats_write(struct file *file, const char *buf, int clear_mask; int chan; - if (count >= sizeof(debug_str)) { + if (count > sizeof(debug_str)) { count = sizeof(debug_str) - 1; + debug_str[count] = '\0'; } if (copy_from_user(debug_str, buf, count)) { return -EFAULT; @@ -5210,7 +5943,7 @@ bkn_proc_dstats_write(struct file *file, const char *buf, unit = simple_strtol(debug_str, NULL, 10); sinfo = bkn_sinfo_from_unit(unit); if (sinfo == NULL) { - gprintk("Warning: unknown unit\n"); + gprintk("Warning: unknown unit: %d\n", unit); return count; } @@ -5248,7 +5981,7 @@ bkn_proc_dstats_write(struct file *file, const char *buf, sinfo->tx.suspends = 0; } /* Rx counters */ - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (clear_mask & (1 << chan)) { sinfo->rx[chan].pkts_f_api = 0; sinfo->rx[chan].pkts_f_netif = 0; @@ -5307,18 +6040,18 @@ bkn_proc_init(void) return -1; } - return 0; + return 0; } static int bkn_proc_cleanup(void) { - remove_proc_entry("link", bkn_proc_root); - remove_proc_entry("rate", bkn_proc_root); - remove_proc_entry("dma", bkn_proc_root); - remove_proc_entry("debug", bkn_proc_root); - remove_proc_entry("stats", bkn_proc_root); - remove_proc_entry("dstats", bkn_proc_root); + remove_proc_entry("link", bkn_proc_root); + remove_proc_entry("rate", bkn_proc_root); + remove_proc_entry("dma", bkn_proc_root); + remove_proc_entry("debug", bkn_proc_root); + remove_proc_entry("stats", bkn_proc_root); + remove_proc_entry("dstats", bkn_proc_root); return 0; } @@ -5328,7 +6061,7 @@ bkn_proc_cleanup(void) static int _pprint(void) -{ +{ pprintf("Broadcom BCM KNET Linux Network Driver\n"); return 0; @@ -5340,8 +6073,8 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) bkn_switch_info_t *sinfo; bkn_dcb_chain_t *dcb_chain, *dcb_chain_end; unsigned long flags; - int chan = API_RX_CHAN; - dma_addr_t dcb_dma; + int chan; + uint64_t dcb_dma; int woffset; kmsg->hdr.type = KCOM_MSG_TYPE_RSP; @@ -5362,10 +6095,9 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) dcb_chain->dcb_cnt = kmsg->dma_info.cnt; dcb_chain->dcb_dma = kmsg->dma_info.data.dcb_start; dcb_chain->dcb_mem = kernel_bde->p2l(sinfo->dev_no, - dcb_chain->dcb_dma); + (sal_paddr_t)dcb_chain->dcb_dma); if (kmsg->dma_info.type == KCOM_DMA_INFO_T_TX_DCB) { - spin_lock_irqsave(&sinfo->lock, flags); /* Hold back packets from kernel */ @@ -5376,8 +6108,12 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) /* Handle for Continuous DMA mode */ if (CDMA_CH(sinfo, XGS_DMA_TX_CHAN)) { woffset = (dcb_chain->dcb_cnt - 1) * sinfo->dcb_wsize + 1; + if (sinfo->cmic_type == 'x') { + woffset += 1; + } if ((dcb_chain->dcb_mem[woffset] & ((1 << 18) | (1 << 16))) != 0x50000) { - gprintk("No suitable API DCB chain for Continuous DMA mode\n"); + gprintk("Not suitable API DCB chain for Continuous DMA mode\n"); + list_del(&dcb_chain->list); kfree(dcb_chain); kmsg->hdr.status = KCOM_E_PARAM; spin_unlock_irqrestore(&sinfo->lock, flags); @@ -5388,6 +6124,9 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) /* Stitch this chain */ woffset = (dcb_chain_end->dcb_cnt - 1) * sinfo->dcb_wsize; dcb_chain_end->dcb_mem[woffset] = dcb_chain->dcb_dma; + if (sinfo->cmic_type == 'x') { + dcb_chain_end->dcb_mem[woffset + 1] = DMA_TO_BUS_HI(dcb_chain->dcb_dma >> 32); + } } sinfo->tx.api_dcb_chain_end = dcb_chain; if (sinfo->tx.api_active) { @@ -5406,18 +6145,29 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) } spin_unlock_irqrestore(&sinfo->lock, flags); - } else if (kmsg->dma_info.type == KCOM_DMA_INFO_T_RX_DCB) { - spin_lock_irqsave(&sinfo->lock, flags); + chan = kmsg->dma_info.chan - 1; + if ((chan < 0) || (chan > sinfo->rx_chans)) { + gprintk("Invalid RX DMA channel specified: %d\n", + kmsg->dma_info.chan); + kmsg->hdr.status = KCOM_E_PARAM; + spin_unlock_irqrestore(&sinfo->lock, flags); + return sizeof(kcom_msg_hdr_t); + } + list_add_tail(&dcb_chain->list, &sinfo->rx[chan].api_dcb_list); /* Handle for Continuous DMA mode */ if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { woffset = (dcb_chain->dcb_cnt - 1) * sinfo->dcb_wsize + 1; + if (sinfo->cmic_type == 'x') { + woffset += 1; + } if ((dcb_chain->dcb_mem[woffset] & ((1 << 18) | (1 << 16))) != 0x50000) { - gprintk("No suitable API DCB chain for Continuous DMA mode\n"); + gprintk("Not suitable API DCB chain for Continuous DMA mode\n"); + list_del(&dcb_chain->list); kfree(dcb_chain); kmsg->hdr.status = KCOM_E_PARAM; spin_unlock_irqrestore(&sinfo->lock, flags); @@ -5428,6 +6178,9 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) /* Stitch this chain */ woffset = (dcb_chain_end->dcb_cnt - 1) * sinfo->dcb_wsize; dcb_chain_end->dcb_mem[woffset] = dcb_chain->dcb_dma; + if (sinfo->cmic_type == 'x') { + dcb_chain_end->dcb_mem[woffset + 1] = DMA_TO_BUS_HI(dcb_chain->dcb_dma >> 32); + } } sinfo->rx[chan].api_dcb_chain_end = dcb_chain; if (!sinfo->rx[chan].use_rx_skb) { @@ -5440,11 +6193,22 @@ bkn_knet_dma_info(kcom_msg_dma_info_t *kmsg, int len) } if (sinfo->rx[chan].api_active == 0) { - bkn_api_rx_restart(sinfo); + bkn_api_rx_restart(sinfo, chan); + /* Resume SKB Rx due to refilled API resources */ + if (sinfo->rx[chan].use_rx_skb && sinfo->rx[chan].api_wait) { + sinfo->rx[chan].api_wait = 0; + if (CDMA_CH(sinfo, XGS_DMA_RX_CHAN + chan)) { + bkn_do_skb_rx(sinfo, chan, 1); + } else { + bkn_do_skb_rx(sinfo, chan, MAX_RX_DCBS); + if (sinfo->rx[chan].chain_complete) { + bkn_rx_chain_done(sinfo, chan); + } + } + } } spin_unlock_irqrestore(&sinfo->lock, flags); - } else { DBG_DCB(("Unknown DCB_INFO type (%d).\n", kmsg->dma_info.type)); kfree(dcb_chain); @@ -5463,7 +6227,7 @@ bkn_create_inst(uint32 inst_id) int i, evt_idx = -1; /* multiple instance mode */ - for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i ++) { + for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i++) { evt = &_bkn_evt[i]; if (evt->inst_id == inst_id) { evt_idx = i; @@ -5484,7 +6248,7 @@ bkn_create_inst(uint32 inst_id) DBG_WARN(("Run out the event queue resource !\n")); return -1; } - for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i ++) { + for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i++) { if (inst_id & (1 << i)) { sinfo = bkn_sinfo_from_unit(i); spin_lock_irqsave(&sinfo->lock, flags); @@ -5505,6 +6269,7 @@ bkn_knet_dev_reprobe(void) { bkn_switch_info_t *sinfo; int i; + for (i = 0; i < kernel_bde->num_devices(BDE_ALL_DEVICES); i++) { sinfo = bkn_sinfo_from_unit(i); if (sinfo == NULL ) { @@ -5544,7 +6309,7 @@ bkn_knet_dev_inst_set(kcom_msg_version_t *kmsg) spin_unlock_irqrestore(&sinfo->lock, flags); if (inst) { - if (sinfo->inst_id == 0){ + if (sinfo->inst_id == 0) { if (bkn_create_inst(inst) != 0) { return -1; } @@ -5569,8 +6334,8 @@ static int bkn_knet_version(kcom_msg_version_t *kmsg, int len) { /* Support pci hot plug and multiple instance */ - if ((bkn_knet_dev_reprobe() < 0) || - (bkn_knet_dev_inst_set(kmsg) < 0)){ + if ((bkn_knet_dev_reprobe() < 0) || + (bkn_knet_dev_inst_set(kmsg) < 0)) { kmsg->hdr.status = KCOM_E_RESOURCE; return sizeof(kcom_msg_version_t); } @@ -5609,7 +6374,7 @@ bkn_knet_hw_reset(kcom_msg_hw_reset_t *kmsg, int len) bkn_dma_abort_tx(sinfo); bkn_clean_tx_dcbs(sinfo); } - for (chan = 0; chan < NUM_RX_CHAN; chan++) { + for (chan = 0; chan < sinfo->rx_chans; chan++) { if (kmsg->channels & (1 << (XGS_DMA_RX_CHAN + chan))) { bkn_dma_abort_rx(sinfo, chan); bkn_clean_rx_dcbs(sinfo, chan); @@ -5626,6 +6391,7 @@ static int bkn_knet_hw_init(kcom_msg_hw_init_t *kmsg, int len) { bkn_switch_info_t *sinfo; + uint32_t dev_type; unsigned long flags; kmsg->hdr.type = KCOM_MSG_TYPE_RSP; @@ -5640,18 +6406,37 @@ bkn_knet_hw_init(kcom_msg_hw_init_t *kmsg, int len) spin_lock_irqsave(&sinfo->lock, flags); + sinfo->cmic_type = kmsg->cmic_type; + sinfo->dcb_type = kmsg->dcb_type; + sinfo->dcb_wsize = BYTES2WORDS(kmsg->dcb_size); + sinfo->pkt_hdr_size = kmsg->pkt_hdr_size; + sinfo->dma_hi = kmsg->dma_hi; + sinfo->rx_chans = sinfo->cmic_type == 'x' ? NUM_CMICX_RX_CHAN : NUM_CMICM_RX_CHAN; + if (sinfo->rx_chans > NUM_RX_CHAN) { + sinfo->rx_chans = NUM_RX_CHAN; + } + /* Config Continuous DMA mode */ - sinfo->cdma_channels = kmsg->cdma_channels; + sinfo->cdma_channels = kmsg->cdma_channels & ~(~0 << (sinfo->rx_chans + 1)); + + /* Ensure 32-bit PCI DMA is mapped properly on 64-bit platforms */ + dev_type = kernel_bde->get_dev_type(sinfo->dev_no); + if (dev_type & BDE_PCI_DEV_TYPE && sinfo->cmic_type != 'x') { + if (pci_set_dma_mask(sinfo->pdev, 0xffffffff)) { + spin_unlock_irqrestore(&sinfo->lock, flags); + gprintk("No suitable DMA available for SKBs\n"); + kmsg->hdr.status = KCOM_E_RESOURCE; + return sizeof(kcom_msg_hdr_t); + } + } /* First time called we need to allocate DCBs */ - sinfo->dcb_type = kmsg->dcb_type; - sinfo->dcb_wsize = BYTES2WORDS(kmsg->dcb_size); if (sinfo->dcb_mem == NULL) { if (bkn_alloc_dcbs(sinfo) < 0) { + spin_unlock_irqrestore(&sinfo->lock, flags); kmsg->hdr.status = KCOM_E_RESOURCE; return sizeof(kcom_msg_hdr_t); } - bkn_init_dcbs(sinfo); } /* Ensure that we restart properly */ @@ -5664,6 +6449,16 @@ bkn_knet_hw_init(kcom_msg_hw_init_t *kmsg, int len) } } + /* Ensure all interrupts are disabled, e.g. if warmbooting */ + dev_irq_mask_set(sinfo, 0); + + /* Register interrupt handler */ + kernel_bde->interrupt_connect(sinfo->dev_no | LKBDE_ISR2_DEV, + bkn_isr, sinfo); + + /* Init DCBs */ + bkn_init_dcbs(sinfo); + bkn_dma_init(sinfo); spin_unlock_irqrestore(&sinfo->lock, flags); @@ -6179,6 +6974,47 @@ bkn_knet_dbg_pkt_get(kcom_msg_dbg_pkt_get_t *kmsg, int len) return sizeof(kcom_msg_dbg_pkt_get_t); } +static int +bkn_knet_wb_cleanup(kcom_msg_wb_cleanup_t *kmsg, int len) +{ + bkn_switch_info_t *sinfo; + bkn_dcb_chain_t *dcb_chain; + unsigned long flags; + int chan; + + 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); + } + + spin_lock_irqsave(&sinfo->lock, flags); + + for (chan = 0; chan < sinfo->rx_chans; chan++) { + if (sinfo->rx[chan].api_dcb_chain) { + DBG_DCB_RX(("Freeing active Rx%d DCB chain.\n", chan)); + kfree(sinfo->rx[chan].api_dcb_chain); + sinfo->rx[chan].api_dcb_chain = NULL; + } + while (!list_empty(&sinfo->rx[chan].api_dcb_list)) { + dcb_chain = list_entry(sinfo->rx[chan].api_dcb_list.next, + bkn_dcb_chain_t, list); + list_del(&dcb_chain->list); + DBG_DCB_RX(("Freeing Rx%d DCB chain.\n", chan)); + kfree(dcb_chain); + } + sinfo->rx[chan].api_dcb_chain_end = NULL; + sinfo->rx[chan].api_active = 0; + sinfo->rx[chan].api_wait = 0; + } + + spin_unlock_irqrestore(&sinfo->lock, flags); + + return sizeof(kcom_msg_hdr_t); +} + static int bkn_handle_cmd_req(kcom_msg_t *kmsg, int len) { @@ -6269,6 +7105,11 @@ bkn_handle_cmd_req(kcom_msg_t *kmsg, int len) /* Get debugging packet function info */ len = bkn_knet_dbg_pkt_get(&kmsg->dbg_pkt_get, len); break; + case KCOM_M_WB_CLEANUP: + DBG_CMD(("KCOM_M_WB_CLEANUP\n")); + /* Clean up for warmbooting */ + len = bkn_knet_wb_cleanup(&kmsg->wb_cleanup, len); + break; default: DBG_WARN(("Unsupported command (type=%d, opcode=%d)\n", kmsg->hdr.type, kmsg->hdr.opcode)); @@ -6344,7 +7185,7 @@ bkn_get_next_dma_event(kcom_msg_dma_info_t *kmsg) } if (sinfo && (sinfo->inst_id != 0) && - ((sinfo->inst_id & (1 << dev_evt)) == 0)) { + ((sinfo->inst_id & (1 << dev_evt)) == 0)) { DBG_INST((" %s skip dev(%d)\n",__FUNCTION__,dev_evt)); continue; } @@ -6364,7 +7205,7 @@ bkn_get_next_dma_event(kcom_msg_dma_info_t *kmsg) if (dev_no == last_dev_no) { DBG_INST(("wait queue index %d\n",sinfo->evt_idx)); - wait_event_interruptible(evt->evt_wq, + wait_event_interruptible(evt->evt_wq, evt->evt_wq_get != evt->evt_wq_put); DBG_VERB(("Event thread wakeup\n")); @@ -6431,7 +7272,7 @@ _cleanup(void) bkn_thread_stop(&bkn_cmd_ctrl); /* Remove KCOM channel */ - PROXY_SERVICE_DESTROY(KCOM_CHAN_KNET); + PROXY_SERVICE_DESTROY(KCOM_CHAN_KNET); bkn_proc_cleanup(); remove_proc_entry("bcm/knet", NULL); @@ -6464,11 +7305,11 @@ _cleanup(void) /* Destroy all switch devices */ while (!list_empty(&_sinfo_list)) { - sinfo = list_entry(_sinfo_list.next, bkn_switch_info_t, list); + sinfo = list_entry(_sinfo_list.next, bkn_switch_info_t, list); /* Destroy all associated Rx packet filters */ while (!list_empty(&sinfo->rxpf_list)) { - filter = list_entry(sinfo->rxpf_list.next, bkn_filter_t, list); + filter = list_entry(sinfo->rxpf_list.next, bkn_filter_t, list); list_del(&filter->list); DBG_VERB(("Removing filter ID %d.\n", filter->kf.id)); kfree(filter); @@ -6476,7 +7317,7 @@ _cleanup(void) /* Destroy all associated virtual net devices */ while (!list_empty(&sinfo->ndev_list)) { - priv = list_entry(sinfo->ndev_list.next, bkn_priv_t, list); + priv = list_entry(sinfo->ndev_list.next, bkn_priv_t, list); list_del(&priv->list); dev = priv->dev; DBG_VERB(("Removing virtual Ethernet device %s.\n", dev->name)); @@ -6499,14 +7340,13 @@ _cleanup(void) } return 0; -} +} static int bkn_knet_dev_reinit(int d) { bkn_switch_info_t *sinfo; uint32 dev_state; - uint32_t dev_type; unsigned long flags; if (lkbde_dev_state_get(d, &dev_state) < 0) { @@ -6519,26 +7359,8 @@ bkn_knet_dev_reinit(int d) sinfo->base_addr = lkbde_get_dev_virt(d); sinfo->dma_dev = lkbde_get_dma_dev(d); sinfo->pdev = lkbde_get_hw_dev(d); - - dev_type = kernel_bde->get_dev_type(d); - /* Ensure 32-bit PCI DMA is mapped properly on 64-bit platforms */ - if (dev_type & BDE_PCI_DEV_TYPE) { - if (pci_set_dma_mask(sinfo->pdev, 0xffffffff)) { - gprintk("No suitable DMA available for SKBs\n"); - _cleanup(); - return -1; - } - } - dev_irq_mask_set(sinfo, 0); spin_unlock_irqrestore(&sinfo->lock, flags); - gprintk("Unregister ISR.\n"); - kernel_bde->interrupt_disconnect(sinfo->dev_no | LKBDE_ISR2_DEV); - - /* Register interrupt handler */ - kernel_bde->interrupt_connect(sinfo->dev_no | LKBDE_ISR2_DEV, - bkn_isr, sinfo); - dev_state = 0; lkbde_dev_state_set(d, dev_state); } @@ -6586,14 +7408,7 @@ bkn_knet_dev_init(int d) _cleanup(); return -ENOMEM; } - /* Ensure 32-bit PCI DMA is mapped properly on 64-bit platforms */ - if (dev_type & BDE_PCI_DEV_TYPE) { - if (pci_set_dma_mask(sinfo->pdev, 0xffffffff)) { - gprintk("No suitable DMA available for SKBs\n"); - _cleanup(); - return -EIO; - } - } + /* Initialize the cpu_no.*/ if (dev_type & BDE_AXI_DEV_TYPE) { /* AXI device type implies the activated iProc iHost */ @@ -6608,13 +7423,6 @@ bkn_knet_dev_init(int d) sinfo->rcpu_sig = rcpu_signature; } - /* Ensure all interrupts are disabled, e.g. if warmbooting */ - dev_irq_mask_set(sinfo, 0); - - /* Register interrupt handler */ - kernel_bde->interrupt_connect(sinfo->dev_no | LKBDE_ISR2_DEV, - bkn_isr, sinfo); - /* Create base virtual net device */ bkn_dev_mac[5]++; if ((dev = bkn_init_ndev(bkn_dev_mac, bdev_name)) == NULL) { @@ -6701,7 +7509,7 @@ _init(void) init_waitqueue_head(&evt->evt_wq); if (use_proxy) { - PROXY_SERVICE_CREATE(KCOM_CHAN_KNET, 1, 0); + PROXY_SERVICE_CREATE(KCOM_CHAN_KNET, 1, 0); DBG_VERB(("Starting command thread\n")); bkn_thread_start(&bkn_cmd_ctrl, "bkncmd", bkn_cmd_thread); @@ -6715,10 +7523,10 @@ _init(void) return 0; } -static int +static int _ioctl(unsigned int cmd, unsigned long arg) { - bkn_ioctl_t io; + bkn_ioctl_t io; kcom_msg_t kmsg; if (!module_initialized) { @@ -6734,7 +7542,7 @@ _ioctl(unsigned int cmd, unsigned long arg) } io.rc = 0; - + switch(cmd) { case 0: if (io.len > 0) { @@ -6747,7 +7555,7 @@ _ioctl(unsigned int cmd, unsigned long arg) } else { memset(&kmsg, 0, sizeof(kcom_msg_dma_info_t)); /* - * Retrive the kmsg.hdr.unit from user space. The dma event queue + * Retrive the kmsg.hdr.unit from user space. The dma event queue * selection is based the instance derived from unit. */ if (copy_from_user(&kmsg, (void *)(unsigned long)io.buf, sizeof(kmsg))) { @@ -6779,17 +7587,17 @@ _ioctl(unsigned int cmd, unsigned long arg) } static gmodule_t _gmodule = { - name: MODULE_NAME, - major: MODULE_MAJOR, + name: MODULE_NAME, + major: MODULE_MAJOR, init: _init, - cleanup: _cleanup, - pprint: _pprint, + cleanup: _cleanup, + pprint: _pprint, ioctl: _ioctl, - open: NULL, - close: NULL, -}; + open: NULL, + close: NULL, +}; -gmodule_t* +gmodule_t * gmodule_get(void) { EXPORT_NO_SYMBOLS; 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 277ea741525a..760690b3fb9d 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: bcm-knet.h,v 1.4 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h index a0deac1bae08..22cef82a8ddc 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/include/gmodule.h @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: gmodule.h,v 1.9 Broadcom SDK $ 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 eb0077f2573b..d1977076850b 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: lkm.h,v 1.22 Broadcom SDK $ 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 ecabf0ae8e26..d7ca56cd5701 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 @@ -1,22 +1,21 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- -# $Id: -# $Copyright: (c) 2017 Broadcom Corp. +# $Id: Makefile,v 1.3 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. # All Rights Reserved.$ # LOCALDIR = systems/linux/kernel/modules/knet-cb 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 30fba8750ed3..da221f9f453a 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 @@ -1,21 +1,20 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* - * $Id: + * $Id: $ * $Copyright: (c) 2017 Broadcom Corp. * All Rights Reserved.$ */ @@ -50,6 +49,13 @@ MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom Linux KNET Call-Back Driver"); MODULE_LICENSE("GPL"); + +static int debug; +LKM_MOD_PARAM(debug, "i", int, 0); +MODULE_PARM_DESC(debug, +"Debug level (default 0)"); + + /* Module Information */ #define MODULE_MAJOR 121 #define MODULE_NAME "linux-knet-cb" @@ -57,6 +63,9 @@ MODULE_LICENSE("GPL"); /* set KNET_CB_DEBUG for debug info */ #define KNET_CB_DEBUG +#define FILTER_TAG_STRIP 0 +#define FILTER_TAG_KEEP 1 + /* Maintain tag strip statistics */ struct strip_stats_s { unsigned long stripped; /* Number of packets that have been stripped */ @@ -113,63 +122,84 @@ get_tag_status(int dcb_type, void *meta) uint32 *dcb = (uint32 *) meta; int tag_status; switch (dcb_type) { - case 14: - case 19: - case 20: - case 21: - case 22: - case 30: - tag_status = (dcb[12] > 10) & 0x3; - break; - case 23: - case 29: - case 31: - case 34: - case 37: - case 26: - case 32: - case 33: - case 35: - tag_status = dcb[13] & 0x3; - break; - default: - tag_status = -1; - break; + case 14: + case 19: + case 20: + case 21: + case 22: + case 30: + tag_status = (dcb[12] > 10) & 0x3; + break; + case 23: + case 29: + case 31: + case 34: + case 37: + case 26: + case 32: + case 33: + case 35: + tag_status = dcb[13] & 0x3; + break; + case 36: + /* TD3 */ + tag_status = ((dcb[13] >> 9) & 0x3); + break; + break; + case 38: + { + /* untested */ + /* TH3 only parses outer tag. */ + const int tag_map[4] = { 0, 2, -1, -1 }; + tag_status = tag_map[(dcb[9] >> 13) & 0x3]; + } + break; + default: + tag_status = -1; + break; + } +#ifdef KNET_CB_DEBUG + if (debug & 0x1) { + gprintk("%s; DCB Type: %d; tag status: %d\n", __func__, dcb_type, tag_status); } +#endif return tag_status; } -/* - * SDK-134189 added the ability to pass two 4 byte unsigned values to the - * KNET callback function, one from the matching filter and one from the - * network interface. The usage of this data is completely defined by the - * user. In this case, if bit 0 of the interface value is set, tag stripping - * is enabled for that interface. When creating the interface and filter, - * something like the following is necessary: "netif.cb_user_data = uflags". - */ -#define NETIF_UNTAGGED_STRIP (1 << 0) - /* Rx packet callback function */ static struct sk_buff * strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *meta) { unsigned netif_flags = KNET_SKB_CB(skb)->netif_user_data; + unsigned filter_flags = KNET_SKB_CB(skb)->filter_user_data; unsigned dcb_type; int tag_status; + unsigned int strip_tag = 0; /* Currently not using filter flags: * unsigned filter_flags = KNET_SKB_CB(skb)->filter_user_data; */ #ifdef KNET_CB_DEBUG - gprintk("%s Enter; Flags: %08X\n", __func__, netif_flags); + if (debug & 0x1) { + gprintk("%s Enter; netif Flags: %08X filter_flags %08X \n", + __func__, netif_flags, filter_flags); + } #endif - if ((netif_flags & NETIF_UNTAGGED_STRIP) == 0) { - /* Untagged stripping not enabled on this netif */ + /* KNET implements this already */ + if (filter_flags == FILTER_TAG_KEEP) + { strip_stats.skipped++; return skb; } + /* SAI strip implies always strip. If the packet is untagged or + inner taged, SDK adds a .1q tag, so we need to strip tag + anyway */ + if (filter_flags == FILTER_TAG_STRIP) + { + strip_tag = 1; + } /* Get DCB type for this packet, passed by KNET driver */ dcb_type = KNET_SKB_CB(skb)->dcb_type; @@ -177,7 +207,9 @@ strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *meta) tag_status = get_tag_status(dcb_type, meta); #ifdef KNET_CB_DEBUG - gprintk("%s; DCB Type: %d; tag status: %d\n", __func__, dcb_type, tag_status); + if (debug & 0x1) { + gprintk("%s; DCB Type: %d; tag status: %d\n", __func__, dcb_type, tag_status); + } #endif if (tag_status < 0) { @@ -186,22 +218,24 @@ strip_tag_rx_cb(struct sk_buff *skb, int dev_no, void *meta) } strip_stats.checked++; - /* - * Untagged and inner tagged packet will get a new tag from the switch - * device, we need to strip this off. - */ - if (tag_status < 2) { + + if (strip_tag) { #ifdef KNET_CB_DEBUG - gprintk("%s; Stripping VLAN\n", __func__); + if (debug & 0x1) { + gprintk("%s; Stripping VLAN\n", __func__); + } #endif strip_stats.stripped++; strip_vlan_tag(skb); } #ifdef KNET_CB_DEBUG else { - gprintk("%s; Preserve VLAN\n", __func__); + if (debug & 0x1) { + gprintk("%s; Preserve VLAN\n", __func__); + } } #endif + return skb; } @@ -216,7 +250,7 @@ strip_tag_tx_cb(struct sk_buff *skb, int dev_no, void *meta) /* Filter callback not used */ static int strip_tag_filter_cb(uint8_t * pkt, int size, int dev_no, void *meta, - int chan, kcom_filter_t *kf) + int chan, kcom_filter_t *kf) { /* Pass through for now */ return 0; diff --git a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile index 4c420c07ecdd..5e97a3a32123 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/kernel/modules/shared/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.2 Broadcom SDK $ 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 a72a54ef1c69..cdfaf089674a 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: gmodule.c,v 1.20 Broadcom SDK $ 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 1ed0416f02c9..d1caf871f0e2 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 @@ -1,18 +1,17 @@ /* - * Unless you and Broadcom execute a separate written software license - * agreement governing use of this software, this software is licensed to - * you under the terms of the GNU General Public License version 2 (the - * "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, - * with the following added to such license: + * Copyright 2017 Broadcom * - * As a special exception, the copyright holders of this software give - * you permission to link this software with independent modules, and to - * copy and distribute the resulting executable under terms of your - * choice, provided that you also meet, for each linked independent - * module, the terms and conditions of the license of that module. An - * independent module is a module which is not derived from this - * software. The special exception does not apply to any modifications - * of the software. + * 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 (the "GPL"). + * + * 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 version 2 (GPLv2) for more details. + * + * You should have received a copy of the GNU General Public License + * version 2 (GPLv2) along with this source code. */ /* * $Id: ksal.c,v 1.1 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/bmw-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/bmw-2_6/Makefile new file mode 100644 index 000000000000..899c7b405374 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/bmw-2_6/Makefile @@ -0,0 +1,63 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.4 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# PPC_TOOLS_DIR - path to build tools (if not in PATH already) +# PPC_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +override kernel_version=2_6 +platform=bmw-$(kernel_version) + +# Windriver linux version +#WRS_LINUX_VERSION=1.4 +#WRS_LINUX_VERSION=2.0 + +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile index f78ed606aa63..0e6226544334 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/common/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.4 Broadcom SDK $ @@ -86,12 +85,12 @@ KERNEL_BDE :=$(DEST_DIR)/$(KERNEL_BDE_LOCAL) USER_BDE_LOCAL :=linux-user-bde.$(KOBJ) USER_BDE=$(DEST_DIR)/$(USER_BDE_LOCAL) -BCM_KNET_LOCAL :=linux-bcm-knet.$(KOBJ) -BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL) - KNET_CB_LOCAL := linux-knet-cb.$(KOBJ) KNET_CB := $(DEST_DIR)/$(KNET_CB_LOCAL) +BCM_KNET_LOCAL :=linux-bcm-knet.$(KOBJ) +BCM_KNET=$(DEST_DIR)/$(BCM_KNET_LOCAL) + ifeq (,$(findstring DELIVER,$(MAKECMDGOALS))) .DEFAULT_GOAL := all all_targets := kernel_modules $(KERNEL_BDE) $(USER_BDE) @@ -118,11 +117,7 @@ LOCAL_TARGETS +=$(patsubst %,../$(platform)/%,$(BCM_KNET_LOCAL)) all_targets +=$(LOCAL_TARGETS) endif -ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include -COND_KNET_LIBS = libuser.$(libext) - -ifeq ($(BUILD_KNET_CB),1) -# KNET callback module support +ifdef BUILD_KNET_CB all_targets += $(KNET_CB) ifeq ($(NO_LOCAL_TARGETS),) @@ -131,9 +126,11 @@ all_targets +=$(LOCAL_TARGETS) endif endif +ADD_TO_CFLAGS += -I$(SDK)/systems/linux/kernel/modules/include +COND_KNET_LIBS = libuser.$(libext) endif -#OPENNSL_FIXUP +#SAI_FIXUP .NOTPARALLEL: all: $(BLDDIR)/.tree $(all_targets) @@ -152,24 +149,20 @@ ADD_TO_CFLAGS += -I$(SDK)/systems/bde/linux/include ADD_TO_CFLAGS += -DPROXY_SUPPORT=0 CFLAGS += $(ADD_TO_CFLAGS) +#SAI_FIXUP +CFLAGS:=$(filter-out -fPIC, $(CFLAGS)) -# Kernel network support -ifdef BUILD_KNET - -knet_subdirs = shared bcm-knet - -ifdef BUILD_KNET_CB -knet_subdirs += knet-cb -endif - -endif # BUILD_KNET kernel_modules: $(MAKE) -C $(SDK)/systems/bde/linux/kernel kernel_version=$(kernel_version) $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel kernel_version=$(kernel_version) ifeq ($(BUILD_KNET),1) $(MAKE) -j1 -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ - subdirs="$(knet_subdirs)" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" + subdirs="shared bcm-knet" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" +ifdef BUILD_KNET_CB + $(MAKE) -j1 -C $(SDK)/systems/linux/kernel/modules kernel_version=$(kernel_version) \ + subdirs="knet-cb" override-target=linux-$(platform) CFLAGS="$(CFLAGS)" +endif endif $(KERNEL_BDE): $(KERN_BLDROOT)/linux-kernel-bde.$(KOBJ) @@ -193,14 +186,14 @@ clean:: $(MAKE) -C $(SDK)/systems/bde/linux/kernel $@ $(MAKE) -C $(SDK)/systems/bde/linux/user/kernel $@ $(MAKE) -C $(SDK)/systems/linux/kernel/modules \ - subdirs="$(knet_subdirs)" \ + subdirs="shared bcm-knet knet-cb" \ override-target=linux-$(platform) $@ $(RM) $(KERNEL_BDE) $(USER_BDE) - $(RM) $(BCM_KNET) - $(RM) $(KNET_CB) + $(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) + $(RM) $(KERN_BLDROOT)/linux-knet-cb.$(KOBJ) $(RM) $(LOCAL_TARGETS) distclean:: clean diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/gto-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/gto-2_6/Makefile index 08f37e51c637..c157f9ff35fc 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/gto-2_6/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/gto-2_6/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.9 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/gto/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/gto/Makefile index 8e3422cd18d8..fd98f6d2f963 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/gto/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/gto/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.9 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile index c2081e42dc33..c9f538802f6d 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc-3_14/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile index 7eef55d448fd..7a8b4a8b0c4d 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/iproc/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.7 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/jag-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/jag-2_6/Makefile new file mode 100644 index 000000000000..26a7f520f2d2 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/jag-2_6/Makefile @@ -0,0 +1,79 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.4 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +override kernel_version=2_6 +platform=jag-$(kernel_version) + +# Select the build environment +#BUILD_PLATFORM=ELDK +#BUILD_PLATFORM=WR_LINUX + +#Select the LINUX KERNEL VERSION +#KERN_VER = 2.6.21.7 + + +# Select the ELDK version +#ELDK_VERSION=4.1 + +# Windriver linux version +#WRS_LINUX_VERSION=1.4 +#WRS_LINUX_VERSION=2.0 + +export KERN_VER +export ELDK_VERSION +export BUILD_PLATFORM +export WRS_LINUX_VERSION + +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/nsx-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/nsx-2_6/Makefile new file mode 100644 index 000000000000..881ec34c2d36 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/nsx-2_6/Makefile @@ -0,0 +1,58 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.4 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +override kernel_version=2_6 +platform=nsx-$(kernel_version) +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/nsx64/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/nsx64/Makefile new file mode 100644 index 000000000000..9e79d90fa992 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/nsx64/Makefile @@ -0,0 +1,57 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.3 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +platform=nsx64 +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/nsx_wrl-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/nsx_wrl-2_6/Makefile new file mode 100644 index 000000000000..4e86843cdc7c --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/nsx_wrl-2_6/Makefile @@ -0,0 +1,65 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.3 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +override kernel_version=2_6 +platform=nsx_wrl-$(kernel_version) + +# Windriver linux version +#WRS_LINUX_VERSION=1.4 +#WRS_LINUX_VERSION=2.0 + +export WRS_LINUX_VERSION + +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/raptor-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/raptor-2_6/Makefile new file mode 100644 index 000000000000..10ab1a1cc259 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/raptor-2_6/Makefile @@ -0,0 +1,79 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.5 Broadcom SDK $ +# $Copyright: (c) 2007 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +override kernel_version=2_6 +platform=raptor-$(kernel_version) + +# Select the build environment +#BUILD_PLATFORM=ELDK +#BUILD_PLATFORM=WR_LINUX + +#Select the LINUX KERNEL VERSION +#KERN_VER = 2.6.21.7 + + +# Select the ELDK version +#ELDK_VERSION=4.1 + +# Windriver linux version +#WRS_LINUX_VERSION=1.4 +#WRS_LINUX_VERSION=2.0 + +export KERN_VER +export ELDK_VERSION +export BUILD_PLATFORM +export WRS_LINUX_VERSION + +LINUX_MAKE_USER=1 +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/raptor/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/raptor/Makefile new file mode 100644 index 000000000000..df8800a1a786 --- /dev/null +++ b/platform/broadcom/saibcm-modules/systems/linux/user/raptor/Makefile @@ -0,0 +1,58 @@ +# +# Copyright 2017 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 +# published by the Free Software Foundation (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. +# +# -*- Makefile -*- +# $Id: Makefile,v 1.1 Broadcom SDK $ +# $Copyright: (c) 2005 Broadcom Corp. +# All Rights Reserved.$ + +# +# This make job requires the following environment variables to be set: +# +# SDK - path to StrataXGS SDK root directory +# +# Optionally the following environment variables can be set to +# override the default build server configuration: +# +# MIPS_TOOLS_DIR - path to build tools (if not in PATH already) +# MIPS_CROSS_COMPILE - cross compile tools prefix +# LINUX_INCLUDE - path to Linux kernel include directory +# + +SDK :=$(shell if [ -n "$$SDK" ] ; then\ + echo $$SDK;\ + else\ + cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \ + dir=`cd ../;pwd`; \ + if [ "$$dir" = "/" ] ; then \ + echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2; \ + exit 1; \ + fi ; \ + cd $$dir; \ + done ; \ + pwd; \ + fi) + +ifeq ($(SDK),) +$(error Please run this in a tree) +endif + +export SDK + +platform=raptor +LINUX_MAKE_USER=1 +CFGFLAGS += -DBCM_ICS +include ${SDK}/make/Make.linux + diff --git a/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile b/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile index bb5408536a3d..29717b3af42a 100644 --- a/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile +++ b/platform/broadcom/saibcm-modules/systems/linux/user/x86-smp_generic_64-2_6/Makefile @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # -*- Makefile -*- # $Id: Makefile,v 1.2 Broadcom SDK $ diff --git a/platform/broadcom/saibcm-modules/tools/mktool.pl b/platform/broadcom/saibcm-modules/tools/mktool.pl index 96bff14ecdc8..8800c00613d8 100644 --- a/platform/broadcom/saibcm-modules/tools/mktool.pl +++ b/platform/broadcom/saibcm-modules/tools/mktool.pl @@ -1,18 +1,17 @@ # -# Unless you and Broadcom execute a separate written software license -# agreement governing use of this software, this software is licensed to -# you under the terms of the GNU General Public License version 2 (the -# "GPL"), available at http://www.broadcom.com/licenses/GPLv2.php, -# with the following added to such license: +# Copyright 2017 Broadcom # -# As a special exception, the copyright holders of this software give -# you permission to link this software with independent modules, and to -# copy and distribute the resulting executable under terms of your -# choice, provided that you also meet, for each linked independent -# module, the terms and conditions of the license of that module. An -# independent module is a module which is not derived from this -# software. The special exception does not apply to any modifications -# of the software. +# 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 (the "GPL"). +# +# 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 version 2 (GPLv2) for more details. +# +# You should have received a copy of the GNU General Public License +# version 2 (GPLv2) along with this source code. # # # mktool.pl